文档库定时任务
法规状态为即将实施的法规,根据新车型实施日期和在产车实施日期, 到期后自动更新状态为现行
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package com.jero.modules.document.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description
|
||||||
|
* 法规状态枚举
|
||||||
|
* @date 2022/1/21 15:22
|
||||||
|
* @auth zhn
|
||||||
|
*/
|
||||||
|
public enum LawsStateEnum {
|
||||||
|
ACTIVE("现行","1"),
|
||||||
|
ABOLISH("废止","2"),
|
||||||
|
THE_UPCOMING("即将实施","3"),
|
||||||
|
DRAFT("草稿","4"),
|
||||||
|
BE_REPLACED("被代替","5");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String name;
|
||||||
|
String value;
|
||||||
|
|
||||||
|
private LawsStateEnum(String name, String value) {
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
package com.jero.modules.document.service.impl;
|
||||||
|
|
||||||
|
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||||
|
import com.jero.modules.document.enums.LawsStateEnum;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description
|
||||||
|
* @date 2022/9/25 10:03
|
||||||
|
* @auth zhn
|
||||||
|
*/
|
||||||
|
public class TimedTaskLaws implements Job {
|
||||||
|
@Autowired
|
||||||
|
private BussDocumentLibraryEOServiceImpl bussDocumentLibraryEOService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 法规状态为即将实施的法规,根据新车型实施日期和在产车实施日期, 到期后自动更新状态为现行
|
||||||
|
* @param jobExecutionContext
|
||||||
|
* @throws JobExecutionException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String currentTime = sdf.format(new Date());
|
||||||
|
//获取所有的法规
|
||||||
|
List<BussDocumentLibraryEO> bussDocumentLibraryEOList = bussDocumentLibraryEOService.list();
|
||||||
|
if(bussDocumentLibraryEOList.size() != 0){
|
||||||
|
for (BussDocumentLibraryEO bussDocumentLibraryEO : bussDocumentLibraryEOList) {
|
||||||
|
String xin1Che1Xing2Shi2Shi1Ri4Qi1Str = "";
|
||||||
|
String implementTimestr = "";
|
||||||
|
|
||||||
|
String state = bussDocumentLibraryEO.getState();//状态
|
||||||
|
//新车型实施日期
|
||||||
|
Date xin1Che1Xing2Shi2Shi1Ri4Qi1 = bussDocumentLibraryEO.getXin1Che1Xing2Shi2Shi1Ri4Qi1();
|
||||||
|
//在产车实施日期
|
||||||
|
Date implementTime = bussDocumentLibraryEO.getImplementTime();
|
||||||
|
if(ObjectUtils.isNotEmpty(xin1Che1Xing2Shi2Shi1Ri4Qi1)){
|
||||||
|
xin1Che1Xing2Shi2Shi1Ri4Qi1Str = sdf.format(xin1Che1Xing2Shi2Shi1Ri4Qi1);
|
||||||
|
}
|
||||||
|
if(ObjectUtils.isNotEmpty(implementTime)){
|
||||||
|
implementTimestr = sdf.format(implementTime);
|
||||||
|
}
|
||||||
|
//法规状态为即将实施的法规,根据新车型实施日期和在产车实施日期, 到期后自动更新状态为现行
|
||||||
|
if(StringUtils.isNotBlank(state) && LawsStateEnum.THE_UPCOMING.getValue().equals(state)
|
||||||
|
&& (currentTime.equals(xin1Che1Xing2Shi2Shi1Ri4Qi1Str) || currentTime.equals(implementTimestr))){
|
||||||
|
BussDocumentLibraryEO bussDocumentLibraryEOTemp = new BussDocumentLibraryEO();
|
||||||
|
bussDocumentLibraryEOTemp.setId(bussDocumentLibraryEO.getId());
|
||||||
|
bussDocumentLibraryEOTemp.setState(LawsStateEnum.ACTIVE.getValue());
|
||||||
|
bussDocumentLibraryEOService.updateById(bussDocumentLibraryEOTemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user