code生成修改
This commit is contained in:
parent
25178732f8
commit
3ad3c5cfd8
@ -98,7 +98,7 @@ public class RunTask extends Model<RunTask> {
|
||||
* 车辆id,关联车辆表:t_vehicle_info
|
||||
*/
|
||||
@TableField("vehicle_id")
|
||||
private Integer vehicleId;
|
||||
private Long vehicleId;
|
||||
|
||||
/**
|
||||
* 任务开始时间,车辆接收任务时间
|
||||
|
@ -5,10 +5,9 @@ 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;
|
||||
|
||||
@ -23,6 +22,7 @@ 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,47 +35,54 @@ public class AsynRunTaskService extends BaseService {
|
||||
|
||||
//窑炉可用未满的情况下,调用车辆起点为提升台终点为窑炉
|
||||
@Async("asyncServiceExecutor")
|
||||
public void asynRunTask(CurrTask currTask){
|
||||
public void asynRunTask(Long currTaskId,Long vehicleId){
|
||||
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
|
||||
//新建一条执行任务的关系表存放任务执行信息
|
||||
RunTask runTask=new RunTask();
|
||||
runTask.setTaskId(currTask.getId());
|
||||
// TODO: 2021/12/13 currTask code、车辆id、开始执行时间
|
||||
|
||||
runTask.setTaskCode(currTask.getTaskCode());
|
||||
runTask.setVehicleId(vehicleId);
|
||||
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表状态
|
||||
// TODO: 2021/12/13 is_in 改为 1、runTaskId、起终点
|
||||
currTask.setIsIn(1);
|
||||
currTask.setRunTaskId(runTask.getId());
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
}else {
|
||||
// TODO: 2021/12/13 车辆执行不成功,记录日志,推送消息到前端提醒?
|
||||
runTask.setStatus(3);
|
||||
runTask.setUpdateTime(LocalDateTime.now());
|
||||
runTaskServiceBiz.updateById(runTask);
|
||||
logger.info("任务 "+currTask.getTaskCode()+" 车辆从提升平台到窑炉过程中失败。");
|
||||
// TODO: 2021/12/14 websocket推送到前端
|
||||
}
|
||||
}
|
||||
//窑炉已满,调用车辆起点为提升台,终点为缓存区
|
||||
@Async("asyncServiceExecutor")
|
||||
public void asynRunTaskToWarehouse(CurrTask currTask){
|
||||
public void asynRunTaskToWarehouse(Long currTaskId,Long vehicleId){
|
||||
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
|
||||
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);
|
||||
@ -93,30 +100,37 @@ 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);
|
||||
// TODO: 2021/12/13 结束时间
|
||||
runTask.setEndTime(LocalDateTime.now());
|
||||
runTaskServiceBiz.updateById(runTask);
|
||||
//更新currTask表
|
||||
// TODO: 2021/12/13 is_cache 、runTaskId
|
||||
currTask.setCacheSatatus(2);
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
//更新in_stock_info表
|
||||
inStockInfo.setStatus(2);
|
||||
inStockInfo.setInTime(LocalDateTime.now());
|
||||
inStockInfoServiceBiz.updateById(inStockInfo);
|
||||
}else {
|
||||
// TODO: 2021/12/13 车辆执行不成功,记录日志,推送消息到前端提醒?
|
||||
runTask.setStatus(3);
|
||||
runTask.setUpdateTime(LocalDateTime.now());
|
||||
runTaskServiceBiz.updateById(runTask);
|
||||
logger.info("任务 "+currTask.getTaskCode()+" 车辆从提升平台到缓存区过程中失败。");
|
||||
// TODO: 2021/12/14 websocket推送到前端
|
||||
}
|
||||
|
||||
// TODO: 2021/12/13 车辆执行执行成功后加入窑炉的缓存区任务队列
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,6 @@ 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)
|
||||
@ -62,9 +58,12 @@ public class RunTaskUtils {
|
||||
}else {
|
||||
return R.failed("暂无可用车辆!请稍后重试!");
|
||||
}
|
||||
//更改任务状态为执行中
|
||||
currTask.setStatus(1);
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
//异步调用车辆
|
||||
// TODO: 2021/12/13 传入车辆id
|
||||
asynRunTaskService.asynRunTask(currTask);
|
||||
asynRunTaskService.asynRunTask(currTask.getId(),vehicleInfoList.get(0).getId());
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
//窑炉已满
|
||||
@ -87,13 +86,13 @@ public class RunTaskUtils {
|
||||
}else {
|
||||
return R.failed("暂无可用车辆!请稍后重试!");
|
||||
}
|
||||
// TODO: 2021/12/13 更改 is_cache 、库位id、库位名称
|
||||
currTask.setIsCache(1);
|
||||
currTask.setCacheSatatus(1);
|
||||
currTask.setUpdateTime(LocalDateTime.now());
|
||||
currTaskServiceBiz.updateById(currTask);
|
||||
|
||||
//异步调用车辆
|
||||
// TODO: 2021/12/13 传入车辆id
|
||||
asynRunTaskService.asynRunTaskToWarehouse(currTask);
|
||||
asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId());
|
||||
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