Merge branch 'develop_3' into 'develop_master'

Develop 3

See merge request !119
This commit is contained in:
super_liu
2021-08-20 07:06:16 +00:00
12 changed files with 314 additions and 16 deletions
@@ -1,5 +1,11 @@
package com.adc.da.scheduled;
import com.adc.da.scheduled.dao.SarStandardInfoDao;
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.util.UUIDUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -8,7 +14,9 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.time.LocalDate;
import java.util.LinkedList;
import java.util.List;
@EnableScheduling
@Component
@@ -22,17 +30,107 @@ public class ScheduledJob {
@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){
//// }
//// }
// }
@Scheduled(cron="*/5 * * * * ?")
@Autowired
private SarStandardWarningDao sarStandardWarningDao;
@Autowired
private SarStandardItemDao sarStandardItemDao;
@Autowired
private SarStandardInfoDao sarStandardInfoDao;
@Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
// @Scheduled(cron="*/5 * * * * ?")
@Async
public void StandScheduledJob(){
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){
}
public void schedulingTasks() {
/**
* 1.查询标准属性字段表(sar_stand_attr_info) XCXSSEQ ZCCSSRQ ZRGCS
* 联接标准信息表sar_standards_info表的STAND_NAME
* 2.查询分解单(条款表)
* 3.查询预警表
* 4.去掉预警表中已存在的的数据
* 5.插入预警表
*/
/**
mark:标识预警的种类
3:新车标准预警
4:在产车标准预警
1:新车条款预警
2:在产车条款预警
*/
System.out.println("开始执行预警!!!");
//预警期限
DataDTO dataDTO = new DataDTO();
dataDTO.setStartDate(LocalDate.now().plusDays(1)) //系统日期的下一天
.setEndDate(LocalDate.now().plusMonths(3).plusDays(1));//系统日期3个月后
LinkedList<WarningEO> warningList = new LinkedList<>();
//分解单(条款) 新车型 mark=1
List<WarningEO> itemForXCXSSRQ = sarStandardItemDao.select(dataDTO, "XCXSSRQ");
for (WarningEO warningEO : itemForXCXSSRQ) {
warningEO.setId(UUIDUtils.randomUUID20())
.setPower("1")
.setMark("1")
.setPutTime(warningEO.getXCXSSRQ());
}
warningList.addAll(itemForXCXSSRQ);
//分解单(条款) 在产车型 mark=2
List<WarningEO> itemForZCCSSRQ = sarStandardItemDao.select(dataDTO, "ZCCSSRQ");
for (WarningEO warningEO : itemForZCCSSRQ) {
warningEO.setId(UUIDUtils.randomUUID20())
.setPower("1")
.setMark("2")
.setPutTime(warningEO.getZCCSSRQ());
}
warningList.addAll(itemForZCCSSRQ);
//标准 新车型 预警 mark=3
List<WarningEO> standInfoXCXSSRQ = sarStandardInfoDao.select(dataDTO, "XCXSSRQ");
for (WarningEO warningEO : standInfoXCXSSRQ) {
warningEO.setId(UUIDUtils.randomUUID20())
.setPower("1")
.setMark("3")
.setPutTime(warningEO.getXCXSSRQ());
}
warningList.addAll(standInfoXCXSSRQ);
//标准 在产车型 mark=4
List<WarningEO> standInfoZCCSSRQ = sarStandardInfoDao.select(dataDTO, "ZCCSSRQ");
for (WarningEO warningEO : standInfoZCCSSRQ) {
warningEO.setId(UUIDUtils.randomUUID20())
.setPower("1")
.setMark("4")
.setPutTime(warningEO.getZCCSSRQ());
}
warningList.addAll(standInfoZCCSSRQ);
//持久化至预警表 忽略标准id和标志位都一样的数据
if (warningList.size()!=0){
int count = sarStandardWarningDao.ignoreInsert(warningList);
System.out.println("已预警 " + count + " 条标准或条款!!");
}
}
}
@@ -0,0 +1,17 @@
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.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SarStandardInfoDao{
public List<WarningEO> select(DataDTO date, String str);
}
@@ -0,0 +1,17 @@
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;
import java.util.List;
@Repository
public interface SarStandardItemDao extends BaseMapper{
public List<WarningEO> select(DataDTO date, String str);
}
@@ -0,0 +1,15 @@
package com.adc.da.scheduled.dao;
import com.adc.da.scheduled.entity.WarningEO;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.LinkedList;
@Repository
public interface SarStandardWarningDao extends IService<WarningEO> {
public int ignoreInsert(@Param(value = "warningEOS") LinkedList<WarningEO> warningEOS);
}
@@ -0,0 +1,18 @@
package com.adc.da.scheduled.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDate;
@Data
@Accessors(chain = true)
public class DataDTO {
private LocalDate startDate;
private LocalDate endDate;
private String str;
}
@@ -0,0 +1,22 @@
package com.adc.da.scheduled.entity;
import com.adc.da.base.entity.BaseEntity;
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import java.util.Date;
@Data
@Accessors(chain = true)
public class WarningEO extends EarlyWarningEO {
private static final long serialVersionUID = 1L;
private Date XCXSSRQ;
private Date ZCCSSRQ;
}
@@ -193,13 +193,9 @@ public class SarStandItemsServiceImpl extends ServiceImpl<SarStandItemsDao, SarS
public List<SarStandItems> querySarItemAndInterpretation(FindSarItemsPageReqDTO page){
//分页查询的总数
Integer count=dao.sarItemCount(page);
page.getPager().setRowCount(count);
List<SarStandItems> sarStandItems = dao.querySarItemAndInterpretation(page);
return sarStandItems;
}
@@ -1137,6 +1137,17 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
* @Return: com.adc.da.util.http.ResponseMessage<com.adc.da.lawss.entity.SarStandardsInfoEO>
*/
public int updateSarStandardsInfo(SarStandardsInfo sarStandardsInfoEO) throws Exception {
/**
* 加入对应"国家/地区"的清单列表
*/
//1.获取标准清单的"国家/地区"
//2.判断修改的标准的"国家/地区"与清单中的是否一致,一致则添加到清单中,不一致不作处理
String standId = sarStandardsInfoEO.getId();
// 查询修改前数据信息,为修改代替标准号使用
SarStandardsInfo beforeSarStandardsInfo = dao.selectById(standId);