春风项目四线(合箱线、总装线)
wujian
2024-10-23 2c65c31aceb16c1d06c692266e3fb555ecafdfb5
提交 | 用户 | 时间
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
2c65c3 95     public List<BsOrderScheduling> selectBsOrderSchedulingListForNum() {
W 96         LocalDate today = LocalDate.now();
97         LocalDate localDate = today.plusDays(1);
98         String queryDate = today.toString();
99         String addQueryDate = localDate.toString();
100         return bsOrderSchedulingMapper.selectBsOrderSchedulingListForNum(queryDate,addQueryDate);
101     }
102
103     @Override
d4f437 104     public List<BsOrderScheduling> selectBsOrderSchedulingPage(BsOrderScheduling bsOrderScheduling)
Y 105     {
106         if(bsOrderScheduling.getDateConditions()!=null){
107             String[] conditions = bsOrderScheduling.getDateConditions();
108             bsOrderScheduling.setStartTime(conditions[0]);
109             bsOrderScheduling.setEndTime(conditions[1]);
110         }
111         return bsOrderSchedulingMapper.selectBsOrderSchedulingPage(bsOrderScheduling);
112     }
113
114
115     @Override
c74dcb 116     public FollowReportVO getFollowReportList(BsOrderScheduling bsOrderScheduling)
W 117     {
118         FollowReportVO vo = new FollowReportVO();
119         if(bsOrderScheduling.getDateConditions()!=null){
120             String[] conditions = bsOrderScheduling.getDateConditions();
121             bsOrderScheduling.setStartTime(conditions[0]);
122             bsOrderScheduling.setEndTime(conditions[1]);
123         }
124         //主表数据
125         List<BsOrderScheduling> mainList = bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
126         vo.setMainList(mainList);
127         List<String> engineNoList = mainList.stream().map(BsOrderScheduling::getEngineNo).distinct().collect(Collectors.toList());
128         List<DaParamCollection> allChildList = new ArrayList<>();
129         List<DaPassingStationCollection> collect5 = new ArrayList<>();
130         if (CollUtil.isNotEmpty(engineNoList)){
131             allChildList = daParamCollectionMapper.getListBySfcCode(engineNoList);
2c65c3 132             List<DaPassingStationCollection> tempCollect = daPassingStationCollectionMapper.getListBySfcCode(engineNoList);
W 133             if (engineNoList.size()>1){
134                 List<DaPassingStationCollection> outCollect = new ArrayList<>();
135                 engineNoList.forEach(engineNo -> {
136                     List<DaPassingStationCollection> collect = tempCollect.stream().filter(x -> engineNo.equals(x.getSfcCode())).collect(Collectors.toList());
137                     outCollect.addAll(collect);
138                 });
139                 collect5 = outCollect;
140             } else {
141                 collect5 = tempCollect;
142             }
c74dcb 143         }
W 144         if (CollUtil.isNotEmpty(allChildList)){
145             //拿到所有子数据
146             List<DaParamCollection> collect1 = allChildList.stream().filter(x -> Constants.DATA1.equals(x.getType())).collect(Collectors.toList());
2c65c3 147 //            List<DaParamCollection> collect2 = allChildList.stream().filter(x -> Constants.DATA2.equals(x.getType())).collect(Collectors.toList());
c74dcb 148             List<DaParamCollection> collect3 = allChildList.stream().filter(x -> Constants.DATA3.equals(x.getType())).collect(Collectors.toList());
W 149             List<DaParamCollection> collect4 = allChildList.stream().filter(x -> Constants.DATA4.equals(x.getType())).collect(Collectors.toList());
150             vo.setList1(collect1);
2c65c3 151 //            vo.setList2(collect2);
c74dcb 152             vo.setList3(collect3);
W 153             vo.setList4(collect4);
154         }
155         vo.setList5(collect5);
156         return vo;
157
158     }
159
160     @Override
c6e069 161     public List<LineChartVO> getOffLineNum()
W 162     {
163         List<LineChartVO> result = new ArrayList<>();
164         BsOrderScheduling bsOrderScheduling =  new BsOrderScheduling();
165         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
166         LocalDateTime now = LocalDateTime.now();
131e8c 167         LocalDateTime plusDays = now.plusDays(1);
c6e069 168         LocalDateTime startTime = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.getDayOfMonth(),8,0,0);
131e8c 169         LocalDateTime endTime = LocalDateTime.of(now.getYear(),plusDays.getMonthValue(),plusDays.getDayOfMonth(),23,0,0);
c6e069 170         String s1 = startTime.format(formatter);
W 171         String s2 = endTime.format(formatter);
172         bsOrderScheduling.setStartTime(s1);
173         bsOrderScheduling.setEndTime(s2);
174         List<BsOrderScheduling> todayList = bsOrderSchedulingMapper.selectBsOrderSchedulingList(bsOrderScheduling);
bbc578 175         todayList = todayList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getFinalAssemblyOfflineTime())).collect(Collectors.toList());
c6e069 176         if (CollUtil.isNotEmpty(todayList)){
W 177             List<String> allModel = todayList.stream().map(BsOrderScheduling::getModel).distinct().collect(Collectors.toList());
178             Map<String, List<BsOrderScheduling>> collect = new HashMap<>();
179             for (String s : allModel) {
180                 LineChartVO vo = new LineChartVO();
181                 List<Integer> arr = new ArrayList<>();
182                 vo.setName(s);
183                 collect = todayList.stream().filter(x -> s.equals(x.getModel())).collect(Collectors.groupingBy(item -> new SimpleDateFormat("yyyy-MM-dd HH").format(item
bbc578 184                         .getFinalAssemblyOfflineTime())));
c6e069 185                 Map<Integer,Integer> temp = new HashMap<>();
W 186                 if (CollUtil.isNotEmpty(collect)){
187                     for (String string : collect.keySet()) {
188                         int size = collect.get(string).size();
189                         String s3 = string.split(StringUtils.SPACE)[1];
190                         if (StringUtils.isNotEmpty(s3)){
191                             int i = Integer.parseInt(s3);
2720ac 192                             temp.put(i+1,size);
c6e069 193                         }
W 194                     }
195                 }
0ae327 196                 for (int i = 8; i < 24; i++) {
2720ac 197                     if (i==8){
W 198                         arr.add(0);
199                     }else {
200                         arr.add(temp.getOrDefault(i, 0));
201                     }
c6e069 202                 }
W 203                 vo.setData(arr);
204                 vo.setType("line");
205                 result.add(vo);
206             }
207
208         }
209         return result;
210     }
211
0ae9ac 212
W 213     /**
214      * 查询合箱上线列表
215      * @param prepareOnlineQuery
216      * @return list
217      */
218     public List<BsOrderScheduling> getPrepareOnlineList(PrepareOnlineQuery prepareOnlineQuery){
219         return bsOrderSchedulingMapper.getPrepareOnlineList(prepareOnlineQuery);
220     }
d9cf6b 221     /**
J 222      * 新增订单排产
223      * 
224      * @param bsOrderScheduling 订单排产
225      * @return 结果
226      */
227     @Override
228     public int insertBsOrderScheduling(BsOrderScheduling bsOrderScheduling)
229     {
2aea64 230         bsOrderScheduling.setCreateTime(DateUtils.getNowDate());
d9cf6b 231         return bsOrderSchedulingMapper.insertBsOrderScheduling(bsOrderScheduling);
J 232     }
233
234     /**
235      * 修改订单排产
236      * 
237      * @param bsOrderScheduling 订单排产
238      * @return 结果
239      */
240     @Override
241     public int updateBsOrderScheduling(BsOrderScheduling bsOrderScheduling)
242     {
2aea64 243         bsOrderScheduling.setUpdateTime(DateUtils.getNowDate());
d9cf6b 244         return bsOrderSchedulingMapper.updateBsOrderScheduling(bsOrderScheduling);
J 245     }
246
247     /**
248      * 批量删除订单排产
249      * 
2aea64 250      * @param ids 需要删除的订单排产主键
d9cf6b 251      * @return 结果
J 252      */
253     @Override
2aea64 254     public int deleteBsOrderSchedulingByIds(Long[] ids)
d9cf6b 255     {
2aea64 256         return bsOrderSchedulingMapper.deleteBsOrderSchedulingByIds(ids);
d9cf6b 257     }
J 258
259     /**
260      * 删除订单排产信息
261      * 
2aea64 262      * @param id 订单排产主键
d9cf6b 263      * @return 结果
J 264      */
265     @Override
2aea64 266     public int deleteBsOrderSchedulingById(Long id)
d9cf6b 267     {
2aea64 268         return bsOrderSchedulingMapper.deleteBsOrderSchedulingById(id);
d9cf6b 269     }
J 270 }