whyclxw
1 天以前 add5c816a5281cf6b1df4a0988e8b3a0c2b59bee
src/main/java/com/whyc/service/BattInfService.java
@@ -4,16 +4,19 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.constant.BattCapperformanceEnum;
import com.whyc.dto.BattDto;
import com.whyc.dto.InfoDto;
import com.whyc.dto.Param.ParamAlmDto;
import com.whyc.dto.Real.QuarterDto;
import com.whyc.dto.Response;
import com.whyc.dto.SocreHehaviorDto;
import com.whyc.dto.Statistic.*;
import com.whyc.factory.InfoFactory;
import com.whyc.mapper.BattInfMapper;
import com.whyc.mapper.PowerInfMapper;
import com.whyc.mapper.StationInfMapper;
import com.whyc.pojo.db_station.BattInf;
import com.whyc.pojo.db_station.PowerInf;
import com.whyc.pojo.db_station.StationInf;
import com.whyc.pojo.db_station.*;
import com.whyc.pojo.db_user.User;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +26,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class BattInfService {
@@ -37,6 +41,9 @@
    @Autowired(required = false)
    private BaojigroupService bjService;
    @Autowired(required = false)
    private InfoChangeService changeService;
    /*新建电池组(新的设备新的电池组)
     * @param binf
@@ -76,7 +83,7 @@
    //设备下添加电池组
    @Transactional
    public void addBatt(BattInf  addbinf) {
        if(addbinf.getAddBinfFlag()==1){
        if(addbinf.getAddBinfFlag()==0){
            //获取设备的通用信息
            QueryWrapper wrapper=new QueryWrapper();
            wrapper.eq("dev_id",addbinf.getDevId());
@@ -198,6 +205,9 @@
        if(sinf.getLatitude()!=null){
            wrapper1.set("latitude",sinf.getLatitude());
        }
        if(sinf.getNodeStation()!=null){
            wrapper1.set("node_station",sinf.getNodeStation());
        }
        wrapper1.eq("station_id",sinf.getStationId());
        //再修改电源信息
@@ -217,7 +227,22 @@
        if(pinf.getPowerType()!=null){
            wrapper2.set("power_type",pinf.getPowerType());
        }
        if(pinf.getPowerName()!=null){
        if(pinf.getPowerInuseTime()!=null){
            wrapper2.set("power_inuse_time",pinf.getPowerInuseTime());
        }
        if(pinf.getModelCfg()!=null){
            wrapper2.set("model_cfg",pinf.getModelCfg());
        }
        if(pinf.getAcvolHighLimit()!=null){
            wrapper2.set("acvol_high_limit",pinf.getAcvolHighLimit());
        }
        if(pinf.getAcvolLowLimit()!=null){
            wrapper2.set("acvol_low_limit",pinf.getAcvolLowLimit());
        }
        if(pinf.getDcoutvolLowLimit()!=null){
            wrapper2.set("dcoutvol_low_limit",pinf.getDcoutvolLowLimit());
        }
        /*if(pinf.getPowerName()!=null){
            //检测该机房下要修改的电源名是否存在
            QueryWrapper queryWrapper1=new QueryWrapper();
            queryWrapper1.eq("power_name",pinf.getPowerName());
@@ -228,7 +253,7 @@
                return new Response().set(1,false,"该机房下已存在"+pinf.getPowerName()+"的电源");
            }
            wrapper2.set("power_name",pinf.getPowerName());
        }
        }*/
        wrapper2.eq("power_id",pinf.getPowerId());
        //最后修改设备信息
@@ -238,7 +263,7 @@
            if (binf.getDevIp() != null) {
                wrapper3.set("dev_ip", binf.getDevIp());
            }
            if (binf.getDevName() != null) {
           /* if (binf.getDevName() != null) {
                //检测该电源下修改的设备名是否存在
                QueryWrapper queryWrapper2 = new QueryWrapper();
                queryWrapper2.eq("dev_name", binf.getDevName());
@@ -249,7 +274,7 @@
                    return new Response().set(1, false, "该电源下已存在" + binf.getDevName() + "的设备");
                }
                wrapper3.set("dev_name", binf.getDevName());
            }
            }*/
            /*if(binf.getDevType()!=null){
                wrapper3.set("dev_type",binf.getDevType());
            }*/
@@ -257,7 +282,7 @@
            //修改电池组信息
            UpdateWrapper wrapper4 = new UpdateWrapper();
            if (binf.getBattgroupName() != null) {
            /*if (binf.getBattgroupName() != null) {
                //检测该机房下要修改的电源名是否粗在
                QueryWrapper queryWrapper3 = new QueryWrapper();
                queryWrapper3.eq("battgroup_name", binf.getBattgroupName());
@@ -268,7 +293,7 @@
                    return new Response().set(1, false, "该设备下已存在" + binf.getBattgroupName() + "的电池组");
                }
                wrapper4.set("battgroup_name", binf.getBattgroupName());
            }
            }*/
            if (binf.getMonvolstd() != null) {
                wrapper4.set("monvolstd", binf.getMonvolstd());
            }
@@ -287,12 +312,44 @@
            if (binf.getBattModel() != null) {
                wrapper4.set("batt_model", binf.getBattModel());
            }
            if (binf.getInuseTime() != null) {
                wrapper4.set("inuse_time", binf.getInuseTime());
            }
            if (binf.getFloatVolLevel() != null) {
                wrapper4.set("float_vol_level", binf.getFloatVolLevel());
            }
            if (binf.getOfflinelineVolLevel() != null) {
                wrapper4.set("offlineline_vol_level", binf.getOfflinelineVolLevel());
            }
            if (binf.getFloatCurrLevel() != null) {
                wrapper4.set("float_curr_level", binf.getFloatCurrLevel());
            }
            if (binf.getMaxDisCurr() != null) {
                wrapper4.set("max_dis_curr", binf.getMaxDisCurr());
            }
            if (binf.getSignType()!= null) {
                wrapper4.set("sign_type", binf.getSignType());
            }
            if (binf.getCommPort()!= null) {
                wrapper4.set("comm_port", binf.getCommPort());
            }
            if (binf.getLoadCurr()!= null) {
                wrapper4.set("load_curr", binf.getLoadCurr());
            }
            if (binf.getVideoUrl()!= null) {
                wrapper4.set("video_url", binf.getVideoUrl());
            }
            wrapper4.eq("battgroup_id", binf.getBattgroupId());
            mapper.update((BattInf) ActionUtil.objeNull,wrapper3);
            mapper.update((BattInf) ActionUtil.objeNull,wrapper4);
        }
        sinfMapper.update((StationInf) ActionUtil.objeNull,wrapper1);
        pinfMapper.update((PowerInf) ActionUtil.objeNull,wrapper2);
        //存入变更信息记录
        pinf.setStationId(sinf.getStationId());
        binf.setStationId(sinf.getStationId());
        binf.setPowerId(pinf.getPowerId());
        changeService.addInfoChange(sinf,pinf,binf,info.getUpdateReason());
        return new Response().set(1,true,"修改信息成功");
    }
    /*//修改电池组
@@ -378,4 +435,117 @@
        return new Response().setII(1,list.size()>0,list,"获取设备型号(下拉)");
    }
    //根据电池组id获取电池组信息
    public BattInf getBinfByBattgroupId(Integer battgroupId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("battgroup_id",battgroupId);
        wrapper.last("limit 1");
        BattInf binf=mapper.selectOne(wrapper);
        List<BattInfChange> binfChangeList=changeService.getBinfChange(battgroupId);
        binf.setBinfChangeList(binfChangeList);
        return binf;
    }
   //当没有内助测试时初始内阻值为标称内阻
    public List<QuarterDto> getBinfResStd(Integer battgroupId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("battgroup_id",battgroupId);
        wrapper.last("limit 1");
        BattInf binf=mapper.selectOne(wrapper);
        Float monresstd=binf.getMonresstd();
        List<QuarterDto> list=new ArrayList<>();
        for(int i=0;i<binf.getMoncount();i++){
            QuarterDto dto=new QuarterDto();
            dto.setRecordTime(binf.getCreateTime());
            dto.setMonNum(i+1);
            dto.setNumValue(monresstd);
        }
        return list;
    }
    //设备信息统计
    public Response getDevStatistic(StationStic stic) {
        PageHelper.startPage(stic.getPageNum(),stic.getPageSize());
        List<BattInf> list=mapper.getDevStatistic(stic);
        for (BattInf binf:list) {
            //获取设备下电池组个数
            int battCount=mapper.getBattCountBydevId(binf.getDevId());
            binf.setBattCount(battCount);
        }
        PageInfo<BattInf> pageInfo=new PageInfo<>(list);
        return new Response().setII(1,list.size()>0,pageInfo,"设备信息统计");
    }
    //蓄电池组信息统计
    public Response getBattStatistic(StationStic stic) {
        PageHelper.startPage(stic.getPageNum(),stic.getPageSize());
        List<BattInf> list=mapper.getBattStatistic(stic);
        PageInfo<BattInf> pageInfo=new PageInfo<>(list);
        return new Response().setII(1,list.size()>0,pageInfo,"蓄电池组信息统计");
    }
    //单体统计查询符合条件的电池组
    public List<BattInf> getMonStatistic(MonStic stic) {
        return mapper.getMonStatistic(stic);
    }
    //蓄电池组对比分析界面15
    public List<BattInf> getBattCompare15Statistic(BattCompareStic stic) {
        return mapper.getBattCompare15Statistic(stic);
    }
    //获取容量性能(下拉)
    public Response getCapperformance() {
        Map<Integer,String> map= BattCapperformanceEnum.getOpInfo();
        return new Response().setII(1,true,map,"获取容量性能(下拉)");
    }
    //蓄电池组对比分析界面16
    public List<BattInf> getBattCompare16Statistic(BattCompareStic stic) {
        return mapper.getBattCompare16Statistic(stic);
    }
    //蓄电池组对比分析界面17
    public List<BattInf> getBattCompare17Statistic(BattCompareStic stic) {
        return mapper.getBattCompare17Statistic(stic);
    }
    //本年度已放电数量统计(1.2.5)
    public List<BattInf> getDischr5Statistic(DisChargeStic stic) {
        return mapper.getDischr5Statistic(stic);
    }
    //本年度已放电数量统计(1.2.6)
    public List<BattInf> getDischr6Statistic(DisChargeStic stic) {
        return mapper.getDischr6Statistic(stic);
    }
    //电池组电池性能统计(未放电,优秀,劣化,损坏)统计(1.2.8/9/10)
    public List<BattInf> getPerformanceStatistic(PerformanceStic stic) {
        return mapper.getPerformanceStatistic(stic);
    }
    //本年度已/未放电数量统计右侧图表(1.2.5)
    public List<BattInf> getDischrChart(Integer uid) {
        return mapper.getDischrChart(uid);
    }
    public List<BattInf> getListByUserId(Integer userId) {
        return mapper.getListByUserId(userId);
    }
    public List<BattInf> getListByCondition(Integer userId, BattInf battInf) {
        return mapper.getListByCondition(userId, battInf);
    }
    //获取站点下的电池组(下拉)
    public Response getBattByUid(Integer uid, String provice, String city, String country, String stationName) {
        List<BattInf> list=mapper.getBattByUid(uid,provice,city,country,stationName);
        return new Response().setII(1,list.size()>0,list,"获取站点下的电池组(下拉)");
    }
    //根据查询条件获取电池组
    public  BattInf getBattgroupIdInf(Integer battgroupId) {
        return mapper.getBattgroupIdInf(battgroupId);
    }
    //查询电源下所有的电池组id
    public List<BattInf> getBattgroupIdListByPowerId(Integer powerId) {
        return mapper.getBattgroupIdListByPowerId(powerId);
    }
    //查询设备下所有的电池组id
    public List<BattInf> getBattgroupIdListByDevId(Integer devId) {
        return mapper.getBattgroupIdListByDevId(devId);
    }
    //询符合条件的电池组权重表格评分
    public List<BattInf> getScoreByHehavior(SocreHehaviorDto dto) {
        return mapper.getScoreByHehavior(dto);
    }
}