Commit 1738e3e0 authored by suhuiguang's avatar suhuiguang

feat(jyjc): 报检开发调整

1.管道批量报检开发 2.管道报检信息推送及接收开发
parent 8ec77984
......@@ -147,7 +147,7 @@ public class JyjcInspectionApplicationController extends BaseController {
@RequestBody JyjcInspectionApplicationModel model,
@ApiParam(value = "客户端类型: jgAudit-监管审核;jgLook-监管查看") @RequestParam(value = "client", required = false, defaultValue = "jgAudit") String client
) {
Page<JyjcInspectionApplication> page = new Page<JyjcInspectionApplication>();
Page<JyjcInspectionApplication> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.queryForPageList(page, model, sort,client));
......
......@@ -3,7 +3,7 @@ package com.yeejoin.amos.boot.module.jyjc.biz.event.listener;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionDetectionSaveToDbEvent;
import com.yeejoin.amos.boot.module.jyjc.biz.event.listener.service.InspectionDetectionInfoUpdateService;
import com.yeejoin.amos.boot.module.jyjc.biz.event.listener.service.InspectionResultProcessor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
......@@ -29,7 +29,7 @@ public class InspectionDetectionSaveToDbEventListener implements ApplicationList
private final BlockingQueue<JyjcInspectionResult> blockingQueue = new LinkedBlockingQueue<>();
private final InspectionDetectionInfoUpdateService updateService;
private final InspectionResultProcessor updateService;
@Override
......@@ -46,7 +46,7 @@ public class InspectionDetectionSaveToDbEventListener implements ApplicationList
while (true) {
try {
JyjcInspectionResult jyjcInspectionResult = blockingQueue.take();
updateService.update(jyjcInspectionResult);
updateService.process(jyjcInspectionResult);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
......
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener.result;
public interface SupportableResultDataProcessor extends ResultDataProcessor{
boolean support(String equList);
}
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener.service;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.biz.event.listener.result.ResultProcessorFactory;
import com.yeejoin.amos.boot.module.jyjc.biz.result.factory.ResultProcessorFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
......@@ -10,12 +10,12 @@ import org.springframework.transaction.annotation.Transactional;
@Component
@Slf4j
@RequiredArgsConstructor
public class InspectionDetectionInfoUpdateService {
public class InspectionResultProcessor {
private final ResultProcessorFactory resultProcessorFactory;
@Transactional(rollbackFor = Exception.class)
public void update(JyjcInspectionResult jyjcInspectionResult) {
public void process(JyjcInspectionResult jyjcInspectionResult) {
resultProcessorFactory.getProcessor(jyjcInspectionResult.getEquList()).process(jyjcInspectionResult);
}
......
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener.result;
package com.yeejoin.amos.boot.module.jyjc.biz.result.factory;
import com.yeejoin.amos.boot.module.jyjc.biz.result.processor.core.ResultDataProcessor;
import com.yeejoin.amos.boot.module.jyjc.biz.result.factory.support.SupportableResultDataProcessor;
import com.yeejoin.amos.boot.module.jyjc.biz.result.wrapper.ResultDataProcessorWrapper;
import com.yeejoin.amos.component.robot.BadRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
......
package com.yeejoin.amos.boot.module.jyjc.biz.result.factory.support;
import com.yeejoin.amos.boot.module.jyjc.biz.result.processor.core.ResultDataProcessor;
public interface SupportableResultDataProcessor extends ResultDataProcessor {
boolean support(String equList);
}
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener.result;
package com.yeejoin.amos.boot.module.jyjc.biz.result.processor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......@@ -16,6 +16,7 @@ import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultAttachme
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultParam;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionResultParamService;
import com.yeejoin.amos.boot.module.jyjc.biz.event.publisher.BizEmqPublisher;
import com.yeejoin.amos.boot.module.jyjc.biz.result.factory.support.SupportableResultDataProcessor;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.JyjcInspectionResultServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
......@@ -27,7 +28,6 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgTechParamsPipelineMap
import com.yeejoin.amos.boot.module.ymt.api.mapper.UseInfoMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
......
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener.result;
package com.yeejoin.amos.boot.module.jyjc.biz.result.processor;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant;
import com.yeejoin.amos.boot.module.common.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.biz.event.publisher.BizEmqPublisher;
import com.yeejoin.amos.boot.module.jyjc.biz.result.factory.support.SupportableResultDataProcessor;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.JyjcInspectionResultServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
......@@ -17,11 +15,9 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgInspectionDetectionIn
import com.yeejoin.amos.boot.module.ymt.api.mapper.UseInfoMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Date;
import java.util.List;
......@@ -80,11 +76,6 @@ public class SingleEquipResultDataProcessor implements SupportableResultDataProc
record = info.getRecord();
bizEmqPublisher.sendInspectionMsgAfterSave(info, "update");
}
try {
bizEmqPublisher.getEmqKeeper().getMqttClient().publish(String.format(TZSCommonConstant.DATA_REFRESH_TOPIC, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE), JSONObject.toJSONString(Collections.singletonList(record)).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
log.error("发送数据变更emq消息失败:{}", e.getMessage(), e);
}
// 3.更新使用信息表最新的检验信息
useInfoMapper.updateByRecord(jyjcInspectionResult.getEquipUnicode(), jyjcInspectionResult.getNextInspectionDate(), jyjcInspectionResult.getInspectionType(), jyjcInspectionResult.getApplicationNo());
// 4.es更新下次检验日期
......
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener.result;
package com.yeejoin.amos.boot.module.jyjc.biz.result.wrapper;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.biz.result.processor.core.ResultDataProcessor;
import com.yeejoin.amos.boot.module.jyjc.biz.result.factory.support.SupportableResultDataProcessor;
public class ResultDataProcessorWrapper implements ResultDataProcessor {
private final SupportableResultDataProcessor delegate;
......
......@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
......@@ -27,10 +28,12 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jyjc.api.common.StringUtil;
import com.yeejoin.amos.boot.module.jyjc.api.dto.PipelineInspectionResultDto;
import com.yeejoin.amos.boot.module.jyjc.api.dto.PipelineResultItemDto;
import com.yeejoin.amos.boot.module.jyjc.api.entity.*;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionHistory;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultAttachment;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultParam;
import com.yeejoin.amos.boot.module.jyjc.api.enums.*;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionResultMapper;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationModel;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionResultDataModel;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionResultModel;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionResultAttachmentService;
......@@ -62,6 +65,8 @@ import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
......@@ -305,16 +310,21 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
JyjcInspectionResultModel dbResultModel = this.queryBySeq(model.getSequenceNbr());
// 更新使用信息、检验信息、技术参数
Set<String> records = this.updateTechParamAndInspectInfo(dbResultModel, jybgFile);
sendDataRefreshMsg(records);
return dbResultModel;
}
public void sendDataRefreshMsg(Set<String> records) {
try {
emqKeeper.getMqttClient().publish(String.format(TZSCommonConstant.DATA_REFRESH_TOPIC, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE), JSONObject.toJSONString(new ArrayList<>(records)).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
log.error("发送数据变更emq消息失败:{}", e.getMessage(), e);
}
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
try {
log.info("设备检验信息变化发送数据变更mqtt消息, 设备:{}", records);
emqKeeper.getMqttClient().publish(String.format(TZSCommonConstant.DATA_REFRESH_TOPIC, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE), JSONObject.toJSONString(new ArrayList<>(records)).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
log.error("发送数据变更emq消息失败:{}", e.getMessage(), e);
}
}
});
}
......@@ -792,6 +802,10 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
inspectionHistory.setRecDate(new Date());
jyjcInspectionHistoryService.save(inspectionHistory);
records.add(inspectionDetectionInfo.getRecord());
// 3.更新使用信息表,最新检验信息
useInfoMapper.updateByRecord(inspectionDetectionInfo.getRecord(), jyjcInspectionResult.getNextInspectionDate(), jyjcInspectionResult.getInspectionType(), jyjcInspectionResult.getApplicationNo());
// 4.更新es下次检验日期
commonService.updateEquipNextInspectDate(jyjcInspectionResult, inspectionDetectionInfo.getRecord());
} catch (Exception e) {
log.warn(e.getMessage());
throw new BadRequest("数据异常,请联系管理员!");
......@@ -920,8 +934,12 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
inspectionHistory.setRecUserId(RequestContext.getExeUserId());
jyjcInspectionHistoryService.update(inspectionHistory,
new LambdaUpdateWrapper<JyjcInspectionHistory>().eq(JyjcInspectionHistory::getSSeq, Long.valueOf(Objects.toString(sequenceNbr))));
// 3.更新使用信息表,最新检验信息
useInfoMapper.updateByRecord(inspectionDetectionInfo.getRecord(), jyjcInspectionResult.getNextInspectionDate(), jyjcInspectionResult.getInspectionType(), jyjcInspectionResult.getApplicationNo());
// 4.更新es下次检验日期
commonService.updateEquipNextInspectDate(jyjcInspectionResult, inspectionDetectionInfo.getRecord());
// 发送数据变更消息
emqKeeper.getMqttClient().publish(String.format(TZSCommonConstant.DATA_REFRESH_TOPIC, DataRefreshEvent.DataType.equipment.name(), DataRefreshEvent.Operation.UPDATE), JSONObject.toJSONString(Collections.singletonList(inspectionDetectionInfo.getRecord())).getBytes(StandardCharsets.UTF_8), 2, false);
sendDataRefreshMsg(Sets.newHashSet(inspectionDetectionInfo.getRecord()));
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BadRequest("数据异常,请联系管理员!");
......
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