Commit f252d61f authored by tianyiming's avatar tianyiming

一码通性能优化

parent dcfdfda3
...@@ -41,19 +41,15 @@ public interface IdxFeignService { ...@@ -41,19 +41,15 @@ public interface IdxFeignService {
/** /**
* 多表单页提交 数据填报 * 多表单页提交 数据填报
*/ */
@RequestMapping(value = "/table/batch/submit", method = RequestMethod.POST) @RequestMapping(value = "/report/form/batch/submit", method = RequestMethod.POST)
ResponseModel batchSubmit(@RequestParam(required = false) String taskId, ResponseModel batchSubmit(@RequestParam(required = false) String topic,
@RequestParam(required = false) String planInstanceId,
@RequestParam(required = false) String topic,
@RequestParam(required = false) String tableName,
@RequestBody Map<String, Object> kv) throws Exception; @RequestBody Map<String, Object> kv) throws Exception;
/** /**
* 多表单页修改数据修改 * 多表单页修改数据修改
*/ */
@RequestMapping(value = "/table/batch/update", method = RequestMethod.POST) @RequestMapping(value = "/report/form/batch/update", method = RequestMethod.POST)
ResponseModel batchUpdate(@RequestParam(required = false) String topic, ResponseModel batchUpdate(@RequestParam(required = false) String topic,
@RequestParam(required = false) String tableName,
@RequestBody Map<String, Object> kv) throws Exception; @RequestBody Map<String, Object> kv) throws Exception;
/** /**
......
...@@ -103,23 +103,27 @@ ...@@ -103,23 +103,27 @@
<select id="checkCode" resultType="java.util.Map"> <select id="checkCode" resultType="java.util.Map">
SELECT SELECT
<if test="equCode != null and equCode != ''"> <if test="equCode != null and equCode != ''">
(SELECT COUNT ( 1 ) FROM idx_biz_jg_register_info ibjri WHERE ibjri."EQU_CODE" = #{equCode} (SELECT COUNT ( 1 ) FROM idx_biz_jg_register_info ibjri
LEFT JOIN idx_biz_jg_other_info ibjoi ON ibjoi."RECORD" = ibjri."RECORD"
WHERE ibjri."EQU_CODE" = #{equCode}
<if test="type != 'save' "> <if test="type != 'save' ">
and ibjri."RECORD" != #{record} and ibjri."RECORD" != #{record} and ibjoi."CLAIM_STATUS" = '已认领'
</if> </if>
) AS equCode, ) AS equCode,
</if> </if>
<if test="useOrgCode != null and useOrgCode != ''"> <if test="useOrgCode != null and useOrgCode != ''">
(SELECT COUNT ( 1 ) FROM idx_biz_jg_register_info ibjri WHERE ibjri."USE_ORG_CODE" = #{useOrgCode} (SELECT COUNT ( 1 ) FROM idx_biz_jg_register_info ibjri
LEFT JOIN idx_biz_jg_other_info ibjoi ON ibjoi."RECORD" = ibjri."RECORD"
WHERE ibjri."USE_ORG_CODE" = #{useOrgCode}
<if test="type != 'save'"> <if test="type != 'save'">
and ibjri."RECORD" != #{record} and ibjri."RECORD" != #{record} and ibjoi."CLAIM_STATUS" = '已认领'
</if> </if>
) AS useOrgCode, ) AS useOrgCode,
</if> </if>
<if test="code96333 != null and code96333 != ''"> <if test="code96333 != null and code96333 != ''">
(SELECT COUNT ( 1 ) FROM idx_biz_jg_other_info ibjoi WHERE ibjoi."CODE96333" = #{code96333} (SELECT COUNT ( 1 ) FROM idx_biz_jg_other_info ibjoi WHERE ibjoi."CODE96333" = #{code96333}
<if test="type != 'save'"> <if test="type != 'save'">
and ibjoi."RECORD" != #{record} and ibjoi."RECORD" != #{record} and ibjoi."CLAIM_STATUS" = '已认领'
</if> </if>
) AS code ) AS code
</if> </if>
......
...@@ -56,6 +56,8 @@ import java.io.IOException; ...@@ -56,6 +56,8 @@ import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString; import static com.alibaba.fastjson.JSON.toJSONString;
...@@ -888,11 +890,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -888,11 +890,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
list.add(equipmentCategoryData); list.add(equipmentCategoryData);
} }
} }
if (!ObjectUtils.isEmpty(unitCodes)) { if (!ObjectUtils.isEmpty(unitCodes) && !ObjectUtils.isEmpty(orgBranchCodes) ) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>() equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>()
.in("unit_code", unitCodes) .in("unit_code", unitCodes)
.in("org_branch_code",orgBranchCodes)); .in("org_branch_code",orgBranchCodes));
} }
if (!ObjectUtils.isEmpty(unitCodes) && ObjectUtils.isEmpty(orgBranchCodes) ) {
equipmentCategoryDataMapper.delete(new QueryWrapper<EquipmentCategoryData>()
.in("unit_code", unitCodes));
}
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
equipmentCategoryDataService.saveOrUpdateBatch(list); equipmentCategoryDataService.saveOrUpdateBatch(list);
} }
...@@ -944,7 +950,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -944,7 +950,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
private List<EquipmentCategoryData> updateEquipmentCategoryData(String unitCode, String orgBranchCode) { private List<EquipmentCategoryData> updateEquipmentCategoryData(String unitCode) {
List<String> unitCodeList = new ArrayList<>(); List<String> unitCodeList = new ArrayList<>();
unitCodeList.add(unitCode); unitCodeList.add(unitCode);
List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList, null); List<EquipmentCategoryData> equipmentCategoryData = getCategoryData(unitCodeList, null);
...@@ -1001,6 +1007,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1001,6 +1007,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
public ResponseModel submit(Map<String, Object> map) { public ResponseModel submit(Map<String, Object> map) {
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
stopWatch.start(); stopWatch.start();
StopWatch stopWatch3 = new StopWatch();
stopWatch3.start();
SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo(); SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo();
ResponseModel responseModel = new ResponseModel(); ResponseModel responseModel = new ResponseModel();
LinkedHashMap useInfoFrom = (LinkedHashMap) map.get(USE_INFO_FROM_ID); LinkedHashMap useInfoFrom = (LinkedHashMap) map.get(USE_INFO_FROM_ID);
...@@ -1032,9 +1040,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1032,9 +1040,19 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisionMap.put("CODE96333", codeMap.get("code96333")); supervisionMap.put("CODE96333", codeMap.get("code96333"));
supervisionMap.put("SUPERVISORY_CODE", codeMap.get("superviseCode")); supervisionMap.put("SUPERVISORY_CODE", codeMap.get("superviseCode"));
map.put(SUPERVISION_FROM_ID, supervisionMap); map.put(SUPERVISION_FROM_ID, supervisionMap);
stopWatch.stop();
if (log.isInfoEnabled()) {
log.info("业务调用idx前耗时:{} 秒", stopWatch.getTotalTimeSeconds());
}
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
//根据操作状态判断是调用新增还是修改接口 //根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, null, null, null, map) : responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit( null, map) :
idxFeignService.batchUpdate(null, null, map); idxFeignService.batchUpdate(null, map);
stopWatch1.stop();
if (log.isInfoEnabled()) {
log.info("业务调用idx耗时:{} 秒", stopWatch1.getTotalTimeSeconds());
}
if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) { if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) {
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.YSY.getCode()); supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.YSY.getCode());
} else { } else {
...@@ -1046,20 +1064,42 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1046,20 +1064,42 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
supervisionMap.put("CODE96333", "null".equals(code96333) ? null : code96333); supervisionMap.put("CODE96333", "null".equals(code96333) ? null : code96333);
map.put(SUPERVISION_FROM_ID, supervisionMap); map.put(SUPERVISION_FROM_ID, supervisionMap);
//根据操作状态判断是调用新增还是修改接口 //根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, null, null, null, map) : responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, map) :
idxFeignService.batchUpdate(null, null, map); idxFeignService.batchUpdate(null, map);
} else { } else {
map.remove("data"); map.remove("data");
responseModel = idxFeignService.batchUpdate(null, null, map); responseModel = idxFeignService.batchUpdate(null, map);
} }
StopWatch stopWatch4 = new StopWatch();
stopWatch4.start();
if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) { if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) {
log.info("responseModel.getResult().toString()->>>>>>>>>>>>>>",responseModel.getResult()); log.info("responseModel.getResult().toString()->>>>>>>>>>>>>> {}",responseModel.getResult());
checkEsData(String.valueOf(responseModel.getResult())); checkEsData(String.valueOf(responseModel.getResult()));
} }
supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionMap.get("SUPERVISORY_CODE"))); stopWatch4.stop();
stopWatch.stop(); if (log.isInfoEnabled()) {
log.info("更新es耗时:{} 秒", stopWatch4.getTotalTimeSeconds());
}
stopWatch3.stop();
if (log.isInfoEnabled()) {
log.info("通用提交耗时:{} 秒", stopWatch3.getTotalTimeSeconds());
}
StopWatch stopWatch5 = new StopWatch();
stopWatch5.start();
ExecutorService threadPool = Executors.newCachedThreadPool();
threadPool.submit(new Runnable() {
@Override
public void run() {
log.info("已生成对应监管码" + supervisionMap.get("SUPERVISORY_CODE"));
log.info("已生成对应96333电梯识别码" + supervisionMap.get("CODE96333"));
supervisoryCodeInfoMapper.update(supervisoryCodeInfo, new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionMap.get("SUPERVISORY_CODE")));
log.info("unitCode-------->>>>>>>>>>{}", unitCode);
updateEquipmentCategoryData(unitCode);
}
});
stopWatch5.stop();
if (log.isInfoEnabled()) { if (log.isInfoEnabled()) {
log.info("通用提交耗时:{} 秒", stopWatch.getTotalTimeSeconds()); log.info("异步操作耗时:{} 秒", stopWatch5.getTotalTimeSeconds());
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
...@@ -1077,10 +1117,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1077,10 +1117,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
response.setMessage("操作失败,请检查数据输入后重新提交"); response.setMessage("操作失败,请检查数据输入后重新提交");
response.setStatus(HttpStatus.BAD_REQUEST.value()); response.setStatus(HttpStatus.BAD_REQUEST.value());
return response; return response;
} finally {
log.info("已生成对应监管码" + supervisionMap.get("SUPERVISORY_CODE"));
log.info("已生成对应96333电梯识别码" + supervisionMap.get("CODE96333"));
updateEquipmentCategoryData(unitCode, orgBranchCode);
} }
return responseModel; return responseModel;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment