|
@@ -1,11 +1,15 @@
|
|
package com.github.zuihou.business.externalApi.service.impl;
|
|
package com.github.zuihou.business.externalApi.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.github.zuihou.base.R;
|
|
import com.github.zuihou.base.R;
|
|
import com.github.zuihou.base.service.SuperCacheServiceImpl;
|
|
import com.github.zuihou.base.service.SuperCacheServiceImpl;
|
|
|
|
+import com.github.zuihou.business.basics.entity.TimingLogPo;
|
|
|
|
+import com.github.zuihou.business.basics.service.TimingLogService;
|
|
|
|
+import com.github.zuihou.business.basics.service.impl.TimingLogServiceImpl;
|
|
import com.github.zuihou.business.externalApi.dao.ThreeCoordinateMapper;
|
|
import com.github.zuihou.business.externalApi.dao.ThreeCoordinateMapper;
|
|
import com.github.zuihou.business.externalApi.dto.ThreeCoordinateDto;
|
|
import com.github.zuihou.business.externalApi.dto.ThreeCoordinateDto;
|
|
import com.github.zuihou.business.externalApi.entity.ThreeCoordinateEntity;
|
|
import com.github.zuihou.business.externalApi.entity.ThreeCoordinateEntity;
|
|
@@ -25,6 +29,7 @@ import org.springframework.http.MediaType;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -52,6 +57,9 @@ public class ThreeCoordinateImpl extends SuperCacheServiceImpl<ThreeCoordinateMa
|
|
@Autowired
|
|
@Autowired
|
|
private OrderQualityDetailsService orderQualityDetailsService;
|
|
private OrderQualityDetailsService orderQualityDetailsService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private TimingLogService timingLogService;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected String getRegion() {
|
|
protected String getRegion() {
|
|
@@ -89,73 +97,85 @@ public class ThreeCoordinateImpl extends SuperCacheServiceImpl<ThreeCoordinateMa
|
|
public R threeCoordinateTestResults(JSONObject json) {
|
|
public R threeCoordinateTestResults(JSONObject json) {
|
|
BaseContextHandler.setTenant("0000");
|
|
BaseContextHandler.setTenant("0000");
|
|
|
|
|
|
|
|
+ TimingLogPo timingLogPo = TimingLogPo.builder().groupNumber(System.currentTimeMillis() + "").jobCode(System.currentTimeMillis()+"").jobName("三坐标检测上报").executeTriggerType(2).executeStartTime(LocalDateTime.now()).build();
|
|
|
|
+ List executionInfos = new ArrayList();
|
|
|
|
+ JSONObject chuli = new JSONObject();
|
|
|
|
+
|
|
OrderQualityDetails orderQualityDetails = new OrderQualityDetails();
|
|
OrderQualityDetails orderQualityDetails = new OrderQualityDetails();
|
|
- if (json.containsKey("PLCCODE")) {
|
|
|
|
- orderQualityDetails.setDetectionCommand(json.getString("PLCCODE"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("测量时间")) {
|
|
|
|
- orderQualityDetails.setDetectionTime(json.getString("测量时间"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("测量温度")) {
|
|
|
|
- orderQualityDetails.setTemperature(json.getString("测量温度"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("测量湿度")) {
|
|
|
|
- orderQualityDetails.setHumidity(json.getString("测量湿度"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("测量人员")) {
|
|
|
|
- orderQualityDetails.setPersonnel(json.getString("测量人员"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("产品名称")) {
|
|
|
|
- orderQualityDetails.setProductName(json.getString("产品名称"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("图号")) {
|
|
|
|
- orderQualityDetails.setDrawing(json.getString("图号"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("工序号码")) {
|
|
|
|
- orderQualityDetails.setProcessNumber(json.getString("工序号码"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("零件号码")) {
|
|
|
|
- orderQualityDetails.setUniqueCode(json.getString("零件号码"));
|
|
|
|
- }
|
|
|
|
- if (json.containsKey("总OKNG")) {
|
|
|
|
- orderQualityDetails.setOkFlag(json.getString("总OKNG"));
|
|
|
|
- }
|
|
|
|
|
|
+ try {
|
|
|
|
+ if (json.containsKey("PLCCODE")) {
|
|
|
|
+ orderQualityDetails.setDetectionCommand(json.getString("PLCCODE"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("测量时间")) {
|
|
|
|
+ orderQualityDetails.setDetectionTime(json.getString("测量时间"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("测量温度")) {
|
|
|
|
+ orderQualityDetails.setTemperature(json.getString("测量温度"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("测量湿度")) {
|
|
|
|
+ orderQualityDetails.setHumidity(json.getString("测量湿度"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("测量人员")) {
|
|
|
|
+ orderQualityDetails.setPersonnel(json.getString("测量人员"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("产品名称")) {
|
|
|
|
+ orderQualityDetails.setProductName(json.getString("产品名称"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("图号")) {
|
|
|
|
+ orderQualityDetails.setDrawing(json.getString("图号"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("工序号码")) {
|
|
|
|
+ orderQualityDetails.setProcessNumber(json.getString("工序号码"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("零件号码")) {
|
|
|
|
+ orderQualityDetails.setUniqueCode(json.getString("零件号码"));
|
|
|
|
+ }
|
|
|
|
+ if (json.containsKey("总OKNG")) {
|
|
|
|
+ orderQualityDetails.setOkFlag(json.getString("总OKNG"));
|
|
|
|
+ }
|
|
|
|
|
|
- List list = new ArrayList<>();
|
|
|
|
- if (json.containsKey("MeasurementDatas")) {
|
|
|
|
|
|
+ List list = new ArrayList<>();
|
|
|
|
+ if (json.containsKey("MeasurementDatas")) {
|
|
|
|
|
|
- orderQualityDetails.setInspectionReport(JSONArray.toJSONString(json.getJSONArray("MeasurementDatas")));
|
|
|
|
|
|
+ orderQualityDetails.setInspectionReport(JSONArray.toJSONString(json.getJSONArray("MeasurementDatas")));
|
|
|
|
|
|
- JSONArray measurementDatas1 = json.getJSONArray("MeasurementDatas");
|
|
|
|
- for (int i = 0; i < measurementDatas1.size(); i++) {
|
|
|
|
- JSONObject oldJson = measurementDatas1.getJSONObject(i);
|
|
|
|
|
|
+ JSONArray measurementDatas1 = json.getJSONArray("MeasurementDatas");
|
|
|
|
+ for (int i = 0; i < measurementDatas1.size(); i++) {
|
|
|
|
+ JSONObject oldJson = measurementDatas1.getJSONObject(i);
|
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- jsonObject.put("ID",oldJson.containsKey("ID")?oldJson.getString("ID"):0);
|
|
|
|
- jsonObject.put("Code",oldJson.containsKey("Description")?oldJson.getString("Description"):"0");
|
|
|
|
- jsonObject.put("CheckValue", oldJson.containsKey("Actual_value")?oldJson.getString("Actual_value"):"0");
|
|
|
|
- jsonObject.put("NominalValue", oldJson.containsKey("Nominal_value")?oldJson.getString("Nominal_value"):"0");
|
|
|
|
- jsonObject.put("UTol", oldJson.containsKey("UTol")?oldJson.getString("UTol"):"0");
|
|
|
|
- jsonObject.put("LTol", oldJson.containsKey("LTol")?oldJson.getString("LTol"):"0");
|
|
|
|
- jsonObject.put("Dev", oldJson.containsKey("Dev")?oldJson.getString("Dev"):"0");
|
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.put("ID",oldJson.containsKey("ID")?oldJson.getString("ID"):0);
|
|
|
|
+ jsonObject.put("Code",oldJson.containsKey("Description")?oldJson.getString("Description"):"0");
|
|
|
|
+ jsonObject.put("CheckValue", oldJson.containsKey("Actual_value")?oldJson.getString("Actual_value"):"0");
|
|
|
|
+ jsonObject.put("NominalValue", oldJson.containsKey("Nominal_value")?oldJson.getString("Nominal_value"):"0");
|
|
|
|
+ jsonObject.put("UTol", oldJson.containsKey("UTol")?oldJson.getString("UTol"):"0");
|
|
|
|
+ jsonObject.put("LTol", oldJson.containsKey("LTol")?oldJson.getString("LTol"):"0");
|
|
|
|
+ jsonObject.put("Dev", oldJson.containsKey("Dev")?oldJson.getString("Dev"):"0");
|
|
|
|
|
|
- list.add(jsonObject);
|
|
|
|
|
|
+ list.add(jsonObject);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- orderQualityDetails.setPushReport(JSONArray.toJSONString(list));
|
|
|
|
|
|
|
|
|
|
+ orderQualityDetails.setPushReport(JSONArray.toJSONString(list));
|
|
|
|
|
|
- OrderQualityDetails qualityDetails = orderQualityDetailsService.getOne(Wraps.<OrderQualityDetails>lbQ().eq(OrderQualityDetails::getDetectionCommand, orderQualityDetails.getDetectionCommand()));
|
|
|
|
|
|
+ OrderQualityDetails qualityDetails = orderQualityDetailsService.getOne(Wraps.<OrderQualityDetails>lbQ().eq(OrderQualityDetails::getDetectionCommand, orderQualityDetails.getDetectionCommand()));
|
|
|
|
+ if (qualityDetails != null) {
|
|
|
|
+ orderQualityDetails.setId(qualityDetails.getId());
|
|
|
|
+ BeanUtils.copyProperties(orderQualityDetails, qualityDetails);
|
|
|
|
+ orderQualityDetailsService.updateById(qualityDetails);
|
|
|
|
+ } else {
|
|
|
|
+ orderQualityDetailsService.save(orderQualityDetails);
|
|
|
|
+ }
|
|
|
|
|
|
- if (qualityDetails != null) {
|
|
|
|
- orderQualityDetails.setId(qualityDetails.getId());
|
|
|
|
- BeanUtils.copyProperties(orderQualityDetails, qualityDetails);
|
|
|
|
- orderQualityDetailsService.updateById(qualityDetails);
|
|
|
|
- } else {
|
|
|
|
- orderQualityDetailsService.save(orderQualityDetails);
|
|
|
|
|
|
+ timingLogPo.setJobCode(orderQualityDetails.getPersonnel()).setJobName("三坐标检测上报:"+ orderQualityDetails.getInspectionReport());
|
|
|
|
+ chuli.put("success", LocalDateTime.now()+"_"+orderQualityDetails.getInspectionReport());
|
|
|
|
+ executionInfos.add(chuli);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ chuli.put("error", LocalDateTime.now()+"_上报信息:"+ JSON.toJSONString(json)+";异常信息:" +e.getMessage());
|
|
|
|
+ executionInfos.add(chuli);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ timingLogService.addOne(timingLogPo);
|
|
return R.success();
|
|
return R.success();
|
|
}
|
|
}
|
|
|
|
|