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