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