You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
3.5 KiB
Java
77 lines
3.5 KiB
Java
3 years ago
|
package com.glxp.udi.admin.thread;
|
||
|
|
||
|
import cn.hutool.core.collection.CollUtil;
|
||
|
import com.glxp.udi.admin.constant.ConstantStatus;
|
||
|
import com.glxp.udi.admin.constant.SystemParamConstant;
|
||
|
import com.glxp.udi.admin.dao.info.ScheduledDao;
|
||
|
import com.glxp.udi.admin.entity.info.ScheduledEntity;
|
||
|
import com.glxp.udi.admin.entity.inout.OrderMdEntity;
|
||
|
import com.glxp.udi.admin.entity.param.SystemParamConfigEntity;
|
||
|
import com.glxp.udi.admin.mongo.service.OrderMdService;
|
||
|
import com.glxp.udi.admin.req.inout.OrderFilterRequest;
|
||
|
import com.glxp.udi.admin.req.udidl.ScheduledRequest;
|
||
|
import com.glxp.udi.admin.service.param.SystemParamConfigService;
|
||
|
import com.glxp.udi.admin.service.param.SystemParamCustomerConfigService;
|
||
|
import lombok.extern.slf4j.Slf4j;
|
||
|
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;
|
||
|
|
||
|
@Slf4j
|
||
|
@Component
|
||
|
@EnableScheduling
|
||
|
public class TransInoutTask implements SchedulingConfigurer {
|
||
|
|
||
|
@Resource
|
||
|
private TransInoutService transInoutService;
|
||
|
@Resource
|
||
|
private SystemParamConfigService systemParamConfigService;
|
||
|
@Resource
|
||
|
private SystemParamCustomerConfigService systemParamCustomerConfigService;
|
||
|
@Resource
|
||
|
private OrderMdService orderMdService;
|
||
|
@Resource
|
||
|
protected ScheduledDao scheduledDao;
|
||
|
|
||
|
@Override
|
||
|
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
|
||
|
scheduledTaskRegistrar.addTriggerTask(this::process,
|
||
|
triggerContext -> {
|
||
|
ScheduledRequest scheduledRequest = new ScheduledRequest();
|
||
|
scheduledRequest.setCronName("transInout");
|
||
|
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
|
||
|
String cron = scheduledEntity.getCron();
|
||
|
if (cron.isEmpty()) {
|
||
|
log.error("cron is null");
|
||
|
}
|
||
|
return new CronTrigger(cron).nextExecutionTime(triggerContext);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
private void process() {
|
||
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey(SystemParamConstant.IO_TRANSINOUT_INTERVAL);
|
||
|
if (!"0".equals(systemParamConfigEntity.getParamValue())) {
|
||
|
log.info("定时重码校验");
|
||
|
//查询待处理单据,判断此单据的用户是否开启了自动处理单据,如果已开启则自动处理,未开启跳过
|
||
|
OrderFilterRequest orderFilterRequest = new OrderFilterRequest();
|
||
|
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_WAIT);
|
||
|
List<OrderMdEntity> list = orderMdService.findAll(orderFilterRequest);
|
||
|
if (CollUtil.isNotEmpty(list)) {
|
||
|
for (OrderMdEntity orderMdEntity : list) {
|
||
|
SystemParamConfigEntity io_transInout_auto = systemParamCustomerConfigService.getParamByKey(SystemParamConstant.IO_TRANSINOUT_AUTO, orderMdEntity.getCustomerId());
|
||
|
if (null != io_transInout_auto && io_transInout_auto.getParamValue().equals("1")) {
|
||
|
//此单可以自动提交
|
||
|
transInoutService.transInout(orderMdEntity);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|