Commit 7e73200d authored by suhuiguang's avatar suhuiguang

1.增加接口更新气瓶到期日期

2.修改每天及时气瓶超期等级由规则实现
parent 6ca89e3a
...@@ -16,18 +16,18 @@ public enum EarlyWarningLevelEnum { ...@@ -16,18 +16,18 @@ public enum EarlyWarningLevelEnum {
/** /**
* 预警等级枚举 * 预警等级枚举
*/ */
FIRST_LEVEL("一级预警","1", 60), FIRST_LEVEL("一级预警", "1", "即将超期"),
SECOND_LEVEL("二级预警","2", 10), SECOND_LEVEL("二级预警", "2", "即将超期"),
THREE_LEVEL("三级预警","3", 0); THREE_LEVEL("三级预警", "3", "已超期");
private String name; private String name;
private String code; private String level;
private int threshold; private String status;
public static EarlyWarningLevelEnum getEumByCode(String code){ public static EarlyWarningLevelEnum getEumByLevel(String level) {
Optional<EarlyWarningLevelEnum> op = Arrays.stream(EarlyWarningLevelEnum.values()).filter(e->e.getCode().equals(code)).findFirst(); Optional<EarlyWarningLevelEnum> op = Arrays.stream(EarlyWarningLevelEnum.values()).filter(e -> e.getLevel().equals(level)).findFirst();
return op.orElseThrow(()->new RuntimeException("未知的类型")); return op.orElseThrow(() -> new RuntimeException("未知的类型"));
} }
} }
...@@ -107,6 +107,9 @@ public class CylinderInfoDto extends BaseDto { ...@@ -107,6 +107,9 @@ public class CylinderInfoDto extends BaseDto {
@ApiModelProperty(value = "检验状态 0 已超期 1 正常 2 即将超期") @ApiModelProperty(value = "检验状态 0 已超期 1 正常 2 即将超期")
private int inspectionStatas; private int inspectionStatas;
@ApiModelProperty(value = "检验状态描述")
private String inspectionStatusDesc;
@ApiModelProperty(value = "预警等级") @ApiModelProperty(value = "预警等级")
private String earlyWarningLevel; private String earlyWarningLevel;
...@@ -116,4 +119,7 @@ public class CylinderInfoDto extends BaseDto { ...@@ -116,4 +119,7 @@ public class CylinderInfoDto extends BaseDto {
@ApiModelProperty(value = "最近配送地址") @ApiModelProperty(value = "最近配送地址")
private String address; private String address;
@ApiModelProperty(value = "最近预警时间")
private Date earlyWarningLevelCalDate;
} }
...@@ -59,7 +59,7 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> { ...@@ -59,7 +59,7 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
*/ */
Integer getMonthBeforeLastInfoTotalUnit(@Param("appId")String appId); Integer getMonthBeforeLastInfoTotalUnit(@Param("appId")String appId);
Integer countOverDateNumber(@Param("threshold") int threshold); Integer countOverDateNumber(@Param("earlyWarningLevel") String earlyWarningLevel);
Page<CylinderInfoDto> queryPageListByEarlyWarningLevel(Page<CylinderInfoDto> page, @Param("earlyWarningLevel") String earlyWarningLevel); Page<CylinderInfoDto> queryPageListByEarlyWarningLevel(Page<CylinderInfoDto> page, @Param("earlyWarningLevel") String earlyWarningLevel);
......
...@@ -58,31 +58,35 @@ ...@@ -58,31 +58,35 @@
count(1) count(1)
FROM `tz_cylinder_info` ci FROM `tz_cylinder_info` ci
where where
DATEDIFF(ci.next_inspection_date,now()) <![CDATA[<=]]> #{threshold} ci.early_warning_level = #{earlyWarningLevel}
</select> </select>
<select id="queryPageListByEarlyWarningLevel" <select id="queryPageListByEarlyWarningLevel"
resultType="com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto"> resultType="com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto">
select select
ci.sequence_code, ci.sequence_code,
ci.unit_name, ci.unit_name,
ci.factory_num,
ci.inspection_date, ci.inspection_date,
ci.next_inspection_date, ci.next_inspection_date,
ci.early_warning_level, ci.early_warning_level,
ci.early_warning_level_cal_date,
eu.address eu.address
from from
tz_cylinder_info ci tz_cylinder_info ci
left join tz_end_user eu on ci.end_custom_code = eu.custom_code left join tz_end_user eu on ci.end_custom_code = eu.custom_code
where where
ci.early_warning_level = #{earlyWarningLevel} ci.early_warning_level = #{earlyWarningLevel}
order by next_inspection_date desc order by ci.next_inspection_date
</select> </select>
<select id="getDetail" resultType="com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto"> <select id="getDetail" resultType="com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto">
select select
ci.sequence_code, ci.sequence_code,
ci.unit_name, ci.unit_name,
ci.inspection_date, ci.inspection_date,
ci.factory_num,
ci.next_inspection_date, ci.next_inspection_date,
ci.early_warning_level, ci.early_warning_level,
ci.early_warning_level_cal_date,
eu.address, eu.address,
eu.custom_name eu.custom_name
from from
......
...@@ -874,4 +874,11 @@ public class CylinderInfoController extends BaseController { ...@@ -874,4 +874,11 @@ public class CylinderInfoController extends BaseController {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.getMsgList(sequenceCode)); return ResponseHelper.buildResponse(cylinderInfoServiceImpl.getMsgList(sequenceCode));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT",value = "下次检验日期更新",notes = "下次检验日期更新")
@PutMapping(value = "/nextInspectionDate/update")
public ResponseModel<Boolean> nextInspectionDateUpdate(@RequestBody List<CylinderInfoDto> cylinderInfoDtos){
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.nextInspectionDateUpdate(cylinderInfoDtos));
}
} }
...@@ -19,7 +19,7 @@ public class CylinderSchedulerJob { ...@@ -19,7 +19,7 @@ public class CylinderSchedulerJob {
/** /**
* 每天凌晨0点-日报生成 * 每天凌晨0点-日报生成
*/ */
@Scheduled(cron = "0 0 0 * * ?") @Scheduled(cron = "0 0 8 * * ?")
public void dayReport() { public void dayReport() {
cylinderInfoService.calEarlyWarningLevel(); cylinderInfoService.calEarlyWarningLevel();
} }
......
...@@ -569,13 +569,16 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -569,13 +569,16 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
} }
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) { public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
EarlyWarningLevelEnum earlyWarningLevelEnum = EarlyWarningLevelEnum.getEumByCode(earlyWarningLevel); return this.baseMapper.countOverDateNumber(earlyWarningLevel);
return this.baseMapper.countOverDateNumber(earlyWarningLevelEnum.getThreshold());
} }
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) { public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel); Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> r.setEarlyWarningLevelName(EarlyWarningLevelEnum.getEumByCode(earlyWarningLevel).getName())); result.getRecords().forEach(r -> {
r.setEarlyWarningLevelName(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getName());
r.setInspectionStatusDesc(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getStatus());
});
return result; return result;
} }
...@@ -592,22 +595,11 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -592,22 +595,11 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
page.setSize(size); page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.orderByDesc(CylinderInfo::getSequenceNbr); wrapper.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page,wrapper); IPage<CylinderInfo> result = this.page(page, wrapper);
result.getRecords().forEach(r -> { result.getRecords().forEach(r -> {
try { try {
int interval = DateUtils.dateBetweenIncludeToday(r.getNextInspectionDate(), now); int interval = DateUtils.dateBetweenIncludeToday(r.getNextInspectionDate(), now);
if (interval <= 60) { // TODO 循环调用规则 触发计算等级及发送消息
r.setEarlyWarningLevel(EarlyWarningLevelEnum.FIRST_LEVEL.getCode());
r.setEarlyWarningLevelCalDate(now);
}
if (interval <= 10) {
r.setEarlyWarningLevel(EarlyWarningLevelEnum.SECOND_LEVEL.getCode());
r.setEarlyWarningLevelCalDate(now);
}
if (interval <= 0) {
r.setEarlyWarningLevel(EarlyWarningLevelEnum.THREE_LEVEL.getCode());
r.setEarlyWarningLevelCalDate(now);
}
} catch (ParseException e) { } catch (ParseException e) {
log.error(JSON.toJSONString(r) + "格式化失败"); log.error(JSON.toJSONString(r) + "格式化失败");
} }
...@@ -624,9 +616,31 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -624,9 +616,31 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
} }
public List<MsgLog> getMsgList(String sequenceCode) { public List<MsgLog> getMsgList(String sequenceCode) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode,sequenceCode); wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.orderByDesc(MsgLog::getSendTime); wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper); return msgLogService.list(wrapper);
} }
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c->{
CylinderInfo cylinderInfo = this.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode,c.getSequenceCode()));
cylinderInfo.setNextInspectionDate(c.getNextInspectionDate());
cylinderInfos.add(cylinderInfo);
// TODO 循环调用规则 触发计算等级及发送消息
});
if(!cylinderInfos.isEmpty()){
this.updateBatchById(cylinderInfos);
}
return Boolean.TRUE;
}
} }
\ 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