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