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