文本状态更新被代替,废止

This commit is contained in:
zhaokaiyao@91isoft.com
2021-09-04 15:07:15 +08:00
parent 28e8ba6c88
commit 2e83db6d98
@@ -13,6 +13,7 @@ import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
import com.adc.da.util.UUIDUtils; import com.adc.da.util.UUIDUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
@@ -21,9 +22,9 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.LinkedList; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Map; import java.util.stream.Stream;
@EnableScheduling @EnableScheduling
@Component @Component
@@ -173,8 +174,8 @@ public class ScheduledJob {
/** /**
* 定时更新文本状态 * 定时更新文本状态
*/ */
@Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行 // @Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
// @Scheduled(cron="*/5 * * * * ?") @Scheduled(cron="*/5 * * * * ?")
@Async @Async
public void TextStatusSchedulingTasks() { public void TextStatusSchedulingTasks() {
QueryWrapper<SarStandardsInfo> wrapper = new QueryWrapper<>(); QueryWrapper<SarStandardsInfo> wrapper = new QueryWrapper<>();
@@ -205,37 +206,56 @@ public class ScheduledJob {
/** /**
* 被多个标准代替的标准变为“被代替”,只一个代替的自动变为“废止” * 被多个标准代替的标准变为“被代替”,只一个标准代替的自动变为“废止”
*/ */
QueryWrapper<SarStandAttrInfo> columns = new QueryWrapper<>(); QueryWrapper<SarStandardsInfo> columns = new QueryWrapper<>();
columns.select("DTBJH","STAND_ID");
List<Map<String, Object>> mapsDTBZH = sarStandAttrInfoDao.selectMaps(columns);
mapsDTBZH.forEach(item->{ columns.select("REPLACE_STAND_NUM");
if (item.get("DTBJH")!=null && !item.get("DTBJH").toString().equals("")){ //查询代替标准字段得到一个 被代替了的标准的id的键值对列表
String dtbzh = item.get("DTBJH").toString(); List<Map<String, Object>> replaceStandIdMaps = sarStandardsInfoDao.selectMaps(columns);
String[] split = dtbzh.split(","); HashMap<String, Integer> replaceIdCountMap = new HashMap<>();
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
sarStandardsInfo.setId(item.get("STAND_ID").toString());
//一个被代替标准号时,文本状态更新为废止状态,两个及以上时更新为被代替状态 replaceStandIdMaps.forEach(item->{
switch (split.length){ if (item!=null){
case 0 : //此标准代替的标准的id数组
break; String[] standIds = item.get("REPLACE_STAND_NUM").toString().split(",");
case 1 : for (String standId : standIds) {
sarStandardsInfo.setTextStatus("chblaarg77");//废止状态
break; //如果代替标准id已存在则映射为2不存在则添加并映射为1
default: if (replaceIdCountMap.containsKey(standId)) {
sarStandardsInfo.setTextStatus("qke0ckro2p");//被代替状态 replaceIdCountMap.replace(standId,2);
} }else {
try { replaceIdCountMap.put(standId, 1);
sarStandardsInfoDao.updateById(sarStandardsInfo); }
}catch (Exception e){ }
System.out.println("代替标准状态更新:id为"+item.get("STAND_ID").toString()+"文本状态更新失败");
} }
});
//一个被代替标准号时,文本状态更新为废止状态,两个及以上时更新为被代替状态
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
for (String key : replaceIdCountMap.keySet()) {
switch (replaceIdCountMap.get(key)){
case 1 :
sarStandardsInfo.setTextStatus("chblaarg77");//废止状态
sarStandardsInfo.setId(key);
break;
default :
sarStandardsInfo.setTextStatus("qke0ckro2p");//被代替状态
sarStandardsInfo.setId(key);
break;
} }
});
try {
sarStandardsInfoDao.updateById(sarStandardsInfo);
}catch (Exception e){
System.out.println("代替标准状态更新:id为"+key+"文本状态更新失败");
}
}
} }
} }