code生成修改

This commit is contained in:
李广豪 2021-12-14 18:41:17 +08:00
parent 25178732f8
commit 3ad3c5cfd8
4 changed files with 48 additions and 35 deletions

View File

@ -98,7 +98,7 @@ public class RunTask extends Model<RunTask> {
* 车辆id关联车辆表t_vehicle_info * 车辆id关联车辆表t_vehicle_info
*/ */
@TableField("vehicle_id") @TableField("vehicle_id")
private Integer vehicleId; private Long vehicleId;
/** /**
* 任务开始时间车辆接收任务时间 * 任务开始时间车辆接收任务时间

View File

@ -5,10 +5,9 @@ import com.mt.wms.core.base.BaseService;
import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.entity.*;
import com.mt.wms.core.dal.service.*; import com.mt.wms.core.dal.service.*;
import com.mt.wms.core.utils.IDGenerator; 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.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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -23,6 +22,7 @@ import java.time.LocalDateTime;
@Service @Service
@Transactional @Transactional
public class AsynRunTaskService extends BaseService { public class AsynRunTaskService extends BaseService {
private final static Logger logger = LoggerFactory.getLogger(AsynRunTaskService.class);
@Resource @Resource
private CurrTaskServiceBiz currTaskServiceBiz; private CurrTaskServiceBiz currTaskServiceBiz;
@ -35,47 +35,54 @@ public class AsynRunTaskService extends BaseService {
//窑炉可用未满的情况下调用车辆起点为提升台终点为窑炉 //窑炉可用未满的情况下调用车辆起点为提升台终点为窑炉
@Async("asyncServiceExecutor") @Async("asyncServiceExecutor")
public void asynRunTask(CurrTask currTask){ public void asynRunTask(Long currTaskId,Long vehicleId){
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
//新建一条执行任务的关系表存放任务执行信息 //新建一条执行任务的关系表存放任务执行信息
RunTask runTask=new RunTask(); RunTask runTask=new RunTask();
runTask.setTaskId(currTask.getId()); runTask.setTaskId(currTask.getId());
// TODO: 2021/12/13 currTask code车辆id开始执行时间 runTask.setTaskCode(currTask.getTaskCode());
runTask.setVehicleId(vehicleId);
runTask.setStartPosition(currTask.getStartPosition()); runTask.setStartPosition(currTask.getStartPosition());
runTask.setEndPosition(currTask.getTargetPosition()); runTask.setEndPosition(currTask.getTargetPosition());
setCommonField(runTask); setCommonField(runTask);
runTask.setBeginTime(LocalDateTime.now());
runTaskServiceBiz.save(runTask); runTaskServiceBiz.save(runTask);
//调用车辆填入起终点 // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果
//得到车辆执行结果 //执行成功,托盘进炉
//执行成功,托盘进炉(存疑进入窑炉不算任务完成的话窑炉怎么给出是哪条任务加工完成了)
if (true){ if (true){
//更新关系表状态为完成 //更新调度表状态为完成
runTask.setUpdateTime(LocalDateTime.now()); runTask.setUpdateTime(LocalDateTime.now());
runTask.setEndTime(LocalDateTime.now());
runTask.setStatus(2); runTask.setStatus(2);
// TODO: 2021/12/13 结束时间
runTaskServiceBiz.updateById(runTask); runTaskServiceBiz.updateById(runTask);
//更新currTask表状态 //更新currTask表状态
// TODO: 2021/12/13 is_in 改为 1runTaskId起终点 currTask.setIsIn(1);
currTask.setRunTaskId(runTask.getId());
currTask.setUpdateTime(LocalDateTime.now()); currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask); currTaskServiceBiz.updateById(currTask);
}else { }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") @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>() Location location = locationServiceBiz.list(new QueryWrapper<Location>()
.eq(Location.STATUS, 1) .eq(Location.STATUS, 1)
.eq(Location.VALID, 1)).get(0); .eq(Location.VALID, 1)).get(0);
//新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
RunTask runTask=new RunTask(); RunTask runTask=new RunTask();
setCommonField(runTask); setCommonField(runTask);
// TODO: 2021/12/13 currTask code车辆id开始执行时间
runTask.setTaskId(currTask.getId()); runTask.setTaskId(currTask.getId());
runTask.setTaskCode(currTask.getTaskCode());
runTask.setVehicleId(vehicleId);
runTask.setBeginTime(LocalDateTime.now());
runTask.setStartPosition(currTask.getStartPosition()); runTask.setStartPosition(currTask.getStartPosition());
runTask.setEndPosition(location.getCode()); runTask.setEndPosition(location.getCode());
runTaskServiceBiz.save(runTask); runTaskServiceBiz.save(runTask);
@ -93,30 +100,37 @@ public class AsynRunTaskService extends BaseService {
inStockInfo.setKilnName(currTask.getKilnName()); inStockInfo.setKilnName(currTask.getKilnName());
inStockInfo.setLocationId(location.getId()); inStockInfo.setLocationId(location.getId());
inStockInfo.setLocationName(location.getLocationNameAlias()); inStockInfo.setLocationName(location.getLocationNameAlias());
inStockInfo.setType(1);
setCommonField(inStockInfo); setCommonField(inStockInfo);
inStockInfoServiceBiz.save(inStockInfo); inStockInfoServiceBiz.save(inStockInfo);
//修改currTask的是否缓存,库位id,库位名称 //修改currTask的是否缓存,库位id,库位名称
currTask.setIsCache(1); currTask.setIsCache(1);
currTask.setCacheRunTaskId(runTask.getId());
currTask.setLocationId(location.getId()); currTask.setLocationId(location.getId());
currTask.setLocationName(location.getLocationNameAlias()); currTask.setLocationName(location.getLocationNameAlias());
currTaskServiceBiz.updateById(currTask); currTaskServiceBiz.updateById(currTask);
//调用车辆 // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果
if (true){ if (true){
//更新关系表状态为完成 //更新关系表状态为完成
runTask.setUpdateTime(LocalDateTime.now()); runTask.setUpdateTime(LocalDateTime.now());
runTask.setStatus(2); runTask.setStatus(2);
// TODO: 2021/12/13 结束时间 runTask.setEndTime(LocalDateTime.now());
runTaskServiceBiz.updateById(runTask); runTaskServiceBiz.updateById(runTask);
//更新currTask表 //更新currTask表
// TODO: 2021/12/13 is_cache runTaskId currTask.setCacheSatatus(2);
currTask.setUpdateTime(LocalDateTime.now()); currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask); currTaskServiceBiz.updateById(currTask);
//更新in_stock_info表
inStockInfo.setStatus(2);
inStockInfo.setInTime(LocalDateTime.now());
inStockInfoServiceBiz.updateById(inStockInfo);
}else { }else {
// TODO: 2021/12/13 车辆执行不成功记录日志推送消息到前端提醒 runTask.setStatus(3);
} runTask.setUpdateTime(LocalDateTime.now());
runTaskServiceBiz.updateById(runTask);
// TODO: 2021/12/13 车辆执行执行成功后加入窑炉的缓存区任务队列 logger.info("任务 "+currTask.getTaskCode()+" 车辆从提升平台到缓存区过程中失败。");
// TODO: 2021/12/14 websocket推送到前端
}
} }
} }

View File

@ -46,10 +46,6 @@ public class RunTaskUtils {
} }
//窑炉可用未满 //窑炉可用未满
if (kilnStatus==1){ if (kilnStatus==1){
//更改任务状态为执行中
currTask.setStatus(1);
currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask);
//查询是否有空闲车辆若有占用车辆若无返回暂无可用车辆 //查询是否有空闲车辆若有占用车辆若无返回暂无可用车辆
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>() List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>()
.eq(VehicleInfo.STATUS, 0) .eq(VehicleInfo.STATUS, 0)
@ -62,9 +58,12 @@ public class RunTaskUtils {
}else { }else {
return R.failed("暂无可用车辆!请稍后重试!"); return R.failed("暂无可用车辆!请稍后重试!");
} }
//更改任务状态为执行中
currTask.setStatus(1);
currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask);
//异步调用车辆 //异步调用车辆
// TODO: 2021/12/13 传入车辆id asynRunTaskService.asynRunTask(currTask.getId(),vehicleInfoList.get(0).getId());
asynRunTaskService.asynRunTask(currTask);
return R.ok("操作成功"); return R.ok("操作成功");
} }
//窑炉已满 //窑炉已满
@ -87,13 +86,13 @@ public class RunTaskUtils {
}else { }else {
return R.failed("暂无可用车辆!请稍后重试!"); return R.failed("暂无可用车辆!请稍后重试!");
} }
// TODO: 2021/12/13 更改 is_cache 库位id库位名称 currTask.setIsCache(1);
currTask.setCacheSatatus(1);
currTask.setUpdateTime(LocalDateTime.now()); currTask.setUpdateTime(LocalDateTime.now());
currTaskServiceBiz.updateById(currTask); currTaskServiceBiz.updateById(currTask);
//异步调用车辆 //异步调用车辆
// TODO: 2021/12/13 传入车辆id asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId());
asynRunTaskService.asynRunTaskToWarehouse(currTask);
return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。"); return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。");
} }
return R.failed("当前目标窑炉已满!缓存区已满!请稍后重试!"); return R.failed("当前目标窑炉已满!缓存区已满!请稍后重试!");

View File

@ -10,7 +10,7 @@ import org.springframework.scheduling.annotation.Scheduled;
public class ScheduledTask { public class ScheduledTask {
/** /**
* 查询缓存区队列中待加工的 * 查询加工完成窑炉
*/ */
@Scheduled @Scheduled
public void taskForStockToKiln(){ public void taskForStockToKiln(){