Commit 92a601fc authored by wei's avatar wei 🎱

定时任务

parent d0e1ceaf
package com.yonde.dcs.plan.common.vo; 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 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.fasterxml.jackson.annotation.JsonTypeInfo;
import com.yonde.dex.basedata.entity.xmladapters.LocalDateTimeXmlAdapter; import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import lombok.Data; import com.yonde.dex.basedata.entity.annotation.DexEmbedded;
import com.yonde.dex.basedata.entity.annotation.*; import com.yonde.dex.basedata.entity.annotation.ReferenceProperty;
import lombok.AllArgsConstructor; import com.yonde.dex.basedata.entity.annotation.RelationProperty;
import lombok.NoArgsConstructor; import com.yonde.dex.basedata.entity.annotation.VersionProperty;
import com.yonde.dex.basedata.entity.vo.IdOnlyVO;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import com.yonde.dex.basedata.entity.data.VersionRelationType; import com.yonde.dex.basedata.entity.data.VersionRelationType;
import com.yonde.dex.basedata.entity.vo.DxIdVOEmbeddable; 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.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.lcycle.plugin.common.entity.DxLifecycleManageBaseVOEmbeddable;
import com.yonde.dex.logicdelete.plugin.common.entity.DxLogicDeleteVOHolder; import com.yonde.dex.lcycle.plugin.common.entity.DxLifecycleManageBaseVOHolder;
import com.yonde.dcs.plan.common.vo.ExtSupplierManageLinkVO;
import com.yonde.dex.logicdelete.plugin.common.entity.DxLogicDeleteVOEmbeddable; 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.dex.secretcode.plugin.common.entity.DxSecretVOEmbeddable;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO; import com.yonde.dex.secretcode.plugin.common.entity.DxSecretVOHolder;
import com.yonde.dex.dfs.objfilelink.plugin.common.entity.DxObjFileLinkVOEmbeddable; import com.yonde.dex.version.plugin.common.entity.DxIterationVOEmbeddable;
import com.yonde.dex.version.plugin.common.entity.DxIterationVOHolder; 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 * @description: ExtSupplierManage-VO
* @author: dexadmin * @author: dexadmin
* @version: V * @version: V
* @date: 2024-9-19 11:25:51 * @date: 2024-9-19 11:25:51
**/ **/
@JsonTypeInfo( use = JsonTypeInfo.Id.CLASS, property = "dxClassname", visible = true, defaultImpl = ExtSupplierManageVO.class) @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "dxClassname", visible = true, defaultImpl = ExtSupplierManageVO.class)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
@ToString(callSuper = true) @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_OBJ_FILE_LINK_EMBEDDABLE_PROP_NAME = "dxObjFileLinkEmbeddable";
public static final String DX_LIFECYCLE_MANAGE_BASE_EMBEDDABLE_PROP_NAME = "dxLifecycleManageBaseEmbeddable"; public static final String DX_LIFECYCLE_MANAGE_BASE_EMBEDDABLE_PROP_NAME = "dxLifecycleManageBaseEmbeddable";
...@@ -83,142 +65,142 @@ public class ExtSupplierManageVO extends IdOnlyVO implements DxIterationVOHolder ...@@ -83,142 +65,142 @@ public class ExtSupplierManageVO extends IdOnlyVO implements DxIterationVOHolder
public static final String UNIFIED_SOCIETY_CODE_PROP_NAME = "unifiedSocietyCode"; public static final String UNIFIED_SOCIETY_CODE_PROP_NAME = "unifiedSocietyCode";
/** /**
* 扩展VO属性 * 扩展VO属性
*/ */
@DexEmbedded() @DexEmbedded()
@JsonIgnore @JsonIgnore
private DxObjFileLinkVOEmbeddable dxObjFileLinkEmbeddable; private DxObjFileLinkVOEmbeddable dxObjFileLinkEmbeddable;
/** /**
* 扩展VO属性 * 扩展VO属性
*/ */
@DexEmbedded() @DexEmbedded()
@JsonIgnore @JsonIgnore
private DxLifecycleManageBaseVOEmbeddable dxLifecycleManageBaseEmbeddable; private DxLifecycleManageBaseVOEmbeddable dxLifecycleManageBaseEmbeddable;
/** /**
* dao扩展对象 * dao扩展对象
*/ */
@DexEmbedded() @DexEmbedded()
@JsonIgnore @JsonIgnore
private DxIdVOEmbeddable dxIdEmbeddable; private DxIdVOEmbeddable dxIdEmbeddable;
/** /**
* 扩展VO属性 * 扩展VO属性
*/ */
@DexEmbedded() @DexEmbedded()
@JsonIgnore @JsonIgnore
private DxLogicDeleteVOEmbeddable dxLogicDeleteEmbeddable; private DxLogicDeleteVOEmbeddable dxLogicDeleteEmbeddable;
/** /**
* 扩展VO属性 * 扩展VO属性
*/ */
@DexEmbedded() @DexEmbedded()
@JsonIgnore @JsonIgnore
private DxIterationVOEmbeddable<ExtSupplierManageVO> dxIterationEmbeddable; private DxIterationVOEmbeddable<ExtSupplierManageVO> dxIterationEmbeddable;
/** /**
* 扩展VO属性 * 扩展VO属性
*/ */
@DexEmbedded() @DexEmbedded()
@JsonIgnore @JsonIgnore
private DxSecretVOEmbeddable dxSecretEmbeddable; private DxSecretVOEmbeddable dxSecretEmbeddable;
/** /**
* 名录有效期 * 名录有效期
*/ */
private String directoryValidity; private LocalDateTime directoryValidity;
/** /**
* 文档 * 文档
*/ */
@ReferenceProperty(baseProperty = "extCqmId") @ReferenceProperty(baseProperty = "extCqmId")
@VersionProperty(curVersion = VersionRelationType.ITERATION, refVersion = VersionRelationType.ITERATION) @VersionProperty(curVersion = VersionRelationType.ITERATION, refVersion = VersionRelationType.ITERATION)
private DxDocumentVO extCqm; private DxDocumentVO extCqm;
/** /**
* 文档 * 文档
*/ */
private Long extCqmId; private Long extCqmId;
/** /**
* 文档 * 文档
*/ */
private String extCqmIdType; private String extCqmIdType;
/** /**
* 文档 * 文档
*/ */
@ReferenceProperty(baseProperty = "extOtherId") @ReferenceProperty(baseProperty = "extOtherId")
@VersionProperty(curVersion = VersionRelationType.ITERATION, refVersion = VersionRelationType.ITERATION) @VersionProperty(curVersion = VersionRelationType.ITERATION, refVersion = VersionRelationType.ITERATION)
private DxDocumentVO extOther; private DxDocumentVO extOther;
/** /**
* 文档 * 文档
*/ */
private Long extOtherId; private Long extOtherId;
/** /**
* 文档 * 文档
*/ */
private String extOtherIdType; private String extOtherIdType;
/** /**
* 文档 * 文档
*/ */
@ReferenceProperty(baseProperty = "extPotentialId") @ReferenceProperty(baseProperty = "extPotentialId")
@VersionProperty(curVersion = VersionRelationType.ITERATION, refVersion = VersionRelationType.ITERATION) @VersionProperty(curVersion = VersionRelationType.ITERATION, refVersion = VersionRelationType.ITERATION)
private DxDocumentVO extPotential; private DxDocumentVO extPotential;
/** /**
* 文档 * 文档
*/ */
private Long extPotentialId; private Long extPotentialId;
/** /**
* 文档 * 文档
*/ */
private String extPotentialIdType; private String extPotentialIdType;
/** /**
* ExtSupplierManageLink集合 * ExtSupplierManageLink集合
*/ */
@RelationProperty(refProperty = "source") @RelationProperty(refProperty = "source")
@VersionProperty(curVersion = VersionRelationType.ITERATION, refVersion = VersionRelationType.NONE) @VersionProperty(curVersion = VersionRelationType.ITERATION, refVersion = VersionRelationType.NONE)
private List<ExtSupplierManageLinkVO> extSupplierManageLinks; private List<ExtSupplierManageLinkVO> extSupplierManageLinks;
/** /**
* 经营类别 * 经营类别
*/ */
private String operateType; private String operateType;
/** /**
* 注册资金 * 注册资金
*/ */
private String registrationFund; private String registrationFund;
/** /**
* 注册时间 * 注册时间
*/ */
private LocalDateTime registrationTime; private LocalDateTime registrationTime;
/** /**
* 供方地址 * 供方地址
*/ */
private String supplierAddress; private String supplierAddress;
/** /**
* 供方类别 * 供方类别
*/ */
private String supplierType; private String supplierType;
/** /**
* 统一社会信用引用代码 * 统一社会信用引用代码
*/ */
private String unifiedSocietyCode; private String unifiedSocietyCode;
/** /**
* supplierNumber * 供方编码
*/ */
private String supplierNumber; private String supplierNumber;
} }
......
...@@ -74,7 +74,7 @@ public class SupplierEarlyWarningVO implements Serializable { ...@@ -74,7 +74,7 @@ public class SupplierEarlyWarningVO implements Serializable {
* 名录有效期 * 名录有效期
*/ */
@ExcelProperty("名录有效期") @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 ...@@ -23,4 +23,6 @@ public interface ExtSupplierManageService<V extends ExtSupplierManageVO> extends
List<SupplierEarlyWarningVO> exportEarlyWarningData(SearchQueryCondition searchQueryCondition, int warningDay); List<SupplierEarlyWarningVO> exportEarlyWarningData(SearchQueryCondition searchQueryCondition, int warningDay);
void generateSupplierNumber(ExtSupplierManageVO extSupplierManageVO); void generateSupplierNumber(ExtSupplierManageVO extSupplierManageVO);
void changeStatus();
} }
...@@ -10,6 +10,7 @@ import com.yonde.dcs.plan.core.service.ExtSupplierManageLinkService; ...@@ -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.core.service.ExtSupplierManageService;
import com.yonde.dcs.plan.entity.po.ExtSupplierManage; import com.yonde.dcs.plan.entity.po.ExtSupplierManage;
import com.yonde.dex.basedata.data.search.SearchItem; 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.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.data.DxPageImpl; import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basedata.exception.DxBusinessException; import com.yonde.dex.basedata.exception.DxBusinessException;
...@@ -46,7 +47,7 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme ...@@ -46,7 +47,7 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
@Override @Override
public ExtSupplierManageVO startWorkflow(Long id) { public ExtSupplierManageVO startWorkflow(Long id) {
ExtSupplierManageVO extSupplierManageVO= this.get(id); ExtSupplierManageVO extSupplierManageVO = this.get(id);
if (extSupplierManageVO == null) { if (extSupplierManageVO == null) {
throw new DxBusinessException("500", "获取不到对象"); throw new DxBusinessException("500", "获取不到对象");
} }
...@@ -115,6 +116,23 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme ...@@ -115,6 +116,23 @@ public class ExtSupplierManageServiceImpl<V extends ExtSupplierManageVO> impleme
this.saveRecursion((V) extSupplierManageVO); this.saveRecursion((V) extSupplierManageVO);
log.info("generateEncode.supplierNumber={}", supplierNumber); 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 ...@@ -76,7 +76,7 @@ public class ExtSupplierManage extends IdOnlyEntity implements DxObjFileLinkHold
/** /**
* 名录有效期 * 名录有效期
*/ */
private String directoryValidity; private LocalDateTime directoryValidity;
/** /**
* 文档的id * 文档的id
*/ */
......
...@@ -6,6 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -6,6 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@ComponentScan( @ComponentScan(
basePackages = {"com.yonde"} basePackages = {"com.yonde"}
...@@ -20,6 +22,8 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing; ...@@ -20,6 +22,8 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
feignReplaceBasePackages = {"com.yonde"}, feignReplaceBasePackages = {"com.yonde"},
entityCollectorBasePackages = {"com.yonde"} entityCollectorBasePackages = {"com.yonde"}
) )
@EnableScheduling
@EnableAsync
public class ServerApplication { public class ServerApplication {
public static void main(String[] args) { 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