| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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 com.whyc.util.PointUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | private BattStationTempMapper mapper; |
| | | |
| | | public Response<List<BattStationTemp>> getList() { |
| | | List<BattStationTemp> list = mapper.selectList((Wrapper<BattStationTemp>) ActionUtil.objeNull); |
| | | QueryWrapper<BattStationTemp> query = Wrappers.query(); |
| | | query.orderByAsc("camera_id"); |
| | | List<BattStationTemp> list = mapper.selectList(query); |
| | | //对温度坐标进行解析,minTempPoint格式为"1*2,2*3",把里面所有的x*y点 拆解到Point(x,y)列表中 |
| | | list.stream().forEach(battStationTemp -> { |
| | | String minTempPointStr = battStationTemp.getMinTempPoint(); |
| | | |
| | | List<Point> minTempPointList = battStationTemp.getMinTempPointList(); |
| | | minTempPointList = new LinkedList<>(); |
| | | |
| | | List<Point> maxTempPointList = battStationTemp.getMaxTempPointList(); |
| | | maxTempPointList =new LinkedList<>(); |
| | | 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]))); |
| | | minTempPointList.add(new Point(Integer.parseInt(split1[0]),Integer.parseInt(split1[1]))); |
| | | } |
| | | } |
| | | String maxTempPointStr = battStationTemp.getMaxTempPoint(); |
| | |
| | | //对于最高温度点 p(a,b) |
| | | //TODO 已知坐标点两点为p1(a1,b1)和p2(a2,b2), 求 maxTempPoint点与p1p2组成的线垂直相交的点p3的坐标计算方式 |
| | | |
| | | battStationTemp.getMaxTempPointList().add(p); |
| | | maxTempPointList.add(p); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | return new Response<List<BattStationTemp>>().set(1,list); |
| | | } |
| | | |
| | | public void addOrUpdate(BattStationTemp battStationTemp) { |
| | | QueryWrapper<BattStationTemp> query = Wrappers.query(); |
| | | query.eq("camera_id",battStationTemp.getCameraId()); |
| | | BattStationTemp tempInDB = mapper.selectOne(query); |
| | | if (tempInDB ==null) { |
| | | mapper.insert(battStationTemp); |
| | | }else{ |
| | | battStationTemp.setId(tempInDB.getId()); |
| | | mapper.updateById(battStationTemp); |
| | | } |
| | | } |
| | | } |