提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.main.om.productionOrde.service.impl; |
懒 |
2 |
|
768498
|
3 |
import java.text.SimpleDateFormat; |
A |
4 |
import java.util.Date; |
e57a89
|
5 |
import java.util.List; |
懒 |
6 |
import java.util.stream.Collectors; |
|
7 |
|
a759f5
|
8 |
import cn.hutool.core.util.ObjectUtil; |
768498
|
9 |
import cn.hutool.json.JSONObject; |
a75d86
|
10 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
768498
|
11 |
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
0ce25f
|
12 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
e57a89
|
13 |
import com.jcdm.common.core.domain.AjaxResult; |
懒 |
14 |
import com.jcdm.common.utils.DateUtils; |
|
15 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
|
16 |
import com.jcdm.main.om.productionOrde.mapper.OmProductionOrdeInfoMapper; |
|
17 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
e70fb4
|
18 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
8cfe20
|
19 |
import lombok.extern.slf4j.Slf4j; |
A |
20 |
import org.slf4j.Logger; |
|
21 |
import org.slf4j.LoggerFactory; |
e57a89
|
22 |
import org.springframework.beans.factory.annotation.Autowired; |
懒 |
23 |
import org.springframework.stereotype.Service; |
|
24 |
|
|
25 |
/** |
|
26 |
* 生产工单Service业务层处理 |
|
27 |
* |
|
28 |
* @author ruimin |
|
29 |
* @date 2023-12-11 |
|
30 |
*/ |
8cfe20
|
31 |
@Slf4j |
e57a89
|
32 |
@Service |
0ce25f
|
33 |
public class OmProductionOrdeInfoServiceImpl extends ServiceImpl<OmProductionOrdeInfoMapper,OmProductionOrdeInfo> implements IOmProductionOrdeInfoService |
e57a89
|
34 |
{ |
8cfe20
|
35 |
private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
768498
|
36 |
public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
8cfe20
|
37 |
|
e57a89
|
38 |
@Autowired |
懒 |
39 |
private OmProductionOrdeInfoMapper omProductionOrdeInfoMapper; |
|
40 |
|
|
41 |
@Autowired |
|
42 |
private IOmProductionOrdeInfoService omProductionOrdeInfoService; |
|
43 |
|
|
44 |
/** |
|
45 |
* 查询生产工单 |
|
46 |
* |
|
47 |
* @param id 生产工单主键 |
|
48 |
* @return 生产工单 |
|
49 |
*/ |
|
50 |
@Override |
|
51 |
public OmProductionOrdeInfo selectOmProductionOrdeInfoById(Long id) |
|
52 |
{ |
|
53 |
return omProductionOrdeInfoMapper.selectOmProductionOrdeInfoById(id); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* 查询生产工单列表 |
|
58 |
* |
|
59 |
* @param omProductionOrdeInfo 生产工单 |
|
60 |
* @return 生产工单 |
|
61 |
*/ |
|
62 |
@Override |
|
63 |
public List<OmProductionOrdeInfo> selectOmProductionOrdeInfoList(OmProductionOrdeInfo omProductionOrdeInfo) |
|
64 |
{ |
|
65 |
return omProductionOrdeInfoMapper.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* 新增生产工单 |
|
70 |
* |
|
71 |
* @param omProductionOrdeInfo 生产工单 |
|
72 |
* @return 结果 |
|
73 |
*/ |
|
74 |
@Override |
|
75 |
public int insertOmProductionOrdeInfo(OmProductionOrdeInfo omProductionOrdeInfo) |
|
76 |
{ |
|
77 |
omProductionOrdeInfo.setCreateTime(DateUtils.getNowDate()); |
|
78 |
Integer streamNumber = omProductionOrdeInfoMapper.getMaxStreamNumber(); |
|
79 |
omProductionOrdeInfo.setStreamNumber(String.valueOf(streamNumber+1)); |
|
80 |
return omProductionOrdeInfoMapper.insertOmProductionOrdeInfo(omProductionOrdeInfo); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* 修改生产工单 |
|
85 |
* |
|
86 |
* @param omProductionOrdeInfo 生产工单 |
|
87 |
* @return 结果 |
|
88 |
*/ |
|
89 |
@Override |
|
90 |
public int updateOmProductionOrdeInfo(OmProductionOrdeInfo omProductionOrdeInfo) |
|
91 |
{ |
|
92 |
omProductionOrdeInfo.setUpdateTime(DateUtils.getNowDate()); |
|
93 |
return omProductionOrdeInfoMapper.updateOmProductionOrdeInfo(omProductionOrdeInfo); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* 批量删除生产工单 |
|
98 |
* |
|
99 |
* @param ids 需要删除的生产工单主键 |
|
100 |
* @return 结果 |
|
101 |
*/ |
|
102 |
@Override |
|
103 |
public int deleteOmProductionOrdeInfoByIds(Long[] ids) |
|
104 |
{ |
|
105 |
return omProductionOrdeInfoMapper.deleteOmProductionOrdeInfoByIds(ids); |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* 删除生产工单信息 |
|
110 |
* |
|
111 |
* @param id 生产工单主键 |
|
112 |
* @return 结果 |
|
113 |
*/ |
|
114 |
@Override |
|
115 |
public int deleteOmProductionOrdeInfoById(Long id) |
|
116 |
{ |
|
117 |
return omProductionOrdeInfoMapper.deleteOmProductionOrdeInfoById(id); |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo) { |
|
122 |
long currentId = omProductionOrdeInfo.getFrontEndId(); |
|
123 |
List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
|
124 |
List<Long> idList = omProductionOrdeInfos.stream() |
|
125 |
.map(OmProductionOrdeInfo::getId) // 提取id属性 |
|
126 |
.collect(Collectors.toList()); |
|
127 |
int index = idList.indexOf(currentId); |
|
128 |
long moveId = 0L; |
|
129 |
try { |
|
130 |
if(omProductionOrdeInfo.getFlag().equals("up")){ |
|
131 |
moveId = idList.get(index - 1); |
|
132 |
}else { |
|
133 |
moveId = idList.get(index + 1); |
|
134 |
} |
|
135 |
}catch (Exception e){ |
|
136 |
return AjaxResult.error("当前工单为最后一个或第一个,无法移动"); |
|
137 |
} |
|
138 |
OmProductionOrdeInfo currentInfo = new OmProductionOrdeInfo(); |
|
139 |
currentInfo.setId(currentId); |
|
140 |
List<OmProductionOrdeInfo> currentOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(currentInfo); |
|
141 |
String currentStreamNumber = currentOrdeInfos.get(0).getStreamNumber(); |
|
142 |
OmProductionOrdeInfo moveInfo = new OmProductionOrdeInfo(); |
|
143 |
moveInfo.setId(moveId); |
|
144 |
List<OmProductionOrdeInfo> moveOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(moveInfo); |
|
145 |
String moveStreamNumber = moveOrdeInfos.get(0).getStreamNumber(); |
|
146 |
moveOrdeInfos.get(0).setStreamNumber(currentStreamNumber); |
|
147 |
omProductionOrdeInfoService.updateOmProductionOrdeInfo(moveOrdeInfos.get(0)); |
|
148 |
currentOrdeInfos.get(0).setStreamNumber(moveStreamNumber); |
|
149 |
omProductionOrdeInfoService.updateOmProductionOrdeInfo(currentOrdeInfos.get(0)); |
|
150 |
return AjaxResult.success("移动成功"); |
|
151 |
} |
42cfe3
|
152 |
|
懒 |
153 |
@Override |
|
154 |
public void overrideSaveBatch(List<OmProductionOrdeInfo> omProductionOrdeInfoList) { |
|
155 |
try { |
|
156 |
this.saveBatch(omProductionOrdeInfoList); |
|
157 |
}catch (Exception e){ |
|
158 |
return; |
|
159 |
} |
|
160 |
} |
e70fb4
|
161 |
|
A |
162 |
@Override |
|
163 |
public AjaxResult receivingWorkOrders() { |
|
164 |
return null; |
|
165 |
} |
a75d86
|
166 |
|
A |
167 |
@Override |
|
168 |
public AjaxResult trolleyYardBinDing(OmProductionOrdeInfo omProductionOrdeInfo) { |
a759f5
|
169 |
OmProductionOrdeInfo clearTrolleyYard = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, omProductionOrdeInfo.getTrolleyYard())); |
A |
170 |
if(clearTrolleyYard!=null){ |
|
171 |
clearTrolleyYard.setTrolleyYard(""); |
|
172 |
omProductionOrdeInfoService.saveOrUpdate(clearTrolleyYard); |
|
173 |
} |
a75d86
|
174 |
OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum())); |
A |
175 |
one.setTrolleyYard(omProductionOrdeInfo.getTrolleyYard()); |
|
176 |
omProductionOrdeInfoService.saveOrUpdate(one); |
8cfe20
|
177 |
logger.info("绑定pack码{}到小车:{}",omProductionOrdeInfo.getProductNum(),omProductionOrdeInfo.getTrolleyYard()); |
A |
178 |
|
a75d86
|
179 |
return AjaxResult.success(); |
A |
180 |
} |
|
181 |
|
|
182 |
@Override |
|
183 |
public AjaxResult getCarCodeSize(OmProductionOrdeInfo omProductionOrdeInfo) { |
|
184 |
// omProductionOrdeInfo. |
|
185 |
return null; |
|
186 |
} |
|
187 |
|
|
188 |
@Override |
|
189 |
public AjaxResult findBytrolleyYardGetOne(OmProductionOrdeInfo omProductionOrdeInfo) { |
4a5f2a
|
190 |
String str = ""; |
a75d86
|
191 |
OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, omProductionOrdeInfo.getTrolleyYard())); |
4a5f2a
|
192 |
if(one == null){ |
A |
193 |
str = "2"; |
|
194 |
}else { |
|
195 |
str = one.getProductNum(); |
|
196 |
} |
|
197 |
return AjaxResult.success(str); |
a75d86
|
198 |
} |
237733
|
199 |
|
A |
200 |
@Override |
|
201 |
public List<OmProductionOrdeInfo> checkCarCode(OmProductionOrdeInfo omProductionOrdeInfo) { |
|
202 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum()).isNotNull(OmProductionOrdeInfo::getTrolleyYard)); |
|
203 |
return list; |
|
204 |
} |
768498
|
205 |
|
A |
206 |
@Override |
|
207 |
public AjaxResult workReportingByStation(OmProductionOrdeInfo info) { |
|
208 |
OmProductionOrdeInfo omProductionOrdeInfo = omProductionOrdeInfoService.getById(info.getId()); |
|
209 |
logger.info("OP230报工开始-工厂MES异步方法"); |
|
210 |
String reportResult = RestfulService.getWorkReportResultFeedback(omProductionOrdeInfo.getProductNum(), info.getStationCode(), format.format(new Date())); |
|
211 |
JSONObject jsonObject = new JSONObject(reportResult); |
|
212 |
String code = jsonObject.getStr("code"); |
|
213 |
String status = jsonObject.getJSONObject("data").getStr("resultCode"); |
|
214 |
if("success".equals(code)&&"S".equals(status)){ |
|
215 |
//如果成功,执行报工成功方法,修改是否报工为1,添加报工时间 |
|
216 |
this.updateOrderByProductNum("1",omProductionOrdeInfo.getProductNum(),info.getStationCode()); |
|
217 |
}else{ |
|
218 |
//解析工厂mes返回结果,如果失败,执行报工失败方法,修改是否报工为2,添加报工时间 |
|
219 |
this.updateOrderByProductNum("2",omProductionOrdeInfo.getProductNum(),info.getStationCode()); |
|
220 |
} |
|
221 |
return null; |
|
222 |
} |
|
223 |
|
|
224 |
@Override |
|
225 |
public void updateOrderByProductNum(String onlineCompletionMark, String productNum, String stationCode) { |
|
226 |
LambdaUpdateWrapper<OmProductionOrdeInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
4e83fa
|
227 |
if(stationCode.equals("POP230")){ |
768498
|
228 |
updateWrapper.set(OmProductionOrdeInfo::getOnlineCompletionMark,onlineCompletionMark); |
A |
229 |
updateWrapper.set(OmProductionOrdeInfo::getActualStartTime,new Date()); |
|
230 |
} |
4e83fa
|
231 |
if(stationCode.equals("POP430")){ |
768498
|
232 |
updateWrapper.set(OmProductionOrdeInfo::getSfResult,onlineCompletionMark); |
A |
233 |
} |
|
234 |
updateWrapper.eq(OmProductionOrdeInfo::getProductNum,productNum); |
|
235 |
OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
|
236 |
omProductionOrdeInfoService.update(omProductionOrdeInfo,updateWrapper); |
|
237 |
} |
e57a89
|
238 |
} |