根据凭证号查询指标
This commit is contained in:
parent
442f0f452c
commit
4c50b026f8
|
@ -4,6 +4,7 @@ import com.hzya.frame.basedao.dao.IBaseDao;
|
|||
import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* (gl_pzml: table)表数据库访问层
|
||||
|
@ -83,6 +84,16 @@ public interface ISenderGlPzmlDao extends IBaseDao<SenderGlPzmlEntity, String> {
|
|||
* **/
|
||||
Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity senderGlPzmlEntity);
|
||||
|
||||
/**
|
||||
*
|
||||
* @content 查询凭证 商学院
|
||||
* @Param
|
||||
* @Return
|
||||
* @Author hecan
|
||||
* @Date 2024/8/14 16:25
|
||||
* **/
|
||||
List<SenderGlPzmlEntity> queryGlPzmlSxy(SenderGlPzmlEntity senderGlPzmlEntity);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.hzya.frame.grpU8.nxproof.glPzml.entity.SenderGlPzmlEntity;
|
|||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* (GlPzml)表数据库访问层
|
||||
|
@ -60,5 +61,11 @@ public class SenderGlPzmlDaoImpl extends MybatisGenericDao<SenderGlPzmlEntity, S
|
|||
public Integer deleteGlPzmlHealthBureau(SenderGlPzmlEntity 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,16 @@ public class SenderGlPzmlEntity extends BaseEntity {
|
|||
private String stamp;
|
||||
private String yspzje;
|
||||
|
||||
private String bmdm;
|
||||
|
||||
public String getBmdm() {
|
||||
return bmdm;
|
||||
}
|
||||
|
||||
public void setBmdm(String bmdm) {
|
||||
this.bmdm = bmdm;
|
||||
}
|
||||
|
||||
public String getPzsbm() {
|
||||
return pzsbm;
|
||||
}
|
||||
|
|
|
@ -259,6 +259,31 @@
|
|||
</trim>
|
||||
</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 into gl_pzml(
|
||||
|
|
|
@ -95,11 +95,11 @@ public interface ISenderGlPzmlService extends IBaseService<SenderGlPzmlEntity, S
|
|||
|
||||
/**
|
||||
*
|
||||
* @content 保存凭证 商学院 确定指标被哪些凭证使用
|
||||
* @content 查询凭证 商学院 确定指标被哪些凭证使用
|
||||
* @Param
|
||||
* @Return
|
||||
* @Author hecan
|
||||
* @Date 2024/8/13 17:00
|
||||
* **/
|
||||
Object saveGlPzmlSxy(JSONObject jsonObject);
|
||||
Object queryGlPzmlSxy(JSONObject jsonObject);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
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",DateUtil.format(new Date(),"yyyy-MM-dd"));//日期
|
||||
jsonObjectParams.put("userCode","");//用户编码
|
||||
jsonObjectParams.put("depCode","");//部门编码
|
||||
jsonObjectParams.put("applyDate",outputDateString);//日期
|
||||
jsonObjectParams.put("userCode",pzmlEntity.getSrid());//用户编码
|
||||
jsonObjectParams.put("depCode","A518");//部门编码
|
||||
jsonObjectParams.put("description",pzmlEntity.getPzzy());//说明
|
||||
jsonObjectParams.put("amount",pzmlEntity.getPzje());//金额
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue