update 标准预警

This commit is contained in:
liao
2023-10-31 14:39:15 +08:00
parent 61f5e31d18
commit 4f360092f4
5 changed files with 36 additions and 23 deletions
@@ -1,6 +1,7 @@
package com.jero.modules.laws.localTool.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -39,11 +39,13 @@
) AS standard
WHERE
<if test="param.newModelImplementationDate != null and param.newModelImplementationDate != ''">
standard.new_model_implementation_date IS NOT NULL AND
<foreach collection="param.dayStrings" separator=" or " open="(" close=")" item="item">
standard.new_model_implementation_date LIKE CONCAT('%', #{item}, '%')
</foreach>
</if>
<if test="param.onTheProductionDate != null and param.onTheProductionDate != ''">
standard.on_the_production_date IS NOT NULL AND
<foreach collection="param.dayStrings" separator=" or " open="(" close=")" item="item">
standard.on_the_production_date LIKE CONCAT('%', #{item}, '%')
</foreach>
@@ -6,9 +6,12 @@ import com.jero.modules.laws.common.util.DateUtil;
import com.jero.modules.laws.localTool.entity.StandardEarlyWarning;
import com.jero.modules.laws.localTool.mapper.LawsStandardEarlyWarningMapper;
import com.jero.modules.laws.localTool.service.ILawsStandardEarlyWarningService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
/**
@@ -17,6 +20,7 @@ import java.util.List;
* @Description: 标准预警
*/
@Service
@Slf4j
public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWarningService {
@Autowired
@@ -29,12 +33,8 @@ public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWa
**/
@Override
public IPage<StandardEarlyWarning> newModelImplementation(StandardEarlyWarning standardEarlyWarning, Integer pageNo, Integer pageSize) {
// 获取当前日前一周的日期字符串集合
List<String> dayStrings = DateUtil.getLastWeekDateAsString();
standardEarlyWarning.setDayStrings(dayStrings);
standardEarlyWarning.setNewModelImplementationDate("A");
Page<StandardEarlyWarning> page = new Page<>(pageNo, pageSize);
IPage<StandardEarlyWarning> pageList = lawsStandardEarlyWarningMapper.pageList(page, standardEarlyWarning);
IPage<StandardEarlyWarning> pageList = pageList(standardEarlyWarning, pageNo, pageSize);
return pageList;
}
@@ -45,12 +45,37 @@ public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWa
**/
@Override
public IPage<StandardEarlyWarning> onTheProduction(StandardEarlyWarning standardEarlyWarning, Integer pageNo, Integer pageSize) {
standardEarlyWarning.setOnTheProductionDate("A");
IPage<StandardEarlyWarning> pageList = pageList(standardEarlyWarning, pageNo, pageSize);
return pageList;
}
/**
* @Author: liao
* @Date: 2023/10/31 14:08
* @Description: 标准预警通用分页查询
**/
private IPage<StandardEarlyWarning> pageList(StandardEarlyWarning standardEarlyWarning, Integer pageNo, Integer pageSize) {
// 获取当前日前一周的日期字符串集合
List<String> dayStrings = DateUtil.getLastWeekDateAsString();
log.info("标准预警:当前一周的日期为{}", StringUtils.join(dayStrings, ","));
standardEarlyWarning.setDayStrings(dayStrings);
standardEarlyWarning.setOnTheProductionDate("A");
Page<StandardEarlyWarning> page = new Page<>(pageNo, pageSize);
IPage<StandardEarlyWarning> pageList = lawsStandardEarlyWarningMapper.pageList(page, standardEarlyWarning);
pageList.getRecords().forEach(warning -> {
// 新车型实施日期
if (StringUtils.isNotBlank(standardEarlyWarning.getNewModelImplementationDate())) {
List<String> eStrings = Arrays.asList(warning.getNewModelImplementationDate().split(","));
eStrings.retainAll(dayStrings); // 删除eStrings中与dayStrings不相同的元素
warning.setNewModelImplementationDate(eStrings.get(0));
}
// 在产车实施日期
if (StringUtils.isNotBlank(standardEarlyWarning.getOnTheProductionDate())) {
List<String> eStrings = Arrays.asList(warning.getOnTheProductionDate().split(","));
eStrings.retainAll(dayStrings); // 删除eStrings中与dayStrings不相同的元素
warning.setOnTheProductionDate(eStrings.get(0));
}
});
return pageList;
}