提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.main.bs.formulaChild.service.impl; |
懒 |
2 |
|
5316c5
|
3 |
import java.util.ArrayList; |
b64ed2
|
4 |
import java.util.Date; |
e57a89
|
5 |
import java.util.List; |
3c2299
|
6 |
import java.util.Map; |
7bee80
|
7 |
import java.util.stream.Collectors; |
e57a89
|
8 |
|
7bee80
|
9 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
懒 |
10 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
0ce25f
|
11 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
e57a89
|
12 |
import com.jcdm.common.core.domain.AjaxResult; |
懒 |
13 |
import com.jcdm.common.utils.DateUtils; |
3c2299
|
14 |
import com.jcdm.framework.websocket.WebSocketUsers; |
b64ed2
|
15 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
懒 |
16 |
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
32483a
|
17 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
懒 |
18 |
import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper; |
3c2299
|
19 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
懒 |
20 |
import com.kangaroohy.milo.service.MiloService; |
b77303
|
21 |
import org.aspectj.weaver.loadtime.Aj; |
e57a89
|
22 |
import org.springframework.beans.factory.annotation.Autowired; |
懒 |
23 |
import org.springframework.stereotype.Service; |
|
24 |
import com.jcdm.main.bs.formulaChild.mapper.BsFormulaChildInfoMapper; |
|
25 |
import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
|
26 |
import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService; |
3c2299
|
27 |
|
懒 |
28 |
import javax.websocket.Session; |
e57a89
|
29 |
|
懒 |
30 |
/** |
|
31 |
* 配方配置子信息Service业务层处理 |
|
32 |
* |
|
33 |
* @author ruimin |
|
34 |
* @date 2023-12-26 |
|
35 |
*/ |
|
36 |
@Service |
0ce25f
|
37 |
public class BsFormulaChildInfoServiceImpl extends ServiceImpl<BsFormulaChildInfoMapper,BsFormulaChildInfo> implements IBsFormulaChildInfoService |
e57a89
|
38 |
{ |
懒 |
39 |
@Autowired |
|
40 |
private BsFormulaChildInfoMapper bsFormulaChildInfoMapper; |
b64ed2
|
41 |
|
懒 |
42 |
@Autowired |
63b254
|
43 |
private IBsFormulaChildInfoService bsFormulaChildInfoService; |
懒 |
44 |
|
|
45 |
@Autowired |
b64ed2
|
46 |
private DaParamCollectionMapper daParamCollectionMapper; |
3c2299
|
47 |
|
懒 |
48 |
@Autowired |
|
49 |
private MiloService miloService; |
32483a
|
50 |
|
懒 |
51 |
@Autowired |
|
52 |
private DaPassingStationCollectionMapper daPassingStationCollectionMapper; |
3c2299
|
53 |
|
懒 |
54 |
Map<String, Session> map = WebSocketUsers.getUsers(); |
e57a89
|
55 |
|
懒 |
56 |
/** |
|
57 |
* 查询配方配置子信息 |
|
58 |
* |
|
59 |
* @param id 配方配置子信息主键 |
|
60 |
* @return 配方配置子信息 |
|
61 |
*/ |
|
62 |
@Override |
|
63 |
public BsFormulaChildInfo selectBsFormulaChildInfoById(Long id) |
|
64 |
{ |
|
65 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoById(id); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* 查询配方配置子信息列表 |
|
70 |
* |
|
71 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
72 |
* @return 配方配置子信息 |
|
73 |
*/ |
|
74 |
@Override |
|
75 |
public List<BsFormulaChildInfo> selectBsFormulaChildInfoList(BsFormulaChildInfo bsFormulaChildInfo) |
|
76 |
{ |
|
77 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* 新增配方配置子信息 |
|
82 |
* |
|
83 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
84 |
* @return 结果 |
|
85 |
*/ |
|
86 |
@Override |
|
87 |
public int insertBsFormulaChildInfo(BsFormulaChildInfo bsFormulaChildInfo) |
|
88 |
{ |
|
89 |
bsFormulaChildInfo.setCreateTime(DateUtils.getNowDate()); |
|
90 |
return bsFormulaChildInfoMapper.insertBsFormulaChildInfo(bsFormulaChildInfo); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* 修改配方配置子信息 |
|
95 |
* |
|
96 |
* @param bsFormulaChildInfo 配方配置子信息 |
|
97 |
* @return 结果 |
|
98 |
*/ |
|
99 |
@Override |
|
100 |
public int updateBsFormulaChildInfo(BsFormulaChildInfo bsFormulaChildInfo) |
|
101 |
{ |
|
102 |
bsFormulaChildInfo.setUpdateTime(DateUtils.getNowDate()); |
|
103 |
return bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfo); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* 批量删除配方配置子信息 |
|
108 |
* |
|
109 |
* @param ids 需要删除的配方配置子信息主键 |
|
110 |
* @return 结果 |
|
111 |
*/ |
|
112 |
@Override |
|
113 |
public int deleteBsFormulaChildInfoByIds(Long[] ids) |
|
114 |
{ |
|
115 |
return bsFormulaChildInfoMapper.deleteBsFormulaChildInfoByIds(ids); |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* 删除配方配置子信息信息 |
|
120 |
* |
|
121 |
* @param id 配方配置子信息主键 |
|
122 |
* @return 结果 |
|
123 |
*/ |
|
124 |
@Override |
|
125 |
public int deleteBsFormulaChildInfoById(Long id) |
|
126 |
{ |
|
127 |
return bsFormulaChildInfoMapper.deleteBsFormulaChildInfoById(id); |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public BsFormulaChildInfo selectBsFormulaChildInfoByTypeTopOne(String type,String productCode,String processesCode) { |
|
132 |
BsFormulaChildInfo info = new BsFormulaChildInfo(); |
|
133 |
info.setOperationType(type); |
|
134 |
info.setProcessesCode(processesCode); |
|
135 |
info.setProductCode(productCode); |
|
136 |
return bsFormulaChildInfoMapper.selectBsFormulaChildInfoByTypeTopOne(info); |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
b77303
|
140 |
public BsFormulaChildInfo getCount(String productCode, String processesCode) { |
懒 |
141 |
BsFormulaChildInfo info = new BsFormulaChildInfo(); |
|
142 |
info.setProcessesCode(processesCode); |
|
143 |
info.setProductCode(productCode); |
|
144 |
return bsFormulaChildInfoMapper.getCount(info); |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
public BsFormulaChildInfo releaseCheck(BsFormulaChildInfo bsFormulaChildInfo) { |
e57a89
|
149 |
return bsFormulaChildInfoMapper.releaseCheck(bsFormulaChildInfo); |
懒 |
150 |
} |
|
151 |
|
c5e9c5
|
152 |
//1-非本工位物料 2-正常扫描可继续下次 3-扫描结束已经是最后一位工步 |
e57a89
|
153 |
@Override |
懒 |
154 |
public AjaxResult updateResults(BsFormulaChildInfo bsFormulaChildInfo) { |
c5e9c5
|
155 |
String result = ""; |
5316c5
|
156 |
List<BsFormulaChildInfo> bsFormulaChildInfos = new ArrayList<>(); |
A |
157 |
List<BsFormulaChildInfo> infos = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
e70fb4
|
158 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode()) |
A |
159 |
.eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()) |
5316c5
|
160 |
.eq(BsFormulaChildInfo::getOperationType, "2") |
e70fb4
|
161 |
); |
5316c5
|
162 |
for (BsFormulaChildInfo formulaChildInfo : infos) { |
A |
163 |
if(bsFormulaChildInfo.getScanBarcode().contains(formulaChildInfo.getMaterialCode())){ |
|
164 |
bsFormulaChildInfos.add(formulaChildInfo); |
|
165 |
break; |
|
166 |
} |
|
167 |
} |
e57a89
|
168 |
if(bsFormulaChildInfos.size()>0){ |
c5e9c5
|
169 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
3c2299
|
170 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getScanBarcode()); |
e57a89
|
171 |
bsFormulaChildInfos.get(0).setResults("OK"); |
懒 |
172 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
49c784
|
173 |
bsFormulaChildInfo.setParamValue(bsFormulaChildInfo.getScanBarcode()); |
b64ed2
|
174 |
bsFormulaChildInfo.setParamCode(bsFormulaChildInfos.get(0).getParamCode()); |
49c784
|
175 |
bsFormulaChildInfo.setSfcBarcode(bsFormulaChildInfo.getSfcBarcode()); |
b64ed2
|
176 |
addParameterCollection(bsFormulaChildInfo); |
c5e9c5
|
177 |
if (spareField4 != null && !spareField4.isEmpty()) { |
懒 |
178 |
// 执行操作 |
|
179 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
180 |
try { |
|
181 |
result = "3"; |
|
182 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build()); |
|
183 |
} catch (Exception e) { |
|
184 |
throw new RuntimeException(e); |
|
185 |
} |
|
186 |
} |
|
187 |
} |
e57a89
|
188 |
}else { |
c5e9c5
|
189 |
result = "1"; |
e57a89
|
190 |
} |
c5e9c5
|
191 |
return AjaxResult.success(result); |
e57a89
|
192 |
} |
懒 |
193 |
|
b64ed2
|
194 |
public void addParameterCollection(BsFormulaChildInfo bsFormulaChildInfo){ |
懒 |
195 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
196 |
daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode()); |
|
197 |
daParamCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo()); |
|
198 |
daParamCollection.setLocationCode(bsFormulaChildInfo.getLocationCode()); |
|
199 |
daParamCollection.setParamValue(bsFormulaChildInfo.getParamValue()); |
|
200 |
daParamCollection.setProductCode(bsFormulaChildInfo.getProductCode()); |
|
201 |
daParamCollection.setCollectionTime(new Date()); |
49c784
|
202 |
daParamCollection.setSfcCode(bsFormulaChildInfo.getSfcBarcode()); |
b64ed2
|
203 |
daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
懒 |
204 |
} |
|
205 |
|
e57a89
|
206 |
@Override |
懒 |
207 |
public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) { |
63b254
|
208 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
懒 |
209 |
.eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode()) |
|
210 |
.eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode())); |
|
211 |
for (BsFormulaChildInfo info : list) { |
e70fb4
|
212 |
info.setCollectData(""); |
63b254
|
213 |
info.setResults(""); |
懒 |
214 |
bsFormulaChildInfoService.saveOrUpdate(info); |
|
215 |
} |
e57a89
|
216 |
return AjaxResult.success(); |
懒 |
217 |
} |
b77303
|
218 |
|
懒 |
219 |
@Override |
|
220 |
public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) { |
7bee80
|
221 |
BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo(); |
懒 |
222 |
getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode()); |
|
223 |
getMaterTwo.setOperationType("2"); |
|
224 |
List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo); |
|
225 |
List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList()); |
|
226 |
for (String s : collect) { |
|
227 |
if(s.equals("")){ |
|
228 |
return AjaxResult.error("扫描未完成,禁止拧紧操作!"); |
|
229 |
} |
|
230 |
} |
b77303
|
231 |
BsFormulaChildInfo listQuery = new BsFormulaChildInfo(); |
懒 |
232 |
listQuery.setParamCode(bsFormulaChildInfo.getParamCode()); |
|
233 |
String paramCode = bsFormulaChildInfo.getTightenTheArray(); |
|
234 |
if(paramCode.contains("N")){ |
|
235 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
|
236 |
bsFormulaChildInfos.get(0).setResults("NG"); |
|
237 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray()); |
|
238 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
|
239 |
return AjaxResult.error("扫描结果NG,请重新扫描!"); |
|
240 |
}else { |
|
241 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery); |
|
242 |
bsFormulaChildInfos.get(0).setResults("OK"); |
|
243 |
bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray()); |
|
244 |
bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0)); |
3c2299
|
245 |
String spareField4 = bsFormulaChildInfos.get(0).getSpareField4(); |
懒 |
246 |
if (spareField4 != null && !spareField4.isEmpty()) { |
|
247 |
// 执行操作 |
|
248 |
if(bsFormulaChildInfos.get(0).getSpareField4().equals("1")){ |
|
249 |
try { |
32483a
|
250 |
// //更新过站记录表出站时间 |
懒 |
251 |
// DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
|
252 |
// daPassingStationCollection.setWorkOrderNo(bsFormulaChildInfo.getWorkOrderNo()); |
|
253 |
// List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); |
|
254 |
// daPassingStationCollections.get(0).setOutboundTime(new Date()); |
|
255 |
// daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
b5fcd8
|
256 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build()); |
3c2299
|
257 |
WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT"); |
懒 |
258 |
} catch (Exception e) { |
|
259 |
throw new RuntimeException(e); |
|
260 |
} |
|
261 |
} |
|
262 |
} |
|
263 |
|
b77303
|
264 |
} |
懒 |
265 |
return AjaxResult.success("扫描成功!"); |
|
266 |
} |
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
e57a89
|
271 |
} |