Browse Source

fix:三坐标检测结果

wang.sq@aliyun.com 3 weeks ago
parent
commit
918a01cbe0

+ 3 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/ThreeCoordinateService.java

@@ -1,5 +1,6 @@
 package com.github.zuihou.business.externalApi.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
@@ -23,5 +24,7 @@ public interface ThreeCoordinateService extends SuperCacheService<ThreeCoordinat
 
     R acceptTheInspectionTask(ThreeCoordinateEntity threeCoordinateEntity);
 
+    R threeCoordinateTestResults(JSONObject json);
+
     R pushDetectionData();
 }

+ 74 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/ThreeCoordinateImpl.java

@@ -1,5 +1,6 @@
 package com.github.zuihou.business.externalApi.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -9,7 +10,11 @@ import com.github.zuihou.business.externalApi.dao.ThreeCoordinateMapper;
 import com.github.zuihou.business.externalApi.dto.ThreeCoordinateDto;
 import com.github.zuihou.business.externalApi.entity.ThreeCoordinateEntity;
 import com.github.zuihou.business.externalApi.service.ThreeCoordinateService;
+import com.github.zuihou.business.operationManagementCenter.dao.OrderQualityMapper;
+import com.github.zuihou.business.operationManagementCenter.entity.Order;
+import com.github.zuihou.business.operationManagementCenter.entity.OrderQuality;
 import com.github.zuihou.business.operationManagementCenter.entity.Plan;
+import com.github.zuihou.business.operationManagementCenter.service.OrderService;
 import com.github.zuihou.business.util.ManualTaskOperatorUtil;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.ParameterKey;
@@ -50,6 +55,12 @@ public class ThreeCoordinateImpl extends SuperCacheServiceImpl<ThreeCoordinateMa
     @Autowired
     private MsgUtil msgUtil;
 
+    @Autowired
+    private OrderQualityMapper orderQualityMapper;
+
+    @Autowired
+    private OrderService orderService;
+
     @Override
     protected String getRegion() {
         return null;
@@ -82,6 +93,69 @@ public class ThreeCoordinateImpl extends SuperCacheServiceImpl<ThreeCoordinateMa
         return R.success();
     }
 
+    @Override
+    public R threeCoordinateTestResults(JSONObject json) {
+        BaseContextHandler.setTenant("0000");
+
+        OrderQuality orderQuality = new OrderQuality();
+        if(json.containsKey("PLCCODE")){
+            orderQuality.setDetectionCommand(json.getString("PLCCODE"));
+        }
+        if(json.containsKey("总OKNG")){
+            orderQuality.setOkFlag(json.getString("总OKNG"));
+        }
+        if(json.containsKey("PLCCODE")){
+            orderQuality.setDetectionCommand(json.getString("PLCCODE"));
+            // 图号+零件号+工序+是否成毛坯+程序名+任务号+人员编号+订单号+批次
+            String[] split = orderQuality.getDetectionCommand().split("&");
+
+            Order one = orderService.getOne(Wraps.<Order>lbQ().eq(Order::getOrderNo, split[7]));
+            if(one ==null){
+                log.error("====没有查询到订单信息====");
+                throw new BizException("====没有查询到订单信息====");
+            }
+            orderQuality.setOrderId(one.getId());
+            orderQuality.setOrderNo(one.getOrderNo());
+
+
+        }
+        if(json.containsKey("MeasurementDatas")){
+            orderQuality.setMeasuringReport(JSONArray.toJSONString(json.getJSONArray("MeasurementDatas")));
+            orderQuality.setMeasuringType(1);
+        }else {
+            orderQuality.setMeasuringType(2);
+        }
+
+        List list = new ArrayList<>();
+        if(json.containsKey("MeasurementDatas")){
+            JSONArray measurementDatas1 = json.getJSONArray("MeasurementDatas");
+            for (int i = 0; i < measurementDatas1.size(); i++) {
+                JSONObject oldJson = measurementDatas1.getJSONObject(i);
+
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("Code",oldJson.getString("Description"));
+                jsonObject.put("CheckValue",oldJson.getString("Actual_value"));
+
+                list.add(jsonObject);
+            }
+        }
+
+        orderQuality.setMeasuringReport(JSONArray.toJSONString(list));
+
+        OrderQuality quality = orderQualityMapper.selectOne(Wraps.<OrderQuality>lbQ().eq(OrderQuality::getDetectionCommand, orderQuality.getDetectionCommand()));
+
+        if(quality!=null){
+            BeanUtils.copyProperties(orderQuality, quality);
+            orderQualityMapper.updateById(quality);
+        }else {
+            quality = new OrderQuality();
+            BeanUtils.copyProperties(orderQuality, quality);
+            orderQualityMapper.insert(quality);
+        }
+
+        return R.success();
+    }
+
     @Override
     public R pushDetectionData() {
         BaseContextHandler.setTenant("0000");

+ 5 - 23
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/ThreeDimensionalControl.java

@@ -29,6 +29,8 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -50,9 +52,6 @@ public class ThreeDimensionalControl  extends SuperController<ThreeCoordinateSer
     @Autowired
     private ThreeCoordinateService threeCoordinateService;
 
-    @Autowired
-    private OrderQualityMapper orderQualityMapper;
-
     @ApiOperation(value = "分页查询线外质检任务", notes = "分页查询线外质检任务")
     @PostMapping("/pageList")
     public R<IPage<ThreeCoordinateEntity>> getCutterPage(@RequestBody @Validated PageParams<ThreeCoordinateEntity> params) {
@@ -79,26 +78,9 @@ public class ThreeDimensionalControl  extends SuperController<ThreeCoordinateSer
     public R threeCoordinateTestResults(@RequestBody JSONObject json) throws Exception{
         log.info("====================接受三坐标数据===================={}",json);
 
-        OrderQuality orderQuality = new OrderQuality();
-        if(json.containsKey("PLCCODE")){
-            orderQuality.setDetectionCommand(json.getString("PLCCODE"));
-        }
-        if(json.containsKey("总OKNG")){
-            orderQuality.setOkFlag(json.getString("总OKNG"));
-        }
-        if(json.containsKey("MeasurementDatas")){
-            orderQuality.setMeasuringReport(JSONArray.toJSONString(json.getJSONArray("MeasurementDatas")));
-        }
-        OrderQuality quality = orderQualityMapper.selectOne(Wraps.<OrderQuality>lbQ().eq(OrderQuality::getDetectionCommand, orderQuality.getDetectionCommand()));
-
-        if(quality!=null){
-            BeanUtils.copyProperties(orderQuality, quality);
-            orderQualityMapper.updateById(quality);
-        }else {
-            orderQualityMapper.insert(quality);
-        }
-
-        return R.success();
+        R r = threeCoordinateService.threeCoordinateTestResults(json);
+
+        return r;
     }