春风项目四线(合箱线、总装线)
yyt
2024-05-23 04b8eff075a04db23e6f908855699b4d2954588c
提交 | 用户 | 时间
d9cf6b 1 package com.jcdm.main.bs.orderScheduling.service.impl;
J 2
c6e069 3 import cn.hutool.core.collection.CollUtil;
W 4 import cn.hutool.core.util.ObjectUtil;
2aea64 5 import com.jcdm.common.utils.DateUtils;
c6e069 6 import com.jcdm.common.utils.StringUtils;
0ae9ac 7 import com.jcdm.main.bs.orderScheduling.Query.PrepareOnlineQuery;
c74dcb 8 import com.jcdm.main.bs.orderScheduling.common.Constants;
0ae9ac 9 import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
W 10 import com.jcdm.main.bs.orderScheduling.mapper.BsOrderSchedulingMapper;
11 import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
c74dcb 12 import com.jcdm.main.bs.orderScheduling.vo.FollowReportVO;
c6e069 13 import com.jcdm.main.bs.orderScheduling.vo.LineChartVO;
c74dcb 14 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
W 15 import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
16 import com.jcdm.main.da.paramCollection.service.impl.DaParamCollectionServiceImpl;
17 import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection;
18 import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper;
d9cf6b 19 import org.springframework.beans.factory.annotation.Autowired;
J 20 import org.springframework.stereotype.Service;
0ae9ac 21
c74dcb 22 import javax.annotation.Resource;
c6e069 23 import java.text.SimpleDateFormat;
W 24 import java.time.LocalDate;
25 import java.time.LocalDateTime;
26 import java.time.format.DateTimeFormatter;
27 import java.util.ArrayList;
28 import java.util.HashMap;
0ae9ac 29 import java.util.List;
c6e069 30 import java.util.Map;
W 31 import java.util.stream.Collectors;
d9cf6b 32
J 33 /**
34  * 订单排产Service业务层处理
35  * 
36  * @author jiang
2aea64 37  * @date 2024-01-13
d9cf6b 38  */
J 39 @Service
0ae9ac 40 public class BsOrderSchedulingServiceImpl implements IBsOrderSchedulingService
d9cf6b 41 {
J 42     @Autowired
43     private BsOrderSchedulingMapper bsOrderSchedulingMapper;
c74dcb 44
W 45     @Resource
46     private DaParamCollectionMapper daParamCollectionMapper;
47
48     @Resource
49     private DaPassingStationCollectionMapper daPassingStationCollectionMapper;
d9cf6b 50
J 51     /**
52      * 查询订单排产
53      * 
2aea64 54      * @param id 订单排产主键
d9cf6b 55      * @return 订单排产
J 56      */
57     @Override
2aea64 58     public BsOrderScheduling selectBsOrderSchedulingById(Long id)
d9cf6b 59     {
2aea64 60         return bsOrderSchedulingMapper.selectBsOrderSchedulingById(id);
d9cf6b 61     }
J 62
63     /**
1a444b 64      * 查询订单排产
Y 65      *
66      * @param sncode 订单排产发动机号
67      * @return 订单排产
68      */
69     @Override
70     public BsOrderScheduling selectBsOrderSchedulingSNCode(String sncode)
71     {
72         return bsOrderSchedulingMapper.selectBsOrderSchedulingSNCode(sncode);
73     }
74
75
76
77     /**
d9cf6b 78      * 查询订单排产列表
J 79      * 
80      * @param bsOrderScheduling 订单排产
81      * @return 订单排产
82      */
83     @Override
84     public List<BsOrderScheduling> selectBsOrderSchedulingList(BsOrderScheduling bsOrderScheduling)
85     {
d2b752 86         if(bsOrderScheduling.getDateConditions()!=null){
87             String[] conditions = bsOrderScheduling.getDateConditions();
88             bsOrderScheduling.setStartTime(conditions[0]);
89             bsOrderScheduling.setEndTime(conditions[1]);
90         }
d9cf6b 91         return bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
J 92     }
93
c6e069 94     @Override
d4f437 95     public List<BsOrderScheduling> selectBsOrderSchedulingPage(BsOrderScheduling bsOrderScheduling)
Y 96     {
97         if(bsOrderScheduling.getDateConditions()!=null){
98             String[] conditions = bsOrderScheduling.getDateConditions();
99             bsOrderScheduling.setStartTime(conditions[0]);
100             bsOrderScheduling.setEndTime(conditions[1]);
101         }
102         return bsOrderSchedulingMapper.selectBsOrderSchedulingPage(bsOrderScheduling);
103     }
104
105
106     @Override
c74dcb 107     public FollowReportVO getFollowReportList(BsOrderScheduling bsOrderScheduling)
W 108     {
109         FollowReportVO vo = new FollowReportVO();
110         if(bsOrderScheduling.getDateConditions()!=null){
111             String[] conditions = bsOrderScheduling.getDateConditions();
112             bsOrderScheduling.setStartTime(conditions[0]);
113             bsOrderScheduling.setEndTime(conditions[1]);
114         }
115         //主表数据
116         List<BsOrderScheduling> mainList = bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
117         vo.setMainList(mainList);
118         List<String> engineNoList = mainList.stream().map(BsOrderScheduling::getEngineNo).distinct().collect(Collectors.toList());
119         List<DaParamCollection> allChildList = new ArrayList<>();
120         List<DaPassingStationCollection> collect5 = new ArrayList<>();
121         if (CollUtil.isNotEmpty(engineNoList)){
122             allChildList = daParamCollectionMapper.getListBySfcCode(engineNoList);
123             collect5 = daPassingStationCollectionMapper.getListBySfcCode(engineNoList);
124         }
125         if (CollUtil.isNotEmpty(allChildList)){
126             //拿到所有子数据
127             List<DaParamCollection> collect1 = allChildList.stream().filter(x -> Constants.DATA1.equals(x.getType())).collect(Collectors.toList());
128             List<DaParamCollection> collect2 = allChildList.stream().filter(x -> Constants.DATA2.equals(x.getType())).collect(Collectors.toList());
129             List<DaParamCollection> collect3 = allChildList.stream().filter(x -> Constants.DATA3.equals(x.getType())).collect(Collectors.toList());
130             List<DaParamCollection> collect4 = allChildList.stream().filter(x -> Constants.DATA4.equals(x.getType())).collect(Collectors.toList());
131             vo.setList1(collect1);
132             vo.setList2(collect2);
133             vo.setList3(collect3);
134             vo.setList4(collect4);
135         }
136         vo.setList5(collect5);
137         return vo;
138
139     }
140
141     @Override
c6e069 142     public List<LineChartVO> getOffLineNum()
W 143     {
144         List<LineChartVO> result = new ArrayList<>();
145         BsOrderScheduling bsOrderScheduling =  new BsOrderScheduling();
146         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
147         LocalDateTime now = LocalDateTime.now();
148         LocalDateTime startTime = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.getDayOfMonth(),8,0,0);
04b8ef 149         LocalDateTime endTime = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.plusDays(1).getDayOfMonth(),23,0,0);
c6e069 150         String s1 = startTime.format(formatter);
W 151         String s2 = endTime.format(formatter);
152         bsOrderScheduling.setStartTime(s1);
153         bsOrderScheduling.setEndTime(s2);
154         List<BsOrderScheduling> todayList = bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
bbc578 155         todayList = todayList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getFinalAssemblyOfflineTime())).collect(Collectors.toList());
c6e069 156         if (CollUtil.isNotEmpty(todayList)){
W 157             List<String> allModel = todayList.stream().map(BsOrderScheduling::getModel).distinct().collect(Collectors.toList());
158             Map<String, List<BsOrderScheduling>> collect = new HashMap<>();
159             for (String s : allModel) {
160                 LineChartVO vo = new LineChartVO();
161                 List<Integer> arr = new ArrayList<>();
162                 vo.setName(s);
163                 collect = todayList.stream().filter(x -> s.equals(x.getModel())).collect(Collectors.groupingBy(item -> new SimpleDateFormat("yyyy-MM-dd HH").format(item
bbc578 164                         .getFinalAssemblyOfflineTime())));
c6e069 165                 Map<Integer,Integer> temp = new HashMap<>();
W 166                 if (CollUtil.isNotEmpty(collect)){
167                     for (String string : collect.keySet()) {
168                         int size = collect.get(string).size();
169                         String s3 = string.split(StringUtils.SPACE)[1];
170                         if (StringUtils.isNotEmpty(s3)){
171                             int i = Integer.parseInt(s3);
2720ac 172                             temp.put(i+1,size);
c6e069 173                         }
W 174                     }
175                 }
176                 for (int i = 8; i < 23; i++) {
2720ac 177                     if (i==8){
W 178                         arr.add(0);
179                     }else {
180                         arr.add(temp.getOrDefault(i, 0));
181                     }
c6e069 182                 }
W 183                 vo.setData(arr);
184                 vo.setType("line");
185                 result.add(vo);
186             }
187
188         }
189         return result;
190     }
191
0ae9ac 192
W 193     /**
194      * 查询合箱上线列表
195      * @param prepareOnlineQuery
196      * @return list
197      */
198     public List<BsOrderScheduling> getPrepareOnlineList(PrepareOnlineQuery prepareOnlineQuery){
199         return bsOrderSchedulingMapper.getPrepareOnlineList(prepareOnlineQuery);
200     }
d9cf6b 201     /**
J 202      * 新增订单排产
203      * 
204      * @param bsOrderScheduling 订单排产
205      * @return 结果
206      */
207     @Override
208     public int insertBsOrderScheduling(BsOrderScheduling bsOrderScheduling)
209     {
2aea64 210         bsOrderScheduling.setCreateTime(DateUtils.getNowDate());
d9cf6b 211         return bsOrderSchedulingMapper.insertBsOrderScheduling(bsOrderScheduling);
J 212     }
213
214     /**
215      * 修改订单排产
216      * 
217      * @param bsOrderScheduling 订单排产
218      * @return 结果
219      */
220     @Override
221     public int updateBsOrderScheduling(BsOrderScheduling bsOrderScheduling)
222     {
2aea64 223         bsOrderScheduling.setUpdateTime(DateUtils.getNowDate());
d9cf6b 224         return bsOrderSchedulingMapper.updateBsOrderScheduling(bsOrderScheduling);
J 225     }
226
227     /**
228      * 批量删除订单排产
229      * 
2aea64 230      * @param ids 需要删除的订单排产主键
d9cf6b 231      * @return 结果
J 232      */
233     @Override
2aea64 234     public int deleteBsOrderSchedulingByIds(Long[] ids)
d9cf6b 235     {
2aea64 236         return bsOrderSchedulingMapper.deleteBsOrderSchedulingByIds(ids);
d9cf6b 237     }
J 238
239     /**
240      * 删除订单排产信息
241      * 
2aea64 242      * @param id 订单排产主键
d9cf6b 243      * @return 结果
J 244      */
245     @Override
2aea64 246     public int deleteBsOrderSchedulingById(Long id)
d9cf6b 247     {
2aea64 248         return bsOrderSchedulingMapper.deleteBsOrderSchedulingById(id);
d9cf6b 249     }
J 250 }