Commit b062f2bd authored by suhuiguang's avatar suhuiguang

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

1.重要提醒设备开发联调测试 2.使用登记审核完成后更新管道汇总表字段 2管道es增加使用登记证编号
parent f2dda91c
package com.yeejoin.amos.boot.module.jg.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 字段提醒配置表
......@@ -15,10 +14,10 @@ import java.util.Date;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="TzsJgColumnReminderRuleDto", description="字段提醒配置表")
public class TzsJgColumnReminderRuleDto extends BaseDto {
@ApiModel(value = "TzsJgColumnReminderRuleDto", description = "字段提醒配置表")
public class TzsJgColumnReminderRuleDto extends BaseDto {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "业务类型,如使用登记、安装告知")
......@@ -45,4 +44,7 @@ public class TzsJgColumnReminderRuleDto extends BaseDto {
@ApiModelProperty(value = "严重程度:1到n,数字越大,等级越高,自定义")
private Integer sId;
@ApiModelProperty(value = "是否车用气瓶")
private String whetherVehicleCylinder;
}
......@@ -6,7 +6,6 @@ import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 字段提醒配置表
......@@ -25,49 +24,55 @@ public class TzsJgColumnReminderRule extends BaseEntity {
/**
* 业务类型,如使用登记、安装告知
*/
@TableField("biz_type")
@TableField("biz_type")
private String bizType;
/**
* 字段唯一标识
*/
@TableField("column_key")
@TableField("column_key")
private String columnKey;
/**
* 数据项名称
*/
@TableField("column_label")
@TableField("column_label")
private String columnLabel;
/**
* 数据项说明
*/
@TableField("column_value")
@TableField("column_value")
private String columnValue;
/**
* 0-新增;1-历史有证;2-历史无证
*/
@TableField("reg_type")
@TableField("reg_type")
private String regType;
/**
* 设备种类编码,多个逗号分割
*/
@TableField("equ_list")
@TableField("equ_list")
private String equList;
/**
* 未空代表公共,多个逗号分割
*/
@TableField("equ_category")
@TableField("equ_category")
private String equCategory;
/**
* 严重程度:1到n,数字越大,等级越高,自定义
*/
@TableField("s_id")
@TableField("s_id")
private Integer sId;
/**
* 是否车用气瓶
*/
@TableField("whether_vehicle_cylinder")
private String whetherVehicleCylinder;
}
package com.yeejoin.amos.boot.module.jg.biz.controller;
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.IReminderHandler;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.service.RemindServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
@RestController
@RequestMapping(value = "/biz-reminder")
@Api(tags = "业务数据项提醒控制器")
@RequiredArgsConstructor
public class BizReminderController {
private final RemindServiceImpl remindService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/v1/{bizType}/page")
@ApiOperation(value = "缺失数据项分页", httpMethod = "POST")
public ResponseModel<IPage<?>> reminderPageList(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@ApiParam(value = "单据编号或者设备装置唯一标识") @RequestParam(required = false) String bizId,
@ApiParam(value = "业务类型") @PathVariable String bizType,
@ApiParam(value = "生成类型") @RequestParam IReminderHandler.SourceType sourceType,
@ApiParam(value = "表单数据") @RequestBody(required = false) Map<String, Object> formData) {
Page<ReminderItemDto> page = new Page<>(current, size);
return ResponseHelper.buildResponse(remindService.getReminderItems(page, bizId, bizType, sourceType, formData));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/v1/{bizType}/level")
@ApiOperation(value = "缺失等级查询", httpMethod = "GET")
public ResponseModel<Integer> getReminderLevel(
@ApiParam(value = "单据编号或者设备装置唯一标识") @RequestParam String bizId,
@ApiParam(value = "业务类型") @PathVariable String bizType) {
return ResponseHelper.buildResponse(remindService.getReminderLevel(bizId, bizType));
}
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ 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
......@@ -23,17 +25,22 @@ public class InstallNoticeReminderAdapter extends DefaultReminder {
}
@Override
protected List<ReminderItemDto> realtimeParse(String bizId) {
return Collections.emptyList();
}
@Override
public IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
return null;
}
@Override
public MatchItemDto getMatchItem(String bizId, Map<String, Object> formData) {
public MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) {
return null;
}
@Override
public MatchItemDto getMatchItem(String bizId) {
public MatchItemDto setMatchItem(String bizId) {
return null;
}
......
package com.yeejoin.amos.boot.module.jg.biz.reminder.biz.newEquip;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.CommonEquipDataProcessService;
import com.yeejoin.amos.boot.module.jg.biz.reminder.dto.MatchItemDto;
......@@ -9,6 +8,7 @@ import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgUseInfoServiceIm
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.HashMap;
......@@ -40,7 +40,8 @@ public class NewEquipParseService {
}
public String getRegTypeForInsert(Map<String, Object> formData) {
String dataSource = formData.get("DATA_SOURCE").toString();
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";
}
......@@ -49,9 +50,11 @@ public class NewEquipParseService {
String equListCode = (String) equipmentClassForm.get("EQU_LIST");
String equCategoryCode = (String) equipmentClassForm.get("EQU_CATEGORY");
String equDefineCode = (String) equipmentClassForm.get("EQU_DEFINE");
String whetherVehicleCylinder = equipmentClassForm.get("WHETHER_VEHICLE_CYLINDER") != null ? (String) equipmentClassForm.get("WHETHER_VEHICLE_CYLINDER") : "0";
matchItemDto.setEquList(equListCode);
matchItemDto.setEquCategory(equCategoryCode);
matchItemDto.setEquDefine(equDefineCode);
matchItemDto.setWhetherVehicleCylinder(whetherVehicleCylinder);
}
public void setEquCateInfoForEdit(String record, MatchItemDto matchItemDto) {
......@@ -59,6 +62,7 @@ public class NewEquipParseService {
matchItemDto.setEquList(registerInfo.getEquList());
matchItemDto.setEquCategory(registerInfo.getEquCategory());
matchItemDto.setEquDefine(registerInfo.getEquDefine());
matchItemDto.setWhetherVehicleCylinder(StringUtils.isNotEmpty(registerInfo.getWhetherVehicleCylinder()) ? registerInfo.getWhetherVehicleCylinder() : "0");
}
private Object checkAndCast(Object obj) {
......@@ -73,40 +77,16 @@ public class NewEquipParseService {
return equipDataProcessService.getEquipDetailByRecord(record);
}
public IdxBizJgRegisterInfo getRegisterInfoFromJson(Map<String, Object> formData) {
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), IdxBizJgRegisterInfo.class);
return JSON.parseObject(JSON.toJSONString(equipmentInfoForm), clazz);
}
public Map<String, Object> getDetailInfoFromJson(Map<String, Object> formData) {
Map<String, Object> re = new HashMap<>();
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(formData.get(EQUIP_INFO_FORM_ID));
LinkedHashMap equipmentParamsForm = (LinkedHashMap) checkAndCast(formData.get(EQUIP_PARAMS_FORM_ID));
// 使用信息
IdxBizJgUseInfo useInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgUseInfo.class);
// 设计信息
IdxBizJgDesignInfo designInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgDesignInfo.class);
// 制造信息
IdxBizJgFactoryInfo factoryInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgFactoryInfo.class);
// 施工信息
IdxBizJgConstructionInfo constructionInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgConstructionInfo.class);
// 注册登记信息
IdxBizJgRegisterInfo registerInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgRegisterInfo.class);
// 监督管理
IdxBizJgSupervisionInfo supervisionInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgSupervisionInfo.class);
// 其他信息
IdxBizJgOtherInfo otherInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgOtherInfo.class);
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgInspectionDetectionInfo.class);
IdxBizJgMaintenanceRecordInfo idxBizJgMaintenanceRecordInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgMaintenanceRecordInfo.class);
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(supervisionInfo));
re.putAll(BeanUtil.beanToMap(inspectionDetectionInfo));
re.putAll(BeanUtil.beanToMap(idxBizJgMaintenanceRecordInfo));
re.putAll(BeanUtil.beanToMap(constructionInfo));
re.putAll(equipmentInfoForm);
re.putAll(equipmentParamsForm);
return re;
}
......
......@@ -7,10 +7,12 @@ 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.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@Component
......@@ -38,12 +40,24 @@ public class NewEquipReminderAdapter extends DefaultReminder {
}
@Override
public IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
IdxBizJgRegisterInfo registerInfo = newEquipParseService.getRegisterInfoFromJson(formData);
protected List<ReminderItemDto> realtimeParse(String bizId) {
IdxBizJgRegisterInfo registerInfo = newEquipParseService.getIdxBizJgRegisterInfoService().getOneData(bizId);
ReminderItemDto reminderItemDto = new ReminderItemDto();
reminderItemDto.setEquipId(bizId);
reminderItemDto.setEquipNo(registerInfo.getEquCode());
reminderItemDto.setEquipName(registerInfo.getProductName());
reminderItemDto.setDetailData(newEquipParseService.getEquipDetailByRecord(bizId));
return Collections.singletonList(reminderItemDto);
}
@Override
public IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
IdxBizJgRegisterInfo registerInfo = newEquipParseService.geEquipInfoFromJson(formData, IdxBizJgRegisterInfo.class);
IdxBizJgUseInfo bizJgUseInfo = newEquipParseService.geEquipInfoFromJson(formData, IdxBizJgUseInfo.class);
ReminderItemDto reminderItemDto = new ReminderItemDto();
reminderItemDto.setEquipId(bizId == null ? "1" : bizId);
reminderItemDto.setEquipNo(bizJgUseInfo.getUseInnerCode());
reminderItemDto.setEquipName(registerInfo.getProductName());
reminderItemDto.setDetailData(newEquipParseService.getDetailInfoFromJson(formData));
page.setRecords(Collections.singletonList(reminderItemDto));
page.setTotal(1L);
......@@ -51,15 +65,15 @@ public class NewEquipReminderAdapter extends DefaultReminder {
}
@Override
public MatchItemDto getMatchItem(String bizId, Map<String, Object> formData) {
public MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) {
MatchItemDto matchItemDto = MatchItemDto.builder().build();
newEquipParseService.setEquCateInfoForInsert(formData, matchItemDto);
matchItemDto.setRegType(newEquipParseService.getRegTypeForInsert(formData));
matchItemDto.setRegType(bizId != null ? newEquipParseService.getRegTypeForEdit(bizId) : newEquipParseService.getRegTypeForInsert(formData));
return matchItemDto;
}
@Override
public MatchItemDto getMatchItem(String bizId) {
public MatchItemDto setMatchItem(String bizId) {
MatchItemDto matchItemDto = MatchItemDto.builder().build();
newEquipParseService.setEquCateInfoForEdit(bizId, matchItemDto);
matchItemDto.setRegType(newEquipParseService.getRegTypeForEdit(bizId));
......
......@@ -9,6 +9,8 @@ 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
......@@ -23,17 +25,22 @@ public class UseRegisterReminderAdapter extends DefaultReminder {
}
@Override
protected List<ReminderItemDto> realtimeParse(String bizId) {
return Collections.emptyList();
}
@Override
public IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page) {
return null;
}
@Override
public MatchItemDto getMatchItem(String bizId, Map<String, Object> formData) {
public MatchItemDto setMatchItem(String bizId, Map<String, Object> formData) {
return null;
}
@Override
public MatchItemDto getMatchItem(String bizId) {
public MatchItemDto setMatchItem(String bizId) {
return null;
}
......
......@@ -23,17 +23,28 @@ public abstract class DefaultReminder implements IReminderHandler {
public IPage<ReminderItemDto> remindersPage(Page<ReminderItemDto> page, String bizId, SourceType sourceType, Map<String, Object> formData) {
IPage<ReminderItemDto> params = parse(page, bizId, sourceType, formData);
ReminderFieldDiff reminderFieldDiff = applicationContext.getBean(ReminderFieldDiff.class);
MatchItemDto matchItemDto = getMatchItem(bizId, formData) == null ? MatchItemDto.builder().build() : getMatchItem(bizId, formData);
MatchItemDto matchItemDto = setMatchItemBySourceType(sourceType, bizId, formData);
matchItemDto.setBizType(supportBizType());
matchItemDto.setPage(page);
return reminderFieldDiff.getReminderItemsPage(params, matchItemDto);
}
private MatchItemDto setMatchItemBySourceType(SourceType sourceType, String bizId, Map<String, Object> formData) {
switch (sourceType) {
case realTime:
return setMatchItem(bizId);
case json:
return setMatchItem(bizId, formData);
default:
throw new RuntimeException("no support type for " + sourceType);
}
}
@Override
public Integer getReminderLevel(String bizId) {
ReminderFieldDiff reminderFieldDiff = applicationContext.getBean(ReminderFieldDiff.class);
MatchItemDto matchItemDto = getMatchItem(bizId) == null ? MatchItemDto.builder().build() : getMatchItem(bizId);
List<ReminderItemDto> equips = reminderFieldDiff.getReminderItemList(realtimeParse(bizId, null).getRecords(), matchItemDto);
MatchItemDto matchItemDto = setMatchItem(bizId) == null ? MatchItemDto.builder().build() : setMatchItem(bizId);
List<ReminderItemDto> equips = reminderFieldDiff.getReminderItemList(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);
}
......@@ -49,14 +60,18 @@ public abstract class DefaultReminder implements IReminderHandler {
}
}
public abstract IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page);
protected abstract IPage<ReminderItemDto> realtimeParse(String bizId, Page<ReminderItemDto> page);
protected abstract List<ReminderItemDto> realtimeParse(String bizId);
protected abstract IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page);
public abstract IPage<ReminderItemDto> jsonParse(String bizId, Map<String, Object> formData, Page<ReminderItemDto> page);
protected abstract MatchItemDto setMatchItem(String bizId, Map<String, Object> formData);
public abstract MatchItemDto getMatchItem(String bizId, Map<String, Object> formData);
public abstract MatchItemDto getMatchItem(String bizId);
protected abstract MatchItemDto setMatchItem(String bizId);
}
......@@ -15,6 +15,11 @@ public class MatchItemDto {
private String equDefine;
/**
* 是否车用气瓶:0-否;1-是,默认0
*/
private String whetherVehicleCylinder = "0";
private String regType;
Page<ReminderItemDto> page;
......
package com.yeejoin.amos.boot.module.jg.biz.reminder.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.util.List;
......@@ -26,7 +26,7 @@ public class ReminderItemDto {
/**
* 详细数据
*/
@JSONField(serialize = false)
@JsonIgnore
private Map<String, Object> detailData;
/**
......
......@@ -41,19 +41,21 @@ public class ReminderFieldDiffImpl implements ReminderFieldDiff {
private List<ReminderField> buildRemindItem(ReminderItemDto reminderItemDto, MatchItemDto matchItem) {
// regType默认0-新增,不同regType对应不同字段时,配置多行
List<TzsJgColumnReminderRule> rules = reminderRuleService.list(new LambdaQueryWrapper<TzsJgColumnReminderRule>().eq(TzsJgColumnReminderRule::getBizType, matchItem.getBizType()).eq(StringUtils.isNotEmpty(matchItem.getRegType()), TzsJgColumnReminderRule::getRegType, matchItem.getRegType()));
List<TzsJgColumnReminderRule> rules = reminderRuleService.list(new LambdaQueryWrapper<TzsJgColumnReminderRule>()
.eq(TzsJgColumnReminderRule::getBizType, matchItem.getBizType())
.eq(StringUtils.isNotEmpty(matchItem.getRegType()), TzsJgColumnReminderRule::getRegType, matchItem.getRegType()).eq(TzsJgColumnReminderRule::getWhetherVehicleCylinder, matchItem.getWhetherVehicleCylinder()));
List<TzsJgColumnReminderRule> equCategoryMatch = new ArrayList<>();
List<TzsJgColumnReminderRule> equListMatch = new ArrayList<>();
// 特殊不一样的配置设备类别
if (matchItem.getEquCategory() != null) {
equCategoryMatch = rules.stream().filter(r -> r.getEquCategory().contains(matchItem.getEquCategory())).collect(Collectors.toList());
equCategoryMatch = rules.stream().filter(r -> r.getEquCategory() != null && r.getEquCategory().contains(matchItem.getEquCategory())).collect(Collectors.toList());
}
// 和设备类别没关系配置设备整理
// 和设备类别没关系配置设备种类
if (matchItem.getEquList() != null) {
equListMatch = rules.stream().filter(r -> r.getEquList().contains(matchItem.getEquList())).collect(Collectors.toList());
}
Set<TzsJgColumnReminderRule> reminderRules = new HashSet<>(Stream.concat(equCategoryMatch.stream(), equListMatch.stream()).collect(Collectors.toMap(TzsJgColumnReminderRule::getColumnKey, Function.identity(), (O1, O2) -> O1)).values());
return reminderRules.stream().filter(e -> containKeyAndValue(reminderItemDto.getDetailData(), e.getColumnKey())).map(e -> {
return reminderRules.stream().filter(e -> !containKeyAndValue(reminderItemDto.getDetailData(), e.getColumnKey())).map(e -> {
ReminderField reminderField = new ReminderField();
reminderField.setColumnKey(e.getColumnKey());
reminderField.setColumnLabel(e.getColumnLabel());
......@@ -64,6 +66,6 @@ public class ReminderFieldDiffImpl implements ReminderFieldDiff {
}
private boolean containKeyAndValue(Map<String, Object> detailData, String columnKey) {
return Arrays.stream(columnKey.split(",")).noneMatch(k -> detailData.containsKey(k) && StringUtils.isNotEmpty(detailData.get(k).toString()));
return Arrays.stream(columnKey.split(",")).anyMatch(k -> detailData.containsKey(k) && Objects.nonNull(detailData.get(k)));
}
}
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