提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.main.om.productionOrde.controller; |
懒 |
2 |
|
42cfe3
|
3 |
import java.util.ArrayList; |
懒 |
4 |
import java.util.Date; |
e57a89
|
5 |
import java.util.List; |
懒 |
6 |
import javax.servlet.http.HttpServletResponse; |
0ce25f
|
7 |
|
c860ca
|
8 |
import cn.hutool.json.JSONObject; |
0ce25f
|
9 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
c860ca
|
10 |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
42cfe3
|
11 |
import com.jcdm.common.core.domain.entity.SysUser; |
懒 |
12 |
import com.jcdm.common.core.domain.model.LoginUser; |
|
13 |
import com.jcdm.common.utils.ServletUtils; |
237733
|
14 |
import com.jcdm.common.utils.StringUtils; |
e57a89
|
15 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
42cfe3
|
16 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfoExcelImport; |
c860ca
|
17 |
import com.jcdm.main.om.productionOrde.mapper.OmProductionOrdeInfoMapper; |
e57a89
|
18 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
c860ca
|
19 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
8cfe20
|
20 |
import lombok.extern.slf4j.Slf4j; |
c860ca
|
21 |
import org.aspectj.weaver.loadtime.Aj; |
8cfe20
|
22 |
import org.slf4j.Logger; |
A |
23 |
import org.slf4j.LoggerFactory; |
e57a89
|
24 |
import org.springframework.security.access.prepost.PreAuthorize; |
懒 |
25 |
import org.springframework.beans.factory.annotation.Autowired; |
|
26 |
import org.springframework.web.bind.annotation.GetMapping; |
|
27 |
import org.springframework.web.bind.annotation.PostMapping; |
|
28 |
import org.springframework.web.bind.annotation.PutMapping; |
|
29 |
import org.springframework.web.bind.annotation.DeleteMapping; |
|
30 |
import org.springframework.web.bind.annotation.PathVariable; |
|
31 |
import org.springframework.web.bind.annotation.RequestBody; |
|
32 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
33 |
import org.springframework.web.bind.annotation.RestController; |
|
34 |
import com.jcdm.common.annotation.Log; |
|
35 |
import com.jcdm.common.core.controller.BaseController; |
|
36 |
import com.jcdm.common.core.domain.AjaxResult; |
|
37 |
import com.jcdm.common.enums.BusinessType; |
|
38 |
import com.jcdm.common.utils.poi.ExcelUtil; |
|
39 |
import com.jcdm.common.core.page.TableDataInfo; |
42cfe3
|
40 |
import org.springframework.web.multipart.MultipartFile; |
e57a89
|
41 |
|
懒 |
42 |
/** |
|
43 |
* 生产工单Controller |
|
44 |
* |
|
45 |
* @author ruimin |
|
46 |
* @date 2023-12-11 |
|
47 |
*/ |
8cfe20
|
48 |
@Slf4j |
e57a89
|
49 |
@RestController |
懒 |
50 |
@RequestMapping("/om/productionOrde") |
|
51 |
public class OmProductionOrdeInfoController extends BaseController |
|
52 |
{ |
8cfe20
|
53 |
private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
A |
54 |
|
e57a89
|
55 |
@Autowired |
懒 |
56 |
private IOmProductionOrdeInfoService omProductionOrdeInfoService; |
|
57 |
|
|
58 |
/** |
|
59 |
* 查询生产工单列表 |
|
60 |
*/ |
|
61 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:list')") |
|
62 |
@GetMapping("/list") |
|
63 |
public TableDataInfo list(OmProductionOrdeInfo omProductionOrdeInfo) |
|
64 |
{ |
|
65 |
startPage(); |
0ce25f
|
66 |
// List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getWorkOrderNo, "W_202403120001")); |
e57a89
|
67 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
懒 |
68 |
return getDataTable(list); |
|
69 |
} |
|
70 |
|
237733
|
71 |
@GetMapping("/checkCarCode") |
A |
72 |
public AjaxResult checkCarCode(OmProductionOrdeInfo omProductionOrdeInfo) |
|
73 |
{ |
|
74 |
Integer i = 0; |
|
75 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum())); |
|
76 |
if(StringUtils.isNotBlank(list.get(0).getTrolleyYard())){ |
|
77 |
i = 1; |
|
78 |
} |
|
79 |
return AjaxResult.success(i); |
|
80 |
} |
|
81 |
|
|
82 |
@GetMapping("/checkYzSfcCode") |
|
83 |
public AjaxResult checkYzSfcCode(OmProductionOrdeInfo omProductionOrdeInfo) |
|
84 |
{ |
|
85 |
Integer i = 0; |
|
86 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum())); |
|
87 |
if(StringUtils.isNotBlank(list.get(0).getSpareField2())){ |
|
88 |
i = 1; |
|
89 |
} |
|
90 |
return AjaxResult.success(i); |
|
91 |
} |
|
92 |
|
|
93 |
@GetMapping("/bindYzSfcFlag") |
|
94 |
public AjaxResult bindYzSfcFlag(OmProductionOrdeInfo omProductionOrdeInfo) |
|
95 |
{ |
|
96 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, omProductionOrdeInfo.getProductNum())); |
|
97 |
list.get(0).setSpareField2("1"); |
|
98 |
omProductionOrdeInfoService.saveOrUpdate(list.get(0)); |
|
99 |
return AjaxResult.success(null); |
|
100 |
} |
|
101 |
|
e57a89
|
102 |
/** |
懒 |
103 |
* 导出生产工单列表 |
|
104 |
*/ |
|
105 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:export')") |
|
106 |
@Log(title = "生产工单", businessType = BusinessType.EXPORT) |
|
107 |
@PostMapping("/export") |
|
108 |
public void export(HttpServletResponse response, OmProductionOrdeInfo omProductionOrdeInfo) |
|
109 |
{ |
|
110 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
|
111 |
ExcelUtil<OmProductionOrdeInfo> util = new ExcelUtil<OmProductionOrdeInfo>(OmProductionOrdeInfo.class); |
|
112 |
util.exportExcel(response, list, "生产工单数据"); |
|
113 |
} |
|
114 |
|
c860ca
|
115 |
@GetMapping("/receivingWorkOrders") |
A |
116 |
public AjaxResult receivingWorkOrders() |
|
117 |
{ |
|
118 |
String paramProductNum = ""; |
|
119 |
// 查询最新的工单信息 |
|
120 |
List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().orderByAsc(OmProductionOrdeInfo::getCreateTime)); |
|
121 |
if(list.size() > 0){ |
|
122 |
paramProductNum = list.get(list.size()-1).getProductNum(); |
|
123 |
} |
4e83fa
|
124 |
String orderJsonString = RestfulService.getProductionWorkOrderRequest(paramProductNum, "POP230"); |
c860ca
|
125 |
JSONObject jsonObject = new JSONObject(orderJsonString); |
A |
126 |
// 从JSONObject中获取data对象 |
|
127 |
JSONObject dataObject = jsonObject.getJSONObject("data"); |
|
128 |
String code = jsonObject.getStr("code"); |
|
129 |
// 判断接单是否成功 |
|
130 |
if(code.equals("success")){ |
8cfe20
|
131 |
logger.info("请求工厂MES工单:入参pack{}出参pack:{}",paramProductNum,dataObject.getStr("productNum")); |
A |
132 |
List<OmProductionOrdeInfo> check = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum,dataObject.getStr("productNum"))); |
|
133 |
if(check.size() == 0){ |
|
134 |
OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
|
135 |
omProductionOrdeInfo.setWorkOrderNo(dataObject.getStr("productionOrderNum")); |
|
136 |
omProductionOrdeInfo.setProductNum(dataObject.getStr("productNum")); |
|
137 |
omProductionOrdeInfo.setStationCode(dataObject.getStr("stationCode")); |
|
138 |
omProductionOrdeInfo.setMaterialCode(dataObject.getStr("materialCode")); |
768498
|
139 |
omProductionOrdeInfo.setOnlineCompletionMark("0"); |
A |
140 |
omProductionOrdeInfo.setSfResult("0"); |
273d64
|
141 |
if(dataObject.getStr("model").equals("PE01B")){ |
A |
142 |
omProductionOrdeInfo.setSoftwareVersionCode("2"); |
8cfe20
|
143 |
}else { |
273d64
|
144 |
omProductionOrdeInfo.setSoftwareVersionCode("0"); |
8cfe20
|
145 |
} |
273d64
|
146 |
omProductionOrdeInfo.setProductCode(dataObject.getStr("model")); |
8cfe20
|
147 |
omProductionOrdeInfo.setCreateTime(new Date()); |
A |
148 |
omProductionOrdeInfo.setCreateUser("工厂MES"); |
|
149 |
omProductionOrdeInfoService.save(omProductionOrdeInfo); |
a846f2
|
150 |
} |
c860ca
|
151 |
}else { |
A |
152 |
return AjaxResult.error("接单失败,请联系管理员"); |
|
153 |
} |
|
154 |
return AjaxResult.success(dataObject.getStr("productNum")); |
|
155 |
} |
|
156 |
|
a846f2
|
157 |
@GetMapping(value = "/jieBang/{id}") |
A |
158 |
public AjaxResult jieBang(@PathVariable("id") Long id) |
|
159 |
{ |
|
160 |
OmProductionOrdeInfo byId = omProductionOrdeInfoService.getById(id); |
|
161 |
byId.setTrolleyYard(""); |
|
162 |
return success(omProductionOrdeInfoService.saveOrUpdate(byId)); |
|
163 |
} |
|
164 |
|
e57a89
|
165 |
/** |
懒 |
166 |
* 获取生产工单详细信息 |
|
167 |
*/ |
|
168 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:query')") |
|
169 |
@GetMapping(value = "/{id}") |
|
170 |
public AjaxResult getInfo(@PathVariable("id") Long id) |
|
171 |
{ |
|
172 |
return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id)); |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* 新增生产工单 |
|
177 |
*/ |
|
178 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:add')") |
|
179 |
@Log(title = "生产工单", businessType = BusinessType.INSERT) |
|
180 |
@PostMapping |
|
181 |
public AjaxResult add(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
182 |
{ |
|
183 |
return toAjax(omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo)); |
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* 修改生产工单 |
|
188 |
*/ |
|
189 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:edit')") |
|
190 |
@Log(title = "生产工单", businessType = BusinessType.UPDATE) |
|
191 |
@PutMapping |
|
192 |
public AjaxResult edit(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
193 |
{ |
|
194 |
return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo)); |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* 删除生产工单 |
|
199 |
*/ |
|
200 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:remove')") |
|
201 |
@Log(title = "生产工单", businessType = BusinessType.DELETE) |
|
202 |
@DeleteMapping("/{ids}") |
|
203 |
public AjaxResult remove(@PathVariable Long[] ids) |
|
204 |
{ |
|
205 |
return toAjax(omProductionOrdeInfoService.deleteOmProductionOrdeInfoByIds(ids)); |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* table列上移下移 |
|
210 |
*/ |
|
211 |
@Log(title = "生产工单", businessType = BusinessType.DELETE) |
|
212 |
@GetMapping("/upDownMove") |
|
213 |
public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo) |
|
214 |
{ |
|
215 |
return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo); |
|
216 |
} |
42cfe3
|
217 |
|
懒 |
218 |
@PostMapping("/importData") |
|
219 |
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception |
|
220 |
{ |
|
221 |
ExcelUtil<OmProductionOrdeInfo> util = new ExcelUtil<OmProductionOrdeInfo>(OmProductionOrdeInfo.class); |
|
222 |
List<OmProductionOrdeInfo> ordeInfo = util.importExcel(file.getInputStream()); |
|
223 |
for (OmProductionOrdeInfo omProductionOrdeInfo : ordeInfo) { |
|
224 |
omProductionOrdeInfo.setCreateTime(new Date()); |
|
225 |
omProductionOrdeInfo.setCreateBy("工厂MES"); |
|
226 |
} |
|
227 |
omProductionOrdeInfoService.overrideSaveBatch(ordeInfo); |
|
228 |
return AjaxResult.success(); |
|
229 |
} |
|
230 |
|
|
231 |
@PostMapping("/importTemplate") |
|
232 |
public void importTemplate(HttpServletResponse response) |
|
233 |
{ |
|
234 |
ExcelUtil<OmProductionOrdeInfoExcelImport> util = new ExcelUtil<OmProductionOrdeInfoExcelImport>(OmProductionOrdeInfoExcelImport.class); |
|
235 |
util.importTemplateExcel(response, "订单数据"); |
|
236 |
} |
a75d86
|
237 |
|
A |
238 |
@PostMapping("/trolleyYardBinDing") |
|
239 |
public AjaxResult trolleyYardBinDing(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
240 |
{ |
|
241 |
return omProductionOrdeInfoService.trolleyYardBinDing(omProductionOrdeInfo); |
|
242 |
} |
|
243 |
|
|
244 |
@PostMapping("/getCarCodeSize") |
|
245 |
public AjaxResult getCarCodeSize(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
246 |
{ |
|
247 |
return omProductionOrdeInfoService.getCarCodeSize(omProductionOrdeInfo); |
|
248 |
} |
|
249 |
|
|
250 |
@PostMapping("/findBytrolleyYardGetOne") |
|
251 |
public AjaxResult findBytrolleyYardGetOne(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
252 |
{ |
|
253 |
return omProductionOrdeInfoService.findBytrolleyYardGetOne(omProductionOrdeInfo); |
|
254 |
} |
768498
|
255 |
|
A |
256 |
@GetMapping("/workReportingByStation/{id}/{stationCode}") |
|
257 |
public AjaxResult workReportingByStation(@PathVariable("id") Long id, @PathVariable("stationCode") String stationCode) |
|
258 |
{ |
|
259 |
OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
|
260 |
omProductionOrdeInfo.setId(id); |
|
261 |
omProductionOrdeInfo.setStationCode(stationCode); |
|
262 |
return omProductionOrdeInfoService.workReportingByStation(omProductionOrdeInfo); |
|
263 |
} |
e57a89
|
264 |
} |