Commit 9a04427c authored by suhuiguang's avatar suhuiguang

feat(重要提醒):业务新增提醒开发联调

1.使用登记、车用气瓶作废
parent 72fcb711
...@@ -140,12 +140,12 @@ public class EquipBackupHandler { ...@@ -140,12 +140,12 @@ public class EquipBackupHandler {
useInfoService.saveOrUpdate(useInfo); useInfoService.saveOrUpdate(useInfo);
// 检验流水 // 检验流水
List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfos = JSONObject.parseArray(eq.getString(BACKUP_JSON_KEY_INSPECTION_DETECTION_INFO), IdxBizJgInspectionDetectionInfo.class); List<IdxBizJgInspectionDetectionInfo> inspectionDetectionInfos = JSONObject.parseArray(eq.getString(BACKUP_JSON_KEY_INSPECTION_DETECTION_INFO), IdxBizJgInspectionDetectionInfo.class);
if (!inspectionDetectionInfos.isEmpty()) { if (inspectionDetectionInfos != null && !inspectionDetectionInfos.isEmpty()) {
inspectionDetectionInfoService.saveOrUpdateBatch(inspectionDetectionInfos); inspectionDetectionInfoService.saveOrUpdateBatch(inspectionDetectionInfos);
} }
// 施工流水 // 施工流水
List<IdxBizJgConstructionInfo> constructionInfoList = JSONObject.parseArray(eq.getString(BACKUP_JSON_KEY_CONSTRUCTION_INFO), IdxBizJgConstructionInfo.class); List<IdxBizJgConstructionInfo> constructionInfoList = JSONObject.parseArray(eq.getString(BACKUP_JSON_KEY_CONSTRUCTION_INFO), IdxBizJgConstructionInfo.class);
if (!constructionInfoList.isEmpty()) { if (constructionInfoList != null && !constructionInfoList.isEmpty()) {
constructionInfoService.saveOrUpdateBatch(constructionInfoList); constructionInfoService.saveOrUpdateBatch(constructionInfoList);
} }
// 技术参数 // 技术参数
......
package com.yeejoin.amos.boot.module.jg.biz.event;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
import java.util.List;
import java.util.Set;
/**
* @author Administrator
*/
@Getter
public class CancellationAndGradeEvent extends ApplicationEvent {
private final Set<String> projectContraptionIds;
private final List<String> records;
public CancellationAndGradeEvent(Object source, List<String> records, Set<String> projectContraptionIds) {
super(source);
this.projectContraptionIds = projectContraptionIds;
this.records = records;
}
}
...@@ -12,9 +12,7 @@ import java.util.Set; ...@@ -12,9 +12,7 @@ import java.util.Set;
@Getter @Getter
public class CancellationEvent extends ApplicationEvent { public class CancellationEvent extends ApplicationEvent {
private List<String> records; private final List<String> records;
private Set<String> projectContraptionIds;
/** /**
* Create a new {@code ApplicationEvent}. * Create a new {@code ApplicationEvent}.
* *
...@@ -25,10 +23,4 @@ public class CancellationEvent extends ApplicationEvent { ...@@ -25,10 +23,4 @@ public class CancellationEvent extends ApplicationEvent {
super(source); super(source);
this.records = records; this.records = records;
} }
public CancellationEvent(Object source, List<String> records, Set<String> projectContraptionIds) {
super(source);
this.records = records;
this.projectContraptionIds = projectContraptionIds;
}
} }
package com.yeejoin.amos.boot.module.jg.biz.event.dto;
import lombok.Data;
import java.util.List;
import java.util.Set;
@Data
public class CancelEquipItem {
private Set<String> projectContraptionIds;
private List<String> records;
}
package com.yeejoin.amos.boot.module.jg.biz.event.listener;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationAndGradeEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.dto.CancelEquipItem;
import com.yeejoin.amos.boot.module.jg.biz.event.listener.service.ManageStatusDataUpdateService;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
/**
* @author Administrator
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class CancelAndGradeEventListener {
@Value("${cancellation.deal.thread.number:1}")
private int threadNumber;
private final BlockingQueue<CancelEquipItem> queue = new LinkedBlockingQueue<>();
private final ManageStatusDataUpdateService updateService;
@EventListener(value = CancellationAndGradeEvent.class)
public void handleTransactionalEvent(CancellationAndGradeEvent event) {
log.info("收到作废且更新评分消息:{}", JSONObject.toJSONString(event));
List<String> records = event.getRecords();
CancelEquipItem cancelEquipItem = new CancelEquipItem();
cancelEquipItem.setRecords(records);
cancelEquipItem.setProjectContraptionIds(event.getProjectContraptionIds());
queue.add(cancelEquipItem);
}
@PostConstruct
public void init() {
ExecutorService executorService = Executors.newFixedThreadPool(threadNumber, r -> {
Thread t = new Thread(r);
t.setName("CancelAndGradeEventWorker-" + t.getId());
return t;
});
for (int i = 0; i < threadNumber; i++) {
executorService.execute(() -> {
while (true) {
try {
CancelEquipItem cancelEquipItem = queue.take();
log.info("线程 {} 开始处理 cancelEquipItem: {}", Thread.currentThread().getName(), cancelEquipItem);
updateService.dealData(cancelEquipItem);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
});
}
}
}
package com.yeejoin.amos.boot.module.jg.biz.event.listener; package com.yeejoin.amos.boot.module.jg.biz.event.listener;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent; import com.yeejoin.amos.boot.module.jg.biz.event.CancellationEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher; import com.yeejoin.amos.boot.module.jg.biz.event.listener.service.ManageStatusDataUpdateService;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -31,22 +29,14 @@ public class CancellationEventListener { ...@@ -31,22 +29,14 @@ public class CancellationEventListener {
private final BlockingQueue<String> queue = new LinkedBlockingQueue<>(); private final BlockingQueue<String> queue = new LinkedBlockingQueue<>();
private final EventPublisher publisher;
private final ManageStatusDataUpdateService updateService; private final ManageStatusDataUpdateService updateService;
@EventListener(value = CancellationEvent.class) @EventListener(value = CancellationEvent.class)
public void handleTransactionalEvent(CancellationEvent event) { public void handleTransactionalEvent(CancellationEvent event) {
log.info("收到作废消息:{}", JSONObject.toJSONString(event));
List<String> records = event.getRecords(); List<String> records = event.getRecords();
log.info("收到作废消息:{}", JSONObject.toJSONString(records));
queue.addAll(records); queue.addAll(records);
castEvent2EquipEditEvent(event);
}
private void castEvent2EquipEditEvent(CancellationEvent event) {
if (event.getProjectContraptionIds() != null && !event.getProjectContraptionIds().isEmpty()) {
publisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_PROJECT.name(), event.getProjectContraptionIds(), EquipCreateOrEditEvent.EquipType.project));
}
} }
@PostConstruct @PostConstruct
...@@ -62,7 +52,7 @@ public class CancellationEventListener { ...@@ -62,7 +52,7 @@ public class CancellationEventListener {
try { try {
String record = queue.take(); String record = queue.take();
log.info("线程 {} 开始处理 record: {}", Thread.currentThread().getName(), record); log.info("线程 {} 开始处理 record: {}", Thread.currentThread().getName(), record);
updateService.dealData(record); updateService.dealData(record, false);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
......
package com.yeejoin.amos.boot.module.jg.biz.event.listener; package com.yeejoin.amos.boot.module.jg.biz.event.listener.service;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory; 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.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.event.dto.CancelEquipItem;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher; import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent; import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService; import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
...@@ -17,6 +18,7 @@ import org.springframework.stereotype.Service; ...@@ -17,6 +18,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
@Service @Service
@Slf4j @Slf4j
...@@ -34,7 +36,23 @@ public class ManageStatusDataUpdateService { ...@@ -34,7 +36,23 @@ public class ManageStatusDataUpdateService {
private final IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService; private final IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void dealData(String record) { public void dealData(CancelEquipItem cancelEquipItem) {
// 设备、气瓶、管道纳管状态处理
cancelEquipItem.getRecords().forEach(record -> {
dealData(record, true);
});
// 装置评分处理
castEvent2EquipEditEvent(cancelEquipItem.getProjectContraptionIds());
}
/**
* 处理单个设备纳管状态
*
* @param record 设备唯一标识
* @param isForward 是否进行转发
*/
@Transactional(rollbackFor = Exception.class)
public void dealData(String record, Boolean isForward) {
log.info("开始检查设备的引用:{}", record); log.info("开始检查设备的引用:{}", record);
// 所有业务单据(除去作废、删除状态单据),有在引用设备的则不修改设备纳管状态 // 所有业务单据(除去作废、删除状态单据),有在引用设备的则不修改设备纳管状态
Boolean inUsed = commonService.checkEquipIsUsed(record); Boolean inUsed = commonService.checkEquipIsUsed(record);
...@@ -64,14 +82,23 @@ public class ManageStatusDataUpdateService { ...@@ -64,14 +82,23 @@ public class ManageStatusDataUpdateService {
} }
esEquipmentCategoryDao.save(esEquipmentCategoryDto); esEquipmentCategoryDao.save(esEquipmentCategoryDto);
}); });
castEvent2EquipEditEvent(record);
} catch (Exception e) { } catch (Exception e) {
log.error("设备作废异常:{}", e.getMessage()); log.error("设备作废异常:{}", e.getMessage());
} }
} }
if (isForward) {
castEvent2EquipEditEvent(record);
}
} }
private void castEvent2EquipEditEvent(String record) { private void castEvent2EquipEditEvent(String record) {
publisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), Sets.newHashSet(record), EquipCreateOrEditEvent.EquipType.equip)); publisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_EQUIP.name(), Sets.newHashSet(record), EquipCreateOrEditEvent.EquipType.equip));
} }
private void castEvent2EquipEditEvent(Set<String> projectContraptionIds) {
if (projectContraptionIds != null && !projectContraptionIds.isEmpty()) {
publisher.publish(new EquipCreateOrEditEvent(this, BusinessTypeEnum.JG_NEW_PROJECT.name(), projectContraptionIds, EquipCreateOrEditEvent.EquipType.project));
}
}
} }
...@@ -5,16 +5,17 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; ...@@ -5,16 +5,17 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity; import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory; 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.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.GradeStrategyFactory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent; import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.service.IQualityScoreUpdate; import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.service.IQualityScoreUpdate;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.GradeStrategyFactory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto; import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.service.CommonReminderService; import com.yeejoin.amos.boot.module.jg.biz.reminder.service.CommonReminderService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -22,6 +23,7 @@ import org.springframework.scheduling.annotation.Async; ...@@ -22,6 +23,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
...@@ -52,6 +54,10 @@ public class EquipQualityScoreUpdateService implements IQualityScoreUpdate { ...@@ -52,6 +54,10 @@ public class EquipQualityScoreUpdateService implements IQualityScoreUpdate {
public void update(String bizType, Set<String> records) { public void update(String bizType, Set<String> records) {
records.parallelStream().forEach(record -> { records.parallelStream().forEach(record -> {
Optional<ESEquipmentCategoryDto> op = equipmentCategoryDao.findById(record); Optional<ESEquipmentCategoryDto> op = equipmentCategoryDao.findById(record);
// 压力管道不进行管道登记的计算
if (op.isPresent() && op.get().getEQU_LIST_CODE().equals(EquipmentClassifityEnum.YLGD.getCode())) {
return;
}
Integer level = this.getReminderLevel(bizType, record); Integer level = this.getReminderLevel(bizType, record);
op.ifPresent(equipmentCategory -> { op.ifPresent(equipmentCategory -> {
equipmentCategory.setDataQualityScore(level); equipmentCategory.setDataQualityScore(level);
...@@ -60,6 +66,7 @@ public class EquipQualityScoreUpdateService implements IQualityScoreUpdate { ...@@ -60,6 +66,7 @@ public class EquipQualityScoreUpdateService implements IQualityScoreUpdate {
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord, record); updateWrapper.eq(IdxBizJgUseInfo::getRecord, record);
updateWrapper.set(IdxBizJgUseInfo::getDataQualityScore, level); updateWrapper.set(IdxBizJgUseInfo::getDataQualityScore, level);
updateWrapper.set(TzsBaseEntity::getRecDate, new Date());
idxBizJgUseInfoService.update(updateWrapper); idxBizJgUseInfoService.update(updateWrapper);
}); });
} }
......
...@@ -2,11 +2,12 @@ package com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.service.impl; ...@@ -2,11 +2,12 @@ package com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.GradeStrategyFactory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent; import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.service.IQualityScoreUpdate; import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.service.IQualityScoreUpdate;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.GradeStrategyFactory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto; import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.service.CommonReminderService; import com.yeejoin.amos.boot.module.jg.biz.reminder.service.CommonReminderService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgProjectContraptionServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgProjectContraptionServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
...@@ -17,6 +18,7 @@ import org.springframework.scheduling.annotation.Async; ...@@ -17,6 +18,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.Set; import java.util.Set;
@Component @Component
...@@ -44,6 +46,7 @@ public class ProjectQualityScoreUpdateService implements IQualityScoreUpdate { ...@@ -44,6 +46,7 @@ public class ProjectQualityScoreUpdateService implements IQualityScoreUpdate {
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgProjectContraption::getSequenceNbr, projectContraptionId); updateWrapper.eq(IdxBizJgProjectContraption::getSequenceNbr, projectContraptionId);
updateWrapper.set(IdxBizJgProjectContraption::getDataQualityScore, level); updateWrapper.set(IdxBizJgProjectContraption::getDataQualityScore, level);
updateWrapper.set(BaseEntity::getRecDate, new Date());
idxBizJgProjectContraptionService.update(updateWrapper); idxBizJgProjectContraptionService.update(updateWrapper);
}); });
} }
......
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