Commit 5d1ff320 authored by suhuiguang's avatar suhuiguang

feat(重要提醒):设备新增提醒开发

1.重要提醒设备开发联调测试
parent e6141d87
...@@ -190,4 +190,10 @@ public class ESEquipmentCategoryDto { ...@@ -190,4 +190,10 @@ public class ESEquipmentCategoryDto {
*/ */
@Field(type = FieldType.Boolean, name = "IS_DO_BUSINESS") @Field(type = FieldType.Boolean, name = "IS_DO_BUSINESS")
private Boolean IS_DO_BUSINESS; private Boolean IS_DO_BUSINESS;
/**
* 数据质量等级
*/
@Field(type = FieldType.Integer)
private Integer dataQualityScore;
} }
...@@ -75,4 +75,10 @@ public class TzsJgColumnReminderRule extends BaseEntity { ...@@ -75,4 +75,10 @@ public class TzsJgColumnReminderRule extends BaseEntity {
@TableField("whether_vehicle_cylinder") @TableField("whether_vehicle_cylinder")
private String whetherVehicleCylinder; private String whetherVehicleCylinder;
/**
* 是否已经登记
*/
@TableField("is_register")
private Boolean isRegister;
} }
...@@ -54,14 +54,14 @@ public class PieLineDataChangeServiceImpl { ...@@ -54,14 +54,14 @@ public class PieLineDataChangeServiceImpl {
private final CommonEquipDataProcessService commonEquipDataProcessService; private final CommonEquipDataProcessService commonEquipDataProcessService;
private final SnowflakeIdUtil idUtil;
private final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionServiceImpl; private final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionServiceImpl;
private final EquipChangeDataUpdateServiceImpl equipChangeDataUpdateServiceImpl; private final EquipChangeDataUpdateServiceImpl equipChangeDataUpdateServiceImpl;
private final IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineService; private final IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineService;
private final SnowflakeIdUtil idUtil;
private final PieLineLevelTypeHandler pieLineLevelTypeHandler; private final PieLineLevelTypeHandler pieLineLevelTypeHandler;
private final CbDataDictTypeHandler cbDataDictTypeHandler; private final CbDataDictTypeHandler cbDataDictTypeHandler;
......
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.editEquip;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.DefaultReminder;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 设备气瓶编辑-提醒处理器
*/
@Component
public class EditEquipReminderAdapter extends DefaultReminder {
public EditEquipReminderAdapter(ApplicationContext applicationContext) {
super(applicationContext);
}
@Override
protected IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page) {
return null;
}
@Override
protected List<ReminderItemDto> realtimeParse(String bizId) {
return Collections.emptyList();
}
@Override
protected IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
return null;
}
@Override
protected MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) {
return null;
}
@Override
protected MatchItemDto setMatchItem(String bizId) {
return null;
}
@Override
public String supportBizType() {
return "JG_EQUIP_EDIT";
}
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.editProject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.DefaultReminder;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 装置编辑-提醒处理器
*/
@Component
public class EditProjectReminderAdapter extends DefaultReminder {
public EditProjectReminderAdapter(ApplicationContext applicationContext) {
super(applicationContext);
}
@Override
protected IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page) {
return null;
}
@Override
protected List<ReminderItemDto> realtimeParse(String bizId) {
return Collections.emptyList();
}
@Override
protected IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
return null;
}
@Override
protected MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) {
return null;
}
@Override
protected MatchItemDto setMatchItem(String bizId) {
return null;
}
@Override
public String supportBizType() {
return "JG_EDIT_PROJECT";
}
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
import java.util.Set;
@Getter
public class EquipCreateOrEditEvent extends ApplicationEvent {
/**
* 业务类型
*/
private final String bizType;
/**
* 变更的设备/装置集合
*/
private final Set<String> updatedIds;
/**
* 资源类型区分设备还是装置
*/
private final EquipType equipType;
public EquipCreateOrEditEvent(Object source, String bizType, Set<String> records, Set<String> updatedIds, EquipType equipType) {
super(source);
this.bizType = bizType;
this.updatedIds = updatedIds;
this.equipType = equipType;
}
public enum EquipType {
equip,
project
}
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.listener;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.EquipCreateOrEditEvent;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.QualityScoreUpdateFactory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.ReminderFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionalEventListener;
import javax.annotation.PostConstruct;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.IntStream;
/**
* @author Administrator
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class EquipOperationEventHandler {
@Value("${equip.opEvent.deal.thread.number:1}")
private int threadNumber;
private final ReminderFactory reminderFactory;
private final QualityScoreUpdateFactory qualityScoreUpdateFactory;
private final BlockingQueue<EquipCreateOrEditEvent> queue = new LinkedBlockingQueue<>();
private ExecutorService executorService;
@TransactionalEventListener(value = EquipCreateOrEditEvent.class)
@Async
public void onEquipCreateOrEdit(EquipCreateOrEditEvent event) {
log.info("数据质量等级处理器,收到设备装置数据保存消息:{}", JSONObject.toJSONString(event));
queue.add(event);
}
@PostConstruct
public void init() {
executorService = Executors.newFixedThreadPool(threadNumber);
IntStream.range(0, threadNumber).forEach(i -> {
executorService.execute(() -> {
while (true) {
try {
EquipCreateOrEditEvent event = queue.take();
processEvent(event);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
});
});
}
private void processEvent(EquipCreateOrEditEvent event) {
qualityScoreUpdateFactory.getUpdater(event.getEquipType()).update(event.getBizType(), event.getUpdatedIds());
}
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.service;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.EquipCreateOrEditEvent;
import java.util.Set;
public interface IQualityScoreUpdate {
Boolean support(EquipCreateOrEditEvent.EquipType equipType);
void update(String bizType, Set<String> bizIds);
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.EquipCreateOrEditEvent;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.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.ReminderItemDto;
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.IdxBizJgUseInfoServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
@Component
@RequiredArgsConstructor
public class EquipQualityScoreUpdateService implements IQualityScoreUpdate {
private final ESEquipmentCategory equipmentCategoryDao;
private final IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
private final IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
private final CommonReminderService commonReminderService;
@Value("${grade.calculation.strategy:MAX_GRADE}")
private String activeStrategy;
private final GradeStrategyFactory gradeStrategyFactory;
@Override
public Boolean support(EquipCreateOrEditEvent.EquipType equipType) {
return EquipCreateOrEditEvent.EquipType.equip.equals(equipType);
}
@Async
@Override
public void update(String bizType, Set<String> records) {
records.parallelStream().forEach(record -> {
Optional<ESEquipmentCategoryDto> op = equipmentCategoryDao.findById(record);
Integer level = this.getReminderLevel(bizType, record);
op.ifPresent(equipmentCategory -> {
equipmentCategory.setDataQualityScore(level);
equipmentCategoryDao.save(equipmentCategory);
});
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord, record);
updateWrapper.set(IdxBizJgUseInfo::getDataQualityScore, level);
idxBizJgUseInfoService.update(updateWrapper);
});
}
public Integer getReminderLevel(String bizType, String record) {
MatchItemDto matchItemDto = MatchItemDto.builder().build();
IdxBizJgUseInfo useInfo = getIdxBizJgUseInfo(record);
IdxBizJgRegisterInfo registerInfo = getIdxBizJgRegisterInfo(record);
matchItemDto.setBizType(bizType);
matchItemDto.setEquList(registerInfo.getEquList());
matchItemDto.setEquCategory(registerInfo.getEquCategory());
matchItemDto.setEquDefine(registerInfo.getEquDefine());
matchItemDto.setRegType(CommonReminderService.getRegTypeByDataSource(useInfo.getDataSource()));
matchItemDto.setIsRegister(useInfo.getIsIntoManagement() && StringUtils.isNotEmpty(registerInfo.getUseOrgCode()));
matchItemDto.setWhetherVehicleCylinder(StringUtils.isNotEmpty(registerInfo.getWhetherVehicleCylinder()) ? registerInfo.getWhetherVehicleCylinder() : "0");
ReminderItemDto reminderItemDto = new ReminderItemDto();
reminderItemDto.setEquipId(record);
reminderItemDto.setEquipNo(registerInfo.getEquCode());
reminderItemDto.setEquipName(registerInfo.getProductName());
reminderItemDto.setDetailData(commonReminderService.getEquipDetailByRecord(record));
return gradeStrategyFactory.getStrategy(activeStrategy).calculateGrade(Collections.singletonList(reminderItemDto), matchItemDto);
}
private IdxBizJgUseInfo getIdxBizJgUseInfo(String record) {
return idxBizJgUseInfoService.getOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, record)
.select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getIsIntoManagement, IdxBizJgUseInfo::getDataSource));
}
private IdxBizJgRegisterInfo getIdxBizJgRegisterInfo(String record) {
return idxBizJgRegisterInfoService.getOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>()
.eq(IdxBizJgRegisterInfo::getRecord, record)
.select(TzsBaseEntity::getSequenceNbr,
IdxBizJgRegisterInfo::getRecord,
IdxBizJgRegisterInfo::getEquCategory,
IdxBizJgRegisterInfo::getEquDefine,
IdxBizJgRegisterInfo::getEquList,
IdxBizJgRegisterInfo::getWhetherVehicleCylinder,
IdxBizJgRegisterInfo::getProductName));
}
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.EquipCreateOrEditEvent;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.service.IQualityScoreUpdate;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.GradeStrategyFactory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.ReminderFieldDiff;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
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.ymt.api.entity.IdxBizJgProjectContraption;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Set;
@Component
@RequiredArgsConstructor
public class ProjectQualityScoreUpdateService implements IQualityScoreUpdate {
private final GradeStrategyFactory gradeStrategyFactory;
private final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionService;
@Value("${grade.calculation.strategy:MAX_GRADE}")
private String activeStrategy;
@Override
public Boolean support(EquipCreateOrEditEvent.EquipType equipType) {
return EquipCreateOrEditEvent.EquipType.project.equals(equipType);
}
@Async
@Override
public void update(String bizType, Set<String> projectContraptionIds) {
projectContraptionIds.parallelStream().forEach(projectContraptionId -> {
Integer level = this.getReminderLevel(bizType, projectContraptionId);
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgProjectContraption::getSequenceNbr, projectContraptionId);
updateWrapper.set(IdxBizJgProjectContraption::getDataQualityScore, level);
idxBizJgProjectContraptionService.update(updateWrapper);
});
}
public Integer getReminderLevel(String bizType, String projectContraptionId) {
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionService.getById(projectContraptionId);
MatchItemDto matchItemDto = MatchItemDto.builder().build();
matchItemDto.setBizType(bizType);
matchItemDto.setEquList(projectContraption.getEquList());
matchItemDto.setEquCategory(projectContraption.getEquCategory());
matchItemDto.setEquDefine(projectContraption.getEquDefine());
matchItemDto.setRegType(CommonReminderService.getRegTypeByDataSource(projectContraption.getDataSource()));
matchItemDto.setIsRegister(projectContraption.getIsIntoManagement() && StringUtils.isNotEmpty(projectContraption.getUseRegistrationCode()));
ReminderItemDto reminderItemDto = new ReminderItemDto();
reminderItemDto.setEquipId(projectContraptionId);
reminderItemDto.setEquipNo(projectContraption.getProjectContraptionNo());
reminderItemDto.setEquipName(projectContraption.getProjectContraption());
reminderItemDto.setDetailData(BeanUtil.beanToMap(matchItemDto));
return gradeStrategyFactory.getStrategy(activeStrategy).calculateGrade(Collections.singletonList(reminderItemDto), matchItemDto);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.strategy.GradeCalculationStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@Component
public class GradeStrategyFactory {
private final Map<String, GradeCalculationStrategy> strategyMap;
@Autowired
public GradeStrategyFactory(List<GradeCalculationStrategy> strategies) {
this.strategyMap = strategies.stream()
.collect(Collectors.toMap(
GradeCalculationStrategy::getStrategyType,
Function.identity()
));
}
public GradeCalculationStrategy getStrategy(String strategyType) {
return Optional.ofNullable(strategyMap.get(strategyType))
.orElseThrow(() -> new IllegalArgumentException(
String.format("No strategy found for type: %s. Available: %s",
strategyType,
strategyMap.keySet())
));
}
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.EquipCreateOrEditEvent;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.event.service.IQualityScoreUpdate;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Component
@RequiredArgsConstructor
public class QualityScoreUpdateFactory {
private final List<IQualityScoreUpdate> qualityScoreUpdaters;
private final Map<String, IQualityScoreUpdate> qualityScoreUpdaterMap = new ConcurrentHashMap<>();
public IQualityScoreUpdate getUpdater(EquipCreateOrEditEvent.EquipType equipType) {
return qualityScoreUpdaterMap.computeIfAbsent(equipType.name(), (k) -> {
for (IQualityScoreUpdate qualityScoreUpdater : qualityScoreUpdaters) {
if (qualityScoreUpdater.support(equipType)) {
return qualityScoreUpdater;
}
}
throw new BadRequest("not found updater handler for " + equipType.name());
});
}
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.core; package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.IReminderHandler;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.newEquip; package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.newEquip;
import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.CommonEquipDataProcessService; import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.CommonEquipDataProcessService;
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.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.*; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -50,7 +52,7 @@ public class NewEquipParseService { ...@@ -50,7 +52,7 @@ public class NewEquipParseService {
String equListCode = (String) equipmentClassForm.get("EQU_LIST"); String equListCode = (String) equipmentClassForm.get("EQU_LIST");
String equCategoryCode = (String) equipmentClassForm.get("EQU_CATEGORY"); String equCategoryCode = (String) equipmentClassForm.get("EQU_CATEGORY");
String equDefineCode = (String) equipmentClassForm.get("EQU_DEFINE"); String equDefineCode = (String) equipmentClassForm.get("EQU_DEFINE");
String whetherVehicleCylinder = equipmentClassForm.get("WHETHER_VEHICLE_CYLINDER") != null ? (String) equipmentClassForm.get("WHETHER_VEHICLE_CYLINDER") : "0"; String whetherVehicleCylinder = equipmentClassForm.get("WHETHER_VEHICLE_CYLINDER") != null ? (String) equipmentClassForm.get("WHETHER_VEHICLE_CYLINDER") : "0";
matchItemDto.setEquList(equListCode); matchItemDto.setEquList(equListCode);
matchItemDto.setEquCategory(equCategoryCode); matchItemDto.setEquCategory(equCategoryCode);
matchItemDto.setEquDefine(equDefineCode); matchItemDto.setEquDefine(equDefineCode);
...@@ -58,7 +60,14 @@ public class NewEquipParseService { ...@@ -58,7 +60,14 @@ public class NewEquipParseService {
} }
public void setEquCateInfoForEdit(String record, MatchItemDto matchItemDto) { public void setEquCateInfoForEdit(String record, MatchItemDto matchItemDto) {
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOneData(record); IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>()
.eq(IdxBizJgRegisterInfo::getRecord, record)
.select(TzsBaseEntity::getSequenceNbr,
IdxBizJgRegisterInfo::getRecord,
IdxBizJgRegisterInfo::getEquCategory,
IdxBizJgRegisterInfo::getEquDefine,
IdxBizJgRegisterInfo::getEquList,
IdxBizJgRegisterInfo::getWhetherVehicleCylinder));
matchItemDto.setEquList(registerInfo.getEquList()); matchItemDto.setEquList(registerInfo.getEquList());
matchItemDto.setEquCategory(registerInfo.getEquCategory()); matchItemDto.setEquCategory(registerInfo.getEquCategory());
matchItemDto.setEquDefine(registerInfo.getEquDefine()); matchItemDto.setEquDefine(registerInfo.getEquDefine());
...@@ -77,10 +86,6 @@ public class NewEquipParseService { ...@@ -77,10 +86,6 @@ public class NewEquipParseService {
return equipDataProcessService.getEquipDetailByRecord(record); return equipDataProcessService.getEquipDetailByRecord(record);
} }
public <T> T geEquipInfoFromJson(Map<String, Object> formData, Class<T> clazz) {
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(formData.get(EQUIP_INFO_FORM_ID));
return JSON.parseObject(JSON.toJSONString(equipmentInfoForm), clazz);
}
public Map<String, Object> getDetailInfoFromJson(Map<String, Object> formData) { public Map<String, Object> getDetailInfoFromJson(Map<String, Object> formData) {
Map<String, Object> re = new HashMap<>(); Map<String, Object> re = new HashMap<>();
...@@ -91,4 +96,12 @@ public class NewEquipParseService { ...@@ -91,4 +96,12 @@ public class NewEquipParseService {
return re; return re;
} }
public Boolean getIsRegister(String bizId) {
if (StringUtils.isEmpty(bizId)) {
return false;
}
IdxBizJgUseInfo useInfo = idxBizJgUseInfoService.getOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, bizId).select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getIsIntoManagement));
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>().eq(IdxBizJgRegisterInfo::getRecord, bizId).select(IdxBizJgRegisterInfo::getRecord, IdxBizJgRegisterInfo::getUseOrgCode));
return useInfo.getIsIntoManagement() && StringUtils.isNotEmpty(registerInfo.getUseOrgCode());
}
} }
...@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum; ...@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.DefaultReminder; import com.yeejoin.amos.boot.module.jg.biz.reminder.core.DefaultReminder;
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.biz.reminder.dto.ReminderItemDto; import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.service.CommonReminderService;
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 org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -15,9 +16,10 @@ import org.springframework.stereotype.Component; ...@@ -15,9 +16,10 @@ import org.springframework.stereotype.Component;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* 设备/气瓶创建编辑-提醒处理器
*/
@Component @Component
public class NewEquipReminderAdapter extends DefaultReminder { public class NewEquipReminderAdapter extends DefaultReminder {
private final NewEquipParseService newEquipParseService; private final NewEquipParseService newEquipParseService;
...@@ -53,8 +55,8 @@ public class NewEquipReminderAdapter extends DefaultReminder { ...@@ -53,8 +55,8 @@ public class NewEquipReminderAdapter extends DefaultReminder {
@Override @Override
public IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) { public IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
IdxBizJgRegisterInfo registerInfo = newEquipParseService.geEquipInfoFromJson(formData, IdxBizJgRegisterInfo.class); IdxBizJgRegisterInfo registerInfo = CommonReminderService.geEquipInfoFromJson(formData, IdxBizJgRegisterInfo.class);
IdxBizJgUseInfo bizJgUseInfo = newEquipParseService.geEquipInfoFromJson(formData, IdxBizJgUseInfo.class); IdxBizJgUseInfo bizJgUseInfo = CommonReminderService.geEquipInfoFromJson(formData, IdxBizJgUseInfo.class);
ReminderItemDto reminderItemDto = new ReminderItemDto(); ReminderItemDto reminderItemDto = new ReminderItemDto();
reminderItemDto.setEquipId(StringUtils.isEmpty(bizId) ? "1" : bizId); reminderItemDto.setEquipId(StringUtils.isEmpty(bizId) ? "1" : bizId);
reminderItemDto.setEquipNo(bizJgUseInfo.getUseInnerCode()); reminderItemDto.setEquipNo(bizJgUseInfo.getUseInnerCode());
...@@ -69,6 +71,7 @@ public class NewEquipReminderAdapter extends DefaultReminder { ...@@ -69,6 +71,7 @@ public class NewEquipReminderAdapter extends DefaultReminder {
public MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) { public MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) {
MatchItemDto matchItemDto = MatchItemDto.builder().build(); MatchItemDto matchItemDto = MatchItemDto.builder().build();
newEquipParseService.setEquCateInfoForInsert(formData, matchItemDto); newEquipParseService.setEquCateInfoForInsert(formData, matchItemDto);
matchItemDto.setIsRegister(newEquipParseService.getIsRegister(bizId));
matchItemDto.setRegType(StringUtils.isNotEmpty(bizId) ? newEquipParseService.getRegTypeForEdit(bizId) : newEquipParseService.getRegTypeForInsert(formData)); matchItemDto.setRegType(StringUtils.isNotEmpty(bizId) ? newEquipParseService.getRegTypeForEdit(bizId) : newEquipParseService.getRegTypeForInsert(formData));
return matchItemDto; return matchItemDto;
} }
...@@ -77,6 +80,7 @@ public class NewEquipReminderAdapter extends DefaultReminder { ...@@ -77,6 +80,7 @@ public class NewEquipReminderAdapter extends DefaultReminder {
public MatchItemDto setMatchItem(String bizId) { public MatchItemDto setMatchItem(String bizId) {
MatchItemDto matchItemDto = MatchItemDto.builder().build(); MatchItemDto matchItemDto = MatchItemDto.builder().build();
newEquipParseService.setEquCateInfoForEdit(bizId, matchItemDto); newEquipParseService.setEquCateInfoForEdit(bizId, matchItemDto);
matchItemDto.setIsRegister(newEquipParseService.getIsRegister(bizId));
matchItemDto.setRegType(newEquipParseService.getRegTypeForEdit(bizId)); matchItemDto.setRegType(newEquipParseService.getRegTypeForEdit(bizId));
return matchItemDto; return matchItemDto;
} }
......
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.newProject;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgProjectContraptionServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgTechParamsPipelineServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
@Getter
public class NewProjectParseService {
private final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionServiceImpl;
private final IdxBizJgTechParamsPipelineServiceImpl idxBizJgTechParamsPipelineService;
private final JgUseRegistrationServiceImpl jgUseRegistrationService;
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.newProject;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.DefaultReminder;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.service.CommonReminderService;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 管道创建编辑-提醒处理器
*/
@Component
public class NewProjectReminderAdapter extends DefaultReminder {
private final NewProjectParseService newProjectParseService;
public NewProjectReminderAdapter(ApplicationContext applicationContext, NewProjectParseService newProjectParseService) {
super(applicationContext);
this.newProjectParseService = newProjectParseService;
}
@Override
protected IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page) {
// 创建后,详情使用
IdxBizJgProjectContraption projectContraption = newProjectParseService.getIdxBizJgProjectContraptionServiceImpl().getById(bizId);
ReminderItemDto reminderItemDto = new ReminderItemDto();
reminderItemDto.setEquipId(bizId);
reminderItemDto.setEquipNo(projectContraption.getProjectContraptionNo());
reminderItemDto.setEquipName(projectContraption.getProjectContraption());
reminderItemDto.setDetailData(BeanUtil.beanToMap(projectContraption));
page.setRecords(Collections.singletonList(reminderItemDto));
page.setTotal(1L);
return page;
}
@Override
protected List<ReminderItemDto> realtimeParse(String bizId) {
// 创建后,评分使用
IdxBizJgProjectContraption projectContraption = newProjectParseService.getIdxBizJgProjectContraptionServiceImpl().getById(bizId);
ReminderItemDto reminderItemDto = new ReminderItemDto();
reminderItemDto.setEquipId(bizId);
reminderItemDto.setEquipNo(projectContraption.getProjectContraptionNo());
reminderItemDto.setEquipName(projectContraption.getProjectContraption());
reminderItemDto.setDetailData(BeanUtil.beanToMap(projectContraption));
return Collections.singletonList(reminderItemDto);
}
@Override
protected IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
// 新增 + 编辑的保存使用
IdxBizJgProjectContraption projectContraption = CommonReminderService.geEquipInfoFromJson(formData, IdxBizJgProjectContraption.class);
ReminderItemDto reminderItemDto = new ReminderItemDto();
reminderItemDto.setEquipId(StringUtils.isEmpty(bizId) ? "1" : projectContraption.getProjectContraptionParentId());
reminderItemDto.setEquipNo(projectContraption.getProjectContraptionNo());
reminderItemDto.setEquipName(projectContraption.getProjectContraption());
reminderItemDto.setDetailData(BeanUtil.beanToMap(projectContraption));
page.setRecords(Collections.singletonList(reminderItemDto));
page.setTotal(1L);
return page;
}
@Override
protected MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) {
// 新增 + 编辑的保存使用
MatchItemDto matchItemDto = MatchItemDto.builder().build();
IdxBizJgProjectContraption projectContraption = CommonReminderService.geEquipInfoFromJson(formData, IdxBizJgProjectContraption.class);
matchItemDto.setEquList(projectContraption.getEquList());
matchItemDto.setEquCategory(projectContraption.getEquCategory());
matchItemDto.setEquDefine(projectContraption.getEquDefine());
matchItemDto.setIsRegister(!StringUtils.isEmpty(bizId) && projectContraption.getIsIntoManagement() && StringUtils.isNotEmpty(projectContraption.getUseRegistrationCode()));
matchItemDto.setRegType(StringUtils.isNotEmpty(bizId) ? CommonReminderService.getRegTypeByDataSource(projectContraption.getDataSource()) : CommonReminderService.getRegTypeForInsert(formData));
return matchItemDto;
}
@Override
protected MatchItemDto setMatchItem(String bizId) {
IdxBizJgProjectContraption projectContraption = newProjectParseService.getIdxBizJgProjectContraptionServiceImpl().getById(bizId);
// 等级 + 详情使用
MatchItemDto matchItemDto = MatchItemDto.builder().build();
matchItemDto.setEquList(projectContraption.getEquList());
matchItemDto.setEquCategory(projectContraption.getEquCategory());
matchItemDto.setEquDefine(projectContraption.getEquDefine());
matchItemDto.setIsRegister(projectContraption.getIsIntoManagement() && StringUtils.isNotEmpty(projectContraption.getUseRegistrationCode()));
matchItemDto.setRegType(CommonReminderService.getRegTypeByDataSource(projectContraption.getDataSource()));
return matchItemDto;
}
@Override
public String supportBizType() {
return BusinessTypeEnum.JG_NEW_PROJECT.name();
}
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.strategy;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
import java.util.List;
public interface GradeCalculationStrategy {
/**
* 计算等级
*
* @param equips 计算参数
* @param matchItem 条件
* @return 等级
*/
Integer calculateGrade(List<ReminderItemDto> equips, MatchItemDto matchItem);
/**
* 标识支持的策略类型
*/
String getStrategyType();
}
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.strategy;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.ReminderFieldDiff;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderField;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Component
@RequiredArgsConstructor
public class MaxGradeCalStrategy implements GradeCalculationStrategy {
private final ReminderFieldDiff reminderFieldDiff;
@Override
public Integer calculateGrade(List<ReminderItemDto> equips, MatchItemDto matchItem) {
List<ReminderItemDto> reminderItemList = reminderFieldDiff.getReminderItemList(equips, matchItem);
List<ReminderField> items = reminderItemList.stream().flatMap(s -> s.getItems().stream()).collect(Collectors.toList());
return items.stream().max(Comparator.comparingInt(ReminderField::getSId)).map(ReminderField::getSId).orElse(-1);
}
@Override
public String getStrategyType() {
return "MAX_GRADE";
}
}
...@@ -13,6 +13,9 @@ import java.util.Collections; ...@@ -13,6 +13,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* 使用登记-提醒处理器
*/
@Component @Component
public class UseRegisterReminderAdapter extends DefaultReminder { public class UseRegisterReminderAdapter extends DefaultReminder {
public UseRegisterReminderAdapter(ApplicationContext applicationContext) { public UseRegisterReminderAdapter(ApplicationContext applicationContext) {
......
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.installNotice; package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.vehicleInformation;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -14,13 +14,13 @@ import java.util.List; ...@@ -14,13 +14,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@Component @Component
public class InstallNoticeReminderAdapter extends DefaultReminder { public class VehicleInformationReminderAdapter extends DefaultReminder {
public InstallNoticeReminderAdapter(ApplicationContext applicationContext) { public VehicleInformationReminderAdapter(ApplicationContext applicationContext) {
super(applicationContext); super(applicationContext);
} }
@Override @Override
public IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page) { protected IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page) {
return null; return null;
} }
...@@ -30,22 +30,22 @@ public class InstallNoticeReminderAdapter extends DefaultReminder { ...@@ -30,22 +30,22 @@ public class InstallNoticeReminderAdapter extends DefaultReminder {
} }
@Override @Override
public IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) { protected IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
return null; return null;
} }
@Override @Override
public MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) { protected MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) {
return null; return null;
} }
@Override @Override
public MatchItemDto setMatchItem(String bizId) { protected MatchItemDto setMatchItem(String bizId) {
return null; return null;
} }
@Override @Override
public String supportBizType() { public String supportBizType() {
return BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.name(); return BusinessTypeEnum.JG_USAGE_REGISTRATION.name();
} }
} }
...@@ -2,15 +2,13 @@ package com.yeejoin.amos.boot.module.jg.biz.reminder.core; ...@@ -2,15 +2,13 @@ package com.yeejoin.amos.boot.module.jg.biz.reminder.core;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.biz.reminder.dto.ReminderField;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto; import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
public abstract class DefaultReminder implements IReminderHandler { public abstract class DefaultReminder implements IReminderHandler {
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
...@@ -41,13 +39,11 @@ public abstract class DefaultReminder implements IReminderHandler { ...@@ -41,13 +39,11 @@ public abstract class DefaultReminder implements IReminderHandler {
} }
@Override @Override
public Integer getReminderLevel(String bizId) { public Integer getReminderLevel(String bizId, String activeStrategy) {
ReminderFieldDiff reminderFieldDiff = applicationContext.getBean(ReminderFieldDiff.class); GradeStrategyFactory strategyFactory = applicationContext.getBean(GradeStrategyFactory.class);
MatchItemDto matchItemDto = setMatchItem(bizId) == null ? MatchItemDto.builder().build() : setMatchItem(bizId); MatchItemDto matchItemDto = setMatchItem(bizId) == null ? MatchItemDto.builder().build() : setMatchItem(bizId);
matchItemDto.setBizType(supportBizType()); matchItemDto.setBizType(supportBizType());
List<ReminderItemDto> equips = reminderFieldDiff.getReminderItemList(realtimeParse(bizId), matchItemDto); return strategyFactory.getStrategy(activeStrategy).calculateGrade(realtimeParse(bizId), matchItemDto);
List<ReminderField> items = equips.stream().flatMap(s -> s.getItems().stream()).collect(Collectors.toList());
return items.stream().max(Comparator.comparingInt(ReminderField::getSId)).map(ReminderField::getSId).orElse(-1);
} }
private IPage<ReminderItemDto> parse(Page<ReminderItemDto> page, String bizId, SourceType sourceType, Map<String, Object> formData) { private IPage<ReminderItemDto> parse(Page<ReminderItemDto> page, String bizId, SourceType sourceType, Map<String, Object> formData) {
...@@ -61,18 +57,51 @@ public abstract class DefaultReminder implements IReminderHandler { ...@@ -61,18 +57,51 @@ public abstract class DefaultReminder implements IReminderHandler {
} }
} }
/**
* 获取指定分页的设备、装置、单据下的设备、管道,详情使用
*
* @param bizId 唯一标识
* @return 分页的设备/管道
*/
protected abstract IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page); protected abstract IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page);
/**
* 获取指定设备、装置、单据下的设备、管道列表-评分使用;台套-台套设备;气瓶-气瓶;装置-装置
*
* @param bizId 唯一标识
* @return 设备/管道列表
*/
protected abstract List<ReminderItemDto> realtimeParse(String bizId); protected abstract List<ReminderItemDto> realtimeParse(String bizId);
/**
* 获取编辑或者新增的设备、装置、单据设备、管道列表
*
* @param bizId 唯一标识
* @param formData 表单数据
* @param page 分页信息
* @return 解析后的分页数据
*/
protected abstract IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page); protected abstract IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page);
/**
* 设置匹配项
*
* @param bizId 唯一标识
* @param formData 表单数据
* @return 构造好的匹配项
*/
protected abstract MatchItemDto setMatchItem(String bizId, Map<String, Object> formData); protected abstract MatchItemDto setMatchItem(String bizId, Map<String, Object> formData);
/**
* 设置匹配项
*
* @param bizId 唯一标识
* @return 构造好的匹配项
*/
protected abstract MatchItemDto setMatchItem(String bizId); protected abstract MatchItemDto setMatchItem(String bizId);
} }
...@@ -10,7 +10,7 @@ public interface IReminderHandler { ...@@ -10,7 +10,7 @@ public interface IReminderHandler {
IPage<ReminderItemDto> remindersPage(Page<ReminderItemDto> page, String bizId, SourceType sourceType, Map<String, Object> formData); IPage<ReminderItemDto> remindersPage(Page<ReminderItemDto> page, String bizId, SourceType sourceType, Map<String, Object> formData);
Integer getReminderLevel(String bizId); Integer getReminderLevel(String bizId, String activeStrategy);
String supportBizType(); String supportBizType();
......
...@@ -20,7 +20,13 @@ public class MatchItemDto { ...@@ -20,7 +20,13 @@ public class MatchItemDto {
*/ */
private String whetherVehicleCylinder = "0"; private String whetherVehicleCylinder = "0";
private String regType; private String regType;
/**
* 是否已经登记
*/
private Boolean isRegister = false;
Page<ReminderItemDto> page; Page<ReminderItemDto> page;
} }
package com.yeejoin.amos.boot.module.jg.biz.reminder.service;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl.EQUIP_INFO_FORM_ID;
@Component
@RequiredArgsConstructor
public class CommonReminderService {
private final IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper;
private final IdxBizJgFactoryInfoMapper jgFactoryInfoMapper;
private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
private final IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper;
private final IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
public static <T> T geEquipInfoFromJson(Map<String, Object> formData, Class<T> clazz) {
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(formData.get(EQUIP_INFO_FORM_ID));
return JSON.parseObject(JSON.toJSONString(equipmentInfoForm), clazz);
}
private static Object checkAndCast(Object obj) {
if (obj instanceof LinkedHashMap) {
return obj;
} else {
throw new ClassCastException("对象类型不匹配");
}
}
public static String getRegTypeForInsert(Map<String, Object> formData) {
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(formData.get(EQUIP_INFO_FORM_ID));
String dataSource = equipmentInfoForm.get("DATA_SOURCE").toString();
return "new".equals(dataSource) ? "0" : "his".equals(dataSource) ? "1" : "2";
}
public static String getRegTypeByDataSource(String dataSource) {
if (dataSource.contains("jg_his_black")) {
return "2";
} else if (dataSource.contains("jg_his")) {
return "1";
} else {
return "0";
}
}
public Map<String, Object> getEquipDetailByRecord(String record) {
Map<String, Object> re = new HashMap<>();
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgRegisterInfo>().eq(IdxBizJgRegisterInfo::getRecord, record));
IdxBizJgFactoryInfo factoryInfo = jgFactoryInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgFactoryInfo>().eq(IdxBizJgFactoryInfo::getRecord, record));
IdxBizJgUseInfo useInfo = idxBizJgUseInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, record));
IdxBizJgDesignInfo designInfo = idxBizJgDesignInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgDesignInfo>().eq(IdxBizJgDesignInfo::getRecord, record));
IdxBizJgOtherInfo otherInfo = idxBizJgOtherInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgOtherInfo>().eq(IdxBizJgOtherInfo::getRecord, record));
IdxBizJgSupervisionInfo idxBizJgSupervisionInfo = idxBizJgSupervisionInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgSupervisionInfo>().eq(IdxBizJgSupervisionInfo::getRecord, record));
re.putAll(BeanUtil.beanToMap(useInfo));
re.putAll(BeanUtil.beanToMap(registerInfo));
re.putAll(BeanUtil.beanToMap(factoryInfo));
re.putAll(BeanUtil.beanToMap(otherInfo));
re.putAll(BeanUtil.beanToMap(designInfo));
re.putAll(BeanUtil.beanToMap(idxBizJgSupervisionInfo));
return re;
}
}
...@@ -3,10 +3,11 @@ package com.yeejoin.amos.boot.module.jg.biz.reminder.service; ...@@ -3,10 +3,11 @@ package com.yeejoin.amos.boot.module.jg.biz.reminder.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.IReminderHandler; import com.yeejoin.amos.boot.module.jg.biz.reminder.core.IReminderHandler;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.ReminderFactory; import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.ReminderFactory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto; import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
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.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map; import java.util.Map;
...@@ -15,6 +16,9 @@ import java.util.Map; ...@@ -15,6 +16,9 @@ import java.util.Map;
@RequiredArgsConstructor @RequiredArgsConstructor
public class RemindServiceImpl { public class RemindServiceImpl {
@Value("${grade.calculation.strategy:MAX_GRADE}")
private String activeStrategy;
private final ReminderFactory reminderFactory; private final ReminderFactory reminderFactory;
public IPage<ReminderItemDto> getReminderItems(Page<ReminderItemDto> page, String bizId, String bizType, IReminderHandler.SourceType sourceType, Map<String, Object> formData) { public IPage<ReminderItemDto> getReminderItems(Page<ReminderItemDto> page, String bizId, String bizType, IReminderHandler.SourceType sourceType, Map<String, Object> formData) {
...@@ -22,6 +26,6 @@ public class RemindServiceImpl { ...@@ -22,6 +26,6 @@ public class RemindServiceImpl {
} }
public Integer getReminderLevel(String bizId, String bizType) { public Integer getReminderLevel(String bizId, String bizType) {
return reminderFactory.getReminderHandler(bizType).getReminderLevel(bizId); return reminderFactory.getReminderHandler(bizType).getReminderLevel(bizId, activeStrategy);
} }
} }
...@@ -43,7 +43,9 @@ public class ReminderFieldDiffImpl implements ReminderFieldDiff { ...@@ -43,7 +43,9 @@ public class ReminderFieldDiffImpl implements ReminderFieldDiff {
// regType默认0-新增,不同regType对应不同字段时,配置多行 // regType默认0-新增,不同regType对应不同字段时,配置多行
List<TzsJgColumnReminderRule> rules = reminderRuleService.list(new LambdaQueryWrapper<TzsJgColumnReminderRule>() List<TzsJgColumnReminderRule> rules = reminderRuleService.list(new LambdaQueryWrapper<TzsJgColumnReminderRule>()
.eq(TzsJgColumnReminderRule::getBizType, matchItem.getBizType()) .eq(TzsJgColumnReminderRule::getBizType, matchItem.getBizType())
.eq(StringUtils.isNotEmpty(matchItem.getRegType()), TzsJgColumnReminderRule::getRegType, matchItem.getRegType()).eq(TzsJgColumnReminderRule::getWhetherVehicleCylinder, matchItem.getWhetherVehicleCylinder())); .eq(StringUtils.isNotEmpty(matchItem.getRegType()), TzsJgColumnReminderRule::getRegType, matchItem.getRegType())
.eq(TzsJgColumnReminderRule::getWhetherVehicleCylinder, matchItem.getWhetherVehicleCylinder())
.eq(matchItem.getIsRegister() != null, TzsJgColumnReminderRule::getIsRegister, matchItem.getIsRegister()));
List<TzsJgColumnReminderRule> equCategoryMatch = new ArrayList<>(); List<TzsJgColumnReminderRule> equCategoryMatch = new ArrayList<>();
List<TzsJgColumnReminderRule> equListMatch = new ArrayList<>(); List<TzsJgColumnReminderRule> equListMatch = new ArrayList<>();
// 特殊不一样的配置设备类别 // 特殊不一样的配置设备类别
......
...@@ -300,4 +300,10 @@ public class IdxBizJgProjectContraption extends BaseEntity { ...@@ -300,4 +300,10 @@ public class IdxBizJgProjectContraption extends BaseEntity {
@TableField("certificate_print_tag") @TableField("certificate_print_tag")
private String certificatePrintTag; private String certificatePrintTag;
/**
* 数据质量等级
*/
@TableField("\"DATA_QUALITY_SCORE\"")
private Integer dataQualityScore;
} }
...@@ -271,7 +271,7 @@ public class IdxBizJgUseInfo extends TzsBaseEntity implements IBaseChangeData { ...@@ -271,7 +271,7 @@ public class IdxBizJgUseInfo extends TzsBaseEntity implements IBaseChangeData {
* 工程装置名称(工业管道使用) * 工程装置名称(工业管道使用)
*/ */
@TableField("\"PROJECT_CONTRAPTION\"") @TableField("\"PROJECT_CONTRAPTION\"")
@FieldDisplayDefine(value = "工程装置名称(工业管道使用)", isRepeatColumn = true) @FieldDisplayDefine(value = "工程装置名称(工业管道使用)", isRepeatColumn = true)
private String projectContraption; private String projectContraption;
...@@ -320,4 +320,10 @@ public class IdxBizJgUseInfo extends TzsBaseEntity implements IBaseChangeData { ...@@ -320,4 +320,10 @@ public class IdxBizJgUseInfo extends TzsBaseEntity implements IBaseChangeData {
@TableField("\"REMARK\"") @TableField("\"REMARK\"")
@FieldDisplayDefine(value = "备注") @FieldDisplayDefine(value = "备注")
private String remark; private String remark;
/**
* 数据质量等级
*/
@TableField("\"DATA_QUALITY_SCORE\"")
private Integer dataQualityScore;
} }
...@@ -109,4 +109,5 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro ...@@ -109,4 +109,5 @@ public interface IdxBizJgProjectContraptionMapper extends BaseMapper<IdxBizJgPro
List<Map<String, Object>> selectPipelineListPage(@Param("sequenceNbr") String sequenceNbr, @Param("current") int current, @Param("size") int size); List<Map<String, Object>> selectPipelineListPage(@Param("sequenceNbr") String sequenceNbr, @Param("current") int current, @Param("size") int size);
List<Map<String, Object>> selectPipelineList(@Param("equIds") List<String> equIds); List<Map<String, Object>> selectPipelineList(@Param("equIds") List<String> equIds);
} }
\ No newline at end of file
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