| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | public void SNRetrieval(String Node, String value) throws Exception { |
| | | String[] parts = Node.split("[.]"); |
| | | if(value=="1") { |
| | | //SN号检索 |
| | | ClientHandler clientHandler=new ClientHandler(); |
| | | NodeEntity SN_node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".SNCode").value("").type("").build(); |
| | | String SNCode=clientHandler.read(SN_node); |
| | | |
| | | String a=daPassingStationCollectionService.SelectSN(SNCode); |
| | | |
| | | // 1:OK可生产 2:NG不可生产 3:NG可返工 4:PC检索失败(无记录)5:PC检索失败(软件) |
| | | NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".CodeCheckFeed").value(a).type("short").build(); |
| | | Boolean out1=clientHandler.write(node1); |
| | | DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); |
| | | PassingStationCollection.setSfcCode(SNCode); |
| | | PassingStationCollection.setLocationCode(parts[1]); |
| | | PassingStationCollection.setInboundTime(new Date()); |
| | | daPassingStationCollectionService.insertDaPassingStationCollection(PassingStationCollection); |
| | | } |
| | | } |
| | | public void SaveData(String Node, String value) throws Exception { |
| | | String[] parts = Node.split("[.]"); |
| | | if(value=="1") { |
| | | //采集数据最终保存 |
| | | ClientHandler clientHandler=new ClientHandler(); |
| | | NodeEntity SN_node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".SNCode").value("").type("").build(); |
| | | String SNCode=clientHandler.read(SN_node); |
| | | 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 PSC=new DaPassingStationCollection(); |
| | | PSC.setSfcCode(SNCode); |
| | | List<DaPassingStationCollection> LPSC=daPassingStationCollectionService.selectDaPassingStationCollectionList(PSC); |
| | | if(LPSC != null && LPSC.size() > 0){ |
| | | LPSC.get(0).setOutboundTime(new Date()); |
| | | LPSC.get(0).setCollectionTime(new Date()); |
| | | LPSC.get(0).setBeatTime(Long.toString(Math.abs(new Date().getTime() - LPSC.get(0).getInboundTime().getTime()))); |
| | | daPassingStationCollectionService.updateDaPassingStationCollection(LPSC.get(0)); |
| | | } |
| | | //请求最终保存反馈:1 保存完成 2 保存失败 3 保存失败,数据位超长 |
| | | NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".SaveFeedLast").value("1").type("short").build(); |
| | | Boolean out1=clientHandler.write(node1); |
| | | } |
| | | } |
| | | } |