whycxzp
2023-03-17 ab049c643b68186f0ee3895eebc155c81ec7f9de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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;
    }
}