|
|
|
@ -8,6 +8,10 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.hzya.frame.basedao.service.impl.BaseService;
|
|
|
|
|
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.dao.IGbiZbsyrecDao;
|
|
|
|
|
import com.hzya.frame.grpU8.nxproof.gbizbsyrec.entity.GbiZbsyrecEntity;
|
|
|
|
|
import com.hzya.frame.grpU8.nxproof.gbizbxmb.dao.IGbiZbxmbDao;
|
|
|
|
|
import com.hzya.frame.grpU8.nxproof.gbizbxmb.entity.GbiZbxmbEntity;
|
|
|
|
|
import com.hzya.frame.grpU8.nxproof.glPzml.dao.ISenderGlPzmlDao;
|
|
|
|
|
import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
|
|
|
|
|
import com.hzya.frame.grpU8.nxproof.glPzml.service.ISenderGlPzmlService;
|
|
|
|
@ -22,10 +26,13 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import static org.aspectj.runtime.internal.Conversions.doubleValue;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* (GlPzml)表服务实现类
|
|
|
|
@ -41,6 +48,9 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
|
|
|
|
|
|
|
|
|
|
private ISenderGlPzmlDao senderGlPzmlDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IGbiZbxmbDao gbiZbxmbDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
public void setSenderGlPzmlDao(ISenderGlPzmlDao dao) {
|
|
|
|
|
this.senderGlPzmlDao = dao;
|
|
|
|
@ -668,7 +678,8 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
|
|
|
|
|
|
|
|
|
|
//保存凭证 商学院,指标被哪些凭证使用
|
|
|
|
|
@Override
|
|
|
|
|
public Object saveGlPzmlSxy(JSONObject jsonObject){
|
|
|
|
|
public Object queryGlPzmlSxy(JSONObject json){
|
|
|
|
|
JSONObject jsonObject = json.getJSONObject("jsonStr");
|
|
|
|
|
SenderGlPzmlEntity glPzmlEntity = jsonObject.toJavaObject(SenderGlPzmlEntity.class);
|
|
|
|
|
if(StrUtil.isEmpty(glPzmlEntity.getKjqj())){
|
|
|
|
|
glPzmlEntity.setKjqj(DateUtil.format(new Date(),"yyyyMM"));
|
|
|
|
@ -679,29 +690,71 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
|
|
|
|
|
return BaseResult.getFailureMessageEntity("token为空,请先获取token");
|
|
|
|
|
}
|
|
|
|
|
//查询凭证数据
|
|
|
|
|
List<SenderGlPzmlEntity> pzmlEntities = senderGlPzmlDao.query(glPzmlEntity);
|
|
|
|
|
if(CollectionUtils.isEmpty(pzmlEntities)){
|
|
|
|
|
List<SenderGlPzmlEntity> list = senderGlPzmlDao.queryGlPzmlSxy(glPzmlEntity);
|
|
|
|
|
if(CollectionUtils.isEmpty(list)){
|
|
|
|
|
return BaseResult.getSuccessMessageEntity("没有需要同步得凭证",null);
|
|
|
|
|
}
|
|
|
|
|
for (SenderGlPzmlEntity pzmlEntity : pzmlEntities) {
|
|
|
|
|
String pzNum = pzmlEntity.getGsdm() + "_" + pzmlEntity.getZth() + "_" + pzmlEntity.getKjqj() + "_" + pzmlEntity.getPzh();
|
|
|
|
|
JSONObject jsonObjectParams=new JSONObject();
|
|
|
|
|
jsonObjectParams.put("code",pzmlEntity.getIdpzh());//pzid
|
|
|
|
|
jsonObjectParams.put("budgetYear",pzmlEntity.getKjqj().substring(0,4));//预算年度
|
|
|
|
|
jsonObjectParams.put("applyDate",DateUtil.format(new Date(),"yyyy-MM-dd"));//日期
|
|
|
|
|
jsonObjectParams.put("userCode","");//用户编码
|
|
|
|
|
jsonObjectParams.put("depCode","");//部门编码
|
|
|
|
|
jsonObjectParams.put("description",pzmlEntity.getPzzy());//说明
|
|
|
|
|
jsonObjectParams.put("amount",pzmlEntity.getPzje());//金额
|
|
|
|
|
jsonObjectParams.put("pzNum",pzNum);//凭证号 例如:公司代码+账套号+会计期间+凭证号:001_001_202408_付款_1
|
|
|
|
|
JSONArray jsonArray=new JSONArray();
|
|
|
|
|
jsonArray.add(jsonObjectParams);
|
|
|
|
|
JSONObject jsonObjectData=new JSONObject();
|
|
|
|
|
jsonObjectData.put("data",jsonArray);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String result=null;
|
|
|
|
|
for (SenderGlPzmlEntity pzmlEntity : list) {
|
|
|
|
|
String pzNum = pzmlEntity.getGsdm() + "_" + pzmlEntity.getZth() + "_" + pzmlEntity.getKjqj() + "_" + pzmlEntity.getPzh();
|
|
|
|
|
//转换日期,如将20240514转为2024-05-14
|
|
|
|
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Date date = inputFormat.parse(pzmlEntity.getSrrq());
|
|
|
|
|
String outputDateString = outputFormat.format(date);
|
|
|
|
|
//将金额四舍五入
|
|
|
|
|
BigDecimal bigDecimalValue = new BigDecimal(pzmlEntity.getPzje());
|
|
|
|
|
BigDecimal roundedValue = bigDecimalValue.setScale(2,
|
|
|
|
|
RoundingMode.HALF_UP);
|
|
|
|
|
JSONObject jsonObjectParams=new JSONObject();
|
|
|
|
|
jsonObjectParams.put("code",pzmlEntity.getIdpzh());//pzid
|
|
|
|
|
jsonObjectParams.put("budgetYear",pzmlEntity.getKjqj().substring(0,4));//预算年度
|
|
|
|
|
jsonObjectParams.put("applyDate",outputDateString);//日期
|
|
|
|
|
jsonObjectParams.put("userCode",pzmlEntity.getSrid());//用户编码
|
|
|
|
|
jsonObjectParams.put("depCode","A518");//部门编码
|
|
|
|
|
jsonObjectParams.put("description",pzmlEntity.getPzzy());//说明
|
|
|
|
|
jsonObjectParams.put("amount",roundedValue.doubleValue());//金额
|
|
|
|
|
jsonObjectParams.put("pzNum",pzNum);//凭证号 例如:公司代码+账套号+会计期间+凭证号:001_001_202408_付款_1
|
|
|
|
|
//根据idpzh查询指标id和指标金额
|
|
|
|
|
GbiZbxmbEntity gbiZbxmbEntity=new GbiZbxmbEntity();
|
|
|
|
|
gbiZbxmbEntity.setDjId(pzmlEntity.getIdpzh());
|
|
|
|
|
gbiZbxmbEntity.setKjnd(pzmlEntity.getKjqj().substring(0,4));
|
|
|
|
|
gbiZbxmbEntity.setDataSourceCode(glPzmlEntity.getDataSourceCode());
|
|
|
|
|
List<GbiZbxmbEntity> gbiZbsyrecEntities = gbiZbxmbDao.queryZbxmbByIdpzh(gbiZbxmbEntity);
|
|
|
|
|
logger.info("=======根据凭证idpzh:{}查询的指标金额和指标id数据有{}条",pzmlEntity.getIdpzh(),gbiZbsyrecEntities.size());
|
|
|
|
|
if(CollectionUtils.isEmpty(gbiZbsyrecEntities)){
|
|
|
|
|
jsonObjectParams.put("reimburseItems",new ArrayList<>());
|
|
|
|
|
}else{
|
|
|
|
|
JSONArray jsonArray=new JSONArray();
|
|
|
|
|
for (GbiZbxmbEntity zbxmbEntity : gbiZbsyrecEntities) {
|
|
|
|
|
BigDecimal bigDecimalValueZbxmb = new BigDecimal(zbxmbEntity.getJe());
|
|
|
|
|
BigDecimal roundedValueZbxmb = bigDecimalValueZbxmb.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
JSONObject jsonObjectZbxm=new JSONObject();
|
|
|
|
|
jsonObjectZbxm.put("thirdProjectCode",zbxmbEntity.getZbid());
|
|
|
|
|
jsonObjectZbxm.put("amount",roundedValueZbxmb);
|
|
|
|
|
jsonObjectZbxm.put("financialCode",zbxmbEntity.getJjkmdm());
|
|
|
|
|
jsonArray.add(jsonObjectZbxm);
|
|
|
|
|
}
|
|
|
|
|
jsonObjectParams.put("reimburseItems",jsonArray);
|
|
|
|
|
}
|
|
|
|
|
JSONArray jsonArray=new JSONArray();
|
|
|
|
|
jsonArray.add(jsonObjectParams);
|
|
|
|
|
JSONObject jsonObjectData=new JSONObject();
|
|
|
|
|
jsonObjectData.put("data",jsonArray);
|
|
|
|
|
String params = jsonObjectData.toJSONString();
|
|
|
|
|
logger.info("调用商学院凭证保存接口请求参数:{}",params);
|
|
|
|
|
result = HttpRequest.post(URLTest + "/nky/service/zsApi/saveZJSYPZReimburse?accessToken="+token).header("Content-Type", "application/json;charset=UTF-8").timeout(30000).body(params).execute().body();
|
|
|
|
|
logger.info("调用商学院凭证保存接口返回参数:{}",result);
|
|
|
|
|
}
|
|
|
|
|
JSONObject jsonObjectResult=new JSONObject();
|
|
|
|
|
jsonObjectResult.put("status","200");
|
|
|
|
|
jsonObjectResult.put("pzml",result);
|
|
|
|
|
return jsonObjectResult;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
logger.info("根据凭证idpzh:{}查询指标失败:{}",glPzmlEntity.getIdpzh(),e.getMessage());
|
|
|
|
|
return BaseResult.getFailureMessageEntity("根据凭证查询指标失败");
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -713,7 +766,7 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
|
|
|
|
|
String params = jsonObject.toJSONString();
|
|
|
|
|
logger.info("=========获取凭证token请求参数:{}========",params);
|
|
|
|
|
String urlToken="nky/service/session/getAccessToken";
|
|
|
|
|
String result = HttpRequest.post(URLTest + urlToken).header("Content-Type", "soap/xml").timeout(30000).body(params).execute().body();
|
|
|
|
|
String result = HttpRequest.post(URLTest + urlToken).header("Content-Type", "application/json;charset=UTF-8").timeout(30000).body(params).execute().body();
|
|
|
|
|
logger.info("=========获取凭证token返回结果:{}========",result);
|
|
|
|
|
JSONObject jsonObjectResult=JSONObject.parseObject(result);
|
|
|
|
|
String value=jsonObjectResult.getString("value");
|
|
|
|
@ -724,7 +777,6 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
|
|
|
|
|
return accessToken;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|