主数据修改

This commit is contained in:
lvleigang 2024-06-20 08:43:33 +08:00
parent 772a2e86f5
commit 4e94526a30
11 changed files with 1099 additions and 344 deletions

View File

@ -2,7 +2,6 @@ package com.hzya.frame.plugin.mdmDistribute.plugin;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao;
@ -15,6 +14,8 @@ import com.hzya.frame.mdm.mdmModuleDistribute.dao.IMdmModuleDistributeDao;
import com.hzya.frame.mdm.mdmModuleDistribute.entity.MdmModuleDistributeEntity;
import com.hzya.frame.mdm.mdmModuleDistributeDetail.dao.IMdmModuleDistributeDetailDao;
import com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity;
import com.hzya.frame.mdm.mdmModuleSendLog.dao.IMdmModuleSendLogDao;
import com.hzya.frame.mdm.mdmModuleSendLog.entity.MdmModuleSendLogEntity;
import com.hzya.frame.mdm.service.IMdmServiceCache;
import com.hzya.frame.sysnew.application.api.dao.ISysApplicationApiDao;
import com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity;
@ -24,10 +25,9 @@ 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;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.sysnew.messageManageLog.entity.SysMessageManageLogEntity;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.http.HttpEntity;
@ -40,12 +40,12 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -78,6 +78,8 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
private IMdmModuleDao mdmModuleDao;
@Resource
private IMdmServiceCache mdmServiceCache;
@Resource
private IMdmModuleSendLogDao mdmModuleSendLogDao;
@Value("${ax.url}")
private String url ;
@ -387,45 +389,35 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
if(mdmModuleDistributeEntities == null || mdmModuleDistributeEntities.size() == 0){
continue;
}
for (int i1 = 0; i1 < mdmModuleDistributeEntities.size(); i1++) {
//查询主数据db
MdmModuleDbEntity queryMdmModuleDbEntity = new MdmModuleDbEntity();
queryMdmModuleDbEntity.setMdmId(mdmModuleEntities.get(i).getId());
List<MdmModuleDbEntity> mdmModuleDbEntities = mdmServiceCache.queryMdmModuleDb(queryMdmModuleDbEntity);
if(mdmModuleDbEntities == null || mdmModuleDbEntities.size() == 0){
continue;
}
//查询主数据字段
MdmModuleDbFiledsEntity queryFild = new MdmModuleDbFiledsEntity();
queryFild.setMdmId(mdmModuleEntities.get(i).getId());
List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities = mdmServiceCache.queryMdmModuleDbFileds(queryFild);
if(mdmModuleDbFiledsEntities == null || mdmModuleDbFiledsEntities.size() == 0){
continue;
}
//查询下发的配置
MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ;
mdmModuleDistributeDetailEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId());
mdmModuleDistributeDetailEntity.setSts("Y");
List<MdmModuleDistributeDetailEntity> mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity);
//查询主数据db
MdmModuleDbEntity queryMdmModuleDbEntity = new MdmModuleDbEntity();
queryMdmModuleDbEntity.setMdmId(mdmModuleEntities.get(i).getId());
List<MdmModuleDbEntity> mdmModuleDbEntities = mdmServiceCache.queryMdmModuleDb(queryMdmModuleDbEntity);
if(mdmModuleDbEntities == null || mdmModuleDbEntities.size() == 0){
continue;
}
//查询主数据字段
MdmModuleDbFiledsEntity queryFild = new MdmModuleDbFiledsEntity();
queryFild.setMdmId(mdmModuleEntities.get(i).getId());
List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities = mdmServiceCache.queryMdmModuleDbFileds(queryFild);
if(mdmModuleDbFiledsEntities == null || mdmModuleDbFiledsEntities.size() == 0){
continue;
}
//字段的规则
MdmModuleDbFiledsRuleEntity queryFildRule = new MdmModuleDbFiledsRuleEntity();
queryFildRule.setMdmId(mdmModuleEntities.get(i).getId());
queryFildRule.setRuleCode("service");
List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities = mdmModuleDbFiledsRuleDao.queryBase(queryFildRule);
//新增
doAdd(mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//修改
doUpdate(mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//删除
doDelete(mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
}
//查询一千条数据
//查询这一千条数据是否符合规则
//查询是否已经手动发送过只有新增校验查询发送日志是否已经有这条数据
//组装数据发送
//保存日志
//所有下发发送完成修改数据状态
}
}
logger.info("执行成功");
@ -436,6 +428,512 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
return BaseResult.getSuccessMessageEntity("执行成功");
}
private void doDelete(List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities, List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities, List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities) {
//查询一千条数据
String mainDb = null;
List<JSONObject> objects = new ArrayList<>();
for (int i2 = 0; i2 < mdmModuleDbEntities.size(); i2++) {
if("1".equals(mdmModuleDbEntities.get(i2).getDbType())) {
mainDb = mdmModuleDbEntities.get(i2).getDbName();
}
}
if(mainDb == null){
return;
}
Map<String, Object> map1 = new HashMap<>();
map1.put("tableName",mainDb);
map1.put("dataStatus", "N");
map1.put("deleteStatus", "0");
map1.put("size", 1000);
objects = mdmModuleDao.queryMdmSTs(map1);
if(objects == null || objects.size() == 0){
return;
}
for (int i1 = 0; i1 < mdmModuleDistributeEntities.size(); i1++) {
//查询下发的配置
MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ;
mdmModuleDistributeDetailEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId());
mdmModuleDistributeDetailEntity.setSts("Y");
List<MdmModuleDistributeDetailEntity> mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity);
//查询这一千条数据是否符合规则
Map<String, Object> map = new HashMap<>();
map.put("tableName", mainDb);
map.put("dataStatus", "N");
map.put("deleteStatus", "0");
map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities);
map.put("ids", objects);
List<JSONObject> doObjects = mdmModuleDao.queryMdmSTs(map);
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(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(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(objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
}
return ;
}
SysApplicationScriptEntity scriptEntity = null;
if(mdmModuleDistributeEntities.get(i1).getDeleteScript() != null && !"".equals(mdmModuleDistributeEntities.get(i1).getDeleteScript())){
scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getDeleteScript());
if(scriptEntity == null || scriptEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
}
return ;
}
}
for (int i = 0; i < doObjects.size(); i++) {
//查询发送日志是否已经有这条数据
MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity();
mdmModuleSendLogEntity.setTableName(mainDb+"_send_log");
mdmModuleSendLogEntity.setFormmainId(doObjects.get(i).getString("id"));
mdmModuleSendLogEntity.setSts("Y");
mdmModuleSendLogEntity.setOptionType("3");
Integer num = mdmModuleSendLogDao.getCount(mdmModuleSendLogEntity);
if(num > 0){//已经过不发送
continue;
}
getDetailData(mdmModuleDbEntities,doObjects.get(i),mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//执行脚本
JSONObject groovy = new JSONObject();
JSONObject parameterJson = new JSONObject();
parameterJson.put("header",apiEntity.getHeaderIn());
parameterJson.put("body",apiEntity.getBodyIn());
parameterJson.put("query",apiEntity.getQueryIn());
parameterJson.put("data",doObjects.get(i));
/** head */
Map<String, String> header = null;
/** query */
String querys = null;
/** body */
String bodys = doObjects.get(i).toJSONString();
if(scriptEntity != null && scriptEntity.getId() != null ){
groovy.put("code",scriptEntity.getScriptCode());
groovy.put("className",scriptEntity.getClassName());
groovy.put("name",scriptEntity.getScriptName());
groovy.put("methodStr",scriptEntity.getScriptData());
groovy.put("parameterJson",parameterJson);
JSONObject groovyStr = new JSONObject();
groovyStr.put("jsonStr",groovy);
try {
SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy);
header = jsonResultEntity.getHeaders();
querys = jsonResultEntity.getQuerys();
bodys = jsonResultEntity.getBodys();
}catch (Exception e){
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
continue;
}
}
Map<String, String> headers = new HashMap<>();
headers.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj");
headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=");
headers.put("appId",sysApplicationEntity.getAppId().toString());
headers.put("apiCode",apiEntity.getApiCode().toString());
if(header != null){
headers.putAll(header);
}
//组装数据发送
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
if(jsonResultEntity.isFlag()){
//保存日志
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
continue;
}else {
//保存日志
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"3");
continue;
}
}
}
//所有下发发送完成修改数据状态
for (int i = 0; i < objects.size(); i++) {
Map<String, Object> updateMap = new HashMap<>();
updateMap.put("tableName",mainDb);
updateMap.put("dataStatus", "N");
updateMap.put("deleteStatus", "1");
updateMap.put("id", objects.get(i).getString("id"));
mdmModuleDao.updateMdmSTs(updateMap);
}
}
private void doUpdate(List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities, List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities, List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities) {
//查询一千条数据
String mainDb = null;
List<JSONObject> objects = new ArrayList<>();
for (int i2 = 0; i2 < mdmModuleDbEntities.size(); i2++) {
if("1".equals(mdmModuleDbEntities.get(i2).getDbType())) {
mainDb = mdmModuleDbEntities.get(i2).getDbName();
}
}
if(mainDb == null){
return;
}
Map<String, Object> map1 = new HashMap<>();
map1.put("tableName",mainDb);
map1.put("dataStatus", "F");
map1.put("updateStatus", "0");
map1.put("size", 1000);
objects = mdmModuleDao.queryMdmSTs(map1);
if(objects == null || objects.size() == 0){
return;
}
for (int i1 = 0; i1 < mdmModuleDistributeEntities.size(); i1++) {
//查询下发的配置
MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ;
mdmModuleDistributeDetailEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId());
mdmModuleDistributeDetailEntity.setSts("Y");
List<MdmModuleDistributeDetailEntity> mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity);
//查询这一千条数据是否符合规则
Map<String, Object> map = new HashMap<>();
map.put("tableName", mainDb);
map.put("dataStatus", "F");
map.put("updateStatus", "0");
map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities);
map.put("ids", objects);
List<JSONObject> doObjects = mdmModuleDao.queryMdmSTs(map);
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(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(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(objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
}
return ;
}
SysApplicationScriptEntity scriptEntity = null;
if(mdmModuleDistributeEntities.get(i1).getUpdateScript() != null && !"".equals(mdmModuleDistributeEntities.get(i1).getUpdateScript())){
scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getUpdateScript());
if(scriptEntity == null || scriptEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
}
return ;
}
}
for (int i = 0; i < doObjects.size(); i++) {
getDetailData(mdmModuleDbEntities,doObjects.get(i),mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//执行脚本
JSONObject groovy = new JSONObject();
JSONObject parameterJson = new JSONObject();
parameterJson.put("header",apiEntity.getHeaderIn());
parameterJson.put("body",apiEntity.getBodyIn());
parameterJson.put("query",apiEntity.getQueryIn());
parameterJson.put("data",doObjects.get(i));
/** head */
Map<String, String> header = null;
/** query */
String querys = null;
/** body */
String bodys = doObjects.get(i).toJSONString();
if(scriptEntity != null && scriptEntity.getId() != null ){
groovy.put("code",scriptEntity.getScriptCode());
groovy.put("className",scriptEntity.getClassName());
groovy.put("name",scriptEntity.getScriptName());
groovy.put("methodStr",scriptEntity.getScriptData());
groovy.put("parameterJson",parameterJson);
JSONObject groovyStr = new JSONObject();
groovyStr.put("jsonStr",groovy);
try {
SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy);
header = jsonResultEntity.getHeaders();
querys = jsonResultEntity.getQuerys();
bodys = jsonResultEntity.getBodys();
}catch (Exception e){
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
continue;
}
}
Map<String, String> headers = new HashMap<>();
headers.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj");
headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=");
headers.put("appId",sysApplicationEntity.getAppId().toString());
headers.put("apiCode",apiEntity.getApiCode().toString());
if(header != null){
headers.putAll(header);
}
//组装数据发送
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
if(jsonResultEntity.isFlag()){
//保存日志
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
continue;
}else {
//保存日志
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"2");
continue;
}
}
}
//所有下发发送完成修改数据状态
for (int i = 0; i < objects.size(); i++) {
Map<String, Object> updateMap = new HashMap<>();
updateMap.put("tableName",mainDb);
updateMap.put("dataStatus", "F");
updateMap.put("updateStatus", "1");
updateMap.put("id", objects.get(i).getString("id"));
mdmModuleDao.updateMdmSTs(updateMap);
}
}
/**
* @Author lvleigang
* @Description 处理新增数据
* @Date 1:55 下午 2024/6/19
* @param mdmModuleDbEntities
* @param mdmModuleDistributeEntities
* @return void
**/
private void doAdd(List<MdmModuleDbEntity> mdmModuleDbEntities, List<MdmModuleDistributeEntity> mdmModuleDistributeEntities,List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntities,List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntities ) {
//查询一千条数据
String mainDb = null;
List<JSONObject> objects = new ArrayList<>();
for (int i2 = 0; i2 < mdmModuleDbEntities.size(); i2++) {
if("1".equals(mdmModuleDbEntities.get(i2).getDbType())) {
mainDb = mdmModuleDbEntities.get(i2).getDbName();
}
}
if(mainDb == null){
return;
}
Map<String, Object> map1 = new HashMap<>();
map1.put("tableName",mainDb);
map1.put("dataStatus", "Y");
map1.put("addStatus", "0");
map1.put("size", 1000);
objects = mdmModuleDao.queryMdmSTs(map1);
if(objects == null || objects.size() == 0){
return;
}
for (int i1 = 0; i1 < mdmModuleDistributeEntities.size(); i1++) {
//查询下发的配置
MdmModuleDistributeDetailEntity mdmModuleDistributeDetailEntity = new MdmModuleDistributeDetailEntity() ;
mdmModuleDistributeDetailEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId());
mdmModuleDistributeDetailEntity.setSts("Y");
List<MdmModuleDistributeDetailEntity> mdmModuleDistributeDetailEntities = mdmModuleDistributeDetailDao.queryBase(mdmModuleDistributeDetailEntity);
//查询这一千条数据是否符合规则
Map<String, Object> map = new HashMap<>();
map.put("tableName", mainDb);
map.put("dataStatus", "Y");
map.put("addStatus", "0");
map.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities);
map.put("ids", objects);
List<JSONObject> doObjects = mdmModuleDao.queryMdmSTs(map);
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(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(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(objects.get(i).getString("id"),null,apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
}
return ;
}
SysApplicationScriptEntity scriptEntity = null;
if(mdmModuleDistributeEntities.get(i1).getAddScript() != null && !"".equals(mdmModuleDistributeEntities.get(i1).getAddScript())){
scriptEntity = sysApplicationScriptDao.get(mdmModuleDistributeEntities.get(i1).getAddScript());
if(scriptEntity == null || scriptEntity.getId() == null ){
for (int i = 0; i < doObjects.size(); i++) {
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
}
return ;
}
}
for (int i = 0; i < doObjects.size(); i++) {
//查询是否已经手动发送过只有新增校验查询发送日志是否已经有这条数据
MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity();
mdmModuleSendLogEntity.setTableName(mainDb+"_send_log");
mdmModuleSendLogEntity.setFormmainId(doObjects.get(i).getString("id"));
mdmModuleSendLogEntity.setSts("Y");
mdmModuleSendLogEntity.setOptionType("1");
Integer num = mdmModuleSendLogDao.getCount(mdmModuleSendLogEntity);
if(num > 0){//已经新增过不发送
continue;
}
getDetailData(mdmModuleDbEntities,doObjects.get(i),mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities);
//执行脚本
JSONObject groovy = new JSONObject();
JSONObject parameterJson = new JSONObject();
parameterJson.put("header",apiEntity.getHeaderIn());
parameterJson.put("body",apiEntity.getBodyIn());
parameterJson.put("query",apiEntity.getQueryIn());
parameterJson.put("data",doObjects.get(i));
/** head */
Map<String, String> header = null;
/** query */
String querys = null;
/** body */
String bodys = doObjects.get(i).toJSONString();
if(scriptEntity != null && scriptEntity.getId() != null ){
groovy.put("code",scriptEntity.getScriptCode());
groovy.put("className",scriptEntity.getClassName());
groovy.put("name",scriptEntity.getScriptName());
groovy.put("methodStr",scriptEntity.getScriptData());
groovy.put("parameterJson",parameterJson);
JSONObject groovyStr = new JSONObject();
groovyStr.put("jsonStr",groovy);
try {
SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy);
header = jsonResultEntity.getHeaders();
querys = jsonResultEntity.getQuerys();
bodys = jsonResultEntity.getBodys();
}catch (Exception e){
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
}
Map<String, String> headers = new HashMap<>();
headers.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj");
headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=");
headers.put("appId",sysApplicationEntity.getAppId().toString());
headers.put("apiCode",apiEntity.getApiCode().toString());
if(header != null){
headers.putAll(header);
}
//组装数据发送
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
if(jsonResultEntity.isFlag()){
//保存日志
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}else {
//保存日志
saveMdmModuleSendLogEntity(objects.get(i).getString("id"),sysApplicationEntity.getName(),apiEntity.getApiName(),doObjects.get(i).toJSONString(),"1");
continue;
}
}
}
//所有下发发送完成修改数据状态
for (int i = 0; i < objects.size(); i++) {
Map<String, Object> updateMap = new HashMap<>();
updateMap.put("tableName",mainDb);
updateMap.put("dataStatus", "Y");
updateMap.put("addStatus", "1");
updateMap.put("id", objects.get(i).getString("id"));
mdmModuleDao.updateMdmSTs(updateMap);
}
}
private void saveMdmModuleSendLogEntity(String formmain_id,String target_app,String target_api,String source_data, String option_type) {
MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity();
mdmModuleSendLogEntity.setCreate();
mdmModuleSendLogEntity.setId(UUIDUtils.getUUID());
mdmModuleSendLogEntity.setSts("Y");
mdmModuleSendLogEntity.setCreate_user_id("1");
mdmModuleSendLogEntity.setModify_user_id("1");
mdmModuleSendLogEntity.setCreate_time(new Date());
mdmModuleSendLogEntity.setModify_time(new Date());
mdmModuleSendLogEntity.setOrg_id("0");
mdmModuleSendLogEntity.setCompanyId("0");
mdmModuleSendLogEntity.setFormmainId(formmain_id);
mdmModuleSendLogEntity.setTargetApp(target_app);
mdmModuleSendLogEntity.setTargetApi(target_api);
mdmModuleSendLogEntity.setSourceData(source_data);
mdmModuleSendLogEntity.setOptionType(option_type);
mdmModuleSendLogDao.save(mdmModuleSendLogEntity);
}
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.put("tableName",mdmModuleDbEntities.get(i).getDbName());
map.put("formmainId",object.getString("id"));
List<JSONObject> detail = mdmModuleDao.queryMdmSTDetail(map);
//查看主表是否有字段是关联的
if(detail != null && detail.size() > 0){
if(mdmModuleDbFiledsRuleEntities != null && mdmModuleDbFiledsRuleEntities.size() > 0){
for (int i1 = 0; i1 < mdmModuleDbFiledsRuleEntities.size(); i1++) {
if(mdmModuleDbFiledsRuleEntities.get(i1).getDbId().equals(mdmModuleDbEntities.get(i).getId())){
if(mdmModuleDbFiledsEntities != null && mdmModuleDbFiledsEntities.size() > 0){
for (int i2 = 0; i2 < mdmModuleDbFiledsEntities.size(); i2++) {
if(mdmModuleDbFiledsRuleEntities.get(i1).getFiledId().equals(mdmModuleDbFiledsEntities.get(i2).getId())){
for (int i3 = 0; i3 < detail.size(); i3++) {
Map<String,Object> mapDetail = new HashMap<>();
mapDetail.put("tableName",mdmModuleDbFiledsRuleEntities.get(i1).getRuleValue());
mapDetail.put("id",detail.get(i3).getString(mdmModuleDbFiledsEntities.get(i2).getEnName()));
JSONObject objectDetail = mdmModuleDao.queryMdmST(mapDetail);
detail.get(i3).put(mdmModuleDbFiledsEntities.get(i2).getEnName(),objectDetail);
}
}
}
}
}
}
}
}
object.put(mdmModuleDbEntities.get(i).getDbName(),detail);
}
}
return object;
}
private JsonResultEntity sendData(SysApplicationApiEntity applicationApiEntity, Map<String, String> headers ,String bodys ,String querys) {
StringBuffer urls = new StringBuffer(url);
if (querys != null) {

View File

@ -9,6 +9,8 @@ public class MdmQuery {
//分页
private Integer pageNum;
//分页
private Long mdmCode;
private Integer pageSize;
//表名
private String tableName;
@ -66,4 +68,12 @@ public class MdmQuery {
public void setDetailQueryCondition(List<MdmQuery> detailQueryCondition) {
this.detailQueryCondition = detailQueryCondition;
}
public Long getMdmCode() {
return mdmCode;
}
public void setMdmCode(Long mdmCode) {
this.mdmCode = mdmCode;
}
}

View File

@ -52,5 +52,8 @@ public interface IMdmModuleDao extends IBaseDao<MdmModuleEntity, String> {
JSONObject queryMdmST(Map<String, Object> maps);
List<JSONObject> queryMdmSTDetail(Map<String, String> maps);
List<JSONObject> queryMdmSTs(Map<String, Object> map);
void updateMdmSTs(Map<String, Object> updateMap);
}

View File

@ -152,6 +152,16 @@ public class MdmModuleDaoImpl extends MybatisGenericDao<MdmModuleEntity, String>
JSONObject o = (JSONObject) super.selectOne(getSqlIdPrifx() + "queryMdmST", maps);
return o;
}
@Override
public List<JSONObject> queryMdmSTs(Map<String, Object> maps) {
List<JSONObject> o = (List<JSONObject>) super.selectList(getSqlIdPrifx() + "queryMdmST", maps);
return o;
}
@Override
public void updateMdmSTs(Map<String, Object> maps) {
super.update(getSqlIdPrifx() + "updateMdmSTs", maps);
}
@Override
public List<JSONObject> queryMdmSTDetail(Map<String, String> maps) {

View File

@ -751,7 +751,8 @@ where id = #{id}
</insert>
<update id="deleteTemplateById" parameterType="com.hzya.frame.sys.entity.FormmainDeleteDto">
update ${tableName} set
sts='N',modify_time = now(),modify_user_id = #{loginId}
data_status ='N',modify_time = now(),modify_user_id = #{loginId}
<if test="formmain_id == null ">,delete_status = '0' </if>
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id !='' ">and id = #{id}</if>
<if test="formmain_id != null and formmain_id !='' ">and formmain_id = #{formmain_id}</if>
@ -761,7 +762,7 @@ where id = #{id}
<update id="deleteChilder" parameterType="com.hzya.frame.sys.entity.FormmainDeleteDto">
update ${tableName} set
sts='N',modify_time = now(),modify_user_id = #{loginId}
data_status='N',modify_time = now(),modify_user_id = #{loginId},delete_status = '0'
<trim prefix="where" prefixOverrides="and">
<if test="upIdFiled != null and upIdFiled !='' and upIdFiledValue != null and upIdFiledValue !=''">
and ${upIdFiled} like concat(#{upIdFiledValue},'%')
@ -803,6 +804,10 @@ where id = #{id}
select * 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>
<if test="addStatus != null and addStatus !='' ">and add_status = #{addStatus}</if>
<if test="updateStatus != null and updateStatus !='' ">and update_status = #{updateStatus}</if>
<if test="deleteStatus != null and deleteStatus !='' ">and delete_status = #{deleteStatus}</if>
<if test="id != null and id !='' ">and id = #{id}</if>
<if test="mdmModuleDistributeDetailEntities != null and mdmModuleDistributeDetailEntities.size>0">
AND
@ -825,16 +830,39 @@ where id = #{id}
#{item.filedVaule}
<choose>
<when test="item.connectionSymbol == '1'.toString() ">
and
<choose>
<when test="item.rightParenthesis == ')'.toString() ">
${item.rightParenthesis} and
</when>
<otherwise>
${item.rightParenthesis}
</otherwise>
</choose>
</when>
<when test="item.connectionSymbol == '2'.toString() ">
or
<choose>
<when test="item.rightParenthesis == ')'.toString() ">
${item.rightParenthesis} or
</when>
<otherwise>
${item.rightParenthesis}
</otherwise>
</choose>
</when>
<otherwise>
${item.rightParenthesis}
</otherwise>
</choose>
${item.rightParenthesis}
</foreach>
</if>
<if test="ids != null and ids.size>0">
AND id in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item.id}
</foreach>
</if>
and sts = 'Y'
<if test="size != null and size !='' ">limit #{size}</if>
</trim>
</select>
@ -843,5 +871,17 @@ where id = #{id}
parameterType="java.util.HashMap">
select * from ${tableName} where sts='Y' and formmain_id = #{formmainId}
</select>
<update id="updateMdmSTs" parameterType="java.util.HashMap">
update ${tableName} set
<trim prefixOverrides=",">
<if test="addStatus != null and addStatus !='' ">, add_status = #{addStatus}</if>
,modify_time = now()
</trim>
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id !='' ">and id = #{id}</if>
<if test="dataStatus != null and dataStatus !='' ">and data_status = #{dataStatus}</if>
</trim>
</update>
</mapper>

View File

@ -558,7 +558,7 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
documentRule.setShowType("1");
documentRule.setQueryType("1");
documentRule.setListType("1");
documentRule.setViewType("2");
documentRule.setViewType("1");
documentRule.setFiledLength("50");
documentRule.setCreate();
documentRule.setDataType("1");
@ -780,14 +780,14 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
data_status.setMdmId(entity.getMdmId());
data_status.setDbId(entity.getId());
data_status.setEnName("data_status");
data_status.setChName("数据状态 Y正常 N删除 F修改");
data_status.setChName("数据状态");
data_status.setFiledType("3");
data_status.setAddType("2");
data_status.setUpdateType("2");
data_status.setShowType("2");
data_status.setQueryType("2");
data_status.setListType("2");
data_status.setViewType("2");
data_status.setListType("1");
data_status.setViewType("1");
data_status.setFiledLength("1");
data_status.setCreate();
data_status.setDataType("1");

View File

@ -76,6 +76,14 @@
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<if test="roletype != null and roletype != ''">
and id in (
select
filed_id
from mdm_module_db_fileds_rule
where sts='Y' and rule_code = #{roletype} and rule_value = #{roleValue}
)
</if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>

View File

@ -2,30 +2,31 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.mdm.mdmModuleDistributeDetail.dao.impl.MdmModuleDistributeDetailDaoImpl">
<resultMap id="get-MdmModuleDistributeDetailEntity-result" type="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="mdmId" column="mdm_id" jdbcType="VARCHAR"/>
<result property="distributeId" column="distribute_id" jdbcType="VARCHAR"/>
<result property="apiId" column="api_id" jdbcType="VARCHAR"/>
<result property="dataType" column="data_type" jdbcType="VARCHAR"/>
<result property="leftBracket" column="left_bracket" jdbcType="VARCHAR"/>
<result property="filedId" column="filed_id" jdbcType="VARCHAR"/>
<result property="filedName" column="filed_name" jdbcType="VARCHAR"/>
<result property="compareType" column="compare_type" jdbcType="VARCHAR"/>
<result property="filedVaule" column="filed_vaule" jdbcType="VARCHAR"/>
<result property="connectionSymbol" column="connection_symbol" jdbcType="VARCHAR"/>
<result property="rightParenthesis" column="right_parenthesis" jdbcType="VARCHAR"/>
<result property="sorts" column="sorts" jdbcType="INTEGER"/>
<result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="get-MdmModuleDistributeDetailEntity-result"
type="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="mdmId" column="mdm_id" jdbcType="VARCHAR"/>
<result property="distributeId" column="distribute_id" jdbcType="VARCHAR"/>
<result property="apiId" column="api_id" jdbcType="VARCHAR"/>
<result property="dataType" column="data_type" jdbcType="VARCHAR"/>
<result property="leftBracket" column="left_bracket" jdbcType="VARCHAR"/>
<result property="filedId" column="filed_id" jdbcType="VARCHAR"/>
<result property="filedName" column="filed_name" jdbcType="VARCHAR"/>
<result property="compareType" column="compare_type" jdbcType="VARCHAR"/>
<result property="filedVaule" column="filed_vaule" jdbcType="VARCHAR"/>
<result property="connectionSymbol" column="connection_symbol" jdbcType="VARCHAR"/>
<result property="rightParenthesis" column="right_parenthesis" jdbcType="VARCHAR"/>
<result property="sorts" column="sorts" jdbcType="INTEGER"/>
<result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "MdmModuleDistributeDetailEntity_Base_Column_List">
<sql id="MdmModuleDistributeDetailEntity_Base_Column_List">
id
,mdm_id
,distribute_id
@ -47,274 +48,311 @@
,org_id
,company_id
</sql>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-MdmModuleDistributeDetailEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
select
<include refid="MdmModuleDistributeDetailEntity_Base_Column_List" />
from mdm_module_distribute_detail
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="mdmId != null and mdmId != ''"> and mdm_id = #{mdmId} </if>
<if test="distributeId != null and distributeId != ''"> and distribute_id = #{distributeId} </if>
<if test="apiId != null and apiId != ''"> and api_id = #{apiId} </if>
<if test="dataType != null and dataType != ''"> and data_type = #{dataType} </if>
<if test="leftBracket != null and leftBracket != ''"> and left_bracket = #{leftBracket} </if>
<if test="filedId != null and filedId != ''"> and filed_id = #{filedId} </if>
<if test="filedName != null and filedName != ''"> and filed_name = #{filedName} </if>
<if test="compareType != null and compareType != ''"> and compare_type = #{compareType} </if>
<if test="filedVaule != null and filedVaule != ''"> and filed_vaule = #{filedVaule} </if>
<if test="connectionSymbol != null and connectionSymbol != ''"> and connection_symbol = #{connectionSymbol} </if>
<if test="rightParenthesis != null and rightParenthesis != ''"> and right_parenthesis = #{rightParenthesis} </if>
<if test="sorts != null"> and sorts = #{sorts} </if>
<if test="create_user_id != null and create_user_id != ''"> and create_user_id = #{create_user_id} </if>
<if test="create_time != null"> and create_time = #{create_time} </if>
<if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id = #{modify_user_id} </if>
<if test="modify_time != null"> and modify_time = #{modify_time} </if>
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-MdmModuleDistributeDetailEntity-result"
parameterType="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
select
<include refid="MdmModuleDistributeDetailEntity_Base_Column_List"/>
from mdm_module_distribute_detail
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="mdmId != null and mdmId != ''">and mdm_id = #{mdmId}</if>
<if test="distributeId != null and distributeId != ''">and distribute_id = #{distributeId}</if>
<if test="apiId != null and apiId != ''">and api_id = #{apiId}</if>
<if test="dataType != null and dataType != ''">and data_type = #{dataType}</if>
<if test="leftBracket != null and leftBracket != ''">and left_bracket = #{leftBracket}</if>
<if test="filedId != null and filedId != ''">and filed_id = #{filedId}</if>
<if test="filedName != null and filedName != ''">and filed_name = #{filedName}</if>
<if test="compareType != null and compareType != ''">and compare_type = #{compareType}</if>
<if test="filedVaule != null and filedVaule != ''">and filed_vaule = #{filedVaule}</if>
<if test="connectionSymbol != null and connectionSymbol != ''">and connection_symbol = #{connectionSymbol}
</if>
<if test="rightParenthesis != null and rightParenthesis != ''">and right_parenthesis = #{rightParenthesis}
</if>
<if test="sorts != null">and sorts = #{sorts}</if>
<if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
<if test="create_time != null">and create_time = #{create_time}</if>
<if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
<if test="modify_time != null">and modify_time = #{modify_time}</if>
<if test="sts != null and sts != ''">and sts = #{sts}</if>
<if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
<if test="companyId != null and companyId != ''">and company_id = #{companyId}</if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
select count(1) from mdm_module_distribute_detail
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="mdmId != null and mdmId != ''"> and mdm_id = #{mdmId} </if>
<if test="distributeId != null and distributeId != ''"> and distribute_id = #{distributeId} </if>
<if test="apiId != null and apiId != ''"> and api_id = #{apiId} </if>
<if test="dataType != null and dataType != ''"> and data_type = #{dataType} </if>
<if test="leftBracket != null and leftBracket != ''"> and left_bracket = #{leftBracket} </if>
<if test="filedId != null and filedId != ''"> and filed_id = #{filedId} </if>
<if test="filedName != null and filedName != ''"> and filed_name = #{filedName} </if>
<if test="compareType != null and compareType != ''"> and compare_type = #{compareType} </if>
<if test="filedVaule != null and filedVaule != ''"> and filed_vaule = #{filedVaule} </if>
<if test="connectionSymbol != null and connectionSymbol != ''"> and connection_symbol = #{connectionSymbol} </if>
<if test="rightParenthesis != null and rightParenthesis != ''"> and right_parenthesis = #{rightParenthesis} </if>
<if test="sorts != null"> and sorts = #{sorts} </if>
<if test="create_user_id != null and create_user_id != ''"> and create_user_id = #{create_user_id} </if>
<if test="create_time != null"> and create_time = #{create_time} </if>
<if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id = #{modify_user_id} </if>
<if test="modify_time != null"> and modify_time = #{modify_time} </if>
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
</trim>
<if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer"
parameterType="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
select count(1) from mdm_module_distribute_detail
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="mdmId != null and mdmId != ''">and mdm_id = #{mdmId}</if>
<if test="distributeId != null and distributeId != ''">and distribute_id = #{distributeId}</if>
<if test="apiId != null and apiId != ''">and api_id = #{apiId}</if>
<if test="dataType != null and dataType != ''">and data_type = #{dataType}</if>
<if test="leftBracket != null and leftBracket != ''">and left_bracket = #{leftBracket}</if>
<if test="filedId != null and filedId != ''">and filed_id = #{filedId}</if>
<if test="filedName != null and filedName != ''">and filed_name = #{filedName}</if>
<if test="compareType != null and compareType != ''">and compare_type = #{compareType}</if>
<if test="filedVaule != null and filedVaule != ''">and filed_vaule = #{filedVaule}</if>
<if test="connectionSymbol != null and connectionSymbol != ''">and connection_symbol = #{connectionSymbol}
</if>
<if test="rightParenthesis != null and rightParenthesis != ''">and right_parenthesis = #{rightParenthesis}
</if>
<if test="sorts != null">and sorts = #{sorts}</if>
<if test="create_user_id != null and create_user_id != ''">and create_user_id = #{create_user_id}</if>
<if test="create_time != null">and create_time = #{create_time}</if>
<if test="modify_user_id != null and modify_user_id != ''">and modify_user_id = #{modify_user_id}</if>
<if test="modify_time != null">and modify_time = #{modify_time}</if>
<if test="sts != null and sts != ''">and sts = #{sts}</if>
<if test="org_id != null and org_id != ''">and org_id = #{org_id}</if>
<if test="companyId != null and companyId != ''">and company_id = #{companyId}</if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
</trim>
<if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
<!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-MdmModuleDistributeDetailEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
select
<include refid="MdmModuleDistributeDetailEntity_Base_Column_List" />
from mdm_module_distribute_detail
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id like concat('%',#{id},'%') </if>
<if test="mdmId != null and mdmId != ''"> and mdm_id like concat('%',#{mdmId},'%') </if>
<if test="distributeId != null and distributeId != ''"> and distribute_id like concat('%',#{distributeId},'%') </if>
<if test="apiId != null and apiId != ''"> and api_id like concat('%',#{apiId},'%') </if>
<if test="dataType != null and dataType != ''"> and data_type like concat('%',#{dataType},'%') </if>
<if test="leftBracket != null and leftBracket != ''"> and left_bracket like concat('%',#{leftBracket},'%') </if>
<if test="filedId != null and filedId != ''"> and filed_id like concat('%',#{filedId},'%') </if>
<if test="filedName != null and filedName != ''"> and filed_name like concat('%',#{filedName},'%') </if>
<if test="compareType != null and compareType != ''"> and compare_type like concat('%',#{compareType},'%') </if>
<if test="filedVaule != null and filedVaule != ''"> and filed_vaule like concat('%',#{filedVaule},'%') </if>
<if test="connectionSymbol != null and connectionSymbol != ''"> and connection_symbol like concat('%',#{connectionSymbol},'%') </if>
<if test="rightParenthesis != null and rightParenthesis != ''"> and right_parenthesis like concat('%',#{rightParenthesis},'%') </if>
<if test="sorts != null"> and sorts like concat('%',#{sorts},'%') </if>
<if test="create_user_id != null and create_user_id != ''"> and create_user_id like concat('%',#{create_user_id},'%') </if>
<if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
<if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
<if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
<if test="org_id != null and org_id != ''"> and org_id like concat('%',#{org_id},'%') </if>
<if test="companyId != null and companyId != ''"> and company_id like concat('%',#{companyId},'%') </if>
<select id="entity_list_like" resultMap="get-MdmModuleDistributeDetailEntity-result"
parameterType="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
select
<include refid="MdmModuleDistributeDetailEntity_Base_Column_List"/>
from mdm_module_distribute_detail
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''">and id like concat('%',#{id},'%')</if>
<if test="mdmId != null and mdmId != ''">and mdm_id like concat('%',#{mdmId},'%')</if>
<if test="distributeId != null and distributeId != ''">and distribute_id like
concat('%',#{distributeId},'%')
</if>
<if test="apiId != null and apiId != ''">and api_id like concat('%',#{apiId},'%')</if>
<if test="dataType != null and dataType != ''">and data_type like concat('%',#{dataType},'%')</if>
<if test="leftBracket != null and leftBracket != ''">and left_bracket like concat('%',#{leftBracket},'%')
</if>
<if test="filedId != null and filedId != ''">and filed_id like concat('%',#{filedId},'%')</if>
<if test="filedName != null and filedName != ''">and filed_name like concat('%',#{filedName},'%')</if>
<if test="compareType != null and compareType != ''">and compare_type like concat('%',#{compareType},'%')
</if>
<if test="filedVaule != null and filedVaule != ''">and filed_vaule like concat('%',#{filedVaule},'%')</if>
<if test="connectionSymbol != null and connectionSymbol != ''">and connection_symbol like
concat('%',#{connectionSymbol},'%')
</if>
<if test="rightParenthesis != null and rightParenthesis != ''">and right_parenthesis like
concat('%',#{rightParenthesis},'%')
</if>
<if test="sorts != null">and sorts like concat('%',#{sorts},'%')</if>
<if test="create_user_id != null and create_user_id != ''">and create_user_id like
concat('%',#{create_user_id},'%')
</if>
<if test="create_time != null">and create_time like concat('%',#{create_time},'%')</if>
<if test="modify_user_id != null and modify_user_id != ''">and modify_user_id like
concat('%',#{modify_user_id},'%')
</if>
<if test="modify_time != null">and modify_time like concat('%',#{modify_time},'%')</if>
<if test="sts != null and sts != ''">and sts like concat('%',#{sts},'%')</if>
<if test="org_id != null and org_id != ''">and org_id like concat('%',#{org_id},'%')</if>
<if test="companyId != null and companyId != ''">and company_id like concat('%',#{companyId},'%')</if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
</trim>
<if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
<!-- 查询列表 字段采用or格式 -->
<select id="MdmModuleDistributeDetailentity_list_or" resultMap="get-MdmModuleDistributeDetailEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
select
<include refid="MdmModuleDistributeDetailEntity_Base_Column_List" />
from mdm_module_distribute_detail
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> or id = #{id} </if>
<if test="mdmId != null and mdmId != ''"> or mdm_id = #{mdmId} </if>
<if test="distributeId != null and distributeId != ''"> or distribute_id = #{distributeId} </if>
<if test="apiId != null and apiId != ''"> or api_id = #{apiId} </if>
<if test="dataType != null and dataType != ''"> or data_type = #{dataType} </if>
<if test="leftBracket != null and leftBracket != ''"> or left_bracket = #{leftBracket} </if>
<if test="filedId != null and filedId != ''"> or filed_id = #{filedId} </if>
<if test="filedName != null and filedName != ''"> or filed_name = #{filedName} </if>
<if test="compareType != null and compareType != ''"> or compare_type = #{compareType} </if>
<if test="filedVaule != null and filedVaule != ''"> or filed_vaule = #{filedVaule} </if>
<if test="connectionSymbol != null and connectionSymbol != ''"> or connection_symbol = #{connectionSymbol} </if>
<if test="rightParenthesis != null and rightParenthesis != ''"> or right_parenthesis = #{rightParenthesis} </if>
<if test="sorts != null"> or sorts = #{sorts} </if>
<if test="create_user_id != null and create_user_id != ''"> or create_user_id = #{create_user_id} </if>
<if test="create_time != null"> or create_time = #{create_time} </if>
<if test="modify_user_id != null and modify_user_id != ''"> or modify_user_id = #{modify_user_id} </if>
<if test="modify_time != null"> or modify_time = #{modify_time} </if>
<if test="sts != null and sts != ''"> or sts = #{sts} </if>
<if test="org_id != null and org_id != ''"> or org_id = #{org_id} </if>
<if test="companyId != null and companyId != ''"> or company_id = #{companyId} </if>
<!-- 查询列表 字段采用or格式 -->
<select id="MdmModuleDistributeDetailentity_list_or" resultMap="get-MdmModuleDistributeDetailEntity-result"
parameterType="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
select
<include refid="MdmModuleDistributeDetailEntity_Base_Column_List"/>
from mdm_module_distribute_detail
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''">or id = #{id}</if>
<if test="mdmId != null and mdmId != ''">or mdm_id = #{mdmId}</if>
<if test="distributeId != null and distributeId != ''">or distribute_id = #{distributeId}</if>
<if test="apiId != null and apiId != ''">or api_id = #{apiId}</if>
<if test="dataType != null and dataType != ''">or data_type = #{dataType}</if>
<if test="leftBracket != null and leftBracket != ''">or left_bracket = #{leftBracket}</if>
<if test="filedId != null and filedId != ''">or filed_id = #{filedId}</if>
<if test="filedName != null and filedName != ''">or filed_name = #{filedName}</if>
<if test="compareType != null and compareType != ''">or compare_type = #{compareType}</if>
<if test="filedVaule != null and filedVaule != ''">or filed_vaule = #{filedVaule}</if>
<if test="connectionSymbol != null and connectionSymbol != ''">or connection_symbol = #{connectionSymbol}
</if>
<if test="rightParenthesis != null and rightParenthesis != ''">or right_parenthesis = #{rightParenthesis}
</if>
<if test="sorts != null">or sorts = #{sorts}</if>
<if test="create_user_id != null and create_user_id != ''">or create_user_id = #{create_user_id}</if>
<if test="create_time != null">or create_time = #{create_time}</if>
<if test="modify_user_id != null and modify_user_id != ''">or modify_user_id = #{modify_user_id}</if>
<if test="modify_time != null">or modify_time = #{modify_time}</if>
<if test="sts != null and sts != ''">or sts = #{sts}</if>
<if test="org_id != null and org_id != ''">or org_id = #{org_id}</if>
<if test="companyId != null and companyId != ''">or company_id = #{companyId}</if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
</trim>
<if test=" sort == null or sort == ''.toString() ">order by sorts asc</if>
<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
insert into mdm_module_distribute_detail(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> id , </if>
<if test="mdmId != null and mdmId != ''"> mdm_id , </if>
<if test="distributeId != null and distributeId != ''"> distribute_id , </if>
<if test="apiId != null and apiId != ''"> api_id , </if>
<if test="dataType != null and dataType != ''"> data_type , </if>
<if test="leftBracket != null and leftBracket != ''"> left_bracket , </if>
<if test="filedId != null and filedId != ''"> filed_id , </if>
<if test="filedName != null and filedName != ''"> filed_name , </if>
<if test="compareType != null and compareType != ''"> compare_type , </if>
<if test="filedVaule != null and filedVaule != ''"> filed_vaule , </if>
<if test="connectionSymbol != null and connectionSymbol != ''"> connection_symbol , </if>
<if test="rightParenthesis != null and rightParenthesis != ''"> right_parenthesis , </if>
<if test="sorts != null"> sorts , </if>
<if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
<if test="create_time != null"> create_time , </if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
<if test="modify_time != null"> modify_time , </if>
<if test="sts != null and sts != ''"> sts , </if>
<if test="org_id != null and org_id != ''"> org_id , </if>
<if test="companyId != null and companyId != ''"> company_id , </if>
<!--新增所有列-->
<insert id="entity_insert"
parameterType="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
insert into mdm_module_distribute_detail(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''">id ,</if>
<if test="mdmId != null and mdmId != ''">mdm_id ,</if>
<if test="distributeId != null and distributeId != ''">distribute_id ,</if>
<if test="apiId != null and apiId != ''">api_id ,</if>
<if test="dataType != null and dataType != ''">data_type ,</if>
<if test="leftBracket != null and leftBracket != ''">left_bracket ,</if>
<if test="filedId != null and filedId != ''">filed_id ,</if>
<if test="filedName != null and filedName != ''">filed_name ,</if>
<if test="compareType != null and compareType != ''">compare_type ,</if>
<if test="filedVaule != null and filedVaule != ''">filed_vaule ,</if>
<if test="connectionSymbol != null and connectionSymbol != ''">connection_symbol ,</if>
<if test="rightParenthesis != null and rightParenthesis != ''">right_parenthesis ,</if>
<if test="sorts != null">sorts ,</if>
<if test="create_user_id != null and create_user_id != ''">create_user_id ,</if>
<if test="create_time != null">create_time ,</if>
<if test="modify_user_id != null and modify_user_id != ''">modify_user_id ,</if>
<if test="modify_time != null">modify_time ,</if>
<if test="sts != null and sts != ''">sts ,</if>
<if test="org_id != null and org_id != ''">org_id ,</if>
<if test="companyId != null and companyId != ''">company_id ,</if>
<if test="sorts == null ">sorts,</if>
<if test="sts == null ">sts,</if>
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> #{id} ,</if>
<if test="mdmId != null and mdmId != ''"> #{mdmId} ,</if>
<if test="distributeId != null and distributeId != ''"> #{distributeId} ,</if>
<if test="apiId != null and apiId != ''"> #{apiId} ,</if>
<if test="dataType != null and dataType != ''"> #{dataType} ,</if>
<if test="leftBracket != null and leftBracket != ''"> #{leftBracket} ,</if>
<if test="filedId != null and filedId != ''"> #{filedId} ,</if>
<if test="filedName != null and filedName != ''"> #{filedName} ,</if>
<if test="compareType != null and compareType != ''"> #{compareType} ,</if>
<if test="filedVaule != null and filedVaule != ''"> #{filedVaule} ,</if>
<if test="connectionSymbol != null and connectionSymbol != ''"> #{connectionSymbol} ,</if>
<if test="rightParenthesis != null and rightParenthesis != ''"> #{rightParenthesis} ,</if>
<if test="sorts != null"> #{sorts} ,</if>
<if test="create_user_id != null and create_user_id != ''"> #{create_user_id} ,</if>
<if test="create_time != null"> #{create_time} ,</if>
<if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} ,</if>
<if test="modify_time != null"> #{modify_time} ,</if>
<if test="sts != null and sts != ''"> #{sts} ,</if>
<if test="org_id != null and org_id != ''"> #{org_id} ,</if>
<if test="companyId != null and companyId != ''"> #{companyId} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from mdm_module_distribute_detail a WHERE a.sts = 'Y' ),</if>
<if test="sts == null ">'Y',</if>
</trim>
)
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" >
insert into mdm_module_distribute_detail(mdm_id, distribute_id, api_id, data_type, left_bracket, filed_id, filed_name, compare_type, filed_vaule, connection_symbol, right_parenthesis, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, sts)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.mdmId},#{entity.distributeId},#{entity.apiId},#{entity.dataType},#{entity.leftBracket},#{entity.filedId},#{entity.filedName},#{entity.compareType},#{entity.filedVaule},#{entity.connectionSymbol},#{entity.rightParenthesis},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId}, 'Y')
</foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" >
insert into mdm_module_distribute_detail(mdm_id, distribute_id, api_id, data_type, left_bracket, filed_id, filed_name, compare_type, filed_vaule, connection_symbol, right_parenthesis, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.mdmId},#{entity.distributeId},#{entity.apiId},#{entity.dataType},#{entity.leftBracket},#{entity.filedId},#{entity.filedName},#{entity.compareType},#{entity.filedVaule},#{entity.connectionSymbol},#{entity.rightParenthesis},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId})
</foreach>
on duplicate key update
mdm_id = values(mdm_id),
distribute_id = values(distribute_id),
api_id = values(api_id),
data_type = values(data_type),
left_bracket = values(left_bracket),
filed_id = values(filed_id),
filed_name = values(filed_name),
compare_type = values(compare_type),
filed_vaule = values(filed_vaule),
connection_symbol = values(connection_symbol),
right_parenthesis = values(right_parenthesis),
create_user_id = values(create_user_id),
create_time = values(create_time),
modify_user_id = values(modify_user_id),
modify_time = values(modify_time),
sts = values(sts),
org_id = values(org_id),
company_id = values(company_id)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
update mdm_module_distribute_detail set
<trim suffix="" suffixOverrides=",">
<if test="mdmId != null and mdmId != ''"> mdm_id = #{mdmId},</if>
<if test="distributeId != null and distributeId != ''"> distribute_id = #{distributeId},</if>
<if test="apiId != null and apiId != ''"> api_id = #{apiId},</if>
<if test="dataType != null and dataType != ''"> data_type = #{dataType},</if>
<if test="leftBracket != null and leftBracket != ''"> left_bracket = #{leftBracket},</if>
<if test="filedId != null and filedId != ''"> filed_id = #{filedId},</if>
<if test="filedName != null and filedName != ''"> filed_name = #{filedName},</if>
<if test="compareType != null and compareType != ''"> compare_type = #{compareType},</if>
<if test="filedVaule != null and filedVaule != ''"> filed_vaule = #{filedVaule},</if>
<if test="connectionSymbol != null and connectionSymbol != ''"> connection_symbol = #{connectionSymbol},</if>
<if test="rightParenthesis != null and rightParenthesis != ''"> right_parenthesis = #{rightParenthesis},</if>
<if test="create_user_id != null and create_user_id != ''"> create_user_id = #{create_user_id},</if>
<if test="create_time != null"> create_time = #{create_time},</if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id = #{modify_user_id},</if>
<if test="modify_time != null"> modify_time = #{modify_time},</if>
<if test="sts != null and sts != ''"> sts = #{sts},</if>
<if test="org_id != null and org_id != ''"> org_id = #{org_id},</if>
<if test="companyId != null and companyId != ''"> company_id = #{companyId},</if>
</trim>
where id = #{id}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
<if test="sts == null ">sts,</if>
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''">#{id} ,</if>
<if test="mdmId != null and mdmId != ''">#{mdmId} ,</if>
<if test="distributeId != null and distributeId != ''">#{distributeId} ,</if>
<if test="apiId != null and apiId != ''">#{apiId} ,</if>
<if test="dataType != null and dataType != ''">#{dataType} ,</if>
<if test="leftBracket != null and leftBracket != ''">#{leftBracket} ,</if>
<if test="filedId != null and filedId != ''">#{filedId} ,</if>
<if test="filedName != null and filedName != ''">#{filedName} ,</if>
<if test="compareType != null and compareType != ''">#{compareType} ,</if>
<if test="filedVaule != null and filedVaule != ''">#{filedVaule} ,</if>
<if test="connectionSymbol != null and connectionSymbol != ''">#{connectionSymbol} ,</if>
<if test="rightParenthesis != null and rightParenthesis != ''">#{rightParenthesis} ,</if>
<if test="sorts != null">#{sorts} ,</if>
<if test="create_user_id != null and create_user_id != ''">#{create_user_id} ,</if>
<if test="create_time != null">#{create_time} ,</if>
<if test="modify_user_id != null and modify_user_id != ''">#{modify_user_id} ,</if>
<if test="modify_time != null">#{modify_time} ,</if>
<if test="sts != null and sts != ''">#{sts} ,</if>
<if test="org_id != null and org_id != ''">#{org_id} ,</if>
<if test="companyId != null and companyId != ''">#{companyId} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from mdm_module_distribute_detail
a WHERE a.sts = 'Y' ),
</if>
<if test="sts == null ">'Y',</if>
</trim>
)
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch">
insert into mdm_module_distribute_detail(mdm_id, distribute_id, api_id, data_type, left_bracket, filed_id,
filed_name, compare_type, filed_vaule, connection_symbol, right_parenthesis, create_user_id, create_time,
modify_user_id, modify_time, sts, org_id, company_id, sts)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.mdmId},#{entity.distributeId},#{entity.apiId},#{entity.dataType},#{entity.leftBracket},#{entity.filedId},#{entity.filedName},#{entity.compareType},#{entity.filedVaule},#{entity.connectionSymbol},#{entity.rightParenthesis},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},
'Y')
</foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch">
insert into mdm_module_distribute_detail(mdm_id, distribute_id, api_id, data_type, left_bracket, filed_id,
filed_name, compare_type, filed_vaule, connection_symbol, right_parenthesis, create_user_id, create_time,
modify_user_id, modify_time, sts, org_id, company_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.mdmId},#{entity.distributeId},#{entity.apiId},#{entity.dataType},#{entity.leftBracket},#{entity.filedId},#{entity.filedName},#{entity.compareType},#{entity.filedVaule},#{entity.connectionSymbol},#{entity.rightParenthesis},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId})
</foreach>
on duplicate key update
mdm_id = values(mdm_id),
distribute_id = values(distribute_id),
api_id = values(api_id),
data_type = values(data_type),
left_bracket = values(left_bracket),
filed_id = values(filed_id),
filed_name = values(filed_name),
compare_type = values(compare_type),
filed_vaule = values(filed_vaule),
connection_symbol = values(connection_symbol),
right_parenthesis = values(right_parenthesis),
create_user_id = values(create_user_id),
create_time = values(create_time),
modify_user_id = values(modify_user_id),
modify_time = values(modify_time),
sts = values(sts),
org_id = values(org_id),
company_id = values(company_id)
</insert>
<!--通过主键修改方法-->
<update id="entity_update"
parameterType="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
update mdm_module_distribute_detail set
<trim suffix="" suffixOverrides=",">
<if test="mdmId != null and mdmId != ''">mdm_id = #{mdmId},</if>
<if test="distributeId != null and distributeId != ''">distribute_id = #{distributeId},</if>
<if test="apiId != null and apiId != ''">api_id = #{apiId},</if>
<if test="dataType != null and dataType != ''">data_type = #{dataType},</if>
left_bracket = #{leftBracket},
filed_id = #{filedId},
filed_name = #{filedName},
compare_type = #{compareType},
filed_vaule = #{filedVaule},
connection_symbol = #{connectionSymbol},
right_parenthesis = #{rightParenthesis},
<if test="create_user_id != null and create_user_id != ''">create_user_id = #{create_user_id},</if>
<if test="create_time != null">create_time = #{create_time},</if>
<if test="modify_user_id != null and modify_user_id != ''">modify_user_id = #{modify_user_id},</if>
<if test="modify_time != null">modify_time = #{modify_time},</if>
<if test="sts != null and sts != ''">sts = #{sts},</if>
<if test="org_id != null and org_id != ''">org_id = #{org_id},</if>
<if test="companyId != null and companyId != ''">company_id = #{companyId},</if>
</trim>
where id = #{id}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete"
parameterType="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
update mdm_module_distribute_detail set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity" >
update mdm_module_distribute_detail set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''"> and id = #{id} </if>
<if test="mdmId != null and mdmId != ''"> and mdm_id = #{mdmId} </if>
<if test="distributeId != null and distributeId != ''"> and distribute_id = #{distributeId} </if>
<if test="apiId != null and apiId != ''"> and api_id = #{apiId} </if>
<if test="dataType != null and dataType != ''"> and data_type = #{dataType} </if>
<if test="leftBracket != null and leftBracket != ''"> and left_bracket = #{leftBracket} </if>
<if test="filedId != null and filedId != ''"> and filed_id = #{filedId} </if>
<if test="filedName != null and filedName != ''"> and filed_name = #{filedName} </if>
<if test="compareType != null and compareType != ''"> and compare_type = #{compareType} </if>
<if test="filedVaule != null and filedVaule != ''"> and filed_vaule = #{filedVaule} </if>
<if test="connectionSymbol != null and connectionSymbol != ''"> and connection_symbol = #{connectionSymbol} </if>
<if test="rightParenthesis != null and rightParenthesis != ''"> and right_parenthesis = #{rightParenthesis} </if>
<if test="sorts != null"> and sorts = #{sorts} </if>
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition"
parameterType="com.hzya.frame.mdm.mdmModuleDistributeDetail.entity.MdmModuleDistributeDetailEntity">
update mdm_module_distribute_detail set sts= 'N' ,modify_time = #{modify_time},modify_user_id =
#{modify_user_id}
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="mdmId != null and mdmId != ''">and mdm_id = #{mdmId}</if>
<if test="distributeId != null and distributeId != ''">and distribute_id = #{distributeId}</if>
<if test="apiId != null and apiId != ''">and api_id = #{apiId}</if>
<if test="dataType != null and dataType != ''">and data_type = #{dataType}</if>
<if test="leftBracket != null and leftBracket != ''">and left_bracket = #{leftBracket}</if>
<if test="filedId != null and filedId != ''">and filed_id = #{filedId}</if>
<if test="filedName != null and filedName != ''">and filed_name = #{filedName}</if>
<if test="compareType != null and compareType != ''">and compare_type = #{compareType}</if>
<if test="filedVaule != null and filedVaule != ''">and filed_vaule = #{filedVaule}</if>
<if test="connectionSymbol != null and connectionSymbol != ''">and connection_symbol = #{connectionSymbol}
</if>
<if test="rightParenthesis != null and rightParenthesis != ''">and right_parenthesis = #{rightParenthesis}
</if>
<if test="sorts != null">and sorts = #{sorts}</if>
<if test="sts != null and sts != ''">and sts = #{sts}</if>
<if test="companyId != null and companyId != ''">and company_id = #{companyId}</if>
and sts='Y'
</trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
</trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
delete from mdm_module_distribute_detail where id = #{id}
</delete>

View File

@ -21,7 +21,7 @@ public class MdmModuleSendLogEntity extends BaseEntity {
private String targetApi;
/** 源数据 */
private String sourceData;
/** 操作类型 */
/** 操作类型 1新增2、修改3、删除*/
private String optionType;
/** 公司id */
private String companyId;

View File

@ -44,6 +44,12 @@
,company_id
</sql>
<!-- 查询 采用==查询 -->
<!--通过ID获取数据 -->
<select id="entity_get" resultMap="get-MdmModuleSourceEntity-result">
select
<include refid="MdmModuleSourceEntity_Base_Column_List" />
from mdm_module_source where id = #{ id } and sts='Y'
</select>
<select id="entity_list_base" resultMap="get-MdmModuleSourceEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity">
select
<include refid="MdmModuleSourceEntity_Base_Column_List" />

View File

@ -67,6 +67,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -203,6 +204,54 @@ public class MdmServiceImpl implements IMdmService {
**/
private List<MdmViewFiledVo> getFiledByType(String viewType, List<MdmModuleViewDetailEntity> mdmModuleViewDetailEntities, List<MdmModuleDbEntity> mdmModuleDbEntityList, List<MdmModuleDbFiledsEntity> mdmModuleDbFiledsEntityList, List<MdmModuleDbFiledsRuleEntity> mdmModuleDbFiledsRuleEntityList) {
List<MdmViewFiledVo> mdmViewFiledVos = new ArrayList<>();
for (int i = 0; i < mdmModuleDbEntityList.size(); i++) {
if("1".equals(mdmModuleDbEntityList.get(i).getDbType())){
MdmViewFiledVo rule = new MdmViewFiledVo();
rule.setDbName(mdmModuleDbEntityList.get(i).getDbName());
rule.setDbType("1");
rule.setMdmId(mdmModuleDbEntityList.get(i).getMdmId());
rule.setDbId(mdmModuleDbEntityList.get(i).getId());
rule.setChName("单据规则");
rule.setEnName("document_rule");
mdmViewFiledVos.add(rule);
List<MdmModuleDbFiledsRuleEntity> msgRule = new ArrayList<>();
MdmModuleDbFiledsRuleEntity msgRuleTitie = new MdmModuleDbFiledsRuleEntity();
msgRuleTitie.setFormName("optionRuleForm");
msgRuleTitie.setRuleCode("title");
msgRuleTitie.setRuleName("显示名");
msgRuleTitie.setRuleType("2");
msgRuleTitie.setRuleValue("单据编码");
MdmModuleDbFiledsRuleEntity msgRulerow = new MdmModuleDbFiledsRuleEntity();
msgRulerow.setFormName("optionRuleForm");
msgRulerow.setRuleCode("row");
msgRulerow.setRuleName("宽度");
msgRulerow.setRuleType("2");
msgRulerow.setRuleValue("12");
MdmModuleDbFiledsRuleEntity msgRuletype = new MdmModuleDbFiledsRuleEntity();
msgRuletype.setFormName("optionRuleForm");
msgRuletype.setRuleCode("type");
msgRuletype.setRuleName("数据类型");
msgRuletype.setRuleType("2");
msgRuletype.setRuleValue("input");
MdmModuleDbFiledsRuleEntity msgRulerequired = new MdmModuleDbFiledsRuleEntity();
msgRulerequired.setFormName("optionRuleForm");
msgRulerequired.setRuleCode("required");
msgRulerequired.setRuleName("必填");
msgRulerequired.setRuleType("2");
MdmModuleDbFiledsRuleEntity withs = new MdmModuleDbFiledsRuleEntity();
withs.setFormName("optionRuleForm");
withs.setRuleCode("width");
withs.setRuleName("宽度");
withs.setRuleType("2");
withs.setRuleValue("200");
msgRule.add(withs);
msgRule.add(msgRulerequired);
msgRule.add(msgRuletype);
msgRule.add(msgRulerow);
msgRule.add(msgRuleTitie);
rule.setRuleList(msgRule);
}
}
if(mdmModuleViewDetailEntities != null && mdmModuleViewDetailEntities.size() > 0){
for (int i = 0; i < mdmModuleViewDetailEntities.size(); i++) {
if(viewType.equals(mdmModuleViewDetailEntities.get(i).getViewType())){
@ -223,6 +272,7 @@ public class MdmServiceImpl implements IMdmService {
}
mdmViewFiledVo.setChName(mdmModuleDbFiledsEntityList.get(i1).getChName());
mdmViewFiledVo.setEnName(mdmModuleDbFiledsEntityList.get(i1).getEnName());
mdmViewFiledVo.setFiledType(mdmModuleDbFiledsEntityList.get(i1).getFiledType());
//字段规则
if(mdmModuleDbFiledsRuleEntityList != null && mdmModuleDbFiledsRuleEntityList.size() > 0){
@ -233,10 +283,50 @@ public class MdmServiceImpl implements IMdmService {
}
}
mdmViewFiledVo.setRuleList(ruleList);
if("data_status".equals(mdmModuleDbFiledsEntityList.get(i1).getEnName())){
List<MdmModuleDbFiledsRuleEntity> a = new ArrayList<>();
MdmModuleDbFiledsRuleEntity msgRuleTitie = new MdmModuleDbFiledsRuleEntity();
msgRuleTitie.setFormName("optionRuleForm");
msgRuleTitie.setRuleCode("title");
msgRuleTitie.setRuleName("显示名");
msgRuleTitie.setRuleType("2");
msgRuleTitie.setRuleValue("数据状态");
MdmModuleDbFiledsRuleEntity msgRulerow = new MdmModuleDbFiledsRuleEntity();
msgRulerow.setFormName("optionRuleForm");
msgRulerow.setRuleCode("row");
msgRulerow.setRuleName("宽度");
msgRulerow.setRuleType("2");
msgRulerow.setRuleValue("12");
MdmModuleDbFiledsRuleEntity msgRuletype = new MdmModuleDbFiledsRuleEntity();
msgRuletype.setFormName("optionRuleForm");
msgRuletype.setRuleCode("type");
msgRuletype.setRuleName("数据类型");
msgRuletype.setRuleType("2");
msgRuletype.setRuleValue("input");
MdmModuleDbFiledsRuleEntity msgRulerequired = new MdmModuleDbFiledsRuleEntity();
msgRulerequired.setFormName("optionRuleForm");
msgRulerequired.setRuleCode("required");
msgRulerequired.setRuleName("必填");
msgRulerequired.setRuleType("2");
MdmModuleDbFiledsRuleEntity withs = new MdmModuleDbFiledsRuleEntity();
withs.setFormName("optionRuleForm");
withs.setRuleCode("width");
withs.setRuleName("宽度");
withs.setRuleType("2");
withs.setRuleValue("200");
a.add(withs);
a.add(msgRulerequired);
a.add(msgRuletype);
a.add(msgRulerow);
a.add(msgRuleTitie);
mdmViewFiledVo.setRuleList(a);
}
}
break;
}
}
mdmViewFiledVos.add(mdmViewFiledVo);
}
}
}
@ -509,6 +599,24 @@ public class MdmServiceImpl implements IMdmService {
if (entity == null) {
return BaseResult.getFailureMessageEntity("参数不允许为空");
}
entity.setMdmCode(10007L);
MdmModuleEntity mdmModuleEntity = mdmServiceCache.getMdmModuleEntity(entity.getMdmCode());
if(mdmModuleEntity == null || mdmModuleEntity.getId() == null ){
return BaseResult.getFailureMessageEntity("主数据设置错误");
}
MdmModuleDbEntity mdmModuleDbEntity = new MdmModuleDbEntity();
mdmModuleDbEntity.setMdmId(mdmModuleEntity.getId());
mdmModuleDbEntity.setSts("Y");
List<MdmModuleDbEntity> mdmModuleDbEntities = mdmServiceCache.queryMdmModuleDb(mdmModuleDbEntity);
if(mdmModuleDbEntities == null || mdmModuleDbEntities.size() == 0){
return BaseResult.getFailureMessageEntity("主数据设置错误");
}
for (int i = 0; i < mdmModuleDbEntities.size(); i++) {
if("1".equals(mdmModuleDbEntities.get(i).getDbType())){
entity.setTableName(mdmModuleDbEntities.get(i).getDbName());
break;
}
}
//判断分页
if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) {
return BaseResult.getFailureMessageEntity("分页查询参数不存在");
@ -1175,7 +1283,7 @@ public class MdmServiceImpl implements IMdmService {
if (mdmModuleDbEntityList == null || mdmModuleDbEntityList.size() == 0) {
return BaseResult.getFailureMessageEntity("系统错误");
}
String tablename = null;
//String tablename = null;
JSONObject jsonObject = new JSONObject();
for (int i = 0; i < mdmModuleDbEntityList.size(); i++) {
//查询数据
@ -1186,7 +1294,7 @@ public class MdmServiceImpl implements IMdmService {
queryData.put("id", entity.getId());//字段
HashMap<String, Object> datas = mdmModuleDbDao.getServiceDataById(queryData);
jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), datas);
tablename = mdmModuleDbEntityList.get(i).getDbName() + "_distribute";
//tablename = mdmModuleDbEntityList.get(i).getDbName() + "_distribute";
} else {
queryData.put("detailFlag", true);//是否明细
queryData.put("id", entity.getId());//字段
@ -1194,13 +1302,13 @@ public class MdmServiceImpl implements IMdmService {
jsonObject.put(mdmModuleDbEntityList.get(i).getDbName(), datas);
}
}
if (tablename != null && !"".equals(tablename)) {
Map<String, Object> queryData = new HashMap<>();
queryData.put("tableName", tablename);//表名
queryData.put("id", entity.getId());//字段
List<HashMap<String, Object>> datas = mdmModuleDbDao.getServiceByDistributeId(queryData);
jsonObject.put(tablename, datas);
}
//if (tablename != null && !"".equals(tablename)) {
// Map<String, Object> queryData = new HashMap<>();
// queryData.put("tableName", tablename);//表名
// queryData.put("id", entity.getId());//字段
// List<HashMap<String, Object>> datas = mdmModuleDbDao.getServiceByDistributeId(queryData);
// jsonObject.put(tablename, datas);
//}
return BaseResult.getSuccessMessageEntity("获取数据成功", jsonObject);
@ -1364,7 +1472,7 @@ public class MdmServiceImpl implements IMdmService {
}
mdmModuleDao.deleteTemplateById(formmainDeleteDto);
} else {
}else if ("2".equals(mdmModuleDbEntityList.get(i).getDbType())) {
//删除明细
FormmainDeleteDto formmainDeleteDto = new FormmainDeleteDto();
formmainDeleteDto.setFormmain_id(jsonObject.getString("id"));
@ -1677,16 +1785,17 @@ public class MdmServiceImpl implements IMdmService {
//查询单据规则
MdmTableCodeRuleEntity mdmTableCodeRuleEntity = new MdmTableCodeRuleEntity();
mdmTableCodeRuleEntity.setMdmId(mdmModuleEntity.getId());
mdmTableCodeRuleEntity.setDbId(mdmModuleDbEntityList.get(i).getId());
//mdmTableCodeRuleEntity.setDbId(mdmModuleDbEntityList.get(i).getId());
mdmTableCodeRuleEntity.setSts("Y");
List<MdmTableCodeRuleEntity> allMdmTableCodeRuleEntities = mdmTableCodeRuleDao.queryBase(mdmTableCodeRuleEntity);
List<MdmTableCodeRuleEntity> mdmTableCodeRuleEntities = new ArrayList<>();
if(allMdmTableCodeRuleEntities != null && allMdmTableCodeRuleEntities.size() > 0){
for (int i1 = 0; i1 < allMdmTableCodeRuleEntities.size(); i1++) {
if(mdmModuleDbEntityList.get(i).getId().equals(allMdmTableCodeRuleEntities.get(i1).getDbId())){
mdmTableCodeRuleEntities.add(allMdmTableCodeRuleEntities.get(i1));
}
}
mdmTableCodeRuleEntities = allMdmTableCodeRuleEntities;
//for (int i1 = 0; i1 < allMdmTableCodeRuleEntities.size(); i1++) {
// if(mdmModuleDbEntityList.get(i).getId().equals(allMdmTableCodeRuleEntities.get(i1).getDbId())){
// mdmTableCodeRuleEntities.add(allMdmTableCodeRuleEntities.get(i1));
// }
//}
}
StringBuffer document_rule = new StringBuffer();
Integer document_rule_num = 0;
@ -1723,6 +1832,14 @@ 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 {
@ -1733,6 +1850,31 @@ public class MdmServiceImpl implements IMdmService {
ids.setFiledsName("id");
ids.setFiledsValue(id);
mdmDataFiledDtos.add(ids);
MdmDataFiledDto data_status = new MdmDataFiledDto();
data_status.setFiledsName("data_status");
data_status.setFiledsValue("Y");;
mdmDataFiledDtos.add(data_status);
MdmDataFiledDto org_id = new MdmDataFiledDto();
org_id.setFiledsName("org_id");
org_id.setFiledsValue("Y");;
mdmDataFiledDtos.add(org_id);
MdmDataFiledDto company_id = new MdmDataFiledDto();
company_id.setFiledsName("company_id");
company_id.setFiledsValue("Y");;
mdmDataFiledDtos.add(company_id);
MdmDataFiledDto add_status = new MdmDataFiledDto();
add_status.setFiledsName("add_status");
add_status.setFiledsValue("0");
mdmDataFiledDtos.add(add_status);
MdmDataFiledDto update_status = new MdmDataFiledDto();
update_status.setFiledsName("update_status");
update_status.setFiledsValue("1");
mdmDataFiledDtos.add(update_status);
MdmDataFiledDto delete_status = new MdmDataFiledDto();
delete_status.setFiledsName("delete_status");
delete_status.setFiledsValue("1");
mdmDataFiledDtos.add(delete_status);
mdmDataDto.setMdmDataFiledDtos(mdmDataFiledDtos);
int a = mdmModuleDao.saveForm(mdmDataDto);
}