定时任务:预警

This commit is contained in:
zhangjun
2022-09-14 18:12:28 +08:00
parent 317881c646
commit 499d4702ee
2 changed files with 89 additions and 18 deletions
@@ -23,6 +23,7 @@ import com.adc.da.utils.util.InitStandAttrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -155,7 +156,7 @@ public class ScheduledJob {
BeanUtils.copyProperties(item, warningDate);
warningDate.setId(UUIDUtils.randomUUID20());
warningDate.setSSRQ(s);
warningDate.setFileType("0");
warningDate.setType("0");
data.add(warningDate);
}
}
@@ -163,13 +164,16 @@ public class ScheduledJob {
//此处开始处理条款中的预警数据
//查询符合预警期限的标准 多个
List<WarningDate> warningDateOfItems = sarStandardWarningDao.getWarningDateOfItems(term);
//第二步便利相同的
// List<WarningDate> second = sarStandardWarningDao.getWarningDateOfItems(term);
Map<String,List<WarningDate>> standMap = new HashMap<>();
warningDateOfItems.forEach(item -> {
for (String s : item.getSSRQ().split(",")) {
String id = item.getLawId();
if (id.equals("vgh0j186ve7uhxjelctt")){
System.out.println(id);
}
System.out.println(id);
// String id = item.getLawId();
// if (id.equals("vgh0j186ve7uhxjelctt")){
// System.out.println(id);
// }
// System.out.println(id);
String pattern = term.getTermStr();
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(s);
@@ -177,22 +181,32 @@ public class ScheduledJob {
if (m.matches()) {
//此处判断当前条款的数据是否是最新状态的
String lawsId = item.getLawId();
String fileType =item.getFileType();
String textState = sarStandardWarningDao.getStandTextStateByStandId(lawsId);
if(StringUtils.isNotBlank(textState)){
String convertFileType = convertTextStateToItemType(textState);
if(StringUtils.isNotBlank(convertFileType) && fileType.equals(convertFileType)){
WarningDate warningDate = new WarningDate();
BeanUtils.copyProperties(item, warningDate);
warningDate.setId(UUIDUtils.randomUUID20());
warningDate.setSSRQ(s);
warningDate.setFileType("1");
data.add(warningDate);
}
// String fileType =item.getFileType();
// String textState = sarStandardWarningDao.getStandTextStateByStandId(lawsId);
List<WarningDate> warningDates = null;
if(standMap.containsKey(lawsId)){
warningDates = standMap.get(lawsId);
}else{
warningDates=new ArrayList<>();
}
WarningDate warningDate = new WarningDate();
BeanUtils.copyProperties(item, warningDate);
warningDate.setId(UUIDUtils.randomUUID20());
warningDate.setSSRQ(s);
warningDate.setType("1");
warningDates.add(warningDate);
standMap.put(lawsId,warningDates);
}
}
});
for (String lawId : standMap.keySet()){
List<WarningDate> warningDates = standMap.get(lawId);
List<WarningDate> warningDateSend = compareState(warningDates);
if (null != warningDateSend) {
data.addAll(warningDateSend);
}
}
//清空标准的日期子表
iWarningDateService.remove(null);
// 保存进入标准的日期子表 保存标准的实施日期 新车型实施日期 在产车实施日期 多个
@@ -216,6 +230,60 @@ public class ScheduledJob {
}
}
private List<WarningDate> compareState(List<WarningDate> warningDates){
List<WarningDate> ca = new ArrayList<>();
List<WarningDate> zqyjg = new ArrayList<>();
List<WarningDate> bpg = new ArrayList<>();
List<WarningDate> ssg = new ArrayList<>();
List<WarningDate> fbgbjbd = new ArrayList<>();
for (WarningDate warningDate :warningDates){
if (null == warningDate.getFileType()){
warningDate.setFileType("");
}
switch (warningDate.getFileType()){
case "CA"://草稿
ca.add(warningDate);
// fileType="CA";
break;
case "ZQYJG"://征求意见稿
zqyjg.add(warningDate);
// fileType="ZQYJG";
break;
case "BPG"://报批稿
bpg.add(warningDate);
// fileType="BPG";
break;
case "SSG"://送审稿
ssg.add(warningDate);
// fileType="SSG";
break;
case "FBGBJBD"://发布稿
fbgbjbd.add(warningDate);
// fileType="FBGBJBD";
break;
// case "vsaga7nwub"://已实施
// fbgbjbd.add(warningDate);
//// fileType="FBGBJBD";
// break;
default:
break;
}
}
if (!CollectionUtils.isEmpty(fbgbjbd)){
return fbgbjbd;
}else if (!CollectionUtils.isEmpty(ssg)){
return ssg;
}else if (!CollectionUtils.isEmpty(bpg)){
return bpg;
}else if (!CollectionUtils.isEmpty(zqyjg)){
return zqyjg;
}else if (!CollectionUtils.isEmpty(ca)){
return ca;
}else{
return null;
}
}
/**
* 将文本状态转换成文件类型
* @param textState
@@ -24,5 +24,8 @@ public class WarningDate {
private String timeName;
@TableField("type")
private String type;
@TableField(exist = false)
private String fileType;
}