Commit 92a601fc authored by wei's avatar wei 🎱

定时任务

parent d0e1ceaf
package com.yonde.dcs.plan.common.vo;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.time.LocalDateTime;
import java.util.ArrayList;
import cn.hutool.core.convert.Convert;
import com.yonde.dex.basedata.entity.annotation.XmlElementProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import lombok.ToString;
import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.math.BigInteger;
import org.springframework.data.annotation.Transient;
import lombok.experimental.Delegate;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.XmlAttribute;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.yonde.dex.basedata.entity.xmladapters.LocalDateTimeXmlAdapter;
import lombok.Data;
import com.yonde.dex.basedata.entity.annotation.*;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import com.yonde.dex.basedata.entity.vo.IdOnlyVO;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dex.basedata.entity.annotation.DexEmbedded;
import com.yonde.dex.basedata.entity.annotation.ReferenceProperty;
import com.yonde.dex.basedata.entity.annotation.RelationProperty;
import com.yonde.dex.basedata.entity.annotation.VersionProperty;
import com.yonde.dex.basedata.entity.data.VersionRelationType;
import com.yonde.dex.basedata.entity.vo.DxIdVOEmbeddable;
import com.yonde.dex.secretcode.plugin.common.entity.DxSecretVOHolder;
import com.yonde.dex.basedata.entity.vo.IdOnlyVO;
import com.yonde.dex.basedata.entity.vo.IdVO;
import com.yonde.dex.dfs.objfilelink.plugin.common.entity.DxObjFileLinkVOEmbeddable;
import com.yonde.dex.dfs.objfilelink.plugin.common.entity.DxObjFileLinkVOHolder;
import com.yonde.dex.version.plugin.common.entity.DxIterationVOEmbeddable;
import com.yonde.dex.basedata.entity.users.DxUserVO;
import com.yonde.dex.lcycle.plugin.common.entity.DxLifecycleManageBaseVOHolder;
import com.yonde.dex.lcycle.plugin.common.entity.DxLifecycleManageBaseVOEmbeddable;
import com.yonde.dex.logicdelete.plugin.common.entity.DxLogicDeleteVOHolder;
import com.yonde.dcs.plan.common.vo.ExtSupplierManageLinkVO;
import com.yonde.dex.lcycle.plugin.common.entity.DxLifecycleManageBaseVOHolder;
import com.yonde.dex.logicdelete.plugin.common.entity.DxLogicDeleteVOEmbeddable;
import com.yonde.dex.basedata.entity.vo.IdVO;
import com.yonde.dex.logicdelete.plugin.common.entity.DxLogicDeleteVOHolder;
import com.yonde.dex.secretcode.plugin.common.entity.DxSecretVOEmbeddable;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dex.dfs.objfilelink.plugin.common.entity.DxObjFileLinkVOEmbeddable;
import com.yonde.dex.secretcode.plugin.common.entity.DxSecretVOHolder;
import com.yonde.dex.version.plugin.common.entity.DxIterationVOEmbeddable;
import com.yonde.dex.version.plugin.common.entity.DxIterationVOHolder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
import java.util.List;
/**
* @description: ExtSupplierManage-VO
* @author: dexadmin
* @version: V
* @date: 2024-9-19 11:25:51
**/
@JsonTypeInfo( use = JsonTypeInfo.Id.CLASS, property = "dxClassname", visible = true, defaultImpl = ExtSupplierManageVO.class)
* @description: ExtSupplierManage-VO
* @author: dexadmin
* @version: V
* @date: 2024-9-19 11:25:51
**/
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "dxClassname", visible = true, defaultImpl = ExtSupplierManageVO.class)
@EqualsAndHashCode(callSuper = true)
@Data
@ToString(callSuper = true)
public class ExtSupplierManageVO extends IdOnlyVO implements DxIterationVOHolder<ExtSupplierManageVO> ,IdVO ,DxLifecycleManageBaseVOHolder ,DxObjFileLinkVOHolder ,DxLogicDeleteVOHolder ,DxSecretVOHolder{
public class ExtSupplierManageVO extends IdOnlyVO implements DxIterationVOHolder<ExtSupplierManageVO>, IdVO, DxLifecycleManageBaseVOHolder, DxObjFileLinkVOHolder, DxLogicDeleteVOHolder, DxSecretVOHolder {
public static final String DX_OBJ_FILE_LINK_EMBEDDABLE_PROP_NAME = "dxObjFileLinkEmbeddable";
public static final String DX_LIFECYCLE_MANAGE_BASE_EMBEDDABLE_PROP_NAME = "dxLifecycleManageBaseEmbeddable";
......@@ -127,7 +109,7 @@ public class ExtSupplierManageVO extends IdOnlyVO implements DxIterationVOHolder
/**
* 名录有效期
*/
private String directoryValidity;
private LocalDateTime directoryValidity;
/**
* 文档
......@@ -218,7 +200,7 @@ public class ExtSupplierManageVO extends IdOnlyVO implements DxIterationVOHolder
private String unifiedSocietyCode;
/**
* supplierNumber
* 供方编码
*/
private String supplierNumber;
}
......
......@@ -74,7 +74,7 @@ public class SupplierEarlyWarningVO implements Serializable {
* 名录有效期
*/
@ExcelProperty("名录有效期")
private String directoryValidity;
private LocalDateTime directoryValidity;
/**
* 资质内容
......
package com.yonde.dcs.plan.core.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
* @author weihongda
* @date 2024/09/23
*/
@Configuration
@EnableAsync
public class ExecutorPoolConfig {
@Bean("customThreadPool")
public Executor customThreadPool() {
return createExecutor("CustomThreadPool-");
}
/*@Bean("refreshThreadPool")
public ThreadPoolTaskExecutor refreshThreadPool() {
return createExecutor("refreshing-");
}*/
private ThreadPoolTaskExecutor createExecutor(String threadNamePrefix) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(20);
executor.setQueueCapacity(1000);
executor.setThreadNamePrefix(threadNamePrefix);
executor.initialize();
return executor;
}
}
package com.yonde.dcs.plan.core.scheduled;
import com.yonde.dcs.plan.core.service.ExtSupplierManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @author weihongda
* @Date 2024/9/23 17:21
* @Description: 供应商定时任务
*/
@Component
@Slf4j
public class ChangeSupplierStatus {
@Autowired
private ExtSupplierManageService extSupplierManageService;
@Scheduled(cron = "0 0 0 * * ? ")
@Async("customThreadPool")
public void changeStatus() {
log.info("定时执行更新供应商过期状态开始===========");
long begin = System.currentTimeMillis();
extSupplierManageService.changeStatus();
long end = System.currentTimeMillis();
log.info("定时执行更新供应商过期状态结束,共耗时:[" + (end - begin) / 1000 + "]秒");
}
}
......@@ -23,4 +23,6 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends
List<SupplierEarlyWarningVO> exportEarlyWarningData(SearchQueryCondition searchQueryCondition, int warningDay);
void generateSupplierNumber(ExtSupplierManageVO extSupplierManageVO);
void changeStatus();
}
......@@ -10,6 +10,7 @@ import com.yonde.dcs.plan.core.service.ExtSupplierManageLinkService;
import com.yonde.dcs.plan.core.service.ExtSupplierManageService;
import com.yonde.dcs.plan.entity.po.ExtSupplierManage;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basedata.exception.DxBusinessException;
......@@ -46,7 +47,7 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
@Override
public ExtSupplierManageVO startWorkflow(Long id) {
ExtSupplierManageVO extSupplierManageVO= this.get(id);
ExtSupplierManageVO extSupplierManageVO = this.get(id);
if (extSupplierManageVO == null) {
throw new DxBusinessException("500", "获取不到对象");
}
......@@ -115,6 +116,23 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
this.saveRecursion((V) extSupplierManageVO);
log.info("generateEncode.supplierNumber={}", supplierNumber);
}
@Override
public void changeStatus() {
LocalDateTime localDateTime = LocalDate.now().atStartOfDay();
SearchQueryCondition condition = SearchQueryCondition.builder()
.searchItems(SearchItems.builder()
.item(new SearchItem("state", SearchItem.Operator.EQ, "release", null))
.item(new SearchItem("directoryValidity", SearchItem.Operator.GT, localDateTime, null))
.build())
.build();
List<ExtSupplierManageVO> content = (List<ExtSupplierManageVO>) this.findRecursion(condition).getContent();
log.info("changeStatus.条数:{}", content.size());
for (ExtSupplierManageVO extSupplierManageVO : content) {
Long id = extSupplierManageVO.getId();
this.changeStatus(id, "Expired", true);
}
}
}
......@@ -76,7 +76,7 @@ public class ExtSupplierManage extends IdOnlyEntity implements DxObjFileLinkHold
/**
* 名录有效期
*/
private String directoryValidity;
private LocalDateTime directoryValidity;
/**
* 文档的id
*/
......
......@@ -6,6 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@ComponentScan(
basePackages = {"com.yonde"}
......@@ -20,6 +22,8 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
feignReplaceBasePackages = {"com.yonde"},
entityCollectorBasePackages = {"com.yonde"}
)
@EnableScheduling
@EnableAsync
public class ServerApplication {
public static void main(String[] args) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment