|
@@ -16,6 +16,7 @@ import com.github.zuihou.business.cutterdata.utils.CutterFile;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.TTask;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.CuttingTool;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.CuttingToolConfig;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.CuttingToolService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
|
|
|
import com.github.zuihou.business.productionResourceCenter.dao.ZZoneProductionresourceMapper;
|
|
@@ -48,6 +49,7 @@ import java.time.ZonedDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* @Project: imcs-admin-boot
|
|
@@ -88,8 +90,10 @@ public class CutterTestDataServiceImpl extends SuperServiceImpl<CutterTestDataMa
|
|
|
@Autowired
|
|
|
private ProductionresourceBizMapper productionresourceBizMapper;
|
|
|
|
|
|
+ private String CheckCUtter="MES_CUTTER:CHECK_CUTTER_HAVE_READ";
|
|
|
+
|
|
|
@Override
|
|
|
- public String findCutterTestData() throws Exception {
|
|
|
+ public String findCutterTestData(CuttingTool cuttingTool){
|
|
|
log.info("===================定时获取机外对刀仪数据start===================");
|
|
|
|
|
|
List<File> needFile = new ArrayList<>();
|
|
@@ -103,13 +107,21 @@ public class CutterTestDataServiceImpl extends SuperServiceImpl<CutterTestDataMa
|
|
|
CutterFile.findFileS(needFile, new ArrayList<>(), new ArrayList<>(), CutterSharedPath, "test.xml");
|
|
|
|
|
|
if (needFile.isEmpty()) {
|
|
|
- return "需要解析的文件为空";
|
|
|
+ throw new RuntimeException("需要解析的文件为空");
|
|
|
}
|
|
|
|
|
|
List<CutterTestDataEntity> cutterTestDataEntities = new ArrayList<>();
|
|
|
List<String> cutterTs = new ArrayList<>();
|
|
|
|
|
|
+
|
|
|
for (File file : needFile) {
|
|
|
+ // 比对此文件是不是已经读取过
|
|
|
+ long lastModifiedTime = file.lastModified();
|
|
|
+ Object o = msgUtil.redis_get(CheckCUtter);
|
|
|
+ if(Objects.nonNull(o) && lastModifiedTime==Long.parseLong(o.toString())){
|
|
|
+ throw new RuntimeException("此刀具已经采集入库");
|
|
|
+ }
|
|
|
+
|
|
|
CutterTestDataEntity build = CutterTestDataEntity.builder().filePath(file.getPath()).build();
|
|
|
try {
|
|
|
SAXReader saxReader = new SAXReader();
|
|
@@ -117,6 +129,10 @@ public class CutterTestDataServiceImpl extends SuperServiceImpl<CutterTestDataMa
|
|
|
org.dom4j.Element root = document.getRootElement();
|
|
|
JSONObject json = CutterFile.findXmlData(root);
|
|
|
|
|
|
+ if(!cuttingTool.getCuttingToolNo().toString().equals(json.getJSONObject("ToolList").getJSONObject("Tools").getString("PTN"))){
|
|
|
+ throw new RuntimeException("刀柄号数据不一致");
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
build.setStatus(2);
|
|
|
build.setFilePath(file.getPath());
|
|
@@ -127,7 +143,7 @@ public class CutterTestDataServiceImpl extends SuperServiceImpl<CutterTestDataMa
|
|
|
build.setCutterTyp(json.getJSONObject("ToolList").getJSONObject("Tools").getString("ToolType"));
|
|
|
|
|
|
String substring = json.getJSONObject("ToolList").getJSONObject("Tools").getString("ToolType");
|
|
|
- if (CutterTypeContrastEnum.getDncType(substring.substring(0, 1)) == null) { //说明此类型就是主类不是子类
|
|
|
+ if (Objects.isNull(substring) || CutterTypeContrastEnum.getDncType(substring.substring(0, 1)) == null) { //说明此类型就是主类不是子类
|
|
|
build.setCutterTypDnc(CutterTypeContrastEnum.getDncType(substring) == null ? "99" : CutterTypeContrastEnum.getDncType(substring));
|
|
|
build.setCutterTypSubDnc("99");
|
|
|
} else {
|
|
@@ -172,24 +188,27 @@ public class CutterTestDataServiceImpl extends SuperServiceImpl<CutterTestDataMa
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- log.info("机外对刀仪字段解析失败");
|
|
|
- build.setStatus(0);
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException("机外对刀仪字段解析失败");
|
|
|
}
|
|
|
|
|
|
cutterTs.add(build.getCutterT());
|
|
|
cutterTestDataEntities.add(build);
|
|
|
} catch (DocumentException e) {
|
|
|
- log.info("机外对刀仪获取数据失败");
|
|
|
e.printStackTrace();
|
|
|
+ throw new RuntimeException("机外对刀仪获取数据失败");
|
|
|
}
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(cutterTestDataEntities.get(0),cuttingTool);
|
|
|
+
|
|
|
+ //此文件写入到redis中,确认已经读取过此文件的数据,不需要重复读取
|
|
|
+ msgUtil.redis_set(CheckCUtter, lastModifiedTime);
|
|
|
}
|
|
|
|
|
|
for (CutterTestDataEntity cutterTestDataEntity : cutterTestDataEntities) {
|
|
|
- QueryWrapper queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("cutter_name", cutterTestDataEntity.getCutterName());
|
|
|
- queryWrapper.eq("cutter_t", cutterTestDataEntity.getCutterT());
|
|
|
//新增或修改刀具数据
|
|
|
- this.saveOrUpdate(cutterTestDataEntity, queryWrapper);
|
|
|
+ this.remove(Wraps.<CutterTestDataEntity>lbQ().eq(CutterTestDataEntity::getCutterT, cutterTestDataEntity.getCutterT()));
|
|
|
+ this.save(cutterTestDataEntity);
|
|
|
}
|
|
|
|
|
|
log.info("===================定时获取机外对刀仪数据end===================");
|
|
@@ -311,6 +330,8 @@ public class CutterTestDataServiceImpl extends SuperServiceImpl<CutterTestDataMa
|
|
|
}
|
|
|
|
|
|
File file = needFile.get(0);
|
|
|
+ CuttingTool one = new CuttingTool();
|
|
|
+ Integer decimal = null;
|
|
|
try {
|
|
|
SAXReader saxReader = new SAXReader();
|
|
|
org.dom4j.Document document = saxReader.read(file);
|
|
@@ -321,11 +342,9 @@ public class CutterTestDataServiceImpl extends SuperServiceImpl<CutterTestDataMa
|
|
|
JSONObject jsonObject = JSONObject.parseObject(xmlArrayDatum.toString());
|
|
|
if("刀具号".equals(jsonObject.getString("name"))){
|
|
|
String segment = jsonObject.getString("Segment").replace(" ","");
|
|
|
- int decimal = Integer.parseInt(segment, 16);
|
|
|
-
|
|
|
- CuttingTool one = cuttingToolService.getOne(Wraps.<CuttingTool>lbQ().eq(CuttingTool::getCuttingToolNo, decimal));
|
|
|
+ decimal = Integer.parseInt(segment, 10);
|
|
|
|
|
|
- return one;
|
|
|
+ one = cuttingToolService.getOne(Wraps.<CuttingTool>lbQ().eq(CuttingTool::getCuttingToolNo, decimal));
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -337,7 +356,20 @@ public class CutterTestDataServiceImpl extends SuperServiceImpl<CutterTestDataMa
|
|
|
e.printStackTrace();
|
|
|
throw new BizException("机外对刀仪rfid对象文件获取失败");
|
|
|
}
|
|
|
- return null;
|
|
|
+
|
|
|
+ if(one ==null){
|
|
|
+ throw new BizException("基础数据无此刀具号:"+ decimal);
|
|
|
+ }
|
|
|
+
|
|
|
+ //对刀数据读取
|
|
|
+ try {
|
|
|
+ this.findCutterTestData(one);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new BizException(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return one;
|
|
|
}
|
|
|
|
|
|
|