diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/dao/IProjectMainFlowDao.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/dao/IProjectMainFlowDao.java new file mode 100644 index 00000000..be836719 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/dao/IProjectMainFlowDao.java @@ -0,0 +1,42 @@ +package com.hzya.frame.plugin.projectMainFlow.dao; + +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.plugin.projectMainFlow.entity.ProjectMainFlowEntity; + +import java.util.List; + +public interface IProjectMainFlowDao extends IBaseDao { + + /** + * + * @content 查询审定完成节点得项目主流程档案 + * @Param + * @Return + * @Author hecan + * @Date 2025-01-06 16:50 + * **/ + List queryProjectMainFlowAudit(ProjectMainFlowEntity projectMainFlowEntity); + + /** + * + * @content 查询归档节点得项目主流程档案 + * @Param + * @Return + * @Author hecan + * @Date 2025-01-06 16:50 + * **/ + List queryProjectMainFlowArchivist(ProjectMainFlowEntity projectMainFlowEntity); + + /** + * + * @content 更新项目主流程审定和归档推送标识和结果 + * @Param + * @Return + * @Author hecan + * @Date 2025-01-08 11:48 + * **/ + Integer updateProjectMainFlow(ProjectMainFlowEntity projectMainFlowEntity); + + + +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/dao/impl/ProjectMainFlowDaoImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/dao/impl/ProjectMainFlowDaoImpl.java new file mode 100644 index 00000000..a00133d3 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/dao/impl/ProjectMainFlowDaoImpl.java @@ -0,0 +1,30 @@ +package com.hzya.frame.plugin.projectMainFlow.dao.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.plugin.projectMainFlow.dao.IProjectMainFlowDao; +import com.hzya.frame.plugin.projectMainFlow.entity.ProjectMainFlowEntity; +import org.springframework.stereotype.Repository; + +import java.util.List; + +public class ProjectMainFlowDaoImpl extends MybatisGenericDao implements IProjectMainFlowDao { + @DS("#entity.dataSourceCode") + @Override + public List queryProjectMainFlowAudit(ProjectMainFlowEntity entity) { + return (List)super.selectList("queryProjectMainFlowAudit",entity); + } + + @DS("#entity.dataSourceCode") + @Override + public List queryProjectMainFlowArchivist(ProjectMainFlowEntity entity) { + return (List)super.selectList("queryProjectMainFlowArchivist",entity); + } + + @DS("#entity.dataSourceCode") + @Override + public Integer updateProjectMainFlow(ProjectMainFlowEntity entity) { + return super.update("updateProjectMainFlow",entity); + } + +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/entity/ProjectMainFlowEntity.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/entity/ProjectMainFlowEntity.java new file mode 100644 index 00000000..1ffbdd94 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/entity/ProjectMainFlowEntity.java @@ -0,0 +1,269 @@ +package com.hzya.frame.plugin.projectMainFlow.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +public class ProjectMainFlowEntity extends BaseEntity { + private String completemoney;//F完工服务额 + private String def2;//F完工辅材额公司 + private String def3;//F完工辅材额自购 + private String completedate;//完工完成时间 + private String def4;//F实际完工日期 + private String auditmoney;//J审定服务金额 + private String def5;//J审定辅材额公司 + private String def6;//J审定辅材额自购 + private String auditdate;//审计完成时间 + private String pinspectiondate;//H实际初验日期 + private String def1;//I终验日期 + + private String ts;//时间 + private String pkGroup;//集团编码 + private String pkOrg;//公司编码 + private String contractno;//合同号编码 + private String contractname;//合同档案名称 + private String creator;//创建人 + private String creationtime;//创建时间 + private String projectno;//项目号 + private String completepersion;//完工填单人 + private String pinspectionmoney;//初验金额 + private String pinspectionpersion;//初验填单人 + private String auditpersion;//审计填单人 + private String forecastRevenue;//预估收入确认 + private String vnote;//备注 + + private String auditStatus;//审定推送状态 + private String auditResult;//审定推送结果 + private String archivistResult;//归档推送结果 + private String archivistStatus;//归档推送状态 + + public String getCompletemoney() { + return completemoney; + } + + public void setCompletemoney(String completemoney) { + this.completemoney = completemoney; + } + + public String getDef2() { + return def2; + } + + public void setDef2(String def2) { + this.def2 = def2; + } + + public String getDef3() { + return def3; + } + + public void setDef3(String def3) { + this.def3 = def3; + } + + public String getCompletedate() { + return completedate; + } + + public void setCompletedate(String completedate) { + this.completedate = completedate; + } + + public String getDef4() { + return def4; + } + + public void setDef4(String def4) { + this.def4 = def4; + } + + public String getAuditmoney() { + return auditmoney; + } + + public void setAuditmoney(String auditmoney) { + this.auditmoney = auditmoney; + } + + public String getDef5() { + return def5; + } + + public void setDef5(String def5) { + this.def5 = def5; + } + + public String getDef6() { + return def6; + } + + public void setDef6(String def6) { + this.def6 = def6; + } + + public String getAuditdate() { + return auditdate; + } + + public void setAuditdate(String auditdate) { + this.auditdate = auditdate; + } + + public String getPinspectiondate() { + return pinspectiondate; + } + + public void setPinspectiondate(String pinspectiondate) { + this.pinspectiondate = pinspectiondate; + } + + public String getDef1() { + return def1; + } + + public void setDef1(String def1) { + this.def1 = def1; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public String getPkGroup() { + return pkGroup; + } + + public void setPkGroup(String pkGroup) { + this.pkGroup = pkGroup; + } + + public String getPkOrg() { + return pkOrg; + } + + public void setPkOrg(String pkOrg) { + this.pkOrg = pkOrg; + } + + public String getContractno() { + return contractno; + } + + public void setContractno(String contractno) { + this.contractno = contractno; + } + + public String getContractname() { + return contractname; + } + + public void setContractname(String contractname) { + this.contractname = contractname; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getCreationtime() { + return creationtime; + } + + public void setCreationtime(String creationtime) { + this.creationtime = creationtime; + } + + public String getProjectno() { + return projectno; + } + + public void setProjectno(String projectno) { + this.projectno = projectno; + } + + public String getCompletepersion() { + return completepersion; + } + + public void setCompletepersion(String completepersion) { + this.completepersion = completepersion; + } + + public String getPinspectionmoney() { + return pinspectionmoney; + } + + public void setPinspectionmoney(String pinspectionmoney) { + this.pinspectionmoney = pinspectionmoney; + } + + public String getPinspectionpersion() { + return pinspectionpersion; + } + + public void setPinspectionpersion(String pinspectionpersion) { + this.pinspectionpersion = pinspectionpersion; + } + + public String getAuditpersion() { + return auditpersion; + } + + public void setAuditpersion(String auditpersion) { + this.auditpersion = auditpersion; + } + + public String getForecastRevenue() { + return forecastRevenue; + } + + public void setForecastRevenue(String forecastRevenue) { + this.forecastRevenue = forecastRevenue; + } + + public String getVnote() { + return vnote; + } + + public void setVnote(String vnote) { + this.vnote = vnote; + } + + public String getAuditStatus() { + return auditStatus; + } + + public void setAuditStatus(String auditStatus) { + this.auditStatus = auditStatus; + } + + public String getAuditResult() { + return auditResult; + } + + public void setAuditResult(String auditResult) { + this.auditResult = auditResult; + } + + public String getArchivistResult() { + return archivistResult; + } + + public void setArchivistResult(String archivistResult) { + this.archivistResult = archivistResult; + } + + public String getArchivistStatus() { + return archivistStatus; + } + + public void setArchivistStatus(String archivistStatus) { + this.archivistStatus = archivistStatus; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/entity/ProjectMainFlowEntity.xml b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/entity/ProjectMainFlowEntity.xml new file mode 100644 index 00000000..d28dd044 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/entity/ProjectMainFlowEntity.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + formmain_0219.id as id + ,'SW01' as pkGroup -- 集团编码 + ,'666' as pkOrg -- 公司编码 + ,field0274 as contractno -- 合同号 + ,field0279 as contractname -- 合同名称 + ,field0081 as creator -- 创建人 + ,field0003 as creationtime -- 创建时间 + ,field0007 as projectno -- 项目号 + ,field0120 as completemoney -- 完工金额 + ,field0294 as completedate -- 完工日期 + ,field0108 as completepersion -- 完工填单人 + ,field0149 as pinspectionmoney -- 初验金额 + ,field0147 as pinspectiondate -- 初验时间 + ,field0159 as pinspectionpersion -- 初验填单人 + ,field0213 as auditmoney -- 审计金额 + ,field0297 as auditdate -- 审计时间 + ,field0237 as auditpersion -- 审计填单人 + ,null as forecastRevenue -- 预估收入确认 + ,field0138 as vnote -- 备注 + ,field0120 as completemoney -- 完工服务额 + ,field0320 as def2 -- F完工辅材额公司 + ,field0321 as def3 -- F完工辅材额自购 + ,field0294 as completedate -- 完工完成时间 + ,field0112 as def4 -- F实际完工日期 + ,field0213 as auditmoney -- J审定服务金额 + ,field0354 as def5 -- J审定辅材额公司 + ,field0355 as def6 -- J审定辅材额自购 + ,field0297 as auditdate -- 审计完成时间 + ,field0147 as pinspectiondate -- H实际初验日期 + ,field0161 as def1 -- I终验日期 + ,field0427 as auditStatus -- 审定推送状态 + ,field0428 as auditResult -- 审定推送结果 + ,field0426 as archivistResult -- 归档推送结果 + ,field0425 as archivistStatus -- 归档推送状态 + + + + + + + + + + + update formmain_0219 set + + field0427 = #{auditStatus}, + field0428 = #{auditResult}, + field0426 = #{archivistResult}, + field0425 = #{archivistStatus}, + + where id = #{id} + + + + + + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/plugin/ProjectMainFlowArchivistPluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/plugin/ProjectMainFlowArchivistPluginInitializer.java new file mode 100644 index 00000000..5860277f --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/plugin/ProjectMainFlowArchivistPluginInitializer.java @@ -0,0 +1,217 @@ +package com.hzya.frame.plugin.projectMainFlow.plugin; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.plugin.SendContract.entity.SendContractEntity; +import com.hzya.frame.plugin.projectMainFlow.dao.IProjectMainFlowDao; +import com.hzya.frame.plugin.projectMainFlow.entity.ProjectMainFlowEntity; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService; +import com.hzya.frame.uuid.UUIDUtils; +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; +import org.springframework.beans.factory.annotation.Value; + +import java.util.Date; +import java.util.List; + +public class ProjectMainFlowArchivistPluginInitializer extends PluginBaseEntity { + + Logger logger = LoggerFactory.getLogger(ProjectMainFlowArchivistPluginInitializer.class); + + @Autowired + private IProjectMainFlowDao projectMainFlowDao; + + @Autowired + private IIntegrationTaskLivingDetailsService taskLivingDetailsService; + + @Value("${zt.url}") + private String url; + + @Override + public void initialize() { + logger.info(getPluginLabel() + "執行初始化方法initialize()"); + } + + @Override + public void destroy() { + logger.info(getPluginLabel() + "執行銷毀方法destroy()"); + } + + @Override + public String getPluginId() { + return "ProjectMainFlowArchivistPluginInitializer"; + } + + @Override + public String getPluginName() { + return "项目主流程审定"; + } + + @Override + public String getPluginLabel() { + return "ProjectMainFlowArchivistPluginInitializer"; + } + + @Override + public String getPluginType() { + return "1"; + } + + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) { + try { + logger.info("======开始执行项目主流程归档推送BIP========"); + //重试方法 + if (null != requestJson) { + //如果这个id不为空,说明是重试的 + String id = requestJson.getString("integration_task_living_details_id"); + //执行重新发送 + ProjectMainFlowEntity projectMainFlowEntity = new ProjectMainFlowEntity(); + projectMainFlowEntity.setDataSourceCode("SW-OA"); + if (StrUtil.isNotEmpty(id)) { + projectMainFlowEntity.setId(id); + } + //查询审定之后数据 + List projectMainFlowEntities = projectMainFlowDao.queryProjectMainFlowArchivist(projectMainFlowEntity); + if(projectMainFlowEntities == null || projectMainFlowEntities.size() == 0){ + logger.info("=====查询项目主流程归档数据有:{}条",projectMainFlowEntities.size()); + return BaseResult.getSuccessMessageEntity("查询成功"); + } + for (ProjectMainFlowEntity mainFlowEntity : projectMainFlowEntities) { + //组装数据 + JSONObject sendData = getSendData(mainFlowEntity); + JSONObject tokenData = getBipTokenData(); + mainFlowEntity.setDataSourceCode("SW-OA"); + //获取TOKEN + String tokenResult = HttpRequest.post(url). + header("appId", "800050"). + header("apiCode", "8000500003"). + header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj"). + header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). + body(tokenData.toString()). + execute(). + body(); + logger.error("项目主流程归档BIPtoken返回结果:"+tokenResult); + JSONObject tokenResultJson = JSONObject.parseObject(tokenResult); + if(!tokenResultJson.getBoolean("flag")){ + mainFlowEntity.setArchivistStatus("0"); + mainFlowEntity.setArchivistResult("执行失败,Token获取失败"); + projectMainFlowDao.updateProjectMainFlow(mainFlowEntity); + continue; + } + String tokenBody = tokenResultJson.getJSONObject("attribute").getJSONObject("data").getString("access_token"); + //发送数据 + String result = HttpRequest.post(url). + header("appId", "800050"). + header("apiCode", "8000500016"). + header("access_token", tokenBody). + header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj"). + header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). + body(sendData.toString()). + execute(). + body(); + logger.error("项目主流程归档之后返回结果:"+result); + JSONObject resultJson = JSONObject.parseObject(result); + if(!resultJson.getBoolean("flag")){ + mainFlowEntity.setArchivistStatus("0"); + mainFlowEntity.setArchivistResult("归档发送失败"+resultJson.getString("msg")); + projectMainFlowDao.updateProjectMainFlow(mainFlowEntity); + saveTaskLivingDetails(mainFlowEntity.getId(),mainFlowEntity.getId(),sendData.toString(),resultJson.toJSONString(),false); + }else { + mainFlowEntity.setArchivistStatus("1"); + mainFlowEntity.setArchivistResult("归档发送成功"); + projectMainFlowDao.updateProjectMainFlow(mainFlowEntity); + saveTaskLivingDetails(mainFlowEntity.getId(),mainFlowEntity.getId(),sendData.toString(),resultJson.toJSONString(),true); + } + } + } + logger.info("=======项目主流程归档推送BIP执行成功======="); + return BaseResult.getSuccessMessageEntity("项目主流程归档执行成功"); + } catch (Exception e) { + logger.info("======执行项目主流程归档推送BIP失败:{}========", e.getMessage()); + e.printStackTrace(); + } + return BaseResult.getFailureMessageEntity("项目主流程归档执行失败"); + } + + + private JSONObject getBipTokenData() { + JSONObject jsonObject = new JSONObject(); + + + + return jsonObject; + } + + + private JSONObject getSendData(ProjectMainFlowEntity projectMainFlowEntity) { + JSONObject htdd01Master = new JSONObject(); + JSONObject bill = new JSONObject(); + JSONObject htdd01slave4_htdd01slave4 = new JSONObject(); + JSONArray jsonArray=new JSONArray(); + htdd01Master.put("pk_group",projectMainFlowEntity.getPkGroup()); + htdd01Master.put("pk_org",projectMainFlowEntity.getPkOrg()); + htdd01Master.put("contractno",projectMainFlowEntity.getContractno()); + htdd01Master.put("name",projectMainFlowEntity.getContractname()); + // htdd01Master.put("creator",projectMainFlowEntity.getCreator()); + // htdd01Master.put("creationtime",projectMainFlowEntity.getCreationtime()); + + htdd01slave4_htdd01slave4.put("contractno",projectMainFlowEntity.getContractno()); + htdd01slave4_htdd01slave4.put("projectno",projectMainFlowEntity.getProjectno()); + htdd01slave4_htdd01slave4.put("completemoney",projectMainFlowEntity.getCompletemoney()); + htdd01slave4_htdd01slave4.put("completedate",projectMainFlowEntity.getCompletedate()); + htdd01slave4_htdd01slave4.put("completepersion",projectMainFlowEntity.getCompletepersion()); + htdd01slave4_htdd01slave4.put("pinspectionmoney",projectMainFlowEntity.getPinspectionmoney()); + htdd01slave4_htdd01slave4.put("pinspectiondate",projectMainFlowEntity.getPinspectiondate()); + htdd01slave4_htdd01slave4.put("pinspectionpersion",projectMainFlowEntity.getPinspectionpersion()); + htdd01slave4_htdd01slave4.put("auditmoney",projectMainFlowEntity.getAuditmoney()); + htdd01slave4_htdd01slave4.put("auditdate",projectMainFlowEntity.getAuditdate()); + htdd01slave4_htdd01slave4.put("auditpersion",projectMainFlowEntity.getAuditpersion()); + htdd01slave4_htdd01slave4.put("forecast_revenue",projectMainFlowEntity.getForecastRevenue()); + htdd01slave4_htdd01slave4.put("vnote",projectMainFlowEntity.getVnote()); + htdd01slave4_htdd01slave4.put("def1",projectMainFlowEntity.getDef1()); + htdd01slave4_htdd01slave4.put("def2",projectMainFlowEntity.getDef2()); + htdd01slave4_htdd01slave4.put("def3",projectMainFlowEntity.getDef3()); + htdd01slave4_htdd01slave4.put("def4",projectMainFlowEntity.getDef4()); + htdd01slave4_htdd01slave4.put("def5",projectMainFlowEntity.getDef5()); + htdd01slave4_htdd01slave4.put("def6",projectMainFlowEntity.getDef6()); + jsonArray.add(htdd01slave4_htdd01slave4); + bill.put("htdd01Master",htdd01Master); + bill.put("htdd01slave4_htdd01slave4",jsonArray); + return bill; + } + + + private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) { + try { + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID()); + integrationTaskLivingDetailsEntity.setSts("Y"); + integrationTaskLivingDetailsEntity.setCreate_user_id("1"); + integrationTaskLivingDetailsEntity.setModify_user_id("1"); + integrationTaskLivingDetailsEntity.setCreate_time(new Date()); + integrationTaskLivingDetailsEntity.setModify_time(new Date()); + integrationTaskLivingDetailsEntity.setOrg_id("0"); + integrationTaskLivingDetailsEntity.setCompanyId("0"); + integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk); + integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill); + integrationTaskLivingDetailsEntity.setPluginId("ProjectMainFlowArchivistPluginInitializer"); + integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo); + if(flag){ + taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity); + }else { + taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity); + } + }catch (Exception e){ + logger.info("保存日志到集成任务日志明细中失败:{}",e.getMessage()); + } + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/plugin/ProjectMainFlowAuditPluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/plugin/ProjectMainFlowAuditPluginInitializer.java new file mode 100644 index 00000000..75f6d9b9 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/plugin/ProjectMainFlowAuditPluginInitializer.java @@ -0,0 +1,209 @@ +package com.hzya.frame.plugin.projectMainFlow.plugin; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.plugin.SendContract.entity.SendContractEntity; +import com.hzya.frame.plugin.projectMainFlow.dao.IProjectMainFlowDao; +import com.hzya.frame.plugin.projectMainFlow.entity.ProjectMainFlowEntity; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService; +import com.hzya.frame.uuid.UUIDUtils; +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; +import org.springframework.beans.factory.annotation.Value; + +import java.util.Date; +import java.util.List; + +public class ProjectMainFlowAuditPluginInitializer extends PluginBaseEntity { + + Logger logger = LoggerFactory.getLogger(ProjectMainFlowAuditPluginInitializer.class); + + @Autowired + private IProjectMainFlowDao projectMainFlowDao; + + @Autowired + private IIntegrationTaskLivingDetailsService taskLivingDetailsService; + + @Value("${zt.url}") + private String url; + + @Override + public void initialize() { + logger.info(getPluginLabel() + "執行初始化方法initialize()"); + } + + @Override + public void destroy() { + logger.info(getPluginLabel() + "執行銷毀方法destroy()"); + } + + @Override + public String getPluginId() { + return "ProjectMainFlowAuditPluginInitializer"; + } + + @Override + public String getPluginName() { + return "项目主流程审定"; + } + + @Override + public String getPluginLabel() { + return "ProjectMainFlowAuditPluginInitializer"; + } + + @Override + public String getPluginType() { + return "1"; + } + + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) { + try { + logger.info("======开始执行项目主流程审定完成之后推送BIP========"); + //重试方法 + if (null != requestJson) { + //如果这个id不为空,说明是重试的 + String id = requestJson.getString("integration_task_living_details_id"); + //执行重新发送 + ProjectMainFlowEntity projectMainFlowEntity = new ProjectMainFlowEntity(); + projectMainFlowEntity.setDataSourceCode("SW-OA"); + if (StrUtil.isNotEmpty(id)) { + projectMainFlowEntity.setId(id); + } + //查询审定之后数据 + List projectMainFlowEntities = projectMainFlowDao.queryProjectMainFlowAudit(projectMainFlowEntity); + if(projectMainFlowEntities == null || projectMainFlowEntities.size() == 0){ + logger.info("=====查询项目主流程审定完成数据有:{}条",projectMainFlowEntities.size()); + return BaseResult.getSuccessMessageEntity("查询成功"); + } + for (ProjectMainFlowEntity mainFlowEntity : projectMainFlowEntities) { + //组装数据 + JSONObject sendData = getSendData(mainFlowEntity); + JSONObject tokenData = new JSONObject(); + mainFlowEntity.setDataSourceCode("SW-OA"); + //获取TOKEN + String tokenResult = HttpRequest.post(url). + header("appId", "800050"). + header("apiCode", "8000500003"). + header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj"). + header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). + body(tokenData.toString()). + execute(). + body(); + logger.error("项目主流程审定之后BIPtoken返回结果:"+tokenResult); + JSONObject tokenResultJson = JSONObject.parseObject(tokenResult); + if(!tokenResultJson.getBoolean("flag")){ + mainFlowEntity.setAuditStatus("0"); + mainFlowEntity.setAuditResult("执行失败,Token获取失败"); + projectMainFlowDao.updateProjectMainFlow(mainFlowEntity); + continue; + } + String tokenBody = tokenResultJson.getJSONObject("attribute").getJSONObject("data").getString("access_token"); + logger.info("====项目主流程审定请求参数======:{}",sendData.toJSONString()); + //发送数据 + String result = HttpRequest.post(url). + header("appId", "800050"). + header("apiCode", "8000500016"). + header("access_token", tokenBody). + header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj"). + header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). + body(sendData.toString()). + execute(). + body(); + logger.error("项目主流程审定之后返回结果:"+result); + JSONObject resultJson = JSONObject.parseObject(result); + if(!resultJson.getBoolean("flag")){ + mainFlowEntity.setAuditStatus("0"); + mainFlowEntity.setAuditResult("审定发送失败"+resultJson.getString("msg")); + projectMainFlowDao.updateProjectMainFlow(mainFlowEntity); + saveTaskLivingDetails(mainFlowEntity.getId(),mainFlowEntity.getId(),sendData.toString(),resultJson.toJSONString(),false); + }else { + mainFlowEntity.setAuditStatus("1"); + mainFlowEntity.setAuditResult("审定发送成功"); + projectMainFlowDao.updateProjectMainFlow(mainFlowEntity); + saveTaskLivingDetails(mainFlowEntity.getId(),mainFlowEntity.getId(),sendData.toString(),resultJson.toJSONString(),true); + } + } + } + logger.info("=======项目主流程审定完成之后推送BIP执行成功======="); + return BaseResult.getSuccessMessageEntity("项目主流程审定执行成功"); + } catch (Exception e) { + logger.info("======执行项目主流程审定完成之后推送BIP失败:{}========", e.getMessage()); + e.printStackTrace(); + } + return BaseResult.getFailureMessageEntity("项目主流程审定执行失败"); + } + + + private JSONObject getSendData(ProjectMainFlowEntity projectMainFlowEntity) { + JSONObject htdd01Master = new JSONObject(); + JSONObject bill = new JSONObject(); + JSONObject htdd01slave4_htdd01slave4 = new JSONObject(); + JSONArray jsonArray=new JSONArray(); + htdd01Master.put("pk_group",projectMainFlowEntity.getPkGroup()); + htdd01Master.put("pk_org",projectMainFlowEntity.getPkOrg()); + htdd01Master.put("contractno",projectMainFlowEntity.getContractno()); + htdd01Master.put("name",projectMainFlowEntity.getContractname()); + // htdd01Master.put("creator",projectMainFlowEntity.getCreator()); + // htdd01Master.put("creationtime",projectMainFlowEntity.getCreationtime()); + + htdd01slave4_htdd01slave4.put("contractno",projectMainFlowEntity.getContractno()); + htdd01slave4_htdd01slave4.put("projectno",projectMainFlowEntity.getProjectno()); + htdd01slave4_htdd01slave4.put("completemoney",projectMainFlowEntity.getCompletemoney()); + htdd01slave4_htdd01slave4.put("completedate",projectMainFlowEntity.getCompletedate()); + htdd01slave4_htdd01slave4.put("completepersion",projectMainFlowEntity.getCompletepersion()); + htdd01slave4_htdd01slave4.put("pinspectionmoney",projectMainFlowEntity.getPinspectionmoney()); + htdd01slave4_htdd01slave4.put("pinspectiondate",projectMainFlowEntity.getPinspectiondate()); + htdd01slave4_htdd01slave4.put("pinspectionpersion",projectMainFlowEntity.getPinspectionpersion()); + htdd01slave4_htdd01slave4.put("auditmoney",projectMainFlowEntity.getAuditmoney()); + htdd01slave4_htdd01slave4.put("auditdate",projectMainFlowEntity.getAuditdate()); + htdd01slave4_htdd01slave4.put("auditpersion",projectMainFlowEntity.getAuditpersion()); + htdd01slave4_htdd01slave4.put("forecast_revenue",projectMainFlowEntity.getForecastRevenue()); + htdd01slave4_htdd01slave4.put("vnote",projectMainFlowEntity.getVnote()); + htdd01slave4_htdd01slave4.put("def1",projectMainFlowEntity.getDef1()); + htdd01slave4_htdd01slave4.put("def2",projectMainFlowEntity.getDef2()); + htdd01slave4_htdd01slave4.put("def3",projectMainFlowEntity.getDef3()); + htdd01slave4_htdd01slave4.put("def4",projectMainFlowEntity.getDef4()); + htdd01slave4_htdd01slave4.put("def5",projectMainFlowEntity.getDef5()); + htdd01slave4_htdd01slave4.put("def6",projectMainFlowEntity.getDef6()); + jsonArray.add(htdd01slave4_htdd01slave4); + bill.put("htdd01Master",htdd01Master); + bill.put("htdd01slave4_htdd01slave4",jsonArray); + return bill; + } + + + private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) { + try { + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID()); + integrationTaskLivingDetailsEntity.setSts("Y"); + integrationTaskLivingDetailsEntity.setCreate_user_id("1"); + integrationTaskLivingDetailsEntity.setModify_user_id("1"); + integrationTaskLivingDetailsEntity.setCreate_time(new Date()); + integrationTaskLivingDetailsEntity.setModify_time(new Date()); + integrationTaskLivingDetailsEntity.setOrg_id("0"); + integrationTaskLivingDetailsEntity.setCompanyId("0"); + integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk); + integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill); + integrationTaskLivingDetailsEntity.setPluginId("ProjectMainFlowAuditPluginInitializer"); + integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo); + if(flag){ + taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity); + }else { + taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity); + } + }catch (Exception e){ + logger.info("保存日志到集成任务日志明细中失败:{}",e.getMessage()); + } + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/service/IProjectMainFlowService.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/service/IProjectMainFlowService.java new file mode 100644 index 00000000..ca376bfa --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/service/IProjectMainFlowService.java @@ -0,0 +1,9 @@ +package com.hzya.frame.plugin.projectMainFlow.service; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.basedao.service.IBaseService; +import com.hzya.frame.plugin.projectMainFlow.entity.ProjectMainFlowEntity; +import com.hzya.frame.web.entity.JsonResultEntity; + +public interface IProjectMainFlowService extends IBaseService { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/service/impl/ProjectMainFlowServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/service/impl/ProjectMainFlowServiceImpl.java new file mode 100644 index 00000000..3010db59 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/projectMainFlow/service/impl/ProjectMainFlowServiceImpl.java @@ -0,0 +1,24 @@ +package com.hzya.frame.plugin.projectMainFlow.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.basedao.service.impl.BaseService; +import com.hzya.frame.plugin.SendContract.dao.ISendContractDao; +import com.hzya.frame.plugin.projectMainFlow.dao.IProjectMainFlowDao; +import com.hzya.frame.plugin.projectMainFlow.entity.ProjectMainFlowEntity; +import com.hzya.frame.plugin.projectMainFlow.service.IProjectMainFlowService; +import com.hzya.frame.web.entity.BaseResult; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +public class ProjectMainFlowServiceImpl extends BaseService implements IProjectMainFlowService { + + private IProjectMainFlowDao projectMainFlowDao; + + @Autowired + public void setProjectMainFlowDao(IProjectMainFlowDao dao) { + this.projectMainFlowDao = dao; + this.dao = dao; + } + +} diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/pluginCfg.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/pluginCfg.xml new file mode 100644 index 00000000..f3c30ca6 --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/pluginCfg.xml @@ -0,0 +1,6 @@ + + +ProjectMainFlowAuditPluginInitializer +ProjectMainFlowAuditPluginInitializer插件 +90000001 + diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/spring/spring-buildpackage-dao.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/spring/spring-buildpackage-dao.xml new file mode 100644 index 00000000..31689d52 --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/spring/spring-buildpackage-dao.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/spring/spring-buildpackage-plugin.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/spring/spring-buildpackage-plugin.xml new file mode 100644 index 00000000..e1a4e5f1 --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/projectMainFlow/spring/spring-buildpackage-plugin.xml @@ -0,0 +1,6 @@ + + + + + +