Commit 14f84aa3 authored by tianbo's avatar tianbo

fix:1、大屏问题修复;2、安全追溯维保备案变码修改

parent c0b2e138
......@@ -11,9 +11,12 @@ import java.util.Date;
@ApiModel(value="maintenanceRecordInfo", description="")
public class MaintenanceInfoModelForWX {
@ApiModelProperty(value = "最近维保日期")
@ApiModelProperty(value = "维保合同开始日期")
private Date informStart;
@ApiModelProperty(value = "维保合同结束日期")
private Date informEnd;
@ApiModelProperty(value = "维保单位")
private String meUnitName;
......
package com.yeejoin.amos.boot.module.jg.biz.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
......@@ -16,7 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.Optional;
import java.util.List;
import java.util.stream.Collectors;
/**
* WBCQEventHandler 类实现了 SafetyProblemEventHandler 接口,
......@@ -48,25 +49,25 @@ public class JYBJEventHandler implements SafetyProblemEventHandler {
@Override
public void handle(SafetyProblemEvent event) {
// 此处为处理安全问题事件的逻辑代码
handleInspectionRecord(JSON.parseObject(event.getMessage().toString()));
JSONArray jsonArray = JSONObject.parseArray(event.getMessage().toString());
handleInspectionRecord(jsonArray);
}
private void handleInspectionRecord(JSONObject jsonObject) {
String equipRecord = jsonObject.getString("record");
if (!ValidationUtil.isEmpty(equipRecord)) {
private void handleInspectionRecord(JSONArray jsonArray) {
List<String> equipRecords = jsonArray.stream().map(obj -> JSONObject.parseObject(obj.toString()).getString("record")).collect(Collectors.toList());
if (!ValidationUtil.isEmpty(equipRecords)) {
safetyProblemTracingService.lambdaUpdate()
.set(SafetyProblemTracing::getProblemStatusCode, SafetyProblemStatusEnum.HANDLED.getCode())
.set(SafetyProblemTracing::getProblemStatus, SafetyProblemStatusEnum.HANDLED.getName())
.eq(SafetyProblemTracing::getSourceId, equipRecord)
.in(SafetyProblemTracing::getSourceId, equipRecords)
.eq(SafetyProblemTracing::getProblemTypeCode, SafetyProblemTypeEnum.JYCQ.getCode()).update();
idxBizJgOtherInfoService.lambdaUpdate().set(IdxBizJgOtherInfo::getStatus, SafetyProblemStatusEnum.HANDLED.getCode())
.eq(IdxBizJgOtherInfo::getRecord, equipRecord).update();
Optional<ESEquipmentCategoryDto> equipEsDto = esEquipmentCategory.findById(equipRecord);
if (equipEsDto.isPresent()) {
ESEquipmentCategoryDto equipDto = equipEsDto.get();
equipDto.setProblemStatus(SafetyProblemStatusEnum.HANDLED.getCode());
esEquipmentCategory.save(equipDto);
.in(IdxBizJgOtherInfo::getRecord, equipRecords).update();
Iterable<ESEquipmentCategoryDto> equipEsDtoIter = esEquipmentCategory.findAllById(equipRecords);
for (ESEquipmentCategoryDto equipEsDto : equipEsDtoIter) {
equipEsDto.setProblemStatus(SafetyProblemStatusEnum.HANDLED.getCode());
}
esEquipmentCategory.saveAll(equipEsDtoIter);
}
}
}
......
package com.yeejoin.amos.boot.module.jg.biz.handler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.event.SafetyProblemEvent;
......@@ -32,12 +33,12 @@ public class JYCQEventHandler implements SafetyProblemEventHandler {
@Override
public void handle(SafetyProblemEvent event) {
// 此处为处理安全问题事件的逻辑代码
JSONObject jsonObject = JSONObject.parseObject(event.getMessage().toString());
generateProblem(jsonObject);
JSONArray jsonArray = JSONObject.parseArray(event.getMessage().toString());
generateProblem(jsonArray);
}
private void generateProblem(JSONObject jsonObject) {
SafetyProblemTopicMessage.generateProblem(jsonObject, SafetyProblemTypeEnum.JYCQ, safetyProblemTracingService);
private void generateProblem(JSONArray jsonArray) {
SafetyProblemTopicMessage.generateProblem(jsonArray, SafetyProblemTypeEnum.JYCQ, safetyProblemTracingService);
}
}
......@@ -23,7 +23,7 @@ public class SafetyProblemEventHandlerFactory {
if (topic.startsWith(SafetyProblemTypeEnum.WBCQ.getTopic())) {
return new WBCQEventHandler(safetyProblemTracingService);
} else if (topic.startsWith(SafetyProblemTypeEnum.WBBA.getTopic())) {
return new WBBAEventHandler();
return new WBBAEventHandler(safetyProblemTracingService, idxBizJgOtherInfoService, esEquipmentCategory);
} else if (topic.startsWith(SafetyProblemTypeEnum.JYCQ.getTopic())) {
return new JYCQEventHandler(safetyProblemTracingService);
} else if (topic.startsWith(SafetyProblemTypeEnum.JYBJ.getTopic())) {
......
package com.yeejoin.amos.boot.module.jg.biz.handler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.entity.SafetyProblemTracing;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.event.SafetyProblemEvent;
import com.yeejoin.amos.boot.module.jg.api.event.handler.SafetyProblemEventHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgOtherInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.SafetyProblemTracingServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgOtherInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.List;
import java.util.stream.Collectors;
/**
* WBBAEventHandler 类实现了 SafetyProblemEventHandler 接口,
......@@ -12,6 +26,19 @@ import org.springframework.stereotype.Component;
@Component
public class WBBAEventHandler implements SafetyProblemEventHandler {
SafetyProblemTracingServiceImpl safetyProblemTracingService;
IdxBizJgOtherInfoServiceImpl idxBizJgOtherInfoService;
ESEquipmentCategory esEquipmentCategory;
@Autowired
public WBBAEventHandler(SafetyProblemTracingServiceImpl safetyProblemTracingService, IdxBizJgOtherInfoServiceImpl idxBizJgOtherInfoService, ESEquipmentCategory esEquipmentCategory) {
this.safetyProblemTracingService = safetyProblemTracingService;
this.idxBizJgOtherInfoService = idxBizJgOtherInfoService;
this.esEquipmentCategory = esEquipmentCategory;
}
/**
* 处理安全问题事件。
*
......@@ -21,11 +48,26 @@ public class WBBAEventHandler implements SafetyProblemEventHandler {
@Override
public void handle(SafetyProblemEvent event) {
// 此处为处理安全问题事件的逻辑代码
handleMaintenanceRecord(JSONObject.parseObject(event.getMessage().toString()));
JSONArray jsonArray = JSONObject.parseArray(event.getMessage().toString());
handleMaintenanceRecord(jsonArray);
}
private void handleMaintenanceRecord(JSONObject jsonObject) {
// JSONArray maintenanceRecords = JSONArray.parseArray(String.valueOf(jsonObject));
private void handleMaintenanceRecord(JSONArray jsonArray) {
List<String> equipRecords = jsonArray.stream().map(obj -> JSONObject.parseObject(obj.toString()).getString("record")).collect(Collectors.toList());
if (!ValidationUtil.isEmpty(equipRecords)) {
safetyProblemTracingService.lambdaUpdate()
.set(SafetyProblemTracing::getProblemStatusCode, SafetyProblemStatusEnum.HANDLED.getCode())
.set(SafetyProblemTracing::getProblemStatus, SafetyProblemStatusEnum.HANDLED.getName())
.in(SafetyProblemTracing::getSourceId, equipRecords)
.eq(SafetyProblemTracing::getProblemTypeCode, SafetyProblemTypeEnum.WBCQ.getCode()).update();
idxBizJgOtherInfoService.lambdaUpdate().set(IdxBizJgOtherInfo::getStatus, SafetyProblemStatusEnum.HANDLED.getCode())
.in(IdxBizJgOtherInfo::getRecord, equipRecords).update();
Iterable<ESEquipmentCategoryDto> equipEsDtoIter = esEquipmentCategory.findAllById(equipRecords);
for (ESEquipmentCategoryDto equipEsDto : equipEsDtoIter) {
equipEsDto.setProblemStatus(SafetyProblemStatusEnum.HANDLED.getCode());
}
esEquipmentCategory.saveAll(equipEsDtoIter);
}
}
}
package com.yeejoin.amos.boot.module.jg.biz.handler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.event.SafetyProblemEvent;
......@@ -32,12 +33,12 @@ public class WBCQEventHandler implements SafetyProblemEventHandler {
@Override
public void handle(SafetyProblemEvent event) {
// 此处为处理安全问题事件的逻辑代码
JSONObject jsonObject = JSONObject.parseObject(event.getMessage().toString());
generateProblem(jsonObject);
JSONArray jsonArray = JSONObject.parseArray(event.getMessage().toString());
generateProblem(jsonArray);
}
private void generateProblem(JSONObject jsonObject) {
SafetyProblemTopicMessage.generateProblem(jsonObject, SafetyProblemTypeEnum.WBCQ, safetyProblemTracingService);
private void generateProblem(JSONArray jsonArray) {
SafetyProblemTopicMessage.generateProblem(jsonArray, SafetyProblemTypeEnum.WBCQ, safetyProblemTracingService);
}
}
......@@ -81,7 +81,7 @@ public class SafetyProblemTopicMessage extends EmqxListener {
try {
while (true) {
SafetyProblemEvent safetyProblemMessageEvent = blockingQueue.take();
JSONObject jsonObject = JSON.parseObject(safetyProblemMessageEvent.getMessage().toString());
JSONArray jsonObject = JSON.parseArray(safetyProblemMessageEvent.getMessage().toString());
log.info("接收到问题生产消息:{}", jsonObject);
SafetyProblemEventHandler eventHandler = SafetyProblemEventHandlerFactory.createProblemHandler(safetyProblemMessageEvent.getTopic());
eventHandler.handle(safetyProblemMessageEvent);
......@@ -103,13 +103,13 @@ public class SafetyProblemTopicMessage extends EmqxListener {
log.info("接收问题生产消息完成");
}
public static void generateProblem(JSONObject jsonObject, SafetyProblemTypeEnum problemTypeEnum, SafetyProblemTracingServiceImpl safetyProblemTracingService) {
if (jsonObject == null || problemTypeEnum == null) {
public static void generateProblem(JSONArray jsonArray, SafetyProblemTypeEnum problemTypeEnum, SafetyProblemTracingServiceImpl safetyProblemTracingService) {
if (jsonArray == null || problemTypeEnum == null) {
throw new IllegalArgumentException("jsonObject and problemTypeEnum must not be null.");
}
JSONArray records = jsonObject.getJSONArray(problemTypeEnum.getMsgKey());
if (!ValidationUtil.isEmpty(records)) {
List<SafetyProblemTracing> safetyProblemTracingList = records.stream().map(item -> {
// JSONArray records = jsonObject.getJSONArray(problemTypeEnum.getMsgKey());
if (!ValidationUtil.isEmpty(jsonArray)) {
List<SafetyProblemTracing> safetyProblemTracingList = jsonArray.stream().map(item -> {
if (!(item instanceof JSONObject)) {
throw new IllegalArgumentException("item is not a JSONObject.");
}
......
......@@ -14,7 +14,6 @@ import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContract;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContractEq;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
......@@ -718,6 +717,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
maintenanceRecordInfoList.add(info);
});
idxBizJgMaintenanceRecordInfoService.saveBatch(maintenanceRecordInfoList);
// 维保备案后更新安全追溯对应设备状态
emqKeeper.getMqttClient().publish(SafetyProblemTypeEnum.WBBA.getTopic(), JSON.toJSONBytes(maintenanceRecordInfoList), 2, false);
}
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
......@@ -80,10 +81,11 @@ public class SafetyProblemTracingGenServiceImpl{
esEquipmentCategoryDto.add(equipmentCategoryDto);
}
esEquipmentCategory.saveAll(esEquipmentCategoryDto);
JSONObject jsonObject = new JSONObject();
jsonObject.put(safetyProblemTypeEnum.getMsgKey(), mapList);
// JSONObject jsonObject = new JSONObject();
// jsonObject.put(safetyProblemTypeEnum.getMsgKey(), mapList);
JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(mapList));
try {
emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), jsonObject.toString().getBytes(StandardCharsets.UTF_8), 2, false);
emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), jsonArray.toString().getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
logger.error("发送安全追溯问题设备信息消息失败---->{}", e.getMessage());
throw new RuntimeException(e);
......
......@@ -7,7 +7,7 @@
</select>
<select id="queryByUseCode" resultType="com.yeejoin.amos.boot.module.statistics.api.entity.TzBaseEnterpriseInfo">
select * from tz_base_enterprise_info where use_code = #{useCode}
select * from tz_base_enterprise_info where use_unit_code = #{useCode}
</select>
......
......@@ -16,6 +16,7 @@ import com.yeejoin.amos.feign.morphic.model.FormSceneModel;
import jdk.nashorn.api.scripting.ScriptObjectMirror;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
......@@ -57,6 +58,9 @@ public class DPSubServiceImpl {
@Autowired
DPSubBizServiceImpl dpSubBizService;
@Value("${supervisionCode.prefix:https://sxtzsb.sxsei.com:19435/tzs?code=}")
private String supervisionCodePrefix;
public JSONObject commonQuery(String template, @RequestBody Map<String, Object> param) {
JSONObject result = new JSONObject();
String templateJson = DpSubUtils.getFileContent(template + ".json");
......@@ -533,7 +537,7 @@ public class DPSubServiceImpl {
} else if ("异常".equals(problemStatus) || "未处理".equals(problemStatus)) {
color = "red";
}
qrcode.put("value", !ValidationUtil.isEmpty(result.get("SUPERVISORY_CODE")) ? "https://sxtzsb.sxsei.com:9435/tzs/?code=" + result.get("SUPERVISORY_CODE") : result.get("USE_ORG_CODE"));
qrcode.put("value", !ValidationUtil.isEmpty(result.get("SUPERVISORY_CODE")) ? supervisionCodePrefix + result.get("SUPERVISORY_CODE") : result.get("USE_ORG_CODE"));
qrcode.put("status", problemStatus);
qrcode.put("color", color);
return qrcode;
......
......@@ -2443,6 +2443,7 @@ public class JGDPStatisticsServiceImpl {
LambdaQueryWrapper<SafetyProblemTracing> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SafetyProblemTracing::getSourceId, record);
lambdaQueryWrapper.orderByDesc(SafetyProblemTracing::getRecDate);
lambdaQueryWrapper.eq(SafetyProblemTracing::getProblemStatusCode, SafetyProblemStatusEnum.UNHANDLED.getCode());
List<SafetyProblemTracing> safetyProblemTracings = safetyProblemTracingMapper.selectList(lambdaQueryWrapper);
if (!ObjectUtils.isEmpty(safetyProblemTracings)) {
objMap.put("problemStatus", ProblemStatusEnum.getNameByDesc.get(safetyProblemTracings.get(0).getProblemStatus()));
......
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