|
@@ -0,0 +1,203 @@
|
|
|
|
+package com.github.zuihou.business.controller.operationManagementCenter;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.github.zuihou.authority.service.common.ParameterService;
|
|
|
|
+import com.github.zuihou.base.R;
|
|
|
|
+import com.github.zuihou.base.request.PageParams;
|
|
|
|
+import com.github.zuihou.business.DemoLine.YunjianConstant;
|
|
|
|
+import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
|
|
|
|
+import com.github.zuihou.business.edgeLibrary.entity.Storge;
|
|
|
|
+import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
|
|
|
|
+import com.github.zuihou.business.edgeLibrary.service.StorgeService;
|
|
|
|
+import com.github.zuihou.business.externalApi.service.AgvHikOrderInfoService;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.dto.PlanPageDTO;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.Order;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.OrderTask;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.Plan;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.OrderTaskService;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.TaskService;
|
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
|
|
|
|
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
|
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
|
|
|
|
+import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
|
|
|
|
+import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
|
|
|
|
+import com.github.zuihou.business.util.DynamicRabbitMq;
|
|
|
|
+import com.github.zuihou.business.util.MsgUtil;
|
|
|
|
+import com.github.zuihou.common.constant.ParameterKey;
|
|
|
|
+import com.github.zuihou.common.util.DateUtil;
|
|
|
|
+import com.github.zuihou.log.annotation.SysLog;
|
|
|
|
+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.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.redis.core.ListOperations;
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
|
|
|
+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;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 前端控制器
|
|
|
|
+ * 工具查询表
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author imcs
|
|
|
|
+ * @date 2023-12-29
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@Validated
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/toolQuery")
|
|
|
|
+@Api(value = "toolQuery", tags = "工具查询表盘")
|
|
|
|
+@SysLog(enabled = true)
|
|
|
|
+public class ToolQueryController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StockInfoService stockInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private StorgeService storgeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private MsgUtil msgUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TaskNodeService taskNodeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProductionresourceBizMapper productionresourceBizMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ZZoneService zoneService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProductionresourcePositionService productionresourcePositionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private WorkpieceService workpieceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TaskService taskService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DynamicRabbitMq dynamicRabbitMq;
|
|
|
|
+ @Autowired
|
|
|
|
+ private AgvHikOrderInfoService agvHikOrderInfoService;
|
|
|
|
+ @Resource
|
|
|
|
+ private RedisTemplate<String,String> redisTemplate;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OrderTaskService orderTaskService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PlanController planController;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询业务节点状态", notes = "查询业务节点状态")
|
|
|
|
+ @PostMapping("/getBizStatusList")
|
|
|
|
+ public R getBizStatusList(@RequestBody Map<String, String> data) {
|
|
|
|
+ int timeSpan = data.containsKey("timeSpan")? Integer.parseInt(data.get("timeSpan")) : 2;
|
|
|
|
+ List<TaskNode> statusList = taskNodeService.list(new LambdaQueryWrapper<TaskNode>().eq(TaskNode::getNodeType, "0").in(TaskNode::getExeStatus, new String[]{"2","4","5"}).le(TaskNode::getStartTime, DateUtils.addDays(new Date(),(-1)*timeSpan)));
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("data", statusList);
|
|
|
|
+ return R.success(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询AGV锁定状态", notes = "查询AGV锁定状态")
|
|
|
|
+ @PostMapping("/getAgvLockList")
|
|
|
|
+ public R getAgvLockList(@RequestBody Map<String, String> data) {
|
|
|
|
+ return agvHikOrderInfoService.queryAgvCheck();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询节点回调数据", notes = "查询节点回调数据")
|
|
|
|
+ @PostMapping("/getCacheCallbackList")
|
|
|
|
+ public R getCacheCallbackList(@RequestBody Map<String, String> data) {
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ String hostSystemUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(ParameterKey.HOSTSYSTEMURL).toString());
|
|
|
|
+ if(StringUtils.isEmpty(hostSystemUrl)) return R.fail("Redis缓存数据不存在");
|
|
|
|
+ String instructionUrl = "/api/GetCallbackList";
|
|
|
|
+ JSONObject jsonParam = new JSONObject();
|
|
|
|
+ jsonParam.put("state", "1");
|
|
|
|
+ String callbackTaskList = msgUtil.httpForPost(hostSystemUrl+instructionUrl, jsonParam.toJSONString());
|
|
|
|
+ if(null==callbackTaskList) return R.fail("CCS数据调用失败");
|
|
|
|
+ JSONArray jsonArray = JSON.parseArray(callbackTaskList);
|
|
|
|
+ List<Map> mapList = JSONObject.parseArray(jsonArray.toJSONString(), Map.class);
|
|
|
|
+ map.put("data", mapList);
|
|
|
|
+ return R.success(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询点库位锁定状态", notes = "查询点库位锁定状态")
|
|
|
|
+ @PostMapping("/getStorgeLockList")
|
|
|
|
+ public R getStorgeLockList(@RequestBody Map<String, String> data) {
|
|
|
|
+ List<Storge> storgeList = storgeService.list(new LambdaQueryWrapper<Storge>().eq(Storge::getLockStatus, "0").eq(Storge::getStatus,"1"));
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("data", storgeList);
|
|
|
|
+ return R.success(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询点库位锁定状态", notes = "查询点库位锁定状态")
|
|
|
|
+ @PostMapping("/getOfflineList")
|
|
|
|
+ public R getOfflineList(@RequestBody Map<String, String> data) {
|
|
|
|
+ List<Productionresource> productionresourcesList = productionresourceBizMapper.selectList(new LambdaQueryWrapper<Productionresource>().eq(Productionresource::getStatus, "0").or().eq(Productionresource::getOnlineStatus, "0").isNotNull(Productionresource::getIp));
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("data", productionresourcesList);
|
|
|
|
+ return R.success(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询缓存关键字", notes = "查询缓存关键字")
|
|
|
|
+ @PostMapping("/getCacheKeyList")
|
|
|
|
+ public R getCacheKeyList(@RequestBody Map<String, String> data) {
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put(YunjianConstant.YUNJIAN_SHEDULE_FLAG, (null != msgUtil.redis_get(YunjianConstant.YUNJIAN_SHEDULE_FLAG)? 1:0));
|
|
|
|
+ map.put("PRIORITY_LOCK", (null != msgUtil.redis_get("PRIORITY_LOCK"))? 1:0);
|
|
|
|
+
|
|
|
|
+ return R.success(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询自定义订单", notes = "查询自定义订单")
|
|
|
|
+ @PostMapping("/getOrderTaskList")
|
|
|
|
+ public R getOrderTaskList(@RequestBody Map<String, String> data) {
|
|
|
|
+ PageParams<PlanPageDTO> planPage = new PageParams<PlanPageDTO>();
|
|
|
|
+ IPage<Plan> page = planPage.buildPage();
|
|
|
|
+ PlanPageDTO planPageDTO = PlanPageDTO.builder().build();
|
|
|
|
+ planPageDTO.setPlanStatus("2").setSingleTaskFlag("1");
|
|
|
|
+ planPage.setModel(planPageDTO);
|
|
|
|
+ planController.query(planPage, page, 10L);
|
|
|
|
+ R result = planController.page(planPage);
|
|
|
|
+ return R.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 处理超时节点
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ @Scheduled(cron="0 0/10 * * * ?")
|
|
|
|
+ public void cronTaskNode(){
|
|
|
|
+ Date date = DateUtils.addMinutes(new Date(), -20);
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ R result = this.getCacheCallbackList(map);
|
|
|
|
+ Map datas = (Map)result.getData();
|
|
|
|
+ List<Map> mapList = (List<Map>)datas.get("data");
|
|
|
|
+ List<Map> resultList = mapList.stream().filter(item->{
|
|
|
|
+ String dateStr = item.get("createTime").toString().replace("T", " ");
|
|
|
|
+ Date createTime = DateUtil.stringToDate7(dateStr);
|
|
|
|
+ return item.get("address").toString().equals("DB200.50") && DateUtil.dateDiff(createTime, date);
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ if(resultList.size() > 0){
|
|
|
|
+ Map dataMap = resultList.get(0);
|
|
|
|
+ String content = dataMap.get("operateName").toString()+"节点("+ dataMap.get("taskNodeId").toString() +")任务执行超时";
|
|
|
|
+ msgUtil.createWarnLog(content, "TimeoutException");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|