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