From 259120d74ac067f48548f8c3a10eeb6e89780694 Mon Sep 17 00:00:00 2001 From: lvleigang <957075182@qq.com> Date: Thu, 28 Aug 2025 14:53:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frame/plugin/ht/dao/IStopAffairDao.java | 16 ++ .../plugin/ht/dao/impl/StopAffairDaoImpl.java | 26 +++ .../plugin/ht/entity/StopAffairEntity.java | 57 +++++++ .../plugin/ht/entity/StopAffairEntity.xml | 26 +++ .../plugin/StopAffairPluginInitializer.java | 105 ++++++++++++ .../plugin/ht/service/IStopAffairService.java | 24 +++ .../service/impl/StopAffairServiceImpl.java | 150 ++++++++++++++++++ .../ht/spring/spring-buildpackage-plugin.xml | 1 + 8 files changed, 405 insertions(+) create mode 100644 base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IStopAffairDao.java create mode 100644 base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/StopAffairDaoImpl.java create mode 100644 base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/StopAffairEntity.java create mode 100644 base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/StopAffairEntity.xml create mode 100644 base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/StopAffairPluginInitializer.java create mode 100644 base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IStopAffairService.java create mode 100644 base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/StopAffairServiceImpl.java diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IStopAffairDao.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IStopAffairDao.java new file mode 100644 index 00000000..775887e7 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/IStopAffairDao.java @@ -0,0 +1,16 @@ +package com.hzya.frame.plugin.ht.dao; + +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.plugin.ht.entity.BipProjectEntity; +import com.hzya.frame.plugin.ht.entity.StopAffairEntity; + +import java.util.List; + +/** + * @Description + * @Author xiangerlin + * @Date 2025/6/21 14:23 + **/ +public interface IStopAffairDao extends IBaseDao { + List getStopAffair(StopAffairEntity entity); +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/StopAffairDaoImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/StopAffairDaoImpl.java new file mode 100644 index 00000000..30e56939 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/dao/impl/StopAffairDaoImpl.java @@ -0,0 +1,26 @@ +package com.hzya.frame.plugin.ht.dao.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.plugin.ht.dao.IBipProjectDao; +import com.hzya.frame.plugin.ht.dao.IStopAffairDao; +import com.hzya.frame.plugin.ht.entity.BipProjectEntity; +import com.hzya.frame.plugin.ht.entity.StopAffairEntity; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @Description + * @Author xiangerlin + * @Date 2025/6/21 14:24 + **/ +@Repository(value = "stopAffairDaoImpl") +public class StopAffairDaoImpl extends MybatisGenericDao implements IStopAffairDao { + + @DS("#entity.dataSourceCode") + @Override + public List getStopAffair(StopAffairEntity entity) { + return super.query(getSqlIdPrifx() + "getStopAffair",entity); + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/StopAffairEntity.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/StopAffairEntity.java new file mode 100644 index 00000000..a77ed757 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/StopAffairEntity.java @@ -0,0 +1,57 @@ +package com.hzya.frame.plugin.ht.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +/** + * @Description + * @Author xiangerlin + * @Date 2025/6/21 14:19 + **/ +public class StopAffairEntity extends BaseEntity { + + private String colSummaryId;//流程id + private String ctpAffairId;//待办id + private String loginName;//登陆人 + private String workitemId;//流程处理和回退要用这个id + private String dataTime;//日期 + + public String getColSummaryId() { + return colSummaryId; + } + + public void setColSummaryId(String colSummaryId) { + this.colSummaryId = colSummaryId; + } + + public String getCtpAffairId() { + return ctpAffairId; + } + + public void setCtpAffairId(String ctpAffairId) { + this.ctpAffairId = ctpAffairId; + } + + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + public String getWorkitemId() { + return workitemId; + } + + public void setWorkitemId(String workitemId) { + this.workitemId = workitemId; + } + + public String getDataTime() { + return dataTime; + } + + public void setDataTime(String dataTime) { + this.dataTime = dataTime; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/StopAffairEntity.xml b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/StopAffairEntity.xml new file mode 100644 index 00000000..1435359d --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/entity/StopAffairEntity.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/StopAffairPluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/StopAffairPluginInitializer.java new file mode 100644 index 00000000..92b5a182 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/StopAffairPluginInitializer.java @@ -0,0 +1,105 @@ +package com.hzya.frame.plugin.ht.plugin; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.plugin.ht.service.IFundsAllocationPluginService; +import com.hzya.frame.plugin.ht.service.IStopAffairService; +import com.hzya.frame.web.entity.BaseResult; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @Description 资金归集流程终止 + * @Author xiangerlin + * @Date 2025/6/21 14:06 + **/ +public class StopAffairPluginInitializer extends PluginBaseEntity { + Logger logger = LoggerFactory.getLogger(StopAffairPluginInitializer.class); + + @Autowired + private IStopAffairService stopAffairService; + /*** + * 插件初始化方法 + * @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 "StopAffairPlugin"; + } + + /**** + * 插件的名称 + * @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("======开始执行资金归集流程终止========"); + stopAffairService.sendStopAffair(requestJson); + logger.info("======结束资金归集流程终止========"); + return BaseResult.getSuccessMessageEntity("执行成功"); + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IStopAffairService.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IStopAffairService.java new file mode 100644 index 00000000..20992ee5 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/IStopAffairService.java @@ -0,0 +1,24 @@ +package com.hzya.frame.plugin.ht.service; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.basedao.service.IBaseService; +import com.hzya.frame.plugin.ht.entity.BipProjectEntity; +import com.hzya.frame.plugin.ht.entity.StopAffairEntity; +import com.hzya.frame.web.entity.JsonResultEntity; + +/** + * @Description 资金归集流程终止 + * @Author xiangerlin + * @Date 2025/6/21 15:01 + **/ +public interface IStopAffairService extends IBaseService { + + /** + * @Author lvleigang + * @Description 资金归集流程终止 + * @Date 2:51 下午 2025/8/11 + * @param requestJson + * @return com.hzya.frame.web.entity.JsonResultEntity + **/ + JsonResultEntity sendStopAffair(JSONObject requestJson); +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/StopAffairServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/StopAffairServiceImpl.java new file mode 100644 index 00000000..1d450923 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/service/impl/StopAffairServiceImpl.java @@ -0,0 +1,150 @@ +package com.hzya.frame.plugin.ht.service.impl; + +import cn.hutool.core.util.StrUtil; +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.IFundsAllocationDao; +import com.hzya.frame.plugin.ht.dao.IStopAffairDao; +import com.hzya.frame.plugin.ht.entity.FundsAllocationEntity; +import com.hzya.frame.plugin.ht.entity.StopAffairEntity; +import com.hzya.frame.plugin.ht.service.IFundsAllocationService; +import com.hzya.frame.plugin.ht.service.IStopAffairService; +import com.hzya.frame.web.entity.BaseResult; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description 资金归集流程终止 + * @Author xiangerlin + * @Date 2025/6/21 15:03 + **/ +@Service(value = "stopAffairServiceImpl") +public class StopAffairServiceImpl extends BaseService implements IStopAffairService { + + private IStopAffairDao stopAffairDao; + + @Value("${zt.url}") + private String url; + @Autowired + public void setStopAffairDao(IStopAffairDao dao) { + this.stopAffairDao = dao; + this.dao = dao; + } + + /** + * @param requestJson + * @return com.hzya.frame.web.entity.JsonResultEntity + * @Author lvleigang + * @Description 资金归集流程终止 + * @Date 2:51 下午 2025/8/11 + **/ + @Override + public JsonResultEntity sendStopAffair(JSONObject requestJson) { + //格式化日期 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String data = sdf.format(new Date()); + //获取数据 + StopAffairEntity stopAffairEntity = new StopAffairEntity(); + stopAffairEntity.setDataSourceCode("HT-OA"); + stopAffairEntity.setDataTime(data); + List stopAffairEntityList = stopAffairDao.getStopAffair(stopAffairEntity); + if(stopAffairEntityList == null || stopAffairEntityList.size() == 0){ + return BaseResult.getSuccessMessageEntity("处理资金归集流程终止成功"); + } + List list = filterByColSummaryId(stopAffairEntityList); + if(list == null || list.size() == 0){ + return BaseResult.getSuccessMessageEntity("处理资金归集流程终止成功"); + } + for (int i = 0; i < list.size(); i++) { + String token = getTokens("ZZZH"); + //String senddata = getStopAffair(list.get(i).getWorkitemId(),list.get(i).getLoginName()); + String senddata = getStopAffair(list.get(i).getWorkitemId(),"ZZZH"); + String returnData = doSendData("8000590007",token,senddata); + logger.error("终止流程返回结果"+returnData); + if (StrUtil.isNotEmpty(returnData)){ + logger.error("终止流程返回结果"+returnData); + } + } + return BaseResult.getSuccessMessageEntity("处理资金归集流程终止成功"); + } + + private String getStopAffair(String workitemId,String loginName) { + JSONObject json = new JSONObject(); + json.put("affairId", workitemId); + json.put("repealComment", ""); + json.put("member", loginName);//当前处理人登录名 + return json.toJSONString(); + } + private String doSendData(String apiCode,String token,String param) { + String result = HttpRequest.post(url) + .header("appId", "800059") + .header("apiCode", apiCode) + .header("token", token)//token + .header("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj")//OA公钥 + .header("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//OA密钥 + .body(param)//表单内容 + .timeout(30000)//超时,毫秒 + .execute().body(); + logger.error("Oa返回报文:{}",result); + return result; + } + private String getTokens(String loginName) { + String token = null; + JSONObject param = new JSONObject(); + // 向JSON对象中添加键值对 + param.put("password", "b19afb1a-5a72-43db-84e1-e84aa4c571b5"); + param.put("userName", "YDRest"); + param.put("loginName", loginName); + + String result = HttpRequest.post(url) + .header("appId", "800059") + .header("apiCode", "8000590001") + .header("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj")//OA公钥 + .header("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//OA密钥 + .body(param.toJSONString())//表单内容 + .timeout(30000)//超时,毫秒 + .execute().body(); + logger.error("OaToken返回报文:{}",result); + if (StrUtil.isNotEmpty(result)){ + JSONObject tokenObj = JSONObject.parseObject(result); + String code = tokenObj.getString("status"); + if ("200".equals(code)){ + JSONObject attribute = tokenObj.getJSONObject("attribute"); + if (null != attribute){ + token = attribute.getString("id"); + } + } + } + return token; + } + public List filterByColSummaryId(List entityList) { + // key: colSummaryId 的值,value: 对应的 StopAffairEntity(优先保留 loginName 为 ZZZH 的) + Map map = new HashMap<>(); + for (StopAffairEntity entity : entityList) { + String colSummaryId = entity.getColSummaryId(); + if (map.containsKey(colSummaryId)) { + StopAffairEntity existingEntity = map.get(colSummaryId); + // 如果当前实体 loginName 是 ZZZH,或者已存在的实体 loginName 不是 ZZZH 时,替换 + if ("ZZZH".equals(entity.getLoginName()) + || !"ZZZH".equals(existingEntity.getLoginName())) { + map.put(colSummaryId, entity); + } + } else { + map.put(colSummaryId, entity); + } + } + // 将 Map 的值转换为 List 返回 + return new ArrayList<>(map.values()); + } +} diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/ht/spring/spring-buildpackage-plugin.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/ht/spring/spring-buildpackage-plugin.xml index 82030376..e388b0b0 100644 --- a/base-buildpackage/src/main/resources/cfgHome/plugin/ht/spring/spring-buildpackage-plugin.xml +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/ht/spring/spring-buildpackage-plugin.xml @@ -7,5 +7,6 @@ +