更新摄像头温度及历史,温度告警参数设置,温度告警实时及历史
New file |
| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_alarm.BattStationTempAlarm; |
| | | import com.whyc.service.BattStationTempAlarmService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | @RestController |
| | | @Api(tags = "电池机房温度告警") |
| | | @RequestMapping("battStationTempAlarm") |
| | | public class BattStationTempAlarmController { |
| | | |
| | | @Autowired |
| | | private BattStationTempAlarmService service; |
| | | |
| | | @ApiOperation("查询分页-实时温度") |
| | | @GetMapping("getPage") |
| | | public Response<PageInfo<BattStationTempAlarm>> getPage(@RequestParam int pageNum,@RequestParam int pageSize, |
| | | @RequestParam(required = false) Integer level){ |
| | | return service.getPage(pageNum,pageSize,level); |
| | | } |
| | | |
| | | @ApiOperation("查询分页-历史温度") |
| | | @GetMapping("getHisPage") |
| | | public Response<PageInfo<BattStationTempAlarm>> getHisPage(@RequestParam int pageNum,@RequestParam int pageSize, |
| | | @RequestParam(required = false) Integer level){ |
| | | return service.getHisPage(pageNum,pageSize,level); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_power_rt.BattStationTemp; |
| | | import com.whyc.service.BattStationTempService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @Api(tags = "电池机房温度实时") |
| | | @RequestMapping("battStationTemp") |
| | | public class BattStationTempController { |
| | | |
| | | @Autowired |
| | | private BattStationTempService service; |
| | | |
| | | @ApiOperation("查询列表-实时温度") |
| | | @GetMapping("getList") |
| | | public Response<List<BattStationTemp>> getList(){ |
| | | return service.getList(); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_param.PageParam; |
| | | import com.whyc.service.PageParamService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @Api(tags = "页面参数") |
| | | @RequestMapping("pageParam") |
| | | public class PageParamController { |
| | | |
| | | @Autowired |
| | | private PageParamService service; |
| | | |
| | | @ApiOperation("查询温度参数列表") |
| | | @GetMapping("getTempParmList") |
| | | public Response<List<PageParam>> getTempParmList(){ |
| | | List<PageParam> tempParmList = service.getTempParmList(); |
| | | return new Response<List<PageParam>>().set(1,tempParmList); |
| | | } |
| | | |
| | | @ApiOperation("修改参数") |
| | | @PostMapping("updateById") |
| | | public Response updateById(@RequestBody PageParam param){ |
| | | return service.updateById(param); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.db_alarm.BattStationTempAlarm; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface BattStationTempAlarmMapper extends CustomMapper<BattStationTempAlarm>{ |
| | | |
| | | List<BattStationTempAlarm> getList(Integer level); |
| | | |
| | | List<BattStationTempAlarm> getHisList(Integer level); |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.db_power_rt.BattStationTemp; |
| | | |
| | | public interface BattStationTempMapper extends CustomMapper<BattStationTemp>{ |
| | | } |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.db_param.PageParam; |
| | | |
| | | public interface PageParamMapper extends CustomMapper<PageParam>{ |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_alarm; |
| | | |
| | | 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; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 电池机房温度告警,八个电池机房 |
| | | */ |
| | | @ApiModel(value="电池机房温度告警") |
| | | @TableName(schema = "db_alarm",value = "tb_alarm_temp_alarm") |
| | | @Data |
| | | @ToString |
| | | public class BattStationTempAlarm { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | private Integer stationId; |
| | | |
| | | private Integer battGroupId; |
| | | |
| | | private Float temp; |
| | | |
| | | @ApiModelProperty("温度坐标") |
| | | private String point; |
| | | |
| | | @ApiModelProperty("分辨率,格式示例:384*288") |
| | | private String pixel; |
| | | |
| | | @ApiModelProperty("单体编号") |
| | | private Integer monNum; |
| | | |
| | | private Date startTime; |
| | | |
| | | private Date endTime; |
| | | |
| | | @TableField(exist = false) |
| | | private String battGroupName; |
| | | |
| | | @TableField(exist = false) |
| | | private String stationName; |
| | | |
| | | @TableField(exist = false) |
| | | private String powerName; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_param; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 页面参数 |
| | | */ |
| | | @ApiModel(value="页面参数") |
| | | @TableName(schema = "db_param",value = "tb_page_param") |
| | | @Data |
| | | @ToString |
| | | public class PageParam { |
| | | |
| | | private Integer id; |
| | | private String name; |
| | | private Integer value; |
| | | |
| | | private Integer categoryId; |
| | | |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_power_history; |
| | | |
| | | public class BattStationTempHistory { |
| | | } |
New file |
| | |
| | | package com.whyc.pojo.db_power_rt; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.whyc.dto.Point; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 电池机房温度实时 |
| | | */ |
| | | @TableName(schema = "db_power_rt",value = "tb_batt_station_temp") |
| | | @ApiModel(value="电池机房温度实时") |
| | | @Data |
| | | @ToString |
| | | public class BattStationTemp { |
| | | |
| | | private Integer id; |
| | | |
| | | private Integer pixelX; |
| | | |
| | | private Integer pixelY; |
| | | |
| | | private Float minTemp; |
| | | private Float maxTemp; |
| | | |
| | | private String minTempPoint; |
| | | private String maxTempPoint; |
| | | private String cameraId; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date recordTime; |
| | | |
| | | /**最高温度点跟磁条轨道的最短距离的点 x*y */ |
| | | private String mtCrossMstPoint; |
| | | |
| | | /**最高温度跟磁条的最短距离,垂直距离*/ |
| | | private String mtCrossMstDistance; |
| | | |
| | | /**最高温度在磁条的左边/右边,值为false或者right*/ |
| | | private String mtpMstDirection; |
| | | |
| | | @TableField(exist = false) |
| | | private List<Point> minTempPointList; |
| | | |
| | | @TableField(exist = false) |
| | | private List<Point> maxTempPointList; |
| | | |
| | | @TableField(exist = false) |
| | | private List<Point> mtCrossMstPointList; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattStationTempAlarmMapper; |
| | | import com.whyc.pojo.db_alarm.BattStationTempAlarm; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class BattStationTempAlarmService { |
| | | |
| | | @Resource |
| | | private BattStationTempAlarmMapper mapper; |
| | | |
| | | public Response<PageInfo<BattStationTempAlarm>> getPage(int pageNum, int pageSize, Integer level) { |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<BattStationTempAlarm> list = mapper.getList(level); |
| | | PageInfo<BattStationTempAlarm> pageInfo = new PageInfo<>(list); |
| | | return new Response<PageInfo<BattStationTempAlarm>>().set(1,pageInfo); |
| | | } |
| | | |
| | | public Response<PageInfo<BattStationTempAlarm>> getHisPage(int pageNum, int pageSize, Integer level) { |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<BattStationTempAlarm> list = mapper.getHisList(level); |
| | | PageInfo<BattStationTempAlarm> pageInfo = new PageInfo<>(list); |
| | | return new Response<PageInfo<BattStationTempAlarm>>().set(1,pageInfo); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.whyc.dto.Point; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattStationTempMapper; |
| | | import com.whyc.pojo.db_power_rt.BattStationTemp; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class BattStationTempService { |
| | | |
| | | @Resource |
| | | private BattStationTempMapper mapper; |
| | | |
| | | public Response<List<BattStationTemp>> getList() { |
| | | List<BattStationTemp> list = mapper.selectList((Wrapper<BattStationTemp>) ActionUtil.objeNull); |
| | | //对温度坐标进行解析,minTempPoint格式为"1*2,2*3",把里面所有的x*y点 拆解到Point(x,y)列表中 |
| | | list.stream().forEach(battStationTemp -> { |
| | | String minTempPointStr = battStationTemp.getMinTempPoint(); |
| | | if(minTempPointStr!=null&&!minTempPointStr.equals("")){ |
| | | String[] split = minTempPointStr.split(","); |
| | | for (String s : split) { |
| | | String[] split1 = s.split("\\*"); |
| | | battStationTemp.getMinTempPointList().add(new Point(Integer.parseInt(split1[0]),Integer.parseInt(split1[1]))); |
| | | } |
| | | } |
| | | String maxTempPointStr = battStationTemp.getMaxTempPoint(); |
| | | if(maxTempPointStr!=null&&!maxTempPointStr.equals("")){ |
| | | String[] split = maxTempPointStr.split(","); |
| | | for (String s : split) { |
| | | String[] split1 = s.split("\\*"); |
| | | Point p = new Point(Integer.parseInt(split1[0]), Integer.parseInt(split1[1])); |
| | | //对于最高温度点 p(a,b) |
| | | //TODO 已知坐标点两点为p1(a1,b1)和p2(a2,b2), 求 maxTempPoint点与p1p2组成的线垂直相交的点p3的坐标计算方式 |
| | | |
| | | battStationTemp.getMaxTempPointList().add(p); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | return new Response<List<BattStationTemp>>().set(1,list); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.apache.poi.xssf.usermodel.XSSFSheet; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | |
| | | @Service |
| | | public class ExcelService { |
| | | |
| | | public void dcReport() throws IOException { |
| | | String filePath = "C:\\Users\\29550\\Desktop\\当前项目\\2023\\0智能机器人运维系统\\测试.xlsx"; |
| | | //创建一个工作簿 |
| | | XSSFWorkbook workbook = new XSSFWorkbook(); |
| | | //创建sheet1 |
| | | createSheet1(workbook); |
| | | |
| | | |
| | | |
| | | // 将工作簿写入文件 |
| | | FileOutputStream fileOut = new FileOutputStream(filePath); |
| | | workbook.write(fileOut); |
| | | |
| | | // 关闭工作簿 |
| | | workbook.close(); |
| | | |
| | | } |
| | | |
| | | private void createSheet1(XSSFWorkbook workbook) { |
| | | XSSFSheet sheet = workbook.createSheet("放电充电电压数据报表"); |
| | | //总的列数根据 放电时长和充电时长决定 |
| | | Date dischargeStartTime = ThreadLocalUtil.parse("2023-01-01 11:00:00", 1); |
| | | Date dischargeEndTime = ThreadLocalUtil.parse("2023-01-02 01:00:00", 1); |
| | | //查询时长,按小时 |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.PageParamMapper; |
| | | import com.whyc.pojo.db_param.PageParam; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class PageParamService { |
| | | |
| | | @Resource |
| | | private PageParamMapper mapper; |
| | | |
| | | public List<PageParam> getTempParmList() { |
| | | QueryWrapper<PageParam> query = Wrappers.query(); |
| | | query.eq("category_id",1); |
| | | query.orderByAsc("id"); |
| | | return mapper.selectList(query); |
| | | } |
| | | |
| | | |
| | | public Response updateById(PageParam param) { |
| | | param.setUpdateTime(new Date()); |
| | | mapper.updateById(param); |
| | | return new Response().setII(1,"修改完成"); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.util; |
| | | |
| | | import com.whyc.dto.Point; |
| | | |
| | | public class PointUtil { |
| | | public static void main(String[] args) { |
| | | double a1 = 1, b1 = 2; |
| | | double a2 = 3, b2 = 4; |
| | | double x0 = 9, y0 = 9; |
| | | Point p1 = new Point(1, 2); |
| | | Point p2 = new Point(3, 4); |
| | | Point p0 = new Point(9, 9); |
| | | |
| | | Point p = findIntersection2(p1, p2, p0); |
| | | System.out.println(p); |
| | | |
| | | double[] p3 = findIntersection(a1, b1, a2, b2, x0, y0); |
| | | System.out.println("Intersection Point P3: (" + p3[0] + ", " + p3[1] + ")"); |
| | | |
| | | String position = determinePosition(a1, b1, a2, b2, x0, y0); |
| | | System.out.println("Point P is on the " + position + " of the line P1P2."); |
| | | } |
| | | |
| | | public static double[] findIntersection(double a1, double b1, double a2, double b2, double x0, double y0) { |
| | | // 检查 p1p2 是否为垂直线 |
| | | if (a2 == a1) { |
| | | return new double[]{a1, y0}; |
| | | } |
| | | |
| | | // 检查 p1p2 是否为水平线 |
| | | if (b2 == b1) { |
| | | return new double[]{x0, b1}; |
| | | } |
| | | double m = (b2 - b1) / (a2 - a1); |
| | | double mPerpendicular = (a1 - a2) / (b2 - b1); |
| | | |
| | | double x = ((b1 - m * a1) - (y0 - mPerpendicular * x0)) / (mPerpendicular - m); |
| | | double y = m * x + (b1 - m * a1); |
| | | |
| | | return new double[]{x, y}; |
| | | } |
| | | |
| | | public static Point findIntersection2(Point p1, Point p2, Point p0) { |
| | | // 检查 p1p2 是否为垂直线 |
| | | int a1 = p1.getX(); |
| | | int b1 = p1.getY(); |
| | | |
| | | int a2 = p2.getX(); |
| | | int b2 = p2.getY(); |
| | | |
| | | int x0 = p0.getX(); |
| | | int y0 = p0.getY(); |
| | | |
| | | if (a2 == a1) { |
| | | return new Point(a1, y0); |
| | | } |
| | | |
| | | // 检查 p1p2 是否为水平线 |
| | | if (b2 == b1) { |
| | | return new Point(x0, b1); |
| | | } |
| | | double m = (b2 - b1) / (a2 - a1); |
| | | double mPerpendicular = (a1 - a2) / (b2 - b1); |
| | | |
| | | double x = ((b1 - m * a1) - (y0 - mPerpendicular * x0)) / (mPerpendicular - m); |
| | | double y = m * x + (b1 - m * a1); |
| | | |
| | | return new Point((int) x, (int) y); |
| | | } |
| | | public static String determinePosition(double a1, double b1, double a2, double b2, double x0, double y0) { |
| | | double cross = (a2 - a1) * (y0 - b1) - (x0 - a1) * (b2 - b1); |
| | | if (cross > 0) { |
| | | return "left"; |
| | | } else if (cross < 0) { |
| | | return "right"; |
| | | } else { |
| | | return "line"; |
| | | } |
| | | } |
| | | } |
| | | |
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.BattStationTempAlarmMapper" > |
| | | |
| | | |
| | | <select id="getList" resultType="com.whyc.pojo.db_alarm.BattStationTempAlarm"> |
| | | select a.*,p.binf_name as battGroupName,p.power_name as powerName,s.sinf_name as stationName from db_alarm.tb_batt_station_temp_alarm a,db_batt.power_inf p,db_batt.station_inf s |
| | | where a.batt_group_id = p.binf_id |
| | | and a.station_id = s.sinf_id |
| | | and a.end_time is null |
| | | <if test="level!=null"> |
| | | and a.level = #{level} |
| | | </if> |
| | | </select> |
| | | <select id="getHisList" resultType="com.whyc.pojo.db_alarm.BattStationTempAlarm"> |
| | | select a.*,p.binf_name as battGroupName,p.power_name as powerName,s.sinf_name as stationName from db_alarm.tb_batt_station_temp_alarm a,db_batt.power_inf p,db_batt.station_inf s |
| | | where a.batt_group_id = p.binf_id |
| | | and a.station_id = s.sinf_id |
| | | and a.end_time is not null |
| | | <if test="level!=null"> |
| | | and a.level = #{level} |
| | | </if> |
| | | </select> |
| | | </mapper> |