根据凭证号查询指标

This commit is contained in:
hecan 2024-08-27 15:11:56 +08:00
parent 442f0f452c
commit 4c50b026f8
6 changed files with 134 additions and 29 deletions

View File

@ -4,6 +4,7 @@ import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity; import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* (gl_pzml: table)表数据库访问层 * (gl_pzml: table)表数据库访问层
@ -83,6 +84,16 @@ public interface ISenderGlPzmlDao extends IBaseDao<SenderGlPzmlEntity, String> {
* **/ * **/
Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity); Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity);
/**
*
* @content 查询凭证 商学院
* @Param
* @Return
* @Author hecan
* @Date 2024/8/14 16:25
* **/
List<SenderGlPzmlEntity> queryGlPzmlSxy(SenderGlPzmlEntity senderGlPzmlEntity);
} }

View File

@ -8,6 +8,7 @@ import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* (GlPzml)表数据库访问层 * (GlPzml)表数据库访问层
@ -60,5 +61,11 @@ public class SenderGlPzmlDaoImpl extends MybatisGenericDao<SenderGlPzmlEntity, S
public Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity) { public Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity) {
return super.delete("SenderGlPzmlEntity_delete_pzml",senderGlPzmlEntity); return super.delete("SenderGlPzmlEntity_delete_pzml",senderGlPzmlEntity);
} }
@Override
@DS("#senderGlPzmlEntity.dataSourceCode")
public List<SenderGlPzmlEntity> queryGlPzmlSxy(SenderGlPzmlEntity senderGlPzmlEntity) {
return (List<SenderGlPzmlEntity>) super.selectList("queryGlPzmlSxy",senderGlPzmlEntity);
}
} }

View File

@ -54,6 +54,16 @@ public class SenderGlPzmlEntity extends BaseEntity {
private String stamp; private String stamp;
private String yspzje; private String yspzje;
private String bmdm;
public String getBmdm() {
return bmdm;
}
public void setBmdm(String bmdm) {
this.bmdm = bmdm;
}
public String getPzsbm() { public String getPzsbm() {
return pzsbm; return pzsbm;
} }

View File

@ -259,6 +259,31 @@
</trim> </trim>
</select> </select>
<!-- 查询列表 商学院所需要的凭证数据-->
<select id="queryGlPzmlSxy" resultMap="get-SenderGlPzmlEntity-result" parameterType = "com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity">
select
pzml.idpzh as idpzh,
pzml.kjqj as kjqj,
pzml.srrq as srrq,
pzml.srID as srID,
pznr.bmdm as bmdm,
pzml.pzzy as pzzy,
sum(pznr.je) as pzje,
pzml.gsdm,pzml.zth,pzml.kjqj,pzml.pzh
from GL_Pzml pzml
left join gl_pznr pznr on pznr.idpzh=pzml.idpzh and pzml.kjqj=pznr.kjqj
<trim prefix="where" prefixOverrides="and">
<if test="idpzh !=null and idpzh!='' "> and pzml.idpzh = #{idpzh} </if>
and pzml.kjqj =#{kjqj} and pznr.kjqj =#{kjqj} and pznr.zbid!=0
</trim>
group by pzml.idpzh,
pzml.kjqj,
pzml.srrq,
pzml.pzzy,
pzml.gsdm,pzml.zth,pzml.kjqj,pzml.pzh,pzml.srID,pznr.bmdm
</select>
<!--新增所有列--> <!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity" keyProperty="" useGeneratedKeys="true"> <insert id="entity_insert" parameterType = "com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity" keyProperty="" useGeneratedKeys="true">
insert into gl_pzml( insert into gl_pzml(

View File

@ -95,11 +95,11 @@ public interface ISenderGlPzmlService extends IBaseService<SenderGlPzmlEntity, S
/** /**
* *
* @content 保存凭证 商学院 确定指标被哪些凭证使用 * @content 查询凭证 商学院 确定指标被哪些凭证使用
* @Param * @Param
* @Return * @Return
* @Author hecan * @Author hecan
* @Date 2024/8/13 17:00 * @Date 2024/8/13 17:00
* **/ * **/
Object saveGlPzmlSxy(JSONObject jsonObject); Object queryGlPzmlSxy(JSONObject jsonObject);
} }

View File

@ -8,6 +8,10 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService; 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.dao.ISenderGlPzmlDao;
import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity; import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
import com.hzya.frame.grpU8.nxproof.glPzml.service.ISenderGlPzmlService; 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.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.math.BigDecimal;
import java.util.Date; import java.math.RoundingMode;
import java.util.List; import java.text.DecimalFormat;
import java.util.UUID; import java.text.SimpleDateFormat;
import java.util.*;
import static org.aspectj.runtime.internal.Conversions.doubleValue;
/** /**
* (GlPzml)表服务实现类 * (GlPzml)表服务实现类
@ -41,6 +48,9 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
private ISenderGlPzmlDao senderGlPzmlDao; private ISenderGlPzmlDao senderGlPzmlDao;
@Autowired
private IGbiZbxmbDao gbiZbxmbDao;
@Autowired @Autowired
public void setSenderGlPzmlDao(ISenderGlPzmlDao dao) { public void setSenderGlPzmlDao(ISenderGlPzmlDao dao) {
this.senderGlPzmlDao = dao; this.senderGlPzmlDao = dao;
@ -668,7 +678,8 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
//保存凭证 商学院指标被哪些凭证使用 //保存凭证 商学院指标被哪些凭证使用
@Override @Override
public Object saveGlPzmlSxy(JSONObject jsonObject){ public Object queryGlPzmlSxy(JSONObject json){
JSONObject jsonObject = json.getJSONObject("jsonStr");
SenderGlPzmlEntity glPzmlEntity = jsonObject.toJavaObject(SenderGlPzmlEntity.class); SenderGlPzmlEntity glPzmlEntity = jsonObject.toJavaObject(SenderGlPzmlEntity.class);
if(StrUtil.isEmpty(glPzmlEntity.getKjqj())){ if(StrUtil.isEmpty(glPzmlEntity.getKjqj())){
glPzmlEntity.setKjqj(DateUtil.format(new Date(),"yyyyMM")); glPzmlEntity.setKjqj(DateUtil.format(new Date(),"yyyyMM"));
@ -679,29 +690,71 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
return BaseResult.getFailureMessageEntity("token为空请先获取token"); return BaseResult.getFailureMessageEntity("token为空请先获取token");
} }
//查询凭证数据 //查询凭证数据
List<SenderGlPzmlEntity> pzmlEntities = senderGlPzmlDao.query(glPzmlEntity); List<SenderGlPzmlEntity> list = senderGlPzmlDao.queryGlPzmlSxy(glPzmlEntity);
if(CollectionUtils.isEmpty(pzmlEntities)){ if(CollectionUtils.isEmpty(list)){
return BaseResult.getSuccessMessageEntity("没有需要同步得凭证",null); return BaseResult.getSuccessMessageEntity("没有需要同步得凭证",null);
} }
for (SenderGlPzmlEntity pzmlEntity : pzmlEntities) { try {
String result=null;
for (SenderGlPzmlEntity pzmlEntity : list) {
String pzNum = pzmlEntity.getGsdm() + "_" + pzmlEntity.getZth() + "_" + pzmlEntity.getKjqj() + "_" + pzmlEntity.getPzh(); 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(); JSONObject jsonObjectParams=new JSONObject();
jsonObjectParams.put("code",pzmlEntity.getIdpzh());//pzid jsonObjectParams.put("code",pzmlEntity.getIdpzh());//pzid
jsonObjectParams.put("budgetYear",pzmlEntity.getKjqj().substring(0,4));//预算年度 jsonObjectParams.put("budgetYear",pzmlEntity.getKjqj().substring(0,4));//预算年度
jsonObjectParams.put("applyDate",DateUtil.format(new Date(),"yyyy-MM-dd"));//日期 jsonObjectParams.put("applyDate",outputDateString);//日期
jsonObjectParams.put("userCode","");//用户编码 jsonObjectParams.put("userCode",pzmlEntity.getSrid());//用户编码
jsonObjectParams.put("depCode","");//部门编码 jsonObjectParams.put("depCode","A518");//部门编码
jsonObjectParams.put("description",pzmlEntity.getPzzy());//说明 jsonObjectParams.put("description",pzmlEntity.getPzzy());//说明
jsonObjectParams.put("amount",pzmlEntity.getPzje());//金额 jsonObjectParams.put("amount",roundedValue.doubleValue());//金额
jsonObjectParams.put("pzNum",pzNum);//凭证号 例如公司代码+账套号+会计期间+凭证号001_001_202408_付款_1 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 jsonArray=new JSONArray();
jsonArray.add(jsonObjectParams); jsonArray.add(jsonObjectParams);
JSONObject jsonObjectData=new JSONObject(); JSONObject jsonObjectData=new JSONObject();
jsonObjectData.put("data",jsonArray); 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(); String params = jsonObject.toJSONString();
logger.info("=========获取凭证token请求参数:{}========",params); logger.info("=========获取凭证token请求参数:{}========",params);
String urlToken="nky/service/session/getAccessToken"; 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); logger.info("=========获取凭证token返回结果:{}========",result);
JSONObject jsonObjectResult=JSONObject.parseObject(result); JSONObject jsonObjectResult=JSONObject.parseObject(result);
String value=jsonObjectResult.getString("value"); String value=jsonObjectResult.getString("value");
@ -724,7 +777,6 @@ public class SenderGlPzmlServiceImpl extends BaseService<SenderGlPzmlEntity, Str
return accessToken; return accessToken;
} }
return null; return null;
} }