Merge branch 'yuecheng-project' of http://hzya.ufyct.com:9015/root/kangarooDataCenterV3 into yuecheng-project

This commit is contained in:
xiang2lin 2024-07-02 13:46:34 +08:00
commit 9fd9436d94
21 changed files with 896 additions and 274 deletions

View File

@ -1,5 +1,6 @@
package com.hzya.frame.plugin.mdmDistribute.plugin;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
@ -24,7 +25,6 @@ import com.hzya.frame.sysnew.application.api.dao.ISysApplicationApiDao;
import com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity;
import com.hzya.frame.sysnew.application.dao.ISysApplicationDao;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.sysnew.application.script.dao.ISysApplicationScriptDao;
import com.hzya.frame.sysnew.application.script.entity.SysApplicationScriptEntity;
import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService;
@ -47,11 +47,7 @@ import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 主数据模版(MdmModule)表服务接口
@ -106,7 +102,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
@Override
public String getPluginName() {
return "MdmModulePlugin插件";
return "主数据下发";
}
@Override
@ -252,6 +248,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
map.put("tableName",mdmModuleDbEntities.get(i).getDbName());
map.put("documentRule",documentRule);
object = mdmModuleDao.queryMdmST(map);
object = toLowerCaseKeys(object);
if(object.getString("id") == null || "".equals(object.getString("id")) ){
taskDetailEntity.setResult("当前数据不存在");
taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity);
@ -263,6 +260,8 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
checkData.put("documentRule",documentRule);
checkData.put("mdmModuleDistributeDetailEntities",mdmModuleDistributeDetailEntities);
JSONObject object1 = mdmModuleDao.queryMdmST(checkData);
object1 = toLowerCaseKeys(object1);
if(object1.getString("id") == null || "".equals(object1.getString("id")) ){
taskDetailEntity.setResult("当前数据不符合规则不发送");
taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity);
@ -283,6 +282,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
String[] idss = ids.split(",");
mapDetail.put("id", idss[idss.length-1]);
JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail);
objectDetail = toLowerCaseKeys(objectDetail);
object.put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail);
}
}
@ -296,10 +296,12 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
for (int i = 0; i < mdmModuleDbEntities.size(); i++) {
if("2".equals(mdmModuleDbEntities.get(i).getDbType())){
Map<String,String> map = new HashMap<>();
Map<String,Object> map = new HashMap<>();
map.put("tableName",mdmModuleDbEntities.get(i).getDbName());
map.put("formmainId",object.getString("id"));
List<JSONObject> detail = mdmModuleDao.queryMdmSTDetail(map);
detail = toLowerCaseKeys(detail);
//查看主表是否有字段是关联的
if(detail != null && detail.size() > 0){
if(mdmModuleDbFiledsRuleEntities != null && mdmModuleDbFiledsRuleEntities.size() > 0){
@ -317,6 +319,8 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
mapDetail.put("id", idss[idss.length-1]);
JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail);
objectDetail = toLowerCaseKeys(objectDetail);
detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail);
}
@ -395,8 +399,10 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
return BaseResult.getFailureMessageEntity("发送错误:"+rzjsonResultEntity.getMsg());
}
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
logger.info("认证接口返回信息:"+ attritube.toJSONString());
querys = getQuery(apiEntity,querys,attritube);
headers = getHeaders(apiEntity,headers,attritube);
bodys = getBodys(apiEntity,bodys,attritube);
}
//组装数据发送
@ -422,6 +428,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
}
//查询下发的配置 没有直接跳过
for (int i = 0; i < mdmModuleEntities.size(); i++) {
Long mdmCode = mdmModuleEntities.get(i).getMdmCode();
MdmModuleDistributeEntity queryMdmModuleDistributeEntity = new MdmModuleDistributeEntity();
queryMdmModuleDistributeEntity.setMdmId(mdmModuleEntities.get(i).getId());
queryMdmModuleDistributeEntity.setEnabledType("1");
@ -451,11 +458,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities = mdmModuleDbFiledsRuleDao.queryBase(queryFildRule);
//新增
doAdd(mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
doAdd(mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//修改
doUpdate(mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//doUpdate(mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//删除
doDelete(mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//doDelete(mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
}
@ -469,7 +476,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
return BaseResult.getSuccessMessageEntity("执行成功");
}
private void doDelete(List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities, List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities, List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities) {
private void doDelete(Long mainCode,List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities, List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities, List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities) throws Exception {
//查询一千条数据
String mainDb = null;
List<JSONObject> objects = new ArrayList<>();
@ -485,8 +492,9 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
map1.put("tableName",mainDb);
map1.put("dataStatus", "N");
map1.put("deleteStatus", "0");
map1.put("size", 1000);
map1.put("size", 10);
objects = mdmModuleDao.queryMdmSTs(map1);
objects = toLowerCaseKeys(objects);
if(objects == null || objects.size() == 0){
return;
@ -505,26 +513,28 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities);
map.put("ids", objects);
List<JSONObject> doObjects = mdmModuleDao.queryMdmSTs(map);
doObjects = toLowerCaseKeys(doObjects);
if(doObjects == null || doObjects.size() == 0){
continue;
}
if(mdmModuleDistributeEntities.get(i1).getDeleteApi() == null || "".equals(mdmModuleDistributeEntities.get(i1).getDeleteApi())){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","删除接口未设置",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"3");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","删除接口未设置",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"3");
}
return ;
}
SysApplicationApiEntity apiEntity = sysApplicationApiDao.get(mdmModuleDistributeEntities.get(i1).getDeleteApi());
if(apiEntity == null || apiEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","删除接口未找到",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"3");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","删除接口未找到",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"3");
}
return ;
}
SysApplicationEntity sysApplicationEntity = sysApplicationDao.get(apiEntity.getAppId());
if(sysApplicationEntity == null || sysApplicationEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","删除接口的应用未找到",mainDb,objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","删除接口的应用未找到",mainDb,objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
}
return ;
}
@ -534,7 +544,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getDeleteScript());
if(scriptEntity == null || scriptEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","删除接口脚本未找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","删除接口脚本未找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
}
return ;
}
@ -581,7 +591,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
continue;
}
}
@ -597,7 +607,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
//找到登陆接口
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
String rzquerys = getQuery(loginApi,null,null);
@ -610,7 +620,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
@ -622,11 +632,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
if(jsonResultEntity.isFlag()){
//保存日志
saveMdmModuleSendLogEntity("1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
continue;
}else {
//保存日志
saveMdmModuleSendLogEntity("2","转发失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
continue;
}
}
@ -644,7 +654,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
}
}
private void doUpdate(List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities, List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities, List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities) {
private void doUpdate(Long mainCode,List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities, List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities, List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities) throws Exception {
//查询一千条数据
String mainDb = null;
List<JSONObject> objects = new ArrayList<>();
@ -660,8 +670,9 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
map1.put("tableName",mainDb);
//map1.put("dataStatus", "F");
map1.put("updateStatus", "0");
map1.put("size", 1000);
map1.put("size", 10);
objects = mdmModuleDao.queryMdmSTs(map1);
objects = toLowerCaseKeys(objects);
if(objects == null || objects.size() == 0){
return;
@ -680,26 +691,28 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities);
map.put("ids", objects);
List<JSONObject> doObjects = mdmModuleDao.queryMdmSTs(map);
doObjects = toLowerCaseKeys(doObjects);
if(doObjects == null || doObjects.size() == 0){
continue;
}
if(mdmModuleDistributeEntities.get(i1).getUpdateApi() == null || "".equals(mdmModuleDistributeEntities.get(i1).getUpdateApi())){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","修改接口未设置",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"2");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","修改接口未设置",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"2");
}
return ;
}
SysApplicationApiEntity apiEntity = sysApplicationApiDao.get(mdmModuleDistributeEntities.get(i1).getUpdateApi());
if(apiEntity == null || apiEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","修改接口未查找到",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"2");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","修改接口未查找到",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"2");
}
return ;
}
SysApplicationEntity sysApplicationEntity = sysApplicationDao.get(apiEntity.getAppId());
if(sysApplicationEntity == null || sysApplicationEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","应用未查找到",mainDb,objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","应用未查找到",mainDb,objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
}
return ;
}
@ -709,7 +722,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getUpdateScript());
if(scriptEntity == null || scriptEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","脚本未查找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本未查找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
}
return ;
}
@ -747,7 +760,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
continue;
}
}
@ -763,7 +776,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
//找到登陆接口
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
String rzquerys = getQuery(loginApi,null,null);
@ -776,7 +789,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
@ -788,11 +801,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
if(jsonResultEntity.isFlag()){
//保存日志
saveMdmModuleSendLogEntity("1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
continue;
}else {
//保存日志
saveMdmModuleSendLogEntity("2","转发失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
continue;
}
}
@ -817,7 +830,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
* @param mdmModuleDistributeEntities
* @return void
**/
private void doAdd(List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities,List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities,List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities ) {
private void doAdd(Long mainCode,List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities,List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities,List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities ) throws Exception {
//查询一千条数据
String mainDb = null;
List<JSONObject> objects = new ArrayList<>();
@ -833,8 +846,9 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
map1.put("tableName",mainDb);
//map1.put("dataStatus", "Y");
map1.put("addStatus", "0");
map1.put("size", 1000);
map1.put("size", 10);
objects = mdmModuleDao.queryMdmSTs(map1);
objects = toLowerCaseKeys(objects);
if(objects == null || objects.size() == 0){
return;
@ -853,26 +867,29 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities);
map.put("ids", objects);
List<JSONObject> doObjects = mdmModuleDao.queryMdmSTs(map);
doObjects = toLowerCaseKeys(doObjects);
if(doObjects == null || doObjects.size() == 0){
continue;
}
if(mdmModuleDistributeEntities.get(i1).getAddApi() == null || "".equals(mdmModuleDistributeEntities.get(i1).getAddApi())){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","新增接口未设置",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"1");
//taskLivingDetailsService.saveLogToSuccess();
saveMdmModuleSendLogEntity( mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","新增接口未设置",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"1");
}
return ;
}
SysApplicationApiEntity apiEntity = sysApplicationApiDao.get(mdmModuleDistributeEntities.get(i1).getAddApi());
if(apiEntity == null || apiEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","新增接口未查找到",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"1");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","新增接口未查找到",mainDb,objects.get(i).getString("id"),null,null,doObjects.get(i).toJSONString(),"1");
}
return ;
}
SysApplicationEntity sysApplicationEntity = sysApplicationDao.get(apiEntity.getAppId());
if(sysApplicationEntity == null || sysApplicationEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","应用未查找到",mainDb,objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","应用未查找到",mainDb,objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
}
return ;
}
@ -882,7 +899,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getAddScript());
if(scriptEntity == null || scriptEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity("2","脚本未查找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本未查找到",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
}
return ;
}
@ -929,7 +946,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","脚本处理失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
}
@ -945,7 +962,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
//找到登陆接口
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
String rzquerys = getQuery(loginApi,null,null);
@ -958,7 +975,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
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");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
@ -971,11 +988,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
if(jsonResultEntity.isFlag()){
//保存日志
saveMdmModuleSendLogEntity("1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}else {
//保存日志
saveMdmModuleSendLogEntity("2","转发失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
}
@ -992,7 +1009,7 @@ 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) {
private void saveMdmModuleSendLogEntity(Long mdmCode,String distributeId,String dataType,String remark,String dbname,String formmain_id, String target_app, String target_api, String source_data, String option_type) throws Exception {
MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity();
mdmModuleSendLogEntity.setTableName(dbname+"_send_log");
mdmModuleSendLogEntity.setId(UUIDUtils.getUUID());
@ -1011,16 +1028,47 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
mdmModuleSendLogEntity.setDataType(dataType);
mdmModuleSendLogEntity.setRemark(remark);
mdmModuleSendLogDao.save(mdmModuleSendLogEntity);
JSONObject jsonObject = JSONObject.parseObject(source_data);
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
integrationTaskLivingDetailsEntity.setSts("Y");
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
integrationTaskLivingDetailsEntity.setModify_user_id("1");
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
integrationTaskLivingDetailsEntity.setModify_time(new Date());
integrationTaskLivingDetailsEntity.setOrg_id("0");
integrationTaskLivingDetailsEntity.setCompanyId("0");
JSONObject aa = new JSONObject();
aa.put("mdmCode",mdmCode);//主数据编码
aa.put("documentRule",jsonObject.getString("document_rule"));//行数据的单据规则编码
aa.put("distributeId",distributeId);//发送表id
aa.put("type",option_type);//发送类型1新增2修改3删除
integrationTaskLivingDetailsEntity.setRootAppPk(aa.toJSONString());
integrationTaskLivingDetailsEntity.setRootAppBill(jsonObject.getString("document_rule"));
integrationTaskLivingDetailsEntity.setPluginId("MdmModulePlugin");
integrationTaskLivingDetailsEntity.setRootAppNewData(source_data);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(remark);
if("1".equals(dataType)){
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
}else {
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
}
}
private JSONObject getDetailData(List<MdmModuleDbEntity> mdmModuleDbEntities, JSONObject object, List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities,List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities) {
for (int i = 0; i < mdmModuleDbEntities.size(); i++) {
if("2".equals(mdmModuleDbEntities.get(i).getDbType())){
Map<String,String> map = new HashMap<>();
Map<String,Object> map = new HashMap<>();
map.put("tableName",mdmModuleDbEntities.get(i).getDbName());
map.put("formmainId",object.getString("id"));
List<JSONObject> detail = mdmModuleDao.queryMdmSTDetail(map);
detail = toLowerCaseKeys(detail);
//查看主表是否有字段是关联的
if(detail != null && detail.size() > 0){
if(mdmModuleDbFiledsRuleEntities != null && mdmModuleDbFiledsRuleEntities.size() > 0){
@ -1037,6 +1085,8 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
String[] idss = ids.split(",");
mapDetail.put("id", idss[idss.length-1]);
JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail);
objectDetail = toLowerCaseKeys(objectDetail);
detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail);
}
}
@ -1280,4 +1330,23 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
}
return sendData.toString();
}
public JSONObject toLowerCaseKeys(JSONObject jsonObject) {
JSONObject lowerCaseJson = new JSONObject();
if (jsonObject != null) {
for (String key : jsonObject.keySet()) {
Object value = jsonObject.get(key);
lowerCaseJson.put(key.toLowerCase(), value);
}
}
return lowerCaseJson;
}
public List<JSONObject> toLowerCaseKeys(List<JSONObject> list) {
List<JSONObject> jsonObjects = new ArrayList<>();
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
jsonObjects.add(toLowerCaseKeys(list.get(i)));
}
}
return jsonObjects;
}
}

View File

@ -22,12 +22,15 @@ spring:
# 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
password: 62e4295b615a30dbf3b8ee96f41c820b
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
# 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
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
savefile:
# 文件保存路径
path: /Users/apple/Desktop/log/local

View File

@ -23,28 +23,57 @@
#savefile:
# # 文件保存路径
# path: /zt/file
#公司mysql
#ax:
# url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
#logging:
# #日志级别 指定目录级别warn
# level:
# root: info
# encodings: UTF-8
# file:
# # 日志保存路径
# path: /home/webservice/zt/log
#spring:
# datasource:
# dynamic:
# datasource:
# master:
# 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可省略此配置
#savefile:
# # 文件保存路径
# path: /home/webservice/zt/file
#公司服务器达梦
logging:
#日志级别 指定目录级别warn
#日志级别 指定目录级别
level:
root: info
encodings: UTF-8
file:
# 日志保存路径
path: /home/webservice/zt/log
path: /zt/log
spring:
flyway:
# 启动flyway migration, 默认为true
enabled: false
datasource:
dynamic:
druid:
filters: stat,log4j2
datasource:
master:
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
savefile:
# 文件保存路径
path: /home/webservice/zt/file
path: /zt/file
cbs8:
appId: 1P4AGrpz
appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a

View File

@ -655,13 +655,26 @@ public class GeneralServiceImpl implements GeneralService {
List<HashMap<String, Object>> list = null;
try {
list = baseDaoUtilImpl.selectWhereList(tablename, defaultOrder, whereCriteria);
convertKeysToLowerCase(list);
return BaseResult.getSuccessMessageEntity("查询成功", list);
} catch (Exception e) {
log.error("defaultselectList{}", e.getMessage());
return BaseResult.getFailureMessageEntity("查询失败");
}
}
//强制转换数据库字段为小写,出问题在说
public void convertKeysToLowerCase(List<HashMap<String, Object>> list) {
if(list != null && list.size() > 0){
for (HashMap<String, Object> map : list) {
HashMap<String, Object> lowerCaseMap = new HashMap<>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
lowerCaseMap.put(entry.getKey().toLowerCase(), entry.getValue());
}
map.clear(); // 清空原来的Map避免重复存储
map.putAll(lowerCaseMap); // 将转换后的Map全部放回原位
}
}
}
/**
* @param jsonObject
* @return com.hzya.frame.web.entity.JsonResultEntity

View File

@ -20,6 +20,8 @@ public class MdmQuery {
private List<String> returnField;
//明细表查询条件
private List<MdmQuery> detailQueryCondition;
//小写字段
private List<String> fields;
public Integer getPageNum() {
return pageNum;
@ -76,4 +78,12 @@ public class MdmQuery {
public void setMdmCode(Long mdmCode) {
this.mdmCode = mdmCode;
}
public List<String> getFields() {
return fields;
}
public void setFields(List<String> fields) {
this.fields = fields;
}
}

View File

@ -50,10 +50,19 @@ public interface IMdmModuleDao extends IBaseDao<MdmModuleEntity, String> {
JSONObject queryMdmST(Map<String, Object> maps);
List<JSONObject> queryMdmSTDetail(Map<String, String> maps);
List<JSONObject> queryMdmSTDetail(Map<String, Object> maps);
List<JSONObject> queryMdmSTs(Map<String, Object> map);
void updateMdmSTs(Map<String, Object> updateMap);
/****
* 查询主数据字段
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2024-06-27 16:26
* @param
* @return java.util.List<java.lang.Object>
**/
List<String> queryMdMFields(Map<String, Object> maps);
}

View File

@ -1,15 +1,15 @@
package com.hzya.frame.mdm.mdmModule.dao.impl;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.mdm.entity.MdmDataDto;
import com.hzya.frame.mdm.entity.MdmDto;
import com.hzya.frame.mdm.entity.MdmQuery;
import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity;
import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao;
import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity;
import com.hzya.frame.mdm.mdmModuleDbFileds.entity.MdmModuleDbFiledsEntity;
import com.hzya.frame.sys.entity.FormmainDeleteDto;
import org.springframework.stereotype.Repository;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import java.util.HashMap;
import java.util.List;
@ -114,6 +114,10 @@ public class MdmModuleDaoImpl extends MybatisGenericDao<MdmModuleEntity, String>
@Override
public List<HashMap<String, Object>> queryMdmShowData(MdmQuery entity) {
//HashMap<String, Object> maps = new HashMap<>();
//maps.put("tableName",entity.getTableName());
//List<String> fields = queryMdMFields(maps);
//entity.setFields(fields);
List<HashMap<String, Object>> o = (List<HashMap<String, Object>>) super.selectList(getSqlIdPrifx() + "queryMdmShowData", entity);
return o;
}
@ -151,6 +155,8 @@ public class MdmModuleDaoImpl extends MybatisGenericDao<MdmModuleEntity, String>
@Override
public JSONObject queryMdmST(Map<String, Object> maps) {
//List<String> fields = queryMdMFields(maps);
//maps.put("fields",fields);
JSONObject o = (JSONObject) super.selectOne(getSqlIdPrifx() + "queryMdmST", maps);
return o;
}
@ -166,7 +172,15 @@ public class MdmModuleDaoImpl extends MybatisGenericDao<MdmModuleEntity, String>
}
@Override
public List<JSONObject> queryMdmSTDetail(Map<String, String> maps) {
public List<String> queryMdMFields(Map<String, Object> maps) {
List<String> o = (List<String>) super.selectList(getSqlIdPrifx() + "queryMdMFields", maps);
return o;
}
@Override
public List<JSONObject> queryMdmSTDetail(Map<String, Object> maps) {
//List<String> fields = queryMdMFields(maps);
//maps.put("fields", fields );
List<JSONObject> o = (List<JSONObject>) super.selectList(getSqlIdPrifx() + "queryMdmSTDetail", maps);
return o;
}

View File

@ -20,6 +20,9 @@
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id="MdmModuleEntity_Base_Column_List">
id
@ -464,7 +467,7 @@ where id = #{id}
</select>
<select id="alterTableField" resultType="java.lang.Integer">
<select id="alterTableField" databaseId="mysql" resultType="java.lang.Integer">
ALTER TABLE ${dbName}
<choose>
@ -529,6 +532,65 @@ where id = #{id}
</when>
</choose>
</select>
<select id="alterTableField" databaseId="oracle" resultType="java.lang.Integer">
ALTER TABLE "businesscenter".${dbName}
<choose>
<when test="filedType == '1'.toString()">
<choose>
<when test="dataType == '1'.toString()">
add ${enName} bigint(${filedLength}) DEFAULT NULL
</when>
<when test="dataType == '3'.toString()">
drop ${enName}
</when>
<otherwise>
MODIFY ${enName} bigint(${filedLength}) DEFAULT NULL
</otherwise>
</choose>
</when>
<when test="filedType == '3'.toString()">
<choose>
<when test="dataType == '1'.toString()">
add ${enName} varchar(${filedLength}) DEFAULT NULL
</when>
<when test="dataType == '3'.toString()">
drop ${enName}
</when>
<otherwise>
MODIFY ${enName} varchar(${filedLength}) DEFAULT NULL
</otherwise>
</choose>
</when>
<when test="filedType == '2'.toString()">
<choose>
<when test="dataType == '1'.toString()">
add ${enName} decimal(${filedLength}) DEFAULT NULL
</when>
<when test="dataType == '3'.toString()">
drop ${enName}
</when>
<otherwise>
MODIFY ${enName} decimal(${filedLength}) DEFAULT NULL
</otherwise>
</choose>
</when>
<when test="filedType == '4'.toString()">
<choose>
<when test="dataType == '1'.toString()">
add ${enName} datetime DEFAULT NULL
</when>
<when test="dataType == '3'.toString()">
drop ${enName}
</when>
<otherwise>
MODIFY ${enName} datetime DEFAULT NULL
</otherwise>
</choose>
</when>
</choose>
</select>
@ -657,11 +719,61 @@ where id = #{id}
</if>
</foreach>
</if>
modify_time = now(),
</trim>
where id = #{id}
</update>
<insert id="saveForm" databaseId="oracle" parameterType="com.hzya.frame.mdm.entity.MdmDataDto">
insert into ${tableName}(
<trim suffix="" suffixOverrides=",">
<if test="mdmDataFiledDtos != null and mdmDataFiledDtos.size>0">
<foreach collection="mdmDataFiledDtos" item="item" index="index">
<if test="item.filedsName != 'logid'.toString() ">
${item.filedsName},
</if>
<if test="item.filedsName == 'logid'.toString() ">
create_user_id,
modify_user_id,
</if>
</foreach>
</if>
create_time,
modify_time,
sts,
<if test="dbType == '1'.toString()">
document_rule,
document_rule_num,
</if>
</trim>
)values
(
<trim suffix="" suffixOverrides=",">
<if test="mdmDataFiledDtos != null and mdmDataFiledDtos.size>0">
<foreach collection="mdmDataFiledDtos" item="item" index="index">
<if test="item.filedsName != 'logid'.toString() ">
#{item.filedsValue},
</if>
<if test="item.filedsName == 'logid'.toString() ">
#{item.filedsValue},
#{item.filedsValue},
</if>
</foreach>
</if>
now(),
now(),
'Y',
<if test="dbType == '1'.toString()">
concat(#{documentRule},
LPAD( CAST( ( SELECT IFNULL( MAX(f.document_rule_num), 0 )+ 1 FROM ${tableName} f WHERE DATE_FORMAT( f.create_time, '%Y-%m' ) = DATE_FORMAT( now(), '%Y-%m' ) ) AS varchar(50) ), ${documentRuleNum} , '0' )
),
(SELECT IFNULL( MAX(f.document_rule_num), 0 )+ 1 FROM ${tableName} f WHERE DATE_FORMAT( f.create_time, '%Y-%m' ) = DATE_FORMAT( now(), '%Y-%m' )
)
</if>
</trim>
)
</insert>
<insert id="saveForm" parameterType="com.hzya.frame.mdm.entity.MdmDataDto">
insert into ${tableName}(
<trim suffix="" suffixOverrides=",">
@ -803,11 +915,29 @@ where id = #{id}
select count(1) from ${tableName} where sts='Y'
</select>
<!-- 根据表名称查询所有的字段,返回小写个是-->
<select id="queryMdMFields" resultType="String" parameterType="java.util.HashMap" >
SELECT
LOWER(COLUMN_NAME) as fileds
FROM
USER_TAB_COLUMNS
WHERE
TABLE_NAME = #{tableName}
</select>
<!-- 分页查询列表 采用like格式 -->
<select id="queryMdmST" resultType="com.alibaba.fastjson.JSONObject"
parameterType="java.util.HashMap">
select * from ${tableName}
<select id="queryMdmST" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.util.HashMap">
select
<if test="field != null and field.size>0">
<foreach item="field" collection="fields" separator="," >
${field}
</foreach>
</if>
<if test="field == null or field.size == 0">
*
</if>
from ${tableName}
<trim prefix="where" prefixOverrides="and">
<if test="documentRule != null and documentRule !='' ">and document_rule = #{documentRule}</if>
<if test="dataStatus != null and dataStatus !='' ">and data_status = #{dataStatus}</if>
@ -870,12 +1000,23 @@ where id = #{id}
and sts = 'Y'
<if test="size != null and size !='' ">limit #{size}</if>
</trim>
order by sorts asc
</select>
<!-- 分页查询列表 采用like格式 -->
<select id="queryMdmSTDetail" resultType="com.alibaba.fastjson.JSONObject"
parameterType="java.util.HashMap">
select * from ${tableName} where sts='Y' and formmain_id = #{formmainId}
select
<if test="field != null and field.size>0">
<foreach item="field" collection="fields" separator="," >
${field}
</foreach>
</if>
<if test="field == null or field.size == 0">
*
</if>
from ${tableName} where sts='Y' and formmain_id = #{formmainId}
</select>
<update id="updateMdmSTs" parameterType="java.util.HashMap">

View File

@ -48,6 +48,7 @@ import com.hzya.frame.sysnew.popedomOperate.dao.ISysPopedomOperateDao;
import com.hzya.frame.sysnew.popedomOperate.entity.SysPopedomOperateEntity;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException;
import org.checkerframework.checker.units.qual.A;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
@ -1453,7 +1454,11 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
}
}
}
mdmModuleDao.alterTableField(entity);
try {
mdmModuleDao.alterTableField(entity);
} catch (Exception e){
throw new BaseSystemException("表字段类型,修改失败,请联系管理员");
}
return BaseResult.getSuccessMessageEntity("修改字段成功");
}
@ -1667,6 +1672,25 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
object1.put("viewType", entity.getViewName());//1 2列表
module.setOptions(object1.toString());//菜单mate参数
sysMenuConfigDao.save(module);
SysButtonConfigEntity buttonConfigEntity = new SysButtonConfigEntity();
buttonConfigEntity.setMenuId(module.getId());
buttonConfigEntity.setSts("Y");
List<SysButtonConfigEntity> sysButtonConfigEntities = sysButtonConfigDao.queryBase(buttonConfigEntity);
//1查询按钮权限
SysPopedomOperateEntity sysPopedomOperateEntity = new SysPopedomOperateEntity();
sysPopedomOperateEntity.setMenuId(module.getId());
sysPopedomOperateEntity.setSts("Y");
List<SysPopedomOperateEntity> sysPopedomOperateEntities = sysPopedomOperateDao.queryBase(sysPopedomOperateEntity);
//删除按钮和删除按钮权限
sysButtonConfigDao.logicRemoveMultiCondition(buttonConfigEntity);
sysPopedomOperateDao.logicRemoveMultiCondition(sysPopedomOperateEntity);
MdmModuleViewButtonEntity mdmModuleViewButtonEntity = new MdmModuleViewButtonEntity();
mdmModuleViewButtonEntity.setMdmId(mdmModuleEntity.getId());
mdmModuleViewButtonEntity.setSts("Y");
List<MdmModuleViewButtonEntity> mdmModuleViewButtonEntities = mdmModuleViewButtonDao.queryBase(mdmModuleViewButtonEntity);
//删除处理权限
doMdmModuleButton(module,mdmModuleViewButtonEntities,sysButtonConfigEntities,sysPopedomOperateEntities);
return BaseResult.getSuccessMessageEntity("保存显示类型成功");
}
@ -1720,6 +1744,25 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
object1.put("viewType", entity.getViewName());//1 2列表
module.setOptions(object1.toString());//菜单mate参数
sysMenuConfigDao.update(module);
SysButtonConfigEntity buttonConfigEntity = new SysButtonConfigEntity();
buttonConfigEntity.setMenuId(module.getId());
buttonConfigEntity.setSts("Y");
List<SysButtonConfigEntity> sysButtonConfigEntities = sysButtonConfigDao.queryBase(buttonConfigEntity);
//1查询按钮权限
SysPopedomOperateEntity sysPopedomOperateEntity = new SysPopedomOperateEntity();
sysPopedomOperateEntity.setMenuId(module.getId());
sysPopedomOperateEntity.setSts("Y");
List<SysPopedomOperateEntity> sysPopedomOperateEntities = sysPopedomOperateDao.queryBase(sysPopedomOperateEntity);
//删除按钮和删除按钮权限
sysButtonConfigDao.logicRemoveMultiCondition(buttonConfigEntity);
sysPopedomOperateDao.logicRemoveMultiCondition(sysPopedomOperateEntity);
MdmModuleViewButtonEntity mdmModuleViewButtonEntity = new MdmModuleViewButtonEntity();
mdmModuleViewButtonEntity.setMdmId(mdmModuleEntity.getId());
mdmModuleViewButtonEntity.setSts("Y");
List<MdmModuleViewButtonEntity> mdmModuleViewButtonEntities = mdmModuleViewButtonDao.queryBase(mdmModuleViewButtonEntity);
//删除处理权限
doMdmModuleButton(module,mdmModuleViewButtonEntities,sysButtonConfigEntities,sysPopedomOperateEntities);
}
return BaseResult.getSuccessMessageEntity("修改显示类型成功");
}

View File

@ -117,7 +117,7 @@ public interface IMdmService {
* @Description 处理分发数据
* @Date 9:40 上午 2023/10/18
**/
JsonResultEntity doMdmDistribute(JSONObject jsonObject);
JsonResultEntity doMdmDistribute(JSONObject jsonObject) throws Exception;
}

View File

@ -1,29 +1,13 @@
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;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.mdm.entity.DbFiledsDto;
import com.hzya.frame.mdm.entity.MdmDataDto;
import com.hzya.frame.mdm.entity.MdmDataFiledDto;
import com.hzya.frame.mdm.entity.MdmDbFiledVo;
import com.hzya.frame.mdm.entity.MdmDbVo;
import com.hzya.frame.mdm.entity.MdmDetailViewVo;
import com.hzya.frame.mdm.entity.MdmDistributeDto;
import com.hzya.frame.mdm.entity.MdmDto;
import com.hzya.frame.mdm.entity.MdmModuleViewDto;
import com.hzya.frame.mdm.entity.MdmModuleViewVo;
import com.hzya.frame.mdm.entity.MdmQuery;
import com.hzya.frame.mdm.entity.MdmSourceDto;
import com.hzya.frame.mdm.entity.MdmViewFiledVo;
import com.hzya.frame.mdm.entity.MdmViewVo;
import com.hzya.frame.mdm.entity.*;
import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao;
import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity;
import com.hzya.frame.mdm.mdmModuleDb.dao.IMdmModuleDbDao;
@ -40,41 +24,31 @@ import com.hzya.frame.mdm.mdmModuleOptionLog.dao.IMdmModuleOptionLogDao;
import com.hzya.frame.mdm.mdmModuleOptionLog.entity.MdmModuleOptionLogEntity;
import com.hzya.frame.mdm.mdmModuleSendLog.dao.IMdmModuleSendLogDao;
import com.hzya.frame.mdm.mdmModuleSendLog.entity.MdmModuleSendLogEntity;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.mdm.mdmModuleView.dao.IMdmModuleViewDao;
import com.hzya.frame.mdm.mdmModuleView.entity.MdmModuleViewEntity;
import com.hzya.frame.mdm.mdmModuleViewButton.dao.IMdmModuleViewButtonDao;
import com.hzya.frame.mdm.mdmModuleViewButton.entity.MdmModuleViewButtonEntity;
import com.hzya.frame.mdm.mdmModuleViewDetail.dao.IMdmModuleViewDetailDao;
import com.hzya.frame.mdm.mdmModuleViewDetail.entity.MdmModuleViewDetailEntity;
import com.hzya.frame.mdm.mdmTableCodeRule.dao.IMdmTableCodeRuleDao;
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;
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.sysnew.application.plugin.entity.SysApplicationPluginEntity;
import com.hzya.frame.sysnew.application.script.dao.ISysApplicationScriptDao;
import com.hzya.frame.sysnew.application.script.entity.SysApplicationScriptEntity;
import com.hzya.frame.sysnew.buttonConfig.dao.ISysButtonConfigDao;
import com.hzya.frame.sysnew.buttonConfig.entity.SysButtonConfigEntity;
import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.sysnew.menuConfig.dao.ISysMenuConfigDao;
import com.hzya.frame.sysnew.menuConfig.entity.SysMenuConfigEntity;
import com.hzya.frame.sysnew.popedomOperate.dao.ISysPopedomOperateDao;
import com.hzya.frame.sysnew.popedomOperate.entity.SysPopedomOperateEntity;
import com.hzya.frame.sysnew.user.dao.ISysUserDao;
import com.hzya.frame.sysnew.user.entity.SysUserEntity;
import com.hzya.frame.sysnew.userCompany.entity.SysUserCompanyEntity;
import com.hzya.frame.sysnew.userRoles.entity.SysUserRolesEntity;
import com.hzya.frame.util.PluginUtils;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
@ -86,7 +60,6 @@ import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -95,12 +68,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
@ -119,6 +87,8 @@ public class MdmServiceImpl implements IMdmService {
@Resource
private IMdmModuleDao mdmModuleDao;
@Resource
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Resource
private IGroovyIntegrationService groovyIntegrationService;
@Resource
@ -644,7 +614,7 @@ public class MdmServiceImpl implements IMdmService {
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
if(entity.getMdmCode() != null && !"".equals(entity.getMdmCode())){
if (entity.getMdmCode() != null && !"".equals(entity.getMdmCode())) {
MdmModuleEntity mdmModuleEntity = mdmServiceCache.getMdmModuleEntity(entity.getMdmCode());
if (mdmModuleEntity == null || mdmModuleEntity.getId() == null) {
return BaseResult.getFailureMessageEntity("主数据设置错误");
@ -653,11 +623,25 @@ public class MdmServiceImpl implements IMdmService {
mdmModuleDbEntity.setMdmId(mdmModuleEntity.getId());
mdmModuleDbEntity.setSts("Y");
List<MdmModuleDbEntity> mdmModuleDbEntities = mdmServiceCache.queryMdmModuleDb(mdmModuleDbEntity);
MdmModuleDbFiledsEntity mdmModuleDbFiledsEntity = new MdmModuleDbFiledsEntity();
mdmModuleDbFiledsEntity.setMdmId(mdmModuleEntity.getId());
mdmModuleDbFiledsEntity.setSts("Y");
List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities = mdmServiceCache.queryMdmModuleDbFileds(mdmModuleDbFiledsEntity);
if (mdmModuleDbEntities == null || mdmModuleDbEntities.size() == 0) {
return BaseResult.getFailureMessageEntity("主数据设置错误");
}
if (mdmModuleDbFiledsEntities == null || mdmModuleDbFiledsEntities.size() == 0) {
return BaseResult.getFailureMessageEntity("主数据设置错误");
}
for (int i = 0; i < mdmModuleDbEntities.size(); i++) {
if ("1".equals(mdmModuleDbEntities.get(i).getDbType())) {
List<String> returnField = new ArrayList<>();
for (int i1 = 0; i1 < mdmModuleDbFiledsEntities.size(); i1++) {
if (mdmModuleDbEntities.get(i).getId().equals(mdmModuleDbFiledsEntities.get(i1).getDbId())) {
returnField.add(mdmModuleDbFiledsEntities.get(i1).getEnName());
}
}
entity.setReturnField(returnField);
entity.setTableName(mdmModuleDbEntities.get(i).getDbName());
break;
}
@ -669,9 +653,35 @@ public class MdmServiceImpl implements IMdmService {
}
PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
List<HashMap<String, Object>> businessResult = mdmModuleDao.queryMdmShowData(entity);
//强制把数据库字段转换小写
if(null != businessResult && businessResult.size() >0){
convertKeysToLowerCase(businessResult);
}
PageInfo pageInfo = new PageInfo(businessResult);
return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
}
//强制转换数据库字段为小写,出问题在说
public void convertKeysToLowerCase(List<HashMap<String, Object>> list) {
for (HashMap<String, Object> map : list) {
HashMap<String, Object> lowerCaseMap = new HashMap<>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
lowerCaseMap.put(entry.getKey().toLowerCase(), entry.getValue());
}
map.clear(); // 清空原来的Map避免重复存储
map.putAll(lowerCaseMap); // 将转换后的Map全部放回原位
}
}
//强制转换数据库字段为小写,出问题在说
public void convertKeysToLowerCase(HashMap<String, Object> list) {
HashMap<String, Object> lowerCaseMap = new HashMap<>();
for (Map.Entry<String, Object> entry : list.entrySet()) {
lowerCaseMap.put(entry.getKey().toLowerCase(), entry.getValue());
}
list.clear(); // 清空原来的Map避免重复存储
list.putAll(lowerCaseMap); // 将转换后的Map全部放回原位
}
//
///**
// * @param object
@ -780,10 +790,12 @@ public class MdmServiceImpl implements IMdmService {
if (entity.getPageNum() != null && entity.getPageSize() != null) {
PageHelper.startPage(entity.getPageNum(), entity.getPageSize());
List<HashMap<String, Object>> mapList = mdmModuleDao.querySelectData(entity);
convertKeysToLowerCase(mapList);
PageInfo pageInfo = new PageInfo(mapList);
return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo);
} else {
List<HashMap<String, Object>> mapList = mdmModuleDao.querySelectData(entity);
convertKeysToLowerCase(mapList);
return BaseResult.getSuccessMessageEntity("查询数据成功", mapList);
}
}
@ -811,7 +823,7 @@ public class MdmServiceImpl implements IMdmService {
if (entity.getUpId() == null || "".equals(entity.getUpId())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
if(entity.getMdmCode() != null && !"".equals(entity.getMdmCode())){
if (entity.getMdmCode() != null && !"".equals(entity.getMdmCode())) {
//查询模版
MdmModuleEntity mdmModuleEntities = mdmServiceCache.getMdmModuleEntity(entity.getMdmCode());
if (mdmModuleEntities == null) {
@ -831,6 +843,7 @@ public class MdmServiceImpl implements IMdmService {
break;
}
}
entity.setTableName(mdmModuleDbEntity.getDbName());
}
@ -846,6 +859,7 @@ public class MdmServiceImpl implements IMdmService {
List<HashMap<String, Object>> returnList = new ArrayList<>();
return BaseResult.getSuccessMessageEntity("查询数据成功", returnList);
}
convertKeysToLowerCase(mapList);
List<HashMap<String, Object>> returnList = gettochilder(strArray, 0, mapList);
return BaseResult.getSuccessMessageEntity("查询数据成功", returnList);
} else {
@ -854,8 +868,12 @@ public class MdmServiceImpl implements IMdmService {
List<HashMap<String, Object>> returnList = new ArrayList<>();
return BaseResult.getSuccessMessageEntity("查询数据成功", returnList);
}
HashMap<String, Object> lowerCaseMap = new HashMap<>();
for (Map.Entry<String, Object> entry : mapList.entrySet()) {
lowerCaseMap.put(entry.getKey().toLowerCase(), entry.getValue());
}
List<HashMap<String, Object>> returnList = new ArrayList<>();
returnList.add(mapList);
returnList.add(lowerCaseMap);
return BaseResult.getSuccessMessageEntity("查询数据成功", returnList);
}
} else {
@ -863,6 +881,7 @@ public class MdmServiceImpl implements IMdmService {
List<HashMap<String, Object>> returnList = new ArrayList<>();
if (mapList != null && mapList.size() > 0) {
convertKeysToLowerCase(mapList);
for (int i = 0; i < mapList.size(); i++) {
//默认为根
if (mapList.get(i).get(entity.getUpId()) == null || "".equals(mapList.get(i).get(entity.getUpId()))) {
@ -1334,7 +1353,7 @@ public class MdmServiceImpl implements IMdmService {
//String tablename = null;
JSONObject jsonObject = new JSONObject();
for (int i = 0; i < mdmModuleDbEntityList.size(); i++) {
if("1".equals(mdmModuleDbEntityList.get(i).getDbType()) || "2".equals(mdmModuleDbEntityList.get(i).getDbType())){
if ("1".equals(mdmModuleDbEntityList.get(i).getDbType()) || "2".equals(mdmModuleDbEntityList.get(i).getDbType())) {
//查询数据
Map<String, Object> queryData = new HashMap<>();
queryData.put("tableName", mdmModuleDbEntityList.get(i).getDbName());//表名
@ -1342,12 +1361,15 @@ public class MdmServiceImpl implements IMdmService {
queryData.put("detailFlag", false);//是否明细
queryData.put("id", entity.getId());//字段
HashMap<String, Object> datas = mdmModuleDbDao.getServiceDataById(queryData);
convertKeysToLowerCase(datas);
jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), datas);
//tablename = mdmModuleDbEntityList.get(i).getDbName() + "_distribute";
} else {
queryData.put("detailFlag", true);//是否明细
queryData.put("id", entity.getId());//字段
List<HashMap<String, Object>> datas = mdmModuleDbDao.getServiceByFormmainId(queryData);
convertKeysToLowerCase(datas);
jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), datas);
}
}
@ -1399,7 +1421,7 @@ public class MdmServiceImpl implements IMdmService {
if (mdmModuleDbEntityList == null || mdmModuleDbEntityList.size() == 0) {
return BaseResult.getFailureMessageEntity("系统错误");
}
String res = checkDataOnly(jsonObject.getInteger("mdmCode"), saveData, true, mdmModuleEntity, mdmModuleDbEntityList,"界面修改");
String res = checkDataOnly(jsonObject.getInteger("mdmCode"), saveData, true, mdmModuleEntity, mdmModuleDbEntityList, "界面修改");
if (res == null || "".equals(res)) {
return BaseResult.getSuccessMessageEntity("修改数据成功");
@ -1445,7 +1467,7 @@ public class MdmServiceImpl implements IMdmService {
}
String res = checkDataOnly(jsonObject.getInteger("mdmCode"), saveData, false, mdmModuleEntity, mdmModuleDbEntityList,"界面新增");
String res = checkDataOnly(jsonObject.getInteger("mdmCode"), saveData, false, mdmModuleEntity, mdmModuleDbEntityList, "界面新增");
if (res == null || "".equals(res)) {
return BaseResult.getSuccessMessageEntity("保存数据成功");
@ -1454,9 +1476,9 @@ public class MdmServiceImpl implements IMdmService {
}
}
private void saveOption(String dbname ,Long mdmCode ,JSONObject jsonObject,String id,String msg) {
private void saveOption(String dbname, Long mdmCode, JSONObject jsonObject, String id, String msg) {
MdmModuleOptionLogEntity mdmModuleOptionLogEntity = new MdmModuleOptionLogEntity();
mdmModuleOptionLogEntity.setTableName(dbname+"_option_log");
mdmModuleOptionLogEntity.setTableName(dbname + "_option_log");
mdmModuleOptionLogEntity.setMdmCode(mdmCode);
mdmModuleOptionLogEntity.setFormmainId(id);
mdmModuleOptionLogEntity.setSourceName("数智中台");
@ -1466,7 +1488,7 @@ public class MdmServiceImpl implements IMdmService {
mdmModuleOptionLogEntity.setSourceData(jsonObject.toJSONString());
mdmModuleOptionLogEntity.setOptionType(msg);
SysUserEntity sysUserEntity = sysUserDao.get(StpUtil.getLoginIdAsString());
if(sysUserEntity != null){
if (sysUserEntity != null) {
mdmModuleOptionLogEntity.setOptionName(sysUserEntity.getPersonName());
}
mdmModuleOptionLogEntity.setCreate();
@ -1535,6 +1557,8 @@ public class MdmServiceImpl implements IMdmService {
queryData.put("detailFlag", false);//是否明细
queryData.put("id", jsonObject.getString("id"));//字段
HashMap<String, Object> datas = mdmModuleDbDao.getServiceDataById(queryData);
convertKeysToLowerCase(datas);
String upValue = null;
if (datas != null && datas.get(mdmModuleViewEntity.getUpIdFiled()) != null) {
upValue = datas.get(mdmModuleViewEntity.getUpIdFiled()).toString();
@ -1559,10 +1583,31 @@ public class MdmServiceImpl implements IMdmService {
}
saveOption(dbname,mdmModuleEntity.getMdmCode(),jsonObject,jsonObject.getString("id"),"界面删除");
saveOption(dbname, mdmModuleEntity.getMdmCode(), jsonObject, jsonObject.getString("id"), "界面删除");
return BaseResult.getSuccessMessageEntity("删除数据成功");
}
public JSONObject toLowerCaseKeys(JSONObject jsonObject) {
JSONObject lowerCaseJson = new JSONObject();
if (jsonObject != null) {
for (String key : jsonObject.keySet()) {
Object value = jsonObject.get(key);
lowerCaseJson.put(key.toLowerCase(), value);
}
}
return lowerCaseJson;
}
public List<JSONObject> toLowerCaseKeys(List<JSONObject> list) {
List<JSONObject> jsonObjects = new ArrayList<>();
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
jsonObjects.add(toLowerCaseKeys(list.get(i)));
}
}
return jsonObjects;
}
/**
* @param jsonStr
* @return com.hzya.frame.web.entity.JsonResultEntity
@ -1571,7 +1616,7 @@ public class MdmServiceImpl implements IMdmService {
* @Date 9:40 上午 2023/10/18
**/
@Override
public JsonResultEntity doMdmDistribute(JSONObject jsonStr) {
public JsonResultEntity doMdmDistribute(JSONObject jsonStr) throws Exception {
JSONObject jsonObject = getstrObj("jsonStr", jsonStr);
//校验是否有servecr传参
if (!checkData(jsonObject, "mdmCode")) {
@ -1679,6 +1724,7 @@ public class MdmServiceImpl implements IMdmService {
map.put("tableName", mdmModuleDbEntities.get(i).getDbName());
map.put("id", id);
object = mdmModuleDao.queryMdmST(map);
object = toLowerCaseKeys(object);
if (object.getString("id") == null || "".equals(object.getString("id"))) {
return BaseResult.getFailureMessageEntity("当前数据不存在");
}
@ -1688,6 +1734,7 @@ public class MdmServiceImpl implements IMdmService {
checkData.put("id", id);
checkData.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities);
JSONObject object1 = mdmModuleDao.queryMdmST(checkData);
object1 = toLowerCaseKeys(object1);
if (object1 == null || object1.getString("id") == null || "".equals(object1.getString("id"))) {
return BaseResult.getFailureMessageEntity("当前数据不符合规则不发送");
}
@ -1699,13 +1746,14 @@ 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())) {
if(object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){
if (object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null) {
Map<String, Object> mapDetail = new HashMap<>();
mapDetail.put("tableName", mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue());
String ids = object.getString(mdmModuleDbFiledsEntities.get(i2).getEnName());
String[] idss = ids.split(",");
mapDetail.put("id", idss[idss.length-1]);
mapDetail.put("id", idss[idss.length - 1]);
JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail);
objectDetail = toLowerCaseKeys(objectDetail);
object.put(mdmModuleDbFiledsEntities.get(i2).getEnName(), objectDetail);
}
}
@ -1719,12 +1767,13 @@ public class MdmServiceImpl implements IMdmService {
for (int i = 0; i < mdmModuleDbEntities.size(); i++) {
if ("2".equals(mdmModuleDbEntities.get(i).getDbType())) {
Map<String, String> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
map.put("tableName", mdmModuleDbEntities.get(i).getDbName());
map.put("formmainId", object.getString("id"));
List<JSONObject> detail = mdmModuleDao.queryMdmSTDetail(map);
//查看主表是否有字段是关联的
if (detail != null && detail.size() > 0) {
detail = toLowerCaseKeys(detail);
if (mdmModuleDbFiledsRuleEntities != null && mdmModuleDbFiledsRuleEntities.size() > 0) {
for (int i1 = 0; i1 < mdmModuleDbFiledsRuleEntities.size(); i1++) {
if (mdmModuleDbFiledsRuleEntities.get(i1).getDbId().equals(mdmModuleDbEntities.get(i).getId())) {
@ -1732,13 +1781,15 @@ 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++) {
if(detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null){
if (detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()) != null) {
Map<String, Object> mapDetail = new HashMap<>();
mapDetail.put("tableName", mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue());
String ids = detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName());
String ids = detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName());
String[] idss = ids.split(",");
mapDetail.put("id", idss[idss.length-1]);
mapDetail.put("id", idss[idss.length - 1]);
JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail);
objectDetail = toLowerCaseKeys(objectDetail);
detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(), objectDetail);
}
}
@ -1796,41 +1847,54 @@ public class MdmServiceImpl implements IMdmService {
//找到登陆接口
SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort());
if (null == loginApi) {
saveMdmModuleSendLogEntity("2","转发失败,认证接口不存在",dbname,object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type);
saveMdmModuleSendLogEntity(mdmModuleEntity.getMdmCode(),mdmModuleDistributeEntity.getId(),"2", "转发失败,认证接口不存在", dbname, object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type);
return BaseResult.getFailureMessageEntity("发送错误,认证接口不存在");
}
String rzquerys = getQuery(loginApi,null,null);
String rzquerys = getQuery(loginApi, null, null);
Map<String, String> 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<String, String> rzheaders = getHeaders(loginApi,headersa,null);
String rzbodys = getBodys(loginApi,null,null);
JsonResultEntity rzjsonResultEntity = sendData(loginApi,rzheaders,rzbodys,rzquerys);
Map<String, String> 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());
saveMdmModuleSendLogEntity(mdmModuleEntity.getMdmCode(),mdmModuleDistributeEntity.getId(),"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);
//logger.info("认证接口返回信息:"+ attritube.toJSONString());
querys = getQuery(apiEntity, querys, attritube);
//logger.info("认证接口拼接querys信息"+ querys);
headers = getHeaders(apiEntity, headers, attritube);
if (headers != null && headers.size() > 0) {
StringBuffer stringBuffer = new StringBuffer();
for (String key : headers.keySet()) {
stringBuffer.append(key).append("=").append(headers.get(key)).append("&");
}
//logger.info("认证接口拼接header信息"+ stringBuffer);
}
bodys = getBodys(apiEntity, bodys, attritube);
//logger.info("认证接口拼接bodys信息"+ bodys);
}
//组装数据发送
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);
saveMdmModuleSendLogEntity(mdmModuleEntity.getMdmCode(),mdmModuleDistributeEntity.getId(),"1", "发送成功", dbname, object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type);
return BaseResult.getSuccessMessageEntity("发送成功");
} else {
saveMdmModuleSendLogEntity("2","转发失败",dbname,object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type);
return BaseResult.getFailureMessageEntity("发送错误:"+jsonResultEntity.getMsg());
saveMdmModuleSendLogEntity(mdmModuleEntity.getMdmCode(),mdmModuleDistributeEntity.getId(),"2", "转发失败", dbname, object.getString("id"), sysApplicationEntity.getName(), apiEntity.getApiName(), object.toJSONString(), type);
return BaseResult.getFailureMessageEntity("发送错误:" + jsonResultEntity.getMsg());
}
}
private Map<String, String> getHeaders(SysApplicationApiEntity loginApi,Map<String, String> map,JSONObject loginData) {
if(loginData == null){
private Map<String, String> getHeaders(SysApplicationApiEntity loginApi, Map<String, String> map, JSONObject loginData) {
if (loginData == null) {
loginData = new JSONObject();
}
if (loginApi.getHeaderIn() != null && !"".equals(loginApi.getHeaderIn())) {
@ -1850,11 +1914,11 @@ public class MdmServiceImpl implements IMdmService {
}
} else {
if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值如果没有不添加
if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){
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){
if (map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null) {
map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), "");
}
}
@ -1865,27 +1929,25 @@ public class MdmServiceImpl implements IMdmService {
return map;
}
private String getQuery(SysApplicationApiEntity loginApi,String sendDatastr,JSONObject loginData) {
private String getQuery(SysApplicationApiEntity loginApi, String sendDatastr, JSONObject loginData) {
Map<String, String> map = new HashMap<>();
if(sendDatastr != null){
if (sendDatastr != null) {
String[] parts = sendDatastr.split("&");
if(parts != null && parts.length > 0){
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 ){
if (part != null && part.length >= 2) {
for (int a = 0; a < part.length; a++) {
map.put(part[0],part[1]);
map.put(part[0], part[1]);
}
}
}
}
}
if(loginData == null){
if (loginData == null) {
loginData = new JSONObject();
}
if (loginApi.getQueryIn() != null && !"".equals(loginApi.getQueryIn())) {
@ -1906,11 +1968,11 @@ public class MdmServiceImpl implements IMdmService {
} else {
//不是认证类型直接取值
if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值如果没有不添加
if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){
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){
if (map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null) {
map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), "");
}
}
@ -1919,17 +1981,18 @@ public class MdmServiceImpl implements IMdmService {
}
}
StringBuffer returnStr = new StringBuffer();
if(map != null && map.size() > 0){
if (map != null && map.size() > 0) {
for (String key : map.keySet()) {
if("".equals(returnStr)){
if ("".equals(returnStr)) {
returnStr.append(key).append("=").append(map.get(key));
}else {
} else {
returnStr.append("&").append(key).append("=").append(map.get(key));
}
}
}
return returnStr.toString();
}
/**
* @param loginData
* @param example
@ -1955,12 +2018,13 @@ public class MdmServiceImpl implements IMdmService {
}
return values;
}
private String getBodys(SysApplicationApiEntity loginApi,String sendDatastr, JSONObject loginData) {
private String getBodys(SysApplicationApiEntity loginApi, String sendDatastr, JSONObject loginData) {
JSONObject sendData = new JSONObject();
if(sendDatastr != null ){
if (sendDatastr != null) {
sendData = JSONObject.parseObject(sendDatastr);
}
if(loginData == null){
if (loginData == null) {
loginData = new JSONObject();
}
if (loginApi.getBodyIn() != null && !"".equals(loginApi.getBodyIn())) {
@ -1974,7 +2038,7 @@ public class MdmServiceImpl implements IMdmService {
if (query != null && !"".equals(query)) {
JSONArray example = JSONArray.parseArray(query);
String logValue = getObjectValue(loginData, example);
sendData.put(querys.getString(SysEnum.PARAMETERNAME.getValue()),logValue);
sendData.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), logValue);
}
}
}
@ -1982,6 +2046,7 @@ public class MdmServiceImpl implements IMdmService {
}
return sendData.toString();
}
/**
* @param querys 设置的字段属性
* @param sendData 发送数据
@ -2096,15 +2161,15 @@ public class MdmServiceImpl implements IMdmService {
//设置api的参数
//返回数据
JSONArray sendArray = sendData.getJSONArray(querys.getString(SysEnum.PARAMETERNAME.getValue()));
if(sendArray == null || sendArray.size() == 0){
if (sendArray == null || sendArray.size() == 0) {
return new JSONArray();
}
String childers = querys.getString(SysEnum.CHILDREN.getValue());
if(childers == null || "".equals(childers)){
if (childers == null || "".equals(childers)) {
return new JSONArray();
}
JSONArray childersObj = JSONArray.parseArray(childers);
if(childersObj == null || childersObj.size() == 0){
if (childersObj == null || childersObj.size() == 0) {
return new JSONArray();
}
JSONArray obj = new JSONArray();
@ -2170,6 +2235,17 @@ public class MdmServiceImpl implements IMdmService {
entity.setContentType("application/json");
post.setEntity(entity);
}
logger.info("接口拼接querys信息"+ querys);
if (headers != null && headers.size() > 0) {
StringBuffer stringBuffer = new StringBuffer();
for (String key : headers.keySet()) {
stringBuffer.append(key).append("=").append(headers.get(key)).append("&");
}
logger.info("接口拼接header信息"+ stringBuffer);
}
logger.info("接口拼接bodys信息"+ bodys);
response = closeableHttpClient.execute(post);
HttpEntity entity = response.getEntity();
@ -2213,10 +2289,9 @@ 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) {
private void saveMdmModuleSendLogEntity(Long mdmCode,String distributeId,String dataType,String remark,String dbname,String formmain_id, String target_app, String target_api, String source_data, String option_type) throws Exception {
MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity();
mdmModuleSendLogEntity.setTableName(dbname+"_send_log");
mdmModuleSendLogEntity.setCreate();
mdmModuleSendLogEntity.setId(UUIDUtils.getUUID());
mdmModuleSendLogEntity.setSts("Y");
mdmModuleSendLogEntity.setCreate_user_id("1");
@ -2233,6 +2308,35 @@ public class MdmServiceImpl implements IMdmService {
mdmModuleSendLogEntity.setDataType(dataType);
mdmModuleSendLogEntity.setRemark(remark);
mdmModuleSendLogDao.save(mdmModuleSendLogEntity);
JSONObject jsonObject = JSONObject.parseObject(source_data);
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
integrationTaskLivingDetailsEntity.setSts("Y");
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
integrationTaskLivingDetailsEntity.setModify_user_id("1");
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
integrationTaskLivingDetailsEntity.setModify_time(new Date());
integrationTaskLivingDetailsEntity.setOrg_id("0");
integrationTaskLivingDetailsEntity.setCompanyId("0");
JSONObject aa = new JSONObject();
aa.put("mdmCode",mdmCode);//主数据编码
aa.put("documentRule",jsonObject.getString("document_rule"));//行数据的单据规则编码
aa.put("distributeId",distributeId);//发送表id
aa.put("type",option_type);//发送类型1新增2修改3删除
integrationTaskLivingDetailsEntity.setRootAppPk(aa.toJSONString());
integrationTaskLivingDetailsEntity.setRootAppBill(jsonObject.getString("document_rule"));
integrationTaskLivingDetailsEntity.setPluginId("MdmModulePlugin");
integrationTaskLivingDetailsEntity.setRootAppNewData(source_data);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(remark);
if("1".equals(dataType)){
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
}else {
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
}
}
@ -2247,11 +2351,11 @@ public class MdmServiceImpl implements IMdmService {
* @Description 校验数据
* @Date 11:20 上午 2023/11/6
**/
private String checkDataOnly(long mdmCode, JSONObject saveData, boolean flag, MdmModuleEntity mdmModuleEntity, List<MdmModuleDbEntity> mdmModuleDbEntityList,String msg) {
private String checkDataOnly(long mdmCode, JSONObject saveData, boolean flag, MdmModuleEntity mdmModuleEntity, List<MdmModuleDbEntity> mdmModuleDbEntityList, String msg) {
StringBuffer str = new StringBuffer();
String dbname = null;
for (int i = 0; i < mdmModuleDbEntityList.size(); i++) {
if("1".equals(mdmModuleDbEntityList.get(i).getDbType())){
if ("1".equals(mdmModuleDbEntityList.get(i).getDbType())) {
dbname = mdmModuleDbEntityList.get(i).getDbName();
}
}
@ -2417,10 +2521,27 @@ public class MdmServiceImpl implements IMdmService {
List<MdmDataFiledDto> mdmDataFiledDtos = new ArrayList<>();
for (int i1 = 0; i1 < fileds.size(); i1++) {
if (jsonObject.get(fileds.get(i1).getEnName()) != null) {
MdmDataFiledDto mdmDataFiledDto = new MdmDataFiledDto();
mdmDataFiledDto.setFiledsName(fileds.get(i1).getEnName());
mdmDataFiledDto.setFiledsValue(jsonObject.getString(fileds.get(i1).getEnName()));
mdmDataFiledDtos.add(mdmDataFiledDto);
if (flag && "update_status".equals(fileds.get(i1).getEnName())) {
MdmDataFiledDto update_status = new MdmDataFiledDto();
update_status.setFiledsName("update_status");
update_status.setFiledsValue("0");
mdmDataFiledDtos.add(update_status);
}else if(flag && "data_status".equals(fileds.get(i1).getEnName())) {
MdmDataFiledDto data_status = new MdmDataFiledDto();
data_status.setFiledsName("data_status");
data_status.setFiledsValue("F");
mdmDataFiledDtos.add(data_status);
}else if(flag && "modify_user_id".equals(fileds.get(i1).getEnName())) {
MdmDataFiledDto data_status = new MdmDataFiledDto();
data_status.setFiledsName("modify_user_id");
data_status.setFiledsValue("F");
//mdmDataFiledDtos.add(data_status);
}else {
MdmDataFiledDto mdmDataFiledDto = new MdmDataFiledDto();
mdmDataFiledDto.setFiledsName(fileds.get(i1).getEnName());
mdmDataFiledDto.setFiledsValue(jsonObject.getString(fileds.get(i1).getEnName()));
mdmDataFiledDtos.add(mdmDataFiledDto);
}
}
}
MdmDataFiledDto mdmDataFiledDto = new MdmDataFiledDto();
@ -2431,15 +2552,7 @@ public class MdmServiceImpl implements IMdmService {
if (flag) {
mdmDataDto.setId(jsonObject.getString("id"));
id = jsonObject.getString("id");
MdmDataFiledDto update_status = new MdmDataFiledDto();
update_status.setFiledsName("update_status");
update_status.setFiledsValue("0");
mdmDataFiledDtos.add(update_status);
MdmDataFiledDto data_status = new MdmDataFiledDto();
data_status.setFiledsName("data_status");
data_status.setFiledsValue("F");
;
mdmDataFiledDtos.add(data_status);
int a = mdmModuleDao.updateForm(mdmDataDto);
} else {
@ -2515,7 +2628,7 @@ public class MdmServiceImpl implements IMdmService {
mdmDataDto.setTableName(mdmModuleDbEntityList.get(i).getDbName());
List<MdmDataFiledDto> mdmDataFiledDtos = new ArrayList<>();
for (int i1 = 0; i1 < fileds.size(); i1++) {
if("id".equals(fileds.get(i1).getEnName())){
if ("id".equals(fileds.get(i1).getEnName())) {
if (jsonObject.getString("id") != null) {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("id");
@ -2527,12 +2640,12 @@ public class MdmServiceImpl implements IMdmService {
ids.setFiledsValue(UUIDUtils.getUUID());
mdmDataFiledDtos.add(ids);
}
}else if("formmain_id".equals(fileds.get(i1).getEnName())){
} else if ("formmain_id".equals(fileds.get(i1).getEnName())) {
MdmDataFiledDto formain_id = new MdmDataFiledDto();
formain_id.setFiledsName("formmain_id");
formain_id.setFiledsValue(id);
mdmDataFiledDtos.add(formain_id);
}else if("data_status".equals(fileds.get(i1).getEnName())){
} else if ("data_status".equals(fileds.get(i1).getEnName())) {
if (jsonObject.getString("id") != null) {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("data_status");
@ -2544,9 +2657,9 @@ public class MdmServiceImpl implements IMdmService {
ids.setFiledsValue("Y");
mdmDataFiledDtos.add(ids);
}
}else if("sorts".equals(fileds.get(i1).getEnName())){
} else if ("sorts".equals(fileds.get(i1).getEnName())) {
}else if("create_user_id".equals(fileds.get(i1).getEnName())){
} else if ("create_user_id".equals(fileds.get(i1).getEnName())) {
//if (jsonObject.getString("id") != null) {
//
//} else {
@ -2555,28 +2668,28 @@ public class MdmServiceImpl implements IMdmService {
// ids.setFiledsValue(UUIDUtils.getUUID());
// mdmDataFiledDtos.add(ids);
//}
}else if("create_time".equals(fileds.get(i1).getEnName())){
} else if ("create_time".equals(fileds.get(i1).getEnName())) {
}else if("modify_user_id".equals(fileds.get(i1).getEnName())){
} else if ("modify_user_id".equals(fileds.get(i1).getEnName())) {
//MdmDataFiledDto ids = new MdmDataFiledDto();
//ids.setFiledsName("modify_user_id");
//ids.setFiledsValue(UUIDUtils.getUUID());
//mdmDataFiledDtos.add(ids);
}else if("company_id".equals(fileds.get(i1).getEnName())){
} else if ("company_id".equals(fileds.get(i1).getEnName())) {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("company_id");
ids.setFiledsValue("0");
mdmDataFiledDtos.add(ids);
}else if("org_id".equals(fileds.get(i1).getEnName())){
} else if ("org_id".equals(fileds.get(i1).getEnName())) {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("org_id");
ids.setFiledsValue("0");
mdmDataFiledDtos.add(ids);
}else if("modify_time".equals(fileds.get(i1).getEnName())){
} else if ("modify_time".equals(fileds.get(i1).getEnName())) {
}else if("sts".equals(fileds.get(i1).getEnName())){
} else if ("sts".equals(fileds.get(i1).getEnName())) {
}else {
} else {
MdmDataFiledDto mdmDataFiledDto = new MdmDataFiledDto();
mdmDataFiledDto.setFiledsName(fileds.get(i1).getEnName());
mdmDataFiledDto.setFiledsValue(jsonObject.getString(fileds.get(i1).getEnName()));
@ -2600,7 +2713,7 @@ public class MdmServiceImpl implements IMdmService {
}
}
}
saveOption(dbname,mdmCode,saveData,id,msg);
saveOption(dbname, mdmCode, saveData, id, msg);
}
return str.toString();
}
@ -2658,5 +2771,15 @@ public class MdmServiceImpl implements IMdmService {
}
return flag;
}
///***
// * 查询所有的字段根据表名称
// * @content:
// * @author 👻👻👻👻👻👻👻👻 gjh
// * @date 2024-06-27 16:29
// * @param
// * @return java.util.List<com.alibaba.fastjson.JSONObject>
// **/
//private List<String> queryMdMFields(Map<String, Object> maps){
// return mdmModuleDao.queryMdMFields(maps);
//}
}

View File

@ -1654,8 +1654,30 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
//例如A应用发送数据到中台中台转发到B应用
HttpServletRequest request = (HttpServletRequest) servletRequest;
String oldbodys = ServletUtil.getBody(servletRequest);
Enumeration<String> headerNames = request.getHeaderNames();
Map<String, String> newheader = ServletUtil.getHeaderMap(request);
StringBuffer newheaders = new StringBuffer();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
String headerValue = request.getHeader(headerName);
newheader.put(headerName,headerValue);
newheaders.append(headerName).append("=").append(headerValue).append("&");
}
logger.info("转发接口获取newheaders信息"+ newheaders);
Map<String, String> oldheaderMap = ServletUtil.getHeaderMap(request);
String oldquerys = request.getQueryString();
logger.info("转发接口获取querys信息"+ oldquerys);
if (oldheaderMap != null && oldheaderMap.size() > 0) {
StringBuffer stringBuffer = new StringBuffer();
for (String key : oldheaderMap.keySet()) {
stringBuffer.append(key).append("=").append(oldheaderMap.get(key)).append("&");
}
logger.info("转发接口获取header信息"+ stringBuffer);
}
logger.info("转发接口获取bodys信息"+ oldbodys);
//应用key
String publicKey = request.getHeader("publicKey");
//应用密钥
@ -1765,7 +1787,13 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
Method[] methods = null;
Object object = null;
if (headers != null && headers.size() > 0) {
StringBuffer stringBuffer = new StringBuffer();
for (String key : headers.keySet()) {
stringBuffer.append(key).append("=").append(headers.get(key)).append("&");
}
logger.info("内部方法转换前header信息"+ stringBuffer);
}
// 判断是否有内部api 是否扩展api 1启用 2停用
@ -1789,6 +1817,7 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
if (m.getName().equals(receiveApi.getFunName().trim())) {
try {
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
sysExtensionApiEntity = (SysExtensionApiEntity) m.invoke(object, sysExtensionApiEntity);
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
break;
@ -1804,6 +1833,15 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
headers = sysExtensionApiEntity.getHeaders();
String querys = sysExtensionApiEntity.getQuerys();
String bodys = sysExtensionApiEntity.getBodys();
if (headers != null && headers.size() > 0) {
StringBuffer stringBuffer = new StringBuffer();
for (String key : headers.keySet()) {
stringBuffer.append(key).append("=").append(headers.get(key)).append("&");
}
logger.info("内部方法转换后header信息"+ stringBuffer);
}
logger.info("内部方法转换bodys信息"+ bodys);
//设置参数获取参数
StringBuffer url = new StringBuffer();
if(!receiveApi.getDestinationAddress().toLowerCase().startsWith("http")){
@ -1866,6 +1904,15 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
entity.setContentType("application/json");
post.setEntity(entity);
}
if (headers != null && headers.size() > 0) {
StringBuffer stringBuffer = new StringBuffer();
for (String key : headers.keySet()) {
stringBuffer.append(key).append("=").append(headers.get(key)).append("&");
}
logger.info("转发接口发送header信息"+ stringBuffer);
}
logger.info("转发接口发送bodys信息"+ bodys);
response = closeableHttpClient.execute(post);
HttpEntity entity = response.getEntity();

View File

@ -62,7 +62,8 @@
<if test="optionName != null and optionName != ''">option_name ,</if>
<if test="dataType != null and dataType != ''"> data_type,</if>
<if test="remark != null and remark != ''"> remark,</if>
<if test="sorts == null"> sorts , </if>
<if test="sorts != null"> sorts,</if>
<!-- <if test="sorts == null"> sorts , </if>-->
<if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
<if test="org_id != null and org_id != ''"> org_id , </if>
@ -83,7 +84,7 @@
<if test="dataType != null and dataType != ''"> #{dataType},</if>
<if test="remark != null and remark != ''"> #{remark},</if>
<if test="sorts != null"> #{sorts} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from ${dbName} a WHERE a.sts = 'Y' ),</if>
<!-- <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from ${dbName} a WHERE a.sts = 'Y' ),</if>-->
<if test="create_user_id != null and create_user_id != ''"> #{create_user_id} ,</if>
<if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} ,</if>
<if test="org_id != null and org_id != ''"> #{org_id} ,</if>

View File

@ -48,6 +48,25 @@ public class ComparisonEntity extends BaseEntity {
private String ruleCode;//规则编码required 判断字段是否是必填
private String ruleValue;//规则值 true/false 判断字段是否是必填
private String filedId;//mdm_module_db_fileds_rule的id
//小写字段
private List<String> fields;
private List<String> returnField;
public List<String> getReturnField() {
return returnField;
}
public void setReturnField(List<String> returnField) {
this.returnField = returnField;
}
public List<String> getFields() {
return fields;
}
public void setFields(List<String> fields) {
this.fields = fields;
}
public String getFiledId() {
return filedId;

View File

@ -16,7 +16,23 @@
<!--分页查询数据-->
<select id="queryComparisonPage" resultType="java.util.Map"
parameterType = "java.util.Map">
select * from ${dbName}
select
<if test="returnField != null and returnField.size>0">
<trim suffixOverrides=",">
<foreach collection="returnField" item="returnField">
a.${returnField} as ${returnField} ,
</foreach>
</trim>
</if>
<if test="returnField == null or returnField.size == 0">
<foreach item="field" collection="fields" separator="," >
a.${field}
</foreach>
</if>
from ${dbName} a
<trim prefix="where" prefixOverrides="and">
<foreach collection="map.entrySet()" item="value" index="key">
and ${key} like concat('%',#{value},'%')
@ -66,11 +82,12 @@
<!--根据mdm_module的id和mdm_module_db的id查询单据规则-->
<select id="queryComparisonById" resultMap="get-ComparisonEntity-result">
select group_concat(db_value SEPARATOR '') as documentRule from mdm_table_code_rule
where mdm_id=#{mId} and sts='Y'
</select>
<!-- select group_concat(db_value SEPARATOR '') as documentRule from mdm_table_code_rule-->
select replace(WM_CONCAT(db_value),',','') as documentRule from mdm_table_code_rule
where mdm_id=#{mId} and sts='Y'
</select>
<!--生成单据规则-->
<!--生成单据规则-->
<select id="queryComparisonRule" resultMap="get-ComparisonEntity-result"
parameterType="com.hzya.frame.sysnew.comparison.entity.ComparisonEntity">
select

View File

@ -1,13 +1,14 @@
package com.hzya.frame.sysnew.comparison.masterData.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.dateutil.DateUtil;
import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.application.service.impl.ApplicationCache;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.sysnew.comparison.masterData.dao.impl.MasterDataDaoImpl;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService;
@ -34,6 +35,8 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
@Autowired
private ApplicationCache applicationCache;
private String ts = "";
/**
@ -46,6 +49,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
@Override
public JsonResultEntity queryArchives(JSONObject json){
// logger.info("第一次入参"+String.valueOf(json));
JSONObject jsonObject = json.getJSONObject("jsonStr");
//查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
@ -54,6 +58,11 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
// applicationCache.get()
// logger.info("入参数据"+jsonObject.toString());
String startTime = DateUtil.format(json.getDate("startTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的开始时间
String endTime = DateUtil.format(json.getDate("endTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的结束时间
// logger.info("本次任务查询区间开始时间:{} 结束时间:{}",startTime,endTime);
String tableName = "";
try {
//通过不同的应用类型用于拼接sql
@ -61,22 +70,25 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
String dbCode = mdmModuleSourceEntity.getDbCode();
String mdmCode = mdmModuleSourceEntity.getMdmCode();
List<JSONObject> listAll = new ArrayList<>();
if(!"10004".equals(mdmCode)){
if("10007".equals(mdmCode)){
continue;
}
// if(!"10003".equals(mdmCode)){
// continue;
// }
switch (appTyp) {//1致远OA 2用友U8C 3用友BIP
case "1":
//通过主数据编码判断不同的接口走不通的查询逻辑
switch (mdmCode){
case "10003"://致远用户信息
tableName = "mdm_user";
listAll = bindingUser(jsonObject, mdmModuleSourceEntity, dbCode);
listAll = bindingUser(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
case "10004"://致远客商信息
tableName = "mdm_customer";
listAll = binDingCust(jsonObject, mdmModuleSourceEntity, dbCode);
listAll = binDingCust(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
break;
case "10007"://致远客商信息
case "10007"://银行信息
tableName = "mdm_bank";
listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode);
break;
@ -106,7 +118,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
// ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'");
}
StringBuffer stringBuffer = new StringBuffer();
@ -129,18 +141,19 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
}
//绑定客户档案
private List<JSONObject> binDingCust(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception {
private List<JSONObject> binDingCust(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception {
List<JSONObject> list = new ArrayList<>();
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'");
// ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.modify_date >= '"+startTime+"'");
sb.append(" and a.modify_date < '"+endTime+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("SELECT id as data_id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0226 a WHERE 1=1 ");
stringBuffer.append("SELECT id as data_id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0177 a WHERE 1=1 " +sb.toString());
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
if(CollectionUtils.isNotEmpty(hashMaps)){
@ -153,7 +166,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
//获取明细信息
Long formmainId = (Long) hashMap.get("data_id");
StringBuffer stringBufferDetails = new StringBuffer();
stringBufferDetails.append("SELECT id as data_id ,field0023 AS pk_bankdoc,field0024 AS accnum,field0025 AS combinenum FROM formson_0229 WHERE formmain_id = '"+formmainId+"' " );
stringBufferDetails.append("SELECT id as data_id ,field0019 AS pk_bankdoc,field0020 AS accnum,field0021 AS combinenum FROM formson_0230 WHERE formmain_id = '"+formmainId+"' " );
List<HashMap<String, Object>> hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
JSONArray mdm_customer_bank = new JSONArray();
if(CollectionUtils.isNotEmpty(hashMapsDetails)){
@ -174,19 +187,50 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
}
//绑定OA用户参数
private List<JSONObject> bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception {
private List<JSONObject> bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime)throws Exception {
List<JSONObject> list = new ArrayList<>();
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'");
// ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+startTime+"'");
sb.append(" and a.update_time <> '"+endTime+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select a.id as data_id, a.name as user_name, e.LOGIN_NAME as user_code FROM org_member a left join org_principal e on a.id = e.MEMBER_ID" +
" WHERE 1=1 " + sb.toString());
stringBuffer.append("SELECT\n" +
"\ta.id AS data_id,\n" +
"\ta.NAME AS user_name,\n" +
"\ta.CODE AS user_code,\n" +
"\te.LOGIN_NAME AS login_name,\n" +
"\t'hzya@1314' as user_password,\n" +
"\t'N' as islocked,\n" +
"\t'1' as user_type,\n" +
"\t'0' as base_doc_type,\n" +
"\t'静态密码验证' as identityverifycode,\n" +
"\t'0000' as pk_org,\n" +
"\t'ZH-CN' as format,\n" +
"\t'Y' as isca,\n" +
"\t'2' as enablestate,\n" +
"\t'ZH' as contentlang,\n" +
"\ta.CODE as user_code_q,\n" +
"CASE\n" +
"\t\t\n" +
"\t\tWHEN EXT_ATTR_11 = '1' THEN\n" +
"\t\t'男' \n" +
"\t\tWHEN EXT_ATTR_11 = '2' THEN\n" +
"\t\t'女' ELSE NULL \n" +
"\tEND AS gender,\n" +
"CASE\n" +
"\t\t\n" +
"\t\tWHEN ( a.EXT_ATTR_1 IS NULL OR a.EXT_ATTR_1 = '' ) THEN\n" +
"\t\t'11111111111' ELSE a.EXT_ATTR_1 \n" +
"\tEND AS mobile \n" +
"FROM\n" +
"\torg_member a\n" +
"\tLEFT JOIN org_principal e ON a.id = e.MEMBER_ID WHERE 1=1 and e.LOGIN_NAME IS not null"+ sb.toString() );//
// " WHERE 1=1 and a.id = '-2698997042624247722'");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
int i = 0;
@ -246,7 +290,7 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
jsonStr.put("jsonStr", hashMap);
JsonResultEntity result = comparisonServiceimpl.updateEntity(jsonStr);
if(!result.isFlag()){
throw new BaseSystemException("主数据更新失败"+ result.getMsg());
//throw new BaseSystemException("主数据更新失败"+ result.getMsg());
}
}
}

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao;
import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity;
import com.hzya.frame.mdm.mdmModuleDb.entity.MdmModuleDbEntity;
import com.hzya.frame.mdm.mdmModuleDbFileds.entity.MdmModuleDbFiledsEntity;
@ -36,6 +37,8 @@ import java.util.stream.Collectors;
public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String> implements IComparisonService {
private IComparisonDao comparisonDao;
@Autowired
private IMdmModuleDao mdmModuleDao;
@Autowired
private IComparisonDetailsDao comparisonDetailsDao;
@ -96,6 +99,9 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
comparisonEntity.setMap(map);
try {
List<JSONObject> list=new ArrayList<>();
//查询所有列
List<String> fields = getFields(comparisonEntity);
comparisonEntity.setFields(fields);
//查询主表数据
List<Map<String,Object>> comparisonEntitiePages = comparisonDao.queryComparisonPage(comparisonEntity);
if(CollectionUtils.isNotEmpty(comparisonEntitiePages)){
@ -254,6 +260,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败");
}
}
@ -261,6 +268,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败");
}
try {
@ -318,6 +326,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
} else {
jsonObjectList.put(comparisonDetailsEntity.getDbName(), new ArrayList<>());
}
jsonObjectList.remove(null);
list.add(jsonObjectList);
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","1");
@ -326,6 +335,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("保存通用数据时候错误:{}", e.getMessage());
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","2");
return BaseResult.getFailureMessageEntity("保存失败");
}
}
@ -396,13 +406,15 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
List<List<Map<String,Object>>> mapDetails=new ArrayList<>();//将子表数据存到map中
if(comparisonEntities !=null && comparisonEntities.size()>0) {
map=spliceMainMap(comparisonEntities,jsonObjectMain,map,comparisonEntity,comparisonDetailsEntity);
//查询所有列
List<String> fields = getFields(comparisonEntity);
//根据data_id查询id.根据id更新主表数据,然后再根据主表id和明细表的data_id,删除明细表数据
Map<String,Object> mapId=new HashMap<>();
mapId.put("data_id",jsonObjectMain.getString("data_id"));
ComparisonEntity comparison=new ComparisonEntity();
comparison.setDbName(comparisonEntity.getDbName());
comparison.setMap(mapId);
comparison.setFields(fields);
List<Map<String,Object>> comparisonEntitiePages = comparisonDao.queryComparisonPage(comparison);
if(CollectionUtils.isEmpty(comparisonEntitiePages)){
return BaseResult.getFailureMessageEntity("根据data_id查询id数据为空请检查data_id");
@ -449,6 +461,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}else{
jsonObjectList.put(comparisonDetailsEntity.getDbName(),new ArrayList<>());
}
jsonObjectList.remove(null);
jsonObjects.add(jsonObjectList);
//保存操作日志
controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log","1");
@ -466,6 +479,12 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数");
}
private List<String> getFields(ComparisonEntity comparisonEntity) {
HashMap<String, Object> maps = new HashMap<>();
maps.put("tableName",comparisonEntity.getDbName());
return mdmModuleDao.queryMdMFields(maps);
}
//删除通用数据
@Override
public JsonResultEntity deleteEntity(JSONObject json) {
@ -527,13 +546,15 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
}
}
//查询所有列
List<String> fields = getFields(comparisonEntity);
//根据data_id查询主表id.根据id删除主表数据然后再根据主表id和明细表data_id删除明细表数据
Map<String,Object> mapId=new HashMap<>();
mapId.put("data_id",jsonObjectMain.getString("data_id"));
ComparisonEntity comparison=new ComparisonEntity();
comparison.setDbName(comparisonEntity.getDbName());
comparison.setMap(mapId);
comparison.setFields(fields);
List<Map<String,Object>> comparisonEntitiePages = comparisonDao.queryComparisonPage(comparison);
if(CollectionUtils.isEmpty(comparisonEntitiePages)){
return BaseResult.getFailureMessageEntity("根据data_id查询id数据为空请检查data_id");

View File

@ -11,6 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Groovy 脚本执行实现类
*
@ -31,7 +34,7 @@ public class GroovyIntegrationServiceImpl implements IGroovyIntegrationService {
}
public static void main(String[] args) {
java.lang.String str = "{\"data\":{\"enablestate\":\"2\",\"user_password\":\"Hzya@1314\",\"gender\":\"12312\",\"user_name\":\"测试用户\",\"modify_time\":1719305835000,\"document_rule_num\":112,\"pk_org\":{\"org_mnecode\":\"1\",\"modify_time\":1718866279000,\"document_rule_num\":4,\"add_status\":\"0\",\"org_address\":\"1\",\"delete_status\":\"1\",\"org_innercode\":\"1\",\"id\":\"f7a8cee35fce4aa8ab266b3c7f125d7d\",\"data_status\":\"F\",\"modify_user_id\":\"1\",\"org_name\":\"开发部\",\"sorts\":4,\"document_rule\":\"ZZ-2024-06-20-00004\",\"create_user_id\":\"1\",\"create_time\":1718864103000,\"company_id\":\"Y\",\"org_memo\":\"1\",\"update_status\":\"0\",\"sts\":\"Y\",\"org_tel\":\"1\",\"org_id\":\"Y\",\"org_ncindustry\":\"1\",\"org_fatherorg\":\"c4913dde8da142bab4206fc084269382\",\"org_code\":\"003\",\"org_principal\":\"1\",\"org_countryzone\":\"1\"},\"add_status\":\"0\",\"pwdlevelcode\":\"\",\"user_type\":\"1\",\"user_code\":\"17633965916\",\"delete_status\":\"1\",\"id\":\"d99fe4e1c211450a960f7a1057da0d2c\",\"data_status\":\"F\",\"modify_user_id\":\"1\",\"sorts\":346,\"document_rule\":\"YH-2024-06-25-00112\",\"create_user_id\":\"1\",\"create_time\":1719305229000,\"company_id\":\"Y\",\"user_code_q\":\"KP003\",\"format\":\"ZH-CN\",\"mobile\":\"123123\",\"identityverifycode\":\"静态密码验证\",\"islocked\":\"N\",\"update_status\":\"0\",\"base_doc_type\":\"0\",\"sts\":\"Y\",\"login_name\":\"123123\",\"pwdparam\":\"2024-06-17\",\"org_id\":\"Y\",\"abledate\":\"2024-06-17 00:00:00\",\"isca\":\"Y\",\"contentlang\":\"ZH\"},\"query\":\"[]\",\"header\":\"[{\\\"parameterType\\\":\\\"fundamental\\\",\\\"length\\\":\\\"100\\\",\\\"index\\\":0,\\\"description\\\":\\\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA87rrNR\\\",\\\"concreteType\\\":\\\"String\\\",\\\"id\\\":\\\"7127798c-b731-453a-b3ac-cfe9033eeace\\\",\\\"parameterName\\\":\\\"pubKey\\\",\\\"required\\\":true,\\\"example\\\":\\\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA87rrNREgMNeOEOwlvM2iqqEfshDadRHziDSB2PbRnoMqSv1nGr3XBlZuseNj5HmxDEkLhOdfyw0yjzoz3wK7XhFpeN4Iyf7NT7hps5jAQMEpnul9Qwmj5qUr/eK5SaO9H8n7sh9BvCdrX9oRUh+U2/ceA3O+y/MUHk5DRvSadc8FhpqbOaNBbAzPnyYAwpVUPvaJ90jcGN1ZG99HR1GEzC+Cn9s6vgt7dYL6ysMs36bSP47xraDSxpfr0CLwa6JV/9KjLIeqL1ZaMtK0CJ1zJGCBA6O6kgxeE9Ul7q2lSS6mPAEJ78izaTYsrjhLpKT+eTtFBOLFbiCrbLp8tVE5kwIDAQAB\\\"},{\\\"parameterType\\\":\\\"fundamental\\\",\\\"length\\\":\\\"50\\\",\\\"index\\\":1,\\\"description\\\":\\\"OA\\\",\\\"concreteType\\\":\\\"String\\\",\\\"id\\\":\\\"7f965281-df0f-4d2f-b005-07e061fcde49\\\",\\\"parameterName\\\":\\\"client_id\\\",\\\"required\\\":true,\\\"example\\\":\\\"OA\\\"},{\\\"parameterType\\\":\\\"authport\\\",\\\"length\\\":\\\"50\\\",\\\"index\\\":2,\\\"concreteType\\\":\\\"String\\\",\\\"id\\\":\\\"cbc0e105-17c0-4385-8863-8903303edc1f\\\",\\\"parameterName\\\":\\\"access_token\\\",\\\"example\\\":[\\\"attribute\\\",\\\"data\\\",\\\"access_token\\\"]}]\",\"body\":\"[{\\\"index\\\":0,\\\"id\\\":\\\"beeedbc6-24c2-4093-9a5e-20fced9fb1b4\\\",\\\"parameterName\\\":\\\"body\\\",\\\"first\\\":true}]\"}";
java.lang.String str = "{\"data\":{\"code\":\"test0628\",\"modify_time\":1719544020000,\"document_rule_num\":1,\"mdm_customer_bank\":[{\"create_user_id\":\"c796fd9ba4c9f5ff3cc2fa41a040e443\",\"accnum\":\"6234886523676743\",\"formmain_id\":\"-9194252578190768513\",\"create_time\":1719544020000,\"company_id\":\"0\",\"combinenum\":\"001421036014\",\"modify_time\":1719830508000,\"pk_bankdoc\":\"中国人民银行进贤县支行\",\"sts\":\"Y\",\"data_id\":\"5504698360056529043\",\"org_id\":\"0\",\"id\":\"7565801375982767614\",\"modify_user_id\":\"1\",\"data_status\":\"F\",\"sorts\":173}],\"pk_org\":{},\"add_status\":\"0\",\"data_id\":\"9026082101877884176\",\"delete_status\":\"1\",\"custprop_type\":\"项目\",\"id\":\"-9194252578190768513\",\"modify_user_id\":\"1\",\"data_status\":\"F\",\"sorts\":126,\"document_rule\":\"KH-2024-06-28-00001\",\"create_user_id\":\"c796fd9ba4c9f5ff3cc2fa41a040e443\",\"create_time\":1719544020000,\"update_status\":\"0\",\"sts\":\"Y\",\"pk_custclass\":\"K01\",\"org_id\":\"0\",\"name\":\"越城区人民医院\"},\"query\":\"[]\",\"header\":\"[]\",\"body\":\"[{\\\"index\\\":0,\\\"id\\\":\\\"23af8d17-7ab9-4d71-b357-6f4d04ac0706\\\",\\\"parameterName\\\":\\\"body\\\",\\\"first\\\":true}]\"}";
A88772 s = new A88772();
s.execute(str);
}
@ -43,47 +46,22 @@ public class GroovyIntegrationServiceImpl implements IGroovyIntegrationService {
com.alibaba.fastjson.JSONObject reqData = com.alibaba.fastjson.JSON.parseObject(jsonStr);
com.alibaba.fastjson.JSONObject data = reqData.getJSONObject("data");
com.alibaba.fastjson.JSONObject orger = data.getJSONObject("pk_org");
com.alibaba.fastjson.JSONObject ufinterfaceObject = new com.alibaba.fastjson.JSONObject();
ufinterfaceObject.put("account", "01");
ufinterfaceObject.put("billtype", "user");
ufinterfaceObject.put("isexchange", "Y");
ufinterfaceObject.put("roottag", "bill");
ufinterfaceObject.put("filename", "user0603");
ufinterfaceObject.put("sender", "OA");
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("user_name", data.get("user_name"));
billheadObject.put("user_code", data.get("user_code"));
billheadObject.put("user_password", "Hzya@1314");
billheadObject.put("pwdparam", data.get("pwdparam"));
billheadObject.put("abledate", data.get("abledate"));
billheadObject.put("islocked", data.get("islocked"));
billheadObject.put("user_type", data.get("user_type"));
billheadObject.put("base_doc_type", data.get("base_doc_type"));
billheadObject.put("identityverifycode", data.get("identityverifycode"));
if(orger != null ){
billheadObject.put("pk_org", orger.get("org_code"));
}
billheadObject.put("format", data.get("format"));
billheadObject.put("isca", data.get("isca"));
billheadObject.put("enablestate", data.get("enablestate"));
billheadObject.put("contentlang", data.get("contentlang"));
billheadObject.put("user_code_q", data.get("user_code_q"));
billObject.put("billhead", billheadObject);
ufinterfaceObject.put("bill", billObject);
bodys.put("ufinterface", ufinterfaceObject);
com.alibaba.fastjson.JSONObject mdm_customer = new com.alibaba.fastjson.JSONObject();
mdm_customer.put("code",data.getString("code"));
mdm_customer.put("custprop",data.getString("custprop"));
mdm_customer.put("custstate",data.getString("custstate"));
mdm_customer.put("enablestate",data.getString("enablestate"));
mdm_customer.put("name",data.getString("name"));
mdm_customer.put("name",data.getString("name"));
mdm_customer.put("name",data.getString("name"));
mdm_customer.put("name",data.getString("name"));
mdm_customer.put("name",data.getString("name"));
com.alibaba.fastjson.JSONArray datadetail = data.getJSONArray("mdm_customer_bank");
com.alibaba.fastjson.JSONArray mdm_customer_bank = new com.alibaba.fastjson.JSONArray();
bodys.put("mdm_customer", mdm_customer);
bodys.put("mdm_customer_bank", mdm_customer_bank);
returnObject.put("bodys",bodys.toJSONString());
return returnObject.toJSONString();
}
}

View File

@ -318,5 +318,25 @@ where id = #{id}
concat(replace(replace(DATE_FORMAT(now(),'%Y-%m-%d'),'-',''),'-',ifnull(max(right(task_code,4)), 0)+1)) end as task_code
from integration_task where sts='Y' and task_code like concat('%',substring(replace(DATE_FORMAT(now(),'%Y-%m-%d'),'-',''),1,10),'%')
</select>
<!--查询最大编码+1-->
<select id="IntegrationTaskEntity_maxCode" databaseId="oracle" resultMap="get-IntegrationTaskEntity-result">
SELECT decode(LENGTH(IFNULL(max(RIGHT (task_code, 4)), 0)+ 1),
1,concat(concat(
REPLACE (DATE_FORMAT(now(), '%Y-%m-%d'), '-', ''), '-', '000'), IFNULL(max(RIGHT (task_code, 4)), 0)+ 1),
2,concat(concat(
REPLACE (DATE_FORMAT(now(), '%Y-%m-%d'), '-', ''), '-', '00'), IFNULL(max(RIGHT (task_code, 4)), 0)+ 1),
3,concat(concat(
REPLACE (DATE_FORMAT(now(), '%Y-%m-%d'), '-', ''), '-', '0'), IFNULL(max(RIGHT (task_code, 4)), 0)+ 1),
concat(concat(
REPLACE (DATE_FORMAT(now(), '%Y-%m-%d'), '-', ''), '-', ''), IFNULL(max(RIGHT (task_code, 4)), 0)+ 1)) AS task_code
FROM
integration_task
WHERE
sts = 'Y'
AND task_code LIKE concat('%', substring(
REPLACE (DATE_FORMAT(now(), '%Y-%m-%d'), '-', ''), 1, 10), '%')
</select>
</mapper>

View File

@ -8,6 +8,8 @@ import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
import com.hzya.frame.sysnew.login.ILoginService;
import com.hzya.frame.sysnew.organ.dao.ISysOrganDao;
import com.hzya.frame.sysnew.organ.entity.SysOrganEntity;
import com.hzya.frame.sysnew.person.dao.ISysPersonDao;
import com.hzya.frame.sysnew.person.entity.SysPersonEntity;
import com.hzya.frame.sysnew.popedomInterface.entity.SysPopedomInterfaceEntity;
import com.hzya.frame.sysnew.popedomInterface.service.impl.InterfaceCache;
import com.hzya.frame.sysnew.sysInterface.entity.SysInterfaceEntity;
@ -37,6 +39,8 @@ public class LoginServiceImpl implements ILoginService {
@Resource
private ISysUserDao sysUserDao;
@Resource
private ISysPersonDao sysPersonDao;
@Resource
private ISysOrganDao sysOrganDao;
@Resource
@ -70,6 +74,12 @@ public class LoginServiceImpl implements ILoginService {
if (sysUserEntity.getState() == null || !"0".equals(sysUserEntity.getState())) {
return BaseResult.getFailureMessageEntity("当前用户已停用,请先启用");
}
if(sysUserEntity.getPersonId() != null &&!"".equals(sysUserEntity.getPersonId())){
SysPersonEntity sysPersonEntity = sysPersonDao.get(sysUserEntity.getPersonId());
if(sysPersonEntity != null && sysPersonEntity.getPersonName()!= null){
sysUserEntity.setPersonName(sysPersonEntity.getPersonName());
}
}
//校验当前登陆人是否有权限
//boolean flag = false;
//SysInterfaceEntity sysInterfaceEntity = (SysInterfaceEntity) interfaceCache.get("6","beanNameloginServiceinterfacNamedoLogin");

View File

@ -1,5 +1,6 @@
package com.hzya.frame.webapp.entrance.controler;
import com.hzya.frame.bip.v3.v2207.service.IBipSsoService;
import com.hzya.frame.sysnew.application.service.ISysApplicationService;
import com.hzya.frame.sys.entity.EsbReturnEntity;
import com.hzya.frame.sys.file.download.entity.FileDownloadEntity;
@ -29,6 +30,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -43,7 +46,8 @@ import java.nio.charset.StandardCharsets;
@RequestMapping("/entranceController")
public class EntranceController {
private final Logger logger = LoggerFactory.getLogger(EntranceController.class);
@Autowired
protected IBipSsoService bipSsoService;
@Autowired
@Qualifier(value = "entranceServiceImpl")
private IEntranceService entranceService;
@ -169,4 +173,11 @@ public class EntranceController {
public JsonResultEntity externalCallInterfaceToESB(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
return sysApplicationService.externalCallInterfaceToESB(servletRequest,servletResponse);
}
@RequestMapping(value = "/erpSso")
@ResponseBody
public String erpSso(HttpServletRequest request, HttpServletResponse response, String ticket) throws Exception {
response.sendRedirect(bipSsoService.erpSso(request,ticket));
return null;
}
}