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 |