From ff1ed10ebcb27f4039fb121486261c0b24208baf Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期一, 22 七月 2024 10:43:25 +0800 Subject: [PATCH] 蓄电池单体容量 --- src/main/java/com/whyc/service/SubTableService.java | 36 ++++++++++++++++++ src/main/resources/mapper/BattTestInfMapper.xml | 23 +++++++++-- src/main/java/com/whyc/service/BattTestInfService.java | 37 ++++++++++++++++-- src/main/java/com/whyc/mapper/BattTestInfMapper.java | 4 ++ src/main/java/com/whyc/controller/BattTestInfController.java | 15 +++++-- 5 files changed, 102 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/whyc/controller/BattTestInfController.java b/src/main/java/com/whyc/controller/BattTestInfController.java index 38b389b..36426d6 100644 --- a/src/main/java/com/whyc/controller/BattTestInfController.java +++ b/src/main/java/com/whyc/controller/BattTestInfController.java @@ -34,13 +34,18 @@ return res; } - /** - * 钃勭數姹犵粍鍚庤瘎浼� - */ + @PostMapping("searchGroupAssess") - @ApiOperation(notes = "searchByCondition ", value = "钃勭數姹犵粍鍚庤瘎浼�") + @ApiOperation(value = "钃勭數姹犵粍鍚庤瘎浼�") public Response searchByCondition(@RequestParam int pageNum,@RequestParam int pageSize, @RequestBody ReportBattDTO tinf) { - //UserInf userInf = ActionUtil.getUser(); return service.searchGroupAssess(pageNum,pageSize,tinf,1001); } + + + @PostMapping("searchMonNumAssess") + @ApiOperation(value = "鐢垫睜鍗曚綋鎬ц兘璇勪及") + public Response searchMonNumAssess(@RequestParam int binfId,@RequestParam int monNum){ + return service.searchMonNumAssess(binfId,monNum); + } + } \ No newline at end of file diff --git a/src/main/java/com/whyc/mapper/BattTestInfMapper.java b/src/main/java/com/whyc/mapper/BattTestInfMapper.java index 1773405..66d717f 100644 --- a/src/main/java/com/whyc/mapper/BattTestInfMapper.java +++ b/src/main/java/com/whyc/mapper/BattTestInfMapper.java @@ -12,4 +12,8 @@ //鏌ュ線骞寸殑鏀剧數璁板綍 List<BattTestInf> searchDischargeTest_WJ(Integer battGroupId, Date recordStartTime); + + + //鑾峰彇鏈夋晥鐨勬斁鐢佃褰� + List<BattTestInf> searchDischarge(int battGroupId); } \ No newline at end of file diff --git a/src/main/java/com/whyc/service/BattTestInfService.java b/src/main/java/com/whyc/service/BattTestInfService.java index 290849e..05e0c31 100644 --- a/src/main/java/com/whyc/service/BattTestInfService.java +++ b/src/main/java/com/whyc/service/BattTestInfService.java @@ -11,13 +11,12 @@ import com.whyc.mapper.BattAlarmMapper; import com.whyc.mapper.BattInfMapper; import com.whyc.mapper.BattTestInfMapper; -import com.whyc.pojo.AlarmParam; -import com.whyc.pojo.BattAlarm; -import com.whyc.pojo.BattInf; -import com.whyc.pojo.BattTestInf; +import com.whyc.pojo.*; +import com.whyc.util.ActionUtil; import com.whyc.util.PageInfoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestParam; import java.util.*; @@ -34,6 +33,10 @@ @Autowired(required = false) private BattAlarmMapper alarmMapper; + + @Autowired(required = false) + private SubTableService subTableService; + //鏌ヨ鍏呮斁鐢佃褰� public Response getTinfHis(int binfId, int pageNum, int pageSize) { @@ -278,5 +281,31 @@ return map; } + //鐢垫睜鍗曚綋鎬ц兘璇勪及 + public Response searchMonNumAssess( int binfId, int monNum) { + //鑾峰彇鎸囧畾鐢垫睜缁勪俊鎭� + QueryWrapper wrapper=Wrappers.query(); + wrapper.eq("binf_id",binfId); + wrapper.last("limit 1"); + BattInf binf=binfMapper.selectOne(wrapper); + Map<String, Object> map = new HashMap<>(); + //鑾峰彇鏈夋晥鐨勬斁鐢佃褰� + List<BattTestInf> list=mapper.searchDischarge(binfId); + float cap = 0f;//瀹為檯瀹归噺 + //鍙栨渶杩戜竴绗旀暟鎹� + BattTestInf tinf=list.stream().findFirst().orElse((BattTestInf) ActionUtil.objeNull); + if(tinf!=null){ + int hourRate = BattCapFactory.GetHourRate(binf.getMonCap(), tinf.getTestCurr()); + //鍙栬鍗曚綋鏈�鍚庝竴绗旀斁鐢佃褰� + BattTestInfData tData=subTableService.getMonNumData(binfId,tinf.getTestRecordCount(),tinf.getRecordNum(),monNum); + if(tData!=null){ + cap = (float) BattCapFactory.GetMonomerCap(binf.getMonCap(), hourRate, tinf.getTestCap(), tinf.getMaxMonvol(), tData.getMonVol(), binf.getMonVol(), BattCapFactory.CapType_Real); + + } + } + map.put("cap",cap); + //璇勪及鍗曚綋 + return new Response().set(1, map, "鏌ヨ鎴愬姛"); + } } \ No newline at end of file diff --git a/src/main/java/com/whyc/service/SubTableService.java b/src/main/java/com/whyc/service/SubTableService.java index 6f2d1e2..89eecbe 100644 --- a/src/main/java/com/whyc/service/SubTableService.java +++ b/src/main/java/com/whyc/service/SubTableService.java @@ -3,6 +3,7 @@ import com.whyc.mapper.CallBack; import com.whyc.pojo.BattAlarmHis; import com.whyc.pojo.BattTestInfData; +import com.whyc.util.ActionUtil; import com.whyc.util.ThreadLocalUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -112,4 +113,39 @@ }); return list; } + //鍙栬鍗曚綋鏈�鍚庝竴绗旀斁鐢佃褰� + public BattTestInfData getMonNumData(int binfId, Integer testRecordCount, Integer recordNum, int monNum) { + String sql="select * from db_dis_batt.batt_test_inf_"+binfId+" " + + " where binf_id="+binfId+" " + + " and test_record_count="+testRecordCount+ + " and record_num="+recordNum+ + " and mon_num="+monNum; + List<BattTestInfData> list=sqlExecuteService.executeQuery_call(sql, new CallBack() { + @Override + public List getResults(ResultSet rs) throws SQLException { + List list=new ArrayList(); + while (rs.next()){ + BattTestInfData data=new BattTestInfData(); + data.setNum(rs.getInt("num")); + data.setBinfId(rs.getInt("binf_id")); + data.setTestRecordCount(rs.getInt("test_record_count")); + data.setTestStarttime(rs.getTimestamp("test_starttime")); + data.setRecordTime(rs.getTimestamp("record_time")); + data.setTestType(rs.getInt("test_type")); + data.setRecordNum(rs.getInt("record_num")); + data.setTestTimelong(rs.getInt("test_timelong")); + 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.setMonTmp(rs.getFloat("mon_tmp")); + list.add(data); + } + return list; + } + }); + return list.stream().findFirst().orElse((BattTestInfData) ActionUtil.objeNull); + } } \ No newline at end of file diff --git a/src/main/resources/mapper/BattTestInfMapper.xml b/src/main/resources/mapper/BattTestInfMapper.xml index ab24377..c3faf9b 100644 --- a/src/main/resources/mapper/BattTestInfMapper.xml +++ b/src/main/resources/mapper/BattTestInfMapper.xml @@ -5,7 +5,7 @@ <select id="searchDischargeTest" resultType="com.whyc.pojo.BattTestInf"> select battgroupid,test_curr,max_monvol,min_monvol,test_cap,test_starttime,record_time,test_timelong,test_stoptype - from db_batt_testdata.tb_batttestdata_inf + from db_dis_batt.batt_test_inf <where> db_batt_testdata.tb_batttestdata_inf.data_available=1 and test_starttype=3 and test_type=3 @@ -18,12 +18,12 @@ and record_time>=#{recordStartTime} and record_time<=#{recordEndTime} </if> </where> - ORDER BY tb_batttestdata_inf.BattGroupId asc, test_starttime desc + ORDER BY db_dis_batt.batt_test_inf.BattGroupId asc, test_starttime desc </select> <select id="searchDischargeTest_WJ" resultType="com.whyc.pojo.BattTestInf"> select battgroupid,test_curr,max_monvol,min_monvol,test_cap,test_starttime,record_time,test_timelong,test_stoptype - from db_batt_testdata.tb_batttestdata_inf + from db_dis_batt.batt_test_inf <where> db_batt_testdata.tb_batttestdata_inf.data_available=1 and test_starttype=3 and test_type=3 @@ -36,6 +36,21 @@ and record_time<#{recordStartTime} </if> </where> - ORDER BY tb_batttestdata_inf.BattGroupId asc, test_starttime desc + ORDER BY db_dis_batt.batt_test_inf.BattGroupId asc, test_starttime desc + </select> + <select id="searchDischarge" resultType="com.whyc.pojo.BattTestInf"> + select + battgroupid,test_curr,max_monvol,min_monvol,test_cap,test_starttime,record_time,test_timelong,test_stoptype + from db_dis_batt.batt_test_inf + <where> + db_batt_testdata.tb_batttestdata_inf.data_available=1 + and test_starttype=3 and test_type=3 + and (test_stoptype in (3, 4, 6) + or (test_stoptype=2 and test_timelong>=7200)) + <if test="battGroupId!=null"> + and battgroupid=#{battGroupId} + </if> + </where> + ORDER BY db_dis_batt.batt_test_inf.BattGroupId asc, test_starttime desc </select> </mapper> \ No newline at end of file -- Gitblit v1.9.1