春风项目四线(合箱线、总装线)
yyt
2024-02-17 386e107222d673a1ea2781a03a7b1b1d28212f58
更新OPCUA
已修改2个文件
71 ■■■■■ 文件已修改
jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/resources/mapper/da/collectionParamConf/DaCollectionParamConfMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java
@@ -25,6 +25,70 @@
    private IDaParamCollectionService daParamCollectionService = BeanUtils.getBean(IDaParamCollectionService.class);
    private IDaPassingStationCollectionService daPassingStationCollectionService = BeanUtils.getBean(IDaPassingStationCollectionService.class);
    public void Transit(String Node, String value) throws Exception {
        //log.info(Node+":"+value);
        String[] parts = Node.split("[.]");
        ClientHandler clientHandler=new ClientHandler();
        switch (value) {
            case "0":   //初始
                NodeEntity node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("0").type("short").build();
                Boolean out=clientHandler.write(node);
                log.info("节点:{},响应结果:{}", node.getIdentifier(),out);
                break;
            case "1":   //请求下发进站状态
                NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("11").type("short").build();
                Boolean out1=clientHandler.write(node1);
                log.info("节点:{},响应结果:{}", node1.getIdentifier(),out1);
                break;
            case "2":   //请求记录工位数据
                NodeEntity SN_node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".SNCode").value("").type("").build();
                String SNCode=clientHandler.read(SN_node);
                log.info("读取节点:{},结果:{}", SN_node.getIdentifier(),SNCode);
                if(SNCode==null){
                    NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("22").type("short").build();
                    Boolean out2=clientHandler.write(node2);
                    break;
                }
                List<DaCollectionParamConf> b;
                DaCollectionParamConf daCollectionParamConf=new DaCollectionParamConf();
                daCollectionParamConf.setGatherAddress(parts[0]+"."+parts[1]);
                b=collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf);
                List<NodeId> nodeId = b.stream().map(info -> {
                    NodeId nodeid = new NodeId(2,info.getGatherAddress());
                    return nodeid;
                }).collect(Collectors.toList());
                List<DataValue> s=readValues(nodeId);
                //保存PLC采集数据
                for(int i=0;i<nodeId.size();i++)
                {
                    DaParamCollection Config=new DaParamCollection();
                    Config.setParamCode(nodeId.get(i).getIdentifier().toString().split("[.]")[2]);
                    Config.setLocationCode(nodeId.get(i).getIdentifier().toString().split("[.]")[1]);
                    Config.setParamValue(s.get(i).getValue().getValue().toString());
                    Config.setSfcCode(SNCode);
                    Config.setParamName(b.get(i).getGatherAddress());
                    daParamCollectionService.insertDaParamCollection(Config);
                }
                //记录过站,并计算节拍。
                DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
                PassingStationCollection.setSfcCode(SNCode);
                PassingStationCollection.setLocationCode(parts[1]);
                PassingStationCollection.setInboundTime(new Date());
                PassingStationCollection.setOutboundTime(new Date());
                PassingStationCollection.setCollectionTime(new Date());
                PassingStationCollection.setBeatTime("56");
                daPassingStationCollectionService.insertDaPassingStationCollection(PassingStationCollection);
                //更新PLC节点状态
                NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("21").type("short").build();
                Boolean out2=clientHandler.write(node2);
                log.info("节点:{},响应结果:{}", node2.getIdentifier(),out2);
                break;
            default:
                break;
        }
    }
    public void Transit2(String Node, String value) throws Exception {
        log.info(Node+":"+value);
        String[] parts = Node.split("[.]");
        ClientHandler clientHandler=new ClientHandler();
@@ -33,12 +97,12 @@
        log.info("读取节点:{},结果:{}", SN_node.getIdentifier(),SNCode);
        switch (value) {
            case "0":   //初始
                NodeEntity node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("0").type("short").build();
                NodeEntity node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("0").type("short").build();
                Boolean out=clientHandler.write(node);
                log.info("节点:{},响应结果:{}", node.getIdentifier(),out);
                break;
            case "1":   //请求下发进站状态
                NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("11").type("short").build();
                NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("11").type("short").build();
                Boolean out1=clientHandler.write(node1);
                DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
                PassingStationCollection.setSfcCode(SNCode);
@@ -80,7 +144,7 @@
                    daPassingStationCollectionService.updateDaPassingStationCollection(LPSC.get(0));
                }
                //更新PLC节点状态
                NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("21").type("short").build();
                NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("21").type("short").build();
                Boolean out2=clientHandler.write(node2);
                log.info("节点:{},响应结果:{}", node2.getIdentifier(),out2);
                break;
jcdm-main/src/main/resources/mapper/da/collectionParamConf/DaCollectionParamConfMapper.xml
@@ -47,6 +47,7 @@
            <if test="contrastParameterFlag != null  and contrastParameterFlag != ''"> and contrast_parameter_flag like concat('%', #{contrastParameterFlag}, '%')</if>
            <if test="collectParameterType != null  and collectParameterType != ''"> and collect_parameter_type like concat('%', #{collectParameterType}, '%')</if>
            <if test="productCode != null  and productCode != ''"> and product_code like concat('%', #{productCode}, '%')</if>
            <if test="gatherAddress != null  and gatherAddress != ''"> and gather_address like concat('%', #{gatherAddress}, '%')</if>
        </where>
    </select>