无码库定时维护
parent
a84a8fdb2f
commit
837060c28d
@ -0,0 +1,102 @@
|
|||||||
|
package com.glxp.api.task;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.glxp.api.dao.basic.BasicProductsDao;
|
||||||
|
import com.glxp.api.dao.basic.UdiRelevanceDao;
|
||||||
|
import com.glxp.api.dao.basic.YbNotCodeMapper;
|
||||||
|
import com.glxp.api.dao.schedule.ScheduledDao;
|
||||||
|
import com.glxp.api.dao.system.ThrYbSetupMapper;
|
||||||
|
import com.glxp.api.entity.basic.BasicProductsEntity;
|
||||||
|
import com.glxp.api.entity.basic.UdiRelevanceEntity;
|
||||||
|
import com.glxp.api.entity.basic.YbNotCode;
|
||||||
|
import com.glxp.api.entity.system.ScheduledEntity;
|
||||||
|
import com.glxp.api.entity.system.ThrYbSetup;
|
||||||
|
import com.glxp.api.req.system.ScheduledRequest;
|
||||||
|
import com.glxp.api.service.purchase.impl.PurPlanDetailService;
|
||||||
|
import com.glxp.api.service.thrsys.ThrInvOrderService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||||
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
|
import org.springframework.scheduling.support.CronTrigger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@EnableScheduling
|
||||||
|
@Slf4j
|
||||||
|
public class NotCodeTask implements SchedulingConfigurer {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ScheduledDao scheduledDao;
|
||||||
|
@Resource
|
||||||
|
private UdiRelevanceDao udiRelevanceDao;
|
||||||
|
@Resource
|
||||||
|
private YbNotCodeMapper ybNotCodeMapper;
|
||||||
|
@Resource
|
||||||
|
private ThrYbSetupMapper thrYbSetupMapper;
|
||||||
|
@Override
|
||||||
|
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
|
||||||
|
scheduledTaskRegistrar.addTriggerTask(() -> process(),
|
||||||
|
triggerContext -> {
|
||||||
|
ScheduledRequest scheduledRequest = new ScheduledRequest();
|
||||||
|
scheduledRequest.setCronName("notCodeTask");
|
||||||
|
log.info("notCodeTask----------------");
|
||||||
|
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
|
||||||
|
String cron = scheduledEntity != null ? scheduledEntity.getCron() : "0 0 5 * * ?";
|
||||||
|
|
||||||
|
if (cron.isEmpty()) {
|
||||||
|
log.error("cron is null");
|
||||||
|
}
|
||||||
|
return new CronTrigger(cron).nextExecutionTime(triggerContext);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void process() {
|
||||||
|
List<UdiRelevanceEntity> list = udiRelevanceDao.selectList(
|
||||||
|
new QueryWrapper<UdiRelevanceEntity>()
|
||||||
|
.isNotNull("notCodeType")
|
||||||
|
.ne("notCodeType","0")
|
||||||
|
);
|
||||||
|
if(list!=null && list.size() >0){
|
||||||
|
ThrYbSetup thrYbSetup = thrYbSetupMapper.selectOne(
|
||||||
|
new QueryWrapper<ThrYbSetup>()
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
String appId = "";
|
||||||
|
if(thrYbSetup!=null && StringUtils.isNotEmpty(thrYbSetup.getAppId())){
|
||||||
|
appId = thrYbSetup.getAppId();
|
||||||
|
|
||||||
|
}
|
||||||
|
for (UdiRelevanceEntity udiRelevanceEntity : list) {
|
||||||
|
try {
|
||||||
|
YbNotCode ybNotCode = ybNotCodeMapper.selectOne(
|
||||||
|
new QueryWrapper<YbNotCode>()
|
||||||
|
.eq("ybbm",udiRelevanceEntity.getMainId())
|
||||||
|
);
|
||||||
|
if(ybNotCode != null && ybNotCode.getNotCodeType() != udiRelevanceEntity.getNotCodeType()){
|
||||||
|
YbNotCode ybNotCodeNew = new YbNotCode();
|
||||||
|
ybNotCodeNew.setNotCodeType(udiRelevanceEntity.getNotCodeType());
|
||||||
|
ybNotCodeNew.setOrganizationCode(appId);
|
||||||
|
ybNotCodeMapper.updateById( ybNotCodeNew);
|
||||||
|
}else {
|
||||||
|
YbNotCode ybNotCodeNew = new YbNotCode();
|
||||||
|
ybNotCodeNew.setNotCodeType(udiRelevanceEntity.getNotCodeType());
|
||||||
|
ybNotCodeNew.setYbbm(udiRelevanceEntity.getMainId());
|
||||||
|
ybNotCodeNew.setOrganizationCode(appId);
|
||||||
|
ybNotCodeMapper.insert(ybNotCodeNew);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue