-
懒羊羊
2024-03-23 e20d7373595960ad6be9bd6373a3c6f186e76e5c
提交 | 用户 | 时间
e57a89 1 package com.jcdm.main.da.paramCollection.service.impl;
2
b64ed2 3 import cn.hutool.core.date.DateUtil;
0ce25f 4 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
e57a89 5 import com.jcdm.common.utils.DateUtils;
b77c7b 6 import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo;
7 import com.jcdm.main.bs.formulaChild.mapper.BsFormulaChildInfoMapper;
b64ed2 8 import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf;
9 import com.jcdm.main.da.collectionParamConf.mapper.DaCollectionParamConfMapper;
e57a89 10 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
11 import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
12 import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
32483a 13 import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
14 import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper;
15 import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
16 import com.kangaroohy.milo.model.ReadWriteEntity;
17 import com.kangaroohy.milo.service.MiloService;
e57a89 18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.stereotype.Service;
20
b64ed2 21 import java.util.*;
e57a89 22
23 /**
24  * 设备产品过程参数采集Service业务层处理
25  * 
26  * @author yyt
27  * @date 2023-12-13
28  */
29 @Service
0ce25f 30 public class DaParamCollectionServiceImpl extends ServiceImpl<DaParamCollectionMapper,DaParamCollection> implements IDaParamCollectionService
e57a89 31 {
32     @Autowired
33     private DaParamCollectionMapper daParamCollectionMapper;
b64ed2 34
35     @Autowired
36     private DaCollectionParamConfMapper daCollectionParamConfMapper;
b77c7b 37
38     @Autowired
39     private BsFormulaChildInfoMapper bsFormulaChildInfoMapper;
32483a 40
41     @Autowired
42     private MiloService miloService;
43
44     @Autowired
45     private DaPassingStationCollectionMapper daPassingStationCollectionMapper;
e57a89 46
47     /**
48      * 查询设备产品过程参数采集
49      * 
50      * @param id 设备产品过程参数采集主键
51      * @return 设备产品过程参数采集
52      */
53     @Override
54     public DaParamCollection selectDaParamCollectionById(Long id)
55     {
56         return daParamCollectionMapper.selectDaParamCollectionById(id);
57     }
58
59     /**
60      * 查询设备产品过程参数采集列表
61      * 
62      * @param daParamCollection 设备产品过程参数采集
63      * @return 设备产品过程参数采集
64      */
65     @Override
66     public List<DaParamCollection> selectDaParamCollectionList(DaParamCollection daParamCollection)
67     {
68         return daParamCollectionMapper.selectDaParamCollectionList(daParamCollection);
69     }
70
71     /**
72      * 新增设备产品过程参数采集
73      * 
74      * @param daParamCollection 设备产品过程参数采集
75      * @return 结果
76      */
77     @Override
78     public int insertDaParamCollection(DaParamCollection daParamCollection)
79     {
80         daParamCollection.setCreateTime(DateUtils.getNowDate());
81         return daParamCollectionMapper.insertDaParamCollection(daParamCollection);
82     }
83
84     /**
85      * 修改设备产品过程参数采集
86      * 
87      * @param daParamCollection 设备产品过程参数采集
88      * @return 结果
89      */
90     @Override
91     public int updateDaParamCollection(DaParamCollection daParamCollection)
92     {
93         daParamCollection.setUpdateTime(DateUtils.getNowDate());
94         return daParamCollectionMapper.updateDaParamCollection(daParamCollection);
95     }
96
97     /**
98      * 批量删除设备产品过程参数采集
99      * 
100      * @param ids 需要删除的设备产品过程参数采集主键
101      * @return 结果
102      */
103     @Override
104     public int deleteDaParamCollectionByIds(Long[] ids)
105     {
106         return daParamCollectionMapper.deleteDaParamCollectionByIds(ids);
107     }
108
109     /**
110      * 删除设备产品过程参数采集信息
111      * 
112      * @param id 设备产品过程参数采集主键
113      * @return 结果
114      */
115     @Override
116     public int deleteDaParamCollectionById(Long id)
117     {
118         return daParamCollectionMapper.deleteDaParamCollectionById(id);
119     }
b64ed2 120
121     @Override
122     public void addBasicParameters(DaParamCollection daParamCollection) {
123         // 假设这是从数据库或其他地方获取的参数数据
124         Map<String, String> map = new HashMap<>();
125         map.put("GC", "南浔工厂");
126         map.put("CXBH", "Pack线");
127         map.put("SBBH", "设备001");
128         map.put("YGBH", "员工001");
129         map.put("GDBH", daParamCollection.getWorkOrderNo());
130         map.put("CPXH", daParamCollection.getModel());
131         map.put("INT", DateUtil.formatDateTime(new Date()));
132
133         map.forEach((key, value) -> {
134             DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
135             daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode());
136             daCollectionParamConf.setCollectParameterId(key);
137             List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf);
138             DaParamCollection saveData = new DaParamCollection();
139             saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo());
140             saveData.setProductCode(daParamCollection.getProductCode());
141             saveData.setLocationCode(daParamCollection.getLocationCode());
3c2299 142             saveData.setSfcCode(daParamCollection.getProductBarcode());
b64ed2 143             saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId());
144             saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName());
145             saveData.setCollectionTime(new Date());
146             saveData.setParamValue(value);
147             daParamCollectionMapper.insertDaParamCollection(saveData);
148         });
149     }
49c784 150
151     @Override
152     public void addTighteningParameters(DaParamCollection daParamCollection) {
b77c7b 153         String tightenData = daParamCollection.getTightenTheArray();
154         tightenData = tightenData.replace("[", "").replace("]", "").replace(" ", "");
155         String[] tightenDataParts = tightenData.split(",");
156         String paramCode = daParamCollection.getParamCode();
157         String[] paramCodeParts = paramCode.split(",");
158         for (int i = 0; i < paramCodeParts.length; i++) {
159             daParamCollection.setParamValue(tightenDataParts[i]);
160             daParamCollection.setParamCode(paramCodeParts[i]);
161             daParamCollection.setCollectionTime(new Date());
162             daParamCollection.setSfcCode(daParamCollection.getProductBarcode());
163             daParamCollectionMapper.insertDaParamCollection(daParamCollection);
164         }
49c784 165     }
32483a 166
167     @Override
168     public void saveCampaignTimeParameters(DaParamCollection daParamCollection) {
169         BsFormulaChildInfo bsFormulaChildInfo = new BsFormulaChildInfo();
170         bsFormulaChildInfo.setProcessesCode(daParamCollection.getLocationCode());
171         bsFormulaChildInfo.setProductCode(daParamCollection.getProductCode());
172         bsFormulaChildInfo.setSpareField4("1");
173         List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo);
174         String result = bsFormulaChildInfos.get(0).getResults();
175         if(result != null && !result.isEmpty()){
176             try {
177                 //过站参数采集记录出站时间
178                 DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
179                 daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode());
180                 daCollectionParamConf.setCollectParameterId("OUTT");
181                 List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf);
182                 DaParamCollection saveData = new DaParamCollection();
183                 saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo());
184                 saveData.setProductCode(daParamCollection.getProductCode());
185                 saveData.setLocationCode(daParamCollection.getLocationCode());
186                 saveData.setSfcCode(daParamCollection.getProductBarcode());
187                 saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId());
188                 saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName());
189                 saveData.setCollectionTime(new Date());
190                 saveData.setParamValue(DateUtil.formatDateTime(new Date()));
191                 daParamCollectionMapper.insertDaParamCollection(saveData);
192
193                 //更新过站记录表出站时间
194                 DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
195                 daPassingStationCollection.setWorkOrderNo(daParamCollection.getWorkOrderNo());
196                 List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection);
197                 daPassingStationCollections.get(0).setOutboundTime(new Date());
198                 int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0));
199
200                 //给opc发21
201                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("OP."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build());
202             } catch (Exception e) {
203                 throw new RuntimeException(e);
204             }
205         }
206     }
e57a89 207 }