提交 | 用户 | 时间
|
71e81e
|
1 |
package cn.stylefeng.guns.modular.om.productionOrdeInfo.controller; |
懒 |
2 |
|
|
3 |
import cn.afterturn.easypoi.entity.vo.MapExcelConstants; |
|
4 |
import cn.afterturn.easypoi.excel.entity.ExportParams; |
|
5 |
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; |
|
6 |
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; |
|
7 |
import cn.afterturn.easypoi.view.PoiBaseView; |
|
8 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; |
9bd546
|
9 |
import cn.stylefeng.guns.modular.bs.locationInfo.entity.LocationInfo; |
懒 |
10 |
import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
|
11 |
import cn.stylefeng.guns.modular.bs.materialInfo.entity.MaterialInfo; |
|
12 |
import cn.stylefeng.guns.modular.bs.materialInfo.service.MaterialInfoService; |
|
13 |
import cn.stylefeng.guns.modular.cm.passingStationCollection.entity.PassingStationCollection; |
|
14 |
import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
71e81e
|
15 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.entity.ProductionOrdeInfo; |
懒 |
16 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
|
17 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
|
18 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
|
19 |
import cn.stylefeng.guns.sys.modular.system.entity.Dict; |
|
20 |
import cn.stylefeng.guns.sys.modular.system.service.DictService; |
|
21 |
import cn.stylefeng.roses.core.base.controller.BaseController; |
0d7f31
|
22 |
import cn.stylefeng.roses.core.util.ToolUtil; |
71e81e
|
23 |
import cn.stylefeng.roses.kernel.model.response.ResponseData; |
懒 |
24 |
import com.alibaba.fastjson.JSONObject; |
|
25 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
26 |
import com.baomidou.mybatisplus.extension.api.R; |
|
27 |
import io.swagger.models.auth.In; |
|
28 |
import lombok.SneakyThrows; |
|
29 |
import org.apache.poi.hssf.usermodel.HSSFCell; |
|
30 |
import org.apache.poi.hssf.usermodel.HSSFDateUtil; |
|
31 |
import org.apache.poi.ss.usermodel.Cell; |
|
32 |
import org.apache.poi.xssf.usermodel.XSSFCell; |
|
33 |
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
34 |
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
35 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
36 |
import org.springframework.beans.factory.annotation.Autowired; |
0d7f31
|
37 |
import org.springframework.security.core.parameters.P; |
71e81e
|
38 |
import org.springframework.stereotype.Controller; |
懒 |
39 |
import org.springframework.ui.ModelMap; |
|
40 |
import org.springframework.web.bind.annotation.*; |
|
41 |
import org.springframework.web.multipart.MultipartFile; |
|
42 |
|
|
43 |
import javax.servlet.http.HttpServletRequest; |
|
44 |
import javax.servlet.http.HttpServletResponse; |
|
45 |
import java.io.IOException; |
|
46 |
import java.text.DecimalFormat; |
|
47 |
import java.text.NumberFormat; |
|
48 |
import java.text.SimpleDateFormat; |
|
49 |
import java.time.LocalDate; |
|
50 |
import java.util.*; |
a2805e
|
51 |
import java.util.stream.Collectors; |
71e81e
|
52 |
|
懒 |
53 |
|
|
54 |
/** |
|
55 |
* 生产工单控制器 |
|
56 |
* |
|
57 |
* @author cl |
|
58 |
* @Date 2022-10-25 14:04:47 |
|
59 |
*/ |
|
60 |
@Controller |
|
61 |
@RequestMapping("/productionOrdeInfo") |
|
62 |
public class ProductionOrdeInfoController extends BaseController { |
|
63 |
|
|
64 |
private String PREFIX = "modular/om/productionOrdeInfo"; |
|
65 |
|
|
66 |
@Autowired |
|
67 |
private ProductionOrdeInfoService productionOrdeInfoService; |
|
68 |
|
|
69 |
@Autowired |
|
70 |
private DictService dictService; |
|
71 |
|
|
72 |
/** |
|
73 |
* 跳转到主页面 |
|
74 |
* |
|
75 |
* @author cl |
|
76 |
* @Date 2022-10-25 |
|
77 |
*/ |
|
78 |
@RequestMapping("") |
|
79 |
public String index() { |
|
80 |
return PREFIX + "/productionOrdeInfo.html"; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* 新增页面 |
|
85 |
* |
|
86 |
* @author cl |
|
87 |
* @Date 2022-10-25 |
|
88 |
*/ |
|
89 |
@RequestMapping("/add") |
|
90 |
public String add() { |
|
91 |
return PREFIX + "/productionOrdeInfo_add.html"; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* 编辑页面 |
|
96 |
* |
|
97 |
* @author cl |
|
98 |
* @Date 2022-10-25 |
|
99 |
*/ |
|
100 |
@RequestMapping("/edit") |
|
101 |
public String edit() { |
|
102 |
return PREFIX + "/productionOrdeInfo_edit.html"; |
|
103 |
} |
|
104 |
|
|
105 |
@RequestMapping("/materialList") |
|
106 |
public String materialList() { |
|
107 |
return PREFIX + "/materialList.html"; |
|
108 |
} |
|
109 |
|
|
110 |
@RequestMapping("/materialLists") |
|
111 |
public String materialLists() { |
|
112 |
return PREFIX + "/materialLists.html"; |
|
113 |
} |
|
114 |
|
|
115 |
@RequestMapping("/customInfo") |
|
116 |
public String customInfo() { |
|
117 |
return PREFIX + "/customInfo.html"; |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* 新增接口 |
|
122 |
* |
|
123 |
* @author cl |
|
124 |
* @Date 2022-10-25 |
|
125 |
*/ |
|
126 |
@RequestMapping("/addItem") |
|
127 |
@ResponseBody |
|
128 |
public ResponseData addItem(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
129 |
this.productionOrdeInfoService.add(productionOrdeInfoParam); |
|
130 |
return ResponseData.success(); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* 编辑接口 |
|
135 |
* |
|
136 |
* @author cl |
|
137 |
* @Date 2022-10-25 |
|
138 |
*/ |
|
139 |
@RequestMapping("/editItem") |
|
140 |
@ResponseBody |
|
141 |
public ResponseData editItem(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
142 |
if(productionOrdeInfoParam.getFlag()!=null){ |
|
143 |
productionOrdeInfoParam.setActualStartTime(new Date()); |
0d7f31
|
144 |
} |
71e81e
|
145 |
this.productionOrdeInfoService.update(productionOrdeInfoParam); |
懒 |
146 |
this.productionOrdeInfoService.saveOrderBatchInfo(productionOrdeInfoParam); |
|
147 |
return ResponseData.success(); |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* 编辑接口 |
|
152 |
* |
|
153 |
* @author cl |
|
154 |
* @Date 2022-10-25 |
|
155 |
*/ |
|
156 |
@RequestMapping("/editItemAll") |
|
157 |
@ResponseBody |
|
158 |
public ResponseData editItemAll(@RequestBody List<ProductionOrdeInfoParam> list) { |
|
159 |
for(int i=0;i<list.size();i++){ |
|
160 |
ProductionOrdeInfoParam productionOrdeInfoParam = list.get(i); |
|
161 |
this.productionOrdeInfoService.update(productionOrdeInfoParam); |
|
162 |
} |
|
163 |
|
|
164 |
return ResponseData.success(); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* 删除接口 |
|
169 |
* |
|
170 |
* @author cl |
|
171 |
* @Date 2022-10-25 |
|
172 |
*/ |
|
173 |
@RequestMapping("/delete") |
|
174 |
@ResponseBody |
|
175 |
public ResponseData delete(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
176 |
this.productionOrdeInfoService.delete(productionOrdeInfoParam); |
|
177 |
return ResponseData.success(); |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* 查看详情接口 |
|
182 |
* |
|
183 |
* @author cl |
|
184 |
* @Date 2022-10-25 |
|
185 |
*/ |
|
186 |
@RequestMapping("/detail") |
|
187 |
@ResponseBody |
|
188 |
public ResponseData detail(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
189 |
ProductionOrdeInfo detail = this.productionOrdeInfoService.getById(productionOrdeInfoParam.getId()); |
|
190 |
return ResponseData.success(detail); |
|
191 |
} |
|
192 |
|
|
193 |
/** |
|
194 |
* 查询列表 |
|
195 |
* |
|
196 |
* @author cl |
|
197 |
* @Date 2022-10-25 |
|
198 |
*/ |
|
199 |
@ResponseBody |
|
200 |
@CrossOrigin |
|
201 |
@RequestMapping("/list") |
|
202 |
public LayuiPageInfo list(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
203 |
return this.productionOrdeInfoService.findPageBySpec(productionOrdeInfoParam); |
|
204 |
} |
|
205 |
|
|
206 |
@ResponseBody |
|
207 |
@RequestMapping("/orderCount") |
|
208 |
public ResponseData orderCount(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
209 |
int orderStatus = productionOrdeInfoService.count(new QueryWrapper<ProductionOrdeInfo>().eq("order_status", productionOrdeInfoParam.getOrderStatus())); |
|
210 |
return ResponseData.success(orderStatus); |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* 大屏列表接口 |
|
215 |
* @param productionOrdeInfoParam |
|
216 |
* @return |
|
217 |
*/ |
|
218 |
@ResponseBody |
|
219 |
@CrossOrigin |
|
220 |
@RequestMapping("/largeScreenList") |
|
221 |
public List largeScreenList(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
222 |
ArrayList arrayList = new ArrayList(); |
|
223 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
224 |
// productionOrdeInfoParam.setOrderStatus("3"); |
|
225 |
LayuiPageInfo pageBySpec = this.productionOrdeInfoService.findPageBySpec(productionOrdeInfoParam); |
|
226 |
List<ProductionOrdeInfoResult> result = pageBySpec.getData(); |
|
227 |
for (ProductionOrdeInfoResult productionOrdeInfoResult : result) { |
|
228 |
ArrayList resultList = new ArrayList(); |
|
229 |
resultList.add(productionOrdeInfoResult.getWorkOrderNo()); |
|
230 |
resultList.add(productionOrdeInfoResult.getMaterialCode()); |
|
231 |
resultList.add(productionOrdeInfoResult.getProductionLine()); |
|
232 |
resultList.add(productionOrdeInfoResult.getPlanQty()); |
|
233 |
resultList.add(productionOrdeInfoResult.getActualQty()); |
|
234 |
resultList.add(format.format(productionOrdeInfoResult.getCreateTime())); |
|
235 |
arrayList.add(resultList); |
|
236 |
} |
|
237 |
return arrayList; |
|
238 |
} |
|
239 |
|
|
240 |
@ResponseBody |
|
241 |
@CrossOrigin |
|
242 |
@RequestMapping("/largeScreenList1") |
|
243 |
public List largeScreenList1(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
244 |
ArrayList arrayList = new ArrayList(); |
|
245 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
246 |
List<ProductionOrdeInfoResult> list = this.productionOrdeInfoService.getListMonth(); |
|
247 |
for (ProductionOrdeInfoResult productionOrdeInfoResult : list) { |
|
248 |
ArrayList resultList = new ArrayList(); |
|
249 |
resultList.add(productionOrdeInfoResult.getWorkOrderNo()); |
|
250 |
resultList.add(productionOrdeInfoResult.getMaterialCode()); |
|
251 |
resultList.add(productionOrdeInfoResult.getPlanQty()); |
|
252 |
resultList.add(productionOrdeInfoResult.getActualQty()); |
|
253 |
resultList.add(format.format(productionOrdeInfoResult.getCreateTime())); |
|
254 |
arrayList.add(resultList); |
|
255 |
} |
|
256 |
return arrayList; |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
260 |
* 大屏产线接口 |
|
261 |
* @return |
|
262 |
*/ |
|
263 |
@ResponseBody |
|
264 |
@CrossOrigin |
|
265 |
@RequestMapping("/lineFinishQty") |
|
266 |
public ResponseData lineFinishQty() { |
0d7f31
|
267 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
懒 |
268 |
List resultList = new ArrayList(); |
|
269 |
List<ProductionOrdeInfoResult> list = this.productionOrdeInfoService.lineFinishQty(); |
|
270 |
for (ProductionOrdeInfoResult productionOrdeInfo : list) { |
|
271 |
Map map = new HashMap(); |
|
272 |
map.put("name",format.format(productionOrdeInfo.getActualStartTime())); |
|
273 |
map.put("value",productionOrdeInfo.getActualQty()); |
|
274 |
resultList.add(map); |
|
275 |
} |
|
276 |
return ResponseData.success(resultList); |
71e81e
|
277 |
} |
懒 |
278 |
|
|
279 |
/** |
|
280 |
* 大屏车间工单信息接口 |
|
281 |
* @return |
|
282 |
*/ |
|
283 |
@ResponseBody |
|
284 |
@CrossOrigin |
|
285 |
@RequestMapping("/workshopOrderDetail") |
|
286 |
public ResponseData workshopOrderDetail(ProductionOrdeInfoParam productionOrdeInfoParam) { |
0d7f31
|
287 |
// NumberFormat numberFormat = NumberFormat.getInstance(); |
懒 |
288 |
// numberFormat.setMaximumFractionDigits(2); |
|
289 |
// ProductionOrdeInfo one = productionOrdeInfoService.getOne(new QueryWrapper<ProductionOrdeInfo>() |
|
290 |
// .select("SUM\n" + |
|
291 |
// "\t( plan_qty ) AS planQty,\n" + |
|
292 |
// "\tSUM ( actual_qty ) AS actualQty,\n" + |
|
293 |
// "\tSUM ( scrap_qty ) AS scrapQty ") |
|
294 |
// ); |
|
295 |
// //计划 |
|
296 |
// Integer plqnQty = one.getPlanQty(); |
|
297 |
// //完成 |
|
298 |
// Integer actualQty = one.getActualQty(); |
|
299 |
// //报废 |
|
300 |
// Integer scrapQty = one.getScrapQty(); |
|
301 |
// //合格数量 |
|
302 |
// Integer paseQty = actualQty-scrapQty; |
|
303 |
// |
|
304 |
// Map map = new HashMap<String,String>(); |
|
305 |
// map.put("produceQty",plqnQty); |
|
306 |
// map.put("finishQty",actualQty); |
|
307 |
// map.put("paseQty",paseQty); |
|
308 |
// map.put("noPaseQty",scrapQty); |
|
309 |
// map.put("CompletionRate",numberFormat.format((float) actualQty / (float) plqnQty * 100)); |
|
310 |
// map.put("PassRate",numberFormat.format((float) paseQty / (float) actualQty * 100)); |
|
311 |
// map.put("surplusQty",plqnQty-actualQty); |
|
312 |
// return ResponseData.success(map); |
|
313 |
ProductionOrdeInfoParam param = new ProductionOrdeInfoParam(); |
|
314 |
param.setOrderStatus("3"); |
|
315 |
ProductionOrdeInfoResult one = new ProductionOrdeInfoResult(); |
71e81e
|
316 |
NumberFormat numberFormat = NumberFormat.getInstance(); |
懒 |
317 |
numberFormat.setMaximumFractionDigits(2); |
0d7f31
|
318 |
List<ProductionOrdeInfoResult> listMonth = productionOrdeInfoService.getListMonth(); |
懒 |
319 |
List<ProductionOrdeInfoResult> listBySpec = productionOrdeInfoService.findListBySpec(param); |
|
320 |
if(listBySpec.size() == 0){ |
|
321 |
ToolUtil.copyProperties(listMonth.get(0), one); |
|
322 |
}else { |
|
323 |
ToolUtil.copyProperties(listBySpec.get(0), one); |
|
324 |
} |
|
325 |
if(one.getActualQty() == null){ |
|
326 |
one.setActualQty(0); |
|
327 |
} |
|
328 |
if(one.getScrapQty() == null){ |
|
329 |
one.setScrapQty(0); |
|
330 |
} |
71e81e
|
331 |
//计划 |
懒 |
332 |
Integer plqnQty = one.getPlanQty(); |
|
333 |
//完成 |
|
334 |
Integer actualQty = one.getActualQty(); |
|
335 |
//报废 |
|
336 |
Integer scrapQty = one.getScrapQty(); |
|
337 |
//合格数量 |
|
338 |
Integer paseQty = actualQty-scrapQty; |
|
339 |
|
|
340 |
Map map = new HashMap<String,String>(); |
0d7f31
|
341 |
map.put("produceQty",one.getPlanQty()); |
懒 |
342 |
map.put("finishQty",one.getActualQty()); |
71e81e
|
343 |
map.put("paseQty",paseQty); |
懒 |
344 |
map.put("noPaseQty",scrapQty); |
|
345 |
map.put("CompletionRate",numberFormat.format((float) actualQty / (float) plqnQty * 100)); |
0d7f31
|
346 |
String format = numberFormat.format((float) paseQty / (float) actualQty * 100); |
懒 |
347 |
if(format.equals("�")){ |
|
348 |
map.put("PassRate","0"); |
|
349 |
}else { |
|
350 |
map.put("PassRate",format); |
|
351 |
} |
71e81e
|
352 |
map.put("surplusQty",plqnQty-actualQty); |
懒 |
353 |
return ResponseData.success(map); |
|
354 |
} |
|
355 |
|
|
356 |
/** |
|
357 |
* 大屏车间工单信息接口 |
|
358 |
* @return |
|
359 |
*/ |
|
360 |
@ResponseBody |
|
361 |
@CrossOrigin |
|
362 |
@RequestMapping("/reportLineList") |
|
363 |
public ResponseData reportLineList(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
364 |
Map map = new HashMap<String,String>(); |
|
365 |
return ResponseData.success(map); |
|
366 |
} |
|
367 |
|
|
368 |
@ResponseBody |
|
369 |
@CrossOrigin |
|
370 |
@RequestMapping("/lineChart") |
|
371 |
public ResponseData lineChart(ProductionOrdeInfoParam productionOrdeInfoParam) { |
a2805e
|
372 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
71e81e
|
373 |
List<String> list = new ArrayList(); |
懒 |
374 |
List<Integer> planQtyList = new ArrayList(); |
|
375 |
List<Integer> actualQtyList = new ArrayList(); |
|
376 |
Map map = new HashMap<String,String>(); |
a2805e
|
377 |
List<ProductionOrdeInfoResult> ColumnarDateList = productionOrdeInfoService.getColumnarDate(); |
懒 |
378 |
for (ProductionOrdeInfoResult result : ColumnarDateList) { |
|
379 |
String s = format.format(result.getActualStartTime()); |
0d7f31
|
380 |
QueryWrapper<ProductionOrdeInfo> queryWrapper = new QueryWrapper<ProductionOrdeInfo>(); |
懒 |
381 |
queryWrapper.select("SUM(plan_qty) as planQty,SUM(actual_qty) as actualQty"); |
a2805e
|
382 |
queryWrapper.apply("CONVERT ( VARCHAR ( 100 ), actual_start_time, 23 ) = {0}",s); |
0d7f31
|
383 |
ProductionOrdeInfo one = productionOrdeInfoService.getOne(queryWrapper); |
懒 |
384 |
if(one!=null){ |
|
385 |
if(one.getPlanQty()!=null){ |
|
386 |
planQtyList.add(one.getPlanQty()); |
71e81e
|
387 |
}else { |
懒 |
388 |
planQtyList.add(0); |
0d7f31
|
389 |
} |
懒 |
390 |
if(one.getActualQty()!=null){ |
|
391 |
actualQtyList.add(one.getActualQty()); |
|
392 |
}else { |
71e81e
|
393 |
actualQtyList.add(0); |
懒 |
394 |
} |
0d7f31
|
395 |
}else { |
懒 |
396 |
planQtyList.add(0); |
|
397 |
actualQtyList.add(0); |
71e81e
|
398 |
} |
a2805e
|
399 |
list.add(s); |
0d7f31
|
400 |
} |
71e81e
|
401 |
|
懒 |
402 |
map.put("category",list); |
|
403 |
map.put("lineData",planQtyList); |
|
404 |
map.put("barData",actualQtyList); |
|
405 |
return ResponseData.success(map); |
|
406 |
} |
|
407 |
|
1f3486
|
408 |
@ResponseBody |
懒 |
409 |
@CrossOrigin |
|
410 |
@RequestMapping("/findOrdrList") |
|
411 |
public ResponseData findOrdrList(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
412 |
ProductionOrdeInfoParam param = new ProductionOrdeInfoParam(); |
|
413 |
param.setProductionLine("");//产线 |
|
414 |
param.setOrderStatus("3");//工单状态 |
|
415 |
List<ProductionOrdeInfoResult> list = productionOrdeInfoService.findListBySpec(param); |
|
416 |
return ResponseData.success(list); |
|
417 |
} |
|
418 |
|
71e81e
|
419 |
/** |
懒 |
420 |
* 下载excel导入模板 |
|
421 |
* |
|
422 |
* @author liwenya |
|
423 |
* @Date 2021年7月9日 17点01分 |
|
424 |
*/ |
|
425 |
@RequestMapping("/downloadExcelTemplate") |
|
426 |
public void downloadExcelTemplate(ModelMap modelMap, HttpServletRequest request, |
0d7f31
|
427 |
HttpServletResponse response) { |
71e81e
|
428 |
//初始化表头 |
懒 |
429 |
List<ExcelExportEntity> entity = new ArrayList<>(); |
|
430 |
entity.add(new ExcelExportEntity("生产工单号", "workOrderNo")); |
|
431 |
entity.add(new ExcelExportEntity("物料编号", "materialCode")); |
|
432 |
entity.add(new ExcelExportEntity("物料描述", "materialName")); |
|
433 |
|
|
434 |
entity.add(new ExcelExportEntity("软件版本编码", "softwareVersionCode")); |
|
435 |
entity.add(new ExcelExportEntity("生产基地编码", "productCompanyCode")); |
|
436 |
|
|
437 |
entity.add(new ExcelExportEntity("计划数量", "planQty")); |
|
438 |
entity.add(new ExcelExportEntity("计划开始时间", "planStartTime")); |
|
439 |
entity.add(new ExcelExportEntity("计划结束时间", "planEndTime")); |
|
440 |
|
|
441 |
ExportParams params = new ExportParams("生产工单模板", "生产工单", ExcelType.XSSF); |
|
442 |
modelMap.put(MapExcelConstants.MAP_LIST, new ArrayList<>()); |
|
443 |
modelMap.put(MapExcelConstants.ENTITY_LIST, entity); |
|
444 |
modelMap.put(MapExcelConstants.PARAMS, params); |
|
445 |
modelMap.put(MapExcelConstants.FILE_NAME, "生产工单"); |
|
446 |
PoiBaseView.render(modelMap, request, response, MapExcelConstants.EASYPOI_MAP_EXCEL_VIEW); |
|
447 |
} |
|
448 |
|
|
449 |
/** |
|
450 |
* 导入Excel |
|
451 |
* |
|
452 |
* @author cl |
|
453 |
* @Date 2022-10-25 |
|
454 |
*/ |
|
455 |
@SneakyThrows |
|
456 |
@RequestMapping("/uploadExcel") |
|
457 |
@ResponseBody |
|
458 |
public ResponseData exportIn(@RequestPart("file") MultipartFile file, HttpServletRequest request){ |
|
459 |
List<ProductionOrdeInfo> list = new ArrayList<>(); |
|
460 |
|
|
461 |
//定义工作簿 |
|
462 |
XSSFWorkbook sheets = null; |
|
463 |
try{ |
|
464 |
sheets = new XSSFWorkbook(file.getInputStream()); |
|
465 |
//获取sheet |
|
466 |
XSSFSheet sheet = sheets.getSheet(sheets.getSheetName(0)); |
|
467 |
int rows = sheet.getPhysicalNumberOfRows(); |
|
468 |
for(int i = 2; i < rows; i++){ |
|
469 |
//获取列数 |
|
470 |
XSSFRow row = sheet.getRow(i); |
|
471 |
ProductionOrdeInfo orderInfo = new ProductionOrdeInfo(); |
|
472 |
|
|
473 |
orderInfo.setWorkOrderNo(getCellValue(row.getCell(0)));//工单编码 |
|
474 |
orderInfo.setMaterialCode(getCellValue(row.getCell(1)));//物料编号 |
|
475 |
orderInfo.setMaterialName(getCellValue(row.getCell(2)));//物料描述 |
|
476 |
|
|
477 |
orderInfo.setSoftwareVersionCode(getCellValue(row.getCell(3)));//软件版本编码 |
|
478 |
orderInfo.setProductCompanyCode(getCellValue(row.getCell(4)));//生产基地编码 |
|
479 |
|
|
480 |
|
|
481 |
Cell planQty = row.getCell(5);//计划数量 |
|
482 |
if(!Objects.equals(planQty, null) && !Objects.equals(planQty.toString(),"")){ |
|
483 |
double d = planQty.getNumericCellValue(); |
|
484 |
orderInfo.setPlanQty((int) d); |
|
485 |
} |
|
486 |
|
|
487 |
Cell planStartTime = row.getCell(6);//计划开始时间 |
|
488 |
if(HSSFDateUtil.isCellDateFormatted(planStartTime)){ |
|
489 |
Date d = planStartTime.getDateCellValue(); |
|
490 |
orderInfo.setPlanStartTime(d); |
|
491 |
} |
|
492 |
|
|
493 |
Cell planEndTime = row.getCell(7);//计划结束时间 |
|
494 |
if(HSSFDateUtil.isCellDateFormatted(planEndTime)){ |
|
495 |
Date d = planEndTime.getDateCellValue(); |
|
496 |
orderInfo.setPlanEndTime(d); |
|
497 |
} |
|
498 |
list.add(orderInfo); |
|
499 |
} |
|
500 |
|
|
501 |
for(ProductionOrdeInfo obj : list){ |
|
502 |
productionOrdeInfoService.save(obj); |
|
503 |
} |
|
504 |
return ResponseData.success("上传成功"); |
|
505 |
} catch (IOException e) { |
|
506 |
e.printStackTrace(); |
|
507 |
return ResponseData.error("上传失败"); |
|
508 |
} |
|
509 |
} |
|
510 |
|
|
511 |
|
|
512 |
/** |
|
513 |
* 获得Hsscell内容 |
|
514 |
* |
|
515 |
* @param cell |
|
516 |
* @return |
|
517 |
*/ |
|
518 |
public String getCellValue(XSSFCell cell) { |
|
519 |
String value = ""; |
|
520 |
if (cell != null) { |
|
521 |
switch (cell.getCellType()) { |
|
522 |
case HSSFCell.CELL_TYPE_FORMULA: |
|
523 |
break; |
|
524 |
case HSSFCell.CELL_TYPE_NUMERIC: |
|
525 |
DecimalFormat df = new DecimalFormat("0"); |
|
526 |
value = df.format(cell.getNumericCellValue()); |
|
527 |
break; |
|
528 |
case HSSFCell.CELL_TYPE_STRING: |
|
529 |
value = cell.getStringCellValue().trim(); |
|
530 |
break; |
|
531 |
default: |
|
532 |
value = ""; |
|
533 |
break; |
|
534 |
} |
|
535 |
} |
|
536 |
return value.trim(); |
|
537 |
} |
|
538 |
|
9bd546
|
539 |
@Autowired |
懒 |
540 |
MaterialInfoService materialInfoService; |
|
541 |
|
|
542 |
@Autowired |
|
543 |
PassingStationCollectionService passingStationCollectionService; |
|
544 |
|
|
545 |
@Autowired |
|
546 |
LocationInfoService locationInfoService; |
|
547 |
|
|
548 |
/** |
|
549 |
* 大屏车间工单信息接口 |
|
550 |
* @return |
|
551 |
*/ |
|
552 |
@ResponseBody |
|
553 |
@CrossOrigin |
|
554 |
@RequestMapping("/topData") |
|
555 |
public ResponseData topData(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
556 |
Map map = new HashMap<String,String>(); |
|
557 |
ProductionOrdeInfo result = null; |
|
558 |
//但前工单 |
|
559 |
List<ProductionOrdeInfo> orderStatus = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("order_status", "3")); |
|
560 |
if(productionOrdeInfoParam.getWorkOrderNo() != null && !productionOrdeInfoParam.getWorkOrderNo().equals("")){ |
|
561 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("work_order_no", productionOrdeInfoParam.getWorkOrderNo())); |
|
562 |
result = workOrderNo.get(0); |
|
563 |
}else if(orderStatus.size()!=0){ |
|
564 |
result = orderStatus.get(0); |
|
565 |
}else { |
|
566 |
List<ProductionOrdeInfoResult> results = productionOrdeInfoService.orderDescListFive(); |
|
567 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("work_order_no", results.get(0).getWorkOrderNo())); |
|
568 |
result = workOrderNo.get(0); |
|
569 |
} |
|
570 |
//产品 |
|
571 |
List<MaterialInfo> materialCode = materialInfoService.list(new QueryWrapper<MaterialInfo>().eq("material_code", result.getMaterialCode())); |
|
572 |
Integer planQty = result.getPlanQty(); |
|
573 |
Integer actualQty = result.getActualQty(); |
|
574 |
Date date2 = new Date(); // 第二个日期 |
|
575 |
long diffInMillis =result.getPlanEndTime().getTime() - date2.getTime(); //计算两个日期的毫秒差 |
|
576 |
long diffInHours = diffInMillis / (60 * 60 * 1000); // 将毫秒差转换为小时差 |
|
577 |
List<PassingStationCollection> list = passingStationCollectionService.list(new QueryWrapper<PassingStationCollection>() |
|
578 |
.eq("out_rs_sign", "2") |
|
579 |
.eq("work_order_no", result.getWorkOrderNo()) |
|
580 |
.eq("location_code", "OP1060") |
|
581 |
); |
|
582 |
Integer NgNumber = list.size(); |
|
583 |
map.put("workOrderNo",result.getWorkOrderNo()); |
|
584 |
map.put("planQty",planQty); |
|
585 |
map.put("actualQty",actualQty); |
|
586 |
map.put("materialName",materialCode.get(0).getMaterialName()); |
|
587 |
map.put("completionRate",Math.round((float) actualQty / planQty * 100)); |
|
588 |
map.put("remainder",diffInHours); |
|
589 |
map.put("NgNumber",NgNumber); |
|
590 |
if(list.size() == 0){ |
|
591 |
map.put("passRate","100"); |
|
592 |
}else { |
|
593 |
map.put("passRate",Math.round((float) NgNumber / actualQty * 100)); |
|
594 |
} |
|
595 |
return ResponseData.success(map); |
|
596 |
} |
|
597 |
|
|
598 |
|
|
599 |
@ResponseBody |
|
600 |
@CrossOrigin |
|
601 |
@RequestMapping("/centerLeftData") |
|
602 |
public ResponseData centerLeftData(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
603 |
Map map = new HashMap<String,String>(); |
|
604 |
List categoryList = new ArrayList(); |
|
605 |
List lineDataList = new ArrayList(); |
|
606 |
List barDataList = new ArrayList(); |
|
607 |
|
|
608 |
ProductionOrdeInfo result = null; |
|
609 |
//但前工单 |
|
610 |
List<ProductionOrdeInfo> orderStatus = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("order_status", "3")); |
|
611 |
if(productionOrdeInfoParam.getWorkOrderNo() != null && !productionOrdeInfoParam.getWorkOrderNo().equals("")){ |
|
612 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("work_order_no", productionOrdeInfoParam.getWorkOrderNo())); |
|
613 |
result = workOrderNo.get(0); |
|
614 |
}else if(orderStatus.size()!=0){ |
|
615 |
result = orderStatus.get(0); |
|
616 |
}else { |
|
617 |
List<ProductionOrdeInfoResult> results = productionOrdeInfoService.orderDescListFive(); |
|
618 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("work_order_no", results.get(0).getWorkOrderNo())); |
|
619 |
result = workOrderNo.get(0); |
|
620 |
} |
|
621 |
for (String o : getLocationList()) { |
|
622 |
List<PassingStationCollection> list = passingStationCollectionService.list(new QueryWrapper<PassingStationCollection>() |
|
623 |
.eq("location_code", o) |
|
624 |
.eq("out_rs_sign", "2") |
|
625 |
.eq("work_order_no",result.getWorkOrderNo()) |
|
626 |
); |
|
627 |
List<PassingStationCollection> lineList = passingStationCollectionService.list(new QueryWrapper<PassingStationCollection>() |
|
628 |
.eq("location_code", o) |
|
629 |
.eq("work_order_no",result.getWorkOrderNo()) |
|
630 |
); |
|
631 |
categoryList.add(o); |
|
632 |
barDataList.add(list.size()); |
|
633 |
lineDataList.add(lineList.size()); |
|
634 |
} |
|
635 |
map.put("category",categoryList); |
|
636 |
map.put("barData",barDataList); |
|
637 |
map.put("lineData",lineDataList); |
|
638 |
|
|
639 |
return ResponseData.success(map); |
|
640 |
} |
|
641 |
|
|
642 |
@ResponseBody |
|
643 |
@CrossOrigin |
|
644 |
@RequestMapping("/bottomData") |
|
645 |
public ResponseData bottomData(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
646 |
Map map = new HashMap<String,String>(); |
|
647 |
List unqualifiedList = new ArrayList(); |
|
648 |
List qualifiedList = new ArrayList(); |
|
649 |
List passRate = new ArrayList(); |
|
650 |
// List<ProductionOrdeInfo> orderStatus = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("order_status", "3")); |
|
651 |
// ProductionOrdeInfo result = orderStatus.get(0); |
|
652 |
ProductionOrdeInfo result = null; |
|
653 |
//但前工单 |
|
654 |
List<ProductionOrdeInfo> orderStatus = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("order_status", "3")); |
|
655 |
if(productionOrdeInfoParam.getWorkOrderNo() != null && !productionOrdeInfoParam.getWorkOrderNo().equals("")){ |
|
656 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("work_order_no", productionOrdeInfoParam.getWorkOrderNo())); |
|
657 |
result = workOrderNo.get(0); |
|
658 |
}else if(orderStatus.size()!=0){ |
|
659 |
result = orderStatus.get(0); |
|
660 |
}else { |
|
661 |
List<ProductionOrdeInfoResult> results = productionOrdeInfoService.orderDescListFive(); |
|
662 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("work_order_no", results.get(0).getWorkOrderNo())); |
|
663 |
result = workOrderNo.get(0); |
|
664 |
} |
|
665 |
for (String o : getLocationList()) { |
|
666 |
List<PassingStationCollection> list = passingStationCollectionService.list(new QueryWrapper<PassingStationCollection>() |
|
667 |
.eq("location_code", o) |
|
668 |
.eq("out_rs_sign", "2") |
|
669 |
.eq("work_order_no",result.getWorkOrderNo()) |
|
670 |
); |
|
671 |
Integer unqualified = list.size(); |
|
672 |
Integer qualified = result.getActualQty()-list.size(); |
|
673 |
unqualifiedList.add(unqualified); |
|
674 |
qualifiedList.add(qualified); |
|
675 |
if(unqualified == 0){ |
|
676 |
passRate.add(100); |
|
677 |
}else { |
|
678 |
passRate.add(Math.round((float) qualified / result.getActualQty() * 100)); |
|
679 |
} |
|
680 |
} |
|
681 |
map.put("unqualifiedList",unqualifiedList); |
|
682 |
map.put("qualifiedList",qualifiedList); |
|
683 |
map.put("passRate",passRate); |
|
684 |
return ResponseData.success(map); |
|
685 |
} |
|
686 |
|
|
687 |
@ResponseBody |
|
688 |
@CrossOrigin |
|
689 |
@RequestMapping("/centerRightData") |
|
690 |
public ResponseData centerRightData(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
691 |
// List<ProductionOrdeInfo> orderStatus = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("order_status", "3")); |
|
692 |
// ProductionOrdeInfo result = orderStatus.get(0); |
|
693 |
ProductionOrdeInfo result = null; |
|
694 |
//但前工单 |
|
695 |
List<ProductionOrdeInfo> orderStatus = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("order_status", "3")); |
|
696 |
if(productionOrdeInfoParam.getWorkOrderNo() != null && !productionOrdeInfoParam.getWorkOrderNo().equals("")){ |
|
697 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("work_order_no", productionOrdeInfoParam.getWorkOrderNo())); |
|
698 |
result = workOrderNo.get(0); |
|
699 |
}else if(orderStatus.size()!=0){ |
|
700 |
result = orderStatus.get(0); |
|
701 |
}else { |
|
702 |
List<ProductionOrdeInfoResult> results = productionOrdeInfoService.orderDescListFive(); |
|
703 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().eq("work_order_no", results.get(0).getWorkOrderNo())); |
|
704 |
result = workOrderNo.get(0); |
|
705 |
} |
|
706 |
Integer targetNumber = 70; |
|
707 |
List resultList = new ArrayList(); |
|
708 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
709 |
String format1 = format.format(new Date()); |
|
710 |
String paramPrefix = format1+" "; |
|
711 |
for (String s : getCenterRightSpit()) { |
|
712 |
List itemList = new ArrayList(); |
|
713 |
int outTotal = passingStationCollectionService.bigCenterRightTable(paramPrefix+s+":00",paramPrefix+s.substring(0,1)+":59:59",null,result.getWorkOrderNo()); |
|
714 |
int i = passingStationCollectionService.bigCenterRightTable(paramPrefix+s+":00",paramPrefix+s.substring(0,1)+":59:59","1",result.getWorkOrderNo()); |
|
715 |
if(outTotal<targetNumber){ |
|
716 |
itemList.add(boldText(s)); |
|
717 |
itemList.add(boldText(targetNumber.toString())); |
|
718 |
itemList.add(boldText(String.valueOf(outTotal))); |
|
719 |
itemList.add(boldText(String.valueOf(targetNumber-outTotal))); |
|
720 |
itemList.add(boldText(Math.round((float) i / outTotal * 100)+"%")); |
|
721 |
}else { |
|
722 |
itemList.add(s); |
|
723 |
itemList.add(targetNumber); |
|
724 |
itemList.add(outTotal); |
|
725 |
itemList.add(targetNumber-outTotal); |
|
726 |
itemList.add(Math.round((float) i / outTotal * 100)+"%"); |
|
727 |
} |
|
728 |
resultList.add(itemList); |
|
729 |
} |
|
730 |
return ResponseData.success(resultList); |
|
731 |
} |
|
732 |
|
|
733 |
@ResponseBody |
|
734 |
@CrossOrigin |
|
735 |
@RequestMapping("/orderDescListFive") |
|
736 |
public ResponseData orderDescListFive() { |
|
737 |
List list = new ArrayList(); |
|
738 |
List<ProductionOrdeInfoResult> results = productionOrdeInfoService.orderDescListFive(); |
|
739 |
for (ProductionOrdeInfoResult result : results) { |
|
740 |
Map itemMap = new HashMap(); |
|
741 |
itemMap.put("value",result.getWorkOrderNo()); |
|
742 |
itemMap.put("label",result.getWorkOrderNo()); |
|
743 |
list.add(itemMap); |
|
744 |
} |
|
745 |
return ResponseData.success(list); |
|
746 |
} |
|
747 |
|
|
748 |
public static List<String> getLocationList(){ |
|
749 |
List<String> locationList = new ArrayList<>(); |
|
750 |
locationList.add("OP070"); |
|
751 |
locationList.add("OP100"); |
|
752 |
locationList.add("OP140"); |
|
753 |
locationList.add("OP150"); |
|
754 |
locationList.add("EOP080"); |
|
755 |
locationList.add("EOP090"); |
|
756 |
return locationList; |
|
757 |
} |
|
758 |
|
|
759 |
public static List<String> getCenterRightSpit(){ |
|
760 |
List<String> locationList = new ArrayList<>(); |
|
761 |
locationList.add("8:00"); |
|
762 |
locationList.add("9:00"); |
|
763 |
locationList.add("10:00"); |
|
764 |
locationList.add("11:00"); |
|
765 |
locationList.add("12:00"); |
|
766 |
locationList.add("13:00"); |
|
767 |
locationList.add("14:00"); |
|
768 |
locationList.add("15:00"); |
|
769 |
locationList.add("16:00"); |
|
770 |
locationList.add("17:00"); |
|
771 |
return locationList; |
|
772 |
} |
|
773 |
|
|
774 |
public static String boldText(String param){ |
|
775 |
return "<span style='font-size: 20px' class='colorRed'>"+param+"</span>"; |
|
776 |
} |
|
777 |
|
71e81e
|
778 |
} |
懒 |
779 |
|
|
780 |
|