Browse Source

fix:优化刀具上下料站任务

wang.sq@aliyun.com 3 ngày trước cách đây
mục cha
commit
37bd780c05

+ 2 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskService.java

@@ -104,6 +104,8 @@ public interface TaskService extends SuperService<TTask> {
 
     R confirmProcedure(Map<String, Object> map);
 
+    R cutterRfidConfirmProcedure(Map<String, Object> map);
+
     List<Tray> getValidTrayCount(Map<String, Object> map);
 
     TTask getNNextTask(TTask task, int n);

+ 77 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskServiceImpl.java

@@ -16,6 +16,8 @@ import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.aps.algorithm.ga.GAScheduler;
 import com.github.zuihou.business.aps.instance.domain.basicdata.*;
 import com.github.zuihou.business.classSchedule.dao.ScheduleUserDateMapper;
+import com.github.zuihou.business.cutterdata.dao.CutterTestDataMapper;
+import com.github.zuihou.business.cutterdata.entity.CutterTestDataEntity;
 import com.github.zuihou.business.edgeLibrary.dao.StockInfoMapper;
 import com.github.zuihou.business.edgeLibrary.dao.StockLogMapper;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
@@ -35,9 +37,11 @@ import com.github.zuihou.business.productionReadyCenter.service.TrayService;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ZZoneMapper;
+import com.github.zuihou.business.productionResourceCenter.dao.ZZoneProductionresourceMapper;
 import com.github.zuihou.business.productionResourceCenter.entity.*;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.business.productionResourceCenter.service.RepairService;
+import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.business.util.CommonUtil;
 import com.github.zuihou.business.util.DynamicRabbitMq;
 import com.github.zuihou.business.util.MsgUtil;
@@ -53,7 +57,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang.time.DateUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
@@ -115,6 +121,9 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
     @Autowired
     private StockInfoService stockInfoService;
 
+    @Value("${imcs-to-ccs.enabled:true}")
+    private Boolean imcsTOccsEnable;
+
     @Autowired
     private ProductionresourcePositionMapper productionresourcePositionMapper;
 
@@ -1598,6 +1607,74 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
         return R.success(data);
     }
 
+
+    @Autowired
+    private ZZoneService zoneService;
+
+    @Autowired
+    private ZZoneProductionresourceMapper zZoneProductionresourceMapper;
+    @Autowired
+    private CutterTestDataMapper cutterTestDataMapper;
+    @Override
+    //刀具上料确认过程
+    public R cutterRfidConfirmProcedure(Map<String, Object> map) {
+        /**
+         * 1、调用rfid接口获取rfid,如果没数据返回
+         * 2、根据rfid查询对刀仪表,确认此刀是符合进线要求的,
+         */
+
+        // 根据设备id查询设备信息 进行推送
+        Productionresource productionresource = productionresourceBizMapper.selectOne(Wraps.<Productionresource>lbQ().eq(Productionresource::getCode,map.get("code")));
+        if(productionresource == null){
+            return R.fail("没有查询到需求设备");
+        }
+
+        ZZone zZone = zoneService.getById(Long.parseLong(map.get("zoneId").toString()));
+        String url = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(zZone.getNo() + "_plc").toString());
+        url = url + "/api/findRfidData";
+
+        //LAUPT 刀具rfid
+        JSONObject object = new JSONObject();
+        object.put("Location","LAUPT");
+        JSONObject rfidObj = new JSONObject();
+        rfidObj.put("url", productionresource.getIp());
+        rfidObj.put("port", productionresource.getPort());
+        rfidObj.put("taskId", System.currentTimeMillis()+"1");
+        rfidObj.put("taskNodeId", System.currentTimeMillis()+"1");
+        rfidObj.put("data", object);
+
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
+        HttpEntity<String> formEntity = new HttpEntity<String>(rfidObj.toJSONString(), headers);
+
+        String s = null;
+        if(imcsTOccsEnable){
+            s = restTemplate.postForObject(url, formEntity, String.class);
+        }else {
+            s="{\"taskID\":\"1872123464509292544\",\"taskNodeID\":\"1872123575505080322\",\"result\":\"true\",\"resultMsg\":\"执行成功\",\"concurrency\":\"false\",\"data\":null,\"returnData\":{\"par1\":\"1\"}}\n";
+        }
+
+        JSONObject jsonObject = JSONObject.parseObject(s);
+        // 把机床下刀的数据同步过来,以保证二次入库,数据正确写入,只有在从机床出刀的时候才执行此代码
+        if(jsonObject.getString("result") ==null || jsonObject.getString("result").equals("false")){
+            return R.fail("调用ccs,获取rfid失败");
+        }
+        JSONObject returnData = jsonObject.getJSONObject("returnData");
+        String par1 = returnData.getString("par1");
+
+        // 根据读取的rfid检测对刀数据是否已经对刀过
+        CutterTestDataEntity cutterTestData = cutterTestDataMapper.selectOne(Wraps.<CutterTestDataEntity>lbQ().eq(CutterTestDataEntity::getCutterT, par1).
+                eq(CutterTestDataEntity::getStatus, 2));
+
+        if(Objects.isNull(cutterTestData)){
+            return R.fail("此刀具未经过对刀仪检测,刀柄号:"+par1);
+        }
+
+        Map data = new HashMap();
+        data.put("rfidCutterT",  cutterTestData.getCutterT());
+        return R.success(data);
+    }
+
     //确认当前工序零件下料状态
     public R confirmBaiting(Map<String, Object> map) {
         TaskNode taskNode = taskNodeService.getById(map.get("taskNodeId").toString());

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

@@ -243,6 +243,11 @@ public class TaskController extends SuperController<TaskService, Long, TTask, TT
         return baseService.confirmProcedure(map);
     }
 
+    @PostMapping("/cutterRfidConfirmProcedure")
+    public R cutterRfidConfirmProcedure(@RequestBody Map<String,Object> map) {
+        return baseService.cutterRfidConfirmProcedure(map);
+    }
+
     @PostMapping("/confirmBaiting")
     public R confirmBaiting(@RequestBody Map<String,Object> map) {
         return baseService.confirmBaiting(map);

+ 2 - 2
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/productionResourceCenter/StationUserController.java

@@ -226,9 +226,9 @@ public class StationUserController extends SuperController<StationUserService, L
     @ApiOperation(value = "新增刀具上料库位信息", notes = "新增刀具上料库位信息")
     @PostMapping("/addCutToolStockInfo")
     public R addCutToolStockInfo(@RequestBody Map<String,Object> model) {
-        if(!model.containsKey("RFID") || !model.containsKey("deviceId")) return R.fail("数据参数不全");
+        if(!model.containsKey("rfid") || !model.containsKey("deviceId")) return R.fail("数据参数不全");
         Long deviceId = Long.parseLong(model.get("deviceId").toString());
-        CuttingTool cuttingTool = cuttingToolService.getOne(new LbqWrapper<CuttingTool>().eq(CuttingTool::getCuttingToolNo, model.get("RFID").toString()).last("LIMIT 1"));
+        CuttingTool cuttingTool = cuttingToolService.getOne(new LbqWrapper<CuttingTool>().eq(CuttingTool::getCuttingToolNo, model.get("rfid").toString()).last("LIMIT 1"));
         ProductionresourcePosition productionresourcePosition = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getResourceId, deviceId).eq(ProductionresourcePosition::getStatus, "0").last("LIMIT 1"));
         StockInfo stockInfo = StockInfo.builder().goodsId(cuttingTool.getId()).specId(cuttingTool.getId()).num(1).goodsType("6").storgeId(productionresourcePosition.getStorgeId()).lockStatus("1").uniqueCode(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_UNIQUE)).build();
         stockInfoService.save(stockInfo);