Explorar el Código

fix:rfid缓存消息存储

wang.sq@aliyun.com hace 6 meses
padre
commit
8e4fc76ef3

+ 2 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/DemoLine/DemoCacheKey.java

@@ -48,6 +48,8 @@ public interface DemoCacheKey {
     //缓存记下当前任务刀具的起点和终点
     //缓存记下当前任务刀具的起点和终点
     String DEMOLINE_TOOL_STORGE = "DEMOLINE_TOOL_STORGE";
     String DEMOLINE_TOOL_STORGE = "DEMOLINE_TOOL_STORGE";
 
 
+    String RFID = "RFID:";
+
 
 
 
 
     /**
     /**

+ 22 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -7,6 +7,7 @@ import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.zuihou.authority.dto.priority.TaskNodePriorityDto;
 import com.github.zuihou.authority.dto.priority.TaskNodePriorityDto;
 import com.github.zuihou.authority.service.common.ParameterService;
 import com.github.zuihou.authority.service.common.ParameterService;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.R;
@@ -54,6 +55,7 @@ import com.github.zuihou.tenant.entity.ModuleInstruction;
 import com.github.zuihou.tenant.service.ModuleInstructionService;
 import com.github.zuihou.tenant.service.ModuleInstructionService;
 import com.github.zuihou.tenant.service.ModuleService;
 import com.github.zuihou.tenant.service.ModuleService;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Maps;
+import com.google.gson.Gson;
 import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException;
 import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import net.sf.jsqlparser.statement.select.KSQLWindow;
 import net.sf.jsqlparser.statement.select.KSQLWindow;
@@ -308,6 +310,20 @@ public class TaskWorkNode {
                     log.setExeResult("0").setManual("0").setFeedback("当前任务节点为空");
                     log.setExeResult("0").setManual("0").setFeedback("当前任务节点为空");
                     autoNodeLogService.save(log);
                     autoNodeLogService.save(log);
                     throw new RuntimeException("当前任务节点为空");
                     throw new RuntimeException("当前任务节点为空");
+                }else {
+                    // 缓存到根据节点id taskNodeId 查询出零件编码,托盘编码,给rfid数据校验使用
+                    Map parMap = new HashMap();
+                    parMap.put("nodeId", taskNode.getId());
+                    List<Map> nodeDataToRfidUse = taskMapper.getNodeDataToRfidUse(parMap);
+
+                    // 因为工装夹具是两条数据,rfid只校验工装(托盘),即没有关联查询夹具数据,查询出来有一条数据为空,需要过滤掉才能缓存到redis
+                    for (Map resultMap : nodeDataToRfidUse) {
+                        if( resultMap.get("trayNo")!=null){
+                            logger.warn("工rfid托盘校验数据缓存到redis:{}",resultMap);
+                            // 缓存到redis
+                            this.msgUtil.redis_set(DemoCacheKey.RFID+taskNode.getId(), resultMap.get("trayNo")+"&"+resultMap.get("uniqueCode"), 2L, TimeUnit.DAYS);
+                        }
+                    }
                 }
                 }
 
 
                 if (tTask == null || tTask.getStatus() == "3") {
                 if (tTask == null || tTask.getStatus() == "3") {
@@ -510,8 +526,9 @@ public class TaskWorkNode {
                                         log.setRequestParam(jsonParam);
                                         log.setRequestParam(jsonParam);
                                         log.setRequestUrl(instructionUrl);
                                         log.setRequestUrl(instructionUrl);
                                         HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
                                         HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
-                                        returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
-//                                        returnData = "{\"result\": \"true\"}";
+//                                        returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
+                                        returnData = "{\"result\": \"true\"}";
+
 
 
 
 
                                     }
                                     }
@@ -564,6 +581,9 @@ public class TaskWorkNode {
                 if (code.equals("true")) {
                 if (code.equals("true")) {
                     //回调处理
                     //回调处理
                     log.setExeStatus("3").setEndTime(new Date()).setSendStatus("1");
                     log.setExeStatus("3").setEndTime(new Date()).setSendStatus("1");
+
+                    // 任务下发成功,数据缓存到redis,与rfid比对使用
+                    logger.info("==============需要缓存的数据=================="+taskNode+"========="+ conMap);
                 } else if (code.equals("false")) {
                 } else if (code.equals("false")) {
                     //需要人工处理解决警报异常
                     //需要人工处理解决警报异常
                     log.setManual("1").setFeedback(retJson.getString("msg"));
                     log.setManual("1").setFeedback(retJson.getString("msg"));

+ 9 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/TTaskMapper.java

@@ -54,7 +54,7 @@ public interface TTaskMapper extends SuperMapper<TTask> {
 
 
     public List<Map> getTaskCountStatistics(Map<String, String> map);
     public List<Map> getTaskCountStatistics(Map<String, String> map);
 
 
-    public List<TaskNode> getInstructions(TaskNode taskNode);
+//    public List<TaskNode> getInstructions(TaskNode taskNode);
 
 
     List<Map> getStationTasks(Map<String, Object> map);
     List<Map> getStationTasks(Map<String, Object> map);
 
 
@@ -62,7 +62,14 @@ public interface TTaskMapper extends SuperMapper<TTask> {
 
 
     List<Map> query3dResourceData(Map<String, String> data);
     List<Map> query3dResourceData(Map<String, String> data);
 
 
-    List<String> getTaskResourceName(Map<String, String> params);
+//    List<String> getTaskResourceName(Map<String, String> params);
 
 
     List<Map> getXbkChangeStatus(Map<String, Object> map);
     List<Map> getXbkChangeStatus(Map<String, Object> map);
+
+    /**
+     * 获取节点数据,存储到redis,rfid 比对使用
+     * @param map
+     * @return
+     */
+    List<Map> getNodeDataToRfidUse(Map<String, Object> map);
 }
 }

+ 20 - 2
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TTaskMapper.xml

@@ -436,9 +436,27 @@
           GROUP BY t.is_reload
           GROUP BY t.is_reload
     </select>
     </select>
 
 
-    <select id="getTaskResourceName" resultType="java.util.Map">
-       SELECT * from imcs_s
+<!--    <select id="getTaskResourceName" resultType="java.util.Map">-->
+<!--       SELECT * from imcs_s-->
 
 
+<!--    </select>-->
+
+    <select id="getNodeDataToRfidUse" parameterType="java.util.Map" resultType="java.util.Map">
+        SELECT
+            itask.id taskId,
+            itask.procedure_name procedureName,
+            ittn.node_name nodeName,
+            ittn.id taskNodeId,
+            itt.`name` trayName,
+            itt.`no` trayNo,
+            itw.unique_code uniqueCode
+        FROM
+            imcs_t_task itask
+                LEFT JOIN imcs_t_task_node ittn ON itask.id = ittn.task_id
+                LEFT JOIN imcs_b_bom_procedure_tray ibbp  ON ittn.procedure_id = ibbp.procedure_id
+                LEFT JOIN imcs_t_tray itt ON itt.id = ibbp.tray_id
+                LEFT JOIN imcs_t_workpiece itw ON itw.complete_batch_no = ittn.complete_batch_no
+        WHERE ittn.id = ${nodeId};
     </select>
     </select>
 
 
 </mapper>
 </mapper>

+ 50 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/MeasuringController.java

@@ -1,18 +1,27 @@
 package com.github.zuihou.business.controller.operationManagementCenter;
 package com.github.zuihou.business.controller.operationManagementCenter;
 
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.request.PageParams;
 import com.github.zuihou.base.request.PageParams;
+import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
 import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
 import com.github.zuihou.business.operationManagementCenter.dto.*;
 import com.github.zuihou.business.operationManagementCenter.dto.*;
 import com.github.zuihou.business.operationManagementCenter.entity.OrderQuality;
 import com.github.zuihou.business.operationManagementCenter.entity.OrderQuality;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.operationManagementCenter.service.OrderQualityService;
 import com.github.zuihou.business.operationManagementCenter.service.OrderQualityService;
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
+import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.common.util.StringUtil;
+import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.file.entity.File;
 import com.github.zuihou.file.entity.File;
@@ -33,8 +42,11 @@ import java.io.BufferedInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 
 
 
 /**
 /**
@@ -131,4 +143,42 @@ public class MeasuringController extends SuperController<OrderQualityService, Lo
         }
         }
         return null;
         return null;
     }
     }
+
+
+    @Autowired
+    private MsgUtil msgUtil;
+    @ApiOperation(value = "测试--不用做业务使用", notes = "测试--不用做业务使用")
+    @RequestMapping(value="/getNodeDataToRfidUse", method = RequestMethod.POST)
+    @SysLog("获取节点数据")
+    public  void  getNodeDataToRfidUse(@RequestParam  String nodeid) throws JsonProcessingException {
+
+        Map map = new HashMap();
+        map.put("nodeId", nodeid);
+        BaseContextHandler.setTenant("0000");
+        List<Map> nodeDataToRfidUse = tTaskMapper.getNodeDataToRfidUse(map);
+
+        for (Map map1 : nodeDataToRfidUse) {
+           if( map1.get("trayNo")!=null){
+               log.info("缓存到redis中给rfig使用,失效时间,2day"+  map1);
+               // 创建 ObjectMapper 实例
+               ObjectMapper objectMapper = new ObjectMapper();
+               // 将 Map 转换为 JSON 字符串
+               JSONObject jsonObject = JSON.parseObject(objectMapper.writeValueAsString(map1));
+               String jsonString = objectMapper.writeValueAsString(map1);
+
+               TaskNode taskNode = JSONObject.parseObject(jsonString, TaskNode.class);
+
+               List<TaskNode> taskNodes = new ArrayList<>();
+               taskNodes.add(taskNode);
+
+               this.msgUtil.redis_set(DemoCacheKey.RFID+"111", map1, 2L, TimeUnit.DAYS);
+               this.msgUtil.redis_set(DemoCacheKey.RFID+"222", taskNode, 2L, TimeUnit.DAYS);
+               Object o = this.msgUtil.redis_get(DemoCacheKey.RFID + "222");
+
+           }
+        }
+
+        log.info("nodeDataToRfidUse========={}", JSONArray.toJSONString(nodeDataToRfidUse));
+
+    }
 }
 }

+ 2 - 2
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/TWorkpiece.java

@@ -70,10 +70,10 @@ public class TWorkpiece extends Entity implements Serializable {
     @Excel(name = "订单ID")
     @Excel(name = "订单ID")
     private Long orderId;
     private Long orderId;
 
 
-    @ApiModelProperty(value = "")
+    @ApiModelProperty(value = "产品唯一编码")
     @Length(max = 64, message = "长度不能超过64")
     @Length(max = 64, message = "长度不能超过64")
     @TableField(value = "unique_code", condition = LIKE)
     @TableField(value = "unique_code", condition = LIKE)
-    @Excel(name = "")
+    @Excel(name = "产品唯一编码")
     private String uniqueCode;
     private String uniqueCode;
 
 
     /**
     /**

+ 2 - 0
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/impl/ProductionresourceServiceImpl.java

@@ -416,6 +416,8 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
                 String tableSql = "select count(1) from information_schema.TABLES where TABLE_NAME = '"+tableName+"' and table_schema = '"+BizConstant.BASE_DATABASE+"_"+tenantCode+"'";
                 String tableSql = "select count(1) from information_schema.TABLES where TABLE_NAME = '"+tableName+"' and table_schema = '"+BizConstant.BASE_DATABASE+"_"+tenantCode+"'";
                 checkTable = baseMapper.checkTable(tableSql);
                 checkTable = baseMapper.checkTable(tableSql);
             }
             }
+        }else {
+            log.info("检测不到租户数据库的存在,企业:{},数据库:{}", tenant.getName() , (BizConstant.BASE_DATABASE+"_"+tenantCode));
         }
         }
 
 
         return checkTable;
         return checkTable;