提交 | 用户 | 时间
|
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 = ""; |
|
149 |
ArrayList<String> xtList = ListUtil.toList(boxCode.split(";")); |
|
150 |
ArrayList<String> czList = ListUtil.toList(balanceCode.split(";")); |
|
151 |
if (CollUtil.isNotEmpty(xtList) && xtList.size()>1 && |
|
152 |
CollUtil.isNotEmpty(czList) && czList.size()>3){ |
|
153 |
boxCodeSplit = xtList.get(1); |
|
154 |
balanceSplit = czList.get(2); |
|
155 |
} |
|
156 |
DaTileMatchRules daTileMatchRules = new DaTileMatchRules(); |
|
157 |
daTileMatchRules.setScanObject1("箱体"); |
|
158 |
daTileMatchRules.setScanObject2("平衡轴"); |
|
159 |
daTileMatchRules.setProductSeries(productType); |
|
160 |
List<DaTileMatchRules> allMatchRuleList = daTileMatchRulesService.selectDaTileMatchRulesList(daTileMatchRules); |
|
161 |
if (CollUtil.isNotEmpty(allMatchRuleList)){ |
|
162 |
char[] boxCodeCharArray = boxCodeSplit.toCharArray(); |
|
163 |
char[] balanceCodeCharArray = balanceSplit.toCharArray(); |
|
164 |
if (boxCodeCharArray.length>6 && balanceCodeCharArray.length>2){ |
|
165 |
if ("380".equals(productType)){ |
|
166 |
for (int i = 1; i < 3; i++) { |
|
167 |
int finalI = i; |
|
168 |
List<DaTileMatchRules> collect = allMatchRuleList.stream().filter(x -> x.getAxisParameterNoPosition().equals(finalI + 5) && |
|
169 |
x.getNeckParameterPosition().equals(finalI + 1) && |
|
170 |
x.getAxisValue().equals(String.valueOf(boxCodeCharArray[finalI + 4])) && |
|
171 |
x.getNeckValue().equals(String.valueOf(balanceCodeCharArray[finalI]))) |
|
172 |
.collect(Collectors.toList()); |
|
173 |
if (CollUtil.isNotEmpty(collect)){ |
|
174 |
DaTileMatchRules rules = collect.get(0); |
|
175 |
resultList.add(rules); |
|
176 |
} |
|
177 |
} |
|
178 |
} |
|
179 |
} |
|
180 |
} |
|
181 |
if (CollUtil.isEmpty(resultList)){ |
|
182 |
return R.fail("未匹配到平衡轴瓦"); |
|
183 |
} else { |
|
184 |
ReadWriteEntity entity6 = new ReadWriteEntity("CFL4HX.OP040.CodeComplete", 1); |
|
185 |
miloService.writeToOpcByte(entity6); |
|
186 |
ProductNewPassStation passStation = new ProductNewPassStation(); |
|
187 |
passStation.setProductType(productType); |
|
188 |
passStation.setBoxCode(boxCode); |
|
189 |
List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(passStation); |
|
190 |
if (CollUtil.isNotEmpty(productPassStationList)){ |
|
191 |
ProductNewPassStation newPassStation = productPassStationList.get(0); |
|
192 |
productNewPassStationMapper.updatePassStationBalanceCode(newPassStation.getSfcCode(),balanceCode); |
|
193 |
} |
|
194 |
} |
|
195 |
return R.ok(resultList); |
|
196 |
} |
|
197 |
|
|
198 |
@GetMapping("/getDetailData") |
|
199 |
public R getDetailData() throws Exception { |
|
200 |
ReceiveDataVO detailData = productNewPassStationService.getDetailData(); |
|
201 |
return R.ok(detailData); |
|
202 |
} |
dd4482
|
203 |
} |