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