|
|
@@ -27,6 +27,7 @@ import com.github.zuihou.business.operationManagementCenter.dto.TTaskSaveDTO;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dto.TTaskUpdateDTO;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.OrderTask;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.TTask;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.TaskBizService;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
|
|
|
@@ -51,8 +52,11 @@ import com.google.common.collect.Maps;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
@@ -67,11 +71,11 @@ import java.util.stream.Collectors;
|
|
|
/**
|
|
|
* <p>
|
|
|
* 前端控制器
|
|
|
- * 计划表
|
|
|
+ * 工具表
|
|
|
* </p>
|
|
|
*
|
|
|
* @author imcs
|
|
|
- * @date 2020-12-29
|
|
|
+ * @date 2023-12-29
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Validated
|
|
|
@@ -187,11 +191,25 @@ public class ToolbarController {
|
|
|
Productionresource productionresource = productionresourceBizMapper.selectOne(new LbqWrapper<Productionresource>().eq(Productionresource::getIp, ip).isNotNull(Productionresource::getModeSpecification));
|
|
|
if(null == productionresource) return R.fail("设备不存在");
|
|
|
String onlineStatus = productionresource.getOnlineStatus().equals("0")? "1": "0";
|
|
|
- productionresource.setOnlineStatus(onlineStatus).setStatus("1");
|
|
|
+ productionresource.setOnlineStatus(onlineStatus);
|
|
|
productionresourceBizMapper.updateById(productionresource);
|
|
|
return R.success();
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "更改设备掉线状态", notes = "更改设备掉线状态")
|
|
|
+ @PostMapping("/updateDeviceStatus")
|
|
|
+ public R updateDeviceStatus(@RequestBody Map<String, String> data) {
|
|
|
+ String line = data.containsKey("line")? data.get("line").toString() : null;
|
|
|
+ if(StringUtils.isEmpty(line)) return R.fail("设备产线不能为空");
|
|
|
+ List<Productionresource> productionResourceList = productionresourceBizMapper.selectList(new LbqWrapper<Productionresource>().like(Productionresource::getCode, line).eq(Productionresource::getStatus, "0").isNotNull(Productionresource::getIp));
|
|
|
+ if(productionResourceList.size()==0) return R.fail("该产线不存在已掉线设备");
|
|
|
+ List<Long> ids = productionResourceList.stream().map(item->item.getId()).collect(Collectors.toList());
|
|
|
+ UpdateWrapper<Productionresource> updateWrapper = new UpdateWrapper<Productionresource>();
|
|
|
+ updateWrapper.lambda().set(Productionresource::getStatus, "1").in(Productionresource::getId, ids);
|
|
|
+ productionresourceBizMapper.update(null, updateWrapper);
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "新增AGV任务", notes = "新增AGV任务")
|
|
|
@PostMapping("/addHikTask")
|
|
|
public R addHikTask(@RequestBody Map<String, String> data) {
|
|
|
@@ -388,7 +406,7 @@ public class ToolbarController {
|
|
|
TaskNode taskNode = taskNodeService.getById(taskNodeId);
|
|
|
if(null == taskNode || null == taskNode.getResourceId()) return R.fail("节点不存在或者节点设备为空");
|
|
|
log.info("推送mq队列{}消息{}",taskNode.getResourceId().toString(),jsonObject.toString());
|
|
|
- dynamicRabbitMq.sendMsg(taskNode.getResourceId().toString(),jsonObject.toString());
|
|
|
+ dynamicRabbitMq.sendMsg(taskNode.getResourceId().toString(),jsonObject.toString(), 10);
|
|
|
return R.success();
|
|
|
}
|
|
|
|
|
|
@@ -425,5 +443,144 @@ public class ToolbarController {
|
|
|
msgUtil.redis_del("PRIORITY_LIST");
|
|
|
return R.success();
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加设备回调", notes = "添加设备回调")
|
|
|
+ @PostMapping("/addMachineCallback")
|
|
|
+ public R addMachineCallback(@RequestBody Map<String, Object> data) {
|
|
|
+ //添加设备回调信息(加工设备非正常启动)
|
|
|
+ String ip = data.containsKey("ip")? data.get("ip").toString() : null;
|
|
|
+ String taskId = data.containsKey("taskId")? data.get("taskId").toString() : null;
|
|
|
+ String taskNodeId = data.containsKey("taskNodeId")? data.get("taskNodeId").toString() : null;
|
|
|
+ if(StringUtils.isEmpty(taskNodeId) || StringUtils.isEmpty(taskId) || StringUtils.isEmpty(ip)) return R.fail("数据传参为空");
|
|
|
+ JSONObject params = new JSONObject(data);
|
|
|
+ TaskNode taskNode = taskNodeService.getById(taskNodeId);
|
|
|
+ Productionresource productionresource = productionresourceBizMapper.selectOne(new LambdaQueryWrapper<Productionresource>().eq(Productionresource::getIp, ip).last("limit 1"));
|
|
|
+ if(null == taskNode || null == productionresource) return R.fail("设备或节点数据不存在");
|
|
|
+ msgUtil.getCcsData("/api/addMachineCallback", params, taskNode);
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "更新业务数据状态", notes = "更新业务数据状态")
|
|
|
+ @PostMapping("/updateBizStatus")
|
|
|
+ public R updateBizStatus(@RequestBody Map<String, Object> data) {
|
|
|
+ //添加设备回调信息(加工设备非正常启动)
|
|
|
+ String status = data.containsKey("status")? data.get("status").toString() : null;
|
|
|
+ String taskId = data.containsKey("taskId")? data.get("taskId").toString() : null;
|
|
|
+ String taskNodeId = data.containsKey("taskNodeId")? data.get("taskNodeId").toString() : null;
|
|
|
+ if((StringUtils.isEmpty(taskNodeId) && StringUtils.isEmpty(taskId)) || StringUtils.isEmpty(status)) return R.fail("数据传参为空");
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(taskNodeId)) {
|
|
|
+ TaskNode taskNode = taskNodeService.getById(taskNodeId);
|
|
|
+ if(null == taskNode) return R.fail("节点数据不存在");
|
|
|
+ if(taskNode.getExeStatus().equals(status)) return R.fail("节点状态一致无需变更");
|
|
|
+ taskNode.setExeStatus(status);
|
|
|
+ taskNodeService.updateById(taskNode);
|
|
|
+ }else if(StringUtils.isNotEmpty(taskId)){
|
|
|
+ TTask tTask = taskService.getById(taskId);
|
|
|
+ if(null == tTask) return R.fail("任务数据不存在");
|
|
|
+ if(tTask.getStatus().equals(status)) return R.fail("任务状态一致无需变更");
|
|
|
+ tTask.setStatus(status);
|
|
|
+ taskService.updateById(tTask);
|
|
|
+ }
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "零件回复初始化", notes = "零件回复初始化")
|
|
|
+ @PostMapping("/eraseWorkPiece")
|
|
|
+ public R eraseWorkPiece(@RequestBody Map<String, Object> data) {
|
|
|
+ //添加设备回调信息(加工设备非正常启动)
|
|
|
+ String completeBatchNo = data.containsKey("completeBatchNo")? data.get("completeBatchNo").toString() : null;
|
|
|
+ if(StringUtils.isEmpty(completeBatchNo)) return R.fail("数据传参为空");
|
|
|
+ TWorkpiece workpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getCompleteBatchNo, completeBatchNo));
|
|
|
+ if(null==workpiece || workpiece.getIsEnd().equals("1")) return R.fail("还原零件不存在");
|
|
|
+ TaskNode taskNode = taskNodeService.getById(workpiece.getTaskNodeId());
|
|
|
+ if(null==taskNode || !taskNode.getExeStatus().equals("3")) return R.fail("还原零件节点不存在");
|
|
|
+ TTask tTask = taskService.getById(taskNode.getTaskId());
|
|
|
+ if(null==tTask) return R.fail("还原零件任务不存在");
|
|
|
+
|
|
|
+ //数据还原处理
|
|
|
+ UpdateWrapper<TWorkpiece> workpieceUpdateWrapper = new UpdateWrapper<TWorkpiece>();
|
|
|
+ workpieceUpdateWrapper.lambda().set(TWorkpiece::getIsEnd, "0").set(TWorkpiece::getTaskNodeId, null).set(TWorkpiece::getUniqueCode, null).set(TWorkpiece::getPointId, "").set(TWorkpiece::getStorgeId, null).set(TWorkpiece::getProcedureId, null).set(TWorkpiece::getCompleteBatchSort, null).eq(TWorkpiece::getCompleteBatchNo, completeBatchNo);
|
|
|
+ workpieceService.update(null, workpieceUpdateWrapper);
|
|
|
+
|
|
|
+ List<TaskNode> taskNodeList = taskNodeService.list(new LambdaQueryWrapper<TaskNode>().eq(TaskNode::getCompleteBatchNo, completeBatchNo).le(TaskNode::getCompleteBatchSort, taskNode.getCompleteBatchSort() + 2).orderByDesc(TaskNode::getCompleteBatchSort));
|
|
|
+ List<Integer> nodeSortList = new ArrayList<Integer>();
|
|
|
+ List<Integer> agvList = new ArrayList<Integer>();
|
|
|
+ taskNodeList.stream().forEach(item->{
|
|
|
+ boolean isFirst = item.getCompleteBatchSort().equals(1);
|
|
|
+ boolean isAgv = item.getInterfaceType().equals("03");
|
|
|
+ if(isAgv){
|
|
|
+ //item.setResourceId(null).setTargetResourceId(null);
|
|
|
+ agvList.add(item.getCompleteBatchSort());
|
|
|
+ if(!isFirst) {
|
|
|
+ nodeSortList.add(item.getCompleteBatchSort() - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setExeStatus(isFirst?"2":"1").setStartTime(isFirst? new Date():null).setExeResult("").setEndTime(null);
|
|
|
+ });
|
|
|
+ taskNodeService.updateBatchById(taskNodeList);
|
|
|
+ if(agvList.size()>0){
|
|
|
+ UpdateWrapper<TaskNode> agvUpdateWrapper = new UpdateWrapper<TaskNode>();
|
|
|
+ agvUpdateWrapper.lambda().set(TaskNode::getResourceId, null).set(TaskNode::getTargetResourceId, null).eq(TaskNode::getCompleteBatchNo, completeBatchNo).in(TaskNode::getCompleteBatchSort, agvList.toArray());
|
|
|
+ taskNodeService.update(null, agvUpdateWrapper);
|
|
|
+ }
|
|
|
+ if(nodeSortList.size()>0){
|
|
|
+ UpdateWrapper<TaskNode> updateWrapper = new UpdateWrapper<TaskNode>();
|
|
|
+ updateWrapper.lambda().set(TaskNode::getTargetResourceId, null).eq(TaskNode::getCompleteBatchNo, completeBatchNo).in(TaskNode::getCompleteBatchSort, nodeSortList.toArray());
|
|
|
+ taskNodeService.update(null, updateWrapper);
|
|
|
+ }
|
|
|
+ //更新任务
|
|
|
+ List<TTask> taskList = taskService.list(new LambdaQueryWrapper<TTask>().eq(TTask::getCompleteBatchNo, completeBatchNo).le(TTask::getProcedureSort, tTask.getProcedureSort()+1).orderByDesc(TTask::getProcedureSort));
|
|
|
+ taskList.stream().forEach(item->{
|
|
|
+ boolean isFirst = item.getProcedureSort().equals(0);
|
|
|
+ item.setStatus(isFirst?"2":"1").setStartTime(isFirst?new Date():null).setEndTime(null);
|
|
|
+ });
|
|
|
+ taskService.updateBatchById(taskList);
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "清空过期缓存", notes = "清空过期缓存")
|
|
|
+ @PostMapping("/cleanCache")
|
|
|
+ public R cleanCache(@RequestBody Map<String, Object> data) {
|
|
|
+ List<TWorkpiece> workpieceList = workpieceService.list(new LambdaQueryWrapper<TWorkpiece>().eq(TWorkpiece::getIsEnd, "0").isNotNull(TWorkpiece::getUniqueCode).isNotNull(TWorkpiece::getCompleteBatchSort).orderByDesc(TWorkpiece::getCreateTime));
|
|
|
+ workpieceList.stream().forEach(item->{
|
|
|
+ boolean bool = item.getIsEnd().equals("1");
|
|
|
+ List<Long> taskNodeList = new ArrayList<Long>();
|
|
|
+ taskNodeList = taskNodeService.list(new LambdaQueryWrapper<TaskNode>().eq(TaskNode::getCompleteBatchNo, item.getCompleteBatchNo()).lt(TaskNode::getCompleteBatchSort, item.getCompleteBatchSort()).orderByDesc(TaskNode::getCompleteBatchSort)).stream().map(TaskNode::getId).collect(Collectors.toList());
|
|
|
+ taskNodeList.stream().forEach(operationTaskNodeId->{
|
|
|
+ msgUtil.redis_del(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + operationTaskNodeId);
|
|
|
+ msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + operationTaskNodeId);
|
|
|
+ msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + operationTaskNodeId);
|
|
|
+ msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + operationTaskNodeId);
|
|
|
+ msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + operationTaskNodeId);
|
|
|
+ msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + operationTaskNodeId);
|
|
|
+ msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE + "_" + + operationTaskNodeId);
|
|
|
+ msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE_CONDITION + "_" + + operationTaskNodeId);
|
|
|
+ msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE_STATUS + "_" + + operationTaskNodeId);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "更新不加工自定义订单状态", notes = "更新不加工自定义订单状态")
|
|
|
+ @PostMapping("/updateUnExeTask")
|
|
|
+ public R updateUnExeTask(@RequestBody Map<String, Object> data) {
|
|
|
+ String taskNodeId = data.containsKey("taskNodeId")? data.get("taskNodeId").toString() : null;
|
|
|
+ if(StringUtils.isEmpty(taskNodeId)) return R.fail("数据传参为空");
|
|
|
+ TaskNode taskNode = taskNodeService.getById(taskNodeId);
|
|
|
+ if(taskNode!=null && !taskNode.getExeStatus().equals("4")) return R.fail("节点状态不正确");
|
|
|
+ Productionresource productionresource = productionresourceBizMapper.selectById(taskNode.getResourceId());
|
|
|
+ if(productionresource==null || StringUtils.isEmpty(productionresource.getModeSpecification())) return R.fail("节点不是加工设备任务");
|
|
|
+ List<TaskNode> taskNodeList = taskNodeService.list(new LambdaQueryWrapper<TaskNode>().eq(TaskNode::getCompleteBatchNo, taskNode.getCompleteBatchNo()).eq(TaskNode::getTaskId, taskNode.getTaskId()).ge(TaskNode::getCompleteBatchSort, taskNode.getCompleteBatchSort()).orderByAsc(TaskNode::getCompleteBatchSort));
|
|
|
+ UpdateWrapper<TaskNode> updateWrapper = new UpdateWrapper<TaskNode>();
|
|
|
+ updateWrapper.lambda().set(TaskNode::getExeStatus, "3").set(TaskNode::getExeResult, "1").in(TaskNode::getId, taskNodeList.stream().map(TaskNode::getId).collect(Collectors.toList()));
|
|
|
+ taskNodeService.update(null, updateWrapper);
|
|
|
+ TTask task = taskService.getById(taskNode.getTaskId());
|
|
|
+ task.setStatus("3").setEndTime(new Date());
|
|
|
+ taskService.updateById(task);
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|