| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class BattDischargePlanTempService { |
| | |
| | | |
| | | public Response getDisabledDischargeTime(int battGroupId) { |
| | | List<BattDischargePlanTemp> tempList = mapper.selectList(null); |
| | | List<BattDischargePlanTemp> recommendList = new LinkedList<>(); |
| | | List<BattDischargePlanTemp> list = new LinkedList<>(); |
| | | BattDischargePlanTemp currentTemp = null; |
| | | for (BattDischargePlanTemp temp : tempList) { |
| | | if(temp.getBattGroupId()==battGroupId){ |
| | |
| | | } |
| | | } |
| | | //不可用的时间,三种方式,层层筛选:1.当前电池组时间 2.其他 满足每天3个站点的时间 3.如果当前为节点站,再其他,存在节点站的时间 |
| | | |
| | | return null; |
| | | List<Date> disabledDischargeTimeList = new LinkedList<>(); |
| | | Date dischargeStartTime = currentTemp.getDischargeStartTime(); |
| | | disabledDischargeTimeList.add(dischargeStartTime); |
| | | Integer nodeStation = currentTemp.getNodeStation(); |
| | | Map<Date, List<BattDischargePlanTemp>> dischargeMap = tempList.stream().collect(Collectors.groupingBy(BattDischargePlanTemp::getDischargeStartTime)); |
| | | Set<Date> dates = dischargeMap.keySet(); |
| | | for (Date date : dates) { |
| | | if(dischargeStartTime.compareTo(date)==0){ |
| | | continue; |
| | | } |
| | | List<BattDischargePlanTemp> dailyTempList = dischargeMap.get(date); |
| | | if (dailyTempList.size()==3){ |
| | | disabledDischargeTimeList.add(date); |
| | | }else{ //当天不足3个站点 |
| | | if(nodeStation == 1){ //如果需要插入的站点是节点站,当天存在节点站,也不可用 |
| | | for (BattDischargePlanTemp temp : dailyTempList) { |
| | | if(temp.getNodeStation()==1){ |
| | | disabledDischargeTimeList.add(date); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | disabledDischargeTimeList = disabledDischargeTimeList.stream().sorted().collect(Collectors.toList()); |
| | | return new Response().set(1,disabledDischargeTimeList); |
| | | } |
| | | } |