|
@@ -1,15 +1,19 @@
|
|
|
package com.hssx.cloudmodel.service.impl;
|
|
|
|
|
|
import com.hssx.cloudmodel.entity.MouldHistory;
|
|
|
+import com.hssx.cloudmodel.entity.MouldHistoryTime;
|
|
|
+import com.hssx.cloudmodel.entity.vo.MouldHistoryTimeVO;
|
|
|
import com.hssx.cloudmodel.entity.vo.MouldHistoryVO;
|
|
|
import com.hssx.cloudmodel.mapper.MouldHistoryMapper;
|
|
|
+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 org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -23,6 +27,8 @@ import java.util.List;
|
|
|
public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, MouldHistory> implements MouldHistoryService {
|
|
|
@Resource
|
|
|
private MouldHistoryMapper mouldHistoryMapper;
|
|
|
+ @Resource
|
|
|
+ private MouldHistoryTimeMapper mouldHistoryTimeMapper;
|
|
|
@Override
|
|
|
public HttpRespMsg getOpeningAndClosingTimesChart(String equipmentNo, String time) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
@@ -30,4 +36,39 @@ public class MouldHistoryServiceImpl extends ServiceImpl<MouldHistoryMapper, Mou
|
|
|
msg.data=list;
|
|
|
return msg;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg openingAndClosingTimesChartCycle(MouldHistoryTimeVO mouldHistoryTimeVO) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ mouldHistoryTimeVO.setStartTime(mouldHistoryTimeVO.getStartTime());
|
|
|
+// mouldHistoryTimeVO.setStartTime(mouldHistoryTimeVO.getStartTime()+" 00:00:00");
|
|
|
+ System.out.println(mouldHistoryTimeVO.getStartTime());
|
|
|
+// mouldHistoryTimeVO.setEndTime(mouldHistoryTimeVO.getEndTime()+" 23:59:59");
|
|
|
+ mouldHistoryTimeVO.setEndTime(mouldHistoryTimeVO.getEndTime());
|
|
|
+ System.out.println(mouldHistoryTimeVO.getEndTime());
|
|
|
+ List<MouldHistoryTimeVO> list = mouldHistoryTimeMapper.getOpeningAndClosingTimesChartCycle(mouldHistoryTimeVO.getStartTime(),mouldHistoryTimeVO.getEndTime(),mouldHistoryTimeVO.getEquipmentNo());
|
|
|
+ Map<String, List<MouldHistoryTimeVO>> map = list.stream().collect(Collectors.groupingBy(MouldHistoryTimeVO::getTime));
|
|
|
+ List<MouldHistoryTimeVO> resultList = new ArrayList<>();
|
|
|
+ for(Map.Entry<String, List<MouldHistoryTimeVO>> entry : map.entrySet()){
|
|
|
+ String mapKey = entry.getKey();
|
|
|
+ MouldHistoryTimeVO vo = new MouldHistoryTimeVO();
|
|
|
+ vo.setTime(mapKey);
|
|
|
+ List<MouldHistoryTimeVO> mapValue = entry.getValue();
|
|
|
+ vo.setMinCycle(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).min().getAsInt());
|
|
|
+ vo.setMinCycle(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).max().getAsInt());
|
|
|
+ vo.setAvgCycle(mapValue.stream().mapToInt(MouldHistoryTimeVO::getTimeCost).average().getAsDouble());
|
|
|
+ resultList.add(vo);
|
|
|
+ }
|
|
|
+ System.out.println("原来的resultList===>"+resultList);
|
|
|
+ resultList = resultList.stream().sorted(Comparator.comparing(MouldHistoryTimeVO::getTime)).collect(Collectors.toList());
|
|
|
+ System.out.println("排序后的resultList===>"+resultList);
|
|
|
+ msg.data = resultList;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ List<Integer> primes = Arrays.asList(1,2,5,6,7,3,4,8,9,10);
|
|
|
+ primes = primes.stream().sorted(Comparator.comparing(x -> x)).collect(Collectors.toList());
|
|
|
+ System.out.println(primes);
|
|
|
+ }
|
|
|
}
|