From 9090ca3dfa1f0a2f8dd094af2afaaee1e23175ff Mon Sep 17 00:00:00 2001 From: username Date: Mon, 29 Jul 2024 17:23:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-zqt.yml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 buildpackage/src/main/resources/application-zqt.yml diff --git a/buildpackage/src/main/resources/application-zqt.yml b/buildpackage/src/main/resources/application-zqt.yml new file mode 100644 index 00000000..28fa5bb3 --- /dev/null +++ b/buildpackage/src/main/resources/application-zqt.yml @@ -0,0 +1,35 @@ +#######################dev环境####################### +logging: + #日志级别 指定目录级别 + level: + root: info + encodings: UTF-8 + file: + # 日志保存路径 + path: /home/webservice/zt/log +spring: + datasource: + dynamic: + datasource: + master: + url: jdbc:mysql://ufidahz.com.cn:9014/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true + username: root + password: 62e4295b615a30dbf3b8ee96f41c820b + driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置 +savefile: + # 文件保存路径 + path: /home/webservice/zt/file +cbs8: + appId: 1P4AGrpz + appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a + url: https://cbs8-openapi-reprd.csuat.cmburl.cn + # 测试用这个 这个是银行给的,和下面的公钥不是一对密钥 + ya_private_key: 83BA7EC821D35F4CB31FF9A51C1EFA520FC52AF828C2337F88E91CF119B07F44 + # 这个私钥到时候上传到cbs,和下面到是同一对 + #ya_private_key: e1eacfdee9b8d4184437d5a2071e17ce31befc3d93395f9f05709ed562e8dc46 + ya_public_key: 044fa399d2223760f17b81b863cb482b009294c4516f8a605dea1475ec09e720eaa98468715e5ad509a592a0b426061551c5a3df236966c23253a7d894eac0dcde + cbs_public_key: 0469146F06BF3B01236E84632441E826 + #电子回单下载临时存放位置 + elec_path: /Users/xiangerlin/Downloads/ +OA: + data_source_code: djoatest \ No newline at end of file From 29a0b03f145970bc4b489c96808df2e1629d124c Mon Sep 17 00:00:00 2001 From: username Date: Mon, 29 Jul 2024 17:48:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=94=B6=E6=AC=BE=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildpackage/pom.xml | 6 + .../plugin/oaReceipt/dao/IOaReceiptDao.java | 7 + .../oaReceipt/dao/impl/OaReceiptDaoImpl.java | 8 + .../oaReceipt/entity/OaReceiptEntity.java | 6 + .../oaReceipt/entity/OaReceiptEntity.xml | 16 ++ .../plugin/OaReceiptPluginInitializer.java | 58 +++++++ .../oaReceipt/service/IOaReceiptService.java | 7 + .../service/impl/OaReceiptServiceImpl.java | 8 + .../src/main/resources/application-zqt.yml | 4 +- .../cfgHome/plugin/oaReceipt/pluginCfg.xml | 6 + .../spring/spring-buildpackage-dao.xml | 5 + .../spring/spring-buildpackage-plugin.xml | 5 + .../spring/spring-buildpackage-service.xml | 5 + .../hzya/frame/bip/v3/v2207/util/BipUtil.java | 18 ++ .../seeyon/receiptFor/dao/IReceiptForDao.java | 11 ++ .../dao/impl/ReceiptForDaoImpl.java | 25 +++ .../receiptFor/entity/ReceiptForEntity.java | 79 +++++++++ .../receiptFor/entity/ReceiptForEntity.xml | 58 +++++++ .../service/IReceiptForService.java | 11 ++ .../service/impl/ReceiptForServiceImpl.java | 162 ++++++++++++++++++ 20 files changed, 503 insertions(+), 2 deletions(-) create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/dao/IOaReceiptDao.java create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/dao/impl/OaReceiptDaoImpl.java create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/entity/OaReceiptEntity.java create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/entity/OaReceiptEntity.xml create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/plugin/OaReceiptPluginInitializer.java create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/service/IOaReceiptService.java create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/service/impl/OaReceiptServiceImpl.java create mode 100644 buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/pluginCfg.xml create mode 100644 buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-dao.xml create mode 100644 buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-plugin.xml create mode 100644 buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-service.xml create mode 100644 service/src/main/java/com/hzya/frame/seeyon/receiptFor/dao/IReceiptForDao.java create mode 100644 service/src/main/java/com/hzya/frame/seeyon/receiptFor/dao/impl/ReceiptForDaoImpl.java create mode 100644 service/src/main/java/com/hzya/frame/seeyon/receiptFor/entity/ReceiptForEntity.java create mode 100644 service/src/main/java/com/hzya/frame/seeyon/receiptFor/entity/ReceiptForEntity.xml create mode 100644 service/src/main/java/com/hzya/frame/seeyon/receiptFor/service/IReceiptForService.java create mode 100644 service/src/main/java/com/hzya/frame/seeyon/receiptFor/service/impl/ReceiptForServiceImpl.java diff --git a/buildpackage/pom.xml b/buildpackage/pom.xml index 5c949541..c322ef46 100644 --- a/buildpackage/pom.xml +++ b/buildpackage/pom.xml @@ -93,6 +93,12 @@ yc + + zqt + + zqt + + kangarooDataCenterV3 diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/dao/IOaReceiptDao.java b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/dao/IOaReceiptDao.java new file mode 100644 index 00000000..1051b7fa --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/dao/IOaReceiptDao.java @@ -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 { +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/dao/impl/OaReceiptDaoImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/dao/impl/OaReceiptDaoImpl.java new file mode 100644 index 00000000..e458e4d8 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/dao/impl/OaReceiptDaoImpl.java @@ -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 implements IOaReceiptDao { +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/entity/OaReceiptEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/entity/OaReceiptEntity.java new file mode 100644 index 00000000..1ef5e65e --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/entity/OaReceiptEntity.java @@ -0,0 +1,6 @@ +package com.hzya.frame.plugin.oaReceipt.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +public class OaReceiptEntity extends BaseEntity { +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/entity/OaReceiptEntity.xml b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/entity/OaReceiptEntity.xml new file mode 100644 index 00000000..896fd71d --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/entity/OaReceiptEntity.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + id + + + + + diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/plugin/OaReceiptPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/plugin/OaReceiptPluginInitializer.java new file mode 100644 index 00000000..015354c0 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/plugin/OaReceiptPluginInitializer.java @@ -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; + } +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/service/IOaReceiptService.java b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/service/IOaReceiptService.java new file mode 100644 index 00000000..10ce9851 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/service/IOaReceiptService.java @@ -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 { +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/service/impl/OaReceiptServiceImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/service/impl/OaReceiptServiceImpl.java new file mode 100644 index 00000000..721488bd --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/oaReceipt/service/impl/OaReceiptServiceImpl.java @@ -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 implements IOaReceiptService { +} diff --git a/buildpackage/src/main/resources/application-zqt.yml b/buildpackage/src/main/resources/application-zqt.yml index 28fa5bb3..fef30d8a 100644 --- a/buildpackage/src/main/resources/application-zqt.yml +++ b/buildpackage/src/main/resources/application-zqt.yml @@ -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 diff --git a/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/pluginCfg.xml b/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/pluginCfg.xml new file mode 100644 index 00000000..d2654f45 --- /dev/null +++ b/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/pluginCfg.xml @@ -0,0 +1,6 @@ + + +OaReceiptPlugin +OaReceiptPlugin插件 +90000026 + diff --git a/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-dao.xml b/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-dao.xml new file mode 100644 index 00000000..f0695cce --- /dev/null +++ b/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-dao.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-plugin.xml b/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-plugin.xml new file mode 100644 index 00000000..a6799dbf --- /dev/null +++ b/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-plugin.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-service.xml b/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-service.xml new file mode 100644 index 00000000..ba5fdbe0 --- /dev/null +++ b/buildpackage/src/main/resources/cfgHome/plugin/oaReceipt/spring/spring-buildpackage-service.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/service/src/main/java/com/hzya/frame/bip/v3/v2207/util/BipUtil.java b/service/src/main/java/com/hzya/frame/bip/v3/v2207/util/BipUtil.java index a7bfe324..5148ef17 100644 --- a/service/src/main/java/com/hzya/frame/bip/v3/v2207/util/BipUtil.java +++ b/service/src/main/java/com/hzya/frame/bip/v3/v2207/util/BipUtil.java @@ -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"); diff --git a/service/src/main/java/com/hzya/frame/seeyon/receiptFor/dao/IReceiptForDao.java b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/dao/IReceiptForDao.java new file mode 100644 index 00000000..7f6cb7a3 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/dao/IReceiptForDao.java @@ -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 getOaReceipt(ReceiptForEntity recEntity); + + public int updateState(ReceiptForEntity recEntity); +} diff --git a/service/src/main/java/com/hzya/frame/seeyon/receiptFor/dao/impl/ReceiptForDaoImpl.java b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/dao/impl/ReceiptForDaoImpl.java new file mode 100644 index 00000000..2bdecab3 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/dao/impl/ReceiptForDaoImpl.java @@ -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 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); + } +} diff --git a/service/src/main/java/com/hzya/frame/seeyon/receiptFor/entity/ReceiptForEntity.java b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/entity/ReceiptForEntity.java new file mode 100644 index 00000000..b549b44a --- /dev/null +++ b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/entity/ReceiptForEntity.java @@ -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; + } +} diff --git a/service/src/main/java/com/hzya/frame/seeyon/receiptFor/entity/ReceiptForEntity.xml b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/entity/ReceiptForEntity.xml new file mode 100644 index 00000000..0b4d5ca3 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/entity/ReceiptForEntity.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + update formmain_0045 set state = #{state} where id = #{id} + + + + + + + diff --git a/service/src/main/java/com/hzya/frame/seeyon/receiptFor/service/IReceiptForService.java b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/service/IReceiptForService.java new file mode 100644 index 00000000..13bfa3a7 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/service/IReceiptForService.java @@ -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 { + + public JsonResultEntity sendReceiptFor(JSONObject requestJson); +} diff --git a/service/src/main/java/com/hzya/frame/seeyon/receiptFor/service/impl/ReceiptForServiceImpl.java b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/service/impl/ReceiptForServiceImpl.java new file mode 100644 index 00000000..aa9905ff --- /dev/null +++ b/service/src/main/java/com/hzya/frame/seeyon/receiptFor/service/impl/ReceiptForServiceImpl.java @@ -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 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 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; + } + +}