Compare commits
No commits in common. "be40d7ede1292e4fd2ec871f3dd2be0b28abf015" and "336bc29ddc5ce5f98eede28fa3a747af82b9e1cd" have entirely different histories.
be40d7ede1
...
336bc29ddc
@ -98,7 +98,7 @@ public class RunTask extends Model<RunTask> {
|
||||
* 车辆id,关联车辆表:t_vehicle_info
|
||||
*/
|
||||
@TableField("vehicle_id")
|
||||
private Long vehicleId;
|
||||
private Integer vehicleId;
|
||||
|
||||
/**
|
||||
* 任务开始时间,车辆接收任务时间
|
||||
|
@ -5,9 +5,10 @@ import com.mt.wms.core.base.BaseService;
|
||||
import com.mt.wms.core.dal.entity.*;
|
||||
import com.mt.wms.core.dal.service.*;
|
||||
import com.mt.wms.core.utils.IDGenerator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -22,7 +23,6 @@ import java.time.LocalDateTime;
|
||||
@Service
|
||||
@Transactional
|
||||
public class AsynRunTaskService extends BaseService {
|
||||
private final static Logger logger = LoggerFactory.getLogger(AsynRunTaskService.class);
|
||||
|
||||
@Resource
|
||||
private CurrTaskServiceBiz currTaskServiceBiz;
|
||||
@ -35,54 +35,47 @@ public class AsynRunTaskService extends BaseService {
|
||||
|
||||
//窑炉可用未满的情况下,调用车辆起点为提升台终点为窑炉
|
||||
@Async("asyncServiceExecutor")
|
||||
public void asynRunTask(Long currTaskId,Long vehicleId){
|
||||
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
|
||||
public void asynRunTask(CurrTask currTask){
|
||||
//新建一条执行任务的关系表存放任务执行信息
|
||||
RunTask runTask=new RunTask();
|
||||
runTask.setTaskId(currTask.getId());
|
||||
runTask.setTaskCode(currTask.getTaskCode());
|
||||
runTask.setVehicleId(vehicleId);
|
||||
// TODO: 2021/12/13 currTask code、车辆id、开始执行时间
|
||||
|
||||
runTask.setStartPosition(currTask.getStartPosition());
|
||||
runTask.setEndPosition(currTask.getTargetPosition());
|
||||
setCommonField(runTask);
|
||||
runTask.setBeginTime(LocalDateTime.now());
|
||||
runTaskServiceBiz.save(runTask);
|
||||
// TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果
|
||||
//调用车辆填入起终点
|
||||
|
||||
//执行成功,托盘进炉
|
||||
//得到车辆执行结果
|
||||
|
||||
|
||||
//执行成功,托盘进炉(存疑,进入窑炉不算任务完成的话,窑炉怎么给出是哪条任务加工完成了)
|
||||
if (true){
|
||||
//更新调度表状态为完成
|
||||
//更新关系表状态为完成
|
||||
runTask.setUpdateTime(LocalDateTime.now());
|
||||
runTask.setEndTime(LocalDateTime.now());
|
||||
runTask.setStatus(2);
|
||||
// TODO: 2021/12/13 结束时间
|
||||
runTaskServiceBiz.updateById(runTask);
|
||||
//更新currTask表状态
|
||||
currTask.setIsIn(1);
|
||||
currTask.setRunTaskId(runTask.getId());
|
||||
// TODO: 2021/12/13 is_in 改为 1、runTaskId、起终点
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
}else {
|
||||
runTask.setStatus(3);
|
||||
runTask.setUpdateTime(LocalDateTime.now());
|
||||
runTaskServiceBiz.updateById(runTask);
|
||||
logger.info("任务 "+currTask.getTaskCode()+" 车辆从提升平台到窑炉过程中失败。");
|
||||
// TODO: 2021/12/14 websocket推送到前端
|
||||
// TODO: 2021/12/13 车辆执行不成功,记录日志,推送消息到前端提醒?
|
||||
}
|
||||
}
|
||||
//窑炉已满,调用车辆起点为提升台,终点为缓存区
|
||||
@Async("asyncServiceExecutor")
|
||||
public void asynRunTaskToWarehouse(Long currTaskId,Long vehicleId){
|
||||
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
|
||||
public void asynRunTaskToWarehouse(CurrTask currTask){
|
||||
Location location = locationServiceBiz.list(new QueryWrapper<Location>()
|
||||
.eq(Location.STATUS, 1)
|
||||
.eq(Location.VALID, 1)).get(0);
|
||||
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
|
||||
RunTask runTask=new RunTask();
|
||||
setCommonField(runTask);
|
||||
// TODO: 2021/12/13 currTask code、车辆id、开始执行时间
|
||||
runTask.setTaskId(currTask.getId());
|
||||
runTask.setTaskCode(currTask.getTaskCode());
|
||||
runTask.setVehicleId(vehicleId);
|
||||
runTask.setBeginTime(LocalDateTime.now());
|
||||
runTask.setStartPosition(currTask.getStartPosition());
|
||||
runTask.setEndPosition(location.getCode());
|
||||
runTaskServiceBiz.save(runTask);
|
||||
@ -100,37 +93,30 @@ public class AsynRunTaskService extends BaseService {
|
||||
inStockInfo.setKilnName(currTask.getKilnName());
|
||||
inStockInfo.setLocationId(location.getId());
|
||||
inStockInfo.setLocationName(location.getLocationNameAlias());
|
||||
inStockInfo.setType(1);
|
||||
setCommonField(inStockInfo);
|
||||
inStockInfoServiceBiz.save(inStockInfo);
|
||||
//修改currTask的是否缓存,库位id,库位名称
|
||||
currTask.setIsCache(1);
|
||||
currTask.setCacheRunTaskId(runTask.getId());
|
||||
currTask.setLocationId(location.getId());
|
||||
currTask.setLocationName(location.getLocationNameAlias());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
// TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果
|
||||
//调用车辆
|
||||
|
||||
if (true){
|
||||
//更新关系表状态为完成
|
||||
runTask.setUpdateTime(LocalDateTime.now());
|
||||
runTask.setStatus(2);
|
||||
runTask.setEndTime(LocalDateTime.now());
|
||||
// TODO: 2021/12/13 结束时间
|
||||
runTaskServiceBiz.updateById(runTask);
|
||||
//更新currTask表
|
||||
currTask.setCacheSatatus(2);
|
||||
// TODO: 2021/12/13 is_cache 、runTaskId
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
//更新in_stock_info表
|
||||
inStockInfo.setStatus(2);
|
||||
inStockInfo.setInTime(LocalDateTime.now());
|
||||
inStockInfoServiceBiz.updateById(inStockInfo);
|
||||
}else {
|
||||
runTask.setStatus(3);
|
||||
runTask.setUpdateTime(LocalDateTime.now());
|
||||
runTaskServiceBiz.updateById(runTask);
|
||||
logger.info("任务 "+currTask.getTaskCode()+" 车辆从提升平台到缓存区过程中失败。");
|
||||
// TODO: 2021/12/14 websocket推送到前端
|
||||
// TODO: 2021/12/13 车辆执行不成功,记录日志,推送消息到前端提醒?
|
||||
}
|
||||
|
||||
// TODO: 2021/12/13 车辆执行执行成功后加入窑炉的缓存区任务队列
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ public class RunTaskUtils {
|
||||
}
|
||||
//窑炉可用未满
|
||||
if (kilnStatus==1){
|
||||
//更改任务状态为执行中
|
||||
currTask.setStatus(1);
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
//查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆
|
||||
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>()
|
||||
.eq(VehicleInfo.STATUS, 0)
|
||||
@ -58,12 +62,9 @@ public class RunTaskUtils {
|
||||
}else {
|
||||
return R.failed("暂无可用车辆!请稍后重试!");
|
||||
}
|
||||
//更改任务状态为执行中
|
||||
currTask.setStatus(1);
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
//异步调用车辆
|
||||
asynRunTaskService.asynRunTask(currTask.getId(),vehicleInfoList.get(0).getId());
|
||||
// TODO: 2021/12/13 传入车辆id
|
||||
asynRunTaskService.asynRunTask(currTask);
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
//窑炉已满
|
||||
@ -86,13 +87,13 @@ public class RunTaskUtils {
|
||||
}else {
|
||||
return R.failed("暂无可用车辆!请稍后重试!");
|
||||
}
|
||||
currTask.setIsCache(1);
|
||||
currTask.setCacheSatatus(1);
|
||||
// TODO: 2021/12/13 更改 is_cache 、库位id、库位名称
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
|
||||
//异步调用车辆
|
||||
asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId());
|
||||
// TODO: 2021/12/13 传入车辆id
|
||||
asynRunTaskService.asynRunTaskToWarehouse(currTask);
|
||||
return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。");
|
||||
}
|
||||
return R.failed("当前目标窑炉已满!缓存区已满!请稍后重试!");
|
||||
|
@ -10,7 +10,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
||||
public class ScheduledTask {
|
||||
|
||||
/**
|
||||
* 查询加工完成的窑炉
|
||||
* 查询缓存区队列中待加工的
|
||||
*/
|
||||
@Scheduled
|
||||
public void taskForStockToKiln(){
|
||||
|
Loading…
Reference in New Issue
Block a user