提交 | 用户 | 时间
|
fd2207
|
1 |
package com.jcdm.main.om.productionOrde.controller; |
懒 |
2 |
|
8876c2
|
3 |
import cn.hutool.core.collection.CollUtil; |
W |
4 |
import cn.hutool.core.util.ObjectUtil; |
131e8c
|
5 |
import cn.hutool.core.util.StrUtil; |
7dc046
|
6 |
import com.jcdm.common.annotation.Log; |
W |
7 |
import com.jcdm.common.core.controller.BaseController; |
|
8 |
import com.jcdm.common.core.domain.AjaxResult; |
|
9 |
import com.jcdm.common.core.page.TableDataInfo; |
|
10 |
import com.jcdm.common.enums.BusinessType; |
131e8c
|
11 |
import com.jcdm.common.exception.ServiceException; |
7dc046
|
12 |
import com.jcdm.common.utils.poi.ExcelUtil; |
749044
|
13 |
import com.jcdm.main.bs.modelNumber.domain.BsModelNumber; |
C |
14 |
import com.jcdm.main.bs.modelNumber.service.IBsModelNumberService; |
05d425
|
15 |
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling; |
C |
16 |
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService; |
fd2207
|
17 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
懒 |
18 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
df1f2b
|
19 |
import com.jcdm.main.webservice.service.ReceivingServices; |
05d425
|
20 |
import org.apache.commons.lang3.StringUtils; |
fd2207
|
21 |
import org.springframework.beans.factory.annotation.Autowired; |
7dc046
|
22 |
import org.springframework.security.access.prepost.PreAuthorize; |
W |
23 |
import org.springframework.web.bind.annotation.*; |
|
24 |
|
|
25 |
import javax.servlet.http.HttpServletResponse; |
|
26 |
import java.time.LocalDateTime; |
|
27 |
import java.time.format.DateTimeFormatter; |
8876c2
|
28 |
import java.util.Comparator; |
7dc046
|
29 |
import java.util.List; |
8876c2
|
30 |
import java.util.stream.Collectors; |
f11989
|
31 |
|
懒 |
32 |
import static org.apache.commons.lang3.SystemUtils.getUserName; |
fd2207
|
33 |
|
懒 |
34 |
/** |
|
35 |
* 生产工单Controller |
|
36 |
* |
|
37 |
* @author ruimin |
|
38 |
* @date 2023-12-11 |
|
39 |
*/ |
|
40 |
@RestController |
|
41 |
@RequestMapping("/om/productionOrde") |
|
42 |
public class OmProductionOrdeInfoController extends BaseController |
|
43 |
{ |
|
44 |
@Autowired |
|
45 |
private IOmProductionOrdeInfoService omProductionOrdeInfoService; |
05d425
|
46 |
|
C |
47 |
@Autowired |
|
48 |
private IBsOrderSchedulingService bsOrderSchedulingService; |
749044
|
49 |
|
C |
50 |
@Autowired |
|
51 |
private IBsModelNumberService bsModelNumberService; |
fd2207
|
52 |
|
懒 |
53 |
/** |
|
54 |
* 查询生产工单列表 |
|
55 |
*/ |
|
56 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:list')") |
|
57 |
@GetMapping("/list") |
|
58 |
public TableDataInfo list(OmProductionOrdeInfo omProductionOrdeInfo) |
|
59 |
{ |
|
60 |
startPage(); |
2d1514
|
61 |
if (StrUtil.isNotBlank(omProductionOrdeInfo.getEngineNo())){ |
W |
62 |
BsOrderScheduling bsOrderScheduling = bsOrderSchedulingService.selectBsOrderSchedulingSNCode(omProductionOrdeInfo.getEngineNo()); |
|
63 |
if (ObjectUtil.isNotEmpty(bsOrderScheduling)){ |
|
64 |
String orderNo = bsOrderScheduling.getOrderNo(); |
|
65 |
if (StrUtil.isNotBlank(orderNo)){ |
|
66 |
omProductionOrdeInfo.setWorkOrderNo(orderNo); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
fd2207
|
70 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
懒 |
71 |
return getDataTable(list); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* 导出生产工单列表 |
|
76 |
*/ |
|
77 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:export')") |
|
78 |
@Log(title = "生产工单", businessType = BusinessType.EXPORT) |
|
79 |
@PostMapping("/export") |
|
80 |
public void export(HttpServletResponse response, OmProductionOrdeInfo omProductionOrdeInfo) |
|
81 |
{ |
|
82 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
|
83 |
ExcelUtil<OmProductionOrdeInfo> util = new ExcelUtil<OmProductionOrdeInfo>(OmProductionOrdeInfo.class); |
|
84 |
util.exportExcel(response, list, "生产工单数据"); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* 获取生产工单详细信息 |
|
89 |
*/ |
696fd5
|
90 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:query')") |
Y |
91 |
@GetMapping(value = "/{id}") |
|
92 |
public AjaxResult getInfo(@PathVariable("id") Long id) |
|
93 |
{ |
|
94 |
return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id)); |
|
95 |
} |
d4f437
|
96 |
|
Y |
97 |
/** |
|
98 |
* 获取生产工单详细信息 |
|
99 |
*/ |
fd2207
|
100 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:query')") |
696fd5
|
101 |
@GetMapping("/ids/{ids}") |
d4f437
|
102 |
public AjaxResult getInfo(@PathVariable Long[] ids) |
fd2207
|
103 |
{ |
8876c2
|
104 |
List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrderListById(ids); |
W |
105 |
if (CollUtil.isNotEmpty(omProductionOrdeInfos)){ |
|
106 |
List<String> collect = omProductionOrdeInfos.stream().map(OmProductionOrdeInfo::getProductCode).distinct().collect(Collectors.toList()); |
|
107 |
if (CollUtil.isNotEmpty(collect)){ |
|
108 |
if (collect.size()>1){ |
|
109 |
return error("存在多个不同的产品编号,请检查"); |
|
110 |
} |
|
111 |
} |
|
112 |
List<String> collect1 = omProductionOrdeInfos.stream().map(OmProductionOrdeInfo::getOrderStatus).distinct().collect(Collectors.toList()); |
|
113 |
if (CollUtil.isNotEmpty(collect1)){ |
|
114 |
if (collect1.size()>1){ |
|
115 |
return error("存在多个不同的工单状态,请检查"); |
|
116 |
} |
|
117 |
} |
|
118 |
} |
d4f437
|
119 |
return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoByIds(ids)); |
fd2207
|
120 |
} |
懒 |
121 |
|
|
122 |
/** |
|
123 |
* 新增生产工单 |
|
124 |
*/ |
|
125 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:add')") |
|
126 |
@Log(title = "生产工单", businessType = BusinessType.INSERT) |
|
127 |
@PostMapping |
|
128 |
public AjaxResult add(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
129 |
{ |
|
130 |
return toAjax(omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo)); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
e0a2b8
|
134 |
* 生成按钮 |
05d425
|
135 |
*/ |
C |
136 |
@PostMapping("/orderSchedulingForBoxCode") |
|
137 |
public AjaxResult addOrderSchedulingForBoxCode(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
138 |
{ |
696fd5
|
139 |
|
64e175
|
140 |
//获取当前时间 |
懒 |
141 |
LocalDateTime date= LocalDateTime.now(); |
|
142 |
//创建日期时间对象格式化器,日期格式类似: 2023-05-23 22:18:38 |
|
143 |
DateTimeFormatter formatter= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
144 |
//将时间转化为对应格式的字符串 |
|
145 |
String fomateDate=date.format(formatter).toString(); |
749044
|
146 |
|
05d425
|
147 |
Integer startCode = Integer.parseInt(omProductionOrdeInfo.getStartCode());//开始编号 |
696fd5
|
148 |
|
05d425
|
149 |
String dateTimeRule = omProductionOrdeInfo.getDateTimeRule(); |
C |
150 |
|
8876c2
|
151 |
//校验编号重复 |
W |
152 |
BsModelNumber bsModelNumberCheck = new BsModelNumber(); |
|
153 |
bsModelNumberCheck.setModel(omProductionOrdeInfo.getTypeZ()); |
|
154 |
bsModelNumberCheck.setModelDate(dateTimeRule); |
|
155 |
List<BsModelNumber> numbers = bsModelNumberService.selectBsModelNumberList(bsModelNumberCheck); |
|
156 |
BsModelNumber bsModelNumber = new BsModelNumber(); |
|
157 |
Integer maxNum = 0; |
|
158 |
if (CollUtil.isNotEmpty(numbers)){ |
|
159 |
bsModelNumber = numbers.get(0); |
|
160 |
String maxnumValue = bsModelNumber.getMaxnumValue(); |
|
161 |
if (StrUtil.isNotBlank(maxnumValue)){ |
|
162 |
maxNum = Integer.parseInt(maxnumValue); |
749044
|
163 |
} |
8876c2
|
164 |
} |
W |
165 |
if (startCode<=maxNum){ |
|
166 |
return AjaxResult.error("编号重复,请检查!"); |
|
167 |
} |
|
168 |
Long[] id=omProductionOrdeInfo.getIdNums(); |
|
169 |
List<OmProductionOrdeInfo> omProductionOrdeInfoList = omProductionOrdeInfoService.selectOmProductionOrderListById(id); |
|
170 |
if (CollUtil.isNotEmpty(omProductionOrdeInfoList)){ |
|
171 |
omProductionOrdeInfoList.forEach(x -> { |
|
172 |
if (ObjectUtil.isNotNull(x.getWorkOrderNo())){ |
|
173 |
long l = Long.parseLong(x.getWorkOrderNo()); |
|
174 |
x.setWorkOrderNoLong(l); |
|
175 |
} |
|
176 |
}); |
|
177 |
List<OmProductionOrdeInfo> sortList = omProductionOrdeInfoList.stream().sorted(Comparator.comparing(OmProductionOrdeInfo::getWorkOrderNoLong)).collect(Collectors.toList()); |
|
178 |
for (OmProductionOrdeInfo ProductionOrde : sortList) { |
|
179 |
Integer planQty = Math.toIntExact(ProductionOrde.getPlanQty());//计划数量 |
|
180 |
if(planQty>0) { |
|
181 |
for (int i = 0; i < planQty; i++) { |
|
182 |
String engineNo = omProductionOrdeInfo.getTypeZ() + " " + dateTimeRule + StringUtils.leftPad(String.valueOf(startCode), 3, "0"); |
|
183 |
BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); |
|
184 |
bsOrderScheduling.setOrderNo(ProductionOrde.getWorkOrderNo()); |
|
185 |
bsOrderScheduling.setWorkingHours(String.valueOf(i+1)); |
|
186 |
bsOrderScheduling.setModel(ProductionOrde.getTypeZ()); |
|
187 |
bsOrderScheduling.setEngineNo(engineNo); |
|
188 |
bsOrderScheduling.setProductionStatus("1"); |
|
189 |
bsOrderScheduling.setOperator(getUserName()); |
|
190 |
bsOrderScheduling.setOperateTime(fomateDate); |
|
191 |
bsOrderScheduling.setProductType(ProductionOrde.getTypeL());//产品类型 |
|
192 |
bsOrderScheduling.setWhetherOrPrint("0"); |
|
193 |
bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling); |
|
194 |
startCode++; |
|
195 |
} |
|
196 |
} |
|
197 |
//更新工单状态 |
|
198 |
ProductionOrde.setOrderStatus("2"); |
|
199 |
omProductionOrdeInfoService.updateOmProductionOrdeInfo(ProductionOrde); |
|
200 |
} |
749044
|
201 |
} |
696fd5
|
202 |
//新增机型序号 |
8876c2
|
203 |
if (ObjectUtil.isNotNull(bsModelNumber.getId())){ |
W |
204 |
bsModelNumber.setMaxnumValue((startCode - 1) + ""); |
|
205 |
bsModelNumber.setSaveTime(fomateDate); |
|
206 |
bsModelNumber.setLastNumber((startCode - 1) + ""); |
|
207 |
bsModelNumberService.updateBsModelNumber(bsModelNumber); |
|
208 |
} else { |
|
209 |
BsModelNumber bsModelNumberSave = new BsModelNumber(); |
|
210 |
bsModelNumberSave.setModel(omProductionOrdeInfo.getTypeZ()); |
|
211 |
bsModelNumberSave.setModelDate(dateTimeRule); |
|
212 |
bsModelNumberSave.setMaxnumValue((startCode - 1) + ""); |
|
213 |
bsModelNumberSave.setSaveTime(fomateDate); |
|
214 |
bsModelNumberSave.setLastNumber((startCode - 1) + ""); |
|
215 |
bsModelNumberService.insertBsModelNumber(bsModelNumberSave); |
|
216 |
} |
696fd5
|
217 |
return toAjax(1); |
05d425
|
218 |
} |
C |
219 |
|
|
220 |
/** |
fd2207
|
221 |
* 修改生产工单 |
懒 |
222 |
*/ |
|
223 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:edit')") |
|
224 |
@Log(title = "生产工单", businessType = BusinessType.UPDATE) |
|
225 |
@PutMapping |
|
226 |
public AjaxResult edit(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
227 |
{ |
|
228 |
return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo)); |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* 删除生产工单 |
|
233 |
*/ |
|
234 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:remove')") |
|
235 |
@Log(title = "生产工单", businessType = BusinessType.DELETE) |
|
236 |
@DeleteMapping("/{ids}") |
|
237 |
public AjaxResult remove(@PathVariable Long[] ids) |
|
238 |
{ |
|
239 |
return toAjax(omProductionOrdeInfoService.deleteOmProductionOrdeInfoByIds(ids)); |
|
240 |
} |
|
241 |
|
|
242 |
/** |
|
243 |
* table列上移下移 |
|
244 |
*/ |
|
245 |
@Log(title = "生产工单", businessType = BusinessType.DELETE) |
|
246 |
@GetMapping("/upDownMove") |
|
247 |
public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo) |
|
248 |
{ |
|
249 |
return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo); |
|
250 |
} |
df1f2b
|
251 |
|
懒 |
252 |
/** |
1391b3
|
253 |
* 接收工单 |
df1f2b
|
254 |
*/ |
1391b3
|
255 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:receive')") |
df1f2b
|
256 |
@GetMapping("/getProductionNotice") |
懒 |
257 |
public AjaxResult getProductionNotice(OmProductionOrdeInfo omProductionOrdeInfo) |
|
258 |
{ |
131e8c
|
259 |
String factory = omProductionOrdeInfo.getWorkshopCode(); |
5f7e70
|
260 |
String productionNotice = omProductionOrdeInfo.getProductionNotice(); |
131e8c
|
261 |
if (StrUtil.isBlank(productionNotice)){ |
W |
262 |
throw new ServiceException("请输入生产通知单号"); |
|
263 |
} |
|
264 |
if (StrUtil.isBlank(factory)){ |
|
265 |
throw new ServiceException("请选择工厂编号"); |
|
266 |
} |
51b05b
|
267 |
OmProductionOrdeInfo queryProductOrder = new OmProductionOrdeInfo(); |
W |
268 |
queryProductOrder.setWorkshopCode(factory); |
|
269 |
queryProductOrder.setProductionNotice(productionNotice); |
|
270 |
List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(queryProductOrder); |
|
271 |
if(CollUtil.isEmpty(omProductionOrdeInfos)){ |
5f7e70
|
272 |
try { |
b4ff0d
|
273 |
logger.info("接收工单号:,{}",productionNotice); |
131e8c
|
274 |
ReceivingServices.insertWebserviceData(factory,productionNotice); |
5f7e70
|
275 |
} catch (Exception e) { |
懒 |
276 |
return error("接收失败!请检查通知单号"); |
|
277 |
} |
1de44b
|
278 |
}else { |
e4f64a
|
279 |
return warn("该通知单已经接收完毕,不能重复接收!"); |
5f7e70
|
280 |
} |
1de44b
|
281 |
return AjaxResult.success("接收成功!"); |
df1f2b
|
282 |
} |
fd2207
|
283 |
} |