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