package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.BattDischargePlanTempMapper;
|
import com.whyc.pojo.BattDischargePlanTemp;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.annotation.Lazy;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.LinkedList;
|
import java.util.List;
|
|
@Service
|
public class BattDischargePlanTempService {
|
|
@Resource
|
private BattDischargePlanTempMapper mapper;
|
|
@Autowired
|
@Lazy
|
private BattdischargePlanService planService;
|
|
public void truncate() {
|
mapper.truncate();
|
}
|
|
public void insertBatch(List<BattDischargePlanTemp> tempList) {
|
mapper.insertBatchSomeColumn(tempList);
|
}
|
|
public Response getReplaceBattGroupList(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){
|
currentTemp = temp;
|
break;
|
}
|
}
|
//同类型替换,并且不能是同一天的
|
for (BattDischargePlanTemp temp : tempList) {
|
assert currentTemp != null;
|
if(temp.getBattGroupId()!=battGroupId &&temp.getDischargeStartTime().compareTo(currentTemp.getDischargeStartTime())!=0 && temp.getNodeStation().equals(currentTemp.getNodeStation())){
|
if(temp.getGroupId().equals(currentTemp.getGroupId())){ //同班组,推荐
|
recommendList.add(temp);
|
}else{
|
list.add(temp);
|
}
|
}
|
}
|
return new Response().setII(1,recommendList,list,null);
|
}
|
|
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){
|
currentTemp = temp;
|
break;
|
}
|
}
|
//不可用的时间,三种方式,层层筛选:1.当前电池组时间 2.其他 满足每天3个站点的时间 3.如果当前为节点站,再其他,存在节点站的时间
|
|
return null;
|
}
|
}
|