提交 | 用户 | 时间
|
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 |
} |
288790
|
124 |
String orderJsonString = RestfulService.getProductionWorkOrderRequest(paramProductNum, "OP230"); |
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")); |
|
139 |
if(dataObject.getStr("model").equals("PE01A")){ |
|
140 |
omProductionOrdeInfo.setProductCode("1P102S"); |
|
141 |
}else { |
|
142 |
omProductionOrdeInfo.setProductCode(dataObject.getStr("model")); |
|
143 |
} |
|
144 |
omProductionOrdeInfo.setCreateTime(new Date()); |
|
145 |
omProductionOrdeInfo.setCreateUser("工厂MES"); |
|
146 |
omProductionOrdeInfoService.save(omProductionOrdeInfo); |
a846f2
|
147 |
} |
c860ca
|
148 |
}else { |
A |
149 |
return AjaxResult.error("接单失败,请联系管理员"); |
|
150 |
} |
|
151 |
return AjaxResult.success(dataObject.getStr("productNum")); |
|
152 |
} |
|
153 |
|
a846f2
|
154 |
@GetMapping(value = "/jieBang/{id}") |
A |
155 |
public AjaxResult jieBang(@PathVariable("id") Long id) |
|
156 |
{ |
|
157 |
OmProductionOrdeInfo byId = omProductionOrdeInfoService.getById(id); |
|
158 |
byId.setTrolleyYard(""); |
|
159 |
return success(omProductionOrdeInfoService.saveOrUpdate(byId)); |
|
160 |
} |
|
161 |
|
e57a89
|
162 |
/** |
懒 |
163 |
* 获取生产工单详细信息 |
|
164 |
*/ |
|
165 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:query')") |
|
166 |
@GetMapping(value = "/{id}") |
|
167 |
public AjaxResult getInfo(@PathVariable("id") Long id) |
|
168 |
{ |
|
169 |
return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id)); |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* 新增生产工单 |
|
174 |
*/ |
|
175 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:add')") |
|
176 |
@Log(title = "生产工单", businessType = BusinessType.INSERT) |
|
177 |
@PostMapping |
|
178 |
public AjaxResult add(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
179 |
{ |
|
180 |
return toAjax(omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo)); |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* 修改生产工单 |
|
185 |
*/ |
|
186 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:edit')") |
|
187 |
@Log(title = "生产工单", businessType = BusinessType.UPDATE) |
|
188 |
@PutMapping |
|
189 |
public AjaxResult edit(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
190 |
{ |
|
191 |
return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo)); |
|
192 |
} |
|
193 |
|
|
194 |
/** |
|
195 |
* 删除生产工单 |
|
196 |
*/ |
|
197 |
@PreAuthorize("@ss.hasPermi('om:productionOrde:remove')") |
|
198 |
@Log(title = "生产工单", businessType = BusinessType.DELETE) |
|
199 |
@DeleteMapping("/{ids}") |
|
200 |
public AjaxResult remove(@PathVariable Long[] ids) |
|
201 |
{ |
|
202 |
return toAjax(omProductionOrdeInfoService.deleteOmProductionOrdeInfoByIds(ids)); |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* table列上移下移 |
|
207 |
*/ |
|
208 |
@Log(title = "生产工单", businessType = BusinessType.DELETE) |
|
209 |
@GetMapping("/upDownMove") |
|
210 |
public AjaxResult upDownMove(OmProductionOrdeInfo omProductionOrdeInfo) |
|
211 |
{ |
|
212 |
return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo); |
|
213 |
} |
42cfe3
|
214 |
|
懒 |
215 |
@PostMapping("/importData") |
|
216 |
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception |
|
217 |
{ |
|
218 |
ExcelUtil<OmProductionOrdeInfo> util = new ExcelUtil<OmProductionOrdeInfo>(OmProductionOrdeInfo.class); |
|
219 |
List<OmProductionOrdeInfo> ordeInfo = util.importExcel(file.getInputStream()); |
|
220 |
for (OmProductionOrdeInfo omProductionOrdeInfo : ordeInfo) { |
|
221 |
omProductionOrdeInfo.setCreateTime(new Date()); |
|
222 |
omProductionOrdeInfo.setCreateBy("工厂MES"); |
|
223 |
} |
|
224 |
omProductionOrdeInfoService.overrideSaveBatch(ordeInfo); |
|
225 |
return AjaxResult.success(); |
|
226 |
} |
|
227 |
|
|
228 |
@PostMapping("/importTemplate") |
|
229 |
public void importTemplate(HttpServletResponse response) |
|
230 |
{ |
|
231 |
ExcelUtil<OmProductionOrdeInfoExcelImport> util = new ExcelUtil<OmProductionOrdeInfoExcelImport>(OmProductionOrdeInfoExcelImport.class); |
|
232 |
util.importTemplateExcel(response, "订单数据"); |
|
233 |
} |
a75d86
|
234 |
|
A |
235 |
@PostMapping("/trolleyYardBinDing") |
|
236 |
public AjaxResult trolleyYardBinDing(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
237 |
{ |
|
238 |
return omProductionOrdeInfoService.trolleyYardBinDing(omProductionOrdeInfo); |
|
239 |
} |
|
240 |
|
|
241 |
@PostMapping("/getCarCodeSize") |
|
242 |
public AjaxResult getCarCodeSize(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
243 |
{ |
|
244 |
return omProductionOrdeInfoService.getCarCodeSize(omProductionOrdeInfo); |
|
245 |
} |
|
246 |
|
|
247 |
@PostMapping("/findBytrolleyYardGetOne") |
|
248 |
public AjaxResult findBytrolleyYardGetOne(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo) |
|
249 |
{ |
|
250 |
return omProductionOrdeInfoService.findBytrolleyYardGetOne(omProductionOrdeInfo); |
|
251 |
} |
e57a89
|
252 |
} |