|
@@ -3,7 +3,10 @@ package com.github.zuihou.business.controller.dispatchRecord;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.github.zuihou.base.R;
|
|
|
import com.github.zuihou.base.controller.SuperSimpleController;
|
|
@@ -13,8 +16,15 @@ import com.github.zuihou.business.dispatchRecord.entity.DispatchRecord;
|
|
|
import com.github.zuihou.business.dispatchRecord.service.DispatchExceptionService;
|
|
|
import com.github.zuihou.business.dispatchRecord.service.DispatchRecordService;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.Order;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
|
|
|
+import com.github.zuihou.business.util.MsgUtil;
|
|
|
+import com.github.zuihou.common.constant.CacheKey;
|
|
|
+import com.github.zuihou.common.constant.DictionaryKey;
|
|
|
import com.github.zuihou.common.util.DateUtil;
|
|
|
+import com.github.zuihou.context.BaseContextHandler;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
|
|
@@ -24,16 +34,21 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import java.lang.invoke.MethodType;
|
|
|
import java.lang.reflect.Field;
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.Date;
|
|
|
import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
@@ -42,26 +57,40 @@ import java.util.Map;
|
|
|
@RequestMapping("/dispatchException")
|
|
|
@Api(value = "dispatchException", tags = "调度异常")
|
|
|
@SysLog(enabled = true)
|
|
|
-public class DispatchExceptionController extends SuperSimpleController<DispatchExceptionService, DispatchException> {
|
|
|
+public class DispatchExceptionController extends SuperSimpleController<AAutoNodeLogService, AAutoNodeLog> {
|
|
|
|
|
|
- @ApiOperation(value = "查询设备刀具管理", notes = "查询设备刀具管理")
|
|
|
+ @Autowired
|
|
|
+ private AAutoNodeLogService aAutoNodeLogService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkpieceService workpieceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MsgUtil msgUtil;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询对话调度异常", notes = "查询对话调度异常")
|
|
|
@PostMapping("/page")
|
|
|
- public R<IPage<DispatchException>> page(@RequestBody @Validated PageParams<DispatchException> params) {
|
|
|
- IPage<DispatchException> page = params.buildPage();
|
|
|
- QueryWrap<DispatchException> wrap = handlerWrapper(null, params);
|
|
|
- LbqWrapper<DispatchException> wrapper = wrap.lambda();
|
|
|
- wrapper.like(DispatchException::getName, params.getModel().getName())
|
|
|
+ public R<IPage<AAutoNodeLog>> page(@RequestBody @Validated PageParams<AAutoNodeLog> params) {
|
|
|
+ IPage<AAutoNodeLog> page = params.buildPage();
|
|
|
+ QueryWrap<AAutoNodeLog> wrap = handlerWrapper(null, params);
|
|
|
+ LbqWrapper<AAutoNodeLog> wrapper = wrap.lambda();
|
|
|
+ wrapper.like(AAutoNodeLog::getInstructionName, params.getModel().getInstructionName())
|
|
|
//.geHeader(DispatchException::getOperationTime, StrUtil.isEmpty(params.getModel().getOperationTime_st())?null: LocalDateTime.parse(params.getModel().getOperationTime_st()))
|
|
|
- .ge(DispatchException::getOperationTime, DateUtil.stringToDate3(params.getModel().getOperationTime_st()))
|
|
|
- .le(DispatchException::getOperationTime, DateUtil.stringToDate3(params.getModel().getOperationTime_ed()))
|
|
|
+ .ge(AAutoNodeLog::getExecuteTime, DateUtil.stringToDate3(params.getModel().getExecuteTime_st()))
|
|
|
+ .le(AAutoNodeLog::getExecuteTime, DateUtil.stringToDate3(params.getModel().getExecuteTime_ed()))
|
|
|
// .leFooter(DispatchException::getOperationTime, StrUtil.isEmpty(params.getModel().getOperationTime_ed())?null:LocalDateTime.parse(params.getModel().getOperationTime_ed()))
|
|
|
- .orderByDesc(DispatchException::getCreateTime);
|
|
|
- baseService.page(page, wrapper);
|
|
|
+ .orderByDesc(AAutoNodeLog::getCreateTime);
|
|
|
+ //查询弹框异常
|
|
|
+ wrapper.eq(AAutoNodeLog::getExeResult,"0").eq(AAutoNodeLog::getManual, "1").eq(AAutoNodeLog::getStatus, "0");
|
|
|
+ aAutoNodeLogService.page(page, wrapper);
|
|
|
return this.success(page);
|
|
|
}
|
|
|
|
|
|
- private QueryWrap<DispatchException> handlerWrapper(DispatchException model, PageParams<DispatchException> params) {
|
|
|
- QueryWrap<DispatchException> wrapper = model == null ? Wraps.q() : Wraps.q(model);
|
|
|
+ private QueryWrap<AAutoNodeLog> handlerWrapper(AAutoNodeLog model, PageParams<AAutoNodeLog> params) {
|
|
|
+ QueryWrap<AAutoNodeLog> wrapper = model == null ? Wraps.q() : Wraps.q(model);
|
|
|
if (CollUtil.isNotEmpty(params.getMap())) {
|
|
|
Map<String, String> map = params.getMap();
|
|
|
Iterator var5 = map.entrySet().iterator();
|
|
@@ -102,4 +131,49 @@ public class DispatchExceptionController extends SuperSimpleController<DispatchE
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "修改状态", notes = "修改状态")
|
|
|
+ @GetMapping("/updateStatus")
|
|
|
+ public R<Boolean> updateStatus(@RequestParam(value="ids[]") List<Long> ids) {
|
|
|
+ return R.success(aAutoNodeLogService.updateStatus(ids));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "标记指令完成", notes = "标记指令完成")
|
|
|
+ @PostMapping("/complete")
|
|
|
+ public R<Boolean> complete(@RequestBody Map<String, Long> map) {
|
|
|
+ //return R.success(aAutoNodeLogService.updateStatus(ids));
|
|
|
+ AAutoNodeLog autoNodeLog = aAutoNodeLogService.getById(map.get("id"));
|
|
|
+ Long taskNodeId = autoNodeLog.getTaskNodeId();
|
|
|
+ TWorkpiece tWorkpiece = workpieceService.getWorkPiece(taskNodeId);
|
|
|
+ //节点逻辑处理(待定)
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<AAutoNodeLog> updateWrapper = new UpdateWrapper<AAutoNodeLog>().lambda();
|
|
|
+ updateWrapper.eq(AAutoNodeLog::getId, map.get("id")).set(AAutoNodeLog::getStatus, "1").set(AAutoNodeLog::getExeResult ,"1")
|
|
|
+ .set(AAutoNodeLog::getUpdateUser, BaseContextHandler.getUserId()).set(AAutoNodeLog::getUpdateTime, new Date());
|
|
|
+
|
|
|
+ return R.success(aAutoNodeLogService.update(updateWrapper));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "重发数据节点", notes = "重发数据节点")
|
|
|
+ @PostMapping("/resend")
|
|
|
+ private R<Boolean> resend(@RequestBody Map<String, Long> map){
|
|
|
+ AAutoNodeLog autoNodeLog = aAutoNodeLogService.getById(map.get("id"));
|
|
|
+ Long taskNodeId = autoNodeLog.getTaskNodeId();
|
|
|
+ TWorkpiece tWorkpiece = workpieceService.getWorkPiece(taskNodeId);
|
|
|
+ //判断重发节点操作条件(待定)
|
|
|
+ Map<String, Object> conMap = msgUtil.redis_get_map(CacheKey.TASK_CURRENT_NODE_CONDITION + "_" + taskNodeId);
|
|
|
+ //获取重发执行传参
|
|
|
+ String jsonParam = msgUtil.redis_get(CacheKey.TASK_CURRENT_NODE_PARAMS + "_" + taskNodeId).toString();
|
|
|
+
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
|
+ HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
|
|
|
+
|
|
|
+ String instructionUrl = DictionaryKey.INSTRUCTION_URL +"/api/"+ autoNodeLog.getMethod().toString() ;
|
|
|
+ String returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
|
|
|
+ JSONObject retJson = JSONObject.parseObject(returnData);
|
|
|
+ String code = retJson.getString("code").trim();
|
|
|
+
|
|
|
+ return R.success(("1" == code)? true: false);
|
|
|
+ }
|
|
|
+
|
|
|
}
|