Commit aef5db9e authored by 李成龙's avatar 李成龙

Merge remote-tracking branch 'origin/develop_tzs_bugfix' into develop_tzs_bugfix

parents 6d8c10a3 44bd5fb5
...@@ -1053,7 +1053,7 @@ ...@@ -1053,7 +1053,7 @@
<select id="queryOutOfMaintenanceRecord" resultType="java.util.Map"> <select id="queryOutOfMaintenanceRecord" resultType="java.util.Map">
SELECT SELECT
tt."RECORD", ui."RECORD",
tt."INFORM_END", tt."INFORM_END",
ui."USE_UNIT_NAME", ui."USE_UNIT_NAME",
ui."USE_UNIT_CREDIT_CODE", ui."USE_UNIT_CREDIT_CODE",
...@@ -1068,27 +1068,29 @@ ...@@ -1068,27 +1068,29 @@
si."ORG_BRANCH_CODE", si."ORG_BRANCH_CODE",
si."COMPANY_ORG_BRANCH_CODE" si."COMPANY_ORG_BRANCH_CODE"
FROM FROM
( idx_biz_jg_use_info ui
LEFT JOIN idx_biz_jg_other_info oi ON oi."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_supervision_info si on si."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_register_info ri on ri."RECORD" = ui."RECORD"
LEFT JOIN (
SELECT SELECT
"RECORD","INFORM_END","ROWNUM1" "RECORD","INFORM_END","ROWNUM1"
FROM FROM
( (
SELECT "RECORD","INFORM_END",ROW_NUMBER() OVER (PARTITION BY "RECORD" ORDER BY "REC_DATE" DESC) AS ROWNUM1 SELECT "RECORD","INFORM_END",ROW_NUMBER() OVER (PARTITION BY "RECORD" ORDER BY "REC_DATE" DESC) AS ROWNUM1
FROM FROM
idx_biz_jg_maintenance_record_info idx_biz_jg_maintenance_record_info where "INFORM_END" is not null
) d ) d
WHERE d."ROWNUM1" = 1 and d."INFORM_END" <![CDATA[<]]> to_char(now(), 'YYYY-MM-DD') WHERE d."ROWNUM1" = 1 and d."INFORM_END" <![CDATA[<]]> to_char(now(), 'YYYY-MM-DD')
) tt ) tt on tt."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_use_info ui ON ui."RECORD" = tt."RECORD" WHERE si."ORG_BRANCH_CODE" like '50%'
LEFT JOIN idx_biz_jg_register_info ri ON ri."RECORD" = tt."RECORD" and oi."CLAIM_STATUS" not in ('草稿','已拒领','待认领')
LEFT JOIN idx_biz_jg_other_info oi ON oi."RECORD" = tt."RECORD" and tt."INFORM_END" is not null
LEFT JOIN idx_biz_jg_supervision_info si on si."RECORD" = tt."RECORD"
WHERE ui."DATA_SOURCE" like 'jg%' and ui.IS_INTO_MANAGEMENT = true
</select> </select>
<select id="queryOutOfInspectionRecord" resultType="java.util.Map"> <select id="queryOutOfInspectionRecord" resultType="java.util.Map">
SELECT SELECT
tt."RECORD", ui."RECORD",
tt."NEXT_INSPECT_DATE", tt."NEXT_INSPECT_DATE",
ui."USE_UNIT_NAME", ui."USE_UNIT_NAME",
ui."USE_UNIT_CREDIT_CODE", ui."USE_UNIT_CREDIT_CODE",
...@@ -1103,21 +1105,23 @@ ...@@ -1103,21 +1105,23 @@
si."ORG_BRANCH_CODE", si."ORG_BRANCH_CODE",
si."COMPANY_ORG_BRANCH_CODE" si."COMPANY_ORG_BRANCH_CODE"
FROM FROM
( idx_biz_jg_use_info ui
SELECT "RECORD","NEXT_INSPECT_DATE","rowNum1" LEFT JOIN idx_biz_jg_other_info oi ON oi."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_supervision_info si on si."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_register_info ri on ri."RECORD" = ui."RECORD"
LEFT JOIN (
SELECT "RECORD","NEXT_INSPECT_DATE",rowNum1
FROM FROM
( (
SELECT ROW_NUMBER () OVER ( PARTITION BY "RECORD" ORDER BY "REC_DATE" DESC) AS rowNum1,"RECORD", "NEXT_INSPECT_DATE" SELECT ROW_NUMBER () OVER ( PARTITION BY "RECORD" ORDER BY "NEXT_INSPECT_DATE" DESC) AS rowNum1,"RECORD", "NEXT_INSPECT_DATE"
FROM FROM
idx_biz_jg_inspection_detection_info idx_biz_jg_inspection_detection_info where "NEXT_INSPECT_DATE" is not null
) d ) d
WHERE d.rowNum1 = 1 and d."NEXT_INSPECT_DATE" <![CDATA[<]]> to_char(now(), 'YYYY-MM-DD') WHERE d.rowNum1 =1 and d."NEXT_INSPECT_DATE" <![CDATA[<]]> to_char(now(), 'YYYY-MM-DD')
) tt ) tt on tt."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_use_info ui ON ui."RECORD" = tt."RECORD" WHERE si."ORG_BRANCH_CODE" like '50%'
LEFT JOIN idx_biz_jg_register_info ri ON ri."RECORD" = tt."RECORD" and oi."CLAIM_STATUS" not in ('草稿','已拒领','待认领')
LEFT JOIN idx_biz_jg_other_info oi ON oi."RECORD" = tt."RECORD" and tt."NEXT_INSPECT_DATE" is not null
LEFT JOIN idx_biz_jg_supervision_info si on si."RECORD" = tt."RECORD"
WHERE ui."DATA_SOURCE" like 'jg%' and ui.IS_INTO_MANAGEMENT = true
</select> </select>
<select id="countBizFinishedNumForDP" resultType="java.lang.Long"> <select id="countBizFinishedNumForDP" resultType="java.lang.Long">
SELECT count(1) FROM "tzs_jg_installation_notice" where receive_company_org_code like CONCAT(#{orgCode}, '%') and notice_status = '6616' SELECT count(1) FROM "tzs_jg_installation_notice" where receive_company_org_code like CONCAT(#{orgCode}, '%') and notice_status = '6616'
......
...@@ -207,6 +207,7 @@ ...@@ -207,6 +207,7 @@
tzs_safety_problem_tracing tzs_safety_problem_tracing
WHERE WHERE
is_delete = '0' is_delete = '0'
and problem_status_code = '0'
<if test="orgCode != null and orgCode != ''"> <if test="orgCode != null and orgCode != ''">
and governing_body_org_code like CONCAT(#{orgCode}, '%') and governing_body_org_code like CONCAT(#{orgCode}, '%')
</if> </if>
......
...@@ -1535,7 +1535,7 @@ public class DataHandlerServiceImpl { ...@@ -1535,7 +1535,7 @@ public class DataHandlerServiceImpl {
Map<String, List<IdxBizJgInspectionDetectionInfo>> recordInspectInfosGroupByInspectTypeMap = lastedInspectInfosGroupByInspectType.stream().collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord)); Map<String, List<IdxBizJgInspectionDetectionInfo>> recordInspectInfosGroupByInspectTypeMap = lastedInspectInfosGroupByInspectType.stream().collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord));
// 设备最新的检验信息-维度:设备 // 设备最新的检验信息-维度:设备
Map<String, Optional<IdxBizJgInspectionDetectionInfo>> recordLastInspectionMap = lastedInspectInfosGroupByInspectType.stream().filter(e -> e.getInspectDate() != null).collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord, Collectors.maxBy(Comparator.comparing(IdxBizJgInspectionDetectionInfo::getInspectDate)))); Map<String, Optional<IdxBizJgInspectionDetectionInfo>> recordLastInspectionMap = lastedInspectInfosGroupByInspectType.stream().filter(e -> e.getNextInspectDate() != null).collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord, Collectors.maxBy(Comparator.comparing(IdxBizJgInspectionDetectionInfo::getNextInspectDate))));
List<ESEquipmentInfo> esEquipmentInfos = refreshRecords.parallelStream().map(record -> { List<ESEquipmentInfo> esEquipmentInfos = refreshRecords.parallelStream().map(record -> {
ESEquipmentInfo esEquipmentInfo = null; ESEquipmentInfo esEquipmentInfo = null;
try { try {
...@@ -1641,7 +1641,7 @@ public class DataHandlerServiceImpl { ...@@ -1641,7 +1641,7 @@ public class DataHandlerServiceImpl {
Map<String, List<IdxBizJgInspectionDetectionInfo>> recordInspectInfosGroupByInspectTypeMap = lastedInspectInfosGroupByInspectType.stream().collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord)); Map<String, List<IdxBizJgInspectionDetectionInfo>> recordInspectInfosGroupByInspectTypeMap = lastedInspectInfosGroupByInspectType.stream().collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord));
// 设备最新的检验信息-维度:设备 // 设备最新的检验信息-维度:设备
Map<String, Optional<IdxBizJgInspectionDetectionInfo>> recordLastInspectionMap = lastedInspectInfosGroupByInspectType.stream().filter(e -> e.getInspectDate() != null).collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord, Collectors.maxBy(Comparator.comparing(IdxBizJgInspectionDetectionInfo::getInspectDate)))); Map<String, Optional<IdxBizJgInspectionDetectionInfo>> recordLastInspectionMap = lastedInspectInfosGroupByInspectType.stream().filter(e -> e.getNextInspectDate() != null).collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord, Collectors.maxBy(Comparator.comparing(IdxBizJgInspectionDetectionInfo::getNextInspectDate))));
List<ESEquipmentInfo> esEquipmentInfos = records.parallelStream().map(record -> { List<ESEquipmentInfo> esEquipmentInfos = records.parallelStream().map(record -> {
ESEquipmentInfo esEquipmentInfo = null; ESEquipmentInfo esEquipmentInfo = null;
try { try {
...@@ -1768,7 +1768,7 @@ public class DataHandlerServiceImpl { ...@@ -1768,7 +1768,7 @@ public class DataHandlerServiceImpl {
Map<String, List<IdxBizJgInspectionDetectionInfo>> recordInspectInfosGroupByInspectTypeMap = lastedInspectInfosGroupByInspectType.stream().collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord)); Map<String, List<IdxBizJgInspectionDetectionInfo>> recordInspectInfosGroupByInspectTypeMap = lastedInspectInfosGroupByInspectType.stream().collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord));
// 设备最新的检验信息-维度:设备 // 设备最新的检验信息-维度:设备
Map<String, Optional<IdxBizJgInspectionDetectionInfo>> recordLastInspectionMap = lastedInspectInfosGroupByInspectType.stream().filter(e -> e.getInspectDate() != null).collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord, Collectors.maxBy(Comparator.comparing(IdxBizJgInspectionDetectionInfo::getInspectDate)))); Map<String, Optional<IdxBizJgInspectionDetectionInfo>> recordLastInspectionMap = lastedInspectInfosGroupByInspectType.stream().filter(e -> e.getNextInspectDate() != null).collect(Collectors.groupingBy(IdxBizJgInspectionDetectionInfo::getRecord, Collectors.maxBy(Comparator.comparing(IdxBizJgInspectionDetectionInfo::getNextInspectDate))));
List<ESEquipmentInfo> esEquipmentInfos = records.parallelStream().map(record -> { List<ESEquipmentInfo> esEquipmentInfos = records.parallelStream().map(record -> {
ESEquipmentInfo esEquipmentInfo = null; ESEquipmentInfo esEquipmentInfo = null;
try { try {
......
...@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl; ...@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -27,7 +26,6 @@ import org.springframework.stereotype.Service; ...@@ -27,7 +26,6 @@ import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.nio.charset.StandardCharsets;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -145,18 +143,22 @@ public class SafetyProblemTracingGenServiceImpl{ ...@@ -145,18 +143,22 @@ public class SafetyProblemTracingGenServiceImpl{
return; return;
} }
List<String> records = mapList.stream().map(m -> m.get("RECORD").toString()).collect(Collectors.toList()); List<String> records = mapList.stream().map(m -> m.get("RECORD").toString()).collect(Collectors.toList());
// 更新设备状态为未处理(异常) int batchSize = 10000;
idxBizJgOtherInfoService.lambdaUpdate() for (int i = 0; i < records.size(); i += batchSize) {
.in(IdxBizJgOtherInfo::getRecord, records) List<String> batch = records.subList(i, Math.min(i + batchSize, records.size()));
.set(IdxBizJgOtherInfo::getStatus, SafetyProblemStatusEnum.UNHANDLED.getCode()) // 更新设备状态为未处理(异常)
.update(); idxBizJgOtherInfoService.lambdaUpdate()
List<ESEquipmentCategoryDto> esEquipmentCategoryDto = Lists.newArrayList(); .in(IdxBizJgOtherInfo::getRecord, batch)
for (ESEquipmentCategoryDto equipmentCategoryDto : esEquipmentCategory.findAllById(records)) { .set(IdxBizJgOtherInfo::getStatus, SafetyProblemStatusEnum.UNHANDLED.getCode())
equipmentCategoryDto.setProblemStatus(SafetyProblemStatusEnum.UNHANDLED.getCode()); .update();
esEquipmentCategoryDto.add(equipmentCategoryDto); List<ESEquipmentCategoryDto> esEquipmentCategoryDto = Lists.newArrayList();
for (ESEquipmentCategoryDto equipmentCategoryDto : esEquipmentCategory.findAllById(batch)) {
equipmentCategoryDto.setProblemStatus(SafetyProblemStatusEnum.UNHANDLED.getCode());
esEquipmentCategoryDto.add(equipmentCategoryDto);
}
esEquipmentCategory.saveAll(esEquipmentCategoryDto);
sendSafetyProblemMessage(mapList, safetyProblemTypeEnum);
} }
esEquipmentCategory.saveAll(esEquipmentCategoryDto);
sendSafetyProblemMessage(mapList, safetyProblemTypeEnum);
} }
private void updateEnterpriseAndSendMessage(List<Map<String, Object>> mapList) { private void updateEnterpriseAndSendMessage(List<Map<String, Object>> mapList) {
...@@ -193,11 +195,10 @@ public class SafetyProblemTracingGenServiceImpl{ ...@@ -193,11 +195,10 @@ public class SafetyProblemTracingGenServiceImpl{
* @param safetyProblemTypeEnum * @param safetyProblemTypeEnum
*/ */
private void sendSafetyProblemMessage(List<Map<String, Object>> mapList, SafetyProblemTypeEnum safetyProblemTypeEnum) { private void sendSafetyProblemMessage(List<Map<String, Object>> mapList, SafetyProblemTypeEnum safetyProblemTypeEnum) {
JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(mapList)); if (CollectionUtil.isNotEmpty(mapList)){
if (CollectionUtil.isNotEmpty(jsonArray)){
try { try {
logger.info("发送安全追溯问题主题---->{}", safetyProblemTypeEnum.getTopic()); logger.info("发送安全追溯问题主题---->{}", safetyProblemTypeEnum.getTopic());
emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), jsonArray.toString().getBytes(StandardCharsets.UTF_8), 2, false); emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), JSON.toJSONBytes(mapList), 2, false);
logger.info("发送安全追溯问题消息成功---->"); logger.info("发送安全追溯问题消息成功---->");
} catch (MqttException e) { } catch (MqttException e) {
logger.error("发送安全追溯问题设备信息消息失败---->{}", e.getMessage()); logger.error("发送安全追溯问题设备信息消息失败---->{}", e.getMessage());
......
...@@ -1302,6 +1302,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1302,6 +1302,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
pipeLengthQuery.must(existsQuery("SUPERVISORY_CODE")); pipeLengthQuery.must(existsQuery("SUPERVISORY_CODE"));
pipeLengthQuery.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE","")); pipeLengthQuery.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE",""));
SumAggregationBuilder pipeLengthAgg = AggregationBuilders.sum(countField).field("pipeLength").missing(0); SumAggregationBuilder pipeLengthAgg = AggregationBuilders.sum(countField).field("pipeLength").missing(0);
builder.query(pipeLengthQuery);
builder.aggregation(pipeLengthAgg).size(0); builder.aggregation(pipeLengthAgg).size(0);
request.source(builder); request.source(builder);
try { try {
......
...@@ -486,7 +486,9 @@ public class JGDPStatisticsServiceImpl { ...@@ -486,7 +486,9 @@ public class JGDPStatisticsServiceImpl {
pipeLengthQuery.must(QueryBuilders.existsQuery("pipeLength")); pipeLengthQuery.must(QueryBuilders.existsQuery("pipeLength"));
pipeLengthQuery.must(existsQuery("SUPERVISORY_CODE")); pipeLengthQuery.must(existsQuery("SUPERVISORY_CODE"));
pipeLengthQuery.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE", "")); pipeLengthQuery.mustNot(QueryBuilders.termQuery("SUPERVISORY_CODE", ""));
pipeLengthQuery.mustNot(QueryBuilders.termsQuery("STATUS", Arrays.asList("草稿", "已拒领", "待认领")));
SumAggregationBuilder pipeLengthAgg = AggregationBuilders.sum("pipeLengthSum").field("pipeLength").missing(0); SumAggregationBuilder pipeLengthAgg = AggregationBuilders.sum("pipeLengthSum").field("pipeLength").missing(0);
builder.query(pipeLengthQuery);
builder.aggregation(pipeLengthAgg).size(0); builder.aggregation(pipeLengthAgg).size(0);
request.source(builder); request.source(builder);
try { try {
......
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