whyczh
2021-12-10 1ab06fa644b400182dde1621c60f904c4711f2b6
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
package com.whyc.service;
 
import com.whyc.dto.AllModel;
import com.whyc.dto.Batt_Maint_Dealarm;
import com.whyc.dto.Response;
import com.whyc.dto.ServiceModel;
import com.whyc.mapper.BattInfMapper;
import com.whyc.mapper.BattMaintDealarmMapper;
import com.whyc.mapper.BatttestdataInfMapper;
import com.whyc.pojo.Battinf;
import com.whyc.pojo.BatttestdataInf;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
@Service
public class BattMaintDealarmService {
 
 
    @Resource
    private BatttestdataInfService service;
    @Resource
    private BattMaintDealarmMapper mapper;
    @Resource
    private BattInfMapper battInfMapper;
    @Resource
    private BatttestdataInfMapper batttestdataInfMapper;
 
    /**
     * //1.2电池组统计分析查询
     *
     * @param bmd
     * @return
     */
 
//    SELECT DISTINCT
//    (
//            db_battinf.tb_battinf.BattgroupId
//            ),
//    StationName1,
//    StationName,
//    stationip,
//    BattGroupName,
//    BattGroupName1,
//    moncount,
//    moncapstd,
//    monvolstd,
//    battproducer,
//    battproductdate,
//    battinusedate,
//    db_batt_testdata.tb_batttestdata_inf.test_record_count,
//    test_starttime
//            FROM
//    db_battinf.tb_battinf,
//    db_batt_testdata.tb_batttestdata_inf
//            WHERE
//    db_battinf.tb_battinf.battgroupid = db_batt_testdata.tb_batttestdata_inf.battgroupid
//    AND record_time >=?
//    AND record_time <=?
//
//    <if test="battGroupId==0">
//    and db_battinf.tb_battinf.battgroupid!=#{battGroupId}
//    </if>
//    <if test="battGroupId!=0">
//    and db_battinf.tb_battinf.battgroupid==#{battGroupId}
//    </if>
//
//
//    AND db_battinf.tb_battinf.BattgroupId IN (
//            SELECT DISTINCT
//        db_battinf.tb_battinf.battgroupid
//                FROM
//                db_battinf.tb_battinf,
//            db_user.tb_user_battgroup_baojigroup_battgroup,
//            db_user.tb_user_battgroup_baojigroup_usr,
//            db_user.tb_user_inf
//                    WHERE
//        db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId = db_battinf.tb_battinf.BattGroupId
//                    AND db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id = db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id
//                    AND db_user.tb_user_inf.uid = db_user.tb_user_battgroup_baojigroup_usr.uid
//                    AND db_user.tb_user_inf.uid =?
//                    AND db_battinf.tb_battinf.stationname1 LIKE ?
//                    AND db_battinf.tb_battinf.stationname LIKE ?
//    )
//
//
//    <if test="test_type==2">
//    and test_type=2    //充电
//            </if>
//
////用于放电类型
////全部
//    <if test="test_type==3&&test_starttype=0">
//    and test_type=3
//            </if>
//    <if test="test_type==3&&test_starttype=1">
//    and (test_starttype<5 and test_type not in(2,9) and  test_starttype!=2 AND test_starttype!=3)
//    </if>
//    <if test="test_type==3&&test_starttype=2">
//    and (test_starttype=2 and test_type not in(2) )
//    </if>
//    <if test="test_type==3&&test_starttype=3">
//    and (test_starttype=3 and test_type not in(2) )
//    </if>
//    order by db_battinf.tb_battinf.battgroupid asc,test_starttime asc
//
 
    //TODO rzg battInfMapper
    public Response<List<AllModel>> searchLow(Batt_Maint_Dealarm bmd) {
        BatttestdataInf tdata = bmd.getBtestinf();//设定时间
        List<Battinf> list = null;
//        List<Battinf> list = battInfMapper.serchByTestType(bmd);
        List<AllModel> listAll = new ArrayList<AllModel>();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Battinf binf = list.get(i);
                tdata.setBattGroupId(binf.getBattGroupId());
                tdata.setGroupVol(binf.getMonVolStd());//标存电压
                tdata.setTestCap(binf.getMonCapStd());//标存容量
                tdata.setTestRecordCount(binf.getNum());//次数
                //该电池组的放电结果
                List list1 = null;//该电池组的放电结果
//                List list1 = batttestdataInfMapper.serchDischargeTest(tdata);//该电池组的放电结果
                ServiceModel model = new ServiceModel();
                if (list1 != null && list1.size() > 0) {
                    model.setCode(1);
                    model.setData(list1);//1.2电池组统计分析查询
                    model.setMsg("查询成功!");
                } else {
                    model.setCode(0);
                    model.setMsg("查询失败!");
                }
                AllModel allmodel = new AllModel();
                allmodel.setData(list.get(i));
                allmodel.setTmodel(model);
                listAll.add(allmodel);
            }
        }
        return new Response<List<AllModel>>().set(1,listAll);
//        return null;
    }
 
    /**
     * 电池组性能评估
     *
     * @param bmd
     * @return
     */
//TODO rzg battInfMapper
 
//    SELECT SQL_CALC_FOUND_ROWS DISTINCT
//            (
//                    db_battinf.tb_battinf.BattgroupId
//                    ),
//    db_battinf.tb_battinf.stationid,
//    StationName1,
//    StationName,
//    stationip,
//    BattGroupName,
//    BattGroupName1,
//    moncount,
//    moncapstd,
//    monvolstd,
//    battproducer,
//    battproductdate,
//    battinusedate
//            FROM
//    db_battinf.tb_battinf
//    WHERE 1=1
//
//    <if test="battGroupId==0">
//    and db_battinf.tb_battinf.battgroupid!=#{battGroupId}
//    </if>
//
//    <if test="battGroupId!=0">
//    and db_battinf.tb_battinf.battgroupid==#{battGroupId}
//    </if>
//
//    AND db_battinf.tb_battinf.BattgroupId IN (
//            SELECT DISTINCT
//        db_battinf.tb_battinf.battgroupid
//                FROM
//                db_battinf.tb_battinf,
//            db_user.tb_user_battgroup_baojigroup_battgroup,
//            db_user.tb_user_battgroup_baojigroup_usr,
//            db_user.tb_user_inf
//                    WHERE
//        db_user.tb_user_battgroup_baojigroup_battgroup.BattGroupId = db_battinf.tb_battinf.BattGroupId
//                    AND db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id = db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id
//                    AND db_user.tb_user_inf.uid = db_user.tb_user_battgroup_baojigroup_usr.uid
//                    AND db_user.tb_user_inf.uid =?
//                    AND db_battinf.tb_battinf.stationname1 LIKE ?
//                    AND db_battinf.tb_battinf.stationname LIKE ?
//    )
//
//    order by db_battinf.tb_battinf.battgroupid asc
//
 
 
    //TODO RZG
    public Response<List<AllModel>> searchByCondition(Batt_Maint_Dealarm bmd) {
 
        BatttestdataInf tdata = bmd.getBtestinf();//设定时间
        List<Battinf> list = null;
//        List<Battinf> list = battInfMapper.serchGroupAssess(bmd);
        List<AllModel> listAll = new ArrayList<AllModel>();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Battinf binf = list.get(i);
                tdata.setBattGroupId(binf.getBattGroupId());
                tdata.setGroupVol(binf.getMonVolStd());//标存电压
                tdata.setTestCap(binf.getMonCapStd());//标存容量
                //该电池组的放电结果
                List list1 = null;//该电池组的放电结果
//                List list1 = batttestdataInfMapper.serchDischargeTest(tdata);//该电池组的放电结果
                ServiceModel model = new ServiceModel();
                if (list1 != null && list1.size() > 0) {
                    model.setCode(1);
                    model.setData(list1);
                    model.setMsg("查询成功!");
                } else {
                    model.setCode(0);
                    model.setMsg("查询失败!");
                }
                AllModel allmodel = new AllModel();
                allmodel.setData(list.get(i));
                allmodel.setTmodel(model);
                listAll.add(allmodel);
            }
        }
        return new Response<List<AllModel>>().set(1, listAll);
    }
 
 
 
//    SELECT
//            battgroupid,
//            test_curr,
//            max_monvol,
//            min_monvol,
//            test_cap
//    FROM
//    db_batt_testdata.tb_batttestdata_inf
//            WHERE
//    battgroupid =?
//    AND record_time >=?
//    AND record_time <=?
//    AND db_batt_testdata.tb_batttestdata_inf.data_available = 1
//
////充电放电选择 全部 test_type=0不加条件
////用于放电类型
////全部
//    <if test="test_type==3&&test_starttype=0">
//    and test_type=3
//            </if>
//    <if test="test_type==3&&test_starttype=1">
//    and (test_starttype<5 and test_type not in(2,9) and  test_starttype!=2 AND test_starttype!=3)
//    </if>
//    <if test="test_type==3&&test_starttype=2">
//    and (test_starttype=2 and test_type not in(2) )
//    </if>
//    <if test="test_type==3&&test_starttype=3">
//    and (test_starttype=3 and test_type not in(2) )
//    </if>
//
//    order by test_starttime desc
 
}