| | |
| | | package com.jcdm.main.da.opcuaconfig.controller; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; |
| | | import com.jcdm.main.da.opcuaconfig.domain.NodeEntity; |
| | | import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService; |
| | | import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
| | | import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
| | | import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
| | | import com.jcdm.main.da.tileMatchCollection.domain.DaTileMatchCollection; |
| | | import com.jcdm.main.da.tileMatchCollection.service.IDaTileMatchCollectionService; |
| | | import com.jcdm.main.da.tileMatchMiddleware.domain.DaTileMatchMiddleware; |
| | | import com.jcdm.main.da.tileMatchMiddleware.service.IDaTileMatchMiddlewareService; |
| | | import com.jcdm.main.da.tileMatchRules.domain.DaTileMatchRules; |
| | | import com.jcdm.main.da.tileMatchRules.service.IDaTileMatchRulesService; |
| | | import com.jcdm.main.plcserver.sub.OPCUaSubscription; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | { |
| | | @Autowired |
| | | private IDaOpcuaConfigService daOpcuaConfigService; |
| | | @Autowired |
| | | private IDaParamCollectionService daParamCollectionService; |
| | | @Autowired |
| | | private IDaTileMatchRulesService daTileMatchRulesService; |
| | | @Autowired |
| | | private IDaTileMatchMiddlewareService daTileMatchMiddlewareService; |
| | | @Resource |
| | | private IDaTileMatchCollectionService daTileMatchCollectionService; |
| | | |
| | | /** |
| | | * 查询交互信号配置列表 |
| | |
| | | * 配瓦扫码 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')") |
| | | @GetMapping(value = "/barcode/{barcode}/{locationCode}") |
| | | public AjaxResult setBarcode(@PathVariable("barcode") String barcode,@PathVariable("locationCode") String locationCode) { |
| | | Boolean out= true; |
| | | @GetMapping(value = "/barcode1") |
| | | public DaParamCollection setBarcode1(String barcode,String locationCode) { |
| | | Boolean out = true; |
| | | DaParamCollection xParamCollection = null; |
| | | try { |
| | | Object SNCodeObject = miloService.readFromOpcUa("CFL4HX."+locationCode+".Code1").getValue(); |
| | | if (null == SNCodeObject){ |
| | | SNCodeObject = miloService.readFromOpcUa("CFL4HX."+locationCode+ ".Code").getValue(); |
| | | Object SNCodeObject = miloService.readFromOpcUa("CFL4HX." + locationCode + ".Code1").getValue(); |
| | | if (null == SNCodeObject) { |
| | | SNCodeObject = miloService.readFromOpcUa("CFL4HX." + locationCode + ".Code").getValue(); |
| | | } |
| | | if (null != SNCodeObject){ |
| | | if (null != SNCodeObject) { |
| | | String SNCode = SNCodeObject.toString(); |
| | | //插入数据 |
| | | DaParamCollection saveData = new DaParamCollection(); |
| | | saveData.setSfcCode(SNCode); |
| | | saveData.setParamValue(barcode); |
| | | saveData.setLocationCode(locationCode); |
| | | saveData.setParamCode("XTM"); |
| | | saveData.setParamName("曲轴码"); |
| | | saveData.setParamCode("CZM"); |
| | | saveData.setParamName("曲轴"); |
| | | daParamCollectionService.insertDaParamCollection(saveData); |
| | | |
| | | DaTileMatchCollection MatchCollection = new DaTileMatchCollection(); |
| | | MatchCollection.setSfcCode(SNCode); |
| | | MatchCollection.setParamValue(barcode); |
| | | MatchCollection.setLocationCode(locationCode); |
| | | MatchCollection.setParamCode("CZM"); |
| | | MatchCollection.setParamName("曲轴"); |
| | | daTileMatchCollectionService.insertDaTileMatchCollection(MatchCollection); |
| | | |
| | | DaTileMatchRules TileMatchRules = new DaTileMatchRules(); |
| | | TileMatchRules.setProductSeries("380Y"); |
| | | TileMatchRules.setScanObject1("连杆"); |
| | | TileMatchRules.setScanObject2("曲轴"); |
| | | daTileMatchRulesService.selectDaTileMatchRulesList(TileMatchRules); |
| | | |
| | | for (int i = 1; i <= 3; i++) { |
| | | DaTileMatchMiddleware TileMatchMiddleware = new DaTileMatchMiddleware(); |
| | | TileMatchMiddleware.setSfcCode(SNCode); |
| | | TileMatchMiddleware.setCrankshaftNo(barcode); |
| | | TileMatchMiddleware.setCylinder((long) i); |
| | | TileMatchMiddleware.setState(1L); |
| | | daTileMatchMiddlewareService.insertDaTileMatchMiddleware(TileMatchMiddleware); |
| | | } |
| | | |
| | | DaParamCollection ParamCollection = new DaParamCollection(); |
| | | ParamCollection.setSfcCode(SNCode); |
| | | ParamCollection.setParamName("箱体"); |
| | | List<DaParamCollection> DaParamCollectionlist = daParamCollectionService.selectDaParamCollectionList(ParamCollection); |
| | | List<DaParamCollection> XTParamCollection = DaParamCollectionlist.stream().filter(x -> "箱体".equals(x.getParamName())).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(XTParamCollection)) { |
| | | xParamCollection = XTParamCollection.get(0); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return toAjax(out); |
| | | return xParamCollection; |
| | | } |
| | | } |