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