任务过程中能源消耗记录优化

This commit is contained in:
lgh 2022-07-19 10:39:35 +08:00
parent 189475f09b
commit 5aa655b2b0

View File

@ -270,6 +270,19 @@ public class ScheduledTask extends BaseService {
if (currTaskId==0){ if (currTaskId==0){
continue; continue;
} }
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
//任务为null说明是已删除的任务不记录
if (currTask==null){
continue;
}
//任务结束时间不为null说明是已结束的任务不记录
if (currTask.getEndTime()!=null){
continue;
}
//任务不在加工状态不记录
if (currTask.getIsIn()!=1){
continue;
}
//加工炉 //加工炉
if (kilnInfo.getType()==1){ if (kilnInfo.getType()==1){
//一号油搅拌转速 //一号油搅拌转速
@ -357,15 +370,22 @@ public class ScheduledTask extends BaseService {
Long kilnId = kilnInfo.getId(); Long kilnId = kilnInfo.getId();
String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber"); String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber");
Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString());
//任务id为0说明不是自动任务不记录
if (currTaskId==0){ if (currTaskId==0){
continue; continue;
} }
CurrTask currTask = currTaskServiceBiz.getById(currTaskId); CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
if (currTask!=null){ //任务为null说明是已删除的任务不记录
if (currTask==null){
continue;
}
//任务结束时间不为null说明是已结束的任务不记录
if (currTask.getEndTime()!=null){ if (currTask.getEndTime()!=null){
continue; continue;
} }
//任务不在加工状态不记录
if (currTask.getIsIn()!=1){
continue;
} }
//加工炉 //加工炉
if (kilnInfo.getType()==1){ if (kilnInfo.getType()==1){
@ -521,6 +541,8 @@ public class ScheduledTask extends BaseService {
.orderByAsc(InStockInfo.IN_TIME)); .orderByAsc(InStockInfo.IN_TIME));
if (inStockInfoList.size() > 0) { if (inStockInfoList.size() > 0) {
InStockInfo inStockInfo = inStockInfoList.get(0); InStockInfo inStockInfo = inStockInfoList.get(0);
logger.info("加工炉"+kilnInfo.getCode()+"readyIn为"+kilnReadyIn.toString()+" allowIn为"+kilnAllowIn.toString());
logger.info("缓存区等待队列第一位:"+inStockInfo.toString());
CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId()); CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId());
Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); Location location = locationServiceBiz.getById(inStockInfo.getLocationId());
//是否有小车在运行 //是否有小车在运行
@ -530,6 +552,7 @@ public class ScheduledTask extends BaseService {
//计算出路径最短的车辆id //计算出路径最短的车辆id
Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode()); Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode());
//占用车辆 //占用车辆
if (vehicleId!=0){
VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
vehicleInfo.setStatus(1); vehicleInfo.setStatus(1);
vehicleInfo.setUpdateTime(LocalDateTime.now()); vehicleInfo.setUpdateTime(LocalDateTime.now());
@ -539,6 +562,7 @@ public class ScheduledTask extends BaseService {
} }
} }
} }
}
} }
} }