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