提交 | 用户 | 时间
|
b78728
|
1 |
package com.jcdm.main.bs.formulaChild.controller; |
A |
2 |
|
4cba4a
|
3 |
import java.text.SimpleDateFormat; |
C |
4 |
import java.util.Date; |
b78728
|
5 |
import java.util.List; |
A |
6 |
import java.util.stream.Collectors; |
|
7 |
import javax.servlet.http.HttpServletResponse; |
|
8 |
|
|
9 |
import cn.hutool.core.collection.CollUtil; |
|
10 |
import cn.hutool.core.util.ObjectUtil; |
|
11 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
12 |
import com.jcdm.main.constant.Constants; |
|
13 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
|
14 |
import com.kangaroohy.milo.service.MiloService; |
|
15 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
|
17 |
import org.springframework.web.bind.annotation.GetMapping; |
|
18 |
import org.springframework.web.bind.annotation.PostMapping; |
|
19 |
import org.springframework.web.bind.annotation.PutMapping; |
|
20 |
import org.springframework.web.bind.annotation.DeleteMapping; |
|
21 |
import org.springframework.web.bind.annotation.PathVariable; |
|
22 |
import org.springframework.web.bind.annotation.RequestBody; |
|
23 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
24 |
import org.springframework.web.bind.annotation.RestController; |
|
25 |
import com.jcdm.common.annotation.Log; |
|
26 |
import com.jcdm.common.core.controller.BaseController; |
|
27 |
import com.jcdm.common.core.domain.AjaxResult; |
|
28 |
import com.jcdm.common.enums.BusinessType; |
|
29 |
import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
|
30 |
import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService; |
|
31 |
import com.jcdm.common.utils.poi.ExcelUtil; |
|
32 |
import com.jcdm.common.core.page.TableDataInfo; |
|
33 |
|
|
34 |
/** |
|
35 |
* 配方配置子信息Controller |
|
36 |
* |
|
37 |
* @author ruimin |
|
38 |
* @date 2023-12-26 |
|
39 |
*/ |
|
40 |
@RestController |
|
41 |
@RequestMapping("/bs/formulaChild") |
|
42 |
public class BsFormulaChildInfoController extends BaseController |
|
43 |
{ |
|
44 |
@Autowired |
|
45 |
private IBsFormulaChildInfoService bsFormulaChildInfoService; |
|
46 |
|
|
47 |
@Autowired |
|
48 |
private MiloService miloService; |
|
49 |
|
|
50 |
/** |
|
51 |
* 未做完工序回复plc信号 |
|
52 |
*/ |
|
53 |
@GetMapping("/unfinishedProcess") |
|
54 |
public AjaxResult unfinishedProcess(BsFormulaChildInfo bsFormulaChildInfo) |
|
55 |
{ |
989363
|
56 |
String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getProcessesCode());//获取通道 |
b78728
|
57 |
try { |
989363
|
58 |
// String str = "MOZU1."+bsFormulaChildInfo.getProcessesCode()+".RecordDataDone"; |
A |
59 |
// miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(bsFormulaChildInfo.getRecordDataDone()).build()); |
|
60 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare+"."+bsFormulaChildInfo.getProcessesCode()+".RecordDataDone").value(bsFormulaChildInfo.getRecordDataDone()).build()); |
b78728
|
61 |
} catch (Exception e) { |
A |
62 |
throw new RuntimeException(e); |
|
63 |
} |
|
64 |
return AjaxResult.success(); |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* 扫码确认 |
|
69 |
*/ |
|
70 |
@GetMapping("/initializedData") |
|
71 |
public AjaxResult initializedData(BsFormulaChildInfo bsFormulaChildInfo) |
|
72 |
{ |
|
73 |
String productNum = ""; |
|
74 |
try { |
8c09d8
|
75 |
String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getLocationCode()); |
C |
76 |
String str = thoroughfare+"."+bsFormulaChildInfo.getLocationCode()+".SNCode"; |
b78728
|
77 |
Object productNumObject = miloService.readFromOpcUa(str).getValue(); |
A |
78 |
if(ObjectUtil.isNotNull(productNumObject)){ |
|
79 |
productNum = productNumObject.toString(); |
|
80 |
} |
|
81 |
} catch (Exception e) { |
|
82 |
throw new RuntimeException(e); |
|
83 |
} |
|
84 |
return AjaxResult.success(productNum); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* 扫码确认 |
|
89 |
*/ |
|
90 |
@GetMapping("/fistSetpNumber") |
|
91 |
public AjaxResult fistSetpNumber(BsFormulaChildInfo bsFormulaChildInfo) |
|
92 |
{ |
|
93 |
// try { |
|
94 |
// String str = "PACK."+bsFormulaChildInfo.getProcessesCode()+".MStepNumber"; |
|
95 |
// miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(1).build()); |
|
96 |
// } catch (Exception e) { |
|
97 |
// throw new RuntimeException(e); |
|
98 |
// } |
|
99 |
Integer stepNumber = 1; |
|
100 |
try { |
4280d7
|
101 |
// List<BsFormulaChildInfo> op260 = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
A |
102 |
// .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getProcessesCode()) |
|
103 |
// .eq(BsFormulaChildInfo::getOperationType, "1") |
|
104 |
// ); |
|
105 |
// List<BsFormulaChildInfo> filteredList = op260.stream() |
|
106 |
// .filter(obj -> obj.getResults() != null && !obj.getResults().isEmpty()) |
|
107 |
// .collect(Collectors.toList()); |
|
108 |
// if(filteredList.size() > 0){ |
|
109 |
// stepNumber = Integer.valueOf(filteredList.get(filteredList.size()-1).getStepSort())+1; |
|
110 |
// } |
b78728
|
111 |
|
039f89
|
112 |
String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getProcessesCode());//获取通道 |
fd4ea6
|
113 |
String str = thoroughfare+"."+bsFormulaChildInfo.getProcessesCode()+".MESScrew"; |
4cba4a
|
114 |
if(bsFormulaChildInfo.getProcessesCode().equals("OP230")){ |
C |
115 |
//所有进站将进站时间写给PLC |
|
116 |
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
117 |
String currentDate = dateFormat.format(new Date()); |
|
118 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".StartTime").value(currentDate).build()); |
|
119 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".SNCode").value(bsFormulaChildInfo.getSfcBarcode()).build()); |
f2a963
|
120 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".RecordDataDone").value(11).build()); |
C |
121 |
}else if(bsFormulaChildInfo.getProcessesCode().equals("OP220")){ |
|
122 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".RecordDataDone").value(11).build()); |
4cba4a
|
123 |
} |
b78728
|
124 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(stepNumber).build()); |
A |
125 |
} catch (Exception e) { |
|
126 |
throw new RuntimeException(e); |
|
127 |
} |
|
128 |
return AjaxResult.success(stepNumber); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* 查询配方配置子信息列表 |
|
133 |
*/ |
|
134 |
@GetMapping("/noPageListFormulaChild") |
|
135 |
public TableDataInfo noPageListFormulaChild(BsFormulaChildInfo bsFormulaChildInfo) |
|
136 |
{ |
|
137 |
|
|
138 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
|
139 |
.eq(BsFormulaChildInfo::getProductCode,bsFormulaChildInfo.getProductCode()) |
|
140 |
.eq(BsFormulaChildInfo::getProcessesCode,bsFormulaChildInfo.getProcessesCode()) |
eec569
|
141 |
// .orderByAsc(BsFormulaChildInfo::getStepSort) |
b78728
|
142 |
); |
A |
143 |
if (CollUtil.isNotEmpty(list)){ |
|
144 |
List<BsFormulaChildInfo> collect1 = list.stream().filter(x -> Constants.OK.equals(x.getResults())).collect(Collectors.toList()); |
|
145 |
List<BsFormulaChildInfo> collect2 = list.stream().filter(x -> !Constants.OK.equals(x.getResults())).collect(Collectors.toList()); |
|
146 |
list = collect1; |
|
147 |
list.addAll(collect2); |
|
148 |
} |
|
149 |
for (BsFormulaChildInfo formulaChildInfo : list) { |
|
150 |
// formulaChildInfo.setSort(formulaChildInfo.getStepSort()); |
|
151 |
// formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement()); |
|
152 |
// formulaChildInfo.setImg(formulaChildInfo.getOperationSteps()); |
|
153 |
if(formulaChildInfo.getCollectData()!=null&& !"".equals(formulaChildInfo.getCollectData())){ |
|
154 |
if(formulaChildInfo.getCollectData().contains("[")){ |
|
155 |
String data = formulaChildInfo.getCollectData(); |
|
156 |
data = data.replace("[", "").replace("]", "").replace(" ", ""); |
|
157 |
String[] tightenDataParts = data.split(","); |
|
158 |
formulaChildInfo.setCollectData("扭矩"+tightenDataParts[0]+"角度"+tightenDataParts[1]+"扭矩结果"+tightenDataParts[2]+"角度结果"+tightenDataParts[3]); |
|
159 |
} |
|
160 |
} |
|
161 |
} |
|
162 |
return getDataTable(list); |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* 查询配方配置子信息列表 |
|
167 |
*/ |
|
168 |
@PreAuthorize("@ss.hasPermi('bs:formulaChild:list')") |
|
169 |
@GetMapping("/list") |
|
170 |
public TableDataInfo list(BsFormulaChildInfo bsFormulaChildInfo) |
|
171 |
{ |
|
172 |
startPage(); |
|
173 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo); |
|
174 |
for (BsFormulaChildInfo formulaChildInfo : list) { |
|
175 |
formulaChildInfo.setSort(formulaChildInfo.getStepSort()); |
|
176 |
formulaChildInfo.setAddress(formulaChildInfo.getTechRequirement()); |
|
177 |
formulaChildInfo.setImg(formulaChildInfo.getOperationSteps()); |
|
178 |
if(formulaChildInfo.getCollectData()!=null&& !"".equals(formulaChildInfo.getCollectData())){ |
|
179 |
if(formulaChildInfo.getCollectData().contains("[")){ |
|
180 |
String data = formulaChildInfo.getCollectData(); |
|
181 |
data = data.replace("[", "").replace("]", "").replace(" ", ""); |
|
182 |
String[] tightenDataParts = data.split(","); |
|
183 |
formulaChildInfo.setCollectData("扭矩"+tightenDataParts[0]+"角度"+tightenDataParts[1]+"扭矩结果"+tightenDataParts[2]+"角度结果"+tightenDataParts[3]); |
|
184 |
} |
|
185 |
} |
|
186 |
} |
|
187 |
return getDataTable(list); |
|
188 |
} |
|
189 |
|
|
190 |
// /** |
|
191 |
// * 检查是否可以放行 |
|
192 |
// */ |
|
193 |
// @GetMapping("/releaseCheck") |
|
194 |
// public AjaxResult releaseCheck(BsFormulaChildInfo bsFormulaChildInfo) |
|
195 |
// { |
|
196 |
// List<BsFormulaChildInfo> i = bsFormulaChildInfoService.releaseCheck(bsFormulaChildInfo); |
|
197 |
// return AjaxResult.success(i.size()); |
|
198 |
// } |
|
199 |
|
|
200 |
/** |
|
201 |
* 扫码确认 |
|
202 |
*/ |
|
203 |
@GetMapping("/updateResults") |
|
204 |
public AjaxResult updateResults(BsFormulaChildInfo bsFormulaChildInfo) |
|
205 |
{ |
|
206 |
return bsFormulaChildInfoService.updateResults(bsFormulaChildInfo); |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* 扫码确认 |
|
211 |
*/ |
|
212 |
@GetMapping("/jrmUpdateResults") |
|
213 |
public AjaxResult jrmUpdateResults(BsFormulaChildInfo bsFormulaChildInfo) |
|
214 |
{ |
|
215 |
return bsFormulaChildInfoService.jrmUpdateResults(bsFormulaChildInfo); |
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
219 |
* 扫码确认 |
|
220 |
*/ |
|
221 |
@GetMapping("/yzUpdateResults") |
|
222 |
public AjaxResult yzUpdateResults(BsFormulaChildInfo bsFormulaChildInfo) |
|
223 |
{ |
|
224 |
return bsFormulaChildInfoService.yzUpdateResults(bsFormulaChildInfo); |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* 放行请空状态 |
|
229 |
*/ |
|
230 |
@GetMapping("/workpieceRelease") |
|
231 |
public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) |
|
232 |
{ |
|
233 |
return bsFormulaChildInfoService.workpieceRelease(bsFormulaChildInfo); |
|
234 |
} |
|
235 |
|
|
236 |
/** |
|
237 |
* 放行请空状态 |
|
238 |
*/ |
|
239 |
@GetMapping("/checkMaterialCode") |
|
240 |
public AjaxResult checkMaterialCode(BsFormulaChildInfo bsFormulaChildInfo) |
|
241 |
{ |
|
242 |
return bsFormulaChildInfoService.checkMaterialCode(bsFormulaChildInfo); |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* 放行请空状态 |
|
247 |
*/ |
|
248 |
@GetMapping("/clearWorkpieceRelease") |
|
249 |
public AjaxResult clearWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) |
|
250 |
{ |
|
251 |
return bsFormulaChildInfoService.clearWorkpieceRelease(bsFormulaChildInfo); |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* 放行请空状态 |
|
256 |
*/ |
|
257 |
@GetMapping("/jrmWorkpieceRelease") |
|
258 |
public AjaxResult jrmWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) |
|
259 |
{ |
|
260 |
return bsFormulaChildInfoService.jrmWorkpieceRelease(bsFormulaChildInfo); |
|
261 |
} |
|
262 |
|
|
263 |
/** |
|
264 |
* 拧紧后更新对应数据 |
|
265 |
*/ |
|
266 |
@GetMapping("/updateTighteningFormula") |
|
267 |
public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) |
|
268 |
{ |
|
269 |
return bsFormulaChildInfoService.updateTighteningFormula(bsFormulaChildInfo); |
|
270 |
} |
|
271 |
|
|
272 |
/** |
|
273 |
* 拧紧后更新对应数据 |
|
274 |
*/ |
|
275 |
@GetMapping("/yzUpdateTighteningFormula") |
|
276 |
public AjaxResult yzUpdateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) |
|
277 |
{ |
|
278 |
return bsFormulaChildInfoService.yzUpdateTighteningFormula(bsFormulaChildInfo); |
|
279 |
} |
|
280 |
|
|
281 |
/** |
|
282 |
* 导出配方配置子信息列表 |
|
283 |
*/ |
|
284 |
@PreAuthorize("@ss.hasPermi('bs:formulaChild:export')") |
|
285 |
@Log(title = "配方配置子信息", businessType = BusinessType.EXPORT) |
|
286 |
@PostMapping("/export") |
|
287 |
public void export(HttpServletResponse response, BsFormulaChildInfo bsFormulaChildInfo) |
|
288 |
{ |
|
289 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.selectBsFormulaChildInfoList(bsFormulaChildInfo); |
|
290 |
ExcelUtil<BsFormulaChildInfo> util = new ExcelUtil<BsFormulaChildInfo>(BsFormulaChildInfo.class); |
|
291 |
util.exportExcel(response, list, "配方配置子信息数据"); |
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* 获取配方配置子信息详细信息 |
|
296 |
*/ |
|
297 |
@PreAuthorize("@ss.hasPermi('bs:formulaChild:query')") |
|
298 |
@GetMapping(value = "/{id}") |
|
299 |
public AjaxResult getInfo(@PathVariable("id") Long id) |
|
300 |
{ |
|
301 |
return success(bsFormulaChildInfoService.selectBsFormulaChildInfoById(id)); |
|
302 |
} |
|
303 |
|
|
304 |
/** |
|
305 |
* 新增配方配置子信息 |
|
306 |
*/ |
|
307 |
@PreAuthorize("@ss.hasPermi('bs:formulaChild:add')") |
|
308 |
@Log(title = "配方配置子信息", businessType = BusinessType.INSERT) |
|
309 |
@PostMapping |
|
310 |
public AjaxResult add(@RequestBody BsFormulaChildInfo bsFormulaChildInfo) |
|
311 |
{ |
|
312 |
return toAjax(bsFormulaChildInfoService.insertBsFormulaChildInfo(bsFormulaChildInfo)); |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* 修改配方配置子信息 |
|
317 |
*/ |
|
318 |
@PreAuthorize("@ss.hasPermi('bs:formulaChild:edit')") |
|
319 |
@Log(title = "配方配置子信息", businessType = BusinessType.UPDATE) |
|
320 |
@PutMapping |
|
321 |
public AjaxResult edit(@RequestBody BsFormulaChildInfo bsFormulaChildInfo) |
|
322 |
{ |
|
323 |
return toAjax(bsFormulaChildInfoService.updateBsFormulaChildInfo(bsFormulaChildInfo)); |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* 删除配方配置子信息 |
|
328 |
*/ |
|
329 |
@PreAuthorize("@ss.hasPermi('bs:formulaChild:remove')") |
|
330 |
@Log(title = "配方配置子信息", businessType = BusinessType.DELETE) |
|
331 |
@DeleteMapping("/{ids}") |
|
332 |
public AjaxResult remove(@PathVariable Long[] ids) |
|
333 |
{ |
|
334 |
return toAjax(bsFormulaChildInfoService.deleteBsFormulaChildInfoByIds(ids)); |
|
335 |
} |
|
336 |
} |