调整通用数据保存和修改接口返回格式
This commit is contained in:
parent
88775d3efe
commit
c2e6863913
|
@ -48,7 +48,7 @@
|
||||||
${key} =#{value}
|
${key} =#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
</set>
|
</set>
|
||||||
where formmain_id=#{formmainId} and sts='Y'
|
where id=#{id} and sts='Y'
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<!-- 多条件逻辑删除 -->
|
<!-- 多条件逻辑删除 -->
|
||||||
|
|
|
@ -135,9 +135,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
if (!checkStr(jsonObject.getString("optionName"))) {
|
if (!checkStr(jsonObject.getString("optionName"))) {
|
||||||
return BaseResult.getFailureMessageEntity("操作人为空");
|
return BaseResult.getFailureMessageEntity("操作人为空");
|
||||||
}
|
}
|
||||||
/*if (!checkStr(jsonObject.getString("rulePrefix"))) {
|
|
||||||
return BaseResult.getFailureMessageEntity("规则为空");
|
|
||||||
}*/
|
|
||||||
ComparisonEntity comparisonEntity = jsonObject.toJavaObject(ComparisonEntity.class);
|
ComparisonEntity comparisonEntity = jsonObject.toJavaObject(ComparisonEntity.class);
|
||||||
ComparisonDetailsEntity comparisonDetailsEntity=new ComparisonDetailsEntity();
|
ComparisonDetailsEntity comparisonDetailsEntity=new ComparisonDetailsEntity();
|
||||||
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
|
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
|
||||||
|
@ -156,10 +153,9 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
JSONObject jsonObjectMain = JSONObject.parseObject(main);
|
JSONObject jsonObjectMain = JSONObject.parseObject(main);
|
||||||
if(jsonObjectMain != null ) {
|
if(jsonObjectMain != null ) {
|
||||||
Map<String, Object> map = new HashMap<>();//将主表数据存到map中
|
Map<String, Object> map = new HashMap<>();//将主表数据存到map中
|
||||||
Map<String, Object> mapDetails = new HashMap<>();//将子表数据存到map中
|
List<Map<String, Object>> mapDetails = new ArrayList<>();//将子表数据存到map中
|
||||||
if (comparisonEntities != null && comparisonEntities.size() > 0) {
|
if (comparisonEntities != null && comparisonEntities.size() > 0) {
|
||||||
map = spliceMainMap(comparisonEntities, jsonObjectMain, map, comparisonEntity);
|
map = spliceMainMap(comparisonEntities, jsonObjectMain, map, comparisonEntity,comparisonDetailsEntity);
|
||||||
mapDetails = spliceDetailMap(comparisonEntities, mapDetails, comparisonDetailsEntity, jsonArray);
|
|
||||||
String uuid = null;
|
String uuid = null;
|
||||||
if (jsonObjectMain.getString("id") == null) {
|
if (jsonObjectMain.getString("id") == null) {
|
||||||
uuid = UUIDUtils.getUUID();
|
uuid = UUIDUtils.getUUID();
|
||||||
|
@ -182,8 +178,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
//查询单据规则 只查询主表得,明细表不用
|
//查询单据规则 只查询主表得,明细表不用
|
||||||
try {
|
try {
|
||||||
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
|
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
|
||||||
String documentRule = comparisonEntityRules.getDocumentRule();
|
String documentRule = comparisonEntityRules.getDocumentRule();//"KH-2024-05-30-1";
|
||||||
; //"KH-2024-05-30-1";
|
|
||||||
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
|
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
|
||||||
if (documentRule != null) {
|
if (documentRule != null) {
|
||||||
//获取规则前缀 CK
|
//获取规则前缀 CK
|
||||||
|
@ -214,30 +209,41 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
return BaseResult.getFailureMessageEntity("保存失败");
|
return BaseResult.getFailureMessageEntity("保存失败");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
List<JSONObject> list=new ArrayList<>();
|
||||||
|
JSONObject jsonObjectList=new JSONObject();
|
||||||
//保存主表数据
|
//保存主表数据
|
||||||
ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule);
|
ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule);
|
||||||
|
jsonObjectList.put(comparisonEntityOne.getDbName(),map);
|
||||||
//保存子表数据
|
//保存子表数据
|
||||||
if (mapDetails != null && mapDetails.size() > 0) {
|
if (jsonArray != null && jsonArray.size() > 0) {
|
||||||
|
mapDetails = spliceDetailMap(comparisonEntities, mapDetails, jsonArray);
|
||||||
|
if(mapDetails.size()>0 && mapDetails!=null){
|
||||||
|
for (Map<String, Object> mapDetail : mapDetails) {
|
||||||
String uuidDetail = UUIDUtils.getUUID();
|
String uuidDetail = UUIDUtils.getUUID();
|
||||||
mapDetails.put("id", uuidDetail);
|
mapDetail.put("id", uuidDetail);
|
||||||
mapDetails.put("formmain_id", uuid);
|
mapDetail.put("formmain_id", uuid);
|
||||||
mapDetails.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
mapDetail.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||||
mapDetails.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
mapDetail.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||||
mapDetails.put("org_id", "0");
|
mapDetail.put("org_id", "0");
|
||||||
mapDetails.put("create_time", new Date());
|
mapDetail.put("create_time", new Date());
|
||||||
mapDetails.put("modify_time", new Date());
|
mapDetail.put("modify_time", new Date());
|
||||||
mapDetails.put("sts", "Y");
|
mapDetail.put("sts", "Y");
|
||||||
mapDetails.put("data_status","Y");//新增状态
|
mapDetail.put("data_status","Y");//新增状态
|
||||||
comparisonDetailsEntity.setMapDetails(mapDetails);
|
comparisonDetailsEntity.setMapDetails(mapDetail);
|
||||||
ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity);
|
ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity);
|
||||||
//comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne);
|
//comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne);
|
||||||
map.put("details",mapDetails);
|
|
||||||
//保存操作日志
|
//保存操作日志
|
||||||
//controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
|
//controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
|
||||||
}
|
}
|
||||||
|
jsonObjectList.put(comparisonDetailsEntity.getDbName(),mapDetails);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
jsonObjectList.put(comparisonDetailsEntity.getDbName(),new ArrayList<>());
|
||||||
|
}
|
||||||
|
list.add(jsonObjectList);
|
||||||
//保存操作日志
|
//保存操作日志
|
||||||
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonEntityRule.getDbName()+"_option_log");
|
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonEntityRule.getDbName()+"_option_log");
|
||||||
return BaseResult.getSuccessMessageEntity("保存成功", map);
|
return BaseResult.getSuccessMessageEntity("保存成功", list);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.info("保存通用数据时候错误:{}", e.getMessage());
|
logger.info("保存通用数据时候错误:{}", e.getMessage());
|
||||||
return BaseResult.getFailureMessageEntity("保存失败");
|
return BaseResult.getFailureMessageEntity("保存失败");
|
||||||
|
@ -279,10 +285,9 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
return BaseResult.getFailureMessageEntity("更新失败");
|
return BaseResult.getFailureMessageEntity("更新失败");
|
||||||
}
|
}
|
||||||
Map<String,Object> map=new HashMap<>();//将主表数据存到map中
|
Map<String,Object> map=new HashMap<>();//将主表数据存到map中
|
||||||
Map<String,Object> mapDetails=new HashMap<>();//将子表数据存到map中
|
List<Map<String,Object>> mapDetails=new ArrayList<>();//将子表数据存到map中
|
||||||
if(comparisonEntities !=null && comparisonEntities.size()>0) {
|
if(comparisonEntities !=null && comparisonEntities.size()>0) {
|
||||||
map=spliceMainMap(comparisonEntities,jsonObjectMain,map,comparisonEntity);
|
map=spliceMainMap(comparisonEntities,jsonObjectMain,map,comparisonEntity,comparisonDetailsEntity);
|
||||||
mapDetails=spliceDetailMap(comparisonEntities,mapDetails,comparisonDetailsEntity,jsonArray);
|
|
||||||
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||||
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||||
map.put("org_id", "0");
|
map.put("org_id", "0");
|
||||||
|
@ -303,26 +308,37 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
return BaseResult.getFailureMessageEntity("更新失败",e.getMessage());
|
return BaseResult.getFailureMessageEntity("更新失败",e.getMessage());
|
||||||
}*/
|
}*/
|
||||||
try {
|
try {
|
||||||
|
List<JSONObject> jsonObjects=new ArrayList<>();
|
||||||
|
JSONObject jsonObjectList=new JSONObject();
|
||||||
//保存主表数据
|
//保存主表数据
|
||||||
Integer integer = comparisonDao.updateComparisonByType(comparisonEntity);
|
Integer integer = comparisonDao.updateComparisonByType(comparisonEntity);
|
||||||
if (integer > 0) {
|
jsonObjectList.put(comparisonEntity.getDbName(),map);
|
||||||
|
if (integer>0) {
|
||||||
//保存子表数据
|
//保存子表数据
|
||||||
if (mapDetails != null && mapDetails.size() > 0) {
|
if (jsonArray != null && jsonArray.size() > 0) {
|
||||||
mapDetails.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
mapDetails=spliceDetailMap(comparisonEntities,mapDetails,jsonArray);
|
||||||
mapDetails.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
for (Map<String, Object> mapDetail : mapDetails) {
|
||||||
mapDetails.put("org_id", "0");
|
mapDetail.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||||
mapDetails.put("modify_time", new Date());
|
mapDetail.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
|
||||||
mapDetails.put("sts", "Y");
|
mapDetail.put("org_id", "0");
|
||||||
mapDetails.put("data_status","F");//数据状态
|
mapDetail.put("modify_time", new Date());
|
||||||
comparisonDetailsEntity.setFormmainId(jsonObjectMain.getString("id"));
|
mapDetail.put("sts", "Y");
|
||||||
comparisonDetailsEntity.setMapDetails(mapDetails);
|
mapDetail.put("data_status","F");//数据状态
|
||||||
|
//comparisonDetailsEntity.setFormmainId(jsonObjectMain.getString("id"));
|
||||||
|
comparisonDetailsEntity.setId(String.valueOf(mapDetail.get("id")));
|
||||||
|
comparisonDetailsEntity.setMapDetails(mapDetail);
|
||||||
comparisonDetailsDao.updateComparisonDetailsByType(comparisonDetailsEntity);
|
comparisonDetailsDao.updateComparisonDetailsByType(comparisonDetailsEntity);
|
||||||
//保存操作日志
|
//保存操作日志
|
||||||
// controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
|
// controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
|
||||||
}
|
}
|
||||||
|
jsonObjectList.put(comparisonDetailsEntity.getDbName(),mapDetails);
|
||||||
|
}else{
|
||||||
|
jsonObjectList.put(comparisonDetailsEntity.getDbName(),new ArrayList<>());
|
||||||
|
}
|
||||||
|
jsonObjects.add(jsonObjectList);
|
||||||
//保存操作日志
|
//保存操作日志
|
||||||
controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log");
|
controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log");
|
||||||
return BaseResult.getSuccessMessageEntity("更新成功", integer);
|
return BaseResult.getSuccessMessageEntity("更新成功", jsonObjects);
|
||||||
}else{
|
}else{
|
||||||
return BaseResult.getFailureMessageEntity("更新失败");
|
return BaseResult.getFailureMessageEntity("更新失败");
|
||||||
}
|
}
|
||||||
|
@ -436,7 +452,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
}
|
}
|
||||||
|
|
||||||
//得到主表数据
|
//得到主表数据
|
||||||
private Map<String,Object> spliceMainMap(List<ComparisonEntity> comparisonEntities,JSONObject jsonObjectMain,Map<String, Object> map,ComparisonEntity comparisonEntity){
|
private Map<String,Object> spliceMainMap(List<ComparisonEntity> comparisonEntities,JSONObject jsonObjectMain,Map<String, Object> map,ComparisonEntity comparisonEntity,ComparisonDetailsEntity comparisonDetailsEntity){
|
||||||
for (ComparisonEntity entity : comparisonEntities) {
|
for (ComparisonEntity entity : comparisonEntities) {
|
||||||
//遍历主表下面的所有key,字段名
|
//遍历主表下面的所有key,字段名
|
||||||
for (String key : jsonObjectMain.keySet()) {
|
for (String key : jsonObjectMain.keySet()) {
|
||||||
|
@ -447,27 +463,29 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
map.put(key, jsonObjectMain.getString(key));
|
map.put(key, jsonObjectMain.getString(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(entity.getDbType().equals("2")){
|
||||||
|
comparisonDetailsEntity.setDbName(entity.getDbName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
//得到明细表数据
|
//得到明细表数据
|
||||||
private Map<String,Object> spliceDetailMap(List<ComparisonEntity> comparisonEntities,Map<String, Object> mapDetails,ComparisonDetailsEntity comparisonDetailsEntity,JSONArray jsonArray){
|
private List<Map<String, Object>> spliceDetailMap(List<ComparisonEntity> comparisonEntities,List<Map<String, Object>> mapDetails,JSONArray jsonArray){
|
||||||
if (jsonArray != null && jsonArray.size() > 0) {
|
if (jsonArray != null && jsonArray.size() > 0) {
|
||||||
for (Object object : jsonArray) {
|
for (Object object : jsonArray) {
|
||||||
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object);
|
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object);
|
||||||
for (ComparisonEntity entity : comparisonEntities) {
|
JSONObject jsonObject=new JSONObject();
|
||||||
//遍历主表下面的所有key,字段名
|
//遍历主表下面的所有key,字段名
|
||||||
for (String key : jsonObjectDetails.keySet()) {
|
for (String key : jsonObjectDetails.keySet()) {
|
||||||
if (entity.getDbType().equals("2")) {
|
for (ComparisonEntity entity : comparisonEntities) {
|
||||||
comparisonDetailsEntity.setDbName(entity.getDbName());
|
if (entity.getDbType().equals("2") && entity.getEnName().equals(key)) {
|
||||||
if(entity.getEnName().equals(key)){
|
jsonObject.put(key,jsonObjectDetails.getString(key));
|
||||||
mapDetails.put(key, jsonObjectDetails.getString(key));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mapDetails.add(jsonObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mapDetails;
|
return mapDetails;
|
||||||
|
@ -518,7 +536,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "option":
|
case "option":
|
||||||
//获取主表和明细表的字段信息
|
|
||||||
if(moduleDbEntity.getDbType().equals("3")){
|
if(moduleDbEntity.getDbType().equals("3")){
|
||||||
MdmModuleDbFiledsEntity mdmModuleDbFiledsEntity=new MdmModuleDbFiledsEntity();
|
MdmModuleDbFiledsEntity mdmModuleDbFiledsEntity=new MdmModuleDbFiledsEntity();
|
||||||
mdmModuleDbFiledsEntity.setDbId(moduleDbEntity.getId());
|
mdmModuleDbFiledsEntity.setDbId(moduleDbEntity.getId());
|
||||||
|
|
Loading…
Reference in New Issue