src/main/java/com/whyc/controller/AlmParamController.java
New file @@ -0,0 +1,34 @@ package com.whyc.controller; import com.whyc.dto.Real.AlmDto; import com.whyc.dto.Response; import com.whyc.service.BattAlmparamService; import com.whyc.service.DevAlmparamService; import com.whyc.util.ActionUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "告警管理") @RequestMapping("almParam") public class AlmParamController { @Autowired private BattAlmparamService battAlmparamService; @Autowired private DevAlmparamService devAlmparamService; @PostMapping("getBattAlmParam") @ApiOperation("获取电池告警参数") public Response getBattAlmParam(@RequestBody AlmDto almDto){ almDto.setUid(ActionUtil.getUser().getId()); return battAlmparamService.getBattAlmParam(almDto); } } src/main/java/com/whyc/controller/StatisticController.java
@@ -3,6 +3,7 @@ import com.whyc.dto.Response; import com.whyc.dto.Statistic.BattTinfStic; import com.whyc.dto.Statistic.DeviceStateStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.pojo.db_user.User; import com.whyc.service.*; @@ -57,6 +58,13 @@ return battService.getBattStatistic(stic); } @ApiOperation(value = "单节数量统计") @PostMapping("getMonStatistic") public Response getMonStatistic(@RequestBody MonStic stic){ User uinf= ActionUtil.getUser(); stic.setUid(uinf.getId()); return battTinfService.getMonStatistic(stic); } @ApiOperation(value = "站点信息统计") src/main/java/com/whyc/dto/Statistic/MonStic.java
New file @@ -0,0 +1,18 @@ package com.whyc.dto.Statistic; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.Date; @Data public class MonStic { private String product; @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private Date startTime; @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") private Date endTime; private Float moncapstd; private Float monvolstd; private Integer uid; } src/main/java/com/whyc/mapper/BattAlmparamMapper.java
New file @@ -0,0 +1,6 @@ package com.whyc.mapper; import com.whyc.pojo.db_param.BattAlmparam; public interface BattAlmparamMapper extends CustomMapper<BattAlmparam>{ } src/main/java/com/whyc/mapper/BattInfMapper.java
@@ -2,6 +2,7 @@ import com.whyc.dto.BattDto; import com.whyc.dto.InfoDto; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.pojo.db_station.BattInf; import org.apache.ibatis.annotations.Param; @@ -37,4 +38,6 @@ Integer getBattCountBydevId(Integer devId); //蓄电池组信息统计 List<BattInf> getBattStatistic(@Param("stic") StationStic stic); //单体统计查询符合条件的电池组 List<BattInf> getMonStatistic(@Param("stic") MonStic stic); } src/main/java/com/whyc/mapper/DevAlmparamMapper.java
New file @@ -0,0 +1,6 @@ package com.whyc.mapper; import com.whyc.pojo.db_param.DevAlmparam; public interface DevAlmparamMapper extends CustomMapper<DevAlmparam>{ } src/main/java/com/whyc/service/BattAlmparamService.java
New file @@ -0,0 +1,17 @@ package com.whyc.service; import com.whyc.dto.Real.AlmDto; import com.whyc.dto.Response; import com.whyc.mapper.BattAlmparamMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class BattAlmparamService { @Autowired(required = false) private BattAlmparamMapper mapper; //获取电池告警参数 public Response getBattAlmParam(AlmDto almDto) { return null; } } src/main/java/com/whyc/service/BattInfService.java
@@ -8,6 +8,7 @@ import com.whyc.dto.InfoDto; import com.whyc.dto.Real.QuarterDto; import com.whyc.dto.Response; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.factory.InfoFactory; import com.whyc.mapper.BattInfMapper; @@ -424,4 +425,8 @@ 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); } } src/main/java/com/whyc/service/BatttestdataIdService.java
@@ -1,7 +1,19 @@ package com.whyc.service; import com.whyc.pojo.db_batt_testdata.BatttestdataId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class BatttestdataIdService { @Autowired private SubTablePageInfoService subTablePageInfoService; //找这次放电的最后一笔数据 public List<BatttestdataId> getLastDataByBattgroupId(Integer battgroupId, Integer testRecordCount, Integer recordNum) { List<BatttestdataId> list=subTablePageInfoService.getLastDataByBattgroupId(battgroupId, testRecordCount, recordNum); return list; } } src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -5,10 +5,12 @@ import com.github.pagehelper.PageInfo; import com.whyc.dto.Response; import com.whyc.dto.Statistic.BattTinfStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.StationStic; import com.whyc.factory.BattCapFactory; import com.whyc.mapper.BattInfMapper; import com.whyc.mapper.BatttestdataInfMapper; import com.whyc.pojo.db_batt_testdata.BatttestdataId; import com.whyc.pojo.db_batt_testdata.BatttestdataInf; import com.whyc.pojo.db_ram_db.BattRtstate; import com.whyc.pojo.db_station.BattInf; @@ -27,6 +29,10 @@ @Autowired(required = false) private BattInfService battInfService; @Autowired(required = false) private BatttestdataIdService battTestdataIdService; //获取最后一次测试数据并计算剩余容量 @@ -56,6 +62,7 @@ Float restCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Rest); Float realCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); tinf.setRestCap(restCap); tinf.setRealCap(realCap); tinf.setRestTime(0f); //获取电池组实时数据 BattRtstate battRtstate=rtstateService.getBattRealInfo(tinf.getBattgroupId()); @@ -87,4 +94,27 @@ BatttestdataInf tinf = mapper.selectOne(wrapper); return tinf; } /*单节数量统计 1筛选满足条件的电池组,找最近一次标准核容放电记录的最后一笔数据 2再按照公式计算单体实际容量, 3然后找到判断优秀,劣化,损坏的参数,得到结果。 4浮充电压图,需要显示单体+实时数据的单体电压,单体内阻 */ public Response getMonStatistic(MonStic stic) { List<BattInf> binfList=battInfService.getMonStatistic(stic); if(binfList!=null&&binfList.size()>0){ for (BattInf binf:binfList) { BatttestdataInf tinf =getLastStandardTestData(binf.getBattgroupId()); if(tinf!=null){ //找这次放电的最后一笔数据 List<BatttestdataId> idDataList=battTestdataIdService.getLastDataByBattgroupId(tinf.getBattgroupId(),tinf.getTestRecordCount(),tinf.getRecordNum()); for (BatttestdataId data:idDataList) { int hourRate = BattCapFactory.GetHourRate(tinf.getTestCap(), tinf.getTestCurr()); Float realCap = (float) BattCapFactory.GetMonomerCap(tinf.getTestCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tinf.getMinMonvol(), tinf.getGroupVol(), BattCapFactory.CapType_Real); } } } } return new Response().set(1,false,""); } } src/main/java/com/whyc/service/DevAlmparamService.java
New file @@ -0,0 +1,11 @@ package com.whyc.service; import com.whyc.mapper.DevAlmparamMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class DevAlmparamService { @Autowired(required = false) private DevAlmparamMapper mapper; } src/main/java/com/whyc/service/SubTablePageInfoService.java
@@ -8,6 +8,7 @@ import com.whyc.mapper.CallBack; import com.whyc.pojo.db_alarm.BattalarmDataHistory; import com.whyc.pojo.db_alarm.DevalarmDataHistory; import com.whyc.pojo.db_batt_testdata.BatttestdataId; import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarmHistory; import com.whyc.util.ThreadLocalUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -528,4 +529,32 @@ }); return list; } //找这次放电的最后一笔数据 public List<BatttestdataId> getLastDataByBattgroupId(Integer battgroupId, Integer testRecordCount, Integer recordNum) { String sql="select distinct * from db_batt_testdata.tb_batttestdata_"+battgroupId +" where test_record_count="+testRecordCount+" and record_num="+recordNum+ " order by mon_num asc"; List<BatttestdataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { @Override public List getResults(ResultSet rs) throws SQLException { List<BatttestdataId> list=new ArrayList<>(); while (rs.next()){ BatttestdataId data=new BatttestdataId(); data.setBattgroupId(rs.getInt("battgroup_id")); data.setTestRecordCount(rs.getInt("test_record_count")); data.setTestStarttime(rs.getTimestamp("test_starttime")); data.setOnlineVol(rs.getFloat("online_vol")); data.setGroupVol(rs.getFloat("group_vol")); data.setTestCurr(rs.getFloat("test_curr")); data.setTestCap(rs.getFloat("test_cap")); data.setMonNum(rs.getInt("mon_num")); data.setMonVol(rs.getFloat("mon_vol")); data.setMonRes(rs.getFloat("mon_res")); data.setMonTmp(rs.getFloat("mon_tmp")); list.add(data); } return list; } }); return list; } } src/main/resources/mapper/BattInfMapper.xml
@@ -173,5 +173,32 @@ order by tb_batt_inf.dev_id asc,battgroup_id asc </where> </select> <select id="getMonStatistic" resultType="com.whyc.pojo.db_station.BattInf"> select distinct tb_batt_inf.* from db_station.tb_batt_inf <where> <if test="stic.product!=null"> and tb_batt_inf.product=#{stic.product} </if> <if test="stic.moncapstd!=null"> and tb_batt_inf.moncapstd=#{stic.moncapstd} </if> <if test="stic.monvolstd!=null"> and tb_batt_inf.monvolstd=#{stic.monvolstd} </if> <if test="stic.startTime!=null"> and tb_batt_inf.create_time>=#{stic.startTime} </if> <if test="stic.endTime!=null"> and tb_batt_inf.create_time<=#{stic.endTime} </if> <if test="stic.uid>100"> and tb_batt_inf.station_id in( select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr where tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id and tb_baojigroup_usr.uid=#{stic.uid} ) </if> </where> </select> </mapper>