同步生成收款单接口

This commit is contained in:
username 2024-07-29 17:48:06 +08:00
parent 9090ca3dfa
commit 29a0b03f14
20 changed files with 503 additions and 2 deletions

View File

@ -93,6 +93,12 @@
<profile.active>yc</profile.active>
</properties>
</profile>
<profile>
<id>zqt</id> <!--越城区-->
<properties>
<profile.active>zqt</profile.active>
</properties>
</profile>
</profiles>
<build>
<finalName>kangarooDataCenterV3</finalName>

View File

@ -0,0 +1,7 @@
package com.hzya.frame.plugin.oaReceipt.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.plugin.oaReceipt.entity.OaReceiptEntity;
public interface IOaReceiptDao extends IBaseDao<OaReceiptEntity, String> {
}

View File

@ -0,0 +1,8 @@
package com.hzya.frame.plugin.oaReceipt.dao.impl;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.plugin.oaReceipt.dao.IOaReceiptDao;
import com.hzya.frame.plugin.oaReceipt.entity.OaReceiptEntity;
public class OaReceiptDaoImpl extends MybatisGenericDao<OaReceiptEntity, String> implements IOaReceiptDao {
}

View File

@ -0,0 +1,6 @@
package com.hzya.frame.plugin.oaReceipt.entity;
import com.hzya.frame.web.entity.BaseEntity;
public class OaReceiptEntity extends BaseEntity {
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.plugin.oaReceipt.dao.impl.OaReceiptDaoImpl">
<resultMap id="get-OaReceiptEntity-result" type="com.hzya.frame.plugin.oaReceipt.entity.OaReceiptEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "PayBillEntity_Base_Column_List">
id
</sql>
</mapper>

View File

@ -0,0 +1,58 @@
package com.hzya.frame.plugin.oaReceipt.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.a8bill.plugin.PayBillPluginInitializer;
import com.hzya.frame.seeyon.receiptFor.service.IReceiptForService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class OaReceiptPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(PayBillPluginInitializer.class);
@Autowired
private IReceiptForService receiptForService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "OaReceiptPlugin";
}
@Override
public String getPluginName() {
return "OaReceiptPlugin插件";
}
@Override
public String getPluginLabel() {
return "OaReceiptPlugin";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行付款单据信息同步========");
return receiptForService.sendReceiptFor(requestJson);
}catch (Exception e){
logger.info("======执行付款单据同步失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,7 @@
package com.hzya.frame.plugin.oaReceipt.service;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.plugin.oaReceipt.entity.OaReceiptEntity;
public interface IOaReceiptService extends IBaseService<OaReceiptEntity, String> {
}

View File

@ -0,0 +1,8 @@
package com.hzya.frame.plugin.oaReceipt.service.impl;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.plugin.oaReceipt.entity.OaReceiptEntity;
import com.hzya.frame.plugin.oaReceipt.service.IOaReceiptService;
public class OaReceiptServiceImpl extends BaseService<OaReceiptEntity, String> implements IOaReceiptService {
}

View File

@ -6,7 +6,7 @@ logging:
encodings: UTF-8
file:
# 日志保存路径
path: /home/webservice/zt/log
path: D:\log
spring:
datasource:
dynamic:
@ -18,7 +18,7 @@ spring:
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
savefile:
# 文件保存路径
path: /home/webservice/zt/file
path: D:\log
cbs8:
appId: 1P4AGrpz
appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>OaReceiptPlugin</id>
<name>OaReceiptPlugin插件</name>
<category>90000026</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="oaReceiptCustomerDao" class="com.hzya.frame.plugin.oaReceipt.dao.impl.OaReceiptDaoImpl" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="oaReceiptCustomerInitializer" class="com.hzya.frame.plugin.oaReceipt.plugin.OaReceiptPluginInitializer" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="oaReceiptCustomerService" class="com.hzya.frame.plugin.oaReceipt.service.impl.OaReceiptServiceImpl" />
</beans>

View File

@ -58,6 +58,24 @@ public class BipUtil {
}
return null;
}
public static String sendOaToDj(String parm, String apiCode){
String baseUrl = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface";
System.out.println("推送参数"+parm);
String result = HttpRequest.post(baseUrl)
.header("appId", "800035")//头信息多个头信息多次调用此方法即可
.header("apiCode", apiCode)//头信息多个头信息多次调用此方法即可
.header("publicKey", "ZJYATW/MfYZX7zF0eAh4DJXbyTLwUtwSoSz5Y/o1ksAaN/dCe7eDIk+3zDUT+v578prj")//头信息多个头信息多次调用此方法即可
.header("secretKey", "+5BUkLQh3iX3VHgEt5bE2IPh+ZeebGvDaEspsvVu739Ar6sFnwg+fpPod4t6XhoTj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息多个头信息多次调用此方法即可
.body(parm)//表单内容
.timeout(20000)//超时毫秒
.execute().body();
System.out.println("返回参数"+result);
if(StrUtil.isNotEmpty(result)){
return analytic(result);
}
return null;
}
public static String analytic(String parm){
JSONObject main = JSON.parseObject(parm);
return main.getString("attribute");

View File

@ -0,0 +1,11 @@
package com.hzya.frame.seeyon.receiptFor.dao;
import com.hzya.frame.seeyon.receiptFor.entity.ReceiptForEntity;
import java.util.List;
public interface IReceiptForDao{
public List<ReceiptForEntity> getOaReceipt(ReceiptForEntity recEntity);
public int updateState(ReceiptForEntity recEntity);
}

View File

@ -0,0 +1,25 @@
package com.hzya.frame.seeyon.receiptFor.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.seeyon.receiptFor.dao.IReceiptForDao;
import com.hzya.frame.seeyon.receiptFor.entity.ReceiptForEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository("receiptForDao")
public class ReceiptForDaoImpl extends MybatisGenericDao implements IReceiptForDao {
@DS("#recEntity.dataSourceCode")
@Override
public List<ReceiptForEntity> getOaReceipt(ReceiptForEntity recEntity){
return super.selectList(getSqlIdPrifx()+"ReceiptForEntity_list_base",recEntity);
}
@DS("#recEntity.dataSourceCode")
@Override
public int updateState(ReceiptForEntity recEntity){
return super.update(getSqlIdPrifx()+"ReceiptForEntity_update_state",recEntity);
}
}

View File

@ -0,0 +1,79 @@
package com.hzya.frame.seeyon.receiptFor.entity;
import com.hzya.frame.web.entity.BaseEntity;
public class ReceiptForEntity extends BaseEntity {
private String dfybje;
private String djrq;
private String dwbm;
private String hbbm;
private String lrr;
private String shr;
private String shrq;
private String state;
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getDfybje() {
return dfybje;
}
public void setDfybje(String dfybje) {
this.dfybje = dfybje;
}
public String getDjrq() {
return djrq;
}
public void setDjrq(String djrq) {
this.djrq = djrq;
}
public String getDwbm() {
return dwbm;
}
public void setDwbm(String dwbm) {
this.dwbm = dwbm;
}
public String getHbbm() {
return hbbm;
}
public void setHbbm(String hbbm) {
this.hbbm = hbbm;
}
public String getLrr() {
return lrr;
}
public void setLrr(String lrr) {
this.lrr = lrr;
}
public String getShr() {
return shr;
}
public void setShr(String shr) {
this.shr = shr;
}
public String getShrq() {
return shrq;
}
public void setShrq(String shrq) {
this.shrq = shrq;
}
}

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.seeyon.receiptFor.dao.impl.ReceiptForDaoImpl">
<resultMap id="get-ReceiptForEntity-result" type="com.hzya.frame.seeyon.receiptFor.entity.ReceiptForEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="dfybje" column="r_dfybje" jdbcType="VARCHAR"/>
<result property="djrq" column="r_djrq" jdbcType="VARCHAR"/>
<result property="dwbm" column="r_dwbm" jdbcType="VARCHAR"/>
<result property="hbbm" column="r_hbbm" jdbcType="VARCHAR"/>
<result property="lrr" column="r_lrr" jdbcType="VARCHAR"/>
<result property="shr" column="r_shr" jdbcType="VARCHAR"/>
<result property="shrq" column="r_shrq" jdbcType="VARCHAR"/>
</resultMap>
<!-- <select id="ReceiptForEntity_list_base" resultMap="get-ReceiptForEntity-result" parameterType="com.hzya.frame.seeyon.receiptFor.entity.ReceiptForEntity">-->
<!-- select-->
<!-- state as r_dfybje,-->
<!-- '2024-07-23' as r_djrq,-->
<!-- '001' as r_dwbm,-->
<!-- 'C000001' as r_hbbm,-->
<!-- '17633965916' as r_lrr,-->
<!-- '17633965916' as r_shr,-->
<!-- '2024-07-23' as r_shrq-->
<!-- from formmain_0045-->
<!-- </select>-->
<select id="ReceiptForEntity_list_base" resultMap="get-ReceiptForEntity-result" parameterType="com.hzya.frame.seeyon.receiptFor.entity.ReceiptForEntity">
select
id,
'1' as r_dfybje,
'2024-07-23' as r_djrq,
'001' as r_dwbm,
'C000001' as r_hbbm,
'17633965916' as r_lrr,
'17633965916' as r_shr,
'2024-07-23' as r_shrq
from formmain_0045
where sts = 'N'
<trim>
<if test="id !=null and id!=''">and id like concat('%',#{id},'%')</if>
</trim>
</select>
<!-- ReceiptForEntity_update_state-->
<!--通过主键修改方法-->
<update id="ReceiptForEntity_update_state" parameterType = "com.hzya.frame.seeyon.receiptFor.entity.ReceiptForEntity" >
update formmain_0045 set state = #{state} where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,11 @@
package com.hzya.frame.seeyon.receiptFor.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.seeyon.receiptFor.entity.ReceiptForEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IReceiptForService extends IBaseService<ReceiptForEntity,String> {
public JsonResultEntity sendReceiptFor(JSONObject requestJson);
}

View File

@ -0,0 +1,162 @@
package com.hzya.frame.seeyon.receiptFor.service.impl;
import cn.hutool.core.util.StrUtil;
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.bip.v3.v2207.util.BipUtil;
import com.hzya.frame.seeyon.receiptFor.dao.IReceiptForDao;
import com.hzya.frame.seeyon.receiptFor.entity.ReceiptForEntity;
import com.hzya.frame.seeyon.receiptFor.service.IReceiptForService;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service("ReceiptForServiceImpl")
public class ReceiptForServiceImpl extends BaseService<ReceiptForEntity,String> implements IReceiptForService {
Logger logger = LoggerFactory.getLogger(ReceiptForServiceImpl.class);
@Autowired
private IReceiptForDao receiptForDao;
@Autowired
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Override
public JsonResultEntity sendReceiptFor(JSONObject requestJson){
//获取重推信息id并记录日志
JSONObject requestJsonObj = JSON.parseObject(requestJson.toString(),JSONObject.class);
String interId = requestJsonObj.getString("integration_task_living_details_id");
logger.info("收款单重推解析后:"+requestJsonObj.toString());
logger.info("收款单重新执行的任务主键:"+interId);
//更换数据源
JsonResultEntity resultEntity = new JsonResultEntity();
ReceiptForEntity entity = new ReceiptForEntity();
requestJson.put("db_code","djoatest");
entity.setDataSourceCode(requestJson.getString("db_code"));
//根据重推信息id查询该条重推记录信息
IntegrationTaskLivingDetailsEntity oldMsg = new IntegrationTaskLivingDetailsEntity();
if(StrUtil.isNotEmpty(interId)){
oldMsg = taskLivingDetailsService.get(interId);
}
String rootAppPk = oldMsg.getRootAppPk();
entity.setId(rootAppPk);
if(StrUtil.isEmpty(rootAppPk)){
//entity.setQueryState("查询");
}
//如果是重推是否通过entity传入的id只能查到一条数据
//entity.setId("-8845102890648320822");
List<ReceiptForEntity> receiptList = receiptForDao.getOaReceipt(entity);
if(CollectionUtils.isNotEmpty(receiptList)){
for(ReceiptForEntity rec : receiptList){
try{
JSONObject main = bindingAdd(rec);
logger.info("收款认领单推送数据:"+main.toString());
String result = BipUtil.sendOaToDj(main.toString(),"8000350034");
logger.info("收款认领单推送结果:"+result);
IntegrationTaskLivingDetailsEntity logDetails = new IntegrationTaskLivingDetailsEntity();
logDetails.setRootAppPk(rec.getId());
//logDetails.setRootAppBill();
//不知道源系统单据是什么所以先注释掉了
logDetails.setNewTransmitInfo(result);
logDetails.setNewPushDate(new Date());
logDetails.setRootAppNewData(JSON.toJSONString(rec));
logDetails.setPluginId("OaReceiptPlugin");
JSONObject resultObj = JSON.parseObject(result);
boolean flag = resultObj.get("status").equals("success");
if(flag){
// 推送成功更新状态
rec.setState("1");
}else{
// 推送失败
rec.setState("0");
}
rec.setDataSourceCode(requestJson.getString("db_code"));
try{
if(StrUtil.isEmpty(interId)){
if(flag){
//首推成功
//由于字段匹配问题logDetails中没设置单据号因此会保存失败
taskLivingDetailsService.saveLogToSuccess(logDetails);
}else{
//首推失败
taskLivingDetailsService.saveLogToFail(logDetails);
}
}else{
logDetails.setId(interId);
if(flag){
//重推成功
taskLivingDetailsService.saveLogFailToSuccess(logDetails);
}else{
//重推失败把失败信息更新到重推表中
taskLivingDetailsService.updateLogFailToSuccess(logDetails);
}
}
}catch (Exception e){
logger.info("保存日志失败"+e.getMessage());
receiptForDao.updateState(rec);
e.printStackTrace();
}
receiptForDao.updateState(rec);
//
} catch (Exception e) {
logger.info("收款单执行失败"+e.getMessage());
e.printStackTrace();
}
}
}
return new JsonResultEntity("成功",true,resultEntity);
}
@NotNull
private JSONObject bindingAdd(ReceiptForEntity rec) {
String djrq = rec.getDjrq().substring(0,10);
if(djrq.length()>19){
djrq = rec.getDjrq().substring(0,10);
}
String shrq = rec.getShrq().substring(0,10);
if(shrq.length()>19){
shrq = rec.getShrq().substring(0,10);
}
JSONObject dfybjeJson = new JSONObject();
dfybjeJson.put("dfybje",rec.getDfybje());
JSONArray childrenArray = new JSONArray();
childrenArray.add(dfybjeJson);
JSONObject parentvo = new JSONObject();
parentvo.put("djrq",djrq);
parentvo.put("dwbm",rec.getDwbm());
parentvo.put("hbbm",rec.getHbbm());
parentvo.put("lrr",rec.getLrr());
parentvo.put("shr",rec.getShr());
parentvo.put("shrq",shrq);
JSONObject billvoJson = new JSONObject();
billvoJson.put("children",childrenArray);
billvoJson.put("parentvo",parentvo);
JSONArray billvoArray = new JSONArray();
billvoArray.add(billvoJson);
JSONObject main = new JSONObject();
main.put("billvo",billvoArray);
return main;
}
}