diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/PayApplyPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/PayApplyPluginInitializer.java index 4d06fd8c..83886054 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/PayApplyPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/PayApplyPluginInitializer.java @@ -3,6 +3,7 @@ package com.hzya.frame.plugin.cbs8.plugin; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.base.PluginBaseEntity; import com.hzya.frame.plugin.cbs8.service.ICbsPluginService; +import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity; import com.hzya.frame.web.entity.JsonResultEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,8 +97,16 @@ public class PayApplyPluginInitializer extends PluginBaseEntity { **/ @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { + PaymentEntity paymentEntity = null; + if (null != requestJson){ + requestJson.remove("jsonStr"); + paymentEntity = JSONObject.parseObject(requestJson.toString(),PaymentEntity.class); + } + if (null == paymentEntity) + paymentEntity = new PaymentEntity(); //支付申请 - // cbsPluginService.applyPay(requestJson); + paymentEntity.setOaId("5490849762671477371"); + cbsPluginService.applyPay(paymentEntity); return null; } } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/PayResultPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/PayResultPluginInitializer.java index b7f9646e..fab668fa 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/PayResultPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/PayResultPluginInitializer.java @@ -3,6 +3,7 @@ package com.hzya.frame.plugin.cbs8.plugin; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.base.PluginBaseEntity; import com.hzya.frame.plugin.cbs8.service.ICbsPluginService; +import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity; import com.hzya.frame.web.entity.JsonResultEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -95,7 +96,15 @@ public class PayResultPluginInitializer extends PluginBaseEntity { **/ @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { - cbsPluginService.queryResult(requestJson); + CbsLogEntity cbsLogEntity = null; + if (null != requestJson){ + requestJson.remove("jsonStr"); + cbsLogEntity = JSONObject.parseObject(requestJson.toString(),CbsLogEntity.class); + } + if (null == cbsLogEntity){ + cbsLogEntity = new CbsLogEntity(); + } + cbsPluginService.queryResult(cbsLogEntity); return null; } } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/TransactionDetailPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/TransactionDetailPluginInitializer.java index e65b75dc..62f0a278 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/TransactionDetailPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/plugin/TransactionDetailPluginInitializer.java @@ -1,5 +1,6 @@ package com.hzya.frame.plugin.cbs8.plugin; +import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.base.PluginBaseEntity; import com.hzya.frame.cbs8.dto.req.TransactionDetailReqDTO; @@ -101,10 +102,23 @@ public class TransactionDetailPluginInitializer extends PluginBaseEntity { **/ @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { - TransactionDetailReqDTO transactionDetailReqDTO = new TransactionDetailReqDTO(); + TransactionDetailReqDTO transactionDetailReqDTO = null; + if (null != requestJson){ + requestJson.remove("jsonStr"); + transactionDetailReqDTO = JSONObject.parseObject(requestJson.toString(),TransactionDetailReqDTO.class); + } + if (null == transactionDetailReqDTO){ + transactionDetailReqDTO = new TransactionDetailReqDTO(); + } transactionDetailReqDTO.setCurrentPage(CBSUtil.DEFAULT_CURRENT_PAGE); transactionDetailReqDTO.setPageSize(CBSUtil.DEFAULT_PAGE_SIZE); + transactionDetailReqDTO.setStartDate(DateUtil.today()); + transactionDetailReqDTO.setEndDate(DateUtil.today()); + transactionDetailReqDTO.setDateType("0"); + transactionDetailReqDTO.setLoanType("2"); List transactionDetailList = cbsPluginService.queryTransactionDetail(transactionDetailReqDTO); - return null; + System.out.println("11111"); + return new JsonResultEntity("成功",true,transactionDetailList); + //return null; } } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/service/ICbsPluginService.java b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/service/ICbsPluginService.java index ae6401b4..69720b16 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/service/ICbsPluginService.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/service/ICbsPluginService.java @@ -8,6 +8,8 @@ import com.hzya.frame.cbs8.dto.res.PayResponseDTO; import com.hzya.frame.cbs8.dto.res.TransactionDetailDTO; import com.hzya.frame.seeyon.cbs8.entity.AgentPaymentDetailEntity; import com.hzya.frame.seeyon.cbs8.entity.AgentPaymentEntity; +import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity; +import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity; import java.util.List; @@ -20,16 +22,16 @@ public interface ICbsPluginService { /** * 支付申请 - * @param requestJson + * @param entity */ - void applyPay(JSONObject requestJson)throws Exception; + void applyPay(PaymentEntity entity)throws Exception; /** * 查询支付申请的交易结果 - * @param requestJson + * @param cbsLogEntity * @throws Exception */ - void queryResult(JSONObject requestJson)throws Exception; + void queryResult(CbsLogEntity cbsLogEntity)throws Exception; /** * 电子回单查询 并上传OA diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/service/impl/CbsPluginServiceImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/service/impl/CbsPluginServiceImpl.java index 8ce5fb78..347cad0c 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/service/impl/CbsPluginServiceImpl.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/cbs8/service/impl/CbsPluginServiceImpl.java @@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Value; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -60,12 +61,14 @@ public class CbsPluginServiceImpl implements ICbsPluginService { /** * 支付申请 * - * @param requestJson + * @param paymentEntity */ @Override - public void applyPay(JSONObject requestJson) throws Exception{ + public void applyPay(PaymentEntity paymentEntity) throws Exception{ //查询待支付的列表 - PaymentEntity paymentEntity = new PaymentEntity(); + if (null == paymentEntity){ + paymentEntity = new PaymentEntity(); + } paymentEntity.setDataSourceCode(oa_data_source_code); List paymentList = paymentService.queryUnpaid(paymentEntity); /* List paymentList = new ArrayList<>(); @@ -87,7 +90,14 @@ public class CbsPluginServiceImpl implements ICbsPluginService { for (PaymentEntity pay : paymentList) { //调用支付申请接口 PayResponseDTO payResponseDTO = cbs8Service.payApply(pay); + boolean successed = payResponseDTO.getSuccessed(); + if (successed){ + pay.setPayResult(PayState.p.getValue()); + }else { + pay.setPayResult("推送失败"); + } //4、更新OA表单 + pay.setDataSourceCode(oa_data_source_code); paymentService.updatePayState(pay); //5、记录操作日志 cbsLogService.saveLog(new CbsLogEntity()); @@ -98,12 +108,14 @@ public class CbsPluginServiceImpl implements ICbsPluginService { /** * 查询支付申请的交易结果 * - * @param requestJson + * @param cbsLogEntity * @throws Exception */ @Override - public void queryResult(JSONObject requestJson) throws Exception { - CbsLogEntity cbsLogEntity = new CbsLogEntity(); + public void queryResult(CbsLogEntity cbsLogEntity) throws Exception { + if (null == cbsLogEntity){ + cbsLogEntity = new CbsLogEntity(); + } // 1、查询支付中的日志 List inPayList = cbsLogService.queryInPayment(cbsLogEntity); if (CollectionUtils.isNotEmpty(inPayList)){ @@ -162,7 +174,10 @@ public class CbsPluginServiceImpl implements ICbsPluginService { public void elecBillUpload(JSONObject requestJson) throws Exception { //查询支付成功 没有电子回单的数据 PaymentEntity paymentEntity = new PaymentEntity(); - List paymentList = paymentService.queryElecIsNull(paymentEntity); + // List paymentList = paymentService.queryElecIsNull(paymentEntity); + paymentEntity.setPayDate("2024-06-20"); + paymentEntity.setReferenceNum("41"); + List paymentList = Arrays.asList(paymentEntity); if (CollectionUtils.isNotEmpty(paymentList)) { for (PaymentEntity pay : paymentList) { try { diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java index 6c683a0a..0b223649 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java @@ -2,6 +2,8 @@ package com.hzya.frame.plugin.mdmDistribute.plugin; import cn.hutool.core.util.StrUtil; 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; @@ -17,6 +19,7 @@ import com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDe 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; @@ -135,7 +138,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { 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)){ + || "".equals(mdmCode) || "".equals(documentRule) || "".equals(distributeId) || "".equals(type)){ taskDetailEntity.setResult("系统保存参数错误"); taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity); return BaseResult.getFailureMessageEntity("系统保存参数错误"); @@ -183,7 +186,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ; mdmModuleDistributeDetailEntity.setDistributeId(distributeId); mdmModuleDistributeDetailEntity.setSts("Y"); - List mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity); + List mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity); // 启用停用 0、停用 //if("1".equals(mdmModuleDistributeEntity.getEnabledType())){ @@ -273,11 +276,13 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { if(mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0){ for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) { if(mdmModuleDbFiledsRuleEntities.get(i1).getFiledId().equals(mdmModuleDbFiledsEntities.get(i2).getId())){ - Map mapDetail = new HashMap<>(); - mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); - mapDetail.put("id",object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); - JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); - object.put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + if(object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){ + Map mapDetail = new HashMap<>(); + mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); + mapDetail.put("id",object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); + JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); + object.put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + } } } } @@ -302,11 +307,14 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { 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++) { - Map mapDetail = new HashMap<>(); - mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); - mapDetail.put("id",detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); - JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); - detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + if(detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){ + Map mapDetail = new HashMap<>(); + mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); + mapDetail.put("id",detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); + JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); + detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + } + } } } @@ -340,10 +348,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { JSONObject groovyStr = new JSONObject(); groovyStr.put("jsonStr",groovy); try { - SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy); - header = jsonResultEntity.getHeaders(); - querys = jsonResultEntity.getQuerys(); - bodys = jsonResultEntity.getBodys(); + 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); @@ -358,6 +367,33 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { 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()); + 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()){ @@ -386,9 +422,9 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { queryMdmModuleDistributeEntity.setEnabledType("1"); queryMdmModuleDistributeEntity.setEnabledState("1"); List mdmModuleDistributeEntities = mdmModuleDistributeDao.queryBase(queryMdmModuleDistributeEntity); - if(mdmModuleDistributeEntities == null || mdmModuleDistributeEntities.size() == 0){ - continue; - } + if(mdmModuleDistributeEntities == null || mdmModuleDistributeEntities.size() == 0){ + continue; + } //查询主数据db MdmModuleDbEntity queryMdmModuleDbEntity = new MdmModuleDbEntity(); queryMdmModuleDbEntity.setMdmId(mdmModuleEntities.get(i).getId()); @@ -423,7 +459,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { logger.info("执行成功"); return BaseResult.getSuccessMessageEntity("执行成功"); } catch (Exception e) { - logger.error("执行失败{}",e.getMessage()); + logger.error("执行失败{}",e.getMessage()); } return BaseResult.getSuccessMessageEntity("执行成功"); } @@ -534,10 +570,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { JSONObject groovyStr = new JSONObject(); groovyStr.put("jsonStr",groovy); try { - SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy); - header = jsonResultEntity.getHeaders(); - querys = jsonResultEntity.getQuerys(); - bodys = jsonResultEntity.getBodys(); + 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("2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3"); continue; @@ -551,6 +588,31 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { if(header != null){ headers.putAll(header); } + if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + //找到登陆接口 + SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); + if (null == loginApi) { + saveMdmModuleSendLogEntity("2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),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("2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),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()){ @@ -591,7 +653,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { } Map map1 = new HashMap<>(); map1.put("tableName",mainDb); - map1.put("dataStatus", "F"); + //map1.put("dataStatus", "F"); map1.put("updateStatus", "0"); map1.put("size", 1000); objects = mdmModuleDao.queryMdmSTs(map1); @@ -608,7 +670,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { //查询这一千条数据是否符合规则 Map map = new HashMap<>(); map.put("tableName", mainDb); - map.put("dataStatus", "F"); + //map.put("dataStatus", "F"); map.put("updateStatus", "0"); map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities); map.put("ids", objects); @@ -674,10 +736,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { JSONObject groovyStr = new JSONObject(); groovyStr.put("jsonStr",groovy); try { - SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy); - header = jsonResultEntity.getHeaders(); - querys = jsonResultEntity.getQuerys(); - bodys = jsonResultEntity.getBodys(); + 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("2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2"); continue; @@ -691,6 +754,31 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { if(header != null){ headers.putAll(header); } + if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + //找到登陆接口 + SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); + if (null == loginApi) { + saveMdmModuleSendLogEntity("2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),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("2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),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()){ @@ -709,7 +797,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { for (int i = 0; i < objects.size(); i++) { Map updateMap = new HashMap<>(); updateMap.put("tableName",mainDb); - updateMap.put("dataStatus", "F"); + //updateMap.put("dataStatus", "F"); updateMap.put("updateStatus", "1"); updateMap.put("id", objects.get(i).getString("id")); mdmModuleDao.updateMdmSTs(updateMap); @@ -738,7 +826,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { } Map map1 = new HashMap<>(); map1.put("tableName",mainDb); - map1.put("dataStatus", "Y"); + //map1.put("dataStatus", "Y"); map1.put("addStatus", "0"); map1.put("size", 1000); objects = mdmModuleDao.queryMdmSTs(map1); @@ -755,7 +843,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { //查询这一千条数据是否符合规则 Map map = new HashMap<>(); map.put("tableName", mainDb); - map.put("dataStatus", "Y"); + //map.put("dataStatus", "Y"); map.put("addStatus", "0"); map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities); map.put("ids", objects); @@ -830,10 +918,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { JSONObject groovyStr = new JSONObject(); groovyStr.put("jsonStr",groovy); try { - SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy); - header = jsonResultEntity.getHeaders(); - querys = jsonResultEntity.getQuerys(); - bodys = jsonResultEntity.getBodys(); + 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("2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1"); continue; @@ -847,6 +936,32 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { if(header != null){ headers.putAll(header); } + if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + //找到登陆接口 + SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); + if (null == loginApi) { + saveMdmModuleSendLogEntity("2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),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("2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),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()){ @@ -859,18 +974,13 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { continue; } } - - - - - } //所有下发发送完成,修改数据状态 for (int i = 0; i < objects.size(); i++) { Map updateMap = new HashMap<>(); updateMap.put("tableName",mainDb); - updateMap.put("dataStatus", "Y"); + //updateMap.put("dataStatus", "Y"); updateMap.put("addStatus", "1"); updateMap.put("id", objects.get(i).getString("id")); mdmModuleDao.updateMdmSTs(updateMap); @@ -880,7 +990,6 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { private void saveMdmModuleSendLogEntity(String dataType,String remark,String dbname,String formmain_id, String target_app, String target_api, String source_data, String option_type) { MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity(); mdmModuleSendLogEntity.setTableName(dbname+"_send_log"); - mdmModuleSendLogEntity.setCreate(); mdmModuleSendLogEntity.setId(UUIDUtils.getUUID()); mdmModuleSendLogEntity.setSts("Y"); mdmModuleSendLogEntity.setCreate_user_id("1"); @@ -916,11 +1025,13 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { 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++) { - Map mapDetail = new HashMap<>(); - mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); - mapDetail.put("id",detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); - JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); - detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + if(detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){ + Map mapDetail = new HashMap<>(); + mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); + mapDetail.put("id",detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); + JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); + detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail); + } } } } @@ -959,7 +1070,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { } StringBuilder body = new StringBuilder(); boolean flag = true; - try { + try { if (bodys != null && !"".equals(bodys)) { ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8")); entity.setContentType("application/json"); @@ -1007,4 +1118,159 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { 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(); + } } diff --git a/buildpackage/src/main/resources/application-llg.yml b/buildpackage/src/main/resources/application-llg.yml index b8800d3a..c1e105f8 100644 --- a/buildpackage/src/main/resources/application-llg.yml +++ b/buildpackage/src/main/resources/application-llg.yml @@ -17,19 +17,33 @@ spring: filters: stat,log4j2 datasource: master: - url: jdbc:dm://hzya.ufyct.com:9040?schema=businesscenter&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle - username: hzyazt - password: 62e4295b615a30dbf3b8ee96f41c820b - driver-class-name: dm.jdbc.driver.DmDriver -# type: com.alibaba.druid.pool.DruidDataSource -# url: jdbc:mysql://hzya.ufyct.com:9014/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true -# username: root +# url: jdbc:dm://hzya.ufyct.com:9040?schema=businesscenter&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle +# username: hzyazt # password: 62e4295b615a30dbf3b8ee96f41c820b -# driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置 +# driver-class-name: dm.jdbc.driver.DmDriver +# type: com.alibaba.druid.pool.DruidDataSource + url: jdbc:mysql://hzya.ufyct.com:9014/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true + username: root + password: 62e4295b615a30dbf3b8ee96f41c820b + driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置 # url: jdbc:dm://hzya.ufyct.com:9040/businesscenter?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 savefile: # 文件保存路径 path: /Users/apple/Desktop/log/local zt: - url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface \ No newline at end of file + url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface +cbs8: + appId: 1P4AGrpz + appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a + url: https://cbs8-openapi-reprd.csuat.cmburl.cn + # 测试用这个 这个是银行给的,和下面的公钥不是一对密钥 + ya_private_key: 83BA7EC821D35F4CB31FF9A51C1EFA520FC52AF828C2337F88E91CF119B07F44 + # 这个私钥到时候上传到cbs,和下面到是同一对 + #ya_private_key: e1eacfdee9b8d4184437d5a2071e17ce31befc3d93395f9f05709ed562e8dc46 + ya_public_key: 044fa399d2223760f17b81b863cb482b009294c4516f8a605dea1475ec09e720eaa98468715e5ad509a592a0b426061551c5a3df236966c23253a7d894eac0dcde + cbs_public_key: 0469146F06BF3B01236E84632441E826 + #电子回单下载临时存放位置 + elec_path: /Users/xiangerlin/Downloads/ +OA: + data_source_code: yc_oa \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/temButtom.java b/buildpackage/src/test/java/com/hzya/frame/temButtom.java index abab97f8..e59468ee 100644 --- a/buildpackage/src/test/java/com/hzya/frame/temButtom.java +++ b/buildpackage/src/test/java/com/hzya/frame/temButtom.java @@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert; import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.baomidou.dynamic.datasource.annotation.DS; import com.hzya.frame.cbs8.dto.req.PayRequestDTO; import com.hzya.frame.cbs8.dto.req.PayResultRequestDTO; import com.hzya.frame.cbs8.dto.res.PayResultResDTO; @@ -11,6 +12,9 @@ import com.hzya.frame.cbs8.service.ICbs8ExtService; import com.hzya.frame.cbs8.service.ICbs8Service; import com.hzya.frame.cbs8.util.CBSUtil; import com.hzya.frame.cbs8.util.CbsAccessToken; +import com.hzya.frame.plugin.cbs8.plugin.PayApplyPluginInitializer; +import com.hzya.frame.plugin.cbs8.plugin.PayResultPluginInitializer; +import com.hzya.frame.plugin.cbs8.plugin.TransactionDetailPluginInitializer; import com.hzya.frame.plugin.seeyonExt.plugin.SeeyonExtPluginInitializer; import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity; import com.hzya.frame.seeyon.cbs8.service.IPaymentService; @@ -45,6 +49,30 @@ public class temButtom { ICbs8ExtService cbs8ExtService; @Autowired private IPaymentService paymentService; + @Autowired + private PayApplyPluginInitializer payApplyPluginInitializer; + + @Autowired + private TransactionDetailPluginInitializer transactionDetailPluginInitializer; + @Autowired + private PayResultPluginInitializer payResultPluginInitializer; + + @Test + public void cbs8PluginTest(){ + try { + //支付申请 测试通过 + //payApplyPluginInitializer.executeBusiness(new JSONObject()); + //查询交易明细 测试通过 + //transactionDetailPluginInitializer.executeBusiness(new JSONObject()); + //交易结果查询 未测试 (OA没有日志底表,无法测试) + payResultPluginInitializer.executeBusiness(new JSONObject()); + //电子回单测试 通过apipost测试过了,可以取到cbs电子回单,只是没法上传到OA + // + + }catch (Exception e){ + e.printStackTrace(); + } + } @Test public void queryUnpaid(){ //查询待支付的列表 @@ -52,6 +80,7 @@ public class temButtom { paymentEntity.setDataSourceCode("yc-test"); try { List paymentList = paymentService.queryUnpaid(paymentEntity); + System.out.println(paymentList); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); diff --git a/service/src/main/java/com/hzya/frame/cbs8/service/impl/Cbs8ExtServiceImpl.java b/service/src/main/java/com/hzya/frame/cbs8/service/impl/Cbs8ExtServiceImpl.java index 57e49443..accce4ca 100644 --- a/service/src/main/java/com/hzya/frame/cbs8/service/impl/Cbs8ExtServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/cbs8/service/impl/Cbs8ExtServiceImpl.java @@ -2,7 +2,6 @@ package com.hzya.frame.cbs8.service.impl; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.cbs8.dto.req.*; import com.hzya.frame.cbs8.service.ICbs8ExtService; @@ -13,11 +12,10 @@ import com.hzya.frame.stringutil.StringUtil; import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity; import com.hzya.frame.web.exception.BaseSystemException; import org.apache.http.protocol.HTTP; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; - -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * @Description @@ -28,6 +26,7 @@ import java.util.Map; @Service(value = "cbs8Ext") public class Cbs8ExtServiceImpl implements ICbs8ExtService { + Logger logger = LoggerFactory.getLogger(getClass()); /** * 支付经办 * @@ -60,7 +59,8 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService { payRequestDTO.setApplyUnitCode(paymentEntity.getPayCompanyCode()); payRequestDTO.setPayAccount(null); } - String requestData = JSONObject.toJSONString(payRequestDTO); + List list = Arrays.asList(payRequestDTO); + String requestData = JSONObject.toJSONString(list); //加密 签名 encrypAndsign(entity,requestData); } @@ -117,7 +117,7 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService { @Override public SysExtensionApiEntity transactionDetailQuery(SysExtensionApiEntity entity) { String bodys = entity.getBodys(); - if (StrUtil.isEmpty(bodys)){ + if (StrUtil.isNotEmpty(bodys)){ TransactionDetailReqDTO transactionDetailReqDTO = JSONObject.parseObject(bodys,TransactionDetailReqDTO.class); String requestData = JSONObject.toJSONString(transactionDetailReqDTO); ////加密签名 @@ -205,11 +205,12 @@ public class Cbs8ExtServiceImpl implements ICbs8ExtService { private void encrypAndsign(SysExtensionApiEntity entity, String requestData) { //签名 long timestamp = System.currentTimeMillis(); + logger.info("CBS请求参数明文:{}",requestData); String sign = CBSUtil.sign(requestData,timestamp); //加密 byte[] encryptedData = CBSUtil.encrypt(requestData); Map header = headersValueOf(sign,timestamp); - entity.setBodys(Base64.getEncoder().encodeToString(encryptedData)); + entity.setByteBodys(encryptedData); entity.setHeaders(header); } } diff --git a/service/src/main/java/com/hzya/frame/cbs8/service/impl/Cbs8ServiceImpl.java b/service/src/main/java/com/hzya/frame/cbs8/service/impl/Cbs8ServiceImpl.java index a2aad83d..a3807bb3 100644 --- a/service/src/main/java/com/hzya/frame/cbs8/service/impl/Cbs8ServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/cbs8/service/impl/Cbs8ServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.map.MapBuilder; 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.JSONObject; import com.alibaba.fastjson.serializer.SerializerFeature; @@ -19,6 +20,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.util.ArrayList; import java.util.Base64; import java.util.List; import java.util.Map; @@ -44,8 +47,16 @@ public class Cbs8ServiceImpl implements ICbs8Service { String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterfaceToESB").addHeaders(headerMap).body(JSONObject.toJSONString(paymentEntity)).timeout(60000).execute().body(); //解密响应报文 String result = decryptResBody(body); - PayResponseDTO payResponseDTO = JSONObject.parseObject(result,PayResponseDTO.class); - return payResponseDTO; + if (StrUtil.isNotEmpty(result)){ + CbsResponseDTO cbsResponseDTO = JSONObject.parseObject(result, CbsResponseDTO.class); + List dataList = cbsResponseDTO.getData(); + if (CollectionUtils.isNotEmpty(dataList)){ + JSONObject o = dataList.get(0); + PayResponseDTO payResponseDTO = JSON.toJavaObject(o, PayResponseDTO.class); + return payResponseDTO; + } + } + return new PayResponseDTO(); } /** @@ -71,7 +82,7 @@ public class Cbs8ServiceImpl implements ICbs8Service { List payResultList = CBSUtil.convertJsonArrayToList(dataList, PayResultResDTO.class); return payResultList; } - return null; + return new ArrayList(); } /** @@ -138,11 +149,18 @@ public class Cbs8ServiceImpl implements ICbs8Service { int pageSize = transactionDetailReqDTO.getPageSize(); if (currentPage == 0){ currentPage = CBSUtil.DEFAULT_CURRENT_PAGE; + transactionDetailReqDTO.setCurrentPage(currentPage);//页码 } if (pageSize == 0){ pageSize = CBSUtil.DEFAULT_PAGE_SIZE; transactionDetailReqDTO.setPageSize(pageSize); } + if (StrUtil.isNotEmpty(transactionDetailReqDTO.getStartDate())){ + transactionDetailReqDTO.setStartDate(DateUtil.today()); + } + if (StrUtil.isNotEmpty(transactionDetailReqDTO.getEndDate())){ + transactionDetailReqDTO.setEndDate(DateUtil.today()); + } String params = JSON.toJSONString(transactionDetailReqDTO); Map headerMap = MapBuilder.create(true) .put("apiCode", "8000260006") @@ -165,7 +183,7 @@ public class Cbs8ServiceImpl implements ICbs8Service { } } } - return null; + return new CbsResDataDTO(); } /** @@ -196,7 +214,7 @@ public class Cbs8ServiceImpl implements ICbs8Service { return payResponseDTO; } } - return null; + return new PayResponseDTO(); } /** @@ -226,7 +244,7 @@ public class Cbs8ServiceImpl implements ICbs8Service { return agentPayResultResDTO; } } - return null; + return new AgentPayResultResDTO(); } /** @@ -239,8 +257,14 @@ public class Cbs8ServiceImpl implements ICbs8Service { JsonResultEntity resultEntity = JSONObject.parseObject(body,JsonResultEntity.class); String bodyBase64 = String.valueOf(resultEntity.getAttribute()); byte[] bodyBytes = Base64.getDecoder().decode(bodyBase64); + //这里验证一下,如果系统异常 返回的报文没加密 + String test = new String(bodyBytes); + if (JSONUtil.isTypeJSON(test)){ + return test; + } //解密报文 String result = CBSUtil.decrypt(bodyBytes); + logger.info("银行响应参数:{}",result); return result; } return null; diff --git a/service/src/main/java/com/hzya/frame/cbs8/util/SM2Util.java b/service/src/main/java/com/hzya/frame/cbs8/util/SM2Util.java index 6105fb47..46b20936 100644 --- a/service/src/main/java/com/hzya/frame/cbs8/util/SM2Util.java +++ b/service/src/main/java/com/hzya/frame/cbs8/util/SM2Util.java @@ -227,5 +227,11 @@ public class SM2Util { byte[] decode = Base64.getDecoder().decode(encodeToString); byte[] decrypt1 = decrypt("c3509b6df8bdaf84c464daa1b6fa11a8fca77b0e4a6f076ee68487f288278a85", decode); System.out.println("解密完成1"+new String(decrypt1)); + + String base64 = "eyJtc2ciOiLns7vnu5/lvILluLjvvIzor7fnqI3lkI7lho3or5UiLCJkYXRhIjpudWxsLCJjb2RlIjoiNTAwIn0="; + byte[] decode1 = Base64.getDecoder().decode(base64); + String decode2 = new String(decode1); + byte[] decryptbyte = decrypt("83BA7EC821D35F4CB31FF9A51C1EFA520FC52AF828C2337F88E91CF119B07F44", decode1); + System.out.println("解密完成"+new String(decryptbyte)); } } diff --git a/service/src/main/java/com/hzya/frame/mdm/mdmModule/service/impl/MdmModuleServiceImpl.java b/service/src/main/java/com/hzya/frame/mdm/mdmModule/service/impl/MdmModuleServiceImpl.java index c5b3d267..8a9c3ac6 100644 --- a/service/src/main/java/com/hzya/frame/mdm/mdmModule/service/impl/MdmModuleServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/mdm/mdmModule/service/impl/MdmModuleServiceImpl.java @@ -559,7 +559,7 @@ public class MdmModuleServiceImpl extends BaseService i documentRule.setShowType("1"); documentRule.setQueryType("1"); documentRule.setListType("1"); - documentRule.setViewType("1"); + documentRule.setViewType("2"); documentRule.setFiledLength("50"); documentRule.setCreate(); documentRule.setDataType("1"); @@ -2585,13 +2585,13 @@ public class MdmModuleServiceImpl extends BaseService i mdmModuleDbFiledsEntity.setMdmId(entity.getMdmId()); List mdmModuleDbEntities = mdmServiceCache.queryMdmModuleDbFileds(mdmModuleDbFiledsEntity); List list = new ArrayList<>(); - if(mdmModuleDbEntities != null && mdmModuleDbEntities.size() > 0){ - for (int i = 0; i < mdmModuleDbEntities.size(); i++) { - if(entity.getDbId().equals(mdmModuleDbEntities.get(i).getDbId()) && "1".equals(mdmModuleDbEntities.get(i).getViewType())){ - list.add(mdmModuleDbEntities.get(i)); - } - } - } + if(mdmModuleDbEntities != null && mdmModuleDbEntities.size() > 0){ + for (int i = 0; i < mdmModuleDbEntities.size(); i++) { + if(entity.getDbId().equals(mdmModuleDbEntities.get(i).getDbId()) && "1".equals(mdmModuleDbEntities.get(i).getViewType())){ + list.add(mdmModuleDbEntities.get(i)); + } + } + } return BaseResult.getSuccessMessageEntity("查询数据成功", list); } diff --git a/service/src/main/java/com/hzya/frame/mdm/service/impl/MdmServiceImpl.java b/service/src/main/java/com/hzya/frame/mdm/service/impl/MdmServiceImpl.java index 05fd7920..45d2599a 100644 --- a/service/src/main/java/com/hzya/frame/mdm/service/impl/MdmServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/mdm/service/impl/MdmServiceImpl.java @@ -1,7 +1,10 @@ package com.hzya.frame.mdm.service.impl; import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.Method; import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; @@ -49,7 +52,9 @@ import com.hzya.frame.mdm.mdmTableCodeRule.entity.MdmTableCodeRuleEntity; import com.hzya.frame.mdm.service.IMdmService; import com.hzya.frame.mdm.service.IMdmServiceCache; +import com.hzya.frame.sys.appApi.entity.AppApi; import com.hzya.frame.sys.entity.FormmainDeleteDto; +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; @@ -1329,21 +1334,24 @@ public class MdmServiceImpl implements IMdmService { //String tablename = null; JSONObject jsonObject = new JSONObject(); for (int i = 0; i < mdmModuleDbEntityList.size(); i++) { - //查询数据 - Map queryData = new HashMap<>(); - queryData.put("tableName", mdmModuleDbEntityList.get(i).getDbName());//表名 - if ("1".equals(mdmModuleDbEntityList.get(i).getDbType())) { - queryData.put("detailFlag", false);//是否明细 - queryData.put("id", entity.getId());//字段 - HashMap datas = mdmModuleDbDao.getServiceDataById(queryData); - jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), datas); - //tablename = mdmModuleDbEntityList.get(i).getDbName() + "_distribute"; - } else { - queryData.put("detailFlag", true);//是否明细 - queryData.put("id", entity.getId());//字段 - List> datas = mdmModuleDbDao.getServiceByFormmainId(queryData); - jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), datas); + if("1".equals(mdmModuleDbEntityList.get(i).getDbType()) || "2".equals(mdmModuleDbEntityList.get(i).getDbType())){ + //查询数据 + Map queryData = new HashMap<>(); + queryData.put("tableName", mdmModuleDbEntityList.get(i).getDbName());//表名 + if ("1".equals(mdmModuleDbEntityList.get(i).getDbType())) { + queryData.put("detailFlag", false);//是否明细 + queryData.put("id", entity.getId());//字段 + HashMap datas = mdmModuleDbDao.getServiceDataById(queryData); + jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), datas); + //tablename = mdmModuleDbEntityList.get(i).getDbName() + "_distribute"; + } else { + queryData.put("detailFlag", true);//是否明细 + queryData.put("id", entity.getId());//字段 + List> datas = mdmModuleDbDao.getServiceByFormmainId(queryData); + jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), datas); + } } + } //if (tablename != null && !"".equals(tablename)) { // Map queryData = new HashMap<>(); @@ -1691,11 +1699,13 @@ public class MdmServiceImpl implements IMdmService { if (mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0) { for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) { if (mdmModuleDbFiledsRuleEntities.get(i1).getFiledId().equals(mdmModuleDbFiledsEntities.get(i2).getId())) { - Map mapDetail = new HashMap<>(); - mapDetail.put("tableName", mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); - mapDetail.put("id", object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); - JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); - object.put(mdmModuleDbFiledsEntities.get(i2).getEnName(), objectDetail); + if(object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){ + Map mapDetail = new HashMap<>(); + mapDetail.put("tableName", mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); + mapDetail.put("id", object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); + JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); + object.put(mdmModuleDbFiledsEntities.get(i2).getEnName(), objectDetail); + } } } } @@ -1720,11 +1730,13 @@ public class MdmServiceImpl implements IMdmService { 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++) { - Map mapDetail = new HashMap<>(); - mapDetail.put("tableName", mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); - mapDetail.put("id", detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); - JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); - detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(), objectDetail); + if(detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){ + Map mapDetail = new HashMap<>(); + mapDetail.put("tableName", mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue()); + mapDetail.put("id", detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName())); + JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail); + detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(), objectDetail); + } } } } @@ -1736,6 +1748,7 @@ public class MdmServiceImpl implements IMdmService { object.put(mdmModuleDbEntities.get(i).getDbName(), detail); } } + //执行脚本 JSONObject groovy = new JSONObject(); JSONObject parameterJson = new JSONObject(); @@ -1758,12 +1771,11 @@ public class MdmServiceImpl implements IMdmService { JSONObject groovyStr = new JSONObject(); groovyStr.put("jsonStr", groovy); try { - //SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy); - SysExtensionApiEntity jsonResultEntity = new SysExtensionApiEntity(); - jsonResultEntity.setBodys("{\"ufinterface\":{\"billtype\":\"supplier\",\"sender\":\"OA\",\"replace\":\"Y\",\"isexchange\":\"Y\",\"account\":\"01\",\"groupcode\":\"00\"},\"bill\":{\"billhead\":{\"pk_country\":\"CN\",\"pk_group\":\"00\",\"enablestate\":\"2\",\"code\":\"01004\",\"supprop\":\"0\",\"pk_format\":\"ZH-CN\",\"pk_supplierclass\":\"S01\",\"custstate\":\"1\",\"name\":\"\",\"pk_timezone\":\"P0800\",\"taxpayerid\":\"087981489021135119\",\"pk_org\":\"003\"}}}"); - header = jsonResultEntity.getHeaders(); - querys = jsonResultEntity.getQuerys(); - bodys = jsonResultEntity.getBodys(); + 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) { return BaseResult.getFailureMessageEntity("分发脚本转换错误"); } @@ -1776,37 +1788,354 @@ public class MdmServiceImpl implements IMdmService { if (header != null) { headers.putAll(header); } + if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + //找到登陆接口 + SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); + if (null == loginApi) { + saveMdmModuleSendLogEntity("2","转发失败,认证接口不存在",dbname,object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type); + 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()) { + saveMdmModuleSendLogEntity("2","转发失败,认证接口调用失败",dbname,object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type); + return BaseResult.getFailureMessageEntity("发送错误:"+rzjsonResultEntity.getMsg()); + } + JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); + //JSONObject attritube = attritube1.getJSONObject("attribute"); + querys = getQuery(apiEntity,querys,attritube); + headers = getHeaders(apiEntity,headers,attritube); + bodys = getBodys(apiEntity,bodys,attritube); + } //组装数据发送 - JsonResultEntity jsonResultEntity = sendData(apiEntity, headers, bodys, querys); + JsonResultEntity jsonResultEntity = sendData(apiEntity, headers,bodys,querys); if (jsonResultEntity.isFlag()) { saveMdmModuleSendLogEntity("1","发送成功",dbname,object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type); - return BaseResult.getFailureMessageEntity("发送成功"); + return BaseResult.getSuccessMessageEntity("发送成功"); } else { saveMdmModuleSendLogEntity("2","转发失败",dbname,object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type); return BaseResult.getFailureMessageEntity("发送错误:"+jsonResultEntity.getMsg()); } } + 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 void saveMdmModuleSendLogEntity(String dataType,String remark,String dbname,String formmain_id, String target_app, String target_api, String source_data, String option_type) { - MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity(); - mdmModuleSendLogEntity.setTableName(dbname+"_send_log"); - mdmModuleSendLogEntity.setCreate(); - mdmModuleSendLogEntity.setId(UUIDUtils.getUUID()); - mdmModuleSendLogEntity.setSts("Y"); - 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); + + + + } + + + 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(); + } + /** + * @param querys 设置的字段属性 + * @param sendData 发送数据 + * @param loginData 认证信息 + * @return java.lang.Object + * @Author lvleigang + * @Description 设置值 + * @Date 4:14 下午 2023/8/31 + **/ + private Object getUpdata(JSONObject querys, JSONObject sendData, JSONObject loginData) { + 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); + return logValue; + } + } else if (SysEnum.FUNDAMENTAL.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//基本类型 + if (sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())) != null + && !"".equals(sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())))) {//先判断入参是否有值 + return sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())); + } else if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值,如果没有不添加 + return querys.getString(SysEnum.EXAMPLE.getValue()); + } else {//没有值直接拼接 + return ""; + } + } else if (SysEnum.COMPLEX.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//复杂类型 + if (sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())) != null + && !"".equals(sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())))) {//先判断入参是否有值 + //获取子级 + String childers = querys.getString(SysEnum.CHILDREN.getValue()); + if (childers != null && !"".equals(childers)) { + JSONArray childersObj = JSONArray.parseArray(childers); + if (childersObj != null && childersObj.size() > 0) { + JSONObject obj = new JSONObject(); + for (int i = 0; i < childersObj.size(); i++) { + JSONObject a = childersObj.getJSONObject(i); + obj.put(a.getString(SysEnum.PARAMETERNAME.getValue()), getUpdata(a, sendData.getJSONObject(querys.getString(SysEnum.PARAMETERNAME.getValue())), loginData)); + } + return obj; + } + } else { + JSONObject obj = new JSONObject(); + return obj; + } + } else {//入参没有值用实例值,如果没有不添加 + //获取子级 + String childers = querys.getString(SysEnum.CHILDREN.getValue()); + if (childers != null && !"".equals(childers)) { + JSONArray childersObj = JSONArray.parseArray(childers); + if (childersObj != null && childersObj.size() > 0) { + JSONObject obj = new JSONObject(); + for (int i = 0; i < childersObj.size(); i++) { + JSONObject a = childersObj.getJSONObject(i); + obj.put(a.getString(SysEnum.PARAMETERNAME.getValue()), getUpdata(a, new JSONObject(), loginData)); + } + return obj; + } else { //没有值直接拼接 + JSONObject obj = new JSONObject(); + return obj; + } + } else { //没有值直接拼接 + JSONObject obj = new JSONObject(); + return obj; + } + } + } else if (SysEnum.FUNDAMENTALLIST.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//基本列表 + if (sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())) != null + && !"".equals(sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())))) {//先判断入参是否有值 + JSONArray jsonArray = JSONArray.parseArray(sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue()))); + return jsonArray; + } else if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值,如果没有不添加 + if ("String".equals(querys.getString(SysEnum.CONCRETETYPE.getValue()))) { + JSONArray jsonArray = new JSONArray(); + jsonArray.add(querys.getString(SysEnum.EXAMPLE.getValue())); + return jsonArray; + } else if ("Int".equals(querys.getString(SysEnum.CONCRETETYPE.getValue()))) { + JSONArray jsonArray = new JSONArray(); + jsonArray.add(querys.getIntValue(SysEnum.EXAMPLE.getValue())); + return jsonArray; + } else if ("Long".equals(querys.getString(SysEnum.CONCRETETYPE.getValue()))) { + JSONArray jsonArray = new JSONArray(); + jsonArray.add(querys.getLongValue(SysEnum.EXAMPLE.getValue())); + return jsonArray; + } else if ("Float".equals(querys.getString(SysEnum.CONCRETETYPE.getValue()))) { + JSONArray jsonArray = new JSONArray(); + jsonArray.add(querys.getFloatValue(SysEnum.EXAMPLE.getValue())); + return jsonArray; + } else if ("Double".equals(querys.getString(SysEnum.CONCRETETYPE.getValue()))) { + JSONArray jsonArray = new JSONArray(); + jsonArray.add(querys.getDoubleValue(SysEnum.EXAMPLE.getValue())); + return jsonArray; + } else if ("Boolean".equals(querys.getString(SysEnum.CONCRETETYPE.getValue()))) { + JSONArray jsonArray = new JSONArray(); + jsonArray.add(querys.getBooleanValue(SysEnum.EXAMPLE.getValue())); + return jsonArray; + } else { + JSONArray jsonArray = new JSONArray(); + jsonArray.add(querys.getString(SysEnum.EXAMPLE.getValue())); + return jsonArray; + } + } else {//没有值直接拼接 + JSONArray jsonArray = new JSONArray(); + return jsonArray; + } + } else if (SysEnum.COMPLEXLIST.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//复杂列表 + if (sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())) != null + && !"".equals(sendData.getString(querys.getString(SysEnum.PARAMETERNAME.getValue())))) {//先判断入参是否有值 + //获取入参的数据 + //循环入参 + //循环api配置的参数 + //设置api的参数 + //返回数据 + JSONArray sendArray = sendData.getJSONArray(querys.getString(SysEnum.PARAMETERNAME.getValue())); + if(sendArray == null || sendArray.size() == 0){ + return new JSONArray(); + } + String childers = querys.getString(SysEnum.CHILDREN.getValue()); + if(childers == null || "".equals(childers)){ + return new JSONArray(); + } + JSONArray childersObj = JSONArray.parseArray(childers); + if(childersObj == null || childersObj.size() == 0){ + return new JSONArray(); + } + JSONArray obj = new JSONArray(); + for (int i = 0; i < sendArray.size(); i++) { + JSONObject sl = new JSONObject(); + for (int a = 0; a < childersObj.size(); a++) { + JSONObject b = childersObj.getJSONObject(a); + //入参没有只能取实例,实例只会有一个 + sl.put(b.getString(SysEnum.PARAMETERNAME.getValue()), getUpdata(b, sendArray.getJSONObject(i), loginData)); + } + obj.add(sl); + } + return obj; + } else {//入参没有值用实例值,如果没有不添加 + String childers = querys.getString(SysEnum.CHILDREN.getValue()); + if (childers != null && !"".equals(childers)) { + JSONArray childersObj = JSONArray.parseArray(childers); + if (childersObj != null && childersObj.size() > 0) { + JSONArray obj = new JSONArray(); + JSONObject sl = new JSONObject(); + for (int i = 0; i < childersObj.size(); i++) { + JSONObject a = childersObj.getJSONObject(i); + //入参没有只能取实例,实例只会有一个 + sl.put(a.getString(SysEnum.PARAMETERNAME.getValue()), getUpdata(a, new JSONObject(), loginData)); + } + obj.add(sl); + return obj; + } + } else { + JSONArray obj = new JSONArray(); + return obj; + } + } + } + return null; } private JsonResultEntity sendData(SysApplicationApiEntity applicationApiEntity, Map headers, String bodys, String querys) { @@ -1880,6 +2209,29 @@ public class MdmServiceImpl implements IMdmService { } } + private void saveMdmModuleSendLogEntity(String dataType,String remark,String dbname,String formmain_id, String target_app, String target_api, String source_data, String option_type) { + MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity(); + mdmModuleSendLogEntity.setTableName(dbname+"_send_log"); + mdmModuleSendLogEntity.setCreate(); + mdmModuleSendLogEntity.setId(UUIDUtils.getUUID()); + mdmModuleSendLogEntity.setSts("Y"); + 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); + } + + /** * @param mdmCode * @param saveData diff --git a/service/src/main/java/com/hzya/frame/seeyon/cbs8/entity/PaymentEntity.xml b/service/src/main/java/com/hzya/frame/seeyon/cbs8/entity/PaymentEntity.xml index bcc70052..7f107f51 100644 --- a/service/src/main/java/com/hzya/frame/seeyon/cbs8/entity/PaymentEntity.xml +++ b/service/src/main/java/com/hzya/frame/seeyon/cbs8/entity/PaymentEntity.xml @@ -64,6 +64,46 @@ personalFlag, payType + + + + SELECT + formson_0210.id as oaId, + 'formson_0210' as tableName, + COL_SUMMARY.SUBJECT as title, + unit.name as payCompany, + '差旅费报销单' as billName, + 'field0072' as payResultField, + 'field0073' as payDateField, + '' as receiptFiled, + COL_SUMMARY.id as summaryId, + formmain_0209.field0017||'-'||formson_0210.sort as referenceNum, + formmain_0209.START_DATE as startDate, + formmain_0209.FINISHEDFLAG as finishedflag, + formson_0210.field0073 as payDate, + formson_0210.field0072 as payResult, + REGEXP_REPLACE(formmain_0209.field0042, '[[:space:]]', '') as payAccount, + REGEXP_REPLACE(formmain_0209.field0041, '[[:space:]]', '') as payBankName, + formson_0210.field0031 as amount, + formmain_0209.field0038 as purpose, + formmain_0209.field0038 as cbsAbstract, + REGEXP_REPLACE(formson_0210.field0069, '[[:space:]]', '') as revAccount, + formson_0210.field0068 as revBankName, + '测试' as revAccountName, + REGEXP_REPLACE(formson_0210.field0071, '[[:space:]]', '') as cnapsCode, + item.showvalue as personalFlag, + 'OTH' as revBankType, + '10' as currency, + '202' as busType, + '' as receipt + from + formson_0210 + LEFT JOIN formmain_0209 ON formson_0210.FORMMAIN_ID = formmain_0209.id + LEFT JOIN COL_SUMMARY ON COL_SUMMARY.FORM_RECORDID = formmain_0209.id + -- LEFT JOIN CTP_AFFAIR ON CTP_AFFAIR.object_id = COL_SUMMARY.id + left join CTP_ENUM_ITEM item on item.id =formson_0210.field0070 + left join ORG_UNIT unit on unit.id =formmain_0209.field0002 + - - -- 差旅费报销单 - SELECT - formson_0210.id as oaId, -- 主表id - 'formson_0210' as tableName, -- 表名 - COL_SUMMARY.SUBJECT as title, -- 单据标题 - unit.name as payCompany, -- 付款公司 - '差旅费报销单' as billName, - 'field0072' as payResultField, -- 支付结果字段 - 'field0073' as payDateField, -- 打款日期字段 - '' as receiptFiled,-- 电子回单字段 - COL_SUMMARY.id as summaryId, - formmain_0209.field0017||'-'||formson_0210.sort as referenceNum, -- 单据编号 - formmain_0209.START_DATE as startDate, -- 单据日期 - formmain_0209.FINISHEDFLAG as finishedflag, -- 流程状态 - formson_0210.field0073 as payDate, -- 打款日期 - formson_0210.field0072 as payResult, -- 支付结果 - REGEXP_REPLACE(formmain_0209.field0042, '[[:space:]]', '') as payAccount, -- 付款账户 - REGEXP_REPLACE(formmain_0209.field0041, '[[:space:]]', '') as payBankName, -- 付款开户行 - formson_0210.field0031 as amount, -- 金额 - formmain_0209.field0038 as purpose, -- 用途 - formmain_0209.field0038 as cbsAbstract, -- 摘要 - REGEXP_REPLACE(formson_0210.field0069, '[[:space:]]', '') as revAccount, -- 收款账户 - formson_0210.field0068 as revBankName, -- 收款开户行 - '' as revAccountName, -- 收款人 - REGEXP_REPLACE(formson_0210.field0071, '[[:space:]]', '') as cnapsCode, -- 收款联行号 - item.showvalue as personalFlag,-- 公私标记 - '' as revBankType,-- 收款银行类型 - '10' as currency,-- 币种 - '' as busType,-- 业务类型 - '' as receipt -- 电子回单 - from - formson_0210 - LEFT JOIN formmain_0209 ON formson_0210.FORMMAIN_ID = formmain_0209.id - LEFT JOIN COL_SUMMARY ON COL_SUMMARY.FORM_RECORDID = formmain_0209.id - LEFT JOIN CTP_AFFAIR ON CTP_AFFAIR.object_id = COL_SUMMARY.id - left join CTP_ENUM_ITEM item on item.id =formson_0210.field0070 - left join ORG_UNIT unit on unit.id =formmain_0209.field0002 - -- left join V_USER_VIEW_ALL us on us.staffid=formmain_0209.field0024 - WHERE 1=1 - -- and formson_0210.field0031>0 - and CTP_AFFAIR.node_name = '发起者' and CTP_AFFAIR.COMPLETE_TIME is null and CTP_AFFAIR.STATE = 3 + select v.* from ( + + ) v - referenceNum = #{referenceNum} - and busType = #{busType} - and amount = #{amount} - and currency = #{currency} - and payAccount = #{payAccount} - and revAccount = #{revAccount} - and revAccountName = #{revAccountName} - and revBankType = #{revBankType} - and revBankName = #{revBankName} - and cnapsCode = #{cnapsCode} - and purpose = #{purpose} - and personalFlag = #{personalFlag} - and tableName = #{tableName} - and oaId = #{oaId} - and payCompany = #{payCompany} - and payCompanyCode = #{payCompanyCode} - and title = #{title} - and billName = #{billName} - and payResult = #{payResult} - and payBankName = #{payBankName} - and payType = #{payType} - and finishedflag = #{finishedflag} - and payResult is null - and oaId not in (select field0001 from formmain_1283) - and startDate >= #{startDate} + v.referenceNum = #{referenceNum} + and v.busType = #{busType} + and v.amount = #{amount} + and v.currency = #{currency} + and v.payAccount = #{payAccount} + and v.revAccount = #{revAccount} + and v.revAccountName = #{revAccountName} + and v.revBankType = #{revBankType} + and v.revBankName = #{revBankName} + and v.cnapsCode = #{cnapsCode} + and v.purpose = #{purpose} + and v.personalFlag = #{personalFlag} + and v.tableName = #{tableName} + and v.oaId = #{oaId} + and v.payCompany = #{payCompany} + and v.payCompanyCode = #{payCompanyCode} + and v.title = #{title} + and v.billName = #{billName} + and v.payResult = #{payResult} + and v.payBankName = #{payBankName} + and v.payType = #{payType} + and v.finishedflag = #{finishedflag} + diff --git a/service/src/main/java/com/hzya/frame/seeyon/cbs8/service/impl/CbsLogServiceImpl.java b/service/src/main/java/com/hzya/frame/seeyon/cbs8/service/impl/CbsLogServiceImpl.java index 90a83f67..0e5c4323 100644 --- a/service/src/main/java/com/hzya/frame/seeyon/cbs8/service/impl/CbsLogServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/seeyon/cbs8/service/impl/CbsLogServiceImpl.java @@ -99,4 +99,10 @@ public class CbsLogServiceImpl extends BaseService implemen } } } + + //获取xml模板 + private String getXmlTemplate(){ + // return ""; + return ""; + } } diff --git a/service/src/main/java/com/hzya/frame/seeyon/cbs8/service/impl/PaymentServiceImpl.java b/service/src/main/java/com/hzya/frame/seeyon/cbs8/service/impl/PaymentServiceImpl.java index 14f3bf99..d64ab26e 100644 --- a/service/src/main/java/com/hzya/frame/seeyon/cbs8/service/impl/PaymentServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/seeyon/cbs8/service/impl/PaymentServiceImpl.java @@ -1,7 +1,9 @@ package com.hzya.frame.seeyon.cbs8.service.impl; +import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.hzya.frame.basedao.service.impl.BaseService; +import com.hzya.frame.cbs8.util.PayState; import com.hzya.frame.seeyon.cbs8.dao.IPaymentDao; import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity; import com.hzya.frame.seeyon.cbs8.service.IPaymentService; @@ -56,7 +58,12 @@ public class PaymentServiceImpl extends BaseService implem @DS("#entity.dataSourceCode") @Override public List querySuccess(PaymentEntity entity) throws Exception { - return null; + if (null == entity){ + entity = new PaymentEntity(); + } + entity.setPayResult(PayState.payStateGetValue("g")); + List list = paymentDao.queryList(entity, "com.hzya.frame.seeyon.cbs8.entity.PaymentEntity.PaymentEntity_list_base"); + return list; } /** @@ -69,7 +76,8 @@ public class PaymentServiceImpl extends BaseService implem @DS("#entity.dataSourceCode") @Override public List queryElecIsNull(PaymentEntity entity) throws Exception { - return null; + List list = paymentDao.queryList(entity, "com.hzya.frame.seeyon.cbs8.entity.PaymentEntity.PaymentEntity_list_base_elec_isnull"); + return list; } /** @@ -83,7 +91,8 @@ public class PaymentServiceImpl extends BaseService implem @DS("#entity.dataSourceCode") @Override public List queryInPayment(PaymentEntity entity) throws Exception { - return null; + List list = paymentDao.queryList(entity, "com.hzya.frame.seeyon.cbs8.entity.PaymentEntity.PaymentEntity_list_base_in_payment"); + return list; } /** @@ -95,7 +104,13 @@ public class PaymentServiceImpl extends BaseService implem @DS("#entity.dataSourceCode") @Override public void updatePayState(PaymentEntity entity) throws Exception { - + if (null != entity + && StrUtil.isNotEmpty(entity.getTableName()) + && StrUtil.isNotEmpty(entity.getOaId()) + && StrUtil.isNotEmpty(entity.getPayDateField()) + && StrUtil.isNotEmpty(entity.getPayResultField())){ + paymentDao.update("com.hzya.frame.seeyon.cbs8.entity.PaymentEntity.PaymentEntity_update_payState",entity); + } } /** @@ -107,6 +122,11 @@ public class PaymentServiceImpl extends BaseService implem @DS("#entity.dataSourceCode") @Override public void updateElec(PaymentEntity entity) throws Exception { - + if (null != entity + && StrUtil.isNotEmpty(entity.getTableName()) + && StrUtil.isNotEmpty(entity.getOaId()) + && StrUtil.isNotEmpty(entity.getReceiptFiled())){ + paymentDao.update("com.hzya.frame.seeyon.cbs8.entity.PaymentEntity.PaymentEntity_update_electronic",entity); + } } } diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.java b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.java index 5218cabe..67456b9f 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.java +++ b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.java @@ -2,10 +2,15 @@ package com.hzya.frame.sysnew.application.api.entity; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.sys.sysenum.SysEnum; import com.hzya.frame.web.entity.BaseEntity; /** * 应用api(SysApplicationApi)实体类 @@ -14,64 +19,64 @@ import com.hzya.frame.web.entity.BaseEntity; * @since 2023-09-22 16:23:27 */ public class SysApplicationApiEntity extends BaseEntity { - - /** 接口编码 */ - private Long apiCode; - /** Api接口地址(固定系统内部外放接口地址) */ - private String apiPath; - /** 1启用2停用 */ - private String apiStatus; - /** api应用 */ - private String appId; - /** api应用名称 */ - private String appName; - /** api应用地址 **/ - private String appUrl; - /** 目录 */ - private String catalogueId; - /** 目录名称 */ - private String catalogueName; - /** api名称 */ - private String apiName; - /** api描述 */ - private String apiRemark; - /** 是否需要登录 1、是 2、否 */ - private String needLogin; - /** 认证接口 */ - private String authenticationPort; - /** 传参方式 1、query 2、data */ - private String parameterPassingMode; - /** 目标地址 */ - private String destinationAddress; - /** 请求编码 1、UTF-8 */ - private String requestCoding; - /** 请求方法 1、POST 2、GET */ - private String requestMethod; - /** 超时时间 6000 ms */ - private String timeoutPeriod; - /** 限流 6000 ms */ - private String currentLimiting; - /** Header入参 JSON */ - private String headerIn; - /** Query入参 JSON */ - private String queryIn; - /** Body 入参类型 1、Application/json */ - private String bodyInType; - /** Body 入参 JSON */ - private String bodyIn; - /** Body 出参 JSON */ - private String bodyOut; - /** bean名称 */ - private String beanName; - /** 方法名称 */ - private String funName; - /** 是否扩展api 1、启用 2、停用*/ - private String extensionApi; - /** 返回成功字段 */ - private String returnSuccessField; - /** 返回成功值*/ - private String returnSuccessValue; + /** 接口编码 */ + private Long apiCode; + /** Api接口地址(固定系统内部外放接口地址) */ + private String apiPath; + /** 1启用2停用 */ + private String apiStatus; + /** api应用 */ + private String appId; + /** api应用名称 */ + private String appName; + /** api应用地址 **/ + private String appUrl; + /** 目录 */ + private String catalogueId; + /** 目录名称 */ + private String catalogueName; + /** api名称 */ + private String apiName; + /** api描述 */ + private String apiRemark; + /** 是否需要登录 1、是 2、否 */ + private String needLogin; + /** 认证接口 */ + private String authenticationPort; + /** 传参方式 1、query 2、data */ + private String parameterPassingMode; + /** 目标地址 */ + private String destinationAddress; + /** 请求编码 1、UTF-8 */ + private String requestCoding; + /** 请求方法 1、POST 2、GET */ + private String requestMethod; + /** 超时时间 6000 ms */ + private String timeoutPeriod; + /** 限流 6000 ms */ + private String currentLimiting; + /** Header入参 JSON */ + private String headerIn; + /** Query入参 JSON */ + private String queryIn; + /** Body 入参类型 1、Application/json */ + private String bodyInType; + /** Body 入参 JSON */ + private String bodyIn; + /** Body 出参 JSON */ + private String bodyOut; + /** bean名称 */ + private String beanName; + /** 方法名称 */ + private String funName; + /** 是否扩展api 1、启用 2、停用*/ + private String extensionApi; + + /** 返回成功字段 */ + private String returnSuccessField; + /** 返回成功值*/ + private String returnSuccessValue; /** 返回描述字段*/ private String returnMsg; @@ -307,37 +312,9 @@ public class SysApplicationApiEntity extends BaseEntity { this.appUrl = appUrl; } - public List getHeaderInValue() { - List jsonObjects = new ArrayList<>(); - if(headerIn != null && !"".equals(headerIn)){ - JSONArray headers = JSONArray.parseArray(headerIn); - if(headers != null && headers.size() > 0){ - for (int i = 0; i < headers.size(); i++) { - JSONObject object = new JSONObject(); - object.put(headers.getJSONObject(i).getString("parameterName"),headers.getJSONObject(i).getString("example")); - jsonObjects.add(object); - } - } - } - return jsonObjects; - } - public String getQueryInValue() { - StringBuffer jsonObjects = new StringBuffer(); - if(queryIn != null && !"".equals(queryIn)){ - JSONArray querys = JSONArray.parseArray(queryIn); - if(querys != null && querys.size() > 0){ - for (int i = 0; i < querys.size(); i++) { - if(i != 0){ - jsonObjects.append("&"); - } - jsonObjects.append(querys.getJSONObject(i).getString("parameterName")); - jsonObjects.append("="); - jsonObjects.append(querys.getJSONObject(i).getString("example")); - } - } - } - return jsonObjects.toString(); - } + + + } diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/service/impl/SysApplicationServiceImpl.java b/service/src/main/java/com/hzya/frame/sysnew/application/service/impl/SysApplicationServiceImpl.java index ad3ba58b..fe49d95d 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/service/impl/SysApplicationServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/sysnew/application/service/impl/SysApplicationServiceImpl.java @@ -1770,6 +1770,7 @@ public class SysApplicationServiceImpl extends BaseService>>>>>>>>>>>>>>>>>>>>>>>>>>>"); sysExtensionApiEntity = (SysExtensionApiEntity) m.invoke(object, sysExtensionApiEntity); logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + break; } catch (Exception e) { logger.error("invokeException{}", e.getMessage()); return BaseResult.getFailureMessageEntity("内部方法执行错误,请联系管理员"); @@ -2051,11 +2052,11 @@ public class SysApplicationServiceImpl extends BaseService oldheaderMap,Map headerMap, - Map headers, - String oldquerys, String querys, - String body, boolean flag,String msg) { + String oldbodys,String bodys, + Map oldheaderMap,Map headerMap, + Map headers, + String oldquerys, String querys, + String body, boolean flag,String msg) { SysMessageManageLogEntity sysMessageManageLogEntity = new SysMessageManageLogEntity(); //messageManageId 消息主表主键 //theme 消息主题 @@ -2378,10 +2379,10 @@ public class SysApplicationServiceImpl extends BaseService 0){ - return BaseResult.getFailureMessageEntity("脚本已经被使用,请先取消关联"); - } + Integer a = mdmModuleDistributeDao.queryCountUse(mdmModuleDistributeEntity); + if(a > 0){ + return BaseResult.getFailureMessageEntity("脚本已经被使用,请先取消关联"); + } entity.setUpdate(); sysApplicationScriptDao.logicRemoveMultiCondition(entity); return BaseResult.getSuccessMessageEntity("删除脚本成功"); diff --git a/service/src/main/java/com/hzya/frame/sysnew/grovy/service/IGroovyIntegrationService.java b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/IGroovyIntegrationService.java index ae475ac4..2d9d72f9 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/grovy/service/IGroovyIntegrationService.java +++ b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/IGroovyIntegrationService.java @@ -22,5 +22,5 @@ public interface IGroovyIntegrationService { * @param jsonObject 请求参数对象 * @return com.hzya.frame.web.entity.JsonResultEntity **/ - SysExtensionApiEntity groovyScriptExecution(JSONObject jsonObject); + Object groovyScriptExecution(JSONObject jsonObject); } diff --git a/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java index 293d81c6..3e3b85e7 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java +++ b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java @@ -25,39 +25,84 @@ public class GroovyIntegrationServiceImpl implements IGroovyIntegrationService { @Override - public SysExtensionApiEntity groovyScriptExecution(JSONObject jsonObject) { + public Object groovyScriptExecution(JSONObject jsonObject) { Object object = GroovyUtil.execute(jsonObject); - return new SysExtensionApiEntity(); + return object; } public static void main(String[] args) { - java.lang.String str = "{\"project_org\":\"\",\"modify_time\":\"2024-06-17 16:52:34\",\"project_duty_dept\":null,\"project_name\":\"凯伍德组织档案\",\"document_rule_num\":1,\"add_status\":\"0\",\"delete_status\":\"1\",\"project_dutier\":\"\",\"id\":\"fb12734c8267488b96833633e68a7abc\",\"data_status\":\"F\",\"modify_user_id\":\"c796fd9ba4c9f5ff3cc2fa41a040e443\",\"sorts\":1,\"project_memo\":\"\",\"document_rule\":\"XM-2024-06-17-00001\",\"create_user_id\":\"c796fd9ba4c9f5ff3cc2fa41a040e443\",\"create_time\":\"2024-06-17 16:42:18\",\"company_id\":null,\"project_sh_name\":\"\",\"project_code\":\"01004\",\"project_currtype\":\"\",\"update_status\":\"0\",\"sts\":\"Y\",\"org_id\":\"0\",\"project_parentpro\":\"\",\"project_bill_type\":\"\"}"; - + java.lang.String str = "{\"data\":{\"pk_group\":\"00\",\"enablestate\":\"2\",\"code\":\"20240621001\",\"modify_time\":1718935555000,\"document_rule_num\":2,\"mdm_customer_bank\":[],\"add_status\":\"0\",\"custprop\":\"0\",\"delete_status\":\"1\",\"custstate\":\"1\",\"id\":\"d3d20ea680dc4bffaa7e5bf84764d62a\",\"data_status\":\"Y\",\"modify_user_id\":\"1\",\"sorts\":24,\"document_rule\":\"KH-2024-06-21-00002\",\"create_user_id\":\"1\",\"create_time\":1718935555000,\"company_id\":\"Y\",\"pk_country\":\"CN\",\"update_status\":\"1\",\"sts\":\"Y\",\"pk_custclass\":\"K01\",\"org_id\":\"Y\",\"name\":\"测试下发客户\",\"taxpayerid\":\"087982419238904359\"},\"query\":\"[]\",\"header\":\"[{\\\"parameterType\\\":\\\"fundamental\\\",\\\"length\\\":\\\"500\\\",\\\"index\\\":0,\\\"concreteType\\\":\\\"String\\\",\\\"description\\\":\\\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA87rrNR\\\",\\\"id\\\":\\\"421b73f0-5562-4bfe-b770-c8aca8878bfd\\\",\\\"parameterName\\\":\\\"pubKey\\\",\\\"required\\\":true,\\\"example\\\":\\\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA87rrNREgMNeOEOwlvM2iqqEfshDadRHziDSB2PbRnoMqSv1nGr3XBlZuseNj5HmxDEkLhOdfyw0yjzoz3wK7XhFpeN4Iyf7NT7hps5jAQMEpnul9Qwmj5qUr/eK5SaO9H8n7sh9BvCdrX9oRUh+U2/ceA3O+y/MUHk5DRvSadc8FhpqbOaNBbAzPnyYAwpVUPvaJ90jcGN1ZG99HR1GEzC+Cn9s6vgt7dYL6ysMs36bSP47xraDSxpfr0CLwa6JV/9KjLIeqL1ZaMtK0CJ1zJGCBA6O6kgxeE9Ul7q2lSS6mPAEJ78izaTYsrjhLpKT+eTtFBOLFbiCrbLp8tVE5kwIDAQAB\\\"},{\\\"parameterType\\\":\\\"fundamental\\\",\\\"length\\\":\\\"100\\\",\\\"index\\\":1,\\\"concreteType\\\":\\\"String\\\",\\\"description\\\":\\\"OA\\\",\\\"id\\\":\\\"5659424d-261d-43ed-9fff-657bd15c7a64\\\",\\\"parameterName\\\":\\\"client_id\\\",\\\"required\\\":true,\\\"example\\\":\\\"OA\\\"},{\\\"parameterType\\\":\\\"authport\\\",\\\"length\\\":\\\"100\\\",\\\"index\\\":2,\\\"concreteType\\\":\\\"String\\\",\\\"id\\\":\\\"d2c4477e-a0bb-4daa-97b4-3cf0b8445001\\\",\\\"parameterName\\\":\\\"access_token\\\",\\\"required\\\":true,\\\"example\\\":[\\\"attribute\\\",\\\"data\\\",\\\"access_token\\\"]}]\",\"body\":\"[{\\\"index\\\":0,\\\"id\\\":\\\"5ac44a3b-c0d5-4ae9-aec6-af6c4c8f59cc\\\",\\\"parameterName\\\":\\\"body\\\",\\\"first\\\":true}]\"}"; + java.lang.String str1 = "com.alibaba.fastjson.JSONObject returnObject = new com.alibaba.fastjson.JSONObject();\n" + + " com.alibaba.fastjson.JSONObject bodys = new com.alibaba.fastjson.JSONObject();\n" + + "\n" + + " com.alibaba.fastjson.JSONObject reqData = com.alibaba.fastjson.JSON.parseObject(jsonStr);\n" + + " com.alibaba.fastjson.JSONObject data = reqData.getJSONObject(\"data\");\n" + + " com.alibaba.fastjson.JSONObject ufinterfaceObject = new com.alibaba.fastjson.JSONObject();\n" + + " ufinterfaceObject.put(\"billtype\", \"customer\");\n" + + " ufinterfaceObject.put(\"isexchange\", \"Y\");\n" + + " ufinterfaceObject.put(\"replace\", \"Y\");\n" + + " ufinterfaceObject.put(\"sender\", \"OA\");\n" + + " ufinterfaceObject.put(\"account\", \"01\");\n" + + " ufinterfaceObject.put(\"groupcode\", \"00\");\n" + + " com.alibaba.fastjson.JSONObject billObject = new com.alibaba.fastjson.JSONObject();\n" + + " com.alibaba.fastjson.JSONObject billheadObject = new com.alibaba.fastjson.JSONObject();\n" + + " billheadObject.put(\"code\", data.get(\"code\"));\n" + + " billheadObject.put(\"custprop\", data.get(\"custprop\"));\n" + + " billheadObject.put(\"custstate\", data.get(\"custstate\"));\n" + + " billheadObject.put(\"pk_custclass\", data.get(\"pk_custclass\"));\n" + + " billheadObject.put(\"pk_country\", data.get(\"pk_country\"));\n" + + " billheadObject.put(\"pk_timezone\", \"P0800\");\n" + + " billheadObject.put(\"pk_format\", \"ZH-CN\");\n" + + " billheadObject.put(\"enablestate\", data.get(\"enablestate\"));\n" + + " billheadObject.put(\"name\", data.get(\"name\"));\n" + + " billheadObject.put(\"pk_group\", data.get(\"pk_group\"));\n" + + " billheadObject.put(\"pk_org\", data.get(\"pk_org\"));\n" + + " billheadObject.put(\"taxpayerid\", data.get(\"taxpayerid\"));\n" + + " billObject.put(\"billhead\", billheadObject);\n" + + " ufinterfaceObject.put(\"bill\", billObject);\n" + + " bodys.put(\"ufinterface\", ufinterfaceObject);\n" + + " returnObject.put(\"bodys\",bodys.toJSONString());\n" + + " return returnObject.toJSONString();".trim(); + String newString =str1.replaceAll("\\s+", ""); A88772 s = new A88772(); - s .execute(str); + s.execute(str); } + static class A88772 { - String execute(String jsonStr) { - com.alibaba.fastjson.JSONObject reqData = com.alibaba.fastjson.JSON.parseObject(jsonStr); + String execute(String jsonStr) { com.alibaba.fastjson.JSONObject returnObject = new com.alibaba.fastjson.JSONObject(); + com.alibaba.fastjson.JSONObject bodys = new com.alibaba.fastjson.JSONObject(); + + com.alibaba.fastjson.JSONObject reqData = com.alibaba.fastjson.JSON.parseObject(jsonStr); + com.alibaba.fastjson.JSONObject data = reqData.getJSONObject("data"); com.alibaba.fastjson.JSONObject ufinterfaceObject = new com.alibaba.fastjson.JSONObject(); - ufinterfaceObject.put("billtype", "supplier"); ufinterfaceObject.put("isexchange", "Y"); - ufinterfaceObject.put("replace", "Y"); ufinterfaceObject.put("sender", "OA"); - ufinterfaceObject.put("account", "01"); ufinterfaceObject.put("groupcode", "00"); + ufinterfaceObject.put("billtype", "customer"); + ufinterfaceObject.put("isexchange", "Y"); + ufinterfaceObject.put("replace", "Y"); + ufinterfaceObject.put("sender", "OA"); + ufinterfaceObject.put("account", "01"); + ufinterfaceObject.put("groupcode", "00"); com.alibaba.fastjson.JSONObject billObject = new com.alibaba.fastjson.JSONObject(); com.alibaba.fastjson.JSONObject billheadObject = new com.alibaba.fastjson.JSONObject(); - billheadObject.put("code", reqData.get("project_code")); billheadObject.put("supprop", "0"); - billheadObject.put("custstate", "1"); billheadObject.put("pk_supplierclass", "S01"); - billheadObject.put("pk_country", "CN"); billheadObject.put("pk_timezone", "P0800"); - billheadObject.put("pk_format", "ZH-CN"); billheadObject.put("enablestate", "2"); - billheadObject.put("name", reqData.get("project_sh_name")); billheadObject.put("pk_group", "00"); - billheadObject.put("pk_org", "003"); billheadObject.put("taxpayerid", "087981489021135119"); - returnObject.put("ufinterface",ufinterfaceObject); billObject.put("billhead", billheadObject); returnObject.put("bill",billObject); - System.out.println( returnObject.toJSONString()); + billheadObject.put("code", data.get("code")); + billheadObject.put("custprop", data.get("custprop")); + billheadObject.put("custstate", data.get("custstate")); + billheadObject.put("pk_custclass", data.get("pk_custclass")); + billheadObject.put("pk_country", data.get("pk_country")); + billheadObject.put("pk_timezone", "P0800"); + billheadObject.put("pk_format", "ZH-CN"); + billheadObject.put("enablestate", data.get("enablestate")); + billheadObject.put("name", data.get("name")); + billheadObject.put("pk_group", data.get("pk_group")); + billheadObject.put("pk_org", data.get("pk_org")); + billheadObject.put("taxpayerid", data.get("taxpayerid")); + billObject.put("billhead", billheadObject); + ufinterfaceObject.put("bill", billObject); + bodys.put("ufinterface", ufinterfaceObject); + returnObject.put("bodys",bodys.toJSONString()); return returnObject.toJSONString(); } } - }