|
@@ -9,6 +9,7 @@ import com.hssx.cloudmodel.mapper.MouldHistoryTimeMapper;
|
|
|
import com.hssx.cloudmodel.service.MouldHistoryService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
|
+import com.hssx.cloudmodel.util.TimeAndCountUtil;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -32,21 +33,69 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
|
|
|
@Override
|
|
|
public HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
- Map <String,Integer> map = new HashMap<>();
|
|
|
- map.put("00:00-01:00",0);
|
|
|
- map.put("01:00-02:00",0);
|
|
|
- map.put("02:00-03:00",0);
|
|
|
- map.put("03:00-04:00",0);
|
|
|
- map.put("0:00-01:00",0);
|
|
|
- map.put("00:00-01:00",0);
|
|
|
- map.put("00:00-01:00",0);
|
|
|
List<MouldHistoryVO> list = mouldHistoryMapper.selectOpeningAndClosingTimesChart(equipmentNo,time);
|
|
|
- list.stream().forEach(x ->{
|
|
|
- if(Integer.parseInt(x.getTime()) <= 2){
|
|
|
-
|
|
|
+ Set<MouldHistoryVO> set = TimeAndCountUtil.getSet();
|
|
|
+ Map<String, Integer> map = TimeAndCountUtil.getMap();
|
|
|
+ Integer count = 0;
|
|
|
+ Map<String, List<MouldHistoryVO>> mapList = list.stream().collect(Collectors.groupingBy(MouldHistoryVO::getTime));
|
|
|
+ for(Map.Entry<String, List<MouldHistoryVO>> entry:mapList.entrySet()){
|
|
|
+ if("00".equals(entry.getKey())){
|
|
|
+ map.put("00:00-01:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("01".equals(entry.getKey())){
|
|
|
+ map.put("01:00-02:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("02".equals(entry.getKey())){
|
|
|
+ map.put("02:00-03:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("03".equals(entry.getKey())){
|
|
|
+ map.put("03:00-04:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("04".equals(entry.getKey())){
|
|
|
+ map.put("04:00-05:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("05".equals(entry.getKey())){
|
|
|
+ map.put("05:00-06:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("06".equals(entry.getKey())){
|
|
|
+ map.put("06:00-07:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("07".equals(entry.getKey())){
|
|
|
+ map.put("07:00-08:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("08".equals(entry.getKey())){
|
|
|
+ map.put("08:00-09:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("09".equals(entry.getKey())){
|
|
|
+ map.put("09:00-10:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("10".equals(entry.getKey())){
|
|
|
+ map.put("10:00-11:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("11".equals(entry.getKey())){
|
|
|
+ map.put("11:00-12:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("12".equals(entry.getKey())){
|
|
|
+ map.put("12:00-13:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("13".equals(entry.getKey())){
|
|
|
+ map.put("13:00-14:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("14".equals(entry.getKey())){
|
|
|
+ map.put("14:00-15:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("15".equals(entry.getKey())){
|
|
|
+ map.put("15:00-16:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("16".equals(entry.getKey())){
|
|
|
+ map.put("16:00-17:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("17".equals(entry.getKey())){
|
|
|
+ map.put("17:00-18:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("18".equals(entry.getKey())){
|
|
|
+ map.put("18:00-19:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("19".equals(entry.getKey())){
|
|
|
+ map.put("19:00-20:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("20".equals(entry.getKey())){
|
|
|
+ map.put("20:00-21:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("21".equals(entry.getKey())){
|
|
|
+ map.put("21:00-22:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("22".equals(entry.getKey())){
|
|
|
+ map.put("22:00-23:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
+ }else if("23".equals(entry.getKey())){
|
|
|
+ map.put("23:00-24:00",entry.getValue().stream().mapToInt(MouldHistoryVO::getRunCnt).sum());
|
|
|
}
|
|
|
- });
|
|
|
- msg.data=list;
|
|
|
+ }
|
|
|
+ System.out.println("原来的map===>"+map);
|
|
|
+ Map<String, Integer> result = map.entrySet().stream()
|
|
|
+ .sorted(Map.Entry.comparingByKey())
|
|
|
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
|
|
+ (oleValue, newValue) -> oleValue, LinkedHashMap::new));
|
|
|
+ System.out.println("排序后的map===>"+result);
|
|
|
+ msg.data=result;
|
|
|
return msg;
|
|
|
}
|
|
|
|