From ea3c33c8561df39d4f123d1424fda99dd0f0c51d Mon Sep 17 00:00:00 2001
From: wujian <14790700720@163.com>
Date: 星期四, 14 十一月 2024 08:15:41 +0800
Subject: [PATCH] add - panel

---
 jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java |  153 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 131 insertions(+), 22 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java b/jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java
index ee0eac5..3723ce2 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java
@@ -1,11 +1,13 @@
 package com.jcdm.main.bs.orderScheduling.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelWriter;
 import com.alibaba.excel.write.metadata.WriteSheet;
 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
+import com.github.pagehelper.PageInfo;
 import com.jcdm.common.annotation.Log;
 import com.jcdm.common.core.controller.BaseController;
 import com.jcdm.common.core.domain.AjaxResult;
@@ -13,14 +15,15 @@
 import com.jcdm.common.core.domain.entity.SysDictData;
 import com.jcdm.common.core.page.TableDataInfo;
 import com.jcdm.common.enums.BusinessType;
+import com.jcdm.common.exception.ServiceException;
 import com.jcdm.common.utils.StringUtils;
 import com.jcdm.common.utils.poi.ExcelUtil;
+import com.jcdm.main.bs.orderScheduling.Query.EngineQuery;
+import com.jcdm.main.bs.orderScheduling.Query.SAPQuery;
 import com.jcdm.main.bs.orderScheduling.common.Constants;
 import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
 import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
-import com.jcdm.main.bs.orderScheduling.vo.FollowReportVO;
-import com.jcdm.main.bs.orderScheduling.vo.LineChartVO;
-import com.jcdm.main.bs.orderScheduling.vo.SumDataVO;
+import com.jcdm.main.bs.orderScheduling.vo.*;
 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
 import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
 import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
@@ -41,14 +44,12 @@
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -157,9 +158,9 @@
             WriteSheet sheet1 = EasyExcel.writerSheet(1, "鎷х揣鏁版嵁")
                     .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                     .build();
-            WriteSheet sheet2 = EasyExcel.writerSheet(2, "鐩告満妫�娴�")
-                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
-                    .build();
+//            WriteSheet sheet2 = EasyExcel.writerSheet(2, "鐩告満妫�娴�")
+//                    .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
+//                    .build();
             WriteSheet sheet3 = EasyExcel.writerSheet(3, "澶栨紡妫�娴�")
                     .head(DaParamCollection.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                     .build();
@@ -171,7 +172,7 @@
                     .build();
             excelWriter.write(followReportList.getMainList(),mainSheet);
             excelWriter.write(followReportList.getList1(),sheet1);
-            excelWriter.write(followReportList.getList2(),sheet2);
+//            excelWriter.write(followReportList.getList2(),sheet2);
             excelWriter.write(followReportList.getList3(),sheet3);
             excelWriter.write(followReportList.getList4(),sheet4);
             excelWriter.write(followReportList.getList5(),sheet5);
@@ -187,7 +188,6 @@
     /**
      * 鏌ヨ涓嬬嚎鏁伴噺
      */
-    @PreAuthorize("@ss.hasPermi('bs:orderScheduling:list')")
     @GetMapping("/getOffLineNum")
     public TableDataInfo getOffLineNum(BsOrderScheduling bsOrderScheduling)
     {
@@ -213,14 +213,38 @@
     {
         startPage();
         List<BsOrderScheduling> list = new ArrayList<>();
+        long total = 0;
         if (StringUtils.isNotEmpty(bsOrderScheduling.getOrderNo())){
             list = bsOrderSchedulingService.selectBsOrderSchedulingPage(bsOrderScheduling);
+            if (CollUtil.isNotEmpty(list)){
+                total = new PageInfo(list).getTotal();
+                List<String> allEngineNoList = list.stream().map(BsOrderScheduling::getEngineNo).collect(Collectors.toList());
+                List<ProductNewPassStation> productPassStationListByEngineList = productNewPassStationService.getProductPassStationListByEngineList(allEngineNoList);
+                list.forEach(x -> {
+                    if (StrUtil.isNotBlank(x.getWorkingHours())){
+                        x.setWorkingHoursInt(Integer.parseInt(x.getWorkingHours()));
+                    } else {
+                        x.setWorkingHoursInt(0);
+                    }
+                    if (CollUtil.isNotEmpty(productPassStationListByEngineList)){
+                        List<ProductNewPassStation> collect = productPassStationListByEngineList.stream().filter(y -> x.getEngineNo().equals(y.getSfcCode())).collect(Collectors.toList());
+                        if (CollUtil.isNotEmpty(collect)){
+                            ProductNewPassStation productNewPassStation = collect.get(0);
+                            x.setBoxCode(productNewPassStation.getBoxCode());
+                        }
+                    }
+                });
+                list = list.stream().sorted(Comparator.comparing(BsOrderScheduling::getWorkingHoursInt)).collect(Collectors.toList());
+            }
         }
-        List<BsOrderScheduling> collect = list.stream().filter(x -> Constants.UN_QUALIFIED.equals(x.getQualityStatus())).collect(Collectors.toList());
-        if (CollUtil.isNotEmpty(collect)){
-            String.valueOf(collect.size());
-        }
-        return getDataTable(list);
+//        List<BsOrderScheduling> collect = list.stream().filter(x -> Constants.UN_QUALIFIED.equals(x.getQualityStatus())).collect(Collectors.toList());
+//        if (CollUtil.isNotEmpty(collect)){
+//            String.valueOf(collect.size());
+//        }
+        TableDataInfo dataTable = getDataTable(list);
+        dataTable.setTotal(total);
+        return dataTable;
+
     }
 
     /**
@@ -315,21 +339,38 @@
      */
     @Transactional(rollbackFor = Exception.class)
     @GetMapping("/engineNoIsInModel")
-    public R engineNoIsInModel(String engineNo,String model,String orderNo) throws Exception {
+    public R engineNoIsInModel(String engineNo,String model,String orderNo,Boolean repairFlag) throws Exception {
 
         if (StringUtils.isEmpty(engineNo)){
-            return R.fail(500,"绠变綋鐮佷负绌烘垨宸插瓨鍦紝璇烽噸璇�");
+            return R.fail(500,"绠变綋鐮佷笉鑳戒负绌猴紝璇烽噸璇�");
+        }
+        if (!engineNo.contains(",")){
+            return R.fail(500,"绠变綋鐮佹牸寮忔湁璇紝璇烽噸璇�");
         }
         ProductNewPassStation checkStation = new ProductNewPassStation();
         checkStation.setBoxCode(engineNo);
         List<ProductNewPassStation> checkList = productNewPassStationService.getProductPassStationList(checkStation);
+        if (!repairFlag){
+            if (CollUtil.isNotEmpty(checkList)){
+                return R.fail(500,"璇峰嬁閲嶅鎵弿绠变綋鐮�");
+            }
+        }
         BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
         bsOrderScheduling.setOrderNo(orderNo);
         List<BsOrderScheduling> allList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
+        if (CollUtil.isNotEmpty(allList)){
+            allList.forEach(x -> {
+                if (StrUtil.isNotBlank(x.getWorkingHours())){
+                    x.setWorkingHoursInt(Integer.parseInt(x.getWorkingHours()));
+                } else {
+                    x.setWorkingHoursInt(0);
+                }
+            });
+            allList = allList.stream().sorted(Comparator.comparing(BsOrderScheduling::getWorkingHoursInt)).collect(Collectors.toList());
+        }
         List<BsOrderScheduling> dlist = allList.stream().filter(x->x.getProductionStatus().equals(Constants.WAIT_PRODUCTION)).collect(Collectors.toList());
         List<BsOrderScheduling> collect = allList.stream().filter(x -> x.getProductionStatus().equals(Constants.ORDER_STATUS_ING)
                 ||x.getProductionStatus().equals(Constants.FINISH_PRODUCTION)).collect(Collectors.toList());
-
         if (CollUtil.isNotEmpty(checkList)){
             //閲嶅鎵爜
             ProductNewPassStation productNewPassStation = checkList.get(0);
@@ -347,6 +388,8 @@
             } else {
                 //OPC鎿嶄綔
                 logger.info("褰撳墠绔欓噸鏂版壂鐮�,{}",sfcCode);
+//                ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP010.ProductTypeSN",sfcCode);
+//                OPCUaSubscription.miloService.writeToOpcUa(entity3);//鍐欎骇鍝丼N鍙峰弽棣�
                 ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", sfcCode);
                 OPCUaSubscription.miloService.writeToOpcUa(entity);//鍐橲N
                 return R.ok();
@@ -363,7 +406,7 @@
                     OmProductionOrdeInfo omProductionOrdeInfo = omProductionOrdeInfos.get(0);
                     Long planQty = omProductionOrdeInfo.getPlanQty();
                     if (planQty<collect.size()){
-                        return R.ok(500,"瓒呭嚭璁″垝鏁伴噺锛岃妫�鏌ュ悗閲嶈瘯");
+                        return R.fail(500,"瓒呭嚭璁″垝鏁伴噺锛岃妫�鏌ュ悗閲嶈瘯");
                     }
                 }
                 //鎻掑叆鏁版嵁
@@ -428,10 +471,76 @@
                 OrderScheduling.setProductionStatus("2");
                 bsOrderSchedulingService.updateBsOrderScheduling(OrderScheduling);
                 return R.ok();
+            } else {
+                return R.fail(500,"瓒呭嚭璁″垝鏁伴噺锛岃妫�鏌ュ悗閲嶈瘯");
             }
 
         }
 
-        return R.ok();
+    }
+
+
+    @GetMapping("/changeBoxCode")
+    public R changeBoxCode(String sfcCode,String newBoxCode){
+        if (StringUtils.isEmpty(newBoxCode)){
+            return R.fail(500,"绠变綋鐮佷笉鑳戒负绌猴紝璇烽噸璇�");
+        }
+        if (StringUtils.isEmpty(sfcCode)){
+            return R.fail(500,"鍙戝姩鏈哄彿涓嶈兘涓虹┖锛岃閲嶈瘯");
+        }
+        if (!newBoxCode.contains(",")){
+            return R.fail(500,"绠变綋鐮佹牸寮忔湁璇紝璇烽噸璇�");
+        }
+        ProductNewPassStation checkStation = new ProductNewPassStation();
+        checkStation.setSfcCode(sfcCode);
+        List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(checkStation);
+        if (CollUtil.isNotEmpty(productPassStationList)){
+            productNewPassStationService.updateBoxCodeBySfcCode(sfcCode, newBoxCode);
+            return R.ok();
+        } else {
+            return R.fail("鏈煡鎵惧埌璇ュ彂鍔ㄦ満鍙峰搴旂殑绠变綋");
+        }
+    }
+
+
+    @PostMapping("/engine-report")
+    public ReportVO getReportDetail(@RequestBody SAPQuery sapQuery){
+        ReportVO reportVO = new ReportVO();
+        List<ResultDataVO> EV_DATA = new ArrayList<>();
+        List<EngineQuery> engineQueryList = sapQuery.getIV_ZFDJM();
+        if (CollUtil.isEmpty(engineQueryList)){
+            reportVO.setEV_DATA(EV_DATA);
+            return reportVO;
+        }
+        BsOrderScheduling query = new BsOrderScheduling();
+        List<String> engineNoList = engineQueryList.stream().map(EngineQuery::getZFDJM).collect(Collectors.toList());
+        query.setEngineNoList(engineNoList);
+        List<BsOrderScheduling> bsOrderSchedulingList = bsOrderSchedulingService.selectBsOrderSchedulingList(query);
+        for (String s : engineNoList) {
+            ResultDataVO  resultDataVO = new ResultDataVO();
+            resultDataVO.setZFDJM(s);
+            List<BsOrderScheduling> collect = bsOrderSchedulingList.stream().filter(x -> x.getEngineNo().equals(s)).collect(Collectors.toList());
+            if (CollUtil.isNotEmpty(collect)){
+                BsOrderScheduling bsOrderScheduling = collect.get(0);
+                if (StrUtil.isBlank(bsOrderScheduling.getReport20())){
+                    resultDataVO.setSTATU("0");
+                    resultDataVO.setEV_MESSAGE("鏈姤宸�");
+                } else {
+                    if ("1".equals(bsOrderScheduling.getReport20())){
+                        resultDataVO.setSTATU("1");
+                        resultDataVO.setEV_MESSAGE("宸叉姤宸�");
+                    } else if ("3".equals(bsOrderScheduling.getReport20())){
+                        resultDataVO.setSTATU("2");
+                        resultDataVO.setEV_MESSAGE(bsOrderScheduling.getRemarks());
+                    }
+                }
+            } else {
+                resultDataVO.setSTATU("2");
+                resultDataVO.setEV_MESSAGE("鏈煡璇㈠埌姝ゅ彂鍔ㄦ満淇℃伅");
+            }
+            EV_DATA.add(resultDataVO);
+        }
+        reportVO.setEV_DATA(EV_DATA);
+        return reportVO;
     }
 }

--
Gitblit v1.9.3