春风项目四线(合箱线、总装线)
wujian
2024-08-03 131e8c0adbd4f56e1f7e7f877ff1b03e1683314f
提交 | 用户 | 时间
dd4482 1 package com.jcdm.main.da.tileMatchCollection.controller;
Y 2
59e228 3 import java.util.ArrayList;
dd4482 4 import java.util.List;
59e228 5 import java.util.stream.Collectors;
W 6 import javax.annotation.Resource;
dd4482 7 import javax.servlet.http.HttpServletResponse;
59e228 8
W 9 import cn.hutool.core.collection.CollUtil;
10 import cn.hutool.core.collection.ListUtil;
11 import cn.hutool.core.util.StrUtil;
12 import com.jcdm.common.core.domain.R;
13 import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
14 import com.jcdm.main.da.passingStationCollection.domain.ProductNewPassStation;
15 import com.jcdm.main.da.passingStationCollection.mapper.ProductNewPassStationMapper;
16 import com.jcdm.main.da.passingStationCollection.service.ProductNewPassStationService;
17 import com.jcdm.main.da.tileMatchCollection.domain.ReceiveDataVO;
18 import com.jcdm.main.da.tileMatchRules.domain.DaTileMatchRules;
19 import com.jcdm.main.da.tileMatchRules.service.IDaTileMatchRulesService;
20 import com.kangaroohy.milo.model.ReadWriteEntity;
dd4482 21 import org.springframework.security.access.prepost.PreAuthorize;
Y 22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.web.bind.annotation.GetMapping;
24 import org.springframework.web.bind.annotation.PostMapping;
25 import org.springframework.web.bind.annotation.PutMapping;
26 import org.springframework.web.bind.annotation.DeleteMapping;
27 import org.springframework.web.bind.annotation.PathVariable;
28 import org.springframework.web.bind.annotation.RequestBody;
29 import org.springframework.web.bind.annotation.RequestMapping;
30 import org.springframework.web.bind.annotation.RestController;
31 import com.jcdm.common.annotation.Log;
32 import com.jcdm.common.core.controller.BaseController;
33 import com.jcdm.common.core.domain.AjaxResult;
34 import com.jcdm.common.enums.BusinessType;
35 import com.jcdm.main.da.tileMatchCollection.domain.DaTileMatchCollection;
36 import com.jcdm.main.da.tileMatchCollection.service.IDaTileMatchCollectionService;
37 import com.jcdm.common.utils.poi.ExcelUtil;
38 import com.jcdm.common.core.page.TableDataInfo;
39
59e228 40 import static com.jcdm.main.plcserver.sub.OPCUaSubscription.miloService;
W 41
dd4482 42 /**
Y 43  * 条码采集Controller
44  * 
45  * @author yyt
46  * @date 2024-06-06
47  */
48 @RestController
49 @RequestMapping("/da/tileMatchCollection")
50 public class DaTileMatchCollectionController extends BaseController
51 {
52     @Autowired
53     private IDaTileMatchCollectionService daTileMatchCollectionService;
59e228 54
W 55     @Autowired
56     private IDaTileMatchRulesService daTileMatchRulesService;
57
58     @Autowired
59     private IDaParamCollectionService daParamCollectionService;
60
61     @Resource
62     private ProductNewPassStationMapper productNewPassStationMapper;
63
64     @Resource
65     private ProductNewPassStationService productNewPassStationService;
dd4482 66
Y 67     /**
68      * 查询条码采集列表
69      */
70     @PreAuthorize("@ss.hasPermi('da:tileMatchCollection:list')")
71     @GetMapping("/list")
72     public TableDataInfo list(DaTileMatchCollection daTileMatchCollection)
73     {
74         startPage();
75         List<DaTileMatchCollection> list = daTileMatchCollectionService.selectDaTileMatchCollectionList(daTileMatchCollection);
76         return getDataTable(list);
77     }
78
79     /**
80      * 导出条码采集列表
81      */
82     @PreAuthorize("@ss.hasPermi('da:tileMatchCollection:export')")
83     @Log(title = "条码采集", businessType = BusinessType.EXPORT)
84     @PostMapping("/export")
85     public void export(HttpServletResponse response, DaTileMatchCollection daTileMatchCollection)
86     {
87         List<DaTileMatchCollection> list = daTileMatchCollectionService.selectDaTileMatchCollectionList(daTileMatchCollection);
88         ExcelUtil<DaTileMatchCollection> util = new ExcelUtil<DaTileMatchCollection>(DaTileMatchCollection.class);
89         util.exportExcel(response, list, "条码采集数据");
90     }
91
92     /**
93      * 获取条码采集详细信息
94      */
95     @PreAuthorize("@ss.hasPermi('da:tileMatchCollection:query')")
96     @GetMapping(value = "/{id}")
97     public AjaxResult getInfo(@PathVariable("id") Long id)
98     {
99         return success(daTileMatchCollectionService.selectDaTileMatchCollectionById(id));
100     }
101
102     /**
103      * 新增条码采集
104      */
105     @PreAuthorize("@ss.hasPermi('da:tileMatchCollection:add')")
106     @Log(title = "条码采集", businessType = BusinessType.INSERT)
107     @PostMapping
108     public AjaxResult add(@RequestBody DaTileMatchCollection daTileMatchCollection)
109     {
110         return toAjax(daTileMatchCollectionService.insertDaTileMatchCollection(daTileMatchCollection));
111     }
112
113     /**
114      * 修改条码采集
115      */
116     @PreAuthorize("@ss.hasPermi('da:tileMatchCollection:edit')")
117     @Log(title = "条码采集", businessType = BusinessType.UPDATE)
118     @PutMapping
119     public AjaxResult edit(@RequestBody DaTileMatchCollection daTileMatchCollection)
120     {
121         return toAjax(daTileMatchCollectionService.updateDaTileMatchCollection(daTileMatchCollection));
122     }
123
124     /**
125      * 删除条码采集
126      */
127     @PreAuthorize("@ss.hasPermi('da:tileMatchCollection:remove')")
128     @Log(title = "条码采集", businessType = BusinessType.DELETE)
129     @DeleteMapping("/{ids}")
130     public AjaxResult remove(@PathVariable Long[] ids)
131     {
132         return toAjax(daTileMatchCollectionService.deleteDaTileMatchCollectionByIds(ids));
133     }
59e228 134
W 135     @GetMapping("/getBalanceData")
136     public R getBalanceData(String boxCode, String balanceCode, String productType) throws Exception {
137         List<DaTileMatchRules> resultList = new ArrayList<>();
138         if (StrUtil.isBlank(boxCode)){
139             return R.fail("箱体码不能为空");
140         }
141         if (StrUtil.isBlank(balanceCode)){
142             return R.fail("平衡轴码不能为空");
143         }
144         if (StrUtil.isBlank(productType)){
145             return R.fail("产品类型不能为空");
146         }
147         String balanceSplit = "";
148         String boxCodeSplit = "";
131e8c 149 //        ArrayList<String> xtList = ListUtil.toList(boxCode.split(";"));
W 150         ArrayList<String> xtList = ListUtil.toList(boxCode.split(","));
59e228 151         ArrayList<String> czList = ListUtil.toList(balanceCode.split(";"));
W 152         if (CollUtil.isNotEmpty(xtList) && xtList.size()>1 &&
153                 CollUtil.isNotEmpty(czList) && czList.size()>3){
154             boxCodeSplit = xtList.get(1);
155             balanceSplit = czList.get(2);
156         }
157         DaTileMatchRules daTileMatchRules = new DaTileMatchRules();
158         daTileMatchRules.setScanObject1("箱体");
159         daTileMatchRules.setScanObject2("平衡轴");
160         daTileMatchRules.setProductSeries(productType);
161         List<DaTileMatchRules> allMatchRuleList = daTileMatchRulesService.selectDaTileMatchRulesList(daTileMatchRules);
162         if (CollUtil.isNotEmpty(allMatchRuleList)){
163             char[] boxCodeCharArray = boxCodeSplit.toCharArray();
164             char[] balanceCodeCharArray = balanceSplit.toCharArray();
165             if (boxCodeCharArray.length>6 && balanceCodeCharArray.length>2){
166                 if ("380".equals(productType)){
167                     for (int i = 1; i < 3; i++) {
168                         int finalI = i;
169                         List<DaTileMatchRules> collect = allMatchRuleList.stream().filter(x -> x.getAxisParameterNoPosition().equals(finalI + 5) &&
170                                         x.getNeckParameterPosition().equals(finalI + 1) &&
171                                         x.getAxisValue().equals(String.valueOf(boxCodeCharArray[finalI + 4])) &&
172                                         x.getNeckValue().equals(String.valueOf(balanceCodeCharArray[finalI])))
173                                 .collect(Collectors.toList());
174                         if (CollUtil.isNotEmpty(collect)){
175                             DaTileMatchRules rules = collect.get(0);
176                             resultList.add(rules);
177                         }
178                     }
179                 }
180             }
181         }
182         if (CollUtil.isEmpty(resultList)){
183             return R.fail("未匹配到平衡轴瓦");
184         } else {
185             ReadWriteEntity entity6 = new ReadWriteEntity("CFL4HX.OP040.CodeComplete", 1);
186             miloService.writeToOpcByte(entity6);
187             ProductNewPassStation passStation = new ProductNewPassStation();
188             passStation.setProductType(productType);
189             passStation.setBoxCode(boxCode);
190             List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(passStation);
191             if (CollUtil.isNotEmpty(productPassStationList)){
192                 ProductNewPassStation newPassStation = productPassStationList.get(0);
193                 productNewPassStationMapper.updatePassStationBalanceCode(newPassStation.getSfcCode(),balanceCode);
194             }
195         }
196         return R.ok(resultList);
197     }
198
199     @GetMapping("/getDetailData")
200     public R getDetailData() throws Exception {
201         ReceiveDataVO detailData = productNewPassStationService.getDetailData();
202         return R.ok(detailData);
203     }
dd4482 204 }