whycxzp
2023-12-18 6b7be925cc1a5209d302bb1173386207b0e2c853
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
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.CKPowerDevRtSetLogMapper;
import com.whyc.pojo.db_ckpwrdev_data_rt.CKPowerDevRtSetLog;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class CKPowerDevRtSetLogService {
 
    @Resource
    private CKPowerDevRtSetLogMapper mapper;
 
 
    public void add(CKPowerDevRtSetLog log) {
        mapper.insert(log);
    }
 
    public void addBatch(List<CKPowerDevRtSetLog> log){
        mapper.insertBatchSomeColumn(log);
    }
 
    public Response getCounts(List<String> countFields) {
        for (String countField : countFields) {
            QueryWrapper<CKPowerDevRtSetLog> query = Wrappers.query();
            query.select(countField).isNotNull(countField);
            List<CKPowerDevRtSetLog> logs = mapper.selectList(query);
            long count = logs.stream().filter(temp -> temp.getAcIn1VolASt() ==0).count();
            long count2 = logs.stream().filter(temp -> temp.getAcIn1VolASt() ==1).count();
 
            return new Response().setII(1,count,count2,null);
        }
        return null;
 
    }
}