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; |
| | | } |
| | | } |
| | |
| | | import com.whyc.dto.Param.AlmAnalyseDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_alarm.BattalarmData; |
| | | import com.whyc.pojo.db_param.AppParam; |
| | | import com.whyc.service.*; |
| | | import com.whyc.util.ActionUtil; |
| | | import io.swagger.annotations.Api; |
| | |
| | | return almAnalysisParamService.getAlmSummaryParam(); |
| | | } |
| | | |
| | | @PostMapping("updateAlarmAnalysisCycle") |
| | | @GetMapping("updateAlarmAnalysisCycle") |
| | | @ApiOperation("é¢è¦åæç®¡ç-设置æ¶é´é´é") |
| | | public Response updateAlarmAnalysisCycle(@RequestParam Integer intervalTime){ |
| | | return appParamService.updateAlarmAnalysisCycle(intervalTime); |
| | | } |
| | | |
| | | @GetMapping("getAlarmAnalysisCycle") |
| | | @ApiOperation("é¢è¦åæç®¡ç-æ¥è¯¢æ¶é´é´é") |
| | | public Response getAlarmAnalysisCycle(){ |
| | | AppParam appParam= appParamService.getAlarmAnalysisCycle(); |
| | | return new Response().setII(1,appParam!=null,appParam,"æ¥è¯¢æ¶é´é´é"); |
| | | } |
| | | } |
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); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarmParamStand; |
| | | import com.whyc.service.PowerheartParamService; |
| | | import com.whyc.service.PwrdevAlarmParamStandService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @RestController |
| | | @Api(tags = "çµæºå¿è·³åæ°ç®¡ç") |
| | | @RequestMapping("pwrHeart") |
| | | public class PowerheartParamController { |
| | | @Autowired |
| | | private PowerheartParamService service; |
| | | |
| | | @ApiOperation(value = "æ¥è¯¢çµæºå¿è·³åæ°") |
| | | @GetMapping("getPwrHeartParam") |
| | | public Response getPwrHeartParam(@RequestParam Integer powerId){ |
| | | return service.getPwrHeartParam(powerId); |
| | | } |
| | | |
| | | @ApiOperation(value = "è®¾ç½®çµæºå¿è·³åæ°-交æµè¾å
¥") |
| | | @GetMapping("setPwrHeartAcIn") |
| | | public Response setPwrHeartAcIn(@RequestParam Integer powerId,@RequestParam Integer interverCfg,@RequestParam Integer countCfg){ |
| | | return service.setPwrHeartAcIn(powerId,interverCfg,countCfg); |
| | | } |
| | | |
| | | @ApiOperation(value = "è®¾ç½®çµæºå¿è·³åæ°-ç´æµè¾åº") |
| | | @GetMapping("setPwrHeartAcOut") |
| | | public Response setPwrHeartAcOut(@RequestParam Integer powerId,@RequestParam Integer interverCfg,@RequestParam Integer countCfg){ |
| | | return service.setPwrHeartAcOut(powerId,interverCfg,countCfg); |
| | | } |
| | | @ApiOperation(value = "è®¾ç½®çµæºå¿è·³åæ°-æ ¸å®¹è®¾å¤") |
| | | @GetMapping("setPwrHeartHr") |
| | | public Response setPwrHeartHr(@RequestParam Integer powerId,@RequestParam Integer interverCfg,@RequestParam Integer countCfg){ |
| | | return service.setPwrHeartHr(powerId,interverCfg,countCfg); |
| | | } |
| | | } |
| | |
| | | |
| | | @ApiOperation(value = "ç³»ç»æ¦è§è·ååä¸ç¾æ¯æ¶é´é´éæ°æ®ç´æµè¾åºç»è®¡") |
| | | @GetMapping("getPwrHisDcoutData100") |
| | | public Response getPwrHisDcoutData100(@RequestParam Integer powerId){ |
| | | public Response getPwrHisDcoutData100(@RequestParam Integer powerId) throws ParseException, InterruptedException { |
| | | return pwrdevHistorydataIdService.getHalfHourPwrHisDcoutData(powerId); |
| | | } |
| | | |
| | | @ApiOperation(value = "ç³»ç»æ¦è§è·ååä¸ç¾æ¯æ¶é´é´éæ°æ®æ ¸å®¹è®¾å¤ä¿¡æ¯") |
| | | @GetMapping("getBattDevData100") |
| | | public Response getBattDevData100(@RequestParam Integer powerId,@RequestParam Integer battgroupId){ |
| | | public Response getBattDevData100(@RequestParam Integer powerId,@RequestParam Integer battgroupId) throws ParseException, InterruptedException { |
| | | return battRealdataIdService.getBattDevData100(powerId,battgroupId); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | private Float onlineVol; |
| | | @ApiModelProperty(value = "ç»ç«¯çµæµ") |
| | | private Float groupCurr; |
| | | @ApiModelProperty(value = "è´è½½çµæµ") |
| | | private Float loadCurr; |
| | | @ApiModelProperty(value = "åä½çµå") |
| | | private Float monVol; |
| | | @ApiModelProperty(value = "å使¸©åº¦") |
New file |
| | |
| | | package com.whyc.dto.Real; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class RealHeart { |
| | | private Integer powerId; |
| | | private Integer battgroupId; |
| | | } |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.dto.Real.RealDateDTO; |
| | | import com.whyc.pojo.db_ram_db.BattRtstate; |
| | | |
| | | public interface BattRtstateMapper extends CustomMapper<BattRtstate>{ |
| | | //宿¶æ¨éçµæ± æ ¸å®¹è®¾å¤å¿è·³æ°æ® |
| | | RealDateDTO getBattRealHr(Integer battgroupId); |
| | | } |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.dto.Real.PwrHisRealAcInDto; |
| | | import com.whyc.dto.Real.PwrHisRealDcoutInDto; |
| | | import com.whyc.pojo.db_ram_db.PwrdevAcdcdata; |
| | | |
| | | public interface PwrdevAcdcdataMapper extends CustomMapper<PwrdevAcdcdata>{ |
| | | //çµæºå¿è·³æ°æ®è·å交æµè¾å
¥å®æ¶æ°æ® |
| | | PwrHisRealAcInDto getPwrRealAcIn(Integer powerId); |
| | | //çµæºå¿è·³æ°æ®è·åçµæºç´æµè¾åºæ°æ®å®æ¶æ°æ® |
| | | PwrHisRealDcoutInDto getPwrRealDcOut(Integer powerId); |
| | | } |
| | |
| | | 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,Integer>> groupmap=groupPwrAndBatt(almAnalysisParam); |
| | | Map<String,Integer> battMap=groupmap.get("batt"); |
| | | Map<String,Integer> pwrMap=groupmap.get("pwr"); |
| | | Map<String, Map<String,Object>> groupmap=groupPwrAndBatt(almAnalysisParam); |
| | | Map<String,Object> battMap=groupmap.get("batt"); |
| | | Map<String,Object> pwrMap=groupmap.get("pwr"); |
| | | Map<String,Object> mainMap=groupmap.get("main"); |
| | | mainMap.put("pwr",pwrMap.size()); |
| | | mainMap.put("batt",battMap.size()); |
| | | if(battgroupId!=null){ |
| | | if(battMap!=null&&battMap.size()>0){ |
| | | List battHislist=getBattRealData(battgroupId,monthTimeList,battMap); |
| | |
| | | map.put("pwr",pwrHislist); |
| | | } |
| | | } |
| | | return new Response().setII(1,true, map,"é¢è¦åæç®¡ç-çµæºä¸»å±æ§ååæå±æ§"); |
| | | return new Response().setIIII(1,true, map,mainMap,almAnalysisParam,"é¢è¦åæç®¡ç-çµæºä¸»å±æ§ååæå±æ§"); |
| | | } |
| | | } |
| | | //åç»æ¥çéè¦æ¥è¯¢çµæº/çµæ± 宿¶è¡¨çåªäºæ°æ® |
| | | private Map<String, Map<String,Integer>> groupPwrAndBatt(AlmAnalysisParam almAnalysisParam) { |
| | | Map<String, Map<String,Integer>> map = new HashMap<>(); |
| | | Map<String,Integer> battMap=new HashMap<>(); |
| | | Map<String,Integer> pwrMap=new HashMap<>(); |
| | | private Map<String, Map<String,Object>> groupPwrAndBatt(AlmAnalysisParam almAnalysisParam) { |
| | | Map<String, Map<String,Object>> map = new HashMap<>(); |
| | | Map<String,Object> battMap=new HashMap<>(); |
| | | Map<String,Object> pwrMap=new HashMap<>(); |
| | | Map<String,Object> mainMap=new HashMap<>(); |
| | | if(almAnalysisParam.getMainFieldType()==1||almAnalysisParam.getMainFieldType()==2||almAnalysisParam.getMainFieldType()==3){ |
| | | if(almAnalysisParam.getMainField()!=null||almAnalysisParam.getMainField().length()>0){ |
| | | pwrMap.put(almAnalysisParam.getMainField(),almAnalysisParam.getMainFieldType()); |
| | | mainMap.put("main","pwr"); |
| | | } |
| | | }else{ |
| | | if(almAnalysisParam.getMainField()!=null||almAnalysisParam.getMainField().length()>0){ |
| | | battMap.put(almAnalysisParam.getMainField(),almAnalysisParam.getMainFieldType()); |
| | | mainMap.put("main","batt"); |
| | | } |
| | | } |
| | | if(almAnalysisParam.getMinorField1Type()==1||almAnalysisParam.getMinorField1Type()==2||almAnalysisParam.getMinorField1Type()==3){ |
| | |
| | | } |
| | | map.put("pwr",pwrMap); |
| | | map.put("batt",battMap); |
| | | map.put("main",mainMap); |
| | | return map; |
| | | } |
| | | //è¿æ¥æ± è·åçµæºåå²å®æ¶æ°æ® |
| | | public List getPwrRealData(Integer powerId,List<List<Date>> monthTimeList,Map<String,Integer> pwrMap) throws InterruptedException { |
| | | public List getPwrRealData(Integer powerId,List<List<Date>> monthTimeList,Map<String,Object> pwrMap) throws InterruptedException { |
| | | List<ResAnalysis> dataList = new LinkedList<>(); |
| | | ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(monthTimeList.size()); |
| | |
| | | } |
| | | |
| | | //çµæ± åè¦ç¹å»å
·ä½åè¦ä¿¡æ¯æ¥çä»åè¦å¼å§æ¶é´å°ç°å¨çåå²å®æ¶æ°æ® |
| | | public List getBattRealData(Integer battgroupId, List<List<Date>> monthTimeList,Map<String,Integer> battMap) throws ParseException, InterruptedException { |
| | | public List getBattRealData(Integer battgroupId, List<List<Date>> monthTimeList,Map<String,Object> battMap) throws ParseException, InterruptedException { |
| | | List<ResAnalysis> dataList = new LinkedList<>(); |
| | | ThreadPoolExecutor pool = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(monthTimeList.size()); |
| | |
| | | //å°å±æ§æ·è´è³almAnalysisParamä¸ |
| | | copyProperties(almAnalysisParam,res); |
| | | //åç»æ¥çéè¦æ¥è¯¢çµæº/çµæ± 宿¶è¡¨çåªäºæ°æ® |
| | | Map<String, Map<String,Integer>> groupmap=groupPwrAndBatt(almAnalysisParam); |
| | | Map<String,Integer> battMap=groupmap.get("batt"); |
| | | Map<String,Integer> pwrMap=groupmap.get("pwr"); |
| | | Map<String, Map<String,Object>> groupmap=groupPwrAndBatt(almAnalysisParam); |
| | | Map<String,Object> battMap=groupmap.get("batt"); |
| | | Map<String,Object> pwrMap=groupmap.get("pwr"); |
| | | Map<String,Object> mainMap=groupmap.get("main"); |
| | | mainMap.put("pwr",pwrMap.size()); |
| | | mainMap.put("batt",battMap.size()); |
| | | if(res.getBattgroupId()!=null){ |
| | | if(battMap!=null&&battMap.size()>0){ |
| | | List battHislist=getBattRealData(res.getBattgroupId(),monthTimeList,battMap); |
| | |
| | | map.put("pwr",pwrHislist); |
| | | } |
| | | } |
| | | return new Response().setII(1,true, map,"é¢è¦åæç®¡ç-忢æ¶é´é´éåå¯å±æ§"); |
| | | 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,"é¢è¦åæç®¡ç-æ¥è¯¢ææç屿§å¯¹åºå
³ç³»"); |
| | | } |
| | | } |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.dto.Real.BattHisRealDto; |
| | | import com.whyc.dto.Real.CompareDto; |
| | | import com.whyc.dto.Real.QuarterDto; |
| | | import com.whyc.dto.Real.RealDateDTO; |
| | | import com.whyc.dto.Real.*; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.factory.ThreadPoolExecutorFactory; |
| | | import com.whyc.mapper.CommonMapper; |
| | |
| | | return new Response().setII(1,map.size()>0,map,"è·åçµæ± ç»æè¿ä¸å£åº¦çæ¸©åº¦æ°æ®"); |
| | | } |
| | | //ç³»ç»æ¦è§è·ååNç¬æ ¸å®¹è®¾å¤ä¿¡æ¯ |
| | | public Response getBattDevData100(Integer powerId,Integer battgroupId) { |
| | | String dateTime = ActionUtil.sdfwithOutday.format(new Date()); |
| | | String tableName ="db_data_history.tb_batt_realdata_"+battgroupId+"_"+dateTime; |
| | | public Response getBattDevData100(Integer powerId,Integer battgroupId) throws ParseException, InterruptedException { |
| | | //è·ååç¬æ°*æ¶é´é´é |
| | | PowerheartParam heartParam=heartService.getHeartParamByPowerId(powerId); |
| | | Integer interverCount=100*10;//é»è®¤å¼ |
| | | Integer granularity=10;//é»è®¤å¼ |
| | | Integer granularity=5;//é»è®¤å¼ |
| | | if(heartParam!=null){ |
| | | interverCount=heartParam.getAcinInterverCfg()*heartParam.getAcinCountCfg(); |
| | | granularity=heartParam.getAcinInterverCfg(); |
| | | interverCount=heartParam.getHrInterverCfg()*heartParam.getHrCountCfg(); |
| | | granularity=heartParam.getHrInterverCfg(); |
| | | } |
| | | //è·åååä¸ªå°æ¶æ°æ® |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 计ç®åå°æ¶åçæ¶é´ç¹ |
| | | String dateTime = now.format(formatter); |
| | | Date endTime=ActionUtil.sdf.parse(dateTime); |
| | | // 计ç®ç¬æ°*æ¶é´é´éçæ¶é´ç¹ |
| | | LocalDateTime halfHourAgo = now.minusMinutes(interverCount); |
| | | // æ ¼å¼åè¾åº |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String halfHourAgoTime=halfHourAgo.format(formatter); |
| | | String existTableName = commonMapper.existTable("db_data_history", "tb_batt_realdata_"+battgroupId+"_"+dateTime); |
| | | if(existTableName == null){ |
| | | return new Response().set(1,false,"å½åçµæ± ç»ä¸åå¨åé¢å°æ¶æ°æ®"); |
| | | Date startTime=ActionUtil.sdf.parse(halfHourAgoTime); |
| | | List<List<Date>> monthTimeList = DateUtil.getMonthTime(startTime,endTime); |
| | | List<RealDateDTO> 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 = battgroupId + "_" + ThreadLocalUtil.format(recordDatetime,2); |
| | | String tableName="db_data_history.tb_batt_realdata_"+table; |
| | | //å¤æè¡¨æ¯å¦åå¨ |
| | | int tableNum = subTablePageInfoService.judgeTable_realdata(table); |
| | | List<RealDateDTO> list = new ArrayList(); |
| | | if (tableNum > 0) { |
| | | //è·åæå®æ¶é´æ®µå
æå¤§æå°recordNumç¡®ä¿æ°æ®ç宿´ |
| | | List recordNums= subTablePageInfoService.getBattMaxAndMinRecordNum(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.getBattDevData100(tableName, finalGranularity,recordDatetime,recordDatetime1,maxRecordNum,minRecordNum); |
| | | } |
| | | dataList.addAll(list); |
| | | latch.countDown(); |
| | | }); |
| | | sleep(200); |
| | | } |
| | | List<BattHisRealDto> datalist=subTablePageInfoService.getHalfHourBattDevData(tableName,granularity,halfHourAgoTime); |
| | | return new Response().setII(1,datalist.size()>0,datalist,"è·ååå°æ¶å
æ ¸å®¹è®¾å¤ä¿¡æ¯"); |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | List dataListSorted = dataList.stream().sorted(Comparator.comparing(RealDateDTO::getRecordTime)).collect(Collectors.toList()); |
| | | return new Response().setII(1,dataList.size()>0,dataListSorted,"è·ååå°æ¶å
æ ¸å®¹è®¾å¤ä¿¡æ¯"); |
| | | } |
| | | //åå²å®æ¶æ°æ® |
| | | public Response getBattRealDataHis(Integer battgroupId, Integer granularity,String startTime,String endTime) throws ParseException, InterruptedException { |
| | |
| | | realdata.setRecordTime(monthTimeList.get(finalII).get(0)); |
| | | realdata.setRecordTime1(monthTimeList.get(finalII).get(1)); |
| | | String table = battgroupId + "_" + ThreadLocalUtil.format(realdata.getRecordTime(),2); |
| | | String tableName="db_data_history.tb_batt_realdata_"+table; |
| | | realdata.setTableName(table);//è¡¨åæ¶é´æ ¼å¼é¨å |
| | | //å¤æè¡¨æ¯å¦åå¨ |
| | | int tableNum = subTablePageInfoService.judgeTable_realdata(table); |
| | | List<RealDateDTO> list = new ArrayList(); |
| | | if (tableNum > 0) { |
| | | //è·åæå®æ¶é´æ®µå
æå¤§æå°recordNumç¡®ä¿æ°æ®ç宿´ |
| | | List recordNums= subTablePageInfoService.getMaxAndMinRecordNum(realdata); |
| | | List recordNums= subTablePageInfoService.getBattMaxAndMinRecordNum(tableName,realdata.getRecordTime(),realdata.getRecordTime1()); |
| | | Integer maxRecordNum= 0; |
| | | Integer minRecordNum= 0; |
| | | if(recordNums.size()>0){ |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.whyc.constant.BattStateEnum; |
| | | import com.whyc.constant.DevStateEnum; |
| | | import com.whyc.dto.Real.PwrHisRealDcoutInDto; |
| | | import com.whyc.dto.Real.RealDateDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattRtstateMapper; |
| | | import com.whyc.pojo.db_ram_db.BattRtstate; |
| | |
| | | Map<Integer,String> map= BattStateEnum.getOpInfo(); |
| | | return new Response().setII(1,true,map,"è·åçµæ± ç»å·¥ä½ç¶æç±»å(䏿)"); |
| | | } |
| | | |
| | | //宿¶æ¨éçµæ± æ ¸å®¹è®¾å¤å¿è·³æ°æ® |
| | | public RealDateDTO getBattRealHr(Integer battgroupId) { |
| | | RealDateDTO hrDto=mapper.getBattRealHr(battgroupId); |
| | | return hrDto; |
| | | } |
| | | } |
| | |
| | | if(param.getParamNamePsx().equals("batt_mon_damage_val")){ |
| | | damageValue=param.getParamValue(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | //1æ¥è¯¢ç¬¦åæ¡ä»¶ççµæ± ç» |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.PowerheartParamMapper; |
| | | import com.whyc.pojo.db_param.PowerheartParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | heartParam.setHrCountCfg(100); |
| | | mapper.insert(heartParam); |
| | | } |
| | | //æ¥è¯¢çµæºå¿è·³åæ° |
| | | public Response getPwrHeartParam(Integer powerId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("power_id",powerId); |
| | | wrapper.last("limit 1"); |
| | | PowerheartParam param= mapper.selectOne(wrapper); |
| | | return new Response().setII(1,param!=null,param,"æ¥è¯¢çµæºå¿è·³åæ°"); |
| | | } |
| | | //è®¾ç½®çµæºå¿è·³åæ°-交æµè¾å
¥ |
| | | public Response setPwrHeartAcIn(Integer powerId, Integer interverCfg, Integer countCfg) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("power_id",powerId); |
| | | wrapper.set("acin_interver_cfg",interverCfg); |
| | | wrapper.set("acin_count_cfg",countCfg); |
| | | int flag=mapper.update(null,wrapper); |
| | | return new Response().setII(1,flag>0,flag>0,"è®¾ç½®çµæºå¿è·³åæ°-交æµè¾å
¥"); |
| | | } |
| | | //è®¾ç½®çµæºå¿è·³åæ°-ç´æµè¾åº |
| | | public Response setPwrHeartAcOut(Integer powerId, Integer interverCfg, Integer countCfg) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("power_id",powerId); |
| | | wrapper.set("acout_interver_cfg",interverCfg); |
| | | wrapper.set("acout_count_cfg",countCfg); |
| | | int flag=mapper.update(null,wrapper); |
| | | return new Response().setII(1,flag>0,flag>0,"è®¾ç½®çµæºå¿è·³åæ°-ç´æµè¾åº"); |
| | | } |
| | | //è®¾ç½®çµæºå¿è·³åæ°-æ ¸å®¹è®¾å¤ |
| | | public Response setPwrHeartHr(Integer powerId, Integer interverCfg, Integer countCfg) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("power_id",powerId); |
| | | wrapper.set("hr_interver_cfg",interverCfg); |
| | | wrapper.set("hr_count_cfg",countCfg); |
| | | int flag=mapper.update(null,wrapper); |
| | | return new Response().setII(1,flag>0,flag>0,"è®¾ç½®çµæºå¿è·³åæ°-交æµè¾å
¥"); |
| | | } |
| | | } |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.whyc.dto.Real.PwrHisRealAcInDto; |
| | | import com.whyc.dto.Real.PwrHisRealDcoutInDto; |
| | | import com.whyc.mapper.PwrdevAcdcdataMapper; |
| | | import com.whyc.pojo.db_ram_db.BattRtstate; |
| | | import com.whyc.pojo.db_ram_db.PwrdevAcdcdata; |
| | |
| | | PwrdevAcdcdata pwr=mapper.selectOne(wrapper); |
| | | return pwr; |
| | | } |
| | | //çµæºå¿è·³æ°æ®è·å交æµè¾å
¥å®æ¶æ°æ® |
| | | public PwrHisRealAcInDto getPwrRealAcIn(Integer powerId) { |
| | | PwrHisRealAcInDto acinDto=mapper.getPwrRealAcIn(powerId); |
| | | return acinDto; |
| | | } |
| | | |
| | | //çµæºå¿è·³æ°æ®è·åçµæºç´æµè¾åºæ°æ®å®æ¶æ°æ® |
| | | public PwrHisRealDcoutInDto getPwrRealDcOut(Integer powerId) { |
| | | PwrHisRealDcoutInDto dcoutDto=mapper.getPwrRealDcOut(powerId); |
| | | return dcoutDto; |
| | | } |
| | | |
| | | } |
| | |
| | | int tableNum = subTablePageInfoService.judgeTable_pwrhis(table); |
| | | List<PwrHisRealAcInDto> list = new ArrayList(); |
| | | if (tableNum > 0) { |
| | | list=subTablePageInfoService.getHalfHourPwrHisAcinData(tableName, finalGranularity,recordDatetime,recordDatetime1); |
| | | //è·åæå®æ¶é´æ®µå
æå¤§æå°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.getHalfHourPwrHisAcinData(tableName, finalGranularity,recordDatetime,recordDatetime1,maxRecordNum,minRecordNum); |
| | | } |
| | | dataList.addAll(list); |
| | | latch.countDown(); |
| | |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | List dataListSorted = dataList.stream().sorted(Comparator.comparing(PwrHisRealAcInDto::getRecordDatetime)).collect(Collectors.toList()); |
| | | return new Response().setII(1,dataList.size()>0,dataListSorted,"è·ååå°æ¶å
交æµè¾å
¥ç»è®¡"); |
| | | |
| | | } |
| | | //ç³»ç»æ¦è§è·ååNç¬ç´æµè¾åºç»è®¡ |
| | | public Response getHalfHourPwrHisDcoutData(Integer powerId) { |
| | | String dateTime = ActionUtil.sdfwithOutday.format(new Date()); |
| | | public Response getHalfHourPwrHisDcoutData(Integer powerId) throws InterruptedException, ParseException { |
| | | //è·ååç¬æ°*æ¶é´é´é |
| | | PowerheartParam heartParam=heartService.getHeartParamByPowerId(powerId); |
| | | Integer interverCount=100*5;//é»è®¤å¼ |
| | | Integer granularity=5;//é»è®¤å¼ |
| | | if(heartParam!=null){ |
| | | interverCount=heartParam.getAcinInterverCfg()*heartParam.getAcinCountCfg(); |
| | | granularity=heartParam.getAcinInterverCfg(); |
| | | interverCount=heartParam.getAcoutInterverCfg()*heartParam.getAcoutCountCfg(); |
| | | granularity=heartParam.getAcoutInterverCfg();//é»è®¤æ¶é´é´éä¸åéä¸ç¬ï¼æä»¥æ¶é´é´éå°±æ¯å ç¬åä¸ç¬ |
| | | } |
| | | //è·åååä¸ªå°æ¶æ°æ® |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 计ç®åå°æ¶åçæ¶é´ç¹ |
| | | String dateTime = now.format(formatter); |
| | | Date endTime=ActionUtil.sdf.parse(dateTime); |
| | | // 计ç®ç¬æ°*æ¶é´é´éçæ¶é´ç¹ |
| | | LocalDateTime halfHourAgo = now.minusMinutes(interverCount); |
| | | // æ ¼å¼åè¾åº |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String halfHourAgoTime=halfHourAgo.format(formatter); |
| | | |
| | | String tableName ="db_data_history.tb_pwrdev_historydata_"+powerId+"_"+dateTime; |
| | | String existTableName = commonMapper.existTable("db_data_history", "tb_pwrdev_historydata_"+powerId+"_"+dateTime); |
| | | if(existTableName == null){ |
| | | return new Response().set(1,false,"å½åçµæºä¸åå¨åé¢å°æ¶æ°æ®"); |
| | | Date startTime=ActionUtil.sdf.parse(halfHourAgoTime); |
| | | //è·å两个æ¶é´åå²å¤å°å¼ 表 |
| | | List<List<Date>> monthTimeList = DateUtil.getMonthTime(startTime,endTime); |
| | | 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.getHalfHourPwrHisDcoutData(tableName, finalGranularity,recordDatetime,recordDatetime1,maxRecordNum,minRecordNum); |
| | | } |
| | | dataList.addAll(list); |
| | | latch.countDown(); |
| | | }); |
| | | sleep(200); |
| | | } |
| | | List<PwrHisRealDcoutInDto> datalist=subTablePageInfoService.getHalfHourPwrHisDcoutData(tableName,granularity,halfHourAgoTime); |
| | | latch.await(10, TimeUnit.MINUTES); |
| | | List dataListSorted = dataList.stream().sorted(Comparator.comparing(PwrHisRealDcoutInDto::getRecordDatetime)).collect(Collectors.toList()); |
| | | Long modelCfg=0l; |
| | | PowerInf pinf=powerInfService.getPowerInfById(powerId); |
| | | if(pinf!=null){ |
| | | modelCfg=pinf.getModelCfg(); |
| | | } |
| | | return new Response().setIII(1,datalist.size()>0,datalist,modelCfg,"è·ååå°æ¶å
ç´æµè¾åºç»è®¡"); |
| | | return new Response().setIII(1,dataList.size()>0,dataListSorted,modelCfg,"è·ååå°æ¶å
ç´æµè¾åºç»è®¡"); |
| | | } |
| | | //1.2.7ä¼è¯çµæºç»è®¡ä¸ä¸å£åº¦ççµæºæä¸å±æ§ååæ°éå¼è¶
è¿çæ¬¡æ° |
| | | public Integer getPwrQuarter7(Integer powerId,Integer powerType) throws NoSuchFieldException, IllegalAccessException { |
| | |
| | | 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<PwrHisRealAcInDto> getHalfHourPwrHisAcinData(String tableName,Integer granularity,Date recordDatetime,Date recordDatetime1) { |
| | | public List<PwrHisRealAcInDto> getHalfHourPwrHisAcinData(String tableName,Integer granularity,Date recordDatetime,Date recordDatetime1,Integer maxRecordNum,Integer minRecordNum) { |
| | | String sql=" select distinct record_datetime,acin1_vola,acin1_volb,acin1_volc,acin2_vola,acin2_volb,acin2_volc " + |
| | | " ,acin1_curra,acin1_currb,acin1_currc,acin2_curra,acin2_currb,acin2_currc " + |
| | | " from "+tableName+" where record_datetime>='"+ActionUtil.sdf.format(recordDatetime)+"'" + |
| | | " and record_datetime<='"+ActionUtil.sdf.format(recordDatetime1)+ |
| | | "' and record_num%"+granularity+"=0 or record_num=1 or record_num=100 "; |
| | | sql+=" order by record_datetime asc"; |
| | | "' and (record_num-"+minRecordNum+")%"+granularity+"=0 or record_num="+minRecordNum+" or record_num="+maxRecordNum; |
| | | sql+=" order by record_datetime asc"; |
| | | List<PwrHisRealAcInDto> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | |
| | | return list; |
| | | } |
| | | |
| | | public List<PwrHisRealDcoutInDto> getHalfHourPwrHisDcoutData(String tableName,Integer granularity,String halfHourAgoTime) { |
| | | public List<PwrHisRealDcoutInDto> getHalfHourPwrHisDcoutData(String tableName,Integer granularity,Date recordDatetime,Date recordDatetime1,Integer maxRecordNum,Integer minRecordNum) { |
| | | String sql="select distinct * " + |
| | | "from (select a.*, (@i:= @i+1) as number " + |
| | | " from (select * from "+tableName+" "+ |
| | | " where record_datetime>='"+halfHourAgoTime+"') a, " + |
| | | " (select @i:=0) b) c "+ |
| | | " where c.number%"+granularity+"=0 or c.number=1 "; |
| | | " 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<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<RealDateDTO> getBattRealDataHis(BattRealdataId realdata, int granularity,Integer maxRecordNum,Integer minRecordNum) { |
| | | String sql=" select record_time, group_vol, online_vol,group_curr, mon_vol, mon_tmp, mon_res, mon_num,record_num " + |
| | | String sql=" select record_time, group_vol, online_vol,group_curr,load_curr, mon_vol, mon_tmp, mon_res, mon_num,record_num " + |
| | | " from db_data_history.tb_batt_realdata_"+realdata.getTableName()+" " + |
| | | " where record_time >= '"+ThreadLocalUtil.format(realdata.getRecordTime(),1)+"' " + |
| | | " and record_time <= '"+ThreadLocalUtil.format(realdata.getRecordTime1(),1)+"' "+ |
| | |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | //ç³»ç»æ¦è§è·ååNç¬æ ¸å®¹è®¾å¤ä¿¡æ¯ |
| | | public List<RealDateDTO> getBattDevData100(String tableName, Integer granularity, Date recordDatetime, Date recordDatetime1,Integer maxRecordNum,Integer minRecordNum) { |
| | | String sql=" select record_time, group_vol, online_vol,group_curr, load_curr,record_num " + |
| | | " from "+tableName+" " + |
| | | " where record_time >= '"+ThreadLocalUtil.format(recordDatetime,1)+"' " + |
| | | " and record_time <= '"+ThreadLocalUtil.format(recordDatetime1,1)+"' "+ |
| | | " and (record_num-"+minRecordNum+")%"+granularity+"=0 or record_num="+minRecordNum+" or record_num="+maxRecordNum ; |
| | | List<RealDateDTO> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List<RealDateDTO> list=new ArrayList<>(); |
| | | while (rs.next()){ |
| | | RealDateDTO ph=new RealDateDTO(); |
| | | ph.setRecordTime(rs.getTimestamp("record_time")); |
| | | ph.setGroupVol(rs.getFloat("group_vol")); |
| | | ph.setOnlineVol(rs.getFloat("online_vol")); |
| | | ph.setGroupCurr(rs.getFloat("group_curr")); |
| | | ph.setLoadCurr(rs.getFloat("load_curr")); |
| | | ph.setRecordNum(rs.getInt("record_num")); |
| | | list.add(ph); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | //çµæ± æ°æ®åå²å®æ¶å¤ç(é¢è¦åæ) |
| | | public List<ResAnalysis> getBattHisRealInAlm(BattRealdataId realdata, Map<String,Integer> battMap) { |
| | | public List<ResAnalysis> getBattHisRealInAlm(BattRealdataId realdata, Map<String,Object> battMap) { |
| | | String result = String.join(",", battMap.keySet()); |
| | | String sql=" select record_time,"+result+" " + |
| | | " from db_data_history.tb_batt_realdata_"+realdata.getTableName()+" " + |
| | |
| | | ph.setRecordTime(rs.getTimestamp("record_time")); |
| | | int i=1; |
| | | for (String key : battMap.keySet()) { |
| | | Integer dataType = battMap.get(key); |
| | | Integer dataType = (Integer) battMap.get(key); |
| | | try { |
| | | String propertyType = "dataType"+(i); |
| | | Field fieldType = ResAnalysis.class.getDeclaredField(propertyType); |
| | |
| | | } |
| | | |
| | | //çµæºæ°æ®åå²å®æ¶å¤ç(é¢è¦åæ) |
| | | public List<ResAnalysis> getPwrHisRealInAlm(PwrdevHistorydataId pwrHis, Map<String,Integer> pwrMap) { |
| | | public List<ResAnalysis> getPwrHisRealInAlm(PwrdevHistorydataId pwrHis, Map<String,Object> pwrMap) { |
| | | String result = String.join(",", pwrMap.keySet()); |
| | | String sql=" select record_datetime,"+result+" " + |
| | | " from db_data_history.tb_pwrdev_historydata_"+pwrHis.getTableName()+" " + |
| | |
| | | ph.setRecordTime(rs.getTimestamp("record_datetime")); |
| | | int i=1; |
| | | for (String key : pwrMap.keySet()) { |
| | | Integer dataType = pwrMap.get(key); |
| | | Integer dataType = (Integer) pwrMap.get(key); |
| | | try { |
| | | String propertyType = "dataType"+(i); |
| | | Field fieldType = ResAnalysis.class.getDeclaredField(propertyType); |
| | |
| | | }); |
| | | return list; |
| | | } |
| | | //è·åæå®æ¶é´æ®µå
æå¤§æå°recordNumç¡®ä¿æ°æ®ç宿´ |
| | | public List getMaxAndMinRecordNum(BattRealdataId realdata) { |
| | | //è·åçµæ± ç»æå®æ¶é´æ®µå
æå¤§æå°recordNumç¡®ä¿æ°æ®ç宿´ |
| | | public List getBattMaxAndMinRecordNum(String tableName, Date recordDatetime, Date recordDatetime1) { |
| | | String sql="select max(record_num) as maxRecordNum,min(record_num) as minRecordNum " + |
| | | " from db_data_history.tb_batt_realdata_" + realdata.getTableName()+" " + |
| | | " where record_time >= '"+ThreadLocalUtil.format(realdata.getRecordTime(),1)+"' " + |
| | | " and record_time <= '"+ThreadLocalUtil.format(realdata.getRecordTime1(),1)+"' " + |
| | | " from " + tableName+" " + |
| | | " where record_time >= '"+ThreadLocalUtil.format(recordDatetime,1)+"' " + |
| | | " and record_time <= '"+ThreadLocalUtil.format(recordDatetime1,1)+"' " + |
| | | " limit 1"; |
| | | List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | //è·åçµæºæå®æ¶é´æ®µå
æå¤§æå°recordNumç¡®ä¿æ°æ®ç宿´ |
| | | public List getPwrMaxAndMinRecordNum(String tableName, Date recordDatetime, Date recordDatetime1) { |
| | | String sql="select max(record_num) as maxRecordNum,min(record_num) as minRecordNum " + |
| | | " from " + tableName+" " + |
| | | " where record_datetime >= '"+ThreadLocalUtil.format(recordDatetime,1)+"' " + |
| | | " and record_datetime <= '"+ThreadLocalUtil.format(recordDatetime1,1)+"' " + |
| | | " limit 1"; |
| | | List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List list = new ArrayList<>(); |
| | | while (rs.next()) { |
| | | list.add(rs.getInt("maxRecordNum")); |
| | | list.add(rs.getInt("minRecordNum")); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | //1.2.7ä¼è¯çµæºç»è®¡ä¸ä¸å£åº¦ççµæºæä¸å±æ§ååæ°éå¼è¶
è¿çæ¬¡æ° |
| | | public List<PwrdevHistorydataId> getPwrQuarter7(String tableName,List<String> propertyNameList) { |
| | |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.webSocket; |
| | | |
| | | import com.whyc.config.WebSocketConfig; |
| | | import com.whyc.dto.Real.PwrHisRealAcInDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_param.PowerheartParam; |
| | | import com.whyc.service.PowerheartParamService; |
| | | import com.whyc.service.PwrdevAcdcdataService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.websocket.*; |
| | | import javax.websocket.server.ServerEndpoint; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 宿¶æ¨éçµæºäº¤æµè¾å
¥å¿è·³äº¤æµè¾å
¥æ°æ® |
| | | */ |
| | | @Component |
| | | @ServerEndpoint(value = "/acin",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class) |
| | | public class HeartAcInSocket { |
| | | private Session session; |
| | | |
| | | private Thread thread; |
| | | |
| | | private static PwrdevAcdcdataService acdcdataService; |
| | | |
| | | private static PowerheartParamService pwrHeartService; |
| | | |
| | | private static HttpSession httpSession; |
| | | |
| | | private volatile boolean runFlag = true; |
| | | |
| | | private volatile Map<String, Thread> threadMap = new HashMap<>(); |
| | | |
| | | private volatile Map<Long,Boolean> threadFlagMap = new HashMap<>(); |
| | | |
| | | @Autowired |
| | | public void setPwrdevAcdcdataService(PwrdevAcdcdataService service) { |
| | | HeartAcInSocket.acdcdataService = service; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setPowerheartParamService(PowerheartParamService service) { |
| | | HeartAcInSocket.pwrHeartService = service; |
| | | } |
| | | |
| | | @OnOpen |
| | | public void onOpen(Session session, EndpointConfig config) { |
| | | this.session = session; |
| | | this.httpSession = (HttpSession) config.getUserProperties().get("httpSession"); |
| | | } |
| | | @OnMessage |
| | | public void onMessage(Session session, String message) { |
| | | Integer powerId = Integer.valueOf(message); |
| | | thread = new Thread("Thread_HeartacinSocket") { |
| | | @Override |
| | | public void run() { |
| | | while (runFlag && !isInterrupted()) { |
| | | Thread thread = currentThread(); |
| | | threadFlagMap.put(thread.getId(), true); |
| | | try { |
| | | PwrHisRealAcInDto acinDto = acdcdataService.getPwrRealAcIn(powerId); |
| | | if (session.isOpen()) { |
| | | //æ¨éä¿¡æ¯ |
| | | synchronized (session) { |
| | | session.getBasicRemote().sendObject(new Response<>().setII(1,acinDto!=null,acinDto,"çµæºäº¤æµè¾å
¥æ°æ®")); |
| | | } |
| | | threadFlagMap.put(thread.getId(), false); |
| | | } |
| | | PowerheartParam powerheartParam=pwrHeartService.getHeartParamByPowerId(powerId); |
| | | sleep(1000*60*powerheartParam.getAcinInterverCfg()); |
| | | } catch (Exception e) { |
| | | interrupt(); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | thread.start(); |
| | | threadFlagMap.put(thread.getId(),true); |
| | | //忢èçsocketçº¿ç¨ |
| | | Thread threadBefore = threadMap.get(session.getId()); |
| | | if(threadBefore !=null && threadBefore.isAlive()){ |
| | | while (threadFlagMap.get(threadBefore.getId())){ |
| | | } |
| | | threadBefore.interrupt(); |
| | | } |
| | | //å°çº¿ç¨åå¨,便äºè°ç¨å®ä½ |
| | | threadMap.put(session.getId(), this.thread); |
| | | } |
| | | @OnClose |
| | | public void onClose(CloseReason closeReason){ |
| | | System.err.println("closeReason = " + closeReason); |
| | | runFlag = false; |
| | | if (thread != null && thread.isAlive()) { |
| | | thread.interrupt(); |
| | | } |
| | | threadMap.remove(session.getId()); |
| | | } |
| | | |
| | | @OnError |
| | | public void onError(Throwable error) { |
| | | error.printStackTrace(); |
| | | if (thread != null && thread.isAlive()) { |
| | | thread.interrupt(); |
| | | } |
| | | threadMap.remove(session.getId()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.webSocket; |
| | | |
| | | import com.whyc.config.WebSocketConfig; |
| | | import com.whyc.dto.Real.PwrHisRealAcInDto; |
| | | import com.whyc.dto.Real.PwrHisRealDcoutInDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_param.PowerheartParam; |
| | | import com.whyc.service.PowerheartParamService; |
| | | import com.whyc.service.PwrdevAcdcdataService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.websocket.*; |
| | | import javax.websocket.server.ServerEndpoint; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 宿¶æ¨éçµæºç´æµè¾åºå¿è·³äº¤æµè¾å
¥æ°æ® |
| | | */ |
| | | @Component |
| | | @ServerEndpoint(value = "/acout",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class) |
| | | public class HeartAcOutSocket { |
| | | private Session session; |
| | | |
| | | private Thread thread; |
| | | |
| | | private static PwrdevAcdcdataService acdcdataService; |
| | | |
| | | private static PowerheartParamService pwrHeartService; |
| | | |
| | | private static HttpSession httpSession; |
| | | |
| | | private volatile boolean runFlag = true; |
| | | |
| | | private volatile Map<String, Thread> threadMap = new HashMap<>(); |
| | | |
| | | private volatile Map<Long,Boolean> threadFlagMap = new HashMap<>(); |
| | | |
| | | @Autowired |
| | | public void setPwrdevAcdcdataService(PwrdevAcdcdataService service) { |
| | | HeartAcOutSocket.acdcdataService = service; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setPowerheartParamService(PowerheartParamService service) { |
| | | HeartAcOutSocket.pwrHeartService = service; |
| | | } |
| | | |
| | | @OnOpen |
| | | public void onOpen(Session session, EndpointConfig config) { |
| | | this.session = session; |
| | | this.httpSession = (HttpSession) config.getUserProperties().get("httpSession"); |
| | | } |
| | | @OnMessage |
| | | public void onMessage(Session session, String message) { |
| | | Integer powerId = Integer.valueOf(message); |
| | | thread = new Thread("Thread_HeartacoutSocket") { |
| | | @Override |
| | | public void run() { |
| | | while (runFlag && !isInterrupted()) { |
| | | Thread thread = currentThread(); |
| | | threadFlagMap.put(thread.getId(), true); |
| | | try { |
| | | PwrHisRealDcoutInDto dcoutDto = acdcdataService.getPwrRealDcOut(powerId); |
| | | if (session.isOpen()) { |
| | | //æ¨éä¿¡æ¯ |
| | | synchronized (session) { |
| | | session.getBasicRemote().sendObject(new Response<>().setII(1,dcoutDto!=null,dcoutDto,"çµæºç´æµè¾åºæ°æ®")); |
| | | } |
| | | threadFlagMap.put(thread.getId(), false); |
| | | } |
| | | PowerheartParam powerheartParam=pwrHeartService.getHeartParamByPowerId(powerId); |
| | | sleep(1000*60*powerheartParam.getAcoutInterverCfg()); |
| | | } catch (Exception e) { |
| | | interrupt(); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | thread.start(); |
| | | threadFlagMap.put(thread.getId(),true); |
| | | //忢èçsocketçº¿ç¨ |
| | | Thread threadBefore = threadMap.get(session.getId()); |
| | | if(threadBefore !=null && threadBefore.isAlive()){ |
| | | while (threadFlagMap.get(threadBefore.getId())){ |
| | | } |
| | | threadBefore.interrupt(); |
| | | } |
| | | //å°çº¿ç¨åå¨,便äºè°ç¨å®ä½ |
| | | threadMap.put(session.getId(), this.thread); |
| | | } |
| | | @OnClose |
| | | public void onClose(CloseReason closeReason){ |
| | | System.err.println("closeReason = " + closeReason); |
| | | runFlag = false; |
| | | if (thread != null && thread.isAlive()) { |
| | | thread.interrupt(); |
| | | } |
| | | threadMap.remove(session.getId()); |
| | | } |
| | | |
| | | @OnError |
| | | public void onError(Throwable error) { |
| | | error.printStackTrace(); |
| | | if (thread != null && thread.isAlive()) { |
| | | thread.interrupt(); |
| | | } |
| | | threadMap.remove(session.getId()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.webSocket; |
| | | |
| | | import com.whyc.config.WebSocketConfig; |
| | | import com.whyc.dto.Real.PwrHisRealDcoutInDto; |
| | | import com.whyc.dto.Real.RealDateDTO; |
| | | import com.whyc.dto.Real.RealHeart; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_param.PowerheartParam; |
| | | import com.whyc.pojo.db_ram_db.BattRtdata; |
| | | import com.whyc.pojo.db_ram_db.BattRtstate; |
| | | import com.whyc.service.BattRtdataService; |
| | | import com.whyc.service.BattRtstateService; |
| | | import com.whyc.service.PowerheartParamService; |
| | | import com.whyc.service.PwrdevAcdcdataService; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.websocket.*; |
| | | import javax.websocket.server.ServerEndpoint; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 宿¶æ¨éçµæ± æ ¸å®¹è®¾å¤å¿è·³æ°æ® |
| | | */ |
| | | @Component |
| | | @ServerEndpoint(value = "/hr",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class) |
| | | public class HeartHrSocket { |
| | | private Session session; |
| | | |
| | | private Thread thread; |
| | | |
| | | private static BattRtstateService rtstateService; |
| | | |
| | | |
| | | private static PowerheartParamService pwrHeartService; |
| | | |
| | | private static HttpSession httpSession; |
| | | |
| | | private volatile boolean runFlag = true; |
| | | |
| | | private volatile Map<String, Thread> threadMap = new HashMap<>(); |
| | | |
| | | private volatile Map<Long,Boolean> threadFlagMap = new HashMap<>(); |
| | | |
| | | @Autowired |
| | | public void setBattRtstateService(BattRtstateService service) { |
| | | HeartHrSocket.rtstateService = service; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | public void setPowerheartParamService(PowerheartParamService service) { |
| | | HeartHrSocket.pwrHeartService = service; |
| | | } |
| | | |
| | | @OnOpen |
| | | public void onOpen(Session session, EndpointConfig config) { |
| | | this.session = session; |
| | | this.httpSession = (HttpSession) config.getUserProperties().get("httpSession"); |
| | | } |
| | | @OnMessage |
| | | public void onMessage(Session session, String message) { |
| | | RealHeart heart= ActionUtil.getGson().fromJson(message,RealHeart.class); |
| | | thread = new Thread("Thread_HeartacoutSocket") { |
| | | @Override |
| | | public void run() { |
| | | while (runFlag && !isInterrupted()) { |
| | | Thread thread = currentThread(); |
| | | threadFlagMap.put(thread.getId(), true); |
| | | try { |
| | | RealDateDTO hrdto=rtstateService.getBattRealHr(heart.getBattgroupId()); |
| | | if (session.isOpen()) { |
| | | //æ¨éä¿¡æ¯ |
| | | synchronized (session) { |
| | | session.getBasicRemote().sendObject(new Response<>().setII(1,hrdto!=null,hrdto,"çµæºç´æµè¾åºæ°æ®")); |
| | | } |
| | | threadFlagMap.put(thread.getId(), false); |
| | | } |
| | | PowerheartParam powerheartParam=pwrHeartService.getHeartParamByPowerId(heart.getPowerId()); |
| | | sleep(1000*60*powerheartParam.getHrInterverCfg()); |
| | | } catch (Exception e) { |
| | | interrupt(); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | thread.start(); |
| | | threadFlagMap.put(thread.getId(),true); |
| | | //忢èçsocketçº¿ç¨ |
| | | Thread threadBefore = threadMap.get(session.getId()); |
| | | if(threadBefore !=null && threadBefore.isAlive()){ |
| | | while (threadFlagMap.get(threadBefore.getId())){ |
| | | } |
| | | threadBefore.interrupt(); |
| | | } |
| | | //å°çº¿ç¨åå¨,便äºè°ç¨å®ä½ |
| | | threadMap.put(session.getId(), this.thread); |
| | | } |
| | | @OnClose |
| | | public void onClose(CloseReason closeReason){ |
| | | System.err.println("closeReason = " + closeReason); |
| | | runFlag = false; |
| | | if (thread != null && thread.isAlive()) { |
| | | thread.interrupt(); |
| | | } |
| | | threadMap.remove(session.getId()); |
| | | } |
| | | |
| | | @OnError |
| | | public void onError(Throwable error) { |
| | | error.printStackTrace(); |
| | | if (thread != null && thread.isAlive()) { |
| | | thread.interrupt(); |
| | | } |
| | | threadMap.remove(session.getId()); |
| | | } |
| | | } |
| | |
| | | <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 |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.whyc.mapper.BattRtstateMapper"> |
| | | |
| | | <select id="getBattRealHr" resultType="com.whyc.dto.Real.RealDateDTO"> |
| | | select * from db_ram_db.tb_batt_rtstate |
| | | where battgroup_id=#{battgroupId} |
| | | limit 1 |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.whyc.mapper.PwrdevAcdcdataMapper"> |
| | | |
| | | <select id="getPwrRealAcIn" resultType="com.whyc.dto.Real.PwrHisRealAcInDto"> |
| | | select record_datetime,acin1_vola,acin1_volb,acin1_volc,acin2_vola,acin2_volb,acin2_volc,acin1_curra,acin1_currb,acin1_currc,acin2_curra,acin2_currb,acin2_currc |
| | | from db_ram_db.tb_pwrdev_acdcdata |
| | | where power_id=#{powerId} |
| | | limit 1 |
| | | </select> |
| | | <select id="getPwrRealDcOut" resultType="com.whyc.dto.Real.PwrHisRealDcoutInDto"> |
| | | select * |
| | | from db_ram_db.tb_pwrdev_acdcdata |
| | | where power_id=#{powerId} |
| | | limit 1 |
| | | </select> |
| | | </mapper> |