| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.whyc.dto.DalmDto; |
| | | import com.whyc.mapper.CallBack; |
| | | import com.whyc.pojo.db_alarm.DevalarmData; |
| | | import com.whyc.pojo.db_alarm.DevalarmDataYear; |
| | | import com.whyc.pojo.db_batt_testdata.BatttestdataId; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | public List<BatttestdataId> getTdataById(Integer devId, Integer testRecordCount) { |
| | | String sql="select * from db_batt_testdata.tb_batttestdata_" +devId |
| | | +" where need_test=1 and test_record_count="+testRecordCount+" "; |
| | | sql+=" ORDER BY test_starttime asc "; |
| | | System.out.println(sql); |
| | | sql+=" ORDER BY record_num asc "; |
| | | List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | |
| | | tdata.setMonCurr(rs.getDouble("mon_curr")); |
| | | tdata.setMonCap(rs.getDouble("mon_cap")); |
| | | tdata.setMonWh(rs.getDouble("mon_wh")); |
| | | tdata.setMonState(rs.getInt("mon_state")); |
| | | tdata.setMonState(rs.getString("mon_state")); |
| | | tdata.setMonFault(rs.getString("mon_fault")); |
| | | tdata.setNeedTest(rs.getInt("need_test")); |
| | | list.add(tdata); |
| | |
| | | return list; |
| | | } |
| | | |
| | | |
| | | //获取设备某次记录详细的单体放电过程 |
| | | public List<BatttestdataId> getTdataByIdWithListA200(Integer devId, Integer testRecordCount) { |
| | | String sql="select * from db_batt_testdata.tb_batttestdata_" +devId |
| | | +" where need_test=1 and test_record_count="+testRecordCount+" "; |
| | | sql+=" ORDER BY record_num asc "; |
| | | List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List list=new ArrayList<>(); |
| | | List<Float> monVols=null; |
| | | List<Integer> monNums=null; |
| | | BatttestdataId tdata=null; |
| | | int num=0; |
| | | try { |
| | | while (rs.next()){ |
| | | int monNum=rs.getInt("mon_num"); |
| | | float monvol=rs.getFloat("mon_vol"); |
| | | int recordNum=rs.getInt("record_num"); |
| | | if(num!=recordNum){ |
| | | if(num!=0){ |
| | | tdata.setMonVols(monVols); |
| | | tdata.setMonNums(monNums); |
| | | list.add(tdata); |
| | | } |
| | | tdata=new BatttestdataId(); |
| | | monVols=new ArrayList<>(); |
| | | monNums=new ArrayList<>(); |
| | | tdata.setDevId(rs.getInt("dev_id")); |
| | | tdata.setBattIdx(rs.getInt("batt_idx")); |
| | | tdata.setTestRecordCount(rs.getInt("test_record_count")); |
| | | tdata.setTestType(rs.getInt("test_type")); |
| | | tdata.setRecordNum(recordNum); |
| | | tdata.setTestStarttime(rs.getTimestamp("test_starttime")); |
| | | tdata.setRecordTime(rs.getTimestamp("record_time")); |
| | | tdata.setTestTimelong(rs.getInt("test_timelong")); |
| | | tdata.setGroupVol(rs.getDouble("group_vol")); |
| | | tdata.setTestCurr(rs.getDouble("test_curr")); |
| | | tdata.setTestCap(rs.getDouble("test_cap")); |
| | | tdata.setNeedTest(rs.getInt("need_test")); |
| | | tdata.setMaxTemp(rs.getFloat("max_temp")); |
| | | tdata.setMinTemp(rs.getFloat("min_temp")); |
| | | num=recordNum; |
| | | } |
| | | monVols.add(monvol); |
| | | monNums.add(monNum); |
| | | } |
| | | tdata.setMonVols(monVols); |
| | | tdata.setMonNums(monNums); |
| | | list.add(tdata); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | //查询DevAlm历史告警数量 |
| | | public int getCountForDevAlm(DalmDto dto) { |
| | | String sql="select count(distinct num) as number from db_alarm." +dto.getTableName() |
| | |
| | | } |
| | | |
| | | |
| | | public List<BatttestdataId> getTdataByIdWithListActm(Integer devId, Integer testRecordCount) { |
| | | String sql="select * from db_batt_testdata.tb_batttestdata_" +devId |
| | | +" where need_test=1 and test_record_count="+testRecordCount+" "; |
| | | sql+=" ORDER BY record_num asc "; |
| | | List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List list=new ArrayList<>(); |
| | | List<Float> monVols=null; |
| | | List<Float> monCurrs=null; |
| | | List<Float> monCaps=null; |
| | | List<Float> monWhs=null; |
| | | List<Integer> monNums=null; |
| | | BatttestdataId tdata=null; |
| | | int num=0; |
| | | try { |
| | | while (rs.next()){ |
| | | int monNum=rs.getInt("mon_num"); |
| | | float monvol=rs.getFloat("mon_vol"); |
| | | float monCurr=rs.getFloat("mon_curr"); |
| | | float monCap=rs.getFloat("mon_cap"); |
| | | float monWh=rs.getFloat("mon_wh"); |
| | | int recordNum=rs.getInt("record_num"); |
| | | |
| | | if(num!=recordNum){ |
| | | if(num!=0){ |
| | | tdata.setMonVols(monVols); |
| | | tdata.setMonNums(monNums); |
| | | tdata.setMonCurrs(monCurrs); |
| | | tdata.setMonCaps(monCaps); |
| | | tdata.setMonWhs(monWhs); |
| | | list.add(tdata); |
| | | } |
| | | tdata=new BatttestdataId(); |
| | | monVols=new ArrayList<>(); |
| | | monNums=new ArrayList<>(); |
| | | monCurrs=new ArrayList<>(); |
| | | monCaps=new ArrayList<>(); |
| | | monWhs=new ArrayList<>(); |
| | | tdata.setDevId(rs.getInt("dev_id")); |
| | | tdata.setBattIdx(rs.getInt("batt_idx")); |
| | | tdata.setTestRecordCount(rs.getInt("test_record_count")); |
| | | tdata.setTestType(rs.getInt("test_type")); |
| | | tdata.setRecordNum(recordNum); |
| | | tdata.setTestStarttime(rs.getTimestamp("test_starttime")); |
| | | tdata.setRecordTime(rs.getTimestamp("record_time")); |
| | | tdata.setTestTimelong(rs.getInt("test_timelong")); |
| | | tdata.setGroupVol(rs.getDouble("group_vol")); |
| | | tdata.setTestCurr(rs.getDouble("test_curr")); |
| | | tdata.setTestCap(rs.getDouble("test_cap")); |
| | | tdata.setNeedTest(rs.getInt("need_test")); |
| | | tdata.setMonTmp(rs.getDouble("mon_tmp")); |
| | | num=recordNum; |
| | | } |
| | | monVols.add(monvol); |
| | | monNums.add(monNum); |
| | | monCurrs.add(monCurr); |
| | | monCaps.add(monCap); |
| | | monWhs.add(monWh); |
| | | } |
| | | |
| | | tdata.setMonVols(monVols); |
| | | tdata.setMonNums(monNums); |
| | | tdata.setMonCurrs(monCurrs); |
| | | tdata.setMonCaps(monCaps); |
| | | tdata.setMonWhs(monWhs); |
| | | list.add(tdata); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | } |