opt:优化代码
This commit is contained in:
@@ -8,14 +8,19 @@ import lombok.SneakyThrows;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.b_lms.sch.task.dao.SchBaseTask;
|
import org.nl.b_lms.sch.task.dao.SchBaseTask;
|
||||||
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
||||||
|
import org.nl.b_lms.sch.tasks.first_floor_area.auto.AutoSendToZxq;
|
||||||
import org.nl.modules.wql.WQL;
|
import org.nl.modules.wql.WQL;
|
||||||
import org.nl.wms.sch.tasks.InCoolIvtTask;
|
import org.nl.wms.sch.tasks.InCoolIvtTask;
|
||||||
import org.nl.wms.sch.tasks.InHotTask;
|
import org.nl.wms.sch.tasks.InHotTask;
|
||||||
|
import org.redisson.api.RLock;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: lyd
|
* @Author: lyd
|
||||||
@@ -24,13 +29,19 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class AutoIntoHotCacheTask {
|
public class AutoIntoHotCacheTask {
|
||||||
|
private final String THIS_CLASS = AutoIntoHotCacheTask.class.getName();
|
||||||
@Autowired
|
@Autowired
|
||||||
private IschBaseTaskService taskService;
|
private IschBaseTaskService taskService;
|
||||||
|
@Autowired
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("定时对B1入暂存....");
|
log.info("定时对B1入暂存....");
|
||||||
|
RLock lock = redissonClient.getLock(THIS_CLASS);
|
||||||
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||||
|
try {
|
||||||
|
if (tryLock) {
|
||||||
List<SchBaseTask> tasks = taskService.list(new LambdaQueryWrapper<SchBaseTask>()
|
List<SchBaseTask> tasks = taskService.list(new LambdaQueryWrapper<SchBaseTask>()
|
||||||
.eq(SchBaseTask::getTask_type, "010206")
|
.eq(SchBaseTask::getTask_type, "010206")
|
||||||
.eq(SchBaseTask::getIs_delete, "0")
|
.eq(SchBaseTask::getIs_delete, "0")
|
||||||
@@ -43,13 +54,23 @@ public class AutoIntoHotCacheTask {
|
|||||||
log.info("烘箱对接位:{} 没找到暂存位!", task.getPoint_code1());
|
log.info("烘箱对接位:{} 没找到暂存位!", task.getPoint_code1());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
new InHotTask().immediateNotifyAcs(task.getTask_id());
|
||||||
|
|
||||||
task.setTask_status(TaskStatusEnum.START_AND_POINT.getCode());
|
task.setTask_status(TaskStatusEnum.START_AND_POINT.getCode());
|
||||||
task.setPoint_code2(cache_jo.getString("point_code"));
|
task.setPoint_code2(cache_jo.getString("point_code"));
|
||||||
task.setRemark("-");
|
task.setRemark("-");
|
||||||
task.setUpdate_time(DateUtil.now());
|
task.setUpdate_time(DateUtil.now());
|
||||||
task.setTask_type("010204");
|
task.setTask_type("010204");
|
||||||
taskService.updateById(task);
|
taskService.updateById(task);
|
||||||
new InHotTask().immediateNotifyAcs(task.getTask_id());
|
}
|
||||||
|
} else {
|
||||||
|
log.info("定时对B1入暂存任务被锁住。");
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||||
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user