diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IApplyInvoiceDao.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IApplyInvoiceDao.java new file mode 100644 index 00000000..e75045c0 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IApplyInvoiceDao.java @@ -0,0 +1,12 @@ +package com.hzya.frame.plugin.ht.dao; + +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.plugin.ht.entity.ApplyInvoiceEntity; + +/** + * @Description OA开票申请 + * @Author xiangerlin + * @Date 2025/6/21 17:07 + **/ +public interface IApplyInvoiceDao extends IBaseDao { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IFundsAllocationDao.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IFundsAllocationDao.java new file mode 100644 index 00000000..a870399f --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IFundsAllocationDao.java @@ -0,0 +1,12 @@ +package com.hzya.frame.plugin.ht.dao; + +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.plugin.ht.entity.FundsAllocationEntity; + +/** + * @Description OA资金拨付 + * @Author xiangerlin + * @Date 2025/6/21 14:23 + **/ +public interface IFundsAllocationDao extends IBaseDao { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/ApplyInvoiceDaoImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/ApplyInvoiceDaoImpl.java new file mode 100644 index 00000000..a0e7a432 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/ApplyInvoiceDaoImpl.java @@ -0,0 +1,15 @@ +package com.hzya.frame.plugin.ht.dao.impl; + +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.plugin.ht.dao.IApplyInvoiceDao; +import com.hzya.frame.plugin.ht.entity.ApplyInvoiceEntity; +import org.springframework.stereotype.Repository; + +/** + * @Description OA开票申请 + * @Author xiangerlin + * @Date 2025/6/21 17:07 + **/ +@Repository(value = "applyInvoiceDaoImpl") +public class ApplyInvoiceDaoImpl extends MybatisGenericDao implements IApplyInvoiceDao { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/FundsAllocationDaoImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/FundsAllocationDaoImpl.java new file mode 100644 index 00000000..3a849f48 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/FundsAllocationDaoImpl.java @@ -0,0 +1,15 @@ +package com.hzya.frame.plugin.ht.dao.impl; + +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.plugin.ht.dao.IFundsAllocationDao; +import com.hzya.frame.plugin.ht.entity.FundsAllocationEntity; +import org.springframework.stereotype.Repository; + +/** + * @Description OA资金拨付 + * @Author xiangerlin + * @Date 2025/6/21 14:24 + **/ +@Repository(value = "fundsAllocationDaoImpl") +public class FundsAllocationDaoImpl extends MybatisGenericDao implements IFundsAllocationDao { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/ApplyInvoiceEntity.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/ApplyInvoiceEntity.java new file mode 100644 index 00000000..49e87cd1 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/ApplyInvoiceEntity.java @@ -0,0 +1,59 @@ +package com.hzya.frame.plugin.ht.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +/** + * @Description OA开票申请 formmain_0331 + * @Author xiangerlin + * @Date 2025/6/21 17:02 + **/ +public class ApplyInvoiceEntity extends BaseEntity { + private String field0117;//单据号 + + + //查询待办用的字段 + + private String col_summary_id; + private String ctp_affair_id; + private String workitem_id; + private String member_id;//用来指定查哪个用户的待办,这里要查固定人员的待办 + public String getField0117() { + return field0117; + } + + public void setField0117(String field0117) { + this.field0117 = field0117; + } + + public String getCol_summary_id() { + return col_summary_id; + } + + public void setCol_summary_id(String col_summary_id) { + this.col_summary_id = col_summary_id; + } + + public String getCtp_affair_id() { + return ctp_affair_id; + } + + public void setCtp_affair_id(String ctp_affair_id) { + this.ctp_affair_id = ctp_affair_id; + } + + public String getWorkitem_id() { + return workitem_id; + } + + public void setWorkitem_id(String workitem_id) { + this.workitem_id = workitem_id; + } + + public String getMember_id() { + return member_id; + } + + public void setMember_id(String member_id) { + this.member_id = member_id; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/ApplyInvoiceEntity.xml b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/ApplyInvoiceEntity.xml new file mode 100644 index 00000000..2f312035 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/ApplyInvoiceEntity.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/FundsAllocationEntity.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/FundsAllocationEntity.java new file mode 100644 index 00000000..3611076a --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/FundsAllocationEntity.java @@ -0,0 +1,105 @@ +package com.hzya.frame.plugin.ht.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +/** + * @Description OA资金拨付 formmain_0464 + * @Author xiangerlin + * @Date 2025/6/21 14:19 + **/ +public class FundsAllocationEntity extends BaseEntity { + + private String field0045;//单据编号 + private String field0061;//税务系统id,这个字段不为空时表示是税务推过来的单子 + private String field0062;//单据来源,这个字段不为空时表示是司库推过来的单子 + private String field0063;//司库系统批次号,回调时用 + + + //审批意见相关的字段 + private String col_summary_id;//流程id + private String subject;//流程标题 + private String state;//流程状态 + private String name;//处理人姓名 + private String approval_time;//处理时间 + private String content;//审批意见 + + public String getField0045() { + return field0045; + } + + public void setField0045(String field0045) { + this.field0045 = field0045; + } + + public String getField0061() { + return field0061; + } + + public void setField0061(String field0061) { + this.field0061 = field0061; + } + + public String getField0062() { + return field0062; + } + + public void setField0062(String field0062) { + this.field0062 = field0062; + } + + public String getCol_summary_id() { + return col_summary_id; + } + + public void setCol_summary_id(String col_summary_id) { + this.col_summary_id = col_summary_id; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getApproval_time() { + return approval_time; + } + + public void setApproval_time(String approval_time) { + this.approval_time = approval_time; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getField0063() { + return field0063; + } + + public void setField0063(String field0063) { + this.field0063 = field0063; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/FundsAllocationEntity.xml b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/FundsAllocationEntity.xml new file mode 100644 index 00000000..9c8ee996 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/FundsAllocationEntity.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/FundsAllocationPluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/FundsAllocationPluginInitializer.java new file mode 100644 index 00000000..ccb4addf --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/FundsAllocationPluginInitializer.java @@ -0,0 +1,98 @@ +package com.hzya.frame.plugin.ht.plugin; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @Description 资金拨付 流程结束回调 需要同时回调有度税务和中信司库 + * @Author xiangerlin + * @Date 2025/6/21 14:06 + **/ +public class FundsAllocationPluginInitializer extends PluginBaseEntity { + Logger logger = LoggerFactory.getLogger(FundsAllocationPluginInitializer.class); + + + /*** + * 插件初始化方法 + * @Author 👻👻👻👻👻👻👻👻 gjh + * @Date 2023-08-02 10:48 + * @Param [] + * @return void + **/ + @Override + public void initialize() { + logger.info(getPluginLabel() + "執行初始化方法initialize()"); + } + + /**** + * 插件销毁方法 + * @author 👻👻👻👻👻👻👻👻 gjh + * @date 2023-08-02 10:48 + * @return void + **/ + @Override + public void destroy() { + logger.info(getPluginLabel() + "執行銷毀方法destroy()"); + } + + /**** + * 插件的ID + * @author 👻👻👻👻👻👻👻👻 gjh + * @date 2023-08-02 10:48 + * @return void + **/ + @Override + public String getPluginId() { + return "FundsAllocationPlugin"; + } + + /**** + * 插件的名称 + * @author 👻👻👻👻👻👻👻👻 gjh + * @date 2023-08-02 10:48 + * @return void + **/ + @Override + public String getPluginName() { + return "资金拨付回调税务和司库"; + } + + /**** + * 插件的显示值 + * @author 👻👻👻👻👻👻👻👻 gjh + * @date 2023-08-02 10:48 + * @return void + **/ + @Override + public String getPluginLabel() { + return "资金拨付回调税务和司库"; + } + + /*** + * 插件类型 1、场景插件 + * @Author 👻👻👻👻👻👻👻👻 gjh + * @Date 2023-08-02 14:01 + * @Param [] + * @return java.lang.String + **/ + @Override + public String getPluginType() { + return "1"; + } + + /*** + * 执行业务代码 + * @Author 👻👻👻👻👻👻👻👻 gjh + * @Date 2023-08-07 11:20 + * @param requestJson 执行业务代码的参数 + * @return void + **/ + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { + logger.info("======开始执行资金拨付回调有度税务和中信司库插件========"); + return null; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java index 010cd33e..014bb5f6 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java @@ -22,6 +22,8 @@ import com.hzya.frame.mdm.mdmModuleDistributeTripartite.entity.MdmModuleDistribu import com.hzya.frame.mdm.mdmModuleSendLog.dao.IMdmModuleSendLogDao; import com.hzya.frame.mdm.mdmModuleSendLog.entity.MdmModuleSendLogEntity; import com.hzya.frame.mdm.service.IMdmServiceCache; +import com.hzya.frame.plugin.ht.entity.ApplyInvoiceEntity; +import com.hzya.frame.plugin.ht.service.IApplyInvoiceService; import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao; import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; import com.hzya.frame.sys.sysenum.SysEnum; @@ -82,6 +84,8 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity { @Resource private IMdmModuleDistributeTripartiteDao mdmModuleDistributeTripartiteDao; @Autowired + private IApplyInvoiceService applyInvoiceService; + @Autowired private IInvoiceDao invoiceDao; @Value("${zt.url}") private String url ; @@ -1233,7 +1237,17 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity { InvoiceEntity invoiceEntity = new InvoiceEntity(); invoiceEntity.setId(data_id); invoiceEntity.setResult_status(message); + invoiceEntity.setDataSourceCode("HT-OA"); invoiceDao.updateInvoiceResult(invoiceEntity); + //查询待办,退回流程用,这里只处理退回的情况,如果要处理提交,要等开票成功后才能提交,去定时查开票结果的定时任务里做 + ApplyInvoiceEntity applyInvoice = new ApplyInvoiceEntity(); + applyInvoice.setId(data_id); + applyInvoice.setDataSourceCode("HT-OA"); + ApplyInvoiceEntity applyInvoiceEntity = applyInvoiceService.queryAffair(applyInvoice); + if (null != applyInvoiceEntity){ + String stepBack = applyInvoiceService.stepBackValueOf(applyInvoiceEntity.getWorkitem_id(), message); + applyInvoiceService.process(stepBack,"8000590006"); + } } } }catch (Exception e){ diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IApplyInvoiceService.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IApplyInvoiceService.java new file mode 100644 index 00000000..448fe05d --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IApplyInvoiceService.java @@ -0,0 +1,48 @@ +package com.hzya.frame.plugin.ht.service; + +import com.hzya.frame.basedao.service.IBaseService; +import com.hzya.frame.plugin.ht.entity.ApplyInvoiceEntity; +import com.hzya.frame.web.exception.BaseSystemException; + +import java.util.List; + +/** + * @Description OA开票申请 + * @Author xiangerlin + * @Date 2025/6/21 17:56 + **/ +public interface IApplyInvoiceService extends IBaseService { + + /** + * 查询待办信息 + * 这里要指定人员 所以只会查出一条,如果查出多条那就是有问题的 + * @param entity + * @return + * @throws BaseSystemException + */ + ApplyInvoiceEntity queryAffair(ApplyInvoiceEntity entity)throws BaseSystemException; + + /** + * 流程回退参数组装 + * @param workitemId + * @param content + * @return + */ + String stepBackValueOf(String workitemId,String content); + + /** + * 流程结束参数组装 + * @param workitemId + * @param content + * @return + */ + String finishValueOf(String workitemId,String content); + + /** + * 流程处理 + * @param param + * @param apiCode + * @return + */ + String process(String param,String apiCode); +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IFundsAllocationPluginService.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IFundsAllocationPluginService.java new file mode 100644 index 00000000..addcf43a --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IFundsAllocationPluginService.java @@ -0,0 +1,21 @@ +package com.hzya.frame.plugin.ht.service; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.web.entity.JsonResultEntity; +import com.hzya.frame.web.exception.BaseSystemException; + +/** + * @Description 资金拨付 流程结束回调 需要同时回调有度税务和中信司库 + * @Author xiangerlin + * @Date 2025/6/21 14:13 + **/ +public interface IFundsAllocationPluginService { + + /** + * 资金拨付流程结束回调有度税务系统和中信司库 + * @param requestJson + * @return + * @throws BaseSystemException + */ + JsonResultEntity callback(JSONObject requestJson)throws BaseSystemException; +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IFundsAllocationService.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IFundsAllocationService.java new file mode 100644 index 00000000..45ebea50 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IFundsAllocationService.java @@ -0,0 +1,20 @@ +package com.hzya.frame.plugin.ht.service; + +import com.hzya.frame.basedao.service.IBaseService; +import com.hzya.frame.plugin.ht.entity.FundsAllocationEntity; + +import java.util.List; + +/** + * @Description OA资金拨付 formmain_0464 + * @Author xiangerlin + * @Date 2025/6/21 15:01 + **/ +public interface IFundsAllocationService extends IBaseService { + /** + * 查询审批意见 + * @param entity + * @return + */ + List queryCtpCommentList(FundsAllocationEntity entity); +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/ApplyInvoiceServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/ApplyInvoiceServiceImpl.java new file mode 100644 index 00000000..82c8fc2e --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/ApplyInvoiceServiceImpl.java @@ -0,0 +1,136 @@ +package com.hzya.frame.plugin.ht.service.impl; + +import cn.hutool.core.lang.Assert; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hzya.frame.basedao.service.impl.BaseService; +import com.hzya.frame.plugin.ht.dao.IApplyInvoiceDao; +import com.hzya.frame.plugin.ht.entity.ApplyInvoiceEntity; +import com.hzya.frame.plugin.ht.service.IApplyInvoiceService; +import com.hzya.frame.seeyon.util.OARestUtil; +import com.hzya.frame.web.exception.BaseSystemException; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Description + * @Author xiangerlin + * @Date 2025/6/21 17:56 + **/ +@Service(value = "applyInvoiceServiceImpl") +public class ApplyInvoiceServiceImpl extends BaseService implements IApplyInvoiceService { + + private IApplyInvoiceDao applyInvoiceDao; + + @Autowired + public void setApplyInvoiceDao(IApplyInvoiceDao dao) { + this.applyInvoiceDao = dao; + this.dao = dao; + } + @Value("${zt.url}") + private String interfaceUrl; + + + + + /** + * 查询待办信息 + * + * @param entity + * @return + * @throws BaseSystemException + */ + @DS("entity.dataSourceCode") + @Override + public ApplyInvoiceEntity queryAffair(ApplyInvoiceEntity entity) throws BaseSystemException { + List queryList = applyInvoiceDao.queryList(entity, "com.hzya.frame.plugin.ht.dao.impl.ApplyInvoiceDaoImpl.entity_list_affair"); + if (CollectionUtils.isNotEmpty(queryList)){ + if (queryList.size() > 1){ + throw new BaseSystemException("数据异常,查询到多条待办数据"+entity.getId()); + } + return queryList.get(0); + } + return null; + } + + /** + * 流程回退参数组装 + * + * @param workitemId + * @param content + * @return + */ + @Override + public String stepBackValueOf(String workitemId, String content) { + Assert.notEmpty(workitemId,"流程回退时workitemId 必填"); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("appName", "collaboration"); + jsonObject.put("workitemId", workitemId); + + JSONObject commentDeal = new JSONObject(); + commentDeal.put("attitude", "1");//1表示已阅 + commentDeal.put("content", content); + + JSONObject data = new JSONObject(); + data.put("isWFTrace", "0"); + data.put("comment_deal", commentDeal); + + jsonObject.put("data", data); + return jsonObject.toJSONString(); + } + + /** + * 流程结束参数组装 + * + * @param workitemId + * @param content + * @return + */ + @Override + public String finishValueOf(String workitemId, String content) { + Assert.notEmpty(workitemId,"流程回退时workitemId 必填"); + JSONObject json = new JSONObject(); + json.put("appName", "collaboration"); + json.put("workitemId", workitemId); + + JSONObject data = new JSONObject(); + data.put("submitType", "1"); + + JSONObject commentDeal = new JSONObject(); + commentDeal.put("attitude", "2");//2表示同意 + commentDeal.put("content", content); + data.put("comment_deal", commentDeal); + json.put("data", data); + return json.toJSONString(); + } + + /** + * 流程处理 + * + * @param param + * @param apiCode + * @return + */ + @Override + public String process(String param, String apiCode) { + Assert.notEmpty(param,"流程处理时参数不能为空"); + Assert.notEmpty(apiCode,"apiCode不能为空"); + logger.info("准备提交或退回流程:{},{}",apiCode,param); + String token = OARestUtil.getToken("hzya", "8000590001"); + String result = HttpRequest.post(interfaceUrl) + .header("appId", "800059")//OA应用 + .header("apiCode", apiCode)//流程提交/回退接口 + .header("token", token)//token + .header("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")//中台公钥 + .header("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//中台密钥 + .body(param)//表单内容 + .timeout(30000)//超时,毫秒 + .execute().body(); + return result; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/FundsAllocationPluginServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/FundsAllocationPluginServiceImpl.java new file mode 100644 index 00000000..78251cb9 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/FundsAllocationPluginServiceImpl.java @@ -0,0 +1,132 @@ +package com.hzya.frame.plugin.ht.service.impl; + +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.plugin.ht.entity.FundsAllocationEntity; +import com.hzya.frame.plugin.ht.service.IFundsAllocationPluginService; +import com.hzya.frame.plugin.ht.service.IFundsAllocationService; +import com.hzya.frame.seeyon.enums.ColEventTypeEnum; +import com.hzya.frame.seeyon.util.SM2Util; +import com.hzya.frame.web.entity.BaseResult; +import com.hzya.frame.web.entity.JsonResultEntity; +import com.hzya.frame.web.exception.BaseSystemException; +import org.apache.commons.collections.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Description 资金拨付 流程结束回调 需要同时回调有度税务和中信司库 + * @Author xiangerlin + * @Date 2025/6/21 14:17 + **/ +@Service(value = "fundsAllocationPluginServiceImpl") +public class FundsAllocationPluginServiceImpl implements IFundsAllocationPluginService { + Logger logger = LoggerFactory.getLogger(FundsAllocationPluginServiceImpl.class); + @Value("${zt.url}") + private String interfaceUrl; + @Value("${zx.publicKey:}") + private String publicKey; + @Autowired + private IFundsAllocationService fundsAllocationService; + /** + * 资金拨付流程结束回调有度税务系统和中信司库 + * + * @param requestJson + * @return + * @throws BaseSystemException + */ + @Override + public JsonResultEntity callback(JSONObject requestJson) throws BaseSystemException { + String dataSourceCode = requestJson.getString("apiDataSourceCode");//数据源 + String headerStr = requestJson.getString("headers");//表头 + String eventType = requestJson.getString("eventType"); + String summaryId = requestJson.getString("summaryId"); + Assert.notEmpty(dataSourceCode,"数据源不能为空"); + Assert.notEmpty(headerStr,"headers不能为空"); + Assert.notEmpty(eventType,"eventType不能为空"); + Assert.notEmpty(summaryId,"summaryId不能为空"); + JSONObject headers = requestJson.getJSONObject("headers"); + String formmainTableName = headers.getString("formmainTableName"); + JSONObject jsonStrObj = requestJson.getJSONObject("jsonStr"); + JSONObject businessData = jsonStrObj.getJSONObject("businessDataStr"); + JSONObject formmainData = businessData.getJSONObject(formmainTableName); + if (null != formmainData){ + //税务系统id,这个字段不为空时表示是税务推过来的单子 + String field0061 = formmainData.getString("field0061"); + //税务系统批次号 + String field0063 = formmainData.getString("field0063"); + if (StrUtil.isNotEmpty(field0061) || StrUtil.isNotEmpty(field0063)){ + //查询审批意见 + FundsAllocationEntity fundAllocation = new FundsAllocationEntity(); + fundAllocation.setCol_summary_id(summaryId); + List fundsAllocationList = fundsAllocationService.queryCtpCommentList(fundAllocation); + if (CollectionUtils.isNotEmpty(fundsAllocationList)){ + fundAllocation = fundsAllocationList.get(0); + } + String appId = "";//应用 + String apiCode = "";//api + String param = "";//参数 + if (StrUtil.isNotEmpty(field0061)){ + appId = "800060"; + apiCode = "8000600009"; + //税务 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("transferOrderNumber",field0061); + jsonObject.put("approvalUser",fundAllocation.getName()); + jsonObject.put("approvalTime",fundAllocation.getApproval_time()); + jsonObject.put("approvalRemark",StrUtil.isEmpty(fundAllocation.getContent()) ? "审批通过" : fundAllocation.getContent()); + if (ColEventTypeEnum.ONPROCESSFINISHED.getType().equals(eventType)){ + jsonObject.put("approvalStatus","2"); + }else if (ColEventTypeEnum.ONSTOP.getType().equals(eventType)){//审批终止 + jsonObject.put("approvalStatus","3"); + } + param = jsonObject.toJSONString(); + }else if (StrUtil.isNotEmpty(field0063)){ + appId = "800058"; + apiCode = "8000580004"; + //司库 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("batchNo",field0063); + jsonObject.put("reason",fundAllocation.getContent()); + if (ColEventTypeEnum.ONPROCESSFINISHED.getType().equals(eventType)){ + jsonObject.put("status","APPROVED"); + }else if (ColEventTypeEnum.ONSTOP.getType().equals(eventType)){//审批终止 + jsonObject.put("status","REJECTION"); + } + JSONObject objectData = new JSONObject(); + objectData.put("data",jsonObject); + logger.info("资金拨付审批回调司库请求参数明文:{}",objectData.toJSONString()); + String encrypt = SM2Util.encrypt(objectData.toJSONString(),publicKey); + JSONObject jsonData = new JSONObject(); + jsonData.put("data",encrypt); + param = jsonData.toJSONString(); + } + if (StrUtil.isNotEmpty(appId) && StrUtil.isNotEmpty(apiCode) && StrUtil.isNotEmpty(param)){ + logger.info("回调有度/司库请求apiCode{},报文:{}",apiCode,param); + String result = HttpRequest.post(interfaceUrl) + .header("appId", appId)//税务/司库应用 + .header("apiCode", apiCode)//回调接口 + .header("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj")//OA公钥 + .header("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//OA密钥 + .body(param)//表单内容 + .timeout(30000)//超时,毫秒 + .execute().body(); + logger.info("回调有度/司库返回报文:{}",result); + return BaseResult.getSuccessMessageEntity(result); + }else { + logger.info("appId、apiCode、param 其中有参数是空的,不能执行"); + } + }else { + logger.info("不是有度税务/中信司库推过来的单子,不需要执行"); + } + } + return BaseResult.getFailureMessageEntity("表单数据为空"); + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/FundsAllocationServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/FundsAllocationServiceImpl.java new file mode 100644 index 00000000..23956465 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/FundsAllocationServiceImpl.java @@ -0,0 +1,39 @@ +package com.hzya.frame.plugin.ht.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hzya.frame.basedao.service.impl.BaseService; +import com.hzya.frame.plugin.ht.dao.IFundsAllocationDao; +import com.hzya.frame.plugin.ht.entity.FundsAllocationEntity; +import com.hzya.frame.plugin.ht.service.IFundsAllocationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Description + * @Author xiangerlin + * @Date 2025/6/21 15:03 + **/ +@Service(value = "fundsAllocationServiceImpl") +public class FundsAllocationServiceImpl extends BaseService implements IFundsAllocationService { + private IFundsAllocationDao fundsAllocationDao; + @Autowired + public void setFundsAllocationDao(IFundsAllocationDao dao) { + this.fundsAllocationDao = dao; + this.dao = dao; + } + + /** + * 查询审批意见 + * + * @param entity + * @return + */ + @DS("#entity.dataSourceCode") + @Override + public List queryCtpCommentList(FundsAllocationEntity entity) { + List queryList = fundsAllocationDao.queryList(entity, "com.hzya.frame.plugin.ht.dao.impl.FundsAllocationDaoImpl.entity_ctp_comment_all"); + return queryList; + } +}