增加置顶任务;

加工结束能源消耗只记录一次。
This commit is contained in:
lgh 2022-07-17 10:25:51 +08:00
parent 6eb2839b7a
commit dae060d573
5 changed files with 62 additions and 4 deletions

View File

@ -285,6 +285,12 @@ public class CurrTaskController extends BaseController {
public R<String> deleteById(@Validated @RequestBody IdParam param) {
return currTaskService.deleteById(param);
}
@PostMapping(value = "top")
@ApiOperation(value = "置顶该任务")
public R<String> top(@Validated @RequestBody IdParam param) {
return currTaskService.top(param);
}
@PostMapping(value = "runTask")
@ApiOperation(value = "执行任务")
public R<String> runTask(@Validated @RequestBody IdParam param) throws InterruptedException, IOException {

View File

@ -99,4 +99,7 @@ public interface CurrTaskService {
R<String> runTask(Long taskId) throws InterruptedException, IOException;
R<String> createAutoTask(AutoCurrTaskParam autoCurrTaskParam);
//置顶
R<String> top(IdParam idParam);
}

View File

@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.*;
/**
@ -82,6 +83,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
LocationServiceBiz locationServiceBiz;
@Autowired
CurrTaskDetServiceBiz currTaskDetServiceBiz;
@Autowired
InStockInfoServiceBiz inStockInfoServiceBiz;
@Override
public CurrTaskVo getCurrTask(IdParam idParam) {
@ -309,4 +312,34 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
public R<String> createAutoTask(AutoCurrTaskParam autoCurrTaskParam) {
return null;
}
/**
* 传入任务id,查询任务炉子然后根据炉子查询等待列表然后时间置为早
* @param idParam
* @return
*/
@Override
public R<String> top(IdParam idParam) {
CurrTask currTask = currTaskServiceBiz.getById(idParam.getId());
currTask.getIsCache();
if (currTask.getIsCache()==0){
return R.failed("当前任务未进入等待队列,不能置顶");
}
Long kilnId = currTask.getKilnId();
List<InStockInfo> inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper<InStockInfo>()
.eq(InStockInfo.KILN_ID, kilnId)
.eq(InStockInfo.TYPE,1)
.eq(InStockInfo.STATUS,0)
.orderByAsc(InStockInfo.IN_TIME));
if (inStockInfoList.size()<2){
return R.failed("当前加工炉等待队列只有一个任务,无需置顶");
}
LocalDateTime inTime=null;
inTime = inStockInfoList.get(0).getInTime();
InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>().eq(InStockInfo.LOCATION_ID, currTask.getLocationId()));
inStockInfo.setInTime(inTime.minusHours(1));
inStockInfoServiceBiz.updateById(inStockInfo);
return R.ok("当前任务置顶成功","");
}
}

View File

@ -81,6 +81,8 @@ public class AsynRunTaskService extends BaseService {
private AutoExeTaskServiceBiz autoExeTaskServiceBiz;
@Resource
private CurrTaskDetServiceBiz currTaskDetServiceBiz;
@Resource
private TaskHisServiceBiz taskHisServiceBiz;
//工业炉可用未满的情况下调用车辆起点为提升台终点为工业炉
@Async("asyncServiceExecutor")
@ -397,6 +399,10 @@ public class AsynRunTaskService extends BaseService {
currTask.setUpdateTime(LocalDateTime.now());
logger.info("修改currTask任务状态");
currTaskServiceBiz.updateById(currTask);
//新增历史任务表
TaskHis taskHis=new TaskHis();
BeanUtils.copyProperties(currTask,taskHis);
taskHisServiceBiz.save(taskHis);
//更新in_stock_info表
inStockInfo.setStatus(2);
inStockInfo.setInTime(LocalDateTime.now());

View File

@ -225,8 +225,11 @@ public class ScheduledTask extends BaseService {
if (resultBoolean){
//调用RunTaskUtils.runTaskForOutKiln
logger.info(kilnInfo.getCode()+kilnInfo.getKilnAlias()+"识别到允许出炉信号,进入出库程序!");
//加工结束而没有立马出炉加工结束记录能源消耗值只记录一次
if (currTask.getEndTime()!=null){
asynRunTaskService.asynEndRecordConsume(currTask.getId(),kilnId);
logger.info(kilnInfo.getCode()+"炉子中的任务:"+currTask.getId()+"已加工结束,记录加工结束能源消耗值");
}
//更新加工单工艺结束时间,只更新一次因为可能因为不满住出炉条件而进入到下一次定时任务
if (String.valueOf(currTask.getEndTime()).equals("null")){
currTask.setEndTime(LocalDateTime.now());
@ -348,9 +351,16 @@ public class ScheduledTask extends BaseService {
Long kilnId = kilnInfo.getId();
String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber");
Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString());
if (currTaskId==0){
continue;
}
CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
if (currTask!=null){
if (currTask.getEndTime()!=null){
continue;
}
}
//加工炉
if (kilnInfo.getType()==1){
//实际温度
@ -539,10 +549,10 @@ public class ScheduledTask extends BaseService {
//判断炉子是否在工作状态
String working = readPlcToString(kilnNameSpace.getName(), "Working");
JSONObject jsonObject = JSON.parseObject(working);
Boolean aBoolean = Boolean.valueOf(String.valueOf(jsonObject.get("msg")));
Boolean aBoolean = Boolean.valueOf(String.valueOf(jsonObject.get("result")));
if (aBoolean){
//命名空间前缀
String nameSpace = kilnNameSpace.getNote();
String nameSpace = kilnNameSpace.getName();
//炉子的报警变量
List<PlcNameSpace> alarmNameList = plcNameSpaceServiceBiz.list(new QueryWrapper<PlcNameSpace>()
.eq(PlcNameSpace.EQ_TYPE, 1)