为定时任务加上了日志
This commit is contained in:
@@ -20,6 +20,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@@ -228,10 +230,13 @@ public class ScheduledJob {
|
|||||||
QueryWrapper<SarStandAttrInfo> columnForDTBJH = new QueryWrapper<>();
|
QueryWrapper<SarStandAttrInfo> columnForDTBJH = new QueryWrapper<>();
|
||||||
|
|
||||||
columnForDTBJH.select("DTBJH")
|
columnForDTBJH.select("DTBJH")
|
||||||
.eq("VALID_FLAG","0");
|
.eq("VALID_FLAG","0")
|
||||||
|
.ne("DTBJH","");
|
||||||
//查询代替标准字段得到一个 被代替了的标准的id的键值对列表
|
//查询代替标准字段得到一个 被代替了的标准的id的键值对列表
|
||||||
List<Map<String, Object>> replaceStandIdMaps = sarStandAttrInfoDao.selectMaps(columnForDTBJH);
|
List<Map<String, Object>> replaceStandIdMaps = sarStandAttrInfoDao.selectMaps(columnForDTBJH).subList(0,100);
|
||||||
HashMap<String, Integer> replaceIdCountMap = new HashMap<>();
|
HashMap<String, Integer> replaceIdCountMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
// 格式为 T/CSAE 175-2021
|
// 格式为 T/CSAE 175-2021
|
||||||
/**
|
/**
|
||||||
* 国内外表准号格式不统一
|
* 国内外表准号格式不统一
|
||||||
@@ -287,22 +292,37 @@ public class ScheduledJob {
|
|||||||
|
|
||||||
|
|
||||||
//一个被代替标准号时,文本状态更新为废止状态,两个及以上时更新为被代替状态
|
//一个被代替标准号时,文本状态更新为废止状态,两个及以上时更新为被代替状态
|
||||||
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
|
||||||
for (String key : replaceIdCountMap.keySet()) {
|
for (String key : replaceIdCountMap.keySet()) {
|
||||||
|
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
||||||
|
String reasonMsg="";
|
||||||
switch (replaceIdCountMap.get(key)){
|
switch (replaceIdCountMap.get(key)){
|
||||||
case 1 :
|
case 1 :
|
||||||
sarStandardsInfo.setTextStatus("chblaarg77");//废止状态
|
//废止状态
|
||||||
|
sarStandardsInfo.setTextStatus("chblaarg77");
|
||||||
sarStandardsInfo.setId(key);
|
sarStandardsInfo.setId(key);
|
||||||
|
reasonMsg="该标准被一个标准代替";
|
||||||
break;
|
break;
|
||||||
default :
|
case 2 :
|
||||||
sarStandardsInfo.setTextStatus("qke0ckro2p");//被代替状态
|
//被代替状态
|
||||||
|
sarStandardsInfo.setTextStatus("qke0ckro2p");
|
||||||
sarStandardsInfo.setId(key);
|
sarStandardsInfo.setId(key);
|
||||||
|
reasonMsg="该标准被一个以上标准代替";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// sarUpdLogEOService.createUpdateLog(sarStandardsInfoEO.getStandType() + "_STAND", sarStandardsInfoEO.getId(), oldMap, newMap, content);
|
//更新日志
|
||||||
|
SarStandardsInfo beforeSarStandardsInfoEO = sarStandardsInfoDao.selectById(sarStandardsInfo.getId());
|
||||||
|
sarStandardsInfo.setStandType(beforeSarStandardsInfoEO.getStandType());
|
||||||
|
sarStandardsInfo.setStandSort(beforeSarStandardsInfoEO.getStandSort());
|
||||||
|
sarStandardsInfo.setStandNumber(beforeSarStandardsInfoEO.getStandNumber());
|
||||||
|
sarStandardsInfo.setStandYear(beforeSarStandardsInfoEO.getStandYear());
|
||||||
|
sarStandardsInfo.setStandName(beforeSarStandardsInfoEO.getStandName());
|
||||||
|
saveUpdateLog(sarStandardsInfo,beforeSarStandardsInfoEO,reasonMsg);
|
||||||
|
//更新日志
|
||||||
sarStandardsInfoDao.updateById(sarStandardsInfo);
|
sarStandardsInfoDao.updateById(sarStandardsInfo);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
System.out.println("代替标准状态更新:id为"+key+"文本状态更新失败");
|
System.out.println("代替标准状态更新:id为"+key+"文本状态更新失败");
|
||||||
@@ -312,4 +332,24 @@ public class ScheduledJob {
|
|||||||
logger.info("==================================更新文本状态结束======================================");
|
logger.info("==================================更新文本状态结束======================================");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void saveUpdateLog(SarStandardsInfo sarStandardsInfoEO, SarStandardsInfo beforeSarStandardsInfo,String reasonMsg) throws Exception {
|
||||||
|
Map<String, Object> newMap = new HashMap<>();
|
||||||
|
Map<String, Object> oldMap = new HashMap<>();
|
||||||
|
String attrStr = sarStandardsInfoEO.getSarStandAttrEOStr();
|
||||||
|
if (StringUtils.isNotBlank(attrStr)) {
|
||||||
|
newMap = JSONObject.fromObject(attrStr);
|
||||||
|
}
|
||||||
|
newMap.put("textStatus",sarStandardsInfoEO.getTextStatus());
|
||||||
|
oldMap.put("textStatus",beforeSarStandardsInfo.getTextStatus());
|
||||||
|
// 增加关联事件
|
||||||
|
String number = sarStandardsInfoEO.getStandSort() + " " + sarStandardsInfoEO.getStandNumber();
|
||||||
|
if (StringUtils.isNotBlank(sarStandardsInfoEO.getStandYear())) {
|
||||||
|
number += "-" + sarStandardsInfoEO.getStandYear();
|
||||||
|
}
|
||||||
|
String content ="==定时任务执行修改==:" + number + " 《" + sarStandardsInfoEO.getStandName() + "》"+reasonMsg;
|
||||||
|
sarUpdLogEOService.createUpdateLog(sarStandardsInfoEO.getStandType() + "_STAND", sarStandardsInfoEO.getId(), oldMap, newMap, content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -135,6 +135,7 @@ public class SarUpdLogServiceImpl extends ServiceImpl<SarUpdLogDao, SarUpdLog> i
|
|||||||
selectFieldMap.put("standSort","STANDCLASSIFY");
|
selectFieldMap.put("standSort","STANDCLASSIFY");
|
||||||
selectFieldMap.put("standState","STANDSTATE");
|
selectFieldMap.put("standState","STANDSTATE");
|
||||||
selectFieldMap.put("standNature","STANDNATURE");
|
selectFieldMap.put("standNature","STANDNATURE");
|
||||||
|
selectFieldMap.put("textStatus","TEXTSTATUS");
|
||||||
} else if (SarTypeEnum.INLAND_LAWS.getValue().equals(sarType) || SarTypeEnum.FOREIGN_LAWS.getValue().equals(sarType)) {
|
} else if (SarTypeEnum.INLAND_LAWS.getValue().equals(sarType) || SarTypeEnum.FOREIGN_LAWS.getValue().equals(sarType)) {
|
||||||
selectFieldMap = InitStandAttrUtil.selectFieldMapLaws;
|
selectFieldMap = InitStandAttrUtil.selectFieldMapLaws;
|
||||||
selectFieldMap.put("isRelateAccess","SHIFOUGL");
|
selectFieldMap.put("isRelateAccess","SHIFOUGL");
|
||||||
@@ -199,6 +200,7 @@ public class SarUpdLogServiceImpl extends ServiceImpl<SarUpdLogDao, SarUpdLog> i
|
|||||||
|
|
||||||
public String changeStandName (String field,String sarType) throws Exception{
|
public String changeStandName (String field,String sarType) throws Exception{
|
||||||
switch (field) {
|
switch (field) {
|
||||||
|
case "textStatus":return "文本状态";
|
||||||
case "country": return "适用区域";
|
case "country": return "适用区域";
|
||||||
case "isRelateAccess": return "重要度";
|
case "isRelateAccess": return "重要度";
|
||||||
case "issueTime": return "发布日期";
|
case "issueTime": return "发布日期";
|
||||||
|
|||||||
Reference in New Issue
Block a user