hdy
2024-07-10 a4362dfe3e0e9c6fad426685da0065455799d018
cvt交互逻辑更新
已修改5个文件
164 ■■■■■ 文件已修改
jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/controller/DaPassingStationCollectionController.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/plcserver/callback/InitCallback.java 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/plcserver/init/CustomRunner.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-ui/src/api/main/da/passingStationCollection/passingStationCollection.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-ui/src/views/main/kb/cvt/index.vue 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/controller/DaPassingStationCollectionController.java
@@ -157,13 +157,23 @@
    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);
        }
jcdm-main/src/main/java/com/jcdm/main/plcserver/callback/InitCallback.java
@@ -54,53 +54,31 @@
        String ecpStr = "";//异常记录标记
        try {
            if (null != value) {
                //BCOP40进站校验
                if (identifier.equals("CFL4CVT.BCOP040.RecordData") && null != value && "1".equals(value.toString())) {
                    //待添加从过站采集表取sfc_code写入plc的sncode方法
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP040.MesRecordDataDone", 11);
                    miloService.writeToOpcByte(entity);
                //BCOP010出站校验
                if (identifier.equals("CFL4CVT.BCOP010.RecordData") && null != value && "2".equals(value.toString())) {
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP010.MesRecordDataDone", 21);
                    miloService.writeToOpcShort(entity);
                }
                //BCOP40出站校验
                else if (identifier.equals("CFL4CVT.BCOP040.RecordData") && null != value && "2".equals(value.toString())) {
                    SaveData("CFL4CVT.BCOP40.RecordData");
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP040.MesRecordDataDone", 21);
                    miloService.writeToOpcByte(entity);
                }
                //BCOP60进站校验
                else if (identifier.equals("CFL4CVT.BCOP060.RecordData") && null != value && "1".equals(value.toString())) {
                    //待添加从过站采集表取sfc_code写入plc的sncode方法
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP060.MesRecordDataDone", 11);
                    miloService.writeToOpcByte(entity);
                    SaveData("CFL4CVT.BCOP040.RecordData");
                }
                //BCOP60出站校验
                else if (identifier.equals("CFL4CVT.BCOP060.RecordData") && null != value && "2".equals(value.toString())) {
                    SaveData("CFL4CVT.BCOP060.RecordData");
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP060.MesRecordDataDone", 21);
                    miloService.writeToOpcByte(entity);
                }
                //BCOP100进站校验
                else if (identifier.equals("CFL4CVT.BCOP100.RecordData") && null != value && "1".equals(value.toString())) {
                    //待添加从过站采集表取sfc_code写入plc的sncode方法
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP100.MesRecordDataDone", 11);
                    miloService.writeToOpcByte(entity);
                }
                //BCOP100出站校验
                else if (identifier.equals("CFL4CVT.BCOP100.RecordData") && null != value && "2".equals(value.toString())) {
                    SaveData("CFL4CVT.BCOP100.RecordData");
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BCOP100.MesRecordDataDone", 21);
                    miloService.writeToOpcByte(entity);
                }//BP020进站校验
                else if (identifier.equals("CFL4CVT.BP020.RecordData") && null != value && "1".equals(value.toString())) {
                    //待添加从过站采集表取sfc_code写入plc的sncode方法
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BP020.MesRecordDataDone", 11);
                    miloService.writeToOpcByte(entity);
                }
                //BP020出站校验
                else if (identifier.equals("CFL4CVT.BP020.RecordData") && null != value && "2".equals(value.toString())) {
                    SaveData("CFL4CVT.BP020.RecordData");
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.BP020.MesRecordDataDone", 21);
                    miloService.writeToOpcByte(entity);
                }
                else if(identifier.equals("CFL4CVT.OP220.RecordData") && null != value && "2".equals(value.toString())) {
                    ReadWriteEntity entity = new ReadWriteEntity("CFL4CVT.OP220.MesRecordDataDone", 21);
                    miloService.writeToOpcShort(entity);
                }
            }
@@ -114,11 +92,56 @@
        }
    }
//    public void SaveData(String Node) throws Exception {
//        String[] parts = Node.split("[.]");
//        Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code1").getValue();
//
//        if (null != SNCodeObject) {
//            String SNCode = SNCodeObject.toString();
//            List<DaCollectionParamConf> list;
//            DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
//            daCollectionParamConf.setGatherAddress(parts[0] + "." + parts[1]);
//            list = collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf);
//
//            List<String> nodeIdList = list.stream().map(info -> {
//                String nodeid = info.getGatherAddress();
//                return nodeid;
//            }).collect(Collectors.toList());
//
//            if (!nodeIdList.isEmpty()) {
//                List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(nodeIdList);
//                List<DaParamCollection> daParamCollectionlist = new ArrayList<>();
//                for (int i = 0; i < nodeIdList.size(); i++) {
//                    DaParamCollection ParamCollection = new DaParamCollection();
//                    if (!readWriteEntityList.get(i).getValue().toString().equals("0.0")) {
//                        ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]);
//                        ParamCollection.setLocationCode(parts[1]);
//                        Object value = readWriteEntityList.get(i).getValue();
//                        if (ObjectUtils.isNotEmpty(value)) {
//                            String string = value.toString();
//                            ParamCollection.setParamValue(string);
//                        }
//                        ParamCollection.setSfcCode(SNCode);
//                        ParamCollection.setParamName(list.get(i).getCollectParameterName());
//                        ParamCollection.setParamUpper(list.get(i).getParamUpper());
//                        ParamCollection.setParamLower(list.get(i).getParamLower());
//                        ParamCollection.setUnit(list.get(i).getCollectParameterUnit());
//                        ParamCollection.setState("合格");
//                        ParamCollection.setType(list.get(i).getCollectParameterType());
//                        ParamCollection.setCollectionTime(new Date());
//                        daParamCollectionlist.add(ParamCollection);
//                    }
//                }
//                daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist);
//            }
//        }
//    }
    public void SaveData(String Node) throws Exception {
        String[] parts = Node.split("[.]");
        Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code1").getValue();
        if (null != SNCodeObject) {
        Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".RecordData").getValue();
        if(null != SNCodeObject)
        {
            String SNCode = SNCodeObject.toString();
            List<DaCollectionParamConf> list;
            DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
@@ -130,19 +153,15 @@
                return nodeid;
            }).collect(Collectors.toList());
            if (!nodeIdList.isEmpty()) {
            if(!nodeIdList.isEmpty()){
                List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(nodeIdList);
                List<DaParamCollection> daParamCollectionlist = new ArrayList<>();
                for (int i = 0; i < nodeIdList.size(); i++) {
                for(int i=0;i<nodeIdList.size();i++){
                    DaParamCollection ParamCollection = new DaParamCollection();
                    if (!readWriteEntityList.get(i).getValue().toString().equals("0.0")) {
                    if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){
                        ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]);
                        ParamCollection.setLocationCode(parts[1]);
                        Object value = readWriteEntityList.get(i).getValue();
                        if (ObjectUtils.isNotEmpty(value)) {
                            String string = value.toString();
                            ParamCollection.setParamValue(string);
                        }
                        ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
                        ParamCollection.setSfcCode(SNCode);
                        ParamCollection.setParamName(list.get(i).getCollectParameterName());
                        ParamCollection.setParamUpper(list.get(i).getParamUpper());
@@ -155,13 +174,11 @@
                    }
                }
                daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist);
                ReadWriteEntity entity = new ReadWriteEntity(parts[0] + "." + parts[1]   +".MesRecordDataDone", 21);
                miloService.writeToOpcShort(entity);
            }
        }
    }
    public void WriteSNCode(String Node) throws Exception {
    }
}
jcdm-main/src/main/java/com/jcdm/main/plcserver/init/CustomRunner.java
@@ -45,6 +45,7 @@
                daTileMatchRulesService);
        List<String> lists = getList();
        System.out.println("订阅内容:"+lists);
        miloService.subscriptionFromOpcUa(lists,InitCallback);
    }
@@ -56,7 +57,13 @@
        lists.add("CFL4CVT.BCOP060.RecordData");//请求保存
        lists.add("CFL4CVT.BCOP100.RecordData");//请求保存
        lists.add("CFL4CVT.BP020.RecordData");//请求保存
        lists.add("CFL4CVT.OP220.RecordData");//请求保存
        lists.add("CFL4CVT.BCOP010.MesRecordDataDone");//请求保存
        lists.add("CFL4CVT.BCOP040.MesRecordDataDone");//请求保存
        lists.add("CFL4CVT.BCOP060.MesRecordDataDone");//请求保存
        lists.add("CFL4CVT.BCOP100.MesRecordDataDone");//请求保存
        lists.add("CFL4CVT.BP020.MesRecordDataDone");//请求保存
        lists.add("CFL4CVT.OP220.MesRecordDataDone");//请求保存
        return lists;
    }
}
jcdm-ui/src/api/main/da/passingStationCollection/passingStationCollection.js
@@ -78,7 +78,7 @@
export function initializedData(query) {
  return request({
    url: '/da/passingStationCollection/',
    url: '/da/passingStationCollection/initializedData',
    method: 'get',
    params: query
  })
jcdm-ui/src/views/main/kb/cvt/index.vue
@@ -94,7 +94,7 @@
      engineCheckList:[],
      showFlag:false,
      buttondisabled:true,
      locationCode: "未配置工位",
      locationCode: "未配置IP",
      locationName: "未配置工位",
      scannerFlag: false,
@@ -159,13 +159,19 @@
        this.scannerFlag = true
        console.log("条码:",this.form.engineNo)
        if(this.form.engineNo !== null && this.form.engineNo !== undefined) {
          addPassingStationCollection({sfcCode:this.form.engineNo,locationCode:this.locationCode}).then(res =>{
            console.log("rrrrr",res)
          })
          if(this.locationCode === 'BCOP040'|| this.locationCode === 'BCOP060'|| this.locationCode === 'BCOP100'|| this.locationCode === 'BP020' ){
          console.log("条码2:",this.locationCode)
            initializedData({sfcCode:this.form.engineNo,locationCode:this.locationCode}).then(res =>{
              if(res.code===500){
                  this.$createElement;
              }else {
                addPassingStationCollection({sfcCode:this.form.engineNo,locationCode:this.locationCode}).then(res =>{
                  console.log("rrrrr",res)})
                this.$message({
                  message: '扫码成功',
                  type: 'success'
                });
              }
            })
          }
        }else{
          this.reset();
          this.buttondisabled = true