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