From 0e3cac8d5d9603cdd5ff8935e4054f0018a35ed9 Mon Sep 17 00:00:00 2001
From: wujian <14790700720@163.com>
Date: 星期日, 28 四月 2024 15:08:56 +0800
Subject: [PATCH] change model10

---
 jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/service/impl/BsOrderSchedulingServiceImpl.java |  161 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 146 insertions(+), 15 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/service/impl/BsOrderSchedulingServiceImpl.java b/jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/service/impl/BsOrderSchedulingServiceImpl.java
index 9b7dd5c..5f19de3 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/service/impl/BsOrderSchedulingServiceImpl.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/service/impl/BsOrderSchedulingServiceImpl.java
@@ -1,34 +1,63 @@
 package com.jcdm.main.bs.orderScheduling.service.impl;
 
-import java.util.List;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.jcdm.common.utils.DateUtils;
+import com.jcdm.common.utils.StringUtils;
+import com.jcdm.main.bs.orderScheduling.Query.PrepareOnlineQuery;
+import com.jcdm.main.bs.orderScheduling.common.Constants;
+import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
+import com.jcdm.main.bs.orderScheduling.mapper.BsOrderSchedulingMapper;
+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.da.paramCollection.domain.DaParamCollection;
+import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
+import com.jcdm.main.da.paramCollection.service.impl.DaParamCollectionServiceImpl;
+import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
+import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.jcdm.main.bs.orderScheduling.mapper.BsOrderSchedulingMapper;
-import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
-import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 璁㈠崟鎺掍骇Service涓氬姟灞傚鐞�
  * 
  * @author jiang
- * @date 2024-01-09
+ * @date 2024-01-13
  */
 @Service
-public class BsOrderSchedulingServiceImpl implements IBsOrderSchedulingService 
+public class BsOrderSchedulingServiceImpl implements IBsOrderSchedulingService
 {
     @Autowired
     private BsOrderSchedulingMapper bsOrderSchedulingMapper;
 
+    @Resource
+    private DaParamCollectionMapper daParamCollectionMapper;
+
+    @Resource
+    private DaPassingStationCollectionMapper daPassingStationCollectionMapper;
+
     /**
      * 鏌ヨ璁㈠崟鎺掍骇
      * 
-     * @param orderNumber 璁㈠崟鎺掍骇涓婚敭
+     * @param id 璁㈠崟鎺掍骇涓婚敭
      * @return 璁㈠崟鎺掍骇
      */
     @Override
-    public BsOrderScheduling selectBsOrderSchedulingByOrderNumber(String orderNumber)
+    public BsOrderScheduling selectBsOrderSchedulingById(Long id)
     {
-        return bsOrderSchedulingMapper.selectBsOrderSchedulingByOrderNumber(orderNumber);
+        return bsOrderSchedulingMapper.selectBsOrderSchedulingById(id);
     }
 
     /**
@@ -40,9 +69,109 @@
     @Override
     public List<BsOrderScheduling> selectBsOrderSchedulingList(BsOrderScheduling bsOrderScheduling)
     {
+        if(bsOrderScheduling.getDateConditions()!=null){
+            String[] conditions = bsOrderScheduling.getDateConditions();
+            bsOrderScheduling.setStartTime(conditions[0]);
+            bsOrderScheduling.setEndTime(conditions[1]);
+        }
         return bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
     }
 
+    @Override
+    public FollowReportVO getFollowReportList(BsOrderScheduling bsOrderScheduling)
+    {
+        FollowReportVO vo = new FollowReportVO();
+        if(bsOrderScheduling.getDateConditions()!=null){
+            String[] conditions = bsOrderScheduling.getDateConditions();
+            bsOrderScheduling.setStartTime(conditions[0]);
+            bsOrderScheduling.setEndTime(conditions[1]);
+        }
+        //涓昏〃鏁版嵁
+        List<BsOrderScheduling> mainList = bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
+        vo.setMainList(mainList);
+        List<String> engineNoList = mainList.stream().map(BsOrderScheduling::getEngineNo).distinct().collect(Collectors.toList());
+        List<DaParamCollection> allChildList = new ArrayList<>();
+        List<DaPassingStationCollection> collect5 = new ArrayList<>();
+        if (CollUtil.isNotEmpty(engineNoList)){
+            allChildList = daParamCollectionMapper.getListBySfcCode(engineNoList);
+            collect5 = daPassingStationCollectionMapper.getListBySfcCode(engineNoList);
+        }
+        if (CollUtil.isNotEmpty(allChildList)){
+            //鎷垮埌鎵�鏈夊瓙鏁版嵁
+            List<DaParamCollection> collect1 = allChildList.stream().filter(x -> Constants.DATA1.equals(x.getType())).collect(Collectors.toList());
+            List<DaParamCollection> collect2 = allChildList.stream().filter(x -> Constants.DATA2.equals(x.getType())).collect(Collectors.toList());
+            List<DaParamCollection> collect3 = allChildList.stream().filter(x -> Constants.DATA3.equals(x.getType())).collect(Collectors.toList());
+            List<DaParamCollection> collect4 = allChildList.stream().filter(x -> Constants.DATA4.equals(x.getType())).collect(Collectors.toList());
+            vo.setList1(collect1);
+            vo.setList2(collect2);
+            vo.setList3(collect3);
+            vo.setList4(collect4);
+        }
+        vo.setList5(collect5);
+        return vo;
+
+    }
+
+    @Override
+    public List<LineChartVO> getOffLineNum()
+    {
+        List<LineChartVO> result = new ArrayList<>();
+        BsOrderScheduling bsOrderScheduling =  new BsOrderScheduling();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime startTime = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.getDayOfMonth(),8,0,0);
+        LocalDateTime endTime = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.plusDays(1).getDayOfMonth(),22,0,0);
+        String s1 = startTime.format(formatter);
+        String s2 = endTime.format(formatter);
+        bsOrderScheduling.setStartTime(s1);
+        bsOrderScheduling.setEndTime(s2);
+        List<BsOrderScheduling> todayList = bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
+        todayList = todayList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getCvtOfflineTime())).collect(Collectors.toList());
+        if (CollUtil.isNotEmpty(todayList)){
+            List<String> allModel = todayList.stream().map(BsOrderScheduling::getModel).distinct().collect(Collectors.toList());
+            Map<String, List<BsOrderScheduling>> collect = new HashMap<>();
+            for (String s : allModel) {
+                LineChartVO vo = new LineChartVO();
+                List<Integer> arr = new ArrayList<>();
+                vo.setName(s);
+                collect = todayList.stream().filter(x -> s.equals(x.getModel())).collect(Collectors.groupingBy(item -> new SimpleDateFormat("yyyy-MM-dd HH").format(item
+                        .getCvtOfflineTime())));
+                Map<Integer,Integer> temp = new HashMap<>();
+                if (CollUtil.isNotEmpty(collect)){
+                    for (String string : collect.keySet()) {
+                        int size = collect.get(string).size();
+                        String s3 = string.split(StringUtils.SPACE)[1];
+                        if (StringUtils.isNotEmpty(s3)){
+                            int i = Integer.parseInt(s3);
+                            temp.put(i+1,size);
+                        }
+                    }
+                }
+                for (int i = 8; i < 23; i++) {
+                    if (i==8){
+                        arr.add(0);
+                    }else {
+                        arr.add(temp.getOrDefault(i, 0));
+                    }
+                }
+                vo.setData(arr);
+                vo.setType("line");
+                result.add(vo);
+            }
+
+        }
+        return result;
+    }
+
+
+    /**
+     * 鏌ヨ鍚堢涓婄嚎鍒楄〃
+     * @param prepareOnlineQuery
+     * @return list
+     */
+    public List<BsOrderScheduling> getPrepareOnlineList(PrepareOnlineQuery prepareOnlineQuery){
+        return bsOrderSchedulingMapper.getPrepareOnlineList(prepareOnlineQuery);
+    }
     /**
      * 鏂板璁㈠崟鎺掍骇
      * 
@@ -52,6 +181,7 @@
     @Override
     public int insertBsOrderScheduling(BsOrderScheduling bsOrderScheduling)
     {
+        bsOrderScheduling.setCreateTime(DateUtils.getNowDate());
         return bsOrderSchedulingMapper.insertBsOrderScheduling(bsOrderScheduling);
     }
 
@@ -64,30 +194,31 @@
     @Override
     public int updateBsOrderScheduling(BsOrderScheduling bsOrderScheduling)
     {
+        bsOrderScheduling.setUpdateTime(DateUtils.getNowDate());
         return bsOrderSchedulingMapper.updateBsOrderScheduling(bsOrderScheduling);
     }
 
     /**
      * 鎵归噺鍒犻櫎璁㈠崟鎺掍骇
      * 
-     * @param orderNumbers 闇�瑕佸垹闄ょ殑璁㈠崟鎺掍骇涓婚敭
+     * @param ids 闇�瑕佸垹闄ょ殑璁㈠崟鎺掍骇涓婚敭
      * @return 缁撴灉
      */
     @Override
-    public int deleteBsOrderSchedulingByOrderNumbers(String[] orderNumbers)
+    public int deleteBsOrderSchedulingByIds(Long[] ids)
     {
-        return bsOrderSchedulingMapper.deleteBsOrderSchedulingByOrderNumbers(orderNumbers);
+        return bsOrderSchedulingMapper.deleteBsOrderSchedulingByIds(ids);
     }
 
     /**
      * 鍒犻櫎璁㈠崟鎺掍骇淇℃伅
      * 
-     * @param orderNumber 璁㈠崟鎺掍骇涓婚敭
+     * @param id 璁㈠崟鎺掍骇涓婚敭
      * @return 缁撴灉
      */
     @Override
-    public int deleteBsOrderSchedulingByOrderNumber(String orderNumber)
+    public int deleteBsOrderSchedulingById(Long id)
     {
-        return bsOrderSchedulingMapper.deleteBsOrderSchedulingByOrderNumber(orderNumber);
+        return bsOrderSchedulingMapper.deleteBsOrderSchedulingById(id);
     }
 }

--
Gitblit v1.9.3