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 new file mode 100644 index 00000000..14fc3fe7 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java @@ -0,0 +1,1550 @@ +package com.hzya.frame.plugin.ht.plugin; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao; +import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity; +import com.hzya.frame.mdm.mdmModuleDb.entity.MdmModuleDbEntity; +import com.hzya.frame.mdm.mdmModuleDbFileds.entity.MdmModuleDbFiledsEntity; +import com.hzya.frame.mdm.mdmModuleDbFiledsRule.dao.IMdmModuleDbFiledsRuleDao; +import com.hzya.frame.mdm.mdmModuleDbFiledsRule.entity.MdmModuleDbFiledsRuleEntity; +import com.hzya.frame.mdm.mdmModuleDistribute.dao.IMdmModuleDistributeDao; +import com.hzya.frame.mdm.mdmModuleDistribute.entity.MdmModuleDistributeEntity; +import com.hzya.frame.mdm.mdmModuleDistributeDetail.dao.IMdmModuleDistributeDetailDao; +import com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity; +import com.hzya.frame.mdm.mdmModuleDistributeTripartite.dao.IMdmModuleDistributeTripartiteDao; +import com.hzya.frame.mdm.mdmModuleDistributeTripartite.entity.MdmModuleDistributeTripartiteEntity; +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.sys.sysenum.SysEnum; +import com.hzya.frame.sysnew.application.api.dao.ISysApplicationApiDao; +import com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity; +import com.hzya.frame.sysnew.application.dao.ISysApplicationDao; +import com.hzya.frame.sysnew.application.entity.SysApplicationEntity; +import com.hzya.frame.sysnew.application.script.dao.ISysApplicationScriptDao; +import com.hzya.frame.sysnew.application.script.entity.SysApplicationScriptEntity; +import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService; +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.apache.http.HttpEntity; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.*; + +public class InvoiceDistributePluginInitializer extends PluginBaseEntity { + Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private IMdmModuleDistributeDetailDao mdmModuleDistributeDetailDao; + @Resource + private IIntegrationTaskLivingDetailsService taskLivingDetailsService; + @Resource + private ISysApplicationApiDao sysApplicationApiDao; + @Resource + private ISysApplicationDao sysApplicationDao; + @Resource + private ISysApplicationScriptDao sysApplicationScriptDao; + @Resource + private IMdmModuleDistributeDao mdmModuleDistributeDao; + @Resource + private IGroovyIntegrationService groovyIntegrationService; + @Resource + private IMdmModuleDbFiledsRuleDao mdmModuleDbFiledsRuleDao; + @Resource + private IMdmModuleDao mdmModuleDao; + @Resource + private IMdmServiceCache mdmServiceCache; + @Resource + private IMdmModuleSendLogDao mdmModuleSendLogDao; + @Resource + private IMdmModuleDistributeTripartiteDao mdmModuleDistributeTripartiteDao; + @Value("${zt.url}") + private String url ; + + private final Object lock = new Object(); + + /*** + * 插件初始化方法 + * @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 "InvoiceDistributePluginInitializer"; + } + + /**** + * 插件的名称 + * @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 { + try{ + //重试方法 + if (null != requestJson) { + //如果这个id不为空,说明是重试的 + String id = requestJson.getString("integration_task_living_details_id"); + //执行重新发送 + if (StrUtil.isNotEmpty(id)) { + //查询日志表 + IntegrationTaskLivingDetailsEntity taskDetailEntity = taskLivingDetailsService.get(id); + if (null != taskDetailEntity && JSONUtil.isTypeJSON(taskDetailEntity.getRootAppPk())){ + //拿到这张表的源系统ID + JSONObject jsonObject = JSONObject.parseObject(taskDetailEntity.getRootAppPk()); + Long mdmCode = jsonObject.getLong("mdmCode");//主数据编码 + String documentRule = jsonObject.getString("documentRule");//行数据的单据规则编码 + String distributeId = jsonObject.getString("distributeId");//发送表id + String type = jsonObject.getString("type");//发送类型,1、新增2、修改3、删除 + if(mdmCode == null || documentRule == null || distributeId == null || type == null + || "".equals(mdmCode) || "".equals(documentRule) || "".equals(distributeId) || "".equals(type)){ + taskDetailEntity.setResult("系统保存参数错误"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("系统保存参数错误"); + } + String apiId = null; + String scriptId = null; + //查找对应数据,组装数据发送 + + //获取主数据信息 + MdmModuleEntity mdmModuleEntity = mdmServiceCache.getMdmModuleEntity(mdmCode); + if(mdmModuleEntity == null || mdmModuleEntity.getId() == null ){ + taskDetailEntity.setResult("主数据不存在"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("主数据不存在"); + + } + + //获取主数据db + MdmModuleDbEntity mdmModuleDbEntity = new MdmModuleDbEntity(); + mdmModuleDbEntity.setMdmId(mdmModuleEntity.getId()); + List mdmModuleDbEntities = mdmServiceCache.queryMdmModuleDb(mdmModuleDbEntity); + if(mdmModuleDbEntities == null || mdmModuleDbEntities.size() == 0){ + taskDetailEntity.setResult("主数据数据源不存在"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("主数据数据源不存在"); + + } + + //获取分发表 + //获取分发的接口 + MdmModuleDistributeEntity mdmModuleDistributeEntity = mdmModuleDistributeDao.get(distributeId); + if(mdmModuleDistributeEntity == null || mdmModuleDistributeEntity.getId() == null ){ + taskDetailEntity.setResult("分发不存在"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("分发不存在"); + + } + // 启用停用 0、停用 + if("0".equals(mdmModuleDistributeEntity.getEnabledState())){ + taskDetailEntity.setResult("分发已停用"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("分发已停用"); + + } + MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ; + mdmModuleDistributeDetailEntity.setDistributeId(distributeId); + mdmModuleDistributeDetailEntity.setSts("Y"); + List mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity); + + // 启用停用 0、停用 + //if("1".equals(mdmModuleDistributeEntity.getEnabledType())){ + // taskDetailEntity.setResult("分发为手动下发"); + // taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + // return BaseResult.getFailureMessageEntity("分发为手动下发"); + //} + //1、新增2、修改3、删除 + if("1".equals(type)){ + apiId = mdmModuleDistributeEntity.getAddApi(); + scriptId = mdmModuleDistributeEntity.getAddScript(); + }else if("2".equals(type)){ + apiId = mdmModuleDistributeEntity.getUpdateApi(); + scriptId = mdmModuleDistributeEntity.getUpdateScript(); + + }else if("3".equals(type)){ + apiId = mdmModuleDistributeEntity.getDeleteApi(); + scriptId = mdmModuleDistributeEntity.getDeleteScript(); + } + if(apiId == null || "".equals(apiId)){ + taskDetailEntity.setResult("分发接口未选择,请先选择"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("分发接口未选择,请先选择"); + + } + SysApplicationScriptEntity scriptEntity = null; + if(scriptId != null && !"".equals(scriptId)){ + scriptEntity = sysApplicationScriptDao.get(scriptId); + if(scriptEntity == null || scriptEntity.getId() == null ){ + taskDetailEntity.setResult("分发接口脚本不存在"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("分发接口脚本不存在"); + } + } + SysApplicationApiEntity apiEntity = sysApplicationApiDao.get(apiId); + if(apiEntity == null || apiEntity.getId() == null ){ + taskDetailEntity.setResult("分发接口不存在"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("分发接口不存在"); + + } + SysApplicationEntity sysApplicationEntity = sysApplicationDao.get(apiEntity.getAppId()); + if(sysApplicationEntity == null || sysApplicationEntity.getId() == null ){ + taskDetailEntity.setResult("应用不存在"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("应用不存在"); + } + + //获取主数据db字段,以及字段的规则 + MdmModuleDbFiledsEntity queryFild = new MdmModuleDbFiledsEntity(); + queryFild.setMdmId(mdmModuleEntity.getId()); + List mdmModuleDbFiledsEntities = mdmServiceCache.queryMdmModuleDbFileds(queryFild); + MdmModuleDbFiledsRuleEntity queryFildRule = new MdmModuleDbFiledsRuleEntity(); + queryFildRule.setMdmId(mdmModuleEntity.getId()); + queryFildRule.setRuleCode("service"); + List mdmModuleDbFiledsRuleEntities = mdmModuleDbFiledsRuleDao.queryBase(queryFildRule); + + //获取主数据db对应的实体表的数据 + JSONObject object = new JSONObject(); + for (int i = 0; i < mdmModuleDbEntities.size(); i++) { + if("1".equals(mdmModuleDbEntities.get(i).getDbType())){ + Map map = new HashMap<>(); + map.put("tableName",mdmModuleDbEntities.get(i).getDbName()); + map.put("documentRule",documentRule); + object = mdmModuleDao.queryMdmST(map); + object = toLowerCaseKeys(object); + if(object.getString("id") == null || "".equals(object.getString("id")) ){ + taskDetailEntity.setResult("当前数据不存在"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("当前数据不存在"); + } + if(mdmModuleDistributeDetailEntities != null && mdmModuleDistributeDetailEntities.size() > 0){ + Map checkData = new HashMap<>(); + checkData.put("tableName",mdmModuleDbEntities.get(i).getDbName()); + checkData.put("documentRule",documentRule); + checkData.put("mdmModuleDistributeDetailEntities",mdmModuleDistributeDetailEntities); + JSONObject object1 = mdmModuleDao.queryMdmST(checkData); + object1 = toLowerCaseKeys(object1); + + if(object1.getString("id") == null || "".equals(object1.getString("id")) ){ + taskDetailEntity.setResult("当前数据不符合规则不发送"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("当前数据不符合规则不发送"); + } + } + //查看主表是否有字段是关联的 + if(mdmModuleDbFiledsRuleEntities != null && mdmModuleDbFiledsRuleEntities.size() > 0){ + for (int i1 = 0; i1 < mdmModuleDbFiledsRuleEntities.size(); i1++) { + if(mdmModuleDbFiledsRuleEntities.get(i1).getDbId().equals(mdmModuleDbEntities.get(i).getId())){ + if(mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0){ + for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) { + if(mdmModuleDbFiledsRuleEntities.get(i1).getFiledId().equals(mdmModuleDbFiledsEntities.get(i2).getId())){ + if(object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){ + Map mapDetail = new HashMap<>(); + mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); + String ids = object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName()); + String[] idss = ids.split(","); + mapDetail.put("id", idss[idss.length-1]); + JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); + objectDetail = toLowerCaseKeys(objectDetail); + object.put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + } + } + } + } + } + } + } + } + } + + for (int i = 0; i < mdmModuleDbEntities.size(); i++) { + if("2".equals(mdmModuleDbEntities.get(i).getDbType())){ + Map map = new HashMap<>(); + map.put("tableName",mdmModuleDbEntities.get(i).getDbName()); + map.put("formmainId",object.getString("id")); + List detail = mdmModuleDao.queryMdmSTDetail(map); + detail = toLowerCaseKeys(detail); + + //查看主表是否有字段是关联的 + if(detail != null && detail.size() > 0){ + if(mdmModuleDbFiledsRuleEntities != null && mdmModuleDbFiledsRuleEntities.size() > 0){ + for (int i1 = 0; i1 < mdmModuleDbFiledsRuleEntities.size(); i1++) { + if(mdmModuleDbFiledsRuleEntities.get(i1).getDbId().equals(mdmModuleDbEntities.get(i).getId())){ + if(mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0){ + for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) { + if(mdmModuleDbFiledsRuleEntities.get(i1).getFiledId().equals(mdmModuleDbFiledsEntities.get(i2).getId())){ + for (int i3 = 0; i3 < detail.size(); i3++) { + if(detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){ + Map mapDetail = new HashMap<>(); + mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); + String ids = detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()); + String[] idss = ids.split(","); + mapDetail.put("id", idss[idss.length-1]); + + JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); + objectDetail = toLowerCaseKeys(objectDetail); + + detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + } + + } + } + } + } + } + } + } + } + object.put(mdmModuleDbEntities.get(i).getDbName(),detail); + } + } + //执行脚本 + JSONObject groovy = new JSONObject(); + JSONObject parameterJson = new JSONObject(); + parameterJson.put("header",apiEntity.getHeaderIn()); + parameterJson.put("body",apiEntity.getBodyIn()); + parameterJson.put("query",apiEntity.getQueryIn()); + parameterJson.put("data",object); + + if (!"1".equals(type)) {//删除或者修改情况,查询三方id,有就设置,没有就设置空 + //1、根据主数据id、数据id、应用ID默认查询主数据应用下发三方id表,只查询最新的一条数据 + MdmModuleDistributeTripartiteEntity mdmModuleDistributeTripartiteEntity = new MdmModuleDistributeTripartiteEntity(); + mdmModuleDistributeTripartiteEntity.setSts("Y"); + mdmModuleDistributeTripartiteEntity.setMdmId(mdmModuleEntity.getId()); + mdmModuleDistributeTripartiteEntity.setDataId(object.getString("id")); + mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); + mdmModuleDistributeTripartiteEntity = mdmModuleDistributeTripartiteDao.queryOneTripartite(mdmModuleDistributeTripartiteEntity); + String tripartiteId = ""; + if(mdmModuleDistributeTripartiteEntity != null && mdmModuleDistributeTripartiteEntity.getTripartiteId() != null ){ + tripartiteId = mdmModuleDistributeTripartiteEntity.getTripartiteId(); + } + parameterJson.put("tripartiteId", tripartiteId); + } + /** head */ + Map header = null; + /** query */ + String querys = null; + /** body */ + String bodys = object.toJSONString(); + if(scriptEntity != null && scriptEntity.getId() != null ){ + groovy.put("code",scriptEntity.getScriptCode()); + groovy.put("className",scriptEntity.getClassName()); + groovy.put("name",scriptEntity.getScriptName()); + groovy.put("methodStr",scriptEntity.getScriptData()); + groovy.put("parameterJson",parameterJson); + JSONObject groovyStr = new JSONObject(); + groovyStr.put("jsonStr",groovy); + try { + Object str = groovyIntegrationService.groovyScriptExecution(groovyStr); + JSONObject jsonResultEntity = JSONObject.parseObject(str.toString()); + header = (Map) jsonResultEntity.get("header"); + querys = jsonResultEntity.getString("querys"); + bodys = jsonResultEntity.getString("bodys"); + }catch (Exception e){ + taskDetailEntity.setResult("分发脚本转换错误"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("分发脚本转换错误"); + } + } + Map headers = new HashMap<>(); + headers.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); + headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); + headers.put("appId",sysApplicationEntity.getAppId().toString()); + headers.put("apiCode",apiEntity.getApiCode().toString()); + if(header != null){ + headers.putAll(header); + } + if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + //找到登陆接口 + SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); + if (null == loginApi) { + taskDetailEntity.setResult("发送错误,认证接口不存在"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("发送错误,认证接口不存在"); + } + String rzquerys = getQuery(loginApi,null,null); + Map headersa = new HashMap<>(); + headersa.put("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); + headersa.put("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); + headersa.put("appId", sysApplicationEntity.getAppId().toString()); + headersa.put("apiCode", loginApi.getApiCode().toString()); + Map rzheaders = getHeaders(loginApi,headersa,null); + String rzbodys = getBodys(loginApi,null,null); + JsonResultEntity rzjsonResultEntity = sendData(loginApi,rzheaders,rzbodys,rzquerys); + if (!rzjsonResultEntity.isFlag()) { + taskDetailEntity.setResult("发送错误,认证接口错误"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("发送错误:"+rzjsonResultEntity.getMsg()); + } + JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); + logger.info("认证接口返回信息:"+ attritube.toJSONString()); + querys = getQuery(apiEntity,querys,attritube); + headers = getHeaders(apiEntity,headers,attritube); + + bodys = getBodys(apiEntity,bodys,attritube); + } + //组装数据发送 + JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); + if(jsonResultEntity.isFlag()){ + if ("1".equals(type)) {//保存三方返回id + if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) { + JSONObject backScriptJson = new JSONObject(); + backScriptJson.put("data", jsonResultEntity.getAttribute()); + groovy.put("code", scriptEntity.getScriptCode()+"back"); + groovy.put("className", scriptEntity.getClassName()+"back"); + groovy.put("name", scriptEntity.getScriptName()+"back"); + groovy.put("methodStr", scriptEntity.getBackScriptData()); + groovy.put("parameterJson", backScriptJson); + JSONObject groovyStr = new JSONObject(); + groovyStr.put("jsonStr", groovy); + try { + Object str = groovyIntegrationService.groovyScriptExecution(groovyStr); + if(str != null){ + JSONObject backJsonResultEntity = JSONObject.parseObject(str.toString()); + if(backJsonResultEntity != null && backJsonResultEntity.getString("success") != null && "true".equals(backJsonResultEntity.getString("success"))){ + MdmModuleDistributeTripartiteEntity mdmModuleDistributeTripartiteEntity = new MdmModuleDistributeTripartiteEntity(); + mdmModuleDistributeTripartiteEntity.setCreate(); + mdmModuleDistributeTripartiteEntity.setMdmId(mdmModuleEntity.getId()); + mdmModuleDistributeTripartiteEntity.setDataId(object.getString("id")); + mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); + mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId")); + mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity); + } + } + } catch (Exception e) { + logger.info("执行异常错误原因:"+e); + logger.error("新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute()); + taskDetailEntity.setResult("新增返回脚本解析保存三方id错误"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("发送错误"); + } + } + } + taskDetailEntity.setResult("发送成功"); + taskLivingDetailsService.saveLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("发送成功"); + }else { + taskDetailEntity.setResult("发送错误"); + taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); + return BaseResult.getFailureMessageEntity("发送错误"); + } + } + }else {//执行正常下发 + logger.info("==========开始执行正常蓝字发票申请单申请数据下发============="); + //查询主数据 + MdmModuleEntity queryMdmModuleEntity = new MdmModuleEntity(); + queryMdmModuleEntity.setSts("Y"); + queryMdmModuleEntity.setMdmCode(Long.valueOf("10049")); + List mdmModuleEntities = mdmModuleDao.queryBase(queryMdmModuleEntity); + if(mdmModuleEntities == null || mdmModuleEntities.size() == 0){ + return BaseResult.getSuccessMessageEntity("蓝字发票申请单申请数据未设置,不需要下发"); + } + //查询下发的配置 没有直接跳过 + for (int i = 0; i < mdmModuleEntities.size(); i++) { + Long mdmCode = mdmModuleEntities.get(i).getMdmCode(); + MdmModuleDistributeEntity queryMdmModuleDistributeEntity = new MdmModuleDistributeEntity(); + queryMdmModuleDistributeEntity.setMdmId(mdmModuleEntities.get(i).getId()); + queryMdmModuleDistributeEntity.setEnabledType("1"); + queryMdmModuleDistributeEntity.setEnabledState("1"); + List mdmModuleDistributeEntities = mdmModuleDistributeDao.queryBase(queryMdmModuleDistributeEntity); + if(mdmModuleDistributeEntities == null || mdmModuleDistributeEntities.size() == 0){ + continue; + } + //查询主数据db + MdmModuleDbEntity queryMdmModuleDbEntity = new MdmModuleDbEntity(); + queryMdmModuleDbEntity.setMdmId(mdmModuleEntities.get(i).getId()); + List mdmModuleDbEntities = mdmServiceCache.queryMdmModuleDb(queryMdmModuleDbEntity); + if(mdmModuleDbEntities == null || mdmModuleDbEntities.size() == 0){ + continue; + } + //查询主数据字段 + MdmModuleDbFiledsEntity queryFild = new MdmModuleDbFiledsEntity(); + queryFild.setMdmId(mdmModuleEntities.get(i).getId()); + List mdmModuleDbFiledsEntities = mdmServiceCache.queryMdmModuleDbFileds(queryFild); + if(mdmModuleDbFiledsEntities == null || mdmModuleDbFiledsEntities.size() == 0){ + continue; + } + //字段的规则 + MdmModuleDbFiledsRuleEntity queryFildRule = new MdmModuleDbFiledsRuleEntity(); + queryFildRule.setMdmId(mdmModuleEntities.get(i).getId()); + queryFildRule.setRuleCode("service"); + List mdmModuleDbFiledsRuleEntities = mdmModuleDbFiledsRuleDao.queryBase(queryFildRule); + //新增 + doAdd(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); + //修改 + doUpdate(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); + //删除 + doDelete(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); + } + + } + } + logger.info("执行成功"); + return BaseResult.getSuccessMessageEntity("执行成功"); + } catch (Exception e) { + logger.error("执行失败{}",e.getMessage()); + } + return BaseResult.getSuccessMessageEntity("执行成功"); + } + + private void doDelete(String mdmId,Long mainCode,List mdmModuleDbEntities, List mdmModuleDistributeEntities, List mdmModuleDbFiledsRuleEntities, List mdmModuleDbFiledsEntities) throws Exception { + //查询一千条数据 + String mainDb = null; + List objects = new ArrayList<>(); + for (int i2 = 0; i2 < mdmModuleDbEntities.size(); i2++) { + if("1".equals(mdmModuleDbEntities.get(i2).getDbType())) { + mainDb = mdmModuleDbEntities.get(i2).getDbName(); + } + } + if(mainDb == null){ + return; + } + Map map1 = new HashMap<>(); + map1.put("tableName",mainDb); + map1.put("dataStatus", "N"); + map1.put("deleteStatus", "0"); + map1.put("size", 50); + objects = mdmModuleDao.queryMdmSTs(map1); + objects = toLowerCaseKeys(objects); + + if(objects == null || objects.size() == 0){ + return; + } + for (int i1 = 0; i1 < mdmModuleDistributeEntities.size(); i1++) { + //查询下发的配置 + MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ; + mdmModuleDistributeDetailEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId()); + mdmModuleDistributeDetailEntity.setSts("Y"); + List mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity); + //查询这一千条数据是否符合规则 + Map map = new HashMap<>(); + map.put("tableName", mainDb); + map.put("dataStatus", "N"); + map.put("deleteStatus", "0"); + map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities); + map.put("ids", objects); + List doObjects = mdmModuleDao.queryMdmSTs(map); + doObjects = toLowerCaseKeys(doObjects); + + if(doObjects == null || doObjects.size() == 0){ + continue; + } + if(mdmModuleDistributeEntities.get(i1).getDeleteApi() == null || "".equals(mdmModuleDistributeEntities.get(i1).getDeleteApi())){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","删除接口未设置",mainDb,objects.get(i).getString("id"),null,null,null,null,doObjects.get(i).toJSONString(),"3"); + } + return ; + } + SysApplicationApiEntity apiEntity = sysApplicationApiDao.get(mdmModuleDistributeEntities.get(i1).getDeleteApi()); + if(apiEntity == null || apiEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","删除接口未找到",mainDb,objects.get(i).getString("id"),null,null,null,null,doObjects.get(i).toJSONString(),"3"); + } + return ; + } + SysApplicationEntity sysApplicationEntity = sysApplicationDao.get(apiEntity.getAppId()); + if(sysApplicationEntity == null || sysApplicationEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","删除接口的应用未找到",mainDb,objects.get(i).getString("id"),null,null,apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"3"); + } + return ; + } + + SysApplicationScriptEntity scriptEntity = null; + if(mdmModuleDistributeEntities.get(i1).getDeleteScript() != null && !"".equals(mdmModuleDistributeEntities.get(i1).getDeleteScript())){ + scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getDeleteScript()); + if(scriptEntity == null || scriptEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","删除接口脚本未找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"3"); + } + return ; + } + } + + for (int i = 0; i < doObjects.size(); i++) { + //查询发送日志是否已经有这条数据 + MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity(); + mdmModuleSendLogEntity.setTableName(mainDb+"_send_log"); + mdmModuleSendLogEntity.setFormmainId(doObjects.get(i).getString("id")); + mdmModuleSendLogEntity.setSts("Y"); + mdmModuleSendLogEntity.setAppId(sysApplicationEntity.getId()); + mdmModuleSendLogEntity.setApiId(apiEntity.getId()); + //mdmModuleSendLogEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId()); + mdmModuleSendLogEntity.setOptionType("3"); + Integer num = mdmModuleSendLogDao.getCount(mdmModuleSendLogEntity); + if(num > 0){//已经过不发送 + continue; + } + getDetailData(mdmModuleDbEntities,doObjects.get(i),mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); + + //执行脚本 + JSONObject groovy = new JSONObject(); + JSONObject parameterJson = new JSONObject(); + parameterJson.put("header",apiEntity.getHeaderIn()); + parameterJson.put("body",apiEntity.getBodyIn()); + parameterJson.put("query",apiEntity.getQueryIn()); + parameterJson.put("data",doObjects.get(i)); + + //1、根据主数据id、数据id、应用ID默认查询主数据应用下发三方id表,只查询最新的一条数据 + MdmModuleDistributeTripartiteEntity mdmModuleDistributeTripartiteEntity = new MdmModuleDistributeTripartiteEntity(); + mdmModuleDistributeTripartiteEntity.setSts("Y"); + mdmModuleDistributeTripartiteEntity.setMdmId(mdmId); + mdmModuleDistributeTripartiteEntity.setDataId(objects.get(i).getString("id")); + mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); + mdmModuleDistributeTripartiteEntity = mdmModuleDistributeTripartiteDao.queryOneTripartite(mdmModuleDistributeTripartiteEntity); + String tripartiteId = ""; + if(mdmModuleDistributeTripartiteEntity != null && mdmModuleDistributeTripartiteEntity.getTripartiteId() != null ){ + tripartiteId = mdmModuleDistributeTripartiteEntity.getTripartiteId(); + } + parameterJson.put("tripartiteId", tripartiteId); + + /** head */ + Map header = null; + /** query */ + String querys = null; + /** body */ + String bodys = doObjects.get(i).toJSONString(); + if(scriptEntity != null && scriptEntity.getId() != null ){ + groovy.put("code",scriptEntity.getScriptCode()); + groovy.put("className",scriptEntity.getClassName()); + groovy.put("name",scriptEntity.getScriptName()); + groovy.put("methodStr",scriptEntity.getScriptData()); + groovy.put("parameterJson",parameterJson); + JSONObject groovyStr = new JSONObject(); + groovyStr.put("jsonStr",groovy); + try { + Object str = groovyIntegrationService.groovyScriptExecution(groovyStr); + JSONObject jsonResultEntity = JSONObject.parseObject(str.toString()); + header = (Map) jsonResultEntity.get("header"); + querys = jsonResultEntity.getString("querys"); + bodys = jsonResultEntity.getString("bodys"); + }catch (Exception e){ + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"3"); + continue; + } + } + Map headers = new HashMap<>(); + headers.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); + headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); + headers.put("appId",sysApplicationEntity.getAppId().toString()); + headers.put("apiCode",apiEntity.getApiCode().toString()); + if(header != null){ + headers.putAll(header); + } + if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + //找到登陆接口 + SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); + if (null == loginApi) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + continue; + } + String rzquerys = getQuery(loginApi,null,null); + Map headersa = new HashMap<>(); + headersa.put("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); + headersa.put("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); + headersa.put("appId", sysApplicationEntity.getAppId().toString()); + headersa.put("apiCode", loginApi.getApiCode().toString()); + Map rzheaders = getHeaders(loginApi,headersa,null); + String rzbodys = getBodys(loginApi,null,null); + JsonResultEntity rzjsonResultEntity = sendData(loginApi,rzheaders,rzbodys,rzquerys); + if (!rzjsonResultEntity.isFlag()) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + continue; + } + JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); + querys = getQuery(apiEntity,querys,attritube); + headers = getHeaders(apiEntity,headers,attritube); + bodys = getBodys(apiEntity,bodys,attritube); + } + //组装数据发送 + JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); + if(jsonResultEntity.isFlag()){ + //保存日志 + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"3"); + continue; + }else { + //保存日志 + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"3"); + continue; + } + } + + } + + //所有下发发送完成,修改数据状态 + for (int i = 0; i < objects.size(); i++) { + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + updateMap.put("dataStatus", "N"); + updateMap.put("deleteStatus", "1"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); + } + } + + private void doUpdate(String mdmId,Long mainCode,List mdmModuleDbEntities, List mdmModuleDistributeEntities, List mdmModuleDbFiledsRuleEntities, List mdmModuleDbFiledsEntities) throws Exception { + //查询一千条数据 + String mainDb = null; + List objects = new ArrayList<>(); + for (int i2 = 0; i2 < mdmModuleDbEntities.size(); i2++) { + if("1".equals(mdmModuleDbEntities.get(i2).getDbType())) { + mainDb = mdmModuleDbEntities.get(i2).getDbName(); + } + } + if(mainDb == null){ + return; + } + Map map1 = new HashMap<>(); + map1.put("tableName",mainDb); + //map1.put("dataStatus", "F"); + map1.put("updateStatus", "0"); + map1.put("size", 50); + objects = mdmModuleDao.queryMdmSTs(map1); + objects = toLowerCaseKeys(objects); + + if(objects == null || objects.size() == 0){ + return; + } + for (int i1 = 0; i1 < mdmModuleDistributeEntities.size(); i1++) { + //查询下发的配置 + MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ; + mdmModuleDistributeDetailEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId()); + mdmModuleDistributeDetailEntity.setSts("Y"); + List mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity); + //查询这一千条数据是否符合规则 + Map map = new HashMap<>(); + map.put("tableName", mainDb); + //map.put("dataStatus", "F"); + map.put("updateStatus", "0"); + map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities); + map.put("ids", objects); + List doObjects = mdmModuleDao.queryMdmSTs(map); + doObjects = toLowerCaseKeys(doObjects); + + if(doObjects == null || doObjects.size() == 0){ + continue; + } + if(mdmModuleDistributeEntities.get(i1).getUpdateApi() == null || "".equals(mdmModuleDistributeEntities.get(i1).getUpdateApi())){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","修改接口未设置",mainDb,objects.get(i).getString("id"),null,null,null,null,doObjects.get(i).toJSONString(),"2"); + } + return ; + } + SysApplicationApiEntity apiEntity = sysApplicationApiDao.get(mdmModuleDistributeEntities.get(i1).getUpdateApi()); + if(apiEntity == null || apiEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","修改接口未查找到",mainDb,objects.get(i).getString("id"),null,null,null,null,doObjects.get(i).toJSONString(),"2"); + } + return ; + } + SysApplicationEntity sysApplicationEntity = sysApplicationDao.get(apiEntity.getAppId()); + if(sysApplicationEntity == null || sysApplicationEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","应用未查找到",mainDb,objects.get(i).getString("id"),null,null,apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2"); + } + return ; + } + + SysApplicationScriptEntity scriptEntity = null; + if(mdmModuleDistributeEntities.get(i1).getUpdateScript() != null && !"".equals(mdmModuleDistributeEntities.get(i1).getUpdateScript())){ + scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getUpdateScript()); + if(scriptEntity == null || scriptEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本未查找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2"); + } + return ; + } + } + + for (int i = 0; i < doObjects.size(); i++) { + + getDetailData(mdmModuleDbEntities,doObjects.get(i),mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); + + //执行脚本 + JSONObject groovy = new JSONObject(); + JSONObject parameterJson = new JSONObject(); + parameterJson.put("header",apiEntity.getHeaderIn()); + parameterJson.put("body",apiEntity.getBodyIn()); + parameterJson.put("query",apiEntity.getQueryIn()); + parameterJson.put("data",doObjects.get(i)); + //1、根据主数据id、数据id、应用ID默认查询主数据应用下发三方id表,只查询最新的一条数据 + MdmModuleDistributeTripartiteEntity mdmModuleDistributeTripartiteEntity = new MdmModuleDistributeTripartiteEntity(); + mdmModuleDistributeTripartiteEntity.setSts("Y"); + mdmModuleDistributeTripartiteEntity.setMdmId(mdmId); + mdmModuleDistributeTripartiteEntity.setDataId(objects.get(i).getString("id")); + mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); + mdmModuleDistributeTripartiteEntity = mdmModuleDistributeTripartiteDao.queryOneTripartite(mdmModuleDistributeTripartiteEntity); + String tripartiteId = ""; + if(mdmModuleDistributeTripartiteEntity != null && mdmModuleDistributeTripartiteEntity.getTripartiteId() != null ){ + tripartiteId = mdmModuleDistributeTripartiteEntity.getTripartiteId(); + } + parameterJson.put("tripartiteId", tripartiteId); + /** head */ + Map header = null; + /** query */ + String querys = null; + /** body */ + String bodys = doObjects.get(i).toJSONString(); + if(scriptEntity != null && scriptEntity.getId() != null ){ + logger.info("=========开始执行正常开票申请单申请数据修改下发脚本,第一次=============="); + groovy.put("code",scriptEntity.getScriptCode()); + groovy.put("className",scriptEntity.getClassName()); + groovy.put("name",scriptEntity.getScriptName()); + groovy.put("methodStr",scriptEntity.getScriptData()); + groovy.put("parameterJson",parameterJson); + JSONObject groovyStr = new JSONObject(); + groovyStr.put("jsonStr",groovy); + try { + Object str = groovyIntegrationService.groovyScriptExecution(groovyStr); + JSONObject jsonResultEntity = JSONObject.parseObject(str.toString()); + header = (Map) jsonResultEntity.get("header"); + querys = jsonResultEntity.getString("querys"); + bodys = jsonResultEntity.getString("bodys"); + }catch (Exception e){ + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2"); + continue; + } + } + Map headers = new HashMap<>(); + headers.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); + headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); + headers.put("appId",sysApplicationEntity.getAppId().toString()); + headers.put("apiCode",apiEntity.getApiCode().toString()); + if(header != null){ + headers.putAll(header); + } + if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + logger.info("=========正常开票申请单申请数据修改开始执行登录接口=============="); + //找到登陆接口 + SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); + if (null == loginApi) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + continue; + } + String rzquerys = getQuery(loginApi,null,null); + Map headersa = new HashMap<>(); + headersa.put("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); + headersa.put("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); + headersa.put("appId", sysApplicationEntity.getAppId().toString()); + headersa.put("apiCode", loginApi.getApiCode().toString()); + Map rzheaders = getHeaders(loginApi,headersa,null); + String rzbodys = getBodys(loginApi,null,null); + JsonResultEntity rzjsonResultEntity = sendData(loginApi,rzheaders,rzbodys,rzquerys); + if (!rzjsonResultEntity.isFlag()) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + continue; + } + JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); + logger.info("=======开票申请单申请数据正常修改下发登录返回数据:{}========",attritube.toJSONString()); + querys = getQuery(apiEntity,querys,attritube); + headers = getHeaders(apiEntity,headers,attritube); + bodys = getBodys(apiEntity,bodys,attritube); + } + //组装数据发送 + logger.info("=========开始执行开票申请单申请业务修改数据下发脚本,第二次=============="); + JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); + logger.info("=====开票申请单申请数据修改下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString()); + if(jsonResultEntity.isFlag()){ + //保存日志 + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2"); + continue; + }else { + //保存日志 + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2"); + continue; + } + } + } + + //所有下发发送完成,修改数据状态 + for (int i = 0; i < objects.size(); i++) { + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "F"); + updateMap.put("updateStatus", "1"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); + } + } + + private void doAdd(String mdmId,Long mainCode,List mdmModuleDbEntities, List mdmModuleDistributeEntities,List mdmModuleDbFiledsRuleEntities,List mdmModuleDbFiledsEntities ) throws Exception { + //查询一千条数据 + String mainDb = null; + List objects = new ArrayList<>(); + for (int i2 = 0; i2 < mdmModuleDbEntities.size(); i2++) { + if("1".equals(mdmModuleDbEntities.get(i2).getDbType())) { + mainDb = mdmModuleDbEntities.get(i2).getDbName(); + } + } + if(mainDb == null){ + return; + } + Map map1 = new HashMap<>(); + map1.put("tableName",mainDb); + //map1.put("dataStatus", "Y"); + map1.put("addStatus", "0"); + objects = mdmModuleDao.queryMdmSTs(map1); + objects = toLowerCaseKeys(objects); + + if(objects == null || objects.size() == 0){ + return; + } + for (int i1 = 0; i1 < mdmModuleDistributeEntities.size(); i1++) { + //查询下发的配置 + MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ; + mdmModuleDistributeDetailEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId()); + mdmModuleDistributeDetailEntity.setSts("Y"); + List mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity); + //查询这一千条数据是否符合规则 + Map map = new HashMap<>(); + map.put("tableName", mainDb); + //map.put("dataStatus", "Y"); + map.put("addStatus", "0"); + map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities); + map.put("ids", objects); + List doObjects = mdmModuleDao.queryMdmSTs(map); + doObjects = toLowerCaseKeys(doObjects); + + if(doObjects == null || doObjects.size() == 0){ + continue; + } + if(mdmModuleDistributeEntities.get(i1).getAddApi() == null || "".equals(mdmModuleDistributeEntities.get(i1).getAddApi())){ + for (int i = 0; i < doObjects.size(); i++) { + //taskLivingDetailsService.saveLogToSuccess(); + saveMdmModuleSendLogEntity( mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","新增接口未设置",mainDb,objects.get(i).getString("id"),null,null,null,null,doObjects.get(i).toJSONString(),"1"); + } + return ; + } + SysApplicationApiEntity apiEntity = sysApplicationApiDao.get(mdmModuleDistributeEntities.get(i1).getAddApi()); + if(apiEntity == null || apiEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","新增接口未查找到",mainDb,objects.get(i).getString("id"),null,null,null,null,doObjects.get(i).toJSONString(),"1"); + } + return ; + } + SysApplicationEntity sysApplicationEntity = sysApplicationDao.get(apiEntity.getAppId()); + if(sysApplicationEntity == null || sysApplicationEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","应用未查找到",mainDb,objects.get(i).getString("id"),null,null,apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + } + return ; + } + + SysApplicationScriptEntity scriptEntity = null; + if(mdmModuleDistributeEntities.get(i1).getAddScript() != null && !"".equals(mdmModuleDistributeEntities.get(i1).getAddScript())){ + scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getAddScript()); + if(scriptEntity == null || scriptEntity.getId() == null ){ + for (int i = 0; i < doObjects.size(); i++) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本未查找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + } + return ; + } + } + + for (int i = 0; i < doObjects.size(); i++) { + //查询是否已经手动发送过。只有新增校验,查询发送日志是否已经有这条数据 + MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity(); + mdmModuleSendLogEntity.setTableName(mainDb+"_send_log"); + mdmModuleSendLogEntity.setFormmainId(doObjects.get(i).getString("id")); + mdmModuleSendLogEntity.setSts("Y"); + mdmModuleSendLogEntity.setDataType("1"); + mdmModuleSendLogEntity.setAppId(sysApplicationEntity.getId()); + mdmModuleSendLogEntity.setApiId(apiEntity.getId()); + //mdmModuleSendLogEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId()); + mdmModuleSendLogEntity.setOptionType("1"); + Integer num = mdmModuleSendLogDao.getCount(mdmModuleSendLogEntity); + if(num > 0){//已经新增过不发送 + continue; + } + getDetailData(mdmModuleDbEntities,doObjects.get(i),mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); + + //执行脚本 + JSONObject groovy = new JSONObject(); + JSONObject parameterJson = new JSONObject(); + parameterJson.put("header",apiEntity.getHeaderIn()); + parameterJson.put("body",apiEntity.getBodyIn()); + parameterJson.put("query",apiEntity.getQueryIn()); + parameterJson.put("data",doObjects.get(i)); + //1、根据主数据id、数据id、应用ID默认查询主数据应用下发三方id表,只查询最新的一条数据 + MdmModuleDistributeTripartiteEntity mdmModuleDistributeTripartiteEntity1 = new MdmModuleDistributeTripartiteEntity(); + mdmModuleDistributeTripartiteEntity1.setSts("Y"); + mdmModuleDistributeTripartiteEntity1.setMdmId(mdmId); + mdmModuleDistributeTripartiteEntity1.setDataId(objects.get(i).getString("id")); + mdmModuleDistributeTripartiteEntity1.setAppId(sysApplicationEntity.getId()); + mdmModuleDistributeTripartiteEntity1 = mdmModuleDistributeTripartiteDao.queryOneTripartite(mdmModuleDistributeTripartiteEntity1); + String tripartiteId = ""; + if(mdmModuleDistributeTripartiteEntity1 != null && mdmModuleDistributeTripartiteEntity1.getTripartiteId() != null ){ + tripartiteId = mdmModuleDistributeTripartiteEntity1.getTripartiteId(); + } + parameterJson.put("tripartiteId", tripartiteId); + /** head */ + Map header = null; + /** query */ + String querys = null; + /** body */ + String bodys = doObjects.get(i).toJSONString(); + if(scriptEntity != null && scriptEntity.getId() != null ){ + logger.info("=========开始执行正常开票申请单申请数据新增下发脚本,第一次=============="); + groovy.put("code",scriptEntity.getScriptCode()); + groovy.put("className",scriptEntity.getClassName()); + groovy.put("name",scriptEntity.getScriptName()); + groovy.put("methodStr",scriptEntity.getScriptData()); + groovy.put("parameterJson",parameterJson); + JSONObject groovyStr = new JSONObject(); + groovyStr.put("jsonStr",groovy); + try { + Object str = groovyIntegrationService.groovyScriptExecution(groovyStr); + JSONObject jsonResultEntity = JSONObject.parseObject(str.toString()); + header = (Map) jsonResultEntity.get("header"); + querys = jsonResultEntity.getString("querys"); + bodys = jsonResultEntity.getString("bodys"); + }catch (Exception e){ + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + continue; + } + } + Map headers = new HashMap<>(); + headers.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); + headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); + headers.put("appId",sysApplicationEntity.getAppId().toString()); + headers.put("apiCode",apiEntity.getApiCode().toString()); + if(header != null){ + headers.putAll(header); + } + if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + /* logger.info("=========正常开票申请单申请数据新增开始执行登录接口=============="); + //找到登陆接口 + SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); + if (null == loginApi) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + continue; + } + String rzquerys = getQuery(loginApi,null,null); + Map headersa = new HashMap<>(); + headersa.put("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); + headersa.put("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); + headersa.put("appId", sysApplicationEntity.getAppId().toString()); + headersa.put("apiCode", loginApi.getApiCode().toString()); + Map rzheaders = getHeaders(loginApi,headersa,null); + String rzbodys = getBodys(loginApi,null,null); + JsonResultEntity rzjsonResultEntity = sendData(loginApi,rzheaders,rzbodys,rzquerys); + if (!rzjsonResultEntity.isFlag()) { + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + continue; + }*/ + JSONObject jsonObject=new JSONObject(); + jsonObject.put("accessKey","6X3B526P5HqE6ums"); + jsonObject.put("accessSecret","34e5fc32ac894a2ba2ade8c3852c7a0a"); + //获取TOKEN + String tokenResult = HttpRequest.post(url). + header("appId", "800060"). + header("apiCode", "8000600004"). + header("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"). + header("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). + body(jsonObject.toJSONString()). + execute(). + body(); + logger.error("开票申请推送BIPtoken返回结果:"+tokenResult); + JSONObject attritube = JSONObject.parseObject(JSONObject.parseObject(tokenResult).getString("attribute")); + logger.info("=======开票申请单申请数据正常新增下发登录返回数据:{}========",attritube.toJSONString()); + querys = getQuery(apiEntity,querys,attritube); + headers = getHeaders(apiEntity,headers,attritube); + headers.remove(""); + bodys = getBodys(apiEntity,bodys,attritube); + } + + //组装数据发送 + logger.info("=========开始执行开票申请单申请新增数据下发脚本,第二次=============="); + JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); + logger.info("=====开票申请单申请数据新增下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString()); + if(jsonResultEntity.isFlag()){ + if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) { + logger.info("=========开始执行开票申请单申请数据新增返回脚本=============="); + JSONObject backScriptJson = new JSONObject(); + backScriptJson.put("data", jsonResultEntity.getAttribute()); + groovy.put("code", scriptEntity.getScriptCode()+"back"); + groovy.put("className", scriptEntity.getClassName()+"back"); + groovy.put("name", scriptEntity.getScriptName()+"back"); + groovy.put("methodStr", scriptEntity.getBackScriptData()); + groovy.put("parameterJson", backScriptJson); + JSONObject groovyStr = new JSONObject(); + groovyStr.put("jsonStr", groovy); + try { + Object str = groovyIntegrationService.groovyScriptExecution(groovyStr); + if(str != null){ + JSONObject backJsonResultEntity = JSONObject.parseObject(str.toString()); + if(backJsonResultEntity != null && backJsonResultEntity.getString("success") != null && "true".equals(backJsonResultEntity.getString("success"))){ + MdmModuleDistributeTripartiteEntity mdmModuleDistributeTripartiteEntity = new MdmModuleDistributeTripartiteEntity(); + mdmModuleDistributeTripartiteEntity.setId(UUIDUtils.getUUID()); + mdmModuleDistributeTripartiteEntity.setSts("Y"); + mdmModuleDistributeTripartiteEntity.setCreate_user_id("1"); + mdmModuleDistributeTripartiteEntity.setModify_user_id("1"); + mdmModuleDistributeTripartiteEntity.setCreate_time(new Date()); + mdmModuleDistributeTripartiteEntity.setModify_time(new Date()); + mdmModuleDistributeTripartiteEntity.setOrg_id("0"); + mdmModuleDistributeTripartiteEntity.setCompanyId("0"); + mdmModuleDistributeTripartiteEntity.setMdmId(mdmId); + mdmModuleDistributeTripartiteEntity.setDataId(objects.get(i).getString("id")); + mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); + mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId")); + mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity); + } + } + } catch (Exception e) { + logger.error("开票申请单申请下发新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute()); + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","新增返回脚本解析保存三方id错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + continue; + } + } + //保存日志 + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + objects.get(i).put("sendsanfzt123",true); + logger.info("========开票申请单申请数据新增下发完成,日志保存为成功============"); + continue; + }else { + //保存日志 + saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + objects.get(i).put("sendsanfzt123",false); + logger.info("========开票申请单申请数据新增下发完成,日志保存为失败============"); + continue; + } + } + } + + //所有下发发送完成,修改数据状态 + for (int i = 0; i < objects.size(); i++) { + if(objects.get(i).getBoolean("sendsanfzt123")){ + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "Y"); + updateMap.put("addStatus", "1"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); + } + } + } + + private void saveMdmModuleSendLogEntity(Long mdmCode,String distributeId,String dataType,String remark,String dbname,String formmain_id, String target_app, String appId, String target_api,String apiID, String source_data, String option_type) throws Exception { + MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity(); + mdmModuleSendLogEntity.setTableName(dbname+"_send_log"); + mdmModuleSendLogEntity.setId(UUIDUtils.getUUID()); + mdmModuleSendLogEntity.setSts("Y"); + mdmModuleSendLogEntity.setDistributeId(distributeId); + mdmModuleSendLogEntity.setAppId(appId); + mdmModuleSendLogEntity.setApiId(apiID); + mdmModuleSendLogEntity.setCreate_user_id("1"); + mdmModuleSendLogEntity.setModify_user_id("1"); + mdmModuleSendLogEntity.setCreate_time(new Date()); + mdmModuleSendLogEntity.setModify_time(new Date()); + mdmModuleSendLogEntity.setOrg_id("0"); + mdmModuleSendLogEntity.setCompanyId("0"); + mdmModuleSendLogEntity.setFormmainId(formmain_id); + mdmModuleSendLogEntity.setTargetApp(target_app); + mdmModuleSendLogEntity.setTargetApi(target_api); + mdmModuleSendLogEntity.setSourceData(source_data); + mdmModuleSendLogEntity.setOptionType(option_type); + mdmModuleSendLogEntity.setDataType(dataType); + mdmModuleSendLogEntity.setRemark(remark); + mdmModuleSendLogDao.save(mdmModuleSendLogEntity); + + + JSONObject jsonObject = JSONObject.parseObject(source_data); + 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"); + JSONObject aa = new JSONObject(); + aa.put("mdmCode",mdmCode);//主数据编码 + aa.put("documentRule",jsonObject.getString("document_rule"));//行数据的单据规则编码 + aa.put("distributeId",distributeId);//发送表id + aa.put("type",option_type);//发送类型,1、新增2、修改3、删除 + integrationTaskLivingDetailsEntity.setRootAppPk(aa.toJSONString()); + integrationTaskLivingDetailsEntity.setRootAppBill(jsonObject.getString("document_rule")); + integrationTaskLivingDetailsEntity.setPluginId("MdmModulePlugin"); + integrationTaskLivingDetailsEntity.setRootAppNewData(source_data); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(remark); + if("1".equals(dataType)){ + taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity); + }else { + taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity); + + } + + } + + private JSONObject getDetailData(List mdmModuleDbEntities, JSONObject object, List mdmModuleDbFiledsRuleEntities,List mdmModuleDbFiledsEntities) { + + for (int i = 0; i < mdmModuleDbEntities.size(); i++) { + if("2".equals(mdmModuleDbEntities.get(i).getDbType())){ + Map map = new HashMap<>(); + map.put("tableName",mdmModuleDbEntities.get(i).getDbName()); + map.put("formmainId",object.getString("id")); + List detail = mdmModuleDao.queryMdmSTDetail(map); + detail = toLowerCaseKeys(detail); + + //查看主表是否有字段是关联的 + if(detail != null && detail.size() > 0){ + if(mdmModuleDbFiledsRuleEntities != null && mdmModuleDbFiledsRuleEntities.size() > 0){ + for (int i1 = 0; i1 < mdmModuleDbFiledsRuleEntities.size(); i1++) { + if(mdmModuleDbFiledsRuleEntities.get(i1).getDbId().equals(mdmModuleDbEntities.get(i).getId())){ + if(mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0){ + for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) { + if(mdmModuleDbFiledsRuleEntities.get(i1).getFiledId().equals(mdmModuleDbFiledsEntities.get(i2).getId())){ + for (int i3 = 0; i3 < detail.size(); i3++) { + if(detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){ + Map mapDetail = new HashMap<>(); + mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); + String ids = detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()); + String[] idss = ids.split(","); + mapDetail.put("id", idss[idss.length-1]); + JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); + objectDetail = toLowerCaseKeys(objectDetail); + + detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + } + } + } + } + } + } + } + } + } + object.put(mdmModuleDbEntities.get(i).getDbName(),detail); + } + } + + return object; + } + + + private JsonResultEntity sendData(SysApplicationApiEntity applicationApiEntity, Map headers ,String bodys ,String querys) { + StringBuffer urls = new StringBuffer(url); + if (querys != null) { + urls.append("?"); + urls.append(querys); + } + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build(); + HttpPost post = new HttpPost(urls.toString()); + CloseableHttpResponse response = null; + + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(Integer.valueOf(applicationApiEntity.getTimeoutPeriod())).build(); + post.setConfig(requestConfig);//设置请求参数【超时时间】 + + if (headers != null && headers.size() > 0) { + for (String key : headers.keySet()) { + post.setHeader(key, headers.get(key)); + } + } + StringBuilder body = new StringBuilder(); + boolean flag = true; + try { + if (bodys != null && !"".equals(bodys)) { + ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8")); + entity.setContentType("application/json"); + post.setEntity(entity); + } + response = closeableHttpClient.execute(post); + + HttpEntity entity = response.getEntity(); + synchronized (lock) { + body.append(EntityUtils.toString(entity,"UTF-8")); + } + flag = true; + logger.info("返回结果:" + body); + } catch (Exception e) { + logger.error("请求错误:" + e.getMessage()); + body.append(e.getMessage()); + flag = false; + } finally { + try { + // 关闭响应对象 + if (response != null) { + response.close(); + } + // 关闭响应对象 + if (closeableHttpClient != null) { + closeableHttpClient.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + } + if (flag) { + if (JSONUtil.isTypeJSON(body.toString())) { + JsonResultEntity jsonResultEntity = JSONObject.parseObject(body.toString(),JsonResultEntity.class); + if(jsonResultEntity.isFlag()){ + return BaseResult.getSuccessMessageEntity("转发成功", body); + }else { + return BaseResult.getFailureMessageEntity("转发失败", body); + } + }else { + return BaseResult.getFailureMessageEntity("转发失败", body); + } + } else { + return BaseResult.getFailureMessageEntity("转发失败", body); + } + } + + + private Map getHeaders(SysApplicationApiEntity loginApi,Map map,JSONObject loginData) { + if(loginData == null){ + loginData = new JSONObject(); + } + if (loginApi.getHeaderIn() != null && !"".equals(loginApi.getHeaderIn())) { + if (JSONUtil.isTypeJSONArray(loginApi.getHeaderIn())) { + JSONArray headerArray = JSON.parseArray(loginApi.getHeaderIn()); + for (int i = 0; i < headerArray.size(); i++) { + JSONObject querys = headerArray.getJSONObject(i); + //query 只有基本类型,不用循环判断下级 + //判断参数是否有值 + //获取对象下面的层级数据 + if (SysEnum.AUTHPORT.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 + String query = querys.getString(SysEnum.EXAMPLE.getValue()); + if (query != null && !"".equals(query)) { + JSONArray example = JSONArray.parseArray(query); + String logValue = getObjectValue(loginData, example); + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), logValue); + } + } else { + if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值,如果没有不添加 + if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), querys.getString(SysEnum.EXAMPLE.getValue())); + } + } else {//没有值直接拼接 + if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), ""); + } + } + } + } + } + } + return map; + + + + + } + + + private String getQuery(SysApplicationApiEntity loginApi,String sendDatastr,JSONObject loginData) { + Map map = new HashMap<>(); + if(sendDatastr != null){ + String[] parts = sendDatastr.split("&"); + if(parts != null && parts.length > 0){ + for (int i = 0; i < parts.length; i++) { + String[] part = parts[i].split("="); + if(part != null && part.length >=2 ){ + for (int a = 0; a < part.length; a++) { + map.put(part[0],part[1]); + } + } + } + } + } + if(loginData == null){ + loginData = new JSONObject(); + } + if (loginApi.getQueryIn() != null && !"".equals(loginApi.getQueryIn())) { + if (JSONUtil.isTypeJSONArray(loginApi.getQueryIn())) { + JSONArray headerArray = JSON.parseArray(loginApi.getQueryIn()); + for (int i = 0; i < headerArray.size(); i++) { + JSONObject querys = headerArray.getJSONObject(i); + //query 只有基本类型,不用循环判断下级 + //判断参数是否有值 + //获取对象下面的层级数据 + if (SysEnum.AUTHPORT.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 + String query = querys.getString(SysEnum.EXAMPLE.getValue()); + if (query != null && !"".equals(query)) { + JSONArray example = JSONArray.parseArray(query); + String logValue = getObjectValue(loginData, example); + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), logValue); + } + } else { + //不是认证类型直接取值 + if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值,如果没有不添加 + if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), querys.getString(SysEnum.EXAMPLE.getValue())); + } + } else {//没有值直接拼接 + if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), ""); + } + } + } + } + } + } + StringBuffer returnStr = new StringBuffer(); + if(map != null && map.size() > 0){ + for (String key : map.keySet()) { + if("".equals(returnStr)){ + returnStr.append(key).append("=").append(map.get(key)); + }else { + returnStr.append("&").append(key).append("=").append(map.get(key)); + } + } + } + return returnStr.toString(); + } + /** + * @param loginData + * @param example + * @return java.lang.String + * @Author lvleigang + * @Description 根据jsonArray 获取jsonobject中的值 + * @Date 11:47 上午 2023/8/31 + **/ + private String getObjectValue(JSONObject loginData, JSONArray example) { + String values = ""; + if (example != null && example.size() > 0) { + for (int i = 0; i < example.size(); i++) { + if (loginData.getString(example.getString(i)) != null && !"".equals(loginData.getString(example.getString(i)))) { + if (i == (example.size() - 1)) { + values = loginData.getString(example.getString(i)); + } else { + loginData = JSONObject.parseObject(loginData.getString(example.getString(i))); + } + } else { + return values; + } + } + } + return values; + } + private String getBodys(SysApplicationApiEntity loginApi,String sendDatastr, JSONObject loginData) { + JSONObject sendData = new JSONObject(); + if(sendDatastr != null ){ + sendData = JSONObject.parseObject(sendDatastr); + } + if(loginData == null){ + loginData = new JSONObject(); + } + if (loginApi.getBodyIn() != null && !"".equals(loginApi.getBodyIn())) { + if (JSONUtil.isTypeJSONArray(loginApi.getBodyIn())) { + JSONArray headerArray = JSON.parseArray(loginApi.getBodyIn()); + for (int i = 0; i < headerArray.size(); i++) { + //获取到第一个数据 + JSONObject querys = headerArray.getJSONObject(i); + if (SysEnum.AUTHPORT.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 + String query = querys.getString(SysEnum.EXAMPLE.getValue()); + if (query != null && !"".equals(query)) { + JSONArray example = JSONArray.parseArray(query); + String logValue = getObjectValue(loginData, example); + sendData.put(querys.getString(SysEnum.PARAMETERNAME.getValue()),logValue); + } + } + } + } + } + return sendData.toString(); + } + public JSONObject toLowerCaseKeys(JSONObject jsonObject) { + JSONObject lowerCaseJson = new JSONObject(); + if (jsonObject != null) { + for (String key : jsonObject.keySet()) { + Object value = jsonObject.get(key); + lowerCaseJson.put(key.toLowerCase(), value); + } + } + return lowerCaseJson; + } + public List toLowerCaseKeys(List list) { + List jsonObjects = new ArrayList<>(); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + jsonObjects.add(toLowerCaseKeys(list.get(i))); + } + } + return jsonObjects; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/QueryInputInvoiceResultPluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/QueryInputInvoiceResultPluginInitializer.java new file mode 100644 index 00000000..52cd42ca --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/QueryInputInvoiceResultPluginInitializer.java @@ -0,0 +1,58 @@ +package com.hzya.frame.plugin.ht.plugin; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.plugin.zxBank.plugin.ZxBankResultPluginInitializer; +import com.hzya.frame.seeyon.invoice.service.impl.InvoiceServiceImpl; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +public class QueryInputInvoiceResultPluginInitializer extends PluginBaseEntity { + Logger logger = LoggerFactory.getLogger(QueryInputInvoiceResultPluginInitializer.class); + + @Autowired + private InvoiceServiceImpl invoiceService; + + @Override + public void initialize() { + logger.info(getPluginLabel() + "執行初始化方法initialize()"); + } + + @Override + public void destroy() { + logger.info(getPluginLabel() + "執行銷毀方法destroy()"); + } + + @Override + public String getPluginId() { + return "QueryInputInvoiceResultPluginInitializer"; + } + + @Override + public String getPluginName() { + return "查询发票批量录入返回结果插件"; + } + + @Override + public String getPluginLabel() { + return "QueryInputInvoiceResultPluginInitializer"; + } + + @Override + public String getPluginType() { + return "1"; + } + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) { + try { + logger.info("======开始执行查询税务进项发票批量录入返回结果========"); + return invoiceService.queryInputInvoiceResult(requestJson); + }catch (Exception e){ + logger.info("======执行查询税务进项发票批量录入返回结果失败:{}========",e.getMessage()); + e.printStackTrace(); + } + return null; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/QueryInvoiceResultPluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/QueryInvoiceResultPluginInitializer.java new file mode 100644 index 00000000..f688f5be --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/QueryInvoiceResultPluginInitializer.java @@ -0,0 +1,58 @@ +package com.hzya.frame.plugin.ht.plugin; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.plugin.zxBank.plugin.ZxBankResultPluginInitializer; +import com.hzya.frame.seeyon.invoice.service.impl.InvoiceServiceImpl; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +public class QueryInvoiceResultPluginInitializer extends PluginBaseEntity { + Logger logger = LoggerFactory.getLogger(ZxBankResultPluginInitializer.class); + + @Autowired + private InvoiceServiceImpl invoiceService; + + @Override + public void initialize() { + logger.info(getPluginLabel() + "執行初始化方法initialize()"); + } + + @Override + public void destroy() { + logger.info(getPluginLabel() + "執行銷毀方法destroy()"); + } + + @Override + public String getPluginId() { + return "QueryInvoiceResultPluginInitializer"; + } + + @Override + public String getPluginName() { + return "查询开票申请详情插件"; + } + + @Override + public String getPluginLabel() { + return "QueryInvoiceResultPluginInitializer"; + } + + @Override + public String getPluginType() { + return "1"; + } + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) { + try { + logger.info("======开始执行查询税务开票申请详情返回结果========"); + return invoiceService.queryInvoiceResult(requestJson); + }catch (Exception e){ + logger.info("======执行查询税务开票申请详情返回结果失败:{}========",e.getMessage()); + e.printStackTrace(); + } + return null; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/dao/IZjgjDao.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/dao/IZjgjDao.java new file mode 100644 index 00000000..4dc50e3a --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/dao/IZjgjDao.java @@ -0,0 +1,12 @@ +package com.hzya.frame.plugin.zxBank.dao; + +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.plugin.zxBank.entity.ZjgjEntity; + +/** + * @Description 资金归集 + * @Author xiangerlin + * @Date 2025/4/11 11:07 + **/ +public interface IZjgjDao extends IBaseDao { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/dao/impl/ZjgjDaoImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/dao/impl/ZjgjDaoImpl.java new file mode 100644 index 00000000..71655a29 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/dao/impl/ZjgjDaoImpl.java @@ -0,0 +1,15 @@ +package com.hzya.frame.plugin.zxBank.dao.impl; + +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.plugin.zxBank.dao.IZjgjDao; +import com.hzya.frame.plugin.zxBank.entity.ZjgjEntity; +import org.springframework.stereotype.Repository; + +/** + * @Description 资金归集 + * @Author xiangerlin + * @Date 2025/4/11 11:07 + **/ +@Repository() +public class ZjgjDaoImpl extends MybatisGenericDao implements IZjgjDao { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/entity/ZjgjEntity.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/entity/ZjgjEntity.java new file mode 100644 index 00000000..3df95f41 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/entity/ZjgjEntity.java @@ -0,0 +1,11 @@ +package com.hzya.frame.plugin.zxBank.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +/** + * @Description 资金归集 + * @Author xiangerlin + * @Date 2025/4/11 11:04 + **/ +public class ZjgjEntity extends BaseEntity { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/entity/ZjgjEntity.xml b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/entity/ZjgjEntity.xml new file mode 100644 index 00000000..fc6e9287 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/entity/ZjgjEntity.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/plugin/ZjgjPluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/plugin/ZjgjPluginInitializer.java new file mode 100644 index 00000000..80ff4468 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/plugin/ZjgjPluginInitializer.java @@ -0,0 +1,97 @@ +package com.hzya.frame.plugin.zxBank.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/4/11 09:48 + **/ +public class ZjgjPluginInitializer extends PluginBaseEntity { + Logger logger = LoggerFactory.getLogger(getClass()); + /*** + * 插件初始化方法 + * @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 "ZjgjPluginInitializer"; + } + + /**** + * 插件的名称 + * @author 👻👻👻👻👻👻👻👻 gjh + * @date 2023-08-02 10:48 + * @return void + **/ + @Override + public String getPluginName() { + return "OA资金归集审批结果回传司库"; + } + + /**** + * 插件的显示值 + * @author 👻👻👻👻👻👻👻👻 gjh + * @date 2023-08-02 10:48 + * @return void + **/ + @Override + public String getPluginLabel() { + return "OA资金归集审批结果回传司库"; + } + + /*** + * 插件类型 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("======开始执OA资金归集审批结果回传司库插件======"); + + return null; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/service/IZjgjService.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/service/IZjgjService.java new file mode 100644 index 00000000..a42a2557 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/service/IZjgjService.java @@ -0,0 +1,12 @@ +package com.hzya.frame.plugin.zxBank.service; + +import com.hzya.frame.basedao.service.IBaseService; +import com.hzya.frame.plugin.zxBank.entity.ZjgjEntity; + +/** + * @Description 资金归集 + * @Author xiangerlin + * @Date 2025/4/11 11:03 + **/ +public interface IZjgjService extends IBaseService { +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/service/impl/ZjgjServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/service/impl/ZjgjServiceImpl.java new file mode 100644 index 00000000..a257f567 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/service/impl/ZjgjServiceImpl.java @@ -0,0 +1,19 @@ +package com.hzya.frame.plugin.zxBank.service.impl; + +import com.hzya.frame.basedao.service.impl.BaseService; +import com.hzya.frame.plugin.zxBank.entity.ZjgjEntity; +import com.hzya.frame.plugin.zxBank.service.IZjgjService; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.stereotype.Service; + +/** + * @Description + * @Author xiangerlin + * @Date 2025/4/11 11:04 + **/ +@Service +public class ZjgjServiceImpl extends BaseService implements IZjgjService { + Logger logger = LogManager.getLogger(getClass()); + +} diff --git a/base-buildpackage/src/main/resources/application-ht.yml b/base-buildpackage/src/main/resources/application-ht.yml index 85d1b848..afbc5086 100644 --- a/base-buildpackage/src/main/resources/application-ht.yml +++ b/base-buildpackage/src/main/resources/application-ht.yml @@ -40,7 +40,15 @@ OA: data_source_code: yc_oa zt: url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface +file_oa: + url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterfacefileUpload +#税务pdf附件下载存放路径 +invoice_pdf: + url: D:\yongansystem\invoice\pdf\ +#税务ofd附件下载存放路径 +invoice_ofd: + url: D:\yongansystem\invoice\ofd\ zx: - # 测试用这个 这个是银行给的 - privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0 - publicKey: MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEyocGV+D91yPL2EyngjizFW2p1DW2l46yBGcp7IcHTs0VYM0UEojzVqOjgQZAD76hPtkUvuQAaUvNg0pSpfNc9A== \ No newline at end of file + # 生产用这个 这个是银行给的 + privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgOHOzaKWBWOAbslvtYtS8tcQiJ9W9DT2cGQM3KSgXpfygCgYIKoEcz1UBgi2hRANCAAQNPct0MHOuDrVJBIy0RI7JKx9/PTlFHZlkIJr0EqpC+b/+N+z3JKbCMZ/wcP1V36Q+DlfDJCY9Ai/Uk2PZ9ZaF + publicKey: MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEDT3LdDBzrg61SQSMtESOySsffz05RR2ZZCCa9BKqQvm//jfs9ySmwjGf8HD9Vd+kPg5XwyQmPQIv1JNj2fWWhQ== \ No newline at end of file diff --git a/base-buildpackage/src/main/resources/application.yml b/base-buildpackage/src/main/resources/application.yml index b87e5bf7..a0bbeaae 100644 --- a/base-buildpackage/src/main/resources/application.yml +++ b/base-buildpackage/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 10086 + port: 9999 servlet: context-path: /kangarooDataCenterV3 localIP: 127.0.0.1 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 53c83b62..6758f61b 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 @@ -1,6 +1,9 @@ - + + + + diff --git a/base-buildpackage/src/test/java/com/hzya/frame/Test1.java b/base-buildpackage/src/test/java/com/hzya/frame/Test1.java new file mode 100644 index 00000000..a52aef06 --- /dev/null +++ b/base-buildpackage/src/test/java/com/hzya/frame/Test1.java @@ -0,0 +1,34 @@ +package com.hzya.frame; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.plugin.contract.plugin.ContractAuditPluginInitializer; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.junit.Test; + +import javax.annotation.Resource; + +/** + * @Description + * @Author xiangerlin + * @Date 2025/4/1 09:12 + **/ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {WebappApplication.class}) +public class Test1 { + + + @Resource + private ContractAuditPluginInitializer contractPlugin; + @Test + public void contractAuditPluginTest(){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("sourceCode","HT-OA"); + try { + contractPlugin.executeBusiness(jsonObject); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/base-webapp/pom.xml b/base-webapp/pom.xml index afa4acb1..3507e248 100644 --- a/base-webapp/pom.xml +++ b/base-webapp/pom.xml @@ -54,11 +54,11 @@ - - - - - + + com.hzya.frame + fw-oa + ${revision} + diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDao.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDao.java index 50747bc2..e8304591 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDao.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDao.java @@ -29,4 +29,44 @@ public interface IInvoiceDao extends IBaseDao { * @Date 2025-04-07 14:05 * **/ List queryInvoiceResult(InvoiceEntity entity); + + /** + * + * @content 更新推送标识 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-15 15:37 + * **/ + Integer updateInvoicePush(InvoiceEntity entity); + + /** + * + * @content 更新pdf和ofd附件到OA + * @Param + * @Return + * @Author hecan + * @Date 2025-04-14 10:27 + * **/ + Integer updateInvoiceUrl(InvoiceEntity entity); + + /** + * + * @content 更新发票代码,发票号码以及开票结果 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-14 16:35 + * **/ + Integer updateInvoiceResult(InvoiceEntity entity); + + /** + * + * @content 进项发票推送结果查询(查询发票批量录入结果) + * @Param + * @Return + * @Author hecan + * @Date 2025-04-17 15:19 + * **/ + List queryInputInvoiceResult(InvoiceEntity entity); } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDaoImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDaoImpl.java index 92743132..1d189240 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDaoImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDaoImpl.java @@ -38,4 +38,28 @@ public class InvoiceDaoImpl extends MybatisGenericDao impl public List queryInvoiceResult(InvoiceEntity entity) { return (List) super.selectList("queryInvoiceResult",entity); } + + @DS("#entity.dataSourceCode") + @Override + public Integer updateInvoicePush(InvoiceEntity entity) { + return super.update("updateInvoicePush",entity); + } + + @DS("#entity.dataSourceCode") + @Override + public Integer updateInvoiceUrl(InvoiceEntity entity) { + return super.update("updateInvoiceUrl",entity); + } + + @DS("#entity.dataSourceCode") + @Override + public Integer updateInvoiceResult(InvoiceEntity entity) { + return super.update("updateInvoiceResult",entity); + } + + @DS("#entity.dataSourceCode") + @Override + public List queryInputInvoiceResult(InvoiceEntity entity) { + return (List)super.selectList("queryInputInvoiceResult",entity); + } } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.java index c3afa017..239b0659 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.java @@ -72,6 +72,34 @@ public class InvoiceEntity extends BaseEntity { private String url;// 发票文件 private String result_status;// 开票结果 + private String summaryId;// + private String input_result_status_filed;//进项发票结果字段 + private String input_result_status;//进项发票结果 + + public String getInput_result_status_filed() { + return input_result_status_filed; + } + + public void setInput_result_status_filed(String input_result_status_filed) { + this.input_result_status_filed = input_result_status_filed; + } + + public String getInput_result_status() { + return input_result_status; + } + + public void setInput_result_status(String input_result_status) { + this.input_result_status = input_result_status; + } + + public String getSummaryId() { + return summaryId; + } + + public void setSummaryId(String summaryId) { + this.summaryId = summaryId; + } + public String getPush_status_filed() { return push_status_filed; } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml index 89fbf6c3..10213540 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml @@ -87,6 +87,34 @@ from v_hzya_invoice where push_status is not null and url is null and (result_status is null or result_status='申请单处理中') + + + + + update ${tabName} set ${url_field} =#{url} where id=#{id} + + + + + update formmain_0331 set field0206 =#{push_status} where id=#{id} + + + + + update ${tabName} set + + ${input_result_status_filed} = #{input_result_status}, + ${invoice_code_field} = #{invoice_code}, + ${invoice_number_field} = #{invoice_number}, + ${result_status_field} = #{result_status}, + + where id=#{id} + + diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceState.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceState.java new file mode 100644 index 00000000..cf584ee3 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceState.java @@ -0,0 +1,51 @@ +package com.hzya.frame.seeyon.invoice.entity; + +import com.hzya.frame.seeyon.zxbank.entity.PayState; + +public enum InvoiceState { + zero("0","申请单被关闭"), + one("1","申请单开票成功"), + two("2","申请单处理中"), + three("3","申请单开具异常"), + inputZero("0","进行中"), + inputOne("1","全部成功"), + inputTwo("2","部分失败"), + inputThree("3","全部失败"); + + + + + private String type; + //值 + private String value; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + InvoiceState(String type, String value){ + this.type=type; + this.value=value; + } + + public static String invoiceStateGetValue(String type){ + for (InvoiceState invoiceState : InvoiceState.values()){ + if(invoiceState.getType()==type||invoiceState.getType().equals(type)){ + return invoiceState.getValue().toString(); + } + } + return null; + } +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/IInvoiceService.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/IInvoiceService.java index 45f34f2c..05d18405 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/IInvoiceService.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/IInvoiceService.java @@ -26,4 +26,14 @@ public interface IInvoiceService extends IBaseService { * @Date 2025-04-02 14:10 * **/ JsonResultEntity queryInvoiceResult(JSONObject json); + + /** + * + * @content 进项发票推送结果查询(查询发票批量录入结果) + * @Param + * @Return + * @Author hecan + * @Date 2025-04-17 15:11 + * **/ + JsonResultEntity queryInputInvoiceResult(JSONObject json); } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java index f27b78c5..199745c8 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java @@ -7,23 +7,35 @@ import com.alibaba.fastjson.JSONObject; import com.hzya.frame.basedao.service.impl.BaseService; import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl; import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; +import com.hzya.frame.seeyon.dao.ICtpAttachmentDao; +import com.hzya.frame.seeyon.entity.CtpAttachmentEntity; import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao; import com.hzya.frame.seeyon.invoice.dao.IInvoiceDetailsDao; import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; +import com.hzya.frame.seeyon.invoice.entity.InvoiceState; import com.hzya.frame.seeyon.invoice.service.IInvoiceService; +import com.hzya.frame.seeyon.util.OARestUtil; import com.hzya.frame.seeyon.util.YzfSignUtil; +import com.hzya.frame.seeyon.zxbank.entity.PayState; import com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity; import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl; import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService; +import com.hzya.frame.uuid.UUIDLong; import com.hzya.frame.uuid.UUIDUtils; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.*; @Service(value = "InvoiceServiceImpl") @@ -40,10 +52,17 @@ public class InvoiceServiceImpl extends BaseService imple private IIntegrationTaskLivingDetailsService taskLivingDetailsService; @Autowired private ComparisonServiceImpl comparisonServiceimpl; + @Autowired + private ICtpAttachmentDao ctpAttachmentDao; @Value("${zt.url}") private String url; + @Value("${invoice_pdf.url}") + private String invoicePdfUrl; + @Value("${invoice_ofd.url}") + private String invoiceOfdUrl; + @Override public JsonResultEntity queryArchives(JSONObject json) { JSONObject jsonObject = json.getJSONObject("jsonStr"); @@ -78,6 +97,37 @@ public class InvoiceServiceImpl extends BaseService imple //将查询出来的数据进行组装,调用通用方法新增或者更新 if (null != listAll && listAll.size() > 0) { object = ParametricDocument(listAll, mdmCode, tableName); + if (CollectionUtils.isNotEmpty(object)) { + for (Object obj : object) { + //更新单据视图推送标识,不再抽取 + JSONObject attributeResult = (JSONObject) JSON.toJSON(obj); + if (attributeResult.getString("status").equals("200")) { + String resultString = attributeResult.getString("list"); + if ("10049".equals(mdmCode)) { + JSONArray jsonArray = JSONArray.parseArray(resultString); + if (CollectionUtils.isNotEmpty(jsonArray)) { + for (Object o : jsonArray) { + JSONObject attributeArray = (JSONObject) JSON.toJSON(o); + String cmpApply = attributeArray.getString(tableName); + JSONObject jsonObjectCmpApply = JSONObject.parseObject(cmpApply); + String id = jsonObjectCmpApply.getString("data_id");//主表id + String vdef1 = jsonObjectCmpApply.getString("business_no");//主表id + logger.info("=====开始根据单据id:{},单据号:{},更新表:formmain_0331的推送标识", id, vdef1); + InvoiceEntity invoiceEntity = new InvoiceEntity(); + invoiceEntity.setPush_status("1"); + invoiceEntity.setId(id); + invoiceEntity.setDataSourceCode(mdmModuleSourceEntity.getDataSourceCode()); + invoiceDao.updateInvoicePush(invoiceEntity); + //保存业务数据日志 + saveTaskLivingDetails(id, jsonObjectCmpApply.getString("business_no"), listAll.get(0).toString(), object.toString(), true,"MakeInvoicePluginInitializer"); + } + } + } + } else { + saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("mdm_invoice_application")).getString("data_id"), JSONObject.parseObject(listAll.get(0).getString("mdm_invoice_application")).getString("business_no"), listAll.get(0).toString(), JSON.parseObject(JSON.toJSONString(object)).getString("msg"), false,"MakeInvoicePluginInitializer"); + } + } + } } else { logger.info("三维单据视图数据没有需要同步中台的数据"); } @@ -108,7 +158,7 @@ public class InvoiceServiceImpl extends BaseService imple parametersMap.put("timestamp",timestamp); String sign = YzfSignUtil.signRequest(parametersMap,"34e5fc32ac894a2ba2ade8c3852c7a0a"); JSONObject jsonObject=new JSONObject(); - jsonObject.put("serialNumber",entity.getBusiness_no()); + jsonObject.put("serialNumber",entity.getId()); jsonObject.put("accessKey","6X3B526P5HqE6ums"); jsonObject.put("sign",sign); jsonObject.put("timestamp",timestamp); @@ -123,6 +173,59 @@ public class InvoiceServiceImpl extends BaseService imple execute(). body(); logger.info("=====调用杭泰税务查询申请单详情的返回参数为:{}===========",result); + JSONObject resultJson = JSONObject.parseObject(result); + if (!resultJson.getBoolean("flag")) { + saveTaskLivingDetails(entity.getId(), entity.getBusiness_no(), jsonObject.toJSONString(), resultJson.toJSONString(), false,""); + } else { + JSONObject attribute = resultJson.getJSONObject("attribute"); + if("0".equals(attribute.getString("code"))){ + JSONObject jsonResult=JSONObject.parseObject(attribute.getString("result")); + if(null !=jsonResult){ + JSONArray jsonArray = jsonResult.getJSONArray("invoiceInfoVOList"); + if(CollectionUtils.isNotEmpty(jsonArray)){ + for (int i = 0; i < jsonArray.size(); i++) { + //表单的附件字段=ctpAttachment的Sub_reference,表单的Summary_id=ctpAttachment的att_reference + String sub_reference = String.valueOf(UUIDLong.longUUID()); + String att_reference = entity.getSummaryId();//Summary_id + JSONObject invoiceInfo = jsonArray.getJSONObject(i); + String invoiceCode = invoiceInfo.getString("invoiceCode");//发票代码 + String invoiceNumber = invoiceInfo.getString("invoiceNumber");//发票号码 + String resultStatus = InvoiceState.invoiceStateGetValue(jsonResult.getString("resultStatus"));//开票结果 + entity.setInvoice_code(invoiceCode); + entity.setInvoice_number(invoiceNumber); + entity.setResult_status(resultStatus); + //将开票结果,发票号码,发票代码,回写OA + invoiceDao.updateInvoiceResult(entity); + if (null != invoiceInfo.getString("url") || null != invoiceInfo.getString("ofdUrl")) { + String pdfUrl = invoiceInfo.getString("url");//pdf文件 + String ofdUrl = invoiceInfo.getString("ofdUrl");//ofd文件 + String xmlUrl = invoiceInfo.getString("xmlUrl");//xml文件 + //获取pdf文件到本地 并为pdf取名,否则会报无法访问错误 + logger.info("========开始将pdf文件保存到本地========"); + String pdfFileName = generateFileName(pdfUrl, "pdf"); + String pdfSavePath = invoicePdfUrl + pdfFileName; + downloadPdf(pdfUrl, pdfSavePath); + logger.info("========pdf文件保存到本地完成========"); + File filePdf = new File(pdfSavePath); + logger.info("========开始将pdf文件上传OA========"); + ManyfileUpload(filePdf, entity, sub_reference, att_reference, jsonObject); + logger.info("========pdf文件上传OA完成========"); + //获取ofd文件到本地 + logger.info("========开始将ofd文件保存到本地========"); + String ofdFileName = generateFileName(ofdUrl, "ofd"); + String ofdSavePath = ofdUrl + ofdFileName; + downloadPdf(ofdUrl, ofdSavePath); + logger.info("========ofd文件保存到本地完成========"); + File fileOfd = new File(ofdSavePath); + logger.info("========开始将ofd文件上传OA========"); + ManyfileUpload(fileOfd, entity, sub_reference, att_reference, jsonObject); + logger.info("========ofd文件上传OA完成========"); + } + } + } + } + } + } } }catch (Exception e){ @@ -132,6 +235,155 @@ public class InvoiceServiceImpl extends BaseService imple return null; } + //进项发票推送结果查询(查询发票批量录入结果) + @Override + public JsonResultEntity queryInputInvoiceResult(JSONObject json) { + try { + InvoiceEntity invoiceEntity = json.toJavaObject(InvoiceEntity.class); + invoiceEntity.setDataSourceCode("HT-OA"); + logger.info("=======开始查询杭泰税务的发票批量录入返回结果========="); + List invoiceEntities = invoiceDao.queryInputInvoiceResult(invoiceEntity); + if(CollectionUtils.isEmpty(invoiceEntities)){ + logger.info("=====杭泰税务中没有需要查询发票批量录入返回结果的数据========"); + return BaseResult.getSuccessMessageEntity("查询成功"); + } + for (InvoiceEntity entity : invoiceEntities) { + long timestamp = System.currentTimeMillis(); + Map parametersMap = new HashMap<>(); + parametersMap.put("accessKey","6X3B526P5HqE6ums"); + parametersMap.put("timestamp",timestamp); + String sign = YzfSignUtil.signRequest(parametersMap,"34e5fc32ac894a2ba2ade8c3852c7a0a"); + JSONObject jsonObject=new JSONObject(); + jsonObject.put("serialNumber",entity.getId()); + jsonObject.put("accessKey","6X3B526P5HqE6ums"); + jsonObject.put("sign",sign); + jsonObject.put("timestamp",timestamp); + logger.info("=======调用杭泰税务查询发票批量录入结果的请求参数为:{}=======",jsonObject.toJSONString()); + //发送数据 + String result = HttpRequest.post(url). + header("appId", "800060"). + header("apiCode", "8000600006"). + header("publicKey", "ZJYAmRjjYEDgqw4UXWHZNicYclErG0hsrwKQcHukPlP0K1pCe7eDIk+3zDUT+v578prj"). + header("secretKey", "D6AHU3PL8UsNfK6A8I6mL4X1ma2NXckX/vM7AOzI/jmzJf+R1aY06Q6SBz7Y7drHj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). + body(jsonObject.toJSONString()). + execute(). + body(); + logger.info("=====调用杭泰税务查询发票批量录入结果的返回参数为:{}===========",result); + JSONObject resultJson = JSONObject.parseObject(result); + if (!resultJson.getBoolean("flag")) { + saveTaskLivingDetails(entity.getId(), entity.getBusiness_no(), jsonObject.toJSONString(), resultJson.toJSONString(), false,""); + } else { + JSONObject attribute = resultJson.getJSONObject("attribute"); + if("0".equals(attribute.getString("code"))) { + JSONObject jsonResult = JSONObject.parseObject(attribute.getString("result")); + if (null != jsonResult) { + String serialNumber = jsonResult.getString("serialNumber");//流水号 + String status = jsonResult.getString("status");//发票批量录入返回结果状态 + if(serialNumber.equals(entity.getId())){ + //修改发票批量录入结果状态 + logger.info("=========开始更新进项发票的结果=========="); + entity.setInput_result_status(InvoiceState.invoiceStateGetValue(status)); + entity.setDataSourceCode("HT-OA"); + invoiceDao.updateInvoiceResult(entity); + logger.info("=========更新进项发票的结果完成=========="); + saveTaskLivingDetails(entity.getId(),entity.getBusiness_no(),jsonObject.toJSONString(), resultJson.toJSONString(), true,""); + } + } + } + } + } + }catch (Exception e){ + logger.info("======查询杭泰税务发票批量录入结果失败====",e.getMessage()); + e.printStackTrace(); + } + return null; + } + + private void ManyfileUpload(File file,InvoiceEntity entity,String sub_reference,String att_reference,JSONObject jsonObject){ + JSONObject jsonObjectOfd = OARestUtil.fileUpload(file,"8000590003","8000590001"); + if (jsonObjectOfd.getString("fileUrl") != null) { + entity.setUrl(sub_reference); + entity.setDataSourceCode("HT-OA"); + invoiceDao.updateInvoiceUrl(entity); + //根据附件id查询附件业务数据 + String file_url = jsonObjectOfd.getString("fileUrl"); + CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity(); + ctpAttachmentEntity.setFile_url(file_url); + ctpAttachmentEntity.setSub_reference(sub_reference); + ctpAttachmentEntity.setAtt_reference(att_reference); + ctpAttachmentEntity.setDataSourceCode("HT-OA"); + List ctpAttachmentEntities = ctpAttachmentDao.queryCtpAttachment(ctpAttachmentEntity); + //如果没有查询到数据,就新增附件业务,否则更新 + if (ctpAttachmentEntities.size() == 0) { + String category = jsonObject.getString("category"); + String type = jsonObject.getString("type"); + String filename = jsonObject.getString("filename"); + String mime_type = jsonObject.getString("mimeType"); + String attachment_size = jsonObject.getString("size"); + String id = String.valueOf(UUIDLong.longUUID()); + ctpAttachmentEntity.setCategory(category); + ctpAttachmentEntity.setFilename(filename); + ctpAttachmentEntity.setType(type); + ctpAttachmentEntity.setMime_type(mime_type); + ctpAttachmentEntity.setAttachment_size(attachment_size); + ctpAttachmentEntity.setId(id); + ctpAttachmentEntity.setCategory("66"); + ctpAttachmentEntity.setCreatedate(new Date()); + ctpAttachmentEntity.setDataSourceCode("HT-OA"); + ctpAttachmentDao.saveCtpAttachment(ctpAttachmentEntity); + } else { + if (ctpAttachmentEntities.size() > 1) { + throw new BaseSystemException("OA附件业务表中查到多条记录"); + } + //更新数据到OA附件业务表中 + ctpAttachmentDao.updateCtpAttachment(ctpAttachmentEntity); + } + logger.info("=====电子回单执行完毕======="); + } + file.delete(); + } + + private void downloadPdf(String pdfUrl, String savePath) { + try { + URL url = new URL(pdfUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("Post"); + int responseCode = connection.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + InputStream inputStream = connection.getInputStream(); + FileOutputStream outputStream = new FileOutputStream(savePath); + + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + + outputStream.close(); + inputStream.close(); + } else { + logger.info("下载失败,响应码: {}" , responseCode); + } + connection.disconnect(); + }catch (Exception e){ + logger.info("====查询申请单详情获取税务pdf或ofd文件失败:{}========",e.getMessage()); + e.printStackTrace(); + } + } + + private String generateFileName(String url, String extension) { + // 这里简单根据 URL 的参数生成文件名,你可以根据实际需求调整 + String[] parts = url.split("&"); + String fphm = ""; + for (String part : parts) { + if (part.startsWith("fphm=")) { + fphm = part.substring(5); + break; + } + } + return fphm + "." + extension; + } + private List bindingInvoice(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { List list = new ArrayList<>(); StringBuffer stringBuffer = new StringBuffer(); diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/dao/IPayBillDao.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/dao/IPayBillDao.java index 33ab73c8..a0ec8db8 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/dao/IPayBillDao.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/dao/IPayBillDao.java @@ -30,29 +30,4 @@ public interface IPayBillDao { */ int updateState(PayBillEntity pay); -/** - * - * @content 获取保证金付款单数据 - * @author laborer - * @className: Administrator - * @author laborer - * @date 2025-01-07 9:44 - * - */ - - List getMarginPayment(PayBillEntity entity); -/** - * - * @content 获取保证金付款单详情数据 - * @className: Administrator - * @author laborer - * @date 2025-01-07 10:44 - * - */ - - List getOaEngineerPayDetails(PayBillEntity details); - - List getReceived(PayBillEntity entity); - - List getReceivedDetails(PayBillEntity details); } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/dao/impl/PayBillDaoImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/dao/impl/PayBillDaoImpl.java index f01f543a..3a753554 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/dao/impl/PayBillDaoImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/dao/impl/PayBillDaoImpl.java @@ -24,29 +24,9 @@ public class PayBillDaoImpl extends MybatisGenericDao implements IPayBillDao { public List getOaEngineerPay(PayBillEntity entity) { return super.selectList("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_list_base",entity); } - @DS("#entity.dataSourceCode") + @DS("#pay.dataSourceCode") @Override - public int updateState(PayBillEntity entity) { - return super.update("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_update",entity); - } - @DS("#entity.dataSourceCode") - @Override - public List getMarginPayment(PayBillEntity entity) { - return super.selectList("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_list_base_margin",entity); - } - @DS("#entity.dataSourceCode") - @Override - public List getOaEngineerPayDetails(PayBillEntity entity) { - return super.selectList("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_list_base_margin_details",entity); - } - @DS("#entity.dataSourceCode") - @Override - public List getReceived(PayBillEntity entity) { - return super.selectList("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_list_base_received",entity); - } - @DS("#entity.dataSourceCode") - @Override - public List getReceivedDetails(PayBillEntity entity) { - return super.selectList("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_list_base_received_details",entity); + public int updateState(PayBillEntity pay) { + return super.update("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_update",pay); } } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/entity/PayBillEntity.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/entity/PayBillEntity.java index dd1c5065..1a9308de 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/entity/PayBillEntity.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/entity/PayBillEntity.java @@ -14,411 +14,12 @@ import java.util.Map; */ public class PayBillEntity extends BaseEntity { -private String c_bill_type;//单据类型 -private String formCode;//单据号 -private String receiptDetailsId;//BIP到款明细主键 -private String repaymentDate;//还款日期 -private String repaymentType;//还款类型 -private String repaymentAmount;//还款金额 -private String recType;//还款类型 -private String orgCode;//组织编码 -private String deptCode;//部门编码 -private String fklxName;//付款类型 -private String zffsName;//支付方式 -private String firstSubject;//科目编码 -private String bzjProjectName;//保证金项目名称 -private String expirationDate;//投标保证金到期日 -private String deptCode2;//归属部门编码 -private String isCustomer;//是否运营商客户 -private String applyAmount;//申请金额 -private String checkedAmount;//财务核实金额 -private String comments;//说明 -private String creator;//制单人 -private String supplierCode;//供应商编码 -private String openBank;//开户银行 -private String bankAccount;//银行账号 -private String dkAmount;//打款金额 -private String dkTime;//打款时间 -private String isDydj;//是否打印本单据 -private String fieldName;// -private String tableName;// -private String formmain_id;// -private String customerAddress;//客户地址 -private String linkMan;//联系人 -private String bhBeneficiary;//保函受益人 -private String beneficiaryPhone;//受益人电话 -private String beneficiaryAddress;//受益人地址 -private String projectNumber;//工程项目合同/标书号码 -private String projectAmount;//工程项目合同/标书总金额 -private String bhIndate;//保函有效期 -private String bhReceiver;//保函收件人 -private String contactType;//联系方式 -private String contactAddress;//联系地址 -private String bhProjectName;//保函项目名称 -private String lastBhDate;//最晚取得保函日期 -private String notes;//备注 -private String isBh;//是否取得保函原件 -private String contactNumber;//联系电话 - - public String getContactNumber() { - return contactNumber; - } - - public void setContactNumber(String contactNumber) { - this.contactNumber = contactNumber; - } - - public String getCustomerAddress() { - return customerAddress; - } - - public void setCustomerAddress(String customerAddress) { - this.customerAddress = customerAddress; - } - - public String getLinkMan() { - return linkMan; - } - - public void setLinkMan(String linkMan) { - this.linkMan = linkMan; - } - - public String getBhBeneficiary() { - return bhBeneficiary; - } - - public void setBhBeneficiary(String bhBeneficiary) { - this.bhBeneficiary = bhBeneficiary; - } - - public String getBeneficiaryPhone() { - return beneficiaryPhone; - } - - public void setBeneficiaryPhone(String beneficiaryPhone) { - this.beneficiaryPhone = beneficiaryPhone; - } - - public String getBeneficiaryAddress() { - return beneficiaryAddress; - } - - public void setBeneficiaryAddress(String beneficiaryAddress) { - this.beneficiaryAddress = beneficiaryAddress; - } - - public String getProjectNumber() { - return projectNumber; - } - - public void setProjectNumber(String projectNumber) { - this.projectNumber = projectNumber; - } - - public String getProjectAmount() { - return projectAmount; - } - - public void setProjectAmount(String projectAmount) { - this.projectAmount = projectAmount; - } - - public String getBhIndate() { - return bhIndate; - } - - public void setBhIndate(String bhIndate) { - this.bhIndate = bhIndate; - } - - public String getBhReceiver() { - return bhReceiver; - } - - public void setBhReceiver(String bhReceiver) { - this.bhReceiver = bhReceiver; - } - - public String getContactType() { - return contactType; - } - - public void setContactType(String contactType) { - this.contactType = contactType; - } - - public String getContactAddress() { - return contactAddress; - } - - public void setContactAddress(String contactAddress) { - this.contactAddress = contactAddress; - } - - public String getBhProjectName() { - return bhProjectName; - } - - public void setBhProjectName(String bhProjectName) { - this.bhProjectName = bhProjectName; - } - - public String getLastBhDate() { - return lastBhDate; - } - - public void setLastBhDate(String lastBhDate) { - this.lastBhDate = lastBhDate; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - - public String getIsBh() { - return isBh; - } - - public void setIsBh(String isBh) { - this.isBh = isBh; - } - - public String getRecType() { - return recType; - } - - public void setRecType(String recType) { - this.recType = recType; - } - - public String getReceiptDetailsId() { - return receiptDetailsId; - } - - public void setReceiptDetailsId(String receiptDetailsId) { - this.receiptDetailsId = receiptDetailsId; - } - - public String getRepaymentDate() { - return repaymentDate; - } - - public void setRepaymentDate(String repaymentDate) { - this.repaymentDate = repaymentDate; - } - - public String getRepaymentType() { - return repaymentType; - } - - public void setRepaymentType(String repaymentType) { - this.repaymentType = repaymentType; - } - - public String getRepaymentAmount() { - return repaymentAmount; - } - - public void setRepaymentAmount(String repaymentAmount) { - this.repaymentAmount = repaymentAmount; - } - - public String getFormmain_id() { - return formmain_id; - } - - public void setFormmain_id(String formmain_id) { - this.formmain_id = formmain_id; - } - - public String getC_bill_type() { - return c_bill_type; - } - - public void setC_bill_type(String c_bill_type) { - this.c_bill_type = c_bill_type; - } - - public String getFormCode() { - return formCode; - } - - public void setFormCode(String formCode) { - this.formCode = formCode; - } - - public String getOrgCode() { - return orgCode; - } - - public void setOrgCode(String orgCode) { - this.orgCode = orgCode; - } - - public String getDeptCode() { - return deptCode; - } - - public void setDeptCode(String deptCode) { - this.deptCode = deptCode; - } - - public String getFklxName() { - return fklxName; - } - - public void setFklxName(String fklxName) { - this.fklxName = fklxName; - } - - public String getZffsName() { - return zffsName; - } - - public void setZffsName(String zffsName) { - this.zffsName = zffsName; - } - - public String getFirstSubject() { - return firstSubject; - } - - public void setFirstSubject(String firstSubject) { - this.firstSubject = firstSubject; - } - - public String getBzjProjectName() { - return bzjProjectName; - } - - public void setBzjProjectName(String bzjProjectName) { - this.bzjProjectName = bzjProjectName; - } - - public String getExpirationDate() { - return expirationDate; - } - - public void setExpirationDate(String expirationDate) { - this.expirationDate = expirationDate; - } - - public String getDeptCode2() { - return deptCode2; - } - - public void setDeptCode2(String deptCode2) { - this.deptCode2 = deptCode2; - } - - public String getIsCustomer() { - return isCustomer; - } - - public void setIsCustomer(String isCustomer) { - this.isCustomer = isCustomer; - } - - public String getApplyAmount() { - return applyAmount; - } - - public void setApplyAmount(String applyAmount) { - this.applyAmount = applyAmount; - } - - public String getCheckedAmount() { - return checkedAmount; - } - - public void setCheckedAmount(String checkedAmount) { - this.checkedAmount = checkedAmount; - } - - public String getComments() { - return comments; - } - - public void setComments(String comments) { - this.comments = comments; - } - - public String getCreator() { - return creator; - } - - public void setCreator(String creator) { - this.creator = creator; - } - - public String getSupplierCode() { - return supplierCode; - } - - public void setSupplierCode(String supplierCode) { - this.supplierCode = supplierCode; - } - - public String getOpenBank() { - return openBank; - } - - public void setOpenBank(String openBank) { - this.openBank = openBank; - } - - public String getBankAccount() { - return bankAccount; - } - - public void setBankAccount(String bankAccount) { - this.bankAccount = bankAccount; - } - - public String getDkAmount() { - return dkAmount; - } - - public void setDkAmount(String dkAmount) { - this.dkAmount = dkAmount; - } - - public String getDkTime() { - return dkTime; - } - - public void setDkTime(String dkTime) { - this.dkTime = dkTime; - } - - public String getIsDydj() { - return isDydj; - } - - public void setIsDydj(String isDydj) { - this.isDydj = isDydj; - } - - private ListpayBillDetailsEntityList; - - public List getPayBillDetailsEntityList() { - return payBillDetailsEntityList; - } - - public void setPayBillDetailsEntityList(List payBillDetailsEntityList) { - this.payBillDetailsEntityList = payBillDetailsEntityList; - } - private String billDate;//付款日期 private String primalMoney;//付款金额信息 private String pkOppaccount;//付款银行信息 private String pkSupplier;//供应商信息 - + private String tableName;//表名称 + private String fieldName;//字段名称 private String state;//推送状态 private String pkOrg;//组织 private String pkCustomer;//客户 diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/entity/PayBillEntity.xml b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/entity/PayBillEntity.xml index cd82b26c..736d5914 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/entity/PayBillEntity.xml +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/entity/PayBillEntity.xml @@ -11,54 +11,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -99,67 +51,12 @@ LEFT JOIN formson_0223 body ON main.id = body.formmain_id WHERE field0053 IS NOT NULL and field0058 is null - - - - - - - update ${tableName} set ${fieldName} = #{state} where id = #{id} - - - + update ${tableName} set ${fieldName} = #{state} where id = #{id} - - - - - - - diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/service/IPayBillService.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/service/IPayBillService.java index 9a50580b..caad27a7 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/service/IPayBillService.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/service/IPayBillService.java @@ -25,27 +25,5 @@ public interface IPayBillService extends IBaseService { * */ JsonResultEntity sendEngineerPayBillToBip(JSONObject requestJson); -/** - * - * @content 推送保证金付款到BIP - * @param requestJson - * @return JsonResultEntity - * @author laborer - * @className: Administrator - * @author laborer - * @date 2025-01-07 9:39 - * - */ - JsonResultEntity sendMarginPaymentToBip(JSONObject requestJson); -/** - * - * @content 保证金付流程结束更新付款状态 - * @className: Administrator - * @author laborer - * @date 2025-01-08 10:18 - * - */ - - JsonResultEntity sendReceivedToBip(JSONObject requestJson); } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/service/impl/PayBillServiceImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/service/impl/PayBillServiceImpl.java index d0357a53..5bdf9b4b 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/service/impl/PayBillServiceImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/paybill/service/impl/PayBillServiceImpl.java @@ -1,7 +1,5 @@ package com.hzya.frame.seeyon.paybill.service.impl; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -45,228 +43,32 @@ public class PayBillServiceImpl extends BaseService implem */ @Override public JsonResultEntity sendEngineerPayBillToBip(JSONObject requestJson) { -// PayBillEntity entity = new PayBillEntity(); -// requestJson.put("db_code","OA"); -// entity.setDataSourceCode(requestJson.getString("db_code")); -// ListpayBillEntityList = payBillDao.getOaEngineerPay(entity); -// if(CollectionUtils.isNotEmpty(payBillEntityList)){ -// for(PayBillEntity pay : payBillEntityList){ -// PayBillEntity details = new PayBillEntity(); -// ListpayDetailsList = payBillDao.getOaEngineerPayDetails(details); -// -// String token = OABipUtil.getBipToken("yonyou","8000230000"); -// JSONObject main = bindingAdd(pay); -// logger.info("工程付款单调用中台生成BIP付款结算单推送报文{}",main.toString()); -// String result = OABipUtil.sendOATOBipEsb(main.toString(),"8000230014",token); -// logger.info("工程付款单调用中台生成BIP付款结算单返回结果{}",result); -// JSONObject resultObj = JSON.parseObject(result); -// boolean flag = resultObj.getBoolean("success"); -// if(flag){ -// pay.setState("Y"); -// }else{ -// pay.setState("N"); -// } -// pay.setDataSourceCode(requestJson.getString("db_code")); -// payBillDao.updateState(pay); -// // todo 后续在写吧(没字段等OA开了外网在创建),修改推送状态,避免再次查询 -// } -// } - return null; - } - - @Override - public JsonResultEntity sendMarginPaymentToBip(JSONObject requestJson) { PayBillEntity entity = new PayBillEntity(); - requestJson.put("db_code","SW-OA"); + requestJson.put("db_code","OA"); entity.setDataSourceCode(requestJson.getString("db_code")); - ListpayBillEntityList = payBillDao.getMarginPayment(entity); + ListpayBillEntityList = payBillDao.getOaEngineerPay(entity); if(CollectionUtils.isNotEmpty(payBillEntityList)){ for(PayBillEntity pay : payBillEntityList){ - String datasourceCode = requestJson.getString("db_code"); - System.out.println("更新时的数据源编码为"+datasourceCode); - logger.info("更新时的数据源编码为"+datasourceCode); - pay.setDataSourceCode(datasourceCode); - try { -// PayBillEntity details = new PayBillEntity(); -// details.setFormmain_id(pay.getId()); -// details.setDataSourceCode(requestJson.getString("db_code")); -// ListpayDetailsList = payBillDao.getOaEngineerPayDetails(details); - String token = OABipUtil.getBipToken("yonyou","8000500003"); -// pay.setPayBillDetailsEntityList(payDetailsList); - JSONObject main = bindingMarginAdd(pay); - logger.info("保证金原始报文{}",JSON.toJSONString(pay)); - logger.info("保证金付款申请单推送BIP报文{}",main.toString()); - String result = OABipUtil.sendOATOBipEsb(main.toString(),"8000500007",token); - logger.info("保证金付款申请单推送BIP报文返回结果{}",result); - JSONObject resultObj = JSON.parseObject(result); - String resultFlag = resultObj.getString("Result"); - if("success".equals(resultFlag)){ - pay.setState("Y"); - }else{ - pay.setState("N"); - } - - payBillDao.updateState(pay); - } catch (Exception e) { + String token = OABipUtil.getBipToken("yonyou","8000230000"); + JSONObject main = bindingAdd(pay); + logger.info("工程付款单调用中台生成BIP付款结算单推送报文{}",main.toString()); + String result = OABipUtil.sendU9cTOBipEsb(main.toString(),"8000230014",token); + logger.info("工程付款单调用中台生成BIP付款结算单返回结果{}",result); + JSONObject resultObj = JSON.parseObject(result); + boolean flag = resultObj.getBoolean("success"); + if(flag){ + pay.setState("Y"); + }else{ pay.setState("N"); - payBillDao.updateState(pay); - logger.error("保证金同步BIP保证金付款失败,请联系管理员:{}",e); } - - } - } - return null; - } - - @Override - public JsonResultEntity sendReceivedToBip(JSONObject requestJson) { - PayBillEntity entity = new PayBillEntity(); - requestJson.put("db_code","SW-OA"); - entity.setDataSourceCode(requestJson.getString("db_code")); - ListpayBillEntityList = payBillDao.getReceived(entity); - if(CollectionUtils.isNotEmpty(payBillEntityList)){ - for(PayBillEntity pay : payBillEntityList){ pay.setDataSourceCode(requestJson.getString("db_code")); - try { - boolean flag = true; - StringBuffer sb = new StringBuffer(); -// PayBillEntity details = new PayBillEntity(); -// details.setFormmain_id(pay.getId()); -// details.setDataSourceCode(requestJson.getString("db_code")); -// ListpayDetailsList = payBillDao.getReceivedDetails(details); - String token = OABipUtil.getBipToken("yonyou","8000500003"); -// pay.setPayBillDetailsEntityList(payDetailsList); - //组装更新保证金还款信息 - JSONObject main = bindingReceivedAdd(pay); - logger.info("保证金付款申请单-还款推送BIP报文{}",main.toString()); - String result = OABipUtil.sendOATOBipEsb(main.toString(),"8000500015",token); - logger.info("保证金付款申请单-还款推送BIP报文返回结果{}",result); - JSONObject resultObj = JSON.parseObject(result); - flag = resultObj.getBoolean("Result"); - if(!flag){ - sb.append("更新保证金还款信息失败:错误原因"+resultObj.getString("Message")+pay.getReceiptDetailsId() +" "); - pay.setState("N"); - }else{ - pay.setState("Y"); - } - - //不单独更新数据到表中了,记录日志用 - logger.info("保证金流程结束事件出错"+sb.toString()); - payBillDao.updateState(pay); - } catch (Exception e) { - pay.setState("N"); - payBillDao.updateState(pay); - logger.info("保证金流程结束事件出错,请联系管理员:"+e); - logger.info("保证金流程结束事件出错,请联系管理员1:"+e.getMessage()); - - } + payBillDao.updateState(pay); + // todo 后续在写吧(没字段等OA开了外网在创建),修改推送状态,避免再次查询 } } return null; } -// private JSONObject bindingReceivedRLAdd(PayBillEntity pay) { -// JSONObject head = new JSONObject(); -// head.put("c_bill_type","F9");//单据类型 保证金付款申请单固定F9 -// head.put("formCode",pay.getFormCode());//单据号 -// head.put("receiptDetailsId","");//BIP到款明细主键 -// head.put("repaymentDate","");//还款日期 -// head.put("repaymentType","");//还款类型 -// head.put("repaymentAmount","");//还款金额 -// return head; -// } - - private JSONObject bindingReceivedAdd(PayBillEntity pay) { - JSONObject head = new JSONObject(); - head.put("c_bill_type",pay.getC_bill_type());//单据类型 保证金付款申请单固定F9 - head.put("formCode",pay.getFormCode());//单据号 - head.put("receiptDetailsId",pay.getReceiptDetailsId());//BIP到款明细主键 - String repaymentDate = pay.getRepaymentDate(); - if(StrUtil.isNotEmpty(repaymentDate)){ - head.put("repaymentDate",DateUtil.format(DateUtil.parse(repaymentDate), "yyyy-MM-dd HH:mm:ss"));//还款日期 - } - head.put("repaymentType",pay.getRepaymentType());//还款类型 - head.put("repaymentAmount",pay.getRepaymentAmount());//还款金额 - return head; - } - - private JSONObject bindingMarginAdd(PayBillEntity pay) { - - JSONObject head = new JSONObject(); - head.put("c_bill_type","F9");//单据类型 保证金付款申请单固定F9 - head.put("formCode",pay.getFormCode());//单据号(NC有重复校验) - head.put("orgCode",pay.getOrgCode());//公司编码 - head.put("deptCode",pay.getDeptCode());//事业部大类编码 - head.put("fklxName",pay.getFklxName());//付款类型 - head.put("zffsName",pay.getZffsName());//支付方式 - head.put("firstSubject",pay.getFirstSubject());//一级科目 - head.put("bzjProjectName",pay.getBzjProjectName());//保证金项目名称 - String expirationDate= pay.getExpirationDate(); - if(StrUtil.isNotEmpty(expirationDate)){ - head.put("expirationDate",DateUtil.format(DateUtil.parse(expirationDate), "yyyy-MM-dd"));//投标保证金到期日 - } - - head.put("deptCode2",pay.getDeptCode2());//归属部门编码 - head.put("isCustomer","Y");//是否运营商客户 - head.put("applyAmount",pay.getApplyAmount());//申请金额 - head.put("checkedAmount",pay.getCheckedAmount());//财务核实金额 - head.put("comments",pay.getComments());//说明 - head.put("creator",pay.getCreator());//制单人 - head.put("supplierCode",pay.getSupplierCode());//供应商编码 - head.put("openBank",pay.getOpenBank());//开户银行 - head.put("bankAccount",pay.getBankAccount());//银行账号 - head.put("customerAddress",pay.getCustomerAddress());//客户地址 - head.put("linkMan",pay.getLinkMan());//联系人 - head.put("contactNumber",pay.getContactNumber());//联系电话 - - head.put("bhBeneficiary",pay.getBhBeneficiary());//保函受益人 - head.put("beneficiaryPhone",pay.getBeneficiaryPhone());//受益人电话 - head.put("beneficiaryAddress",pay.getBeneficiaryAddress());//受益人地址 - head.put("projectNumber",pay.getProjectNumber());//工程项目合同/标书号码 - head.put("projectAmount",pay.getProjectAmount());//工程项目合同/标书总金额 - String bhIndate = pay.getBhIndate(); - if(StrUtil.isNotEmpty(bhIndate)){ - head.put("bhIndate",DateUtil.format(DateUtil.parse(bhIndate), "yyyy-MM-dd"));//保函有效期 - } - head.put("bhReceiver",pay.getBhReceiver());//保函收件人 - head.put("contactType",pay.getContactType());//联系方式 - head.put("contactAddress",pay.getContactAddress());//联系地址 - head.put("bhProjectName",pay.getBhProjectName());//保函项目名称 - - String lastBhDate = pay.getLastBhDate(); - if(StrUtil.isNotEmpty(lastBhDate)){ - head.put("lastBhDate",DateUtil.format(DateUtil.parse(lastBhDate), "yyyy-MM-dd"));//最晚取得保函日期 - } - head.put("notes",pay.getNotes());//备注 - head.put("isBh",pay.getIsBh());//是否取得保函原件 - - head.put("dkAmount",pay.getDkAmount());//打款金额 - String dkTime = pay.getDkTime(); - if(StrUtil.isNotEmpty(dkTime)){ - head.put("dkTime", DateUtil.format(DateUtil.parse(dkTime), "yyyy-MM-dd HH:mm:ss"));//打款时间 - } - - head.put("isDydj","Y");//是否打印本单据 - - //处理明细数据,按照明细付款 多个明细生成多个付款结算单 - JSONArray detailsArr = new JSONArray(); -// ListdetailsList = pay.getPayBillDetailsEntityList(); -// if(CollectionUtils.isNotEmpty(detailsList)){ -// detailsList.forEach(detail->{ -// JSONObject body = new JSONObject(); -// body.put("projectCode","");//项目编码 -// body.put("projectName","");//项目名称 -// body.put("wdContact","");//未定合同号 -// body.put("buildCost","");//工程造价 -// body.put("deptCode","");//承担部门编码 -// detailsArr.add(body); -// }); -// } - head.put("xmDetail",detailsArr);//明细数据 - head.put("hkDetail",detailsArr);//明细数据 - return head; - } - @NotNull private JSONObject bindingAdd(PayBillEntity pay) { JSONObject head = new JSONObject(); diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/recbill/service/impl/RecBillServiceImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/recbill/service/impl/RecBillServiceImpl.java index 41797f18..f65d2855 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/recbill/service/impl/RecBillServiceImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/recbill/service/impl/RecBillServiceImpl.java @@ -42,29 +42,29 @@ public class RecBillServiceImpl extends BaseService implem */ @Override public JsonResultEntity sendRecBillToBip(JSONObject requestJson) { -// RecBillEntity entity = new RecBillEntity(); -// requestJson.put("db_code","OA"); -// entity.setDataSourceCode(requestJson.getString("db_code")); -// ListpayBillEntityList = payBillDao.getOaRecBill(entity); -// if(CollectionUtils.isNotEmpty(payBillEntityList)){ -// for(RecBillEntity pay : payBillEntityList){ -// String token = OABipUtil.getBipToken("yonyou","8000230000"); -// JSONObject main = bindingAdd(pay); -// logger.info("银行流水收款信息数据{}",main.toString()); -// String result = OABipUtil.sendU9cTOBipEsb(main.toString(),"8000230016",token); -// logger.info("银行流水收款信息数据{}",result); -// JSONObject resultObj = JSON.parseObject(result); -// boolean flag = resultObj.getBoolean("success"); -// if(flag){ -// pay.setState("Y"); -// }else{ -// pay.setState("N"); -// } -// pay.setDataSourceCode(requestJson.getString("db_code")); -// payBillDao.updateState(pay); -// // todo 后续在写吧(没字段等OA开了外网在创建),修改推送状态,避免再次查询 -// } -// } + RecBillEntity entity = new RecBillEntity(); + requestJson.put("db_code","OA"); + entity.setDataSourceCode(requestJson.getString("db_code")); + ListpayBillEntityList = payBillDao.getOaRecBill(entity); + if(CollectionUtils.isNotEmpty(payBillEntityList)){ + for(RecBillEntity pay : payBillEntityList){ + String token = OABipUtil.getBipToken("yonyou","8000230000"); + JSONObject main = bindingAdd(pay); + logger.info("银行流水收款信息数据{}",main.toString()); + String result = OABipUtil.sendU9cTOBipEsb(main.toString(),"8000230016",token); + logger.info("银行流水收款信息数据{}",result); + JSONObject resultObj = JSON.parseObject(result); + boolean flag = resultObj.getBoolean("success"); + if(flag){ + pay.setState("Y"); + }else{ + pay.setState("N"); + } + pay.setDataSourceCode(requestJson.getString("db_code")); + payBillDao.updateState(pay); + // todo 后续在写吧(没字段等OA开了外网在创建),修改推送状态,避免再次查询 + } + } return null; } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/service/ISeeYonInterFace.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/service/ISeeYonInterFace.java index a8566a2b..fd29f738 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/service/ISeeYonInterFace.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/service/ISeeYonInterFace.java @@ -6,6 +6,7 @@ import com.hzya.frame.web.entity.JsonResultEntity; /** * 致远OA接口类 + * * @author 👻👻👻👻👻👻👻👻👻👻 gjh * @version 1.0 * @content @@ -17,18 +18,17 @@ public interface ISeeYonInterFace { * 发起OA表单方法 * @content: * @author 👻👻👻👻👻👻👻👻 gjh - * @date 2023-08-22 9:31 + * @date 2023-08-22 9:31 * @param requestData 请求json * @return com.hzya.frame.web.entity.JsonResultEntity **/ JsonResultEntity thirdInterfaceSend(JSONObject requestData); - /*** * @Content: 提供给OA的标准接口方法,包含参数 entity 为OA 的data信息, , eventType 为事件类型 * @Author 👻👻👻👻👻👻👻👻 gjh - * @Date 2020-12-24 10:36 + * @Date 2020-12-24 10:36 * @Param [entity, eventType] * eventType: * 发起前事件 onBeforeStart , @@ -59,11 +59,13 @@ public interface ISeeYonInterFace { /** * seeyon流程事件监听前置方法,绑定数据源 + * * @param sysExtensionApi * @return * @throws Exception */ - SysExtensionApiEntity colEventPre(SysExtensionApiEntity sysExtensionApi)throws Exception; + SysExtensionApiEntity colEventPre(SysExtensionApiEntity sysExtensionApi) throws Exception; + /** * seeyon流程事件监听前置方法,绑定数据源 * @param entity @@ -73,19 +75,27 @@ public interface ISeeYonInterFace { SysExtensionApiEntity getToken(SysExtensionApiEntity entity) throws Exception; /** * seeyon流程事件监听 + * * @param jsonObject * @return * @throws Exception */ - JsonResultEntity colEventListener(JSONObject jsonObject)throws Exception; + JsonResultEntity colEventListener(JSONObject jsonObject) throws Exception; /** * seeyon流程事件监听后置方法,调用三方接口 + * * @param jsonStr * @param formAppId * @param eventType * @return * @throws Exception */ - String colEventPost(String jsonStr,String formAppId,String eventType)throws Exception; + JsonResultEntity colEventPost(String jsonStr, String formAppId, String eventType) throws Exception; + + + JsonResultEntity chengeBody(JSONObject jsonObject) throws Exception; + + SysExtensionApiEntity chengeBodySetPlug(SysExtensionApiEntity entity); + } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/service/impl/SeeYonInterFaceImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/service/impl/SeeYonInterFaceImpl.java index 1ad93a9e..619d0eca 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/service/impl/SeeYonInterFaceImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/service/impl/SeeYonInterFaceImpl.java @@ -2,46 +2,36 @@ package com.hzya.frame.seeyon.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.map.MapBuilder; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; import com.hzya.frame.seeyon.dao.ISeeYonInterFaceDao; import com.hzya.frame.seeyon.entity.OAWorkflowEventDataEntity; import com.hzya.frame.seeyon.entity.SeeYonInterFaceEntity; import com.hzya.frame.seeyon.service.ISeeYonInterFace; -import com.hzya.frame.sys.sysenum.SysEnum; import com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity; import com.hzya.frame.sysnew.application.api.service.ISysApplicationApiService; import com.hzya.frame.sysnew.application.database.dao.ISysApplicationDatabaseDao; import com.hzya.frame.sysnew.application.database.entity.SysApplicationDatabaseEntity; import com.hzya.frame.sysnew.application.entity.SysApplicationEntity; import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity; -import com.hzya.frame.sysnew.application.service.impl.ApplicationCache; +import com.hzya.frame.util.PluginUtils; 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.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; 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 javax.annotation.Resource; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -63,18 +53,30 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { private static final String sendUrl = "http://60.204.152.210/seeyon/"; //速网esb地址 private static final String baseUrl = "http://hzya.ufyct.com:9067/kangarooDataCenter/entranceController/externalCallInterface"; - @Resource - private ISysApplicationDatabaseDao sysApplicationDatabaseDao; - @Autowired - private ISysApplicationApiService sysApplicationApiService; - @Value("${zt.url}") - private String url ; - @Resource - private ApplicationCache applicationCache; /** * 定义所支持的事件静态代码块 */ private static final StringBuffer eventTypeBuffer = new StringBuffer(); + //基础档案类型 + private final String ARCHIVESTYPE = "archives"; + //流程表单类型 + private final String FLOWTYPE = "flow"; + //创建基础档案 + private final String CREATEARCHIVES = "create"; + //更新基础档案 + private final String UPDATEARCHIVES = "update"; + //创建基础档案 + private final String CREATEARCHIVESURL = "rest/form/import/"; + //创建基础档案 + private final String UPDATEARCHIVESURL = "rest/form/update"; + @Resource + private ISysApplicationDatabaseDao sysApplicationDatabaseDao; + @Autowired + private ISysApplicationApiService sysApplicationApiService; + @Resource + private ISeeYonInterFaceDao seeYonInterFaceDao; + //上一次同步时间 + private final String LAST_SYNCHRONISED_TIME = ""; { eventTypeBuffer.append("发起前事件 onBeforeStart ,"); @@ -92,24 +94,6 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { eventTypeBuffer.append("取回事件 onTakeBack,"); } - //基础档案类型 - private final String ARCHIVESTYPE = "archives"; - //流程表单类型 - private final String FLOWTYPE = "flow"; - //创建基础档案 - private final String CREATEARCHIVES = "create"; - //更新基础档案 - private final String UPDATEARCHIVES = "update"; - //创建基础档案 - private final String CREATEARCHIVESURL = "rest/form/import/"; - //创建基础档案 - private final String UPDATEARCHIVESURL = "rest/form/update"; - @Resource - private ISeeYonInterFaceDao seeYonInterFaceDao; - - - //上一次同步时间 - private String LAST_SYNCHRONISED_TIME = ""; /**** * @Content:发起无流程表单接口实现 * @Author 👻👻👻👻👻👻👻👻 gjh @@ -117,7 +101,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { * @Param [templateCode 模版编码, sendLoginName 发送人登录帐号 ,xmlData ] * @return java.lang.Integer **/ - public static JsonResultEntity saveNoProcess(String templateCode , String interfaceUrl,String sendLoginName, String xmlData) { + public static JsonResultEntity saveNoProcess(String templateCode, String interfaceUrl, String sendLoginName, String xmlData) { String token = getToken(RESTUSERNAME, RESTPASSWORD, sendLoginName); Map res = new HashMap(); res.put("loginName", sendLoginName); @@ -136,7 +120,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { res.put("token", token); res.put("moduleId", moduleId); res.put("templateCode", templateCode); - logger.info("更新无流程表单参数:{}",JSON.toJSONString(res)); + logger.info("更新无流程表单参数:{}", JSON.toJSONString(res)); String result = HttpRequest.put(sendUrl + interfaceUrl).header("token", token).body(JSON.toJSONString(res)).execute().body(); logger.info("更新无流程表单执行结果:" + result); return BaseResult.getFailureMessageEntity("执行成功", result); @@ -202,7 +186,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { List attributeArray = JSON.parseArray(attributeArrayStr, JSONObject.class); JsonResultEntity result = null; if (ARCHIVESTYPE.equalsIgnoreCase(type)) { - switch (templateCode){ + switch (templateCode) { //预留的 case "abc123": break; @@ -215,13 +199,13 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { @Override - public JsonResultEntity thirdInterfaceSeeYonPlugInInterfaceEntrance(JSONObject requestData){ + public JsonResultEntity thirdInterfaceSeeYonPlugInInterfaceEntrance(JSONObject requestData) { String jsonStr = requestData.getString("jsonStr"); JSONObject jsonObject = requestData.getJSONObject("jsonStr"); - OAWorkflowEventDataEntity entity = JSON.parseObject(jsonStr,OAWorkflowEventDataEntity.class); - logger.info("监听OA事件入参:"+jsonObject.toJSONString()); + OAWorkflowEventDataEntity entity = JSON.parseObject(jsonStr, OAWorkflowEventDataEntity.class); + logger.info("监听OA事件入参:" + jsonObject.toJSONString()); JSONObject formBeanData = jsonObject.getJSONObject("businessDataStr"); - String eventType = jsonObject.getString("eventType") ; + String eventType = jsonObject.getString("eventType"); /** 流程ID*/ String summaryId = entity.getSummaryId(); /** 节点ID*/ @@ -240,73 +224,74 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { //formApp 最好过滤一下 - String result = null; + JsonResultEntity result = null; try { //流程事件处理 result = colEventPost(jsonStr, formApp, eventType); - }catch (Exception e){ - return BaseResult.getFailureMessageEntity("传递失败",e.getMessage()); - } - try { - /** 根据事件类型处理相关事件*/ - switch (eventType) { - /** 发起前事件*/ - case "onBeforeStart": - break; - /** 发起事件*/ - case "onStart": - //流程发起 新增grpu8单据 - break; - /** 终止前事件*/ - case "onBeforeStop": - break; - /** 终止事件*/ - case "onStop": - //流程终止,更新grpu8单据 - break; - /** 撤销前事件*/ - case "onBeforeCancel": - break; - /** 撤销事件*/ - case "onCancel": - //流程撤销,更新grpu8单据 - break; - /** 结束事件*/ - case "onProcessFinished": - break; - /** 处理前事件*/ - case "onBeforeFinishWorkitem": - /** 根据form处理相关业务表单的数据*/ - switch (formApp) { - case "abc123": - break; - default: - return BaseResult.getFailureMessageEntity("未匹配到表单!当前formID:" + formApp, ""); - } - break; - /** 处理事件*/ - case "onFinishWorkitem": - break; - /** 回退前事件*/ - case "onBeforeStepBack": - break; - /** 回退事件*/ - case "onStepBack": - break; - /** 取回前事件*/ - case "onBeforeTakeBack": - break; - /** 取回事件*/ - case "onTakeBack": - break; - default: -// throw new RuntimeException("传入了非法事件类型!请参照:" + eventTypeBuffer.toString()); - return BaseResult.getFailureMessageEntity("传入了非法事件类型!请参照:" + eventTypeBuffer.toString(), "", ""); - } - return BaseResult.getSuccessMessageEntity("传递成功", result); - }catch (Exception e){ - return BaseResult.getFailureMessageEntity("传递失败",e.getMessage()); + } catch (Exception e) { + return BaseResult.getFailureMessageEntity("传递失败", e.getMessage()); } + return result; +// try { +// /** 根据事件类型处理相关事件*/ +// switch (eventType) { +// /** 发起前事件*/ +// case "onBeforeStart": +// break; +// /** 发起事件*/ +// case "onStart": +// //流程发起 新增grpu8单据 +// break; +// /** 终止前事件*/ +// case "onBeforeStop": +// break; +// /** 终止事件*/ +// case "onStop": +// //流程终止,更新grpu8单据 +// break; +// /** 撤销前事件*/ +// case "onBeforeCancel": +// break; +// /** 撤销事件*/ +// case "onCancel": +// //流程撤销,更新grpu8单据 +// break; +// /** 结束事件*/ +// case "onProcessFinished": +// break; +// /** 处理前事件*/ +// case "onBeforeFinishWorkitem": +// /** 根据form处理相关业务表单的数据*/ +// switch (formApp) { +// case "abc123": +// break; +// default: +// return BaseResult.getFailureMessageEntity("未匹配到表单!当前formID:" + formApp, ""); +// } +// break; +// /** 处理事件*/ +// case "onFinishWorkitem": +// break; +// /** 回退前事件*/ +// case "onBeforeStepBack": +// break; +// /** 回退事件*/ +// case "onStepBack": +// break; +// /** 取回前事件*/ +// case "onBeforeTakeBack": +// break; +// /** 取回事件*/ +// case "onTakeBack": +// break; +// default: +//// throw new RuntimeException("传入了非法事件类型!请参照:" + eventTypeBuffer.toString()); +// return BaseResult.getFailureMessageEntity("传入了非法事件类型!请参照:" + eventTypeBuffer.toString(), "", ""); +// } +// return BaseResult.getSuccessMessageEntity("传递成功", result); +// }catch (Exception e){ +// return BaseResult.getFailureMessageEntity("传递失败",e.getMessage()); +// } } @@ -314,8 +299,8 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { public JsonResultEntity thirdInterfaceSeeYonDefinitionRePush(JSONObject jsonObject) throws Exception { JSONObject requestData = jsonObject.getJSONObject("jsonStr"); JSONArray resultEntityArray = new JSONArray(); - if(null == requestData){ - throw new BaseSystemException("参数传递错误需要jsonStr!"); + if (null == requestData) { + throw new BaseSystemException("参数传递错误需要jsonStr!"); } //表单模版ID String formAppId = requestData.getString("formAppId"); @@ -325,24 +310,24 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { String dataSourceCode = requestData.getString("dataSourceCode"); //主表ID集合 formMainIds JSONArray formMainIds = requestData.getJSONArray("formMainIds"); - if(StrUtil.isEmpty(eventType)){ - throw new BaseSystemException("需要传递eventType 参照致远OA事件!"); + if (StrUtil.isEmpty(eventType)) { + throw new BaseSystemException("需要传递eventType 参照致远OA事件!"); } - if(StrUtil.isEmpty(formAppId)){ - throw new BaseSystemException("需要传递formAppId 参照致远OA 表 CAP_FORM_DEFINITION!"); + if (StrUtil.isEmpty(formAppId)) { + throw new BaseSystemException("需要传递formAppId 参照致远OA 表 CAP_FORM_DEFINITION!"); } - if(StrUtil.isEmpty(dataSourceCode)){ - throw new BaseSystemException("需要传递dataSourceCode 参照中台表 sys_data_source!"); + if (StrUtil.isEmpty(dataSourceCode)) { + throw new BaseSystemException("需要传递dataSourceCode 参照中台表 sys_data_source!"); } - if(null == formMainIds || formMainIds.size() == 0){ - throw new BaseSystemException("需要传递业务主表数据id集合,不允许全量推送!"); + if (null == formMainIds || formMainIds.size() == 0) { + throw new BaseSystemException("需要传递业务主表数据id集合,不允许全量推送!"); } SeeYonInterFaceEntity seeYonInterFaceEntity = new SeeYonInterFaceEntity(); - BeanUtil.copyProperties(requestData,seeYonInterFaceEntity); + BeanUtil.copyProperties(requestData, seeYonInterFaceEntity); List seeYonInterFaceEntityList = seeYonInterFaceDao.queryDefinitionInfo(seeYonInterFaceEntity); - if(null != seeYonInterFaceEntityList && seeYonInterFaceEntityList.size() >0){ - for(SeeYonInterFaceEntity interFaceEntity : seeYonInterFaceEntityList){ + if (null != seeYonInterFaceEntityList && seeYonInterFaceEntityList.size() > 0) { + for (SeeYonInterFaceEntity interFaceEntity : seeYonInterFaceEntityList) { String field_info = interFaceEntity.getField_info(); JSONObject infoJson = JSON.parseObject(field_info); //获取主表信息 @@ -355,7 +340,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { /** 设置主表查询条件*/ interFaceEntity.setTabName(formMainTableName); interFaceEntity.setDataSourceCode(dataSourceCode); - interFaceEntity.setFormMainIds( formMainIds.toJavaList(String.class) ); + interFaceEntity.setFormMainIds(formMainIds.toJavaList(String.class)); List> forMainList = seeYonInterFaceDao.queryDefinitionData(interFaceEntity); for (Map forMainRow : forMainList) { @@ -367,11 +352,11 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { String forMainId = String.valueOf(forMainRow.get("ID")); //组装主表数据 for (Map.Entry entry : forMainRow.entrySet()) { - formMainObj.put(entry.getKey().toLowerCase(),entry.getValue()); - } + formMainObj.put(entry.getKey().toLowerCase(), entry.getValue()); + } //组装明细表数据 - if(null != formSons && formSons.size() > 0){ - for(Object formSon : formSons){ + if (null != formSons && formSons.size() > 0) { + for (Object formSon : formSons) { JSONObject son = JSON.parseObject(JSON.toJSONString(formSon)); //明细数据 String sonTableName = son.getString("tableName"); @@ -385,38 +370,38 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { //组装明细数据 JSONObject forSonJson = new JSONObject(); for (Map.Entry entry : forSons.entrySet()) { - forSonJson.put(entry.getKey().toLowerCase(),entry.getValue()); - } + forSonJson.put(entry.getKey().toLowerCase(), entry.getValue()); + } jsonArray.add(forSonJson); } //设置明细表数据 - seeYonBean.put(sonTableName,jsonArray); + seeYonBean.put(sonTableName, jsonArray); } } - seeYonBean.put(formMainTableName,formMainObj); + seeYonBean.put(formMainTableName, formMainObj); JSONObject rePushRequestData = new JSONObject(); JSONObject object = new JSONObject(); - object.put("formApp",formAppId); - object.put("eventType",eventType); - object.put("businessDataStr",seeYonBean.toJSONString()); - object.put("affairId",""); - object.put("summaryId",requestData.getString("summaryId")); - object.put("currentActivityId",""); - object.put("id",forMainId); - object.put("hzyaExtData",requestData.getJSONObject("hzyaExtData")); - logger.info("Method:thirdInterfaceSeeYonDefinitionRePush 组装seeYonBean DATA: {}",seeYonBean.toJSONString()); + object.put("formApp", formAppId); + object.put("eventType", eventType); + object.put("businessDataStr", seeYonBean.toJSONString()); + object.put("affairId", ""); + object.put("summaryId", requestData.getString("summaryId")); + object.put("currentActivityId", ""); + object.put("id", forMainId); + object.put("hzyaExtData", requestData.getJSONObject("hzyaExtData")); + logger.info("Method:thirdInterfaceSeeYonDefinitionRePush 组装seeYonBean DATA: {}", seeYonBean.toJSONString()); - rePushRequestData.put("jsonStr",object); + rePushRequestData.put("jsonStr", object); - JsonResultEntity resultEntity = thirdInterfaceSeeYonPlugInInterfaceEntrance(rePushRequestData); - if(null != resultEntity){ + JsonResultEntity resultEntity = thirdInterfaceSeeYonPlugInInterfaceEntrance(rePushRequestData); + if (null != resultEntity) { resultEntityArray.add(resultEntity.getAttribute()); - }else{ - JSONObject jsonResultEntity = new JSONObject(); - jsonResultEntity.put("msg","从新推送失败"); - jsonResultEntity.put("id",forMainId); + } else { + JSONObject jsonResultEntity = new JSONObject(); + jsonResultEntity.put("msg", "从新推送失败"); + jsonResultEntity.put("id", forMainId); resultEntityArray.add(jsonResultEntity); } @@ -424,11 +409,12 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { } } } - return BaseResult.getSuccessMessageEntity("从新推送执行结束",resultEntityArray); + return BaseResult.getSuccessMessageEntity("从新推送执行结束", resultEntityArray); } /** * seeyon流程事件监听前置方法,绑定数据源 + * * @param entity * @return * @throws Exception @@ -443,10 +429,10 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { sysApplicationDatabaseEntity.setAppId(applicationEntity.getId()); sysApplicationDatabaseEntity.setDataSourceCode("master"); List sysDataSourceEntities = sysApplicationDatabaseDao.queryDSBase(sysApplicationDatabaseEntity); - if(sysDataSourceEntities != null && sysDataSourceEntities.size() > 0){ + if (sysDataSourceEntities != null && sysDataSourceEntities.size() > 0) { String parm = entity.getBodys(); JSONObject jsonObject = JSONObject.parseObject(parm); - jsonObject.put("dataSourceCode",sysDataSourceEntities.get(0).getSourceCode()); + jsonObject.put("dataSourceCode", sysDataSourceEntities.get(0).getSourceCode()); entity.setBodys(jsonObject.toJSONString()); } } catch (Exception e) { @@ -465,24 +451,24 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { @Override public JsonResultEntity colEventListener(JSONObject jsonObject) throws Exception { try { - if (null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("jsonStr"))){ + if (null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("jsonStr"))) { SeeYonInterFaceEntity entity = jsonObject.getJSONObject("jsonStr").toJavaObject(SeeYonInterFaceEntity.class); JSONObject requestData = new JSONObject(); //表单模版ID requestData.put("formAppId", entity.getFormAppId()); //事件事件类型 - requestData.put("eventType",entity.getEventType()); + requestData.put("eventType", entity.getEventType()); //数据源编码 - requestData.put("dataSourceCode",entity.getDataSourceCode()); - requestData.put("formMainIds",entity.getFormMainIds()); - requestData.put("summaryId",entity.getSummaryId()); + requestData.put("dataSourceCode", entity.getDataSourceCode()); + requestData.put("formMainIds", entity.getFormMainIds()); + requestData.put("summaryId", entity.getSummaryId()); JSONObject jsonStr = new JSONObject(); - jsonStr.put("jsonStr",requestData); + jsonStr.put("jsonStr", requestData); thirdInterfaceSeeYonDefinitionRePush(jsonStr); } - }catch (Exception e){ - logger.error("流程事件通知接口出错:{}",e); - return BaseResult.getSuccessMessageEntity("失败",e.getMessage()); + } catch (Exception e) { + logger.error("流程事件通知接口出错:{}", e); + return BaseResult.getSuccessMessageEntity("失败", e.getMessage()); } return BaseResult.getSuccessMessageEntity("成功"); } @@ -497,289 +483,85 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace { * @throws Exception */ @Override - public String colEventPost(String jsonStr, String formAppId, String eventType) throws Exception { - if (StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)){ + public JsonResultEntity colEventPost(String jsonStr, String formAppId, String eventType) throws Exception { + if (StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)) { SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity(); - sysApplicationApiEntity.setHeaderIn(formAppId+"_"+eventType); + sysApplicationApiEntity.setHeaderIn(formAppId + "_" + eventType); List applist = sysApplicationApiService.queryLike(sysApplicationApiEntity); - if (CollectionUtil.isNotEmpty(applist)){ - if (applist.size() > 1){ - throw new BaseSystemException("根据formID:" + formAppId+"查询出多条数据"); + if (CollectionUtil.isNotEmpty(applist)) { + if (applist.size() > 1) { + throw new BaseSystemException("根据formID:" + formAppId + "查询出多条数据"); + } + if (applist.size() == 0 ) { + throw new BaseSystemException("根据formID:" + formAppId + "eventType:"+eventType+"未查询到API配置"); } SysApplicationApiEntity sysApp = applist.get(0); - Map headerMap = MapBuilder.create(true) - .put("apiCode", String.valueOf(sysApp.getApiCode())) - //这里用中台做为发送方 - .put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj") - .put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=") - .put("appId",String.valueOf(sysApp.getAppCode())) - .build(); - String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(jsonStr).timeout(60000).execute().body(); - logger.info("调用中台返回的参数:{}",body); - return body; + //数据源配置 + SysApplicationDatabaseEntity sysApiDatabase = new SysApplicationDatabaseEntity(); + sysApiDatabase.setAppId(sysApp.getAppId()); + List apiDataBaseList = sysApplicationDatabaseDao.queryDSBase(sysApiDatabase); + if (CollectionUtils.isNotEmpty(apiDataBaseList) && apiDataBaseList.size() == 1){ + sysApiDatabase = apiDataBaseList.get(0); + } + JSONArray headerArray = JSONArray.parseArray(sysApp.getHeaderIn()); + Map headerMap = new HashMap<>(); + if (null != headerArray && headerArray.size() > 0) { + for (int i = 0; i < headerArray.size(); i++) { + JSONObject querys = headerArray.getJSONObject(i); + //query 只有基本类型,不用循环判断下级 + //判断参数是否有值 + //获取对象下面的层级数据 + String parameterName = querys.getString("parameterName"); + String example = querys.getString("example"); + headerMap.put(parameterName,example); + } + if (headerMap.isEmpty()){ + throw new BaseSystemException("根据formID:" + formAppId + "未获取到head参数"); + } + PluginBaseEntity pluginBaseEntity = PluginUtils.getPluginsById(headerMap.get("plugId")); + if (null == pluginBaseEntity) { + throw new BaseSystemException("根据ID获取插件错误!请传入正确的 pluginId"); + } + //执行业务逻辑代码 + JSONObject reqJson = new JSONObject(); + reqJson.put("jsonStr",jsonStr); + reqJson.put("formAppId",formAppId); + reqJson.put("eventType",eventType); + reqJson.put("headers",JSON.toJSONString(headerMap)); + reqJson.put("apiDataSourceCode",sysApiDatabase.getSourceCode()); + JsonResultEntity result = pluginBaseEntity.executeBusiness(reqJson); + return result; + } else { + throw new BaseSystemException("根据formID:" + formAppId + "未获取到head参数"); + } } } return null; } + @Override + public JsonResultEntity chengeBody(JSONObject object) throws Exception { + JSONObject jsonstr = object.getJSONObject("jsonStr"); + PluginBaseEntity pluginBaseEntity = null; + JsonResultEntity result; + String pluginId = jsonstr.getString("plugId"); + pluginBaseEntity = PluginUtils.getPluginsById(pluginId); + if (null == pluginBaseEntity) { + throw new BaseSystemException("根据ID获取插件错误!请传入正确的 pluginId"); + } else { + //执行业务逻辑代码 + result = pluginBaseEntity.executeBusiness(object); + } + return result; + } @Override - public SysExtensionApiEntity getToken(SysExtensionApiEntity entity) { + public SysExtensionApiEntity chengeBodySetPlug(SysExtensionApiEntity entity) { Map headers = entity.getHeaders(); - SysApplicationApiEntity sysApplicationEntity = entity.getReceiveApi(); - SysApplicationEntity sendApp = entity.getSendApp(); - SysApplicationEntity receiveApp = entity.getReceiveApp(); - if("1".equals(sysApplicationEntity.getNeedLogin()) && sysApplicationEntity.getAuthenticationPort() != null){ - SysApplicationApiEntity loginApi = getApiByAppIdApiCode(sysApplicationEntity.getAuthenticationPort()); - if (null == loginApi) { - return entity; - } - String rzquerys = getQuery(loginApi,null,null); - Map headersa = new HashMap<>(); - headersa.put("publicKey", sendApp.getPublicKey()); - headersa.put("secretKey", sendApp.getSecretKey()); - headersa.put("appId", receiveApp.getAppId().toString()); - headersa.put("apiCode", loginApi.getApiCode().toString()); - Map rzheaders = getHeaders(loginApi,headersa,null); - String rzbodys = getBodys(loginApi,null,null); - JsonResultEntity rzjsonResultEntity = sendData(loginApi,rzheaders,rzbodys,rzquerys); - if (!rzjsonResultEntity.isFlag()) { - return entity; - } - JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); - headers.put("token",attritube.getJSONObject("attribute").getString("id")); - } - entity.setHeaders(headers); + JSONObject jsonObject = JSONObject.parseObject(entity.getBodys()); + jsonObject.put("plugId", headers.get("plugId")); + entity.setBodys(jsonObject.toJSONString()); return entity; } - private SysApplicationApiEntity getApiByAppIdApiCode(String apiId) { - - String str = "apiId" + apiId ; - Object o = applicationCache.get("5", str); - if (o != null) { - return (SysApplicationApiEntity) o; - } - return null; - } - private JsonResultEntity sendData(SysApplicationApiEntity applicationApiEntity, Map headers ,String bodys ,String querys) { - StringBuffer urls = new StringBuffer(url); - if (querys != null) { - urls.append("?"); - urls.append(querys); - } - HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); - // HttpClient - CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build(); - HttpPost post = new HttpPost(urls.toString()); - CloseableHttpResponse response = null; - - RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(Integer.valueOf(applicationApiEntity.getTimeoutPeriod())).build(); - post.setConfig(requestConfig);//设置请求参数【超时时间】 - - if (headers != null && headers.size() > 0) { - for (String key : headers.keySet()) { - post.setHeader(key, headers.get(key)); - } - } - StringBuilder body = new StringBuilder(); - boolean flag = true; - try { - if (bodys != null && !"".equals(bodys)) { - ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8")); - entity.setContentType("application/json"); - post.setEntity(entity); - } - response = closeableHttpClient.execute(post); - - HttpEntity entity = response.getEntity(); - body.append(EntityUtils.toString(entity,"UTF-8")); - flag = true; - logger.info("返回结果:" + body); - } catch (Exception e) { - logger.error("请求错误:" + e.getMessage()); - body.append(e.getMessage()); - flag = false; - } finally { - try { - // 关闭响应对象 - if (response != null) { - response.close(); - } - // 关闭响应对象 - if (closeableHttpClient != null) { - closeableHttpClient.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - - } - if (flag) { - if (JSONUtil.isTypeJSON(body.toString())) { - JsonResultEntity jsonResultEntity = JSONObject.parseObject(body.toString(),JsonResultEntity.class); - if(jsonResultEntity.isFlag()){ - return BaseResult.getSuccessMessageEntity("转发成功", body); - }else { - return BaseResult.getFailureMessageEntity("转发失败", body); - } - }else { - return BaseResult.getFailureMessageEntity("转发失败", body); - } - } else { - return BaseResult.getFailureMessageEntity("转发失败", body); - } - } - - private String getBodys(SysApplicationApiEntity loginApi,String sendDatastr, JSONObject loginData) { - JSONObject sendData = new JSONObject(); - if(sendDatastr != null ){ - sendData = JSONObject.parseObject(sendDatastr); - } - if(loginData == null){ - loginData = new JSONObject(); - } - if (loginApi.getBodyIn() != null && !"".equals(loginApi.getBodyIn())) { - if (JSONUtil.isTypeJSONArray(loginApi.getBodyIn())) { - JSONArray headerbodyArray = JSON.parseArray(loginApi.getBodyIn()); - JSONObject bodyjson = headerbodyArray.getJSONObject(0); - JSONArray headerArray = bodyjson.getJSONArray("children"); - for (int i = 0; i < headerArray.size(); i++) { - //获取到第一个数据 - JSONObject querys = headerArray.getJSONObject(i); - if (SysEnum.FUNDAMENTAL.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 - String query = querys.getString(SysEnum.EXAMPLE.getValue()); - if (query != null && !"".equals(query)) { - sendData.put(querys.getString(SysEnum.PARAMETERNAME.getValue()),query); - } - } - } - } - } - return sendData.toString(); - } - - private Map getHeaders(SysApplicationApiEntity loginApi,Map map,JSONObject loginData) { - if(loginData == null){ - loginData = new JSONObject(); - } - if (loginApi.getHeaderIn() != null && !"".equals(loginApi.getHeaderIn())) { - if (JSONUtil.isTypeJSONArray(loginApi.getHeaderIn())) { - JSONArray headerArray = JSON.parseArray(loginApi.getHeaderIn()); - for (int i = 0; i < headerArray.size(); i++) { - JSONObject querys = headerArray.getJSONObject(i); - //query 只有基本类型,不用循环判断下级 - //判断参数是否有值 - //获取对象下面的层级数据 - if (SysEnum.AUTHPORT.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 - String query = querys.getString(SysEnum.EXAMPLE.getValue()); - if (query != null && !"".equals(query)) { - JSONArray example = JSONArray.parseArray(query); - String logValue = getObjectValue(loginData, example); - map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), logValue); - } - } else { - if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值,如果没有不添加 - if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ - map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), querys.getString(SysEnum.EXAMPLE.getValue())); - } - } else {//没有值直接拼接 - if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ - map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), ""); - } - } - } - } - } - } - return map; - - - } - - /** - * @param loginData - * @param example - * @return java.lang.String - * @Author lvleigang - * @Description 根据jsonArray 获取jsonobject中的值 - * @Date 11:47 上午 2023/8/31 - **/ - private String getObjectValue(JSONObject loginData, JSONArray example) { - String values = ""; - if (example != null && example.size() > 0) { - for (int i = 0; i < example.size(); i++) { - if (loginData.getString(example.getString(i)) != null && !"".equals(loginData.getString(example.getString(i)))) { - if (i == (example.size() - 1)) { - values = loginData.getString(example.getString(i)); - } else { - loginData = JSONObject.parseObject(loginData.getString(example.getString(i))); - } - } else { - return values; - } - } - } - return values; - } - private String getQuery(SysApplicationApiEntity loginApi,String sendDatastr,JSONObject loginData) { - Map map = new HashMap<>(); - if(sendDatastr != null){ - String[] parts = sendDatastr.split("&"); - if(parts != null && parts.length > 0){ - for (int i = 0; i < parts.length; i++) { - String[] part = parts[i].split("="); - if(part != null && part.length >=2 ){ - for (int a = 0; a < part.length; a++) { - map.put(part[0],part[1]); - } - } - } - } - } - if(loginData == null){ - loginData = new JSONObject(); - } - if (loginApi.getQueryIn() != null && !"".equals(loginApi.getQueryIn())) { - if (JSONUtil.isTypeJSONArray(loginApi.getQueryIn())) { - JSONArray headerArray = JSON.parseArray(loginApi.getQueryIn()); - for (int i = 0; i < headerArray.size(); i++) { - JSONObject querys = headerArray.getJSONObject(i); - //query 只有基本类型,不用循环判断下级 - //判断参数是否有值 - //获取对象下面的层级数据 - if (SysEnum.AUTHPORT.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 - String query = querys.getString(SysEnum.EXAMPLE.getValue()); - if (query != null && !"".equals(query)) { - JSONArray example = JSONArray.parseArray(query); - String logValue = getObjectValue(loginData, example); - map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), logValue); - } - } else { - //不是认证类型直接取值 - if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值,如果没有不添加 - if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ - map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), querys.getString(SysEnum.EXAMPLE.getValue())); - } - } else {//没有值直接拼接 - if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ - map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), ""); - } - } - } - } - } - } - StringBuffer returnStr = new StringBuffer(); - if(map != null && map.size() > 0){ - for (String key : map.keySet()) { - if("".equals(returnStr)){ - returnStr.append(key).append("=").append(map.get(key)); - }else { - returnStr.append("&").append(key).append("=").append(map.get(key)); - } - } - } - return returnStr.toString(); - } } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/util/OABipUtil.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/util/OABipUtil.java index 53941ca8..9484e2fb 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/util/OABipUtil.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/util/OABipUtil.java @@ -21,15 +21,15 @@ public class OABipUtil { * */ - public static String sendOATOBipEsb(String parm, String apiCode,String token){ - String baseUrl = "http://127.0.0.1:9011/kangarooDataCenterV3/entranceController/externalCallInterface"; + public static String sendU9cTOBipEsb(String parm, String apiCode,String token){ + String baseUrl = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface"; System.out.println("推送参数"+parm); String result = HttpRequest.post(baseUrl) - .header("appId", "800050")//头信息,多个头信息多次调用此方法即可 + .header("appId", "800023")//头信息,多个头信息多次调用此方法即可 .header("access_token", token)//头信息,多个头信息多次调用此方法即可 .header("apiCode", apiCode)//头信息,多个头信息多次调用此方法即可 - .header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可 - .header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可 + .header("publicKey", "ZJYA1vBeY1ai53iNmbAEsw6DImjkXGBkdMailxcBdliFC85Ce7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可 + .header("secretKey", "7Gp6OjHrIaQ6R3tXGPrI4morjQyWL+qu4JJschQnkBRtv26VDgGFVYKOy5kMZfd/j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可 .body(parm)//表单内容 .timeout(20000)//超时,毫秒 .execute().body(); @@ -40,13 +40,13 @@ public class OABipUtil { return null; } public static String getBipToken(String userCode, String apiCode){ - String baseUrl = "http://127.0.0.1:9011/kangarooDataCenterV3/entranceController/externalCallInterface"; + String baseUrl = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface"; String result = HttpRequest.post(baseUrl) - .header("appId", "800050")//头信息,多个头信息多次调用此方法即可 + .header("appId", "800023")//头信息,多个头信息多次调用此方法即可 .header("apiCode", apiCode)//头信息,多个头信息多次调用此方法即可 -// .header("usercode", userCode)//头信息,多个头信息多次调用此方法即可 - .header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可 - .header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可 + .header("usercode", userCode)//头信息,多个头信息多次调用此方法即可 + .header("publicKey", "ZJYA1vBeY1ai53iNmbAEsw6DImjkXGBkdMailxcBdliFC85Ce7eDIk+3zDUT+v578prj")//头信息,多个头信息多次调用此方法即可 + .header("secretKey", "7Gp6OjHrIaQ6R3tXGPrI4morjQyWL+qu4JJschQnkBRtv26VDgGFVYKOy5kMZfd/j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息,多个头信息多次调用此方法即可 .body("")//表单内容 .timeout(20000)//超时,毫秒 .execute().body(); diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/util/OARestUtil.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/util/OARestUtil.java index 84b42102..73b2d0dc 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/util/OARestUtil.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/util/OARestUtil.java @@ -26,9 +26,9 @@ import java.util.List; * @Date 2024/6/17 15:49 **/ @Component -public class OARestUtil { +public class OARestUtil { @Autowired - private ISysApplicationApiService sysApplicationApiService; + private static ISysApplicationApiService sysApplicationApiService; static Logger logger = LoggerFactory.getLogger(OARestUtil.class); private OARestUtil() { @@ -41,14 +41,14 @@ public class OARestUtil { * @param api_code 接口编码 * @return */ - public JSONObject fileUpload(File file,String api_code) { - if (StrUtil.isNotEmpty(api_code)){ + public static JSONObject fileUpload(File file,String api_code_upload,String api_code_token) { + if (StrUtil.isNotEmpty(api_code_upload)){ //1、查询附件上传api接口信息 - SysApplicationApiEntity sysApp = getByCode(api_code); + SysApplicationApiEntity sysApp = getByCode(api_code_upload); if (null != sysApp){ String app_url = sysApp.getAppUrl(); String url = app_url+"/seeyon/rest/attachment?token=@token@"; - String token = getToken(null,"8000240000"); + String token = getToken(null,api_code_token); url = url.replaceAll("@token@",token); HashMap paramMap = new HashMap<>(); paramMap.put("file", file); @@ -147,7 +147,7 @@ public class OARestUtil { * @param api_code * @return */ - public String getToken(String login_name,String api_code){ + public static String getToken(String login_name,String api_code){ if (StrUtil.isNotEmpty(api_code)){ SysApplicationApiEntity sysApp = getByCode(api_code); return getToken(login_name,sysApp); @@ -162,7 +162,7 @@ public class OARestUtil { * @param sysApp 应用信息 * @return */ - public String getToken(String login_name,SysApplicationApiEntity sysApp){ + public static String getToken(String login_name,SysApplicationApiEntity sysApp){ if (null != sysApp){ HashMap hashMap = new HashMap<>(); String app_url = StrUtil.removeSuffix(sysApp.getAppUrl(), "/"); @@ -190,7 +190,7 @@ public class OARestUtil { } return null; } - private SysApplicationApiEntity getByCode(String api_code){ + private static SysApplicationApiEntity getByCode(String api_code){ if (StrUtil.isNotEmpty(api_code)){ SysApplicationApiEntity sysApp = new SysApplicationApiEntity(); sysApp.setApiCode(Long.valueOf(api_code)); diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/util/SM2Util.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/util/SM2Util.java index 47ff93c4..860a45a3 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/util/SM2Util.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/util/SM2Util.java @@ -236,15 +236,15 @@ public class SM2Util { private void testSignByQuickpass() throws Exception { //密钥生成 - String privateKey = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0"; - String publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEyocGV+D91yPL2EyngjizFW2p1DW2l46yBGcp7IcHTs0VYM0UEojzVqOjgQZAD76hPtkUvuQAaUvNg0pSpfNc9A=="; + String privateKey = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgOHOzaKWBWOAbslvtYtS8tcQiJ9W9DT2cGQM3KSgXpfygCgYIKoEcz1UBgi2hRANCAAQNPct0MHOuDrVJBIy0RI7JKx9/PTlFHZlkIJr0EqpC+b/+N+z3JKbCMZ/wcP1V36Q+DlfDJCY9Ai/Uk2PZ9ZaF"; + String publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEDT3LdDBzrg61SQSMtESOySsffz05RR2ZZCCa9BKqQvm//jfs9ySmwjGf8HD9Vd+kPg5XwyQmPQIv1JNj2fWWhQ=="; // 加验签 //String value = "{\"partner\": \"test\",\"tranTime\": \"20240128003627\",\"seqNo\": \"123456\",\"orderNo\": \"order123456\", \"orderAmt\": \"1500\"}"; String value="{\"data\":{\"companyCode\":\"CN000001\",\"purpose\":\"加入中国光伏行业协会会员单位,获得行业技术支持,2025年会员单位缴纳标准为1万元/年,汇款时需注明“会费”字样,并在备注中注明汇款单位;缴纳会费后,需有付款凭证,将付款凭证发送至协会邮箱,并填写开票信息等内容\",\"recAccountNum\":\"8110701012801540483\",\"recAccountName\":\"\",\"payAccountNum\":\"8110701012601540892\",\"fundType\":\"0001\",\"transAmount\":\"9.90\",\"documentNo\":\"DG202503240321\",\"recBankCode\":\"\",\"settleAccountType\":\"CASH_TRANSFER\",\"sourceFlowNumber\":\"-3854827654841675885_1539\",\"submitUser\":\"user1\",\"digest\":\"加入中国光伏行业协会会员单位,获得行业技术支持,2025年会\",\"payChannel\":\"DIRECT\",\"currency\":\"CNY\",\"toPublic\":true,\"payAccountName\":\"\",\"payDate\":\"2025-03-26\"}}"; System.out.println("明文:" + value); //加密 - String encryptStr = encrypt(value, publicKey); - //String encryptStr="BAYF5RocTMvWHK4JLruoWNmvoBtSgEK6bHrXUIBcso3dx312VyI57p3bahg/qjcQufpa59XiMd8wA+cjyXmYm9+P4Y7DY5dZJQi6FdPZpL6awouRZMagdlceOL8yW5zDnx8tMqreUTAwkpvViwKn4DydKdV9EW0XuWkBwsN+4ZQftrY3FT/5Y/g8XtNSQMBu9PIwGWtPtpEtwO0HnaGCu7DGCSF+lo4PvYFmIlj0f2hQ1V1osdNIJ3IqUeZ0IZVFulaaOE72+vgAQN7UO0447kPq5iC8++oyXP7Bhf9kfU1gYOVXciIeAXoxIcjX+5DCB1q/FOmzqnOIBLRhSysqRXJa0ZvFgf1Ebpr6Fvz2Beim8SOEl3pXeLnLCJe91qsMuENLfNTOYnuESgSmdE1np3OJKcZwgeryUIt+WP7L28aJ1zNisWhB+TJaGtvWR++zY2fmMeZmwtJEz25jdmN1OWSuxgjXpI7fhIYoDnKQBQJKM5FQ+cWqJJozUMOlKG8Xhf5Lv1NjZOiNM7klp/Uprb3kUQj466ArWvsLzsoT1OOTOyBRJTbhKPSKi39ekcz4/ELuGSNB8Oz0pNg1tjbuyIcbiy2WCQI9/feiE+LyGgQPiUsaNxte10bYZuJJV33UWrBiezL0eA5pSm55zd98ToCX0QnJJq5OGW/8t8O/7+fZcSq5EFXSfS+3An8+EMLnBvI1ycjb9Q7PFVP4PmZ/VFqWJDNyi98iekWV09DVCtnCHqA5ZqEcPgZCeY40ZN5EQARvy11RWzs14Gj8JninjFbV6qtgB1Cadmy/piZS/SZdEvSnBfe04vTOElgG5GhraLrfMyVhnsmLeoqzLXmMT62uktPXKITjvFgr2NfdzbY5TkkDVMJu1b3VhZxOZENnJ4kW6nctYO0I7Z+xpVuMUnNOVxQBSJch2AdwIuyEL3odJSOXUt+RZIXhGNhyKw2Y8PvPQx+hOoCUyKyaUIS8G6RK/LI+TyMZTMsCUXYBEIxP10slFPp/4PCa7RPLhvdHsgik+cWNJj45tJRql9YXF1moWIaAUmLeu/ytCho1arA3V6/NjjckWI9mnqs41U2FAchJXdU2wNdIDB4AgGSsZs+o9sv+chgMgITV8/8xPNchu6g1UuczEXZRPFtKsVXlAJkNzQgBrMwCatby1S4CJFc5S/AJNIYipwLGW+M+3rh2+Ay+3HqDv7+7LUn+MTxgFfiosyK3hxkekY/eUg=="; + //String encryptStr = encrypt(value, publicKey); + String encryptStr="BLTRQV8d8D1ILWs21weVXVubIB1Ppx3Oy3rWqdocyrAXm5WBNhSz6YemoVVPTTtdycJ3mcFF1YuRKhuHsMhU/VkzssS3i7W8FPwWHNyyorhd3LrP0HMx+j3MN/s7kGs9PGRem/X4U+tQsJxoQSi8CkmwCcF42aN78LkQ5292cDQ6/AcobhKYNHBqCeX9+gUhue76pWFM12k9rXQYvCnIqdf+vB5ot+UXuk3eXwnlmVdP+f5kSSKxyWRIC8GjLwHRWChkuk6IkjIhVlSMJfVt1fOseBYq5VW32XkHQFbSZW3JvYUhHpimibw7SP6SK60TT8lfJzsABJ5euADCFlhVwfUZZXZLdSV4YFSB/IQ6vVkHorQmD5RdGxktgu3MbErdEPhiGl7/tLj6gKi2ecRobGkQwu1peKcKB08WgnWFX/6Wbs0dxfavAAc1W3mXta0zx/+q2jiIydCsySUT2xCRDVBlGHPIlN8RDucQ4mOE5gBlr9vvMxnKOG2kdWzTVoj+aibqKh5ljwGbIUetbE3XtwNlO7deupvTaUN565P1M8cuK7zQjLeoUD2gqLMZOzz5fgkrPTzd7jUyf3QatDOGEFxrF1u03BMJVNAssxj7pdq2aSBTrHKwafoplUpWEAogeiUh2xYlVSEu2BUinHoMxqGU57UM/ZU1IRFgVKTdHV/R/4hLOpu55Mq7C5cOTVwVFasnIdbkJvabNX/vN0js9Bx/2QJx5SN2wqCV5R4yrXTH4dUGVTQFNLuiZSX8TML463FCIrtiofHZ/jvp3hEbyYTchkMuPEvH3MBZAt6ZXmwInYEktymF2nvBD7Pw22xQaE1Sqfjig5m4gQHB1mRV/RKCaNv7CuXsef29ldU5mQnER0U="; System.out.println("加密结果:" + encryptStr); //解密 diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.xml b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.xml index b8c383c8..74f290c8 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.xml +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.xml @@ -76,7 +76,7 @@