Merge branch 'master' of http://118.89.139.230:10101/r/powerIntelligenceSystem
New file |
| | |
| | | package com.whyc.constant; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public enum AnalysisEnum { |
| | | ALARM_1(1,"直流电源"), |
| | | ALARM_2(2,"通信电源"), |
| | | ALARM_3(3,"配网电源"), |
| | | ALARM_4(4,"蓄电池组"), |
| | | ALARM_5(5,"设备"), |
| | | ALARM_6(6,"ups电源"), |
| | | ; |
| | | |
| | | private Integer stateId; |
| | | private String stateName; |
| | | |
| | | AnalysisEnum(Integer stateId, String stateName) { |
| | | this.stateId = stateId; |
| | | this.stateName = stateName; |
| | | } |
| | | |
| | | public Integer getStateId() { |
| | | return stateId; |
| | | } |
| | | |
| | | public String getStateName() { |
| | | return stateName; |
| | | } |
| | | |
| | | public static String getValue(Integer stateId) { |
| | | if(stateId==null){ |
| | | return ""; |
| | | } |
| | | for (AnalysisEnum ele : values()) { |
| | | if(ele.getStateId().equals(stateId)) { |
| | | return ele.getStateName(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | public static Map<Integer,String> getOpInfo() { |
| | | Map<Integer,String> map=new HashMap<>(); |
| | | for (AnalysisEnum logOpEnum : AnalysisEnum.values()) { |
| | | map.put(logOpEnum.getStateId(),logOpEnum.getStateName()); |
| | | } |
| | | return map; |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.Statistic.BattCompareStic; |
| | | import com.whyc.pojo.db_user.User; |
| | | import com.whyc.service.BatttestdataInfService; |
| | | 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("compare") |
| | | public class BattCompareController { |
| | | |
| | | @Autowired |
| | | private BatttestdataInfService battTinfService; |
| | | |
| | | |
| | | @ApiOperation(value = "蓄电池组对比分析界面(同一品牌同一时间)(1.2.15)") |
| | | @PostMapping("getBattCompare15Statistic") |
| | | public Response getBattCompare15Statistic(@RequestBody BattCompareStic stic){ |
| | | User uinf= ActionUtil.getUser(); |
| | | stic.setUid(uinf.getId()); |
| | | return battTinfService.getBattCompare15Statistic(stic); |
| | | } |
| | | |
| | | @ApiOperation(value = "蓄电池组对比分析界面(不同品牌同一时间)(1.2.16)") |
| | | @PostMapping("getBattCompare16Statistic") |
| | | public Response getBattCompare16Statistic(@RequestBody BattCompareStic stic){ |
| | | User uinf= ActionUtil.getUser(); |
| | | stic.setUid(uinf.getId()); |
| | | return battTinfService.getBattCompare16Statistic(stic); |
| | | } |
| | | |
| | | @ApiOperation(value = "蓄电池组对比分析界面(同一品牌不同时间)(1.2.17)") |
| | | @PostMapping("getBattCompare17Statistic") |
| | | public Response getBattCompare17Statistic(@RequestBody BattCompareStic stic){ |
| | | User uinf= ActionUtil.getUser(); |
| | | stic.setUid(uinf.getId()); |
| | | return battTinfService.getBattCompare17Statistic(stic); |
| | | } |
| | | } |
| | |
| | | return tdataIdService.getTinfDataWithTestRecordCount(battgroupId,testRecordCount,recordNum,granularity); |
| | | } |
| | | |
| | | @ApiOperation(value = "历史实时查询") |
| | | @ApiOperation(value = "电池历史实时查询") |
| | | @GetMapping("getBattRealDataHis") |
| | | public Response getBattRealDataHis(@RequestParam Integer battgroupId,@RequestParam Integer granularity |
| | | ,@RequestParam String startTime,@RequestParam String endTime) throws ParseException, InterruptedException { |
| | | return battRealdataIdService.getBattRealDataHis(battgroupId,granularity,startTime,endTime); |
| | | } |
| | | @ApiOperation(value = "电源历史实时查询") |
| | | @GetMapping("getPwrRealDataHis") |
| | | public Response getPwrRealDataHis(@RequestParam Integer powerId,@RequestParam Integer granularity |
| | | ,@RequestParam String startTime,@RequestParam String endTime) throws ParseException, InterruptedException { |
| | | return pwrdevHistorydataIdService.getPwrRealDataHis(powerId,granularity,startTime,endTime); |
| | | } |
| | | } |
| | |
| | | package com.whyc.pojo.db_param; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | |
| | | @ApiModelProperty(value = "主字段类型[1:直流,2:通信,3配网 4:电池 5:设备]") |
| | | private Integer mainFieldType; |
| | | |
| | | @TableField(exist = false) |
| | | private String mainFieldTypeName; |
| | | |
| | | @ApiModelProperty(value = "次要字段1参考配置") |
| | | private String minorField1; |
| | | |
| | | @ApiModelProperty(value = "字段1类型[1:直流,2:通信,3配网 4:电池 5:设备]") |
| | | private Integer minorField1Type; |
| | | |
| | | @TableField(exist = false) |
| | | private String minorField1TypeName; |
| | | |
| | | @ApiModelProperty(value = "次要字段2参考配置") |
| | | private String minorField2; |
| | |
| | | @ApiModelProperty(value = "字段2类型[1:直流,2:通信,3配网 4:电池 5:设备]") |
| | | private Integer minorField2Type; |
| | | |
| | | @TableField(exist = false) |
| | | private String minorField2TypeName; |
| | | |
| | | @ApiModelProperty(value = "次要字段3参考配置") |
| | | private String minorField3; |
| | | |
| | | @ApiModelProperty(value = "字段3类型[1:直流,2:通信,3配网 4:电池 5:设备]") |
| | | private Integer minorField3Type; |
| | | |
| | | @TableField(exist = false) |
| | | private String minorField3TypeName; |
| | | |
| | | @ApiModelProperty(value = "次要字段4参考配置") |
| | | private String minorField4; |
| | | |
| | | @ApiModelProperty(value = "字段4类型[1:直流,2:通信,3配网 4:电池 5:设备]") |
| | | private Integer minorField4Type; |
| | | |
| | | @TableField(exist = false) |
| | | private String minorField4TypeName; |
| | | |
| | | |
| | | } |
| | |
| | | package com.whyc.pojo.db_param; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | |
| | | @ApiModelProperty(value = "字段类型[1:直流,2:通信,3配网 4:电池 5:设备]") |
| | | private Integer fieldType; |
| | | |
| | | @ApiModelProperty(value = "字段类型[1:直流,2:通信,3配网 4:电池 5:设备]") |
| | | @TableField(exist = false) |
| | | private String fieldTypeName; |
| | | |
| | | @ApiModelProperty(value = "字段属性") |
| | | private String fieldName; |
| | | |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.whyc.constant.AnalysisEnum; |
| | | import com.whyc.dto.AnalysisAlm.AnalysisChangeRes; |
| | | import com.whyc.dto.AnalysisAlm.ResAnalysis; |
| | | import com.whyc.dto.Real.RealDateDTO; |
| | |
| | | wrapper.eq("alm_id",almId); |
| | | wrapper.last("limit 1"); |
| | | AlmAnalysisParam param= mapper.selectOne(wrapper); |
| | | if(param!=null){ |
| | | param.setMainFieldTypeName(AnalysisEnum.getValue(param.getMainFieldType())); |
| | | param.setMinorField1TypeName(AnalysisEnum.getValue(param.getMinorField1Type())); |
| | | param.setMinorField2TypeName(AnalysisEnum.getValue(param.getMinorField2Type())); |
| | | param.setMinorField3TypeName(AnalysisEnum.getValue(param.getMinorField3Type())); |
| | | param.setMinorField4TypeName(AnalysisEnum.getValue(param.getMinorField4Type())); |
| | | } |
| | | return param; |
| | | } |
| | | |
| | |
| | | if(almAnalysisParam==null||almAnalysisParam.getMainFieldType()==null){ |
| | | return new Response().set(1,false,"无对应分析属性"); |
| | | }else{ |
| | | |
| | | //分组查看需要查询电源/电池实时表的哪些数据 |
| | | Map<String, Map<String,Object>> groupmap=groupPwrAndBatt(almAnalysisParam); |
| | | Map<String,Object> battMap=groupmap.get("batt"); |
| | |
| | | map.put("pwr",pwrHislist); |
| | | } |
| | | } |
| | | return new Response().setIII(1,true, map,mainMap,"预警分析管理-电源主属性和分析属性"); |
| | | return new Response().setIIII(1,true, map,mainMap,almAnalysisParam,"预警分析管理-电源主属性和分析属性"); |
| | | } |
| | | } |
| | | //分组查看需要查询电源/电池实时表的哪些数据 |
| | |
| | | map.put("pwr",pwrHislist); |
| | | } |
| | | } |
| | | return new Response().setIII(1,true, map,mainMap,"预警分析管理-切换时间间隔和副属性"); |
| | | return new Response().setIIII(1,true, map,mainMap,almAnalysisParam,"预警分析管理-切换时间间隔和副属性"); |
| | | } |
| | | //将属性拷贝至almAnalysisParam中 |
| | | private void copyProperties(AlmAnalysisParam almAnalysisParam, AnalysisChangeRes res) { |
| | |
| | | public Response getAlmSummaryParam() { |
| | | //总的属性配置 |
| | | List<AlmSummaryParam> summaryList=summaryParamService.getInfo(); |
| | | summaryList.forEach(item->{ |
| | | item.setFieldTypeName(AnalysisEnum.getValue(item.getFieldType())); |
| | | }); |
| | | return new Response().setII(1,true,summaryList,"预警分析管理-查询所有的属性对应关系"); |
| | | } |
| | | } |
| | |
| | | if(param.getParamNamePsx().equals("batt_mon_damage_val")){ |
| | | damageValue=param.getParamValue(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | //1查询符合条件的电池组 |
| | |
| | | return PwrCapperformanceEnum.PWRSTATE_4.getStateId(); |
| | | } |
| | | } |
| | | |
| | | //电源历史实时查询 |
| | | public Response getPwrRealDataHis(Integer powerId, Integer granularity, String startTime, String endTime) throws InterruptedException, ParseException { |
| | | //获取两个时间分割多少张表 |
| | | List<List<Date>> monthTimeList = DateUtil.getMonthTime(ThreadLocalUtil.parse(startTime,1),ThreadLocalUtil.parse(endTime,1)); |
| | | List<PwrHisRealDcoutInDto> dataList = new LinkedList<>(); |
| | | ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(monthTimeList.size()); |
| | | for (int i = 0; i < monthTimeList.size(); i++) { |
| | | int finalI = i; |
| | | Integer finalGranularity = granularity; |
| | | pool.execute(() -> { |
| | | int finalII = finalI; |
| | | Date recordDatetime=monthTimeList.get(finalII).get(0); |
| | | Date recordDatetime1=monthTimeList.get(finalII).get(1); |
| | | String table = powerId + "_" + ThreadLocalUtil.format(recordDatetime,2); |
| | | String tableName="db_data_history.tb_pwrdev_historydata_"+table; |
| | | //判断表是否存在 |
| | | int tableNum = subTablePageInfoService.judgeTable_pwrhis(table); |
| | | List<PwrHisRealDcoutInDto> list = new ArrayList(); |
| | | if (tableNum > 0) { |
| | | //获取指定时间段内最大最小recordNum确保数据的完整 |
| | | List recordNums= subTablePageInfoService.getPwrMaxAndMinRecordNum(tableName,recordDatetime,recordDatetime1); |
| | | Integer maxRecordNum= 0; |
| | | Integer minRecordNum= 0; |
| | | if(recordNums.size()>0){ |
| | | maxRecordNum=(Integer)recordNums.get(0); |
| | | minRecordNum=(Integer)recordNums.get(1); |
| | | } |
| | | list=subTablePageInfoService.getPwrRealDataHis(tableName, finalGranularity,recordDatetime,recordDatetime1,maxRecordNum,minRecordNum); |
| | | } |
| | | dataList.addAll(list); |
| | | latch.countDown(); |
| | | }); |
| | | sleep(200); |
| | | } |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | List dataListSorted = dataList.stream().sorted(Comparator.comparing(PwrHisRealDcoutInDto::getRecordDatetime)).collect(Collectors.toList()); |
| | | return new Response().setII(1,dataList.size()>0,dataListSorted,"获取半小时内直流输出统计"); |
| | | } |
| | | } |
| | |
| | | }); |
| | | return list; |
| | | } |
| | | //电源历史实时 |
| | | public List<PwrHisRealDcoutInDto> getPwrRealDataHis(String tableName,Integer granularity,Date recordDatetime,Date recordDatetime1,Integer maxRecordNum,Integer minRecordNum) { |
| | | String sql="select distinct * " + |
| | | " from "+tableName+" where record_datetime>='"+ActionUtil.sdf.format(recordDatetime)+"'" + |
| | | " and record_datetime<='"+ActionUtil.sdf.format(recordDatetime1)+ |
| | | "' and (record_num-"+minRecordNum+")%"+granularity+"=0 or record_num="+minRecordNum+" or record_num="+maxRecordNum; |
| | | sql+=" order by record_datetime asc"; |
| | | List<PwrHisRealDcoutInDto> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List<PwrHisRealDcoutInDto> list=new ArrayList<>(); |
| | | while (rs.next()){ |
| | | PwrHisRealDcoutInDto data=new PwrHisRealDcoutInDto(); |
| | | data.setRecordDatetime(rs.getTimestamp("record_datetime")); |
| | | data.setMOutputvol(rs.getFloat("m_outputvol")); |
| | | data.setM1Outcurr(rs.getFloat("m1_outcurr")); |
| | | data.setM2Outcurr(rs.getFloat("m2_outcurr")); |
| | | data.setM3Outcurr(rs.getFloat("m3_outcurr")); |
| | | data.setM4Outcurr(rs.getFloat("m4_outcurr")); |
| | | data.setM5Outcurr(rs.getFloat("m5_outcurr")); |
| | | data.setM6Outcurr(rs.getFloat("m6_outcurr")); |
| | | data.setM7Outcurr(rs.getFloat("m7_outcurr")); |
| | | data.setM8Outcurr(rs.getFloat("m8_outcurr")); |
| | | data.setM9Outcurr(rs.getFloat("m9_outcurr")); |
| | | data.setM10Outcurr(rs.getFloat("m10_outcurr")); |
| | | data.setM11Outcurr(rs.getFloat("m11_outcurr")); |
| | | data.setM12Outcurr(rs.getFloat("m12_outcurr")); |
| | | data.setM13Outcurr(rs.getFloat("m13_outcurr")); |
| | | data.setM14Outcurr(rs.getFloat("m14_outcurr")); |
| | | data.setM15Outcurr(rs.getFloat("m15_outcurr")); |
| | | data.setM16Outcurr(rs.getFloat("m16_outcurr")); |
| | | data.setM1OutVol(rs.getFloat("m1_out_vol")); |
| | | data.setM2OutVol(rs.getFloat("m2_out_vol")); |
| | | data.setM3OutVol(rs.getFloat("m3_out_vol")); |
| | | data.setM4OutVol(rs.getFloat("m4_out_vol")); |
| | | data.setM5OutVol(rs.getFloat("m5_out_vol")); |
| | | data.setM6OutVol(rs.getFloat("m6_out_vol")); |
| | | data.setM7OutVol(rs.getFloat("m7_out_vol")); |
| | | data.setM8OutVol(rs.getFloat("m8_out_vol")); |
| | | data.setM9OutVol(rs.getFloat("m9_out_vol")); |
| | | data.setM10OutVol(rs.getFloat("m10_out_vol")); |
| | | data.setM11OutVol(rs.getFloat("m11_out_vol")); |
| | | data.setM12OutVol(rs.getFloat("m12_out_vol")); |
| | | data.setM13OutVol(rs.getFloat("m13_out_vol")); |
| | | data.setM14OutVol(rs.getFloat("m14_out_vol")); |
| | | data.setM15OutVol(rs.getFloat("m15_out_vol")); |
| | | data.setM16OutVol(rs.getFloat("m16_out_vol")); |
| | | list.add(data); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | //历史测试记录具体某一次放电数据详情 |
| | | public List<BatttestdataId> getTinfDataWithTestRecordCount(String tableName, Integer testRecordCount, Integer recordNum, Integer granularity) { |
| | | String sql="select distinct * from "+tableName+" "+ |
| | |
| | | <if test="stic.product!=null"> |
| | | and tb_batt_inf.product=#{stic.product} |
| | | </if> |
| | | <if test="stic.inuseStartTime!=null"> |
| | | and tb_batt_inf.inuse_time>=#{stic.inuseStartTime} |
| | | </if> |
| | | <if test="stic.inuseEndTime!=null"> |
| | | and tb_batt_inf.inuse_time<=#{stic.inuseEndTimee} |
| | | </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 |