同步优化
parent
0de7a593e9
commit
7970a2456b
|
@ -1,6 +1,8 @@
|
||||||
package aiyh.utils.response_deal.state;
|
package aiyh.utils.response_deal.state;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.excention.ParseSqlException;
|
||||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||||
import aiyh.utils.response_deal.entity.RowDefinition;
|
import aiyh.utils.response_deal.entity.RowDefinition;
|
||||||
import aiyh.utils.response_deal.entity.TableDefinition;
|
import aiyh.utils.response_deal.entity.TableDefinition;
|
||||||
|
@ -8,6 +10,7 @@ import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
|
||||||
import aiyh.utils.response_deal.util.ResponseUtil;
|
import aiyh.utils.response_deal.util.ResponseUtil;
|
||||||
import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil;
|
import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil;
|
||||||
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -61,7 +64,13 @@ public class InsertOrUpdateState extends State{
|
||||||
private boolean judgmentRepetition(RowDefinition rowDefinition){
|
private boolean judgmentRepetition(RowDefinition rowDefinition){
|
||||||
String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript());
|
String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript());
|
||||||
String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript;
|
String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript;
|
||||||
String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
|
String dataId;
|
||||||
|
try {
|
||||||
|
dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
|
||||||
|
}catch (ParseSqlException e){
|
||||||
|
logger.error(Util.logStr("parse sql error, current sql : [{}], whereParam : [{}]", cusQuerySql, JSONObject.toJSONString(rowDefinition.getWhereParam())));
|
||||||
|
throw new CustomerException(e);
|
||||||
|
}
|
||||||
if(StrUtil.isNotBlank(dataId)){
|
if(StrUtil.isNotBlank(dataId)){
|
||||||
rowDefinition.setDataId(Util.getIntValue(dataId, -1));
|
rowDefinition.setDataId(Util.getIntValue(dataId, -1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
package aiyh.utils.response_deal.state;
|
package aiyh.utils.response_deal.state;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.excention.ParseSqlException;
|
||||||
import aiyh.utils.recordset.MapperBuilderSql;
|
import aiyh.utils.recordset.MapperBuilderSql;
|
||||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||||
import aiyh.utils.response_deal.entity.RowDefinition;
|
import aiyh.utils.response_deal.entity.RowDefinition;
|
||||||
import aiyh.utils.response_deal.entity.TableDefinition;
|
import aiyh.utils.response_deal.entity.TableDefinition;
|
||||||
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
|
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
|
||||||
import aiyh.utils.response_deal.util.ResponseUtil;
|
import aiyh.utils.response_deal.util.ResponseUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -62,7 +65,12 @@ public class InsertSate extends State{
|
||||||
}
|
}
|
||||||
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, tempRowDefinition.getUpdateParam(),"upItem");
|
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, tempRowDefinition.getUpdateParam(),"upItem");
|
||||||
updateSql = updateSql + " where id = #{whereItem.id}";
|
updateSql = updateSql + " where id = #{whereItem.id}";
|
||||||
flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
|
try {
|
||||||
|
flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
|
||||||
|
}catch (ParseSqlException e){
|
||||||
|
logger.error(Util.logStr("parse sql error, current sql : [{}], updateList : [{}], whereList : [{}]", updateSql, JSONObject.toJSONString(updateList), JSONObject.toJSONString(whereList)));
|
||||||
|
throw new CustomerException(e);
|
||||||
|
}
|
||||||
String modeId = Util.getModeIdByTableName(assignTable);
|
String modeId = Util.getModeIdByTableName(assignTable);
|
||||||
Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList);
|
Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList);
|
||||||
}else {
|
}else {
|
||||||
|
@ -74,7 +82,12 @@ public class InsertSate extends State{
|
||||||
}
|
}
|
||||||
insertList.add(item.getUpdateParam());
|
insertList.add(item.getUpdateParam());
|
||||||
});
|
});
|
||||||
flag = this.configMapper.executeInsertBatchCusSql(insertSql, insertList);
|
try {
|
||||||
|
flag = this.configMapper.executeInsertBatchCusSql(insertSql, insertList);
|
||||||
|
}catch (ParseSqlException e){
|
||||||
|
logger.error(Util.logStr("parse sql error, current sql : [{}], insertList : [{}]", insertSql, JSONObject.toJSONString(insertList)));
|
||||||
|
throw new CustomerException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){
|
if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){
|
||||||
detailTableMap.forEach((key,value)->{
|
detailTableMap.forEach((key,value)->{
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
package aiyh.utils.response_deal.state;
|
package aiyh.utils.response_deal.state;
|
||||||
|
|
||||||
import aiyh.utils.ScriptUtil;
|
import aiyh.utils.ScriptUtil;
|
||||||
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.excention.ParseSqlException;
|
||||||
import aiyh.utils.recordset.MapperBuilderSql;
|
import aiyh.utils.recordset.MapperBuilderSql;
|
||||||
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
import aiyh.utils.response_deal.constant.ResponseConfigConstant;
|
||||||
import aiyh.utils.response_deal.entity.RowDefinition;
|
import aiyh.utils.response_deal.entity.RowDefinition;
|
||||||
import aiyh.utils.response_deal.entity.TableDefinition;
|
import aiyh.utils.response_deal.entity.TableDefinition;
|
||||||
import aiyh.utils.response_deal.exception.ResponseException;
|
import aiyh.utils.response_deal.exception.ResponseException;
|
||||||
import aiyh.utils.response_deal.util.ResponseUtil;
|
import aiyh.utils.response_deal.util.ResponseUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -58,7 +62,13 @@ public class UpdateState extends State {
|
||||||
String tempConditionScript = rowDefinition.getConditionScript();
|
String tempConditionScript = rowDefinition.getConditionScript();
|
||||||
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, rowDefinition.getUpdateParam(),"upItem");
|
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, rowDefinition.getUpdateParam(),"upItem");
|
||||||
updateSql = updateSql + " where " + tempConditionScript;
|
updateSql = updateSql + " where " + tempConditionScript;
|
||||||
boolean flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
|
boolean flag;
|
||||||
|
try {
|
||||||
|
flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList);
|
||||||
|
}catch (ParseSqlException e){
|
||||||
|
logger.error(Util.logStr("parse sql error, current sql : [{}], updateList : [{}], whereList : [{}]", updateSql, JSONObject.toJSONString(updateList), JSONObject.toJSONString(whereList)));
|
||||||
|
throw new CustomerException(e);
|
||||||
|
}
|
||||||
logger.info("批量更新处理结果 ==>"+flag);
|
logger.info("批量更新处理结果 ==>"+flag);
|
||||||
if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
|
if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
|
||||||
this.context.getTableDefinitionCallback().afterHandle(this.context,flag);
|
this.context.getTableDefinitionCallback().afterHandle(this.context,flag);
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.api.xuanran.wang.xk_hospital.data_async.controller;
|
||||||
|
|
||||||
import aiyh.utils.ApiResult;
|
import aiyh.utils.ApiResult;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
|
import aiyh.utils.excention.CustomerException;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService;
|
import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService;
|
||||||
import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl;
|
import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl;
|
||||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||||
|
@ -37,6 +39,10 @@ public class CommonDataAsyncController {
|
||||||
@PathParam("type") String type,
|
@PathParam("type") String type,
|
||||||
@RequestBody Map<String, Object> params){
|
@RequestBody Map<String, Object> params){
|
||||||
try {
|
try {
|
||||||
|
if(StrUtil.isBlank(configId) || StrUtil.isBlank(type)){
|
||||||
|
throw new CustomerException("configId or type can not be empty!");
|
||||||
|
}
|
||||||
|
logger.info(Util.logStr("configId : {}, type : {}, params : {}", configId, type, params));
|
||||||
service.async(configId, type, params);
|
service.async(configId, type, params);
|
||||||
return ApiResult.successNoData();
|
return ApiResult.successNoData();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1></h1>
|
* <h1>数据同步</h1>
|
||||||
*
|
*
|
||||||
* @author xuanran.wang
|
* @author xuanran.wang
|
||||||
* @date 2023/7/18 11:15
|
* @date 2023/7/18 11:15
|
||||||
|
|
Loading…
Reference in New Issue