提交 | 用户 | 时间
|
5030f3
|
1 |
package com.jcdm.main.da.tileMatchMiddleware.controller; |
Y |
2 |
|
|
3 |
import java.util.List; |
59e228
|
4 |
import javax.annotation.Resource; |
5030f3
|
5 |
import javax.servlet.http.HttpServletResponse; |
Y |
6 |
|
59e228
|
7 |
import cn.hutool.core.collection.CollUtil; |
5030f3
|
8 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
59e228
|
9 |
import com.jcdm.main.da.passingStationCollection.domain.ProductNewPassStation; |
W |
10 |
import com.jcdm.main.da.passingStationCollection.service.ProductNewPassStationService; |
5030f3
|
11 |
import com.jcdm.main.da.tileMatchRules.domain.DaTileMatchRules; |
Y |
12 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
13 |
import org.springframework.beans.factory.annotation.Autowired; |
|
14 |
import org.springframework.web.bind.annotation.GetMapping; |
|
15 |
import org.springframework.web.bind.annotation.PostMapping; |
|
16 |
import org.springframework.web.bind.annotation.PutMapping; |
|
17 |
import org.springframework.web.bind.annotation.DeleteMapping; |
|
18 |
import org.springframework.web.bind.annotation.PathVariable; |
|
19 |
import org.springframework.web.bind.annotation.RequestBody; |
|
20 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
21 |
import org.springframework.web.bind.annotation.RestController; |
|
22 |
import com.jcdm.common.annotation.Log; |
|
23 |
import com.jcdm.common.core.controller.BaseController; |
|
24 |
import com.jcdm.common.core.domain.AjaxResult; |
|
25 |
import com.jcdm.common.enums.BusinessType; |
|
26 |
import com.jcdm.main.da.tileMatchMiddleware.domain.DaTileMatchMiddleware; |
|
27 |
import com.jcdm.main.da.tileMatchMiddleware.service.IDaTileMatchMiddlewareService; |
|
28 |
import com.jcdm.common.utils.poi.ExcelUtil; |
|
29 |
import com.jcdm.common.core.page.TableDataInfo; |
|
30 |
|
|
31 |
import static com.jcdm.main.plcserver.sub.OPCUaSubscription.miloService; |
|
32 |
|
|
33 |
/** |
|
34 |
* 活塞连杆配瓦中间Controller |
|
35 |
* |
|
36 |
* @author yyt |
|
37 |
* @date 2024-05-28 |
|
38 |
*/ |
|
39 |
@RestController |
|
40 |
@RequestMapping("/da/tileMatchMiddleware") |
|
41 |
public class DaTileMatchMiddlewareController extends BaseController |
|
42 |
{ |
|
43 |
@Autowired |
|
44 |
private IDaTileMatchMiddlewareService daTileMatchMiddlewareService; |
59e228
|
45 |
|
W |
46 |
@Resource |
|
47 |
private ProductNewPassStationService productNewPassStationService; |
5030f3
|
48 |
|
Y |
49 |
/** |
|
50 |
* 查询活塞连杆配瓦中间列表 |
|
51 |
*/ |
|
52 |
@PreAuthorize("@ss.hasPermi('da:tileMatchMiddleware:list')") |
|
53 |
@GetMapping("/list") |
|
54 |
public TableDataInfo list(DaTileMatchMiddleware daTileMatchMiddleware) |
|
55 |
{ |
|
56 |
startPage(); |
|
57 |
List<DaTileMatchMiddleware> list = daTileMatchMiddlewareService.selectDaTileMatchMiddlewareList(daTileMatchMiddleware); |
|
58 |
return getDataTable(list); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* 导出活塞连杆配瓦中间列表 |
|
63 |
*/ |
|
64 |
@PreAuthorize("@ss.hasPermi('da:tileMatchMiddleware:export')") |
|
65 |
@Log(title = "活塞连杆配瓦中间", businessType = BusinessType.EXPORT) |
|
66 |
@PostMapping("/export") |
|
67 |
public void export(HttpServletResponse response, DaTileMatchMiddleware daTileMatchMiddleware) |
|
68 |
{ |
|
69 |
List<DaTileMatchMiddleware> list = daTileMatchMiddlewareService.selectDaTileMatchMiddlewareList(daTileMatchMiddleware); |
|
70 |
ExcelUtil<DaTileMatchMiddleware> util = new ExcelUtil<DaTileMatchMiddleware>(DaTileMatchMiddleware.class); |
|
71 |
util.exportExcel(response, list, "活塞连杆配瓦中间数据"); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* 获取活塞连杆配瓦中间详细信息 |
|
76 |
*/ |
|
77 |
@PreAuthorize("@ss.hasPermi('da:tileMatchMiddleware:query')") |
|
78 |
@GetMapping(value = "/{id}") |
|
79 |
public AjaxResult getInfo(@PathVariable("id") Long id) |
|
80 |
{ |
|
81 |
return success(daTileMatchMiddlewareService.selectDaTileMatchMiddlewareById(id)); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* 新增活塞连杆配瓦中间 |
|
86 |
*/ |
|
87 |
@PreAuthorize("@ss.hasPermi('da:tileMatchMiddleware:add')") |
|
88 |
@Log(title = "活塞连杆配瓦中间", businessType = BusinessType.INSERT) |
|
89 |
@PostMapping |
|
90 |
public AjaxResult add(@RequestBody DaTileMatchMiddleware daTileMatchMiddleware) |
|
91 |
{ |
|
92 |
return toAjax(daTileMatchMiddlewareService.insertDaTileMatchMiddleware(daTileMatchMiddleware)); |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* 修改活塞连杆配瓦中间 |
|
97 |
*/ |
|
98 |
@PreAuthorize("@ss.hasPermi('da:tileMatchMiddleware:edit')") |
|
99 |
@Log(title = "活塞连杆配瓦中间", businessType = BusinessType.UPDATE) |
|
100 |
@PutMapping |
|
101 |
public AjaxResult edit(@RequestBody DaTileMatchMiddleware daTileMatchMiddleware) |
|
102 |
{ |
|
103 |
return toAjax(daTileMatchMiddlewareService.updateDaTileMatchMiddleware(daTileMatchMiddleware)); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* 删除活塞连杆配瓦中间 |
|
108 |
*/ |
|
109 |
@PreAuthorize("@ss.hasPermi('da:tileMatchMiddleware:remove')") |
|
110 |
@Log(title = "活塞连杆配瓦中间", businessType = BusinessType.DELETE) |
|
111 |
@DeleteMapping("/{ids}") |
|
112 |
public AjaxResult remove(@PathVariable Long[] ids) |
|
113 |
{ |
|
114 |
return toAjax(daTileMatchMiddlewareService.deleteDaTileMatchMiddlewareByIds(ids)); |
|
115 |
} |
|
116 |
|
|
117 |
@PreAuthorize("@ss.hasPermi('da:tileMatchMiddleware:query')") |
|
118 |
@GetMapping(value = "/barcodeup") |
|
119 |
public DaTileMatchMiddleware setBarcodeup(String barcode,String locationCode) { |
|
120 |
DaTileMatchMiddleware rMiddleware=null; |
|
121 |
try { |
|
122 |
//Object SNCodeObject = miloService.readFromOpcUa("CFL4HX."+locationCode+".Code1").getValue(); |
|
123 |
Object SNCodeObject = miloService.readFromOpcUa("CFL4HX.OP050.Code1").getValue(); |
|
124 |
if (null == SNCodeObject){ |
|
125 |
//SNCodeObject = miloService.readFromOpcUa("CFL4HX."+locationCode+ ".Code").getValue(); |
|
126 |
SNCodeObject = miloService.readFromOpcUa("CFL4HX.OP050.Code").getValue(); |
|
127 |
} |
|
128 |
if (null != SNCodeObject){ |
|
129 |
String SNCode = SNCodeObject.toString(); |
|
130 |
|
|
131 |
DaTileMatchMiddleware TileMatchMiddleware=new DaTileMatchMiddleware(); |
|
132 |
TileMatchMiddleware.setSfcCode(SNCode); |
|
133 |
TileMatchMiddleware.setPalletNo(barcode); |
59e228
|
134 |
TileMatchMiddleware.setState(2); |
5030f3
|
135 |
List<DaTileMatchMiddleware> TileMatchMiddlewareList=daTileMatchMiddlewareService.selectDaTileMatchMiddlewareList(TileMatchMiddleware); |
Y |
136 |
if(TileMatchMiddlewareList.size()>0){ |
|
137 |
for(int i=0;i<TileMatchMiddlewareList.size();i++){ |
|
138 |
DaTileMatchMiddleware Middleware=TileMatchMiddlewareList.get(i); |
59e228
|
139 |
Middleware.setState(3); |
5030f3
|
140 |
daTileMatchMiddlewareService.updateDaTileMatchMiddleware(Middleware); |
Y |
141 |
} |
|
142 |
rMiddleware=TileMatchMiddlewareList.get(0); |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
} catch (Exception e) { |
|
147 |
throw new RuntimeException(e); |
|
148 |
} |
|
149 |
return rMiddleware; |
|
150 |
} |
|
151 |
|
|
152 |
@PreAuthorize("@ss.hasPermi('da:tileMatchMiddleware:query')") |
|
153 |
@GetMapping(value = "/barcode") |
59e228
|
154 |
public DaTileMatchMiddleware setBarcode(String barcode,String locationCode) throws Exception { |
5030f3
|
155 |
DaTileMatchMiddleware rMiddleware=new DaTileMatchMiddleware();; |
59e228
|
156 |
rMiddleware.setState(1); |
5030f3
|
157 |
List<DaTileMatchMiddleware> TileMatchMiddlewareList=daTileMatchMiddlewareService.selectDaTileMatchMiddlewareList(rMiddleware); |
59e228
|
158 |
String SNCode=""; |
5030f3
|
159 |
if(TileMatchMiddlewareList.size()>0){ |
Y |
160 |
rMiddleware=TileMatchMiddlewareList.get(0); |
|
161 |
rMiddleware.setPalletNo(locationCode); |
|
162 |
rMiddleware.setConnectingrodNo(barcode); |
59e228
|
163 |
rMiddleware.setState(2); |
W |
164 |
SNCode=rMiddleware.getSfcCode(); |
5030f3
|
165 |
daTileMatchMiddlewareService.updateDaTileMatchMiddleware(rMiddleware); |
d2daac
|
166 |
DaTileMatchMiddleware patch = new DaTileMatchMiddleware(); |
W |
167 |
patch.setSfcCode(SNCode); |
|
168 |
patch.setState(1); |
|
169 |
List<DaTileMatchMiddleware> checkList = daTileMatchMiddlewareService.selectDaTileMatchMiddlewareList(patch); |
|
170 |
if (CollUtil.isNotEmpty(checkList)){ |
|
171 |
if (checkList.size() == 2){ |
|
172 |
rMiddleware.setCheckFlag("1"); |
|
173 |
} |
|
174 |
} |
59e228
|
175 |
//获取产品型号 |
W |
176 |
ProductNewPassStation productNewPassStation = new ProductNewPassStation(); |
|
177 |
productNewPassStation.setSfcCode(SNCode); |
|
178 |
List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(productNewPassStation); |
|
179 |
if (CollUtil.isNotEmpty(productPassStationList)){ |
|
180 |
ProductNewPassStation station = productPassStationList.get(0); |
|
181 |
String productType = station.getProductType(); |
|
182 |
rMiddleware.setProductType(productType); |
|
183 |
} |
5030f3
|
184 |
} |
59e228
|
185 |
// ReadWriteEntity entity = new ReadWriteEntity("CFL3ZZ.CR010.Code", SNCode); |
W |
186 |
// InitCallback.miloService.writeToOpcUa(entity);//写SN |
|
187 |
// ReadWriteEntity entity2 = new ReadWriteEntity("CFL3ZZ.CR010.CodeRequestFeed", 1); |
|
188 |
// InitCallback.miloService.writeToOpcByte(entity2);//写完成 |
5030f3
|
189 |
return rMiddleware; |
Y |
190 |
} |
|
191 |
} |