hdy
2024-07-13 d9502f15ba2829816b466385df558ce266a8e197
jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/controller/DaPassingStationCollectionController.java
@@ -157,15 +157,25 @@
    public AjaxResult initializedData(@RequestParam String sfcCode, @RequestParam String locationCode) {
        try {
            String nodeId = "CFL4CVT." + locationCode + ".MesSNCode";
            ReadWriteEntity entity = new ReadWriteEntity(nodeId, sfcCode);
            miloService.writeToOpcUa(entity);
            String SaveSNCode ="CFL4CVT." + locationCode + ".SaveSNCode";
            ReadWriteEntity SaveSNCodeEntity = new ReadWriteEntity(SaveSNCode, 11);
            miloService.writeToOpcUa(SaveSNCodeEntity);
            return AjaxResult.success("SFC Code updated successfully");
            String str = "CFL4CVT."+locationCode+".RecordData";
            Object recordDataObject = miloService.readFromOpcUa(str).getValue();
            if(Integer.valueOf(recordDataObject.toString())== 1){
                miloService.writeToOpcUa(ReadWriteEntity.builder().identifier("CFL4CVT." + locationCode + ".MesSNCode").value(sfcCode).build());
                ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT." + locationCode + ".MesRecordDataDone", 11);
                miloService.writeToOpcShort(entity);
                return AjaxResult.success("扫码成功");
            }else {
                return AjaxResult.error(500,"未进站禁止扫码");
            }
//            ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT." + locationCode + ".MesSNCode", sfcCode);
//            miloService.writeToOpcChar(entity);
//            String nodeId = "CFL4CVT." + locationCode + ".MesSNCode";
//            String SaveSNCode ="CFL4CVT." + locationCode + ".SaveSNCode";
//            ReadWriteEntity SaveSNCodeEntity = new ReadWriteEntity(SaveSNCode, 11);
//            miloService.writeToOpcShort(SaveSNCodeEntity);
//            return AjaxResult.success("SFC Code updated successfully");
        } catch (Exception e) {
            throw new RuntimeException("Failed to update SFC Code in OPC UA", e);
            throw new RuntimeException("扫码错误", e);
        }
    }