标准预警,标准文本状态自动更新
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
package com.adc.da.scheduled;
|
||||
|
||||
import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@EnableScheduling
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ImplementScheduledJob {
|
||||
|
||||
@Autowired
|
||||
private SarStandardsInfoDao sarStandardsInfoDao;
|
||||
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
|
||||
// @Scheduled(cron="*/5 * * * * ?")
|
||||
@Async
|
||||
public void schedulingTasks() {
|
||||
QueryWrapper<SarStandardsInfo> wrapper = new QueryWrapper<>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+100
-25
@@ -5,8 +5,12 @@ import com.adc.da.scheduled.dao.SarStandardItemDao;
|
||||
import com.adc.da.scheduled.dao.SarStandardWarningDao;
|
||||
import com.adc.da.scheduled.entity.DataDTO;
|
||||
import com.adc.da.scheduled.entity.WarningEO;
|
||||
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
|
||||
import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao;
|
||||
import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo;
|
||||
import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -18,11 +22,12 @@ import org.springframework.stereotype.Component;
|
||||
import java.time.LocalDate;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@EnableScheduling
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WarningScheduledJob {
|
||||
public class ScheduledJob {
|
||||
|
||||
/**
|
||||
* 根据配置文件设置是否开启定时器
|
||||
@@ -31,35 +36,28 @@ public class WarningScheduledJob {
|
||||
@Value("${isNotScheduled}")
|
||||
private boolean isNotScheduled; //是否开启定时器
|
||||
|
||||
//
|
||||
// @Scheduled(cron="*/5 * * * * ?")
|
||||
// @Async
|
||||
// public void StandScheduledJob(){
|
||||
// System.out.println("hello");
|
||||
//// if(isNotScheduled){
|
||||
//// System.out.println(Thread.currentThread().getName() + " cron=0 0 1 1 * ? --- " + new Date()+"---START-01");
|
||||
//// System.out.println(Thread.currentThread().getName() + " cron=0 0 1 1 * ? --- " + new Date()+"---End-01");
|
||||
//// try{
|
||||
//// Thread.sleep(2000);
|
||||
//// }catch(Exception e){
|
||||
//// }
|
||||
//// }
|
||||
// }
|
||||
|
||||
|
||||
@Autowired
|
||||
private SarStandardWarningDao sarStandardWarningDao;
|
||||
private SarStandardInfoDao sarStandardInfoDao; //标准信息表
|
||||
|
||||
@Autowired
|
||||
private SarStandardItemDao sarStandardItemDao;
|
||||
private SarStandardsInfoDao sarStandardsInfoDao;//标准信息表
|
||||
|
||||
@Autowired
|
||||
private SarStandardInfoDao sarStandardInfoDao;
|
||||
private SarStandardWarningDao sarStandardWarningDao;//预警表
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
|
||||
// @Scheduled(cron="*/5 * * * * ?")
|
||||
@Autowired
|
||||
private SarStandardItemDao sarStandardItemDao; //分解单表
|
||||
|
||||
@Autowired
|
||||
private SarStandAttrInfoDao sarStandAttrInfoDao; //属性字段表
|
||||
|
||||
|
||||
|
||||
// @Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
|
||||
@Scheduled(cron="*/5 * * * * ?")
|
||||
@Async
|
||||
public void schedulingTasks() {
|
||||
public void WarningSchedulingTasks() {
|
||||
|
||||
|
||||
/**
|
||||
@@ -110,7 +108,7 @@ public class WarningScheduledJob {
|
||||
.setPower("1")
|
||||
.setMark("3")
|
||||
.setPutTime(warningEO.getXCXSSRQ())
|
||||
.setStandCode(warningEO.getStandSort()+" "+warningEO.getStandNum()+"-"+warningEO.getStandYear());
|
||||
.setStandCode(warningEO.getStandSort()+" "+ warningEO.getStandNum()+"-"+ warningEO.getStandYear());
|
||||
}
|
||||
warningList.addAll(standInfoXCXSSRQ);
|
||||
|
||||
@@ -122,7 +120,7 @@ public class WarningScheduledJob {
|
||||
.setPower("1")
|
||||
.setMark("4")
|
||||
.setPutTime(warningEO.getZCCSSRQ())
|
||||
.setStandCode(warningEO.getStandSort()+" "+warningEO.getStandNum()+"-"+warningEO.getStandYear());
|
||||
.setStandCode(warningEO.getStandSort()+" "+ warningEO.getStandNum()+"-"+ warningEO.getStandYear());
|
||||
}
|
||||
warningList.addAll(standInfoZCCSSRQ);
|
||||
|
||||
@@ -133,4 +131,81 @@ public class WarningScheduledJob {
|
||||
System.out.println("已预警 " + count + " 条标准或条款!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
|
||||
// @Scheduled(cron="*/5 * * * * ?")
|
||||
@Async
|
||||
public void TextStatusSchedulingTasks() {
|
||||
QueryWrapper<SarStandardsInfo> wrapper = new QueryWrapper<>();
|
||||
|
||||
DataDTO data = new DataDTO(LocalDate.now(), LocalDate.now());
|
||||
|
||||
/**
|
||||
*实施日期是当前系统时间的标准文本状态变为'现行有效'
|
||||
*/
|
||||
QueryWrapper<SarStandAttrInfo> columnsAndCondition = new QueryWrapper<>();
|
||||
columnsAndCondition.select("STAND_ID").like("SSRQ",LocalDate.now());
|
||||
List<Map<String, Object>> effectiveList=sarStandAttrInfoDao.selectMaps(columnsAndCondition);
|
||||
// List<ScheduledDTO> effectiveList = sarStandardInfoDao.selectWithinTerm(data, "SSRQ");
|
||||
|
||||
effectiveList.forEach(item->{
|
||||
try {
|
||||
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
||||
sarStandardsInfo.setId(item.get("STAND_ID").toString());
|
||||
sarStandardsInfo.setTextStatus("vsaga7nwub");
|
||||
|
||||
sarStandardsInfoDao.updateById(sarStandardsInfo);
|
||||
// sarStandardInfoDao.updateStandardInfo(item.getStandId(),"vsaga7nwub");
|
||||
|
||||
}catch (Exception e){
|
||||
System.out.println("标准id为=="+item.get("STAND_ID").toString()+"==文本状态更新失败");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 被多个标准代替的标准变为“被代替”,只有一个被代替的自动变为“废止”
|
||||
*/
|
||||
QueryWrapper<SarStandAttrInfo> columns = new QueryWrapper<>();
|
||||
columns.select("DTBJH","STAND_ID");
|
||||
List<Map<String, Object>> mapsDTBZH = sarStandAttrInfoDao.selectMaps(columns);
|
||||
|
||||
mapsDTBZH.forEach(item->{
|
||||
if (item.get("DTBJH")!=null && !item.get("DTBJH").toString().equals("")){
|
||||
String dtbzh = item.get("DTBJH").toString();
|
||||
String[] split = dtbzh.split(",");
|
||||
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
||||
sarStandardsInfo.setId(item.get("STAND_ID").toString());
|
||||
|
||||
//一个被代替标准号时,文本状态更新为废止状态,两个及以上时更新为被代替状态
|
||||
switch (split.length){
|
||||
case 0 :
|
||||
break;
|
||||
case 1 :
|
||||
sarStandardsInfo.setTextStatus("chblaarg77");//废止状态
|
||||
break;
|
||||
default:
|
||||
sarStandardsInfo.setTextStatus("qke0ckro2p");//被代替状态
|
||||
}
|
||||
try {
|
||||
sarStandardsInfoDao.updateById(sarStandardsInfo);
|
||||
}catch (Exception e){
|
||||
System.out.println("代替标准状态更新:id为"+item.get("STAND_ID").toString()+"文本状态更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package com.adc.da.scheduled.dao;
|
||||
|
||||
import com.adc.da.scheduled.entity.DataDTO;
|
||||
import com.adc.da.scheduled.entity.WarningEO;
|
||||
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,4 +14,6 @@ public interface SarStandardInfoDao{
|
||||
|
||||
public List<WarningEO> selectWithinTerm(DataDTO date, String str);
|
||||
|
||||
public int updateStandardInfo(@Param("id")String id, @Param("textStatus") String textStatus);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.adc.da.scheduled.dao;
|
||||
|
||||
import com.adc.da.scheduled.entity.DataDTO;
|
||||
import com.adc.da.scheduled.entity.WarningEO;
|
||||
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.adc.da.scheduled.entity;
|
||||
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@@ -13,15 +13,21 @@ public class DataDTO {
|
||||
* 预警的期限为系统日期的次日至3个月后
|
||||
*/
|
||||
|
||||
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
private LocalDate startDate;
|
||||
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
private LocalDate endDate;
|
||||
|
||||
// private String str;
|
||||
|
||||
public DataDTO() {
|
||||
this.startDate =LocalDate.now(); //系统当前日期
|
||||
this.startDate =LocalDate.now().plusDays(1); //系统当前日期
|
||||
this.endDate = LocalDate.now().plusMonths(3);//系统当前日期3个月后
|
||||
}
|
||||
|
||||
public DataDTO(LocalDate startDate,LocalDate endDate){
|
||||
this.startDate=startDate;
|
||||
this.endDate=endDate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -15,8 +16,10 @@ import java.util.Date;
|
||||
public class WarningEO extends EarlyWarningEO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private Date XCXSSRQ;
|
||||
|
||||
@DateTimeFormat(pattern = "YYYY-MM-dd")
|
||||
private Date ZCCSSRQ;
|
||||
|
||||
private String standNum;
|
||||
@@ -24,4 +27,6 @@ public class WarningEO extends EarlyWarningEO {
|
||||
private String standSort;
|
||||
|
||||
private String standYear;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -31,12 +31,27 @@
|
||||
FROM
|
||||
sar_standards_info AS info
|
||||
JOIN sar_stand_attr_info AS attrInfo ON info.id = attrinfo.stand_id
|
||||
WHERE
|
||||
attrInfo.${str} BETWEEN #{date.startDate} and #{date.endDate}
|
||||
<where>
|
||||
1=1
|
||||
<if test="date!=null">
|
||||
and
|
||||
attrInfo.${str}
|
||||
BETWEEN DATE_FORMAT( #{date.startDate},'%Y-%m-%d %H:%i:%s')
|
||||
and DATE_FORMAT( #{date.endDate},'%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
</where>
|
||||
|
||||
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateStandardInfo">
|
||||
update sar_standards_info
|
||||
set TEXT_STATUS=#{textStatus}
|
||||
where ID=#{id}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user