fix 78642 我的消息-预警消息消息更改点
This commit is contained in:
@@ -436,4 +436,14 @@ CREATE TABLE `process_fb_standard_purchase`
|
||||
alter table process_fb_standard_purchase
|
||||
comment '法规采购流程表';
|
||||
|
||||
DROP TABLE IF EXISTS `laws_early_warning_message`;
|
||||
CREATE TABLE `laws_early_warning_message`
|
||||
(
|
||||
`id` varchar(36) NOT NULL PRIMARY KEY COMMENT '主键ID',
|
||||
`standard_number` varchar(50) COMMENT '标准编号',
|
||||
`warning_day` varchar(50) COMMENT '警告日期',
|
||||
`warning_type` varchar(5) COMMENT '警告类型(1新车型实施日期,2在产车实施日期)'
|
||||
) COMMENT = '标准预警-已发消息';
|
||||
alter table laws_early_warning_message
|
||||
comment '标准预警-已发消息';
|
||||
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.jero.modules.laws.localTool.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 标准预警-已发消息
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-11-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("laws_early_warning_message")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="laws_early_warning_message对象", description="标准预警-已发消息")
|
||||
public class LawsEarlyWarningMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private java.lang.String id;
|
||||
/**标准编号*/
|
||||
@Excel(name = "标准编号", width = 15)
|
||||
@ApiModelProperty(value = "标准编号")
|
||||
private java.lang.String standardNumber;
|
||||
/**警告日期*/
|
||||
@Excel(name = "警告日期", width = 15)
|
||||
@ApiModelProperty(value = "警告日期")
|
||||
private java.lang.String warningDay;
|
||||
/**警告类型(1新车型实施日期,2在产车实施日期)*/
|
||||
@Excel(name = "警告类型(1新车型实施日期,2在产车实施日期)", width = 15)
|
||||
@ApiModelProperty(value = "警告类型(1新车型实施日期,2在产车实施日期)")
|
||||
private java.lang.String warningType;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.jero.modules.laws.localTool.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.jero.modules.laws.localTool.entity.LawsEarlyWarningMessage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 标准预警-已发消息
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-11-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface LawsEarlyWarningMessageMapper extends BaseMapper<LawsEarlyWarningMessage> {
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jero.modules.laws.localTool.mapper.LawsEarlyWarningMessageMapper">
|
||||
<resultMap id="LawsEarlyWarningMessageResultMap" type="com.jero.modules.laws.localTool.entity.LawsEarlyWarningMessage">
|
||||
<id column="id" property="id" />
|
||||
<result column="standard_number" property="standardNumber" />
|
||||
<result column="warning_day" property="warningDay" />
|
||||
<result column="warning_type" property="warningType" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.jero.modules.laws.localTool.service;
|
||||
|
||||
import com.jero.modules.laws.localTool.entity.LawsEarlyWarningMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 标准预警-已发消息
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-11-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ILawsEarlyWarningMessageService extends IService<LawsEarlyWarningMessage> {
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.jero.modules.laws.localTool.service.impl;
|
||||
|
||||
import com.jero.modules.laws.localTool.entity.LawsEarlyWarningMessage;
|
||||
import com.jero.modules.laws.localTool.mapper.LawsEarlyWarningMessageMapper;
|
||||
import com.jero.modules.laws.localTool.service.ILawsEarlyWarningMessageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 标准预警-已发消息
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-11-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = JeroBootException.class)
|
||||
public class LawsEarlyWarningMessageServiceImpl extends ServiceImpl<LawsEarlyWarningMessageMapper, LawsEarlyWarningMessage> implements ILawsEarlyWarningMessageService {
|
||||
|
||||
}
|
||||
+41
-59
@@ -5,11 +5,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.common.api.vo.SendMessageAPI;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.laws.common.constant.MessageTemplateCodeCommon;
|
||||
import com.jero.modules.laws.common.util.DateUtil;
|
||||
import com.jero.modules.laws.localTool.entity.LawsEarlyWarningMessage;
|
||||
import com.jero.modules.laws.localTool.entity.StandardEarlyWarning;
|
||||
import com.jero.modules.laws.localTool.mapper.LawsStandardEarlyWarningMapper;
|
||||
import com.jero.modules.laws.localTool.service.ILawsEarlyWarningMessageService;
|
||||
import com.jero.modules.laws.localTool.service.ILawsStandardEarlyWarningService;
|
||||
import com.jero.modules.system.entity.SysUserDepart;
|
||||
import com.jero.modules.system.service.ISysUserDepartService;
|
||||
@@ -20,16 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -49,6 +42,8 @@ public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWa
|
||||
private ISysUserDepartService userDepartService;
|
||||
@Resource
|
||||
private SendMessageAPI sendMessageAPI;
|
||||
@Resource
|
||||
private ILawsEarlyWarningMessageService lawsEarlyWarningMessageService;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
@@ -105,27 +100,11 @@ public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWa
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// 新车型实施日期
|
||||
if (CollectionUtils.isNotEmpty(newList)) {
|
||||
// 根据 id 字段去重,保留日期最小的
|
||||
List<StandardEarlyWarning> distinctList = newList.stream()
|
||||
.collect(Collectors.toMap(StandardEarlyWarning::getId, Function.identity(),
|
||||
BinaryOperator.minBy((e1, e2) -> LocalDate.parse(e1.getNewModelImplementationDate(), formatter)
|
||||
.compareTo(LocalDate.parse(e2.getNewModelImplementationDate(), formatter)))))
|
||||
.values()
|
||||
.stream()
|
||||
.collect(Collectors.toList());
|
||||
sendMsgList(MessageTemplateCodeCommon.NEW_MODEL_IMPLEMENTATION, distinctList, true);
|
||||
sendMsgList(MessageTemplateCodeCommon.NEW_MODEL_IMPLEMENTATION, newList, true);
|
||||
}
|
||||
// 在产车实施日期
|
||||
if (CollectionUtils.isNotEmpty(onList)) {
|
||||
// 根据 id 字段去重,保留日期最小的
|
||||
List<StandardEarlyWarning> distinctList = onList.stream()
|
||||
.collect(Collectors.toMap(StandardEarlyWarning::getId, Function.identity(),
|
||||
BinaryOperator.minBy((e1, e2) -> LocalDate.parse(e1.getOnTheProductionDate(), formatter)
|
||||
.compareTo(LocalDate.parse(e2.getOnTheProductionDate(), formatter)))))
|
||||
.values()
|
||||
.stream()
|
||||
.collect(Collectors.toList());
|
||||
sendMsgList(MessageTemplateCodeCommon.ON_THE_PRODUCTION, distinctList, false);
|
||||
sendMsgList(MessageTemplateCodeCommon.ON_THE_PRODUCTION, onList, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +114,6 @@ public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWa
|
||||
* @Description: 发送消息
|
||||
**/
|
||||
private void sendMsgList(String templateCode, List<StandardEarlyWarning> distinctList, Boolean flag) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
distinctList.forEach(data -> {
|
||||
String departId = data.getResponsibleDepartment();
|
||||
LambdaQueryWrapper<SysUserDepart> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -149,45 +127,49 @@ public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWa
|
||||
sendMessageDTO.setTemplateCode(templateCode);
|
||||
sendMessageDTO.setToUserId(userIds);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("standardNumber", data.getStandardNumber());
|
||||
String standardNumber = data.getStandardNumber();
|
||||
map.put("standardNumber", standardNumber);
|
||||
map.put("standardName", data.getStandardName());
|
||||
Date date;
|
||||
Date toDay = new Date();
|
||||
try {
|
||||
if (flag) { // 新车型实施日期
|
||||
date = dateFormat.parse(data.getNewModelImplementationDate());
|
||||
} else { // 在产车实施日期
|
||||
date = dateFormat.parse(data.getOnTheProductionDate());
|
||||
String dateDay;
|
||||
if (flag) { // 新车型实施日期
|
||||
dateDay = data.getNewModelImplementationDate();
|
||||
if (isNotExist(standardNumber, dateDay, "1")) {
|
||||
map.put("days", dateDay);
|
||||
sendMessageDTO.setMap(map);
|
||||
sendMessageAPI.sendMessage(sendMessageDTO);
|
||||
saveWarningMessage(standardNumber, dateDay, "1");
|
||||
}
|
||||
} else { // 在产车实施日期
|
||||
dateDay = data.getOnTheProductionDate();
|
||||
if (isNotExist(standardNumber, dateDay, "2")) {
|
||||
map.put("days", dateDay);
|
||||
sendMessageDTO.setMap(map);
|
||||
sendMessageAPI.sendMessage(sendMessageDTO);
|
||||
saveWarningMessage(standardNumber, dateDay, "2");
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("时间格式转换错误");
|
||||
}
|
||||
long days = getBetweenDays(toDay, date);
|
||||
map.put("days", days + "");
|
||||
sendMessageDTO.setMap(map);
|
||||
sendMessageAPI.sendMessage(sendMessageDTO);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/11/10 18:46
|
||||
* @Description: 获取两个日期之间的天数
|
||||
**/
|
||||
private long getBetweenDays(Date startDate, Date endDate) {
|
||||
// 将 Date 转换为 Instant
|
||||
Instant startInstant = startDate.toInstant();
|
||||
Instant endInstant = endDate.toInstant();
|
||||
private Boolean isNotExist(String standardNumber, String dateDay, String type) {
|
||||
LambdaQueryWrapper<LawsEarlyWarningMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsEarlyWarningMessage::getStandardNumber, standardNumber)
|
||||
.eq(LawsEarlyWarningMessage::getWarningDay, dateDay)
|
||||
.eq(LawsEarlyWarningMessage::getWarningType, type);
|
||||
LawsEarlyWarningMessage lawsEarlyWarningMessage = lawsEarlyWarningMessageService.getOne(queryWrapper, false);
|
||||
if (lawsEarlyWarningMessage == null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 将 Instant 转换为 LocalDate
|
||||
LocalDate startLocalDate = startInstant.atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
LocalDate endLocalDate = endInstant.atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
|
||||
// 使用 ChronoUnit 计算日期差
|
||||
long days = ChronoUnit.DAYS.between(startLocalDate, endLocalDate);
|
||||
return days;
|
||||
private void saveWarningMessage(String standardNumber, String dateDay, String type) {
|
||||
LawsEarlyWarningMessage lawsEarlyWarningMessage = new LawsEarlyWarningMessage();
|
||||
lawsEarlyWarningMessage.setStandardNumber(standardNumber);
|
||||
lawsEarlyWarningMessage.setWarningDay(dateDay);
|
||||
lawsEarlyWarningMessage.setWarningType(type);
|
||||
lawsEarlyWarningMessageService.save(lawsEarlyWarningMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user