screen-api/src/main/java/com/moral/api/mapper/HistoryHourlyMapper.java
@@ -44,4 +44,6 @@ void updateHistoryHourly(Map<String, Object> params); List<HistoryHourly> listResult(Map<String, Object> params); List<HistoryHourly> listLikeResult(Map<String, Object> params); } screen-api/src/main/java/com/moral/api/mapper/HistorySecondCruiserMapper.java
@@ -26,7 +26,7 @@ String getDaily(Map<String,Object> params); List<Double> getDust(String start,String end,String mac); List<String> getDust(String start,String end,String mac); List<Map<String,Object>> getDusts(Map<String,Object> params); screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java
@@ -90,29 +90,25 @@ for (TimeForm timeForm : tables) { String start = timeForm.getStart(); String end = timeForm.getEnd(); List<Double> dust = historySecondCruiserMapper.getDust(start, end, mac); List<String> dust = historySecondCruiserMapper.getDust(start, end, mac); ArrayList<Double> rsDouble = new ArrayList<>(); for (Double aDouble : dust) { double v =0.0; for (String s : dust) { double aDouble = Double.parseDouble(s); if (aDouble>=0 && aDouble<40 ){ v = aDouble + 170; aDouble = aDouble + 170; }else if (aDouble>=40 && aDouble<60){ aDouble = aDouble + 130; }else if (aDouble>=60 && aDouble<100 ){ aDouble = aDouble + 110; }else if (aDouble>=100 && aDouble<150){ aDouble = aDouble + 70; }else if (aDouble>=150 && aDouble<180){ aDouble = aDouble + 30; }else { aDouble= aDouble+0; } if (aDouble>=40 && aDouble<60 ){ v = aDouble + 130; } if (aDouble>=60 && aDouble<100 ){ v = aDouble + 110; } if (aDouble>=100 && aDouble<150 ){ v = aDouble + 70; } if (aDouble>=150 && aDouble<180 ){ v = aDouble + 30; } if (aDouble>=180){ v= aDouble; } rsDouble.add(v); rsDouble.add(aDouble); } list.addAll(rsDouble); } screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java
@@ -384,9 +384,9 @@ int nx = (int) Math.floor((lo2 - lo1) / dx); int ny = (int) Math.floor((la1 - la2) / dy); List<Double> uList = new ArrayList<>(); List<Double> vList = new ArrayList<>(); int nums = Objects.nonNull(nx*ny)?nx*ny+100:100; List<Double> uList = new ArrayList<>(nums); List<Double> vList = new ArrayList<>(nums); int x; int y; screen-api/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
@@ -746,43 +746,44 @@ */ @Override public List<HistoryHourly> getValueByMacAndTime(String mac, Date startDate, Date endDate) { QueryWrapper<HistoryHourly> wrapper = new QueryWrapper<>(); wrapper.eq("mac", mac); wrapper.between("time", startDate, endDate); Map<String, Object> mapParams = new HashMap<>(); mapParams.put("startDate",startDate); mapParams.put("endDate",endDate); mapParams.put("mac",mac); List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH); List<HistoryHourly> datas = multiTableQuery(wrapper, tableNames); List<HistoryHourly> datas = multiTableQuery(mapParams, tableNames); return datas; } @Override public List<HistoryHourly> getValueByMacAndTime(List<String> mac, Date startDate, Date endDate) { QueryWrapper<HistoryHourly> wrapper = new QueryWrapper<>(); wrapper.in("mac", mac); wrapper.between("time", startDate, endDate); Map<String, Object> mapParams = new HashMap<>(); mapParams.put("startDate",startDate); mapParams.put("endDate",endDate); mapParams.put("macs",mac); List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH); List<HistoryHourly> datas = multiTableQuery(wrapper, tableNames); List<HistoryHourly> datas = multiTableQuery(mapParams, tableNames); return datas; } @Override public List<HistoryHourly> getValueByMacs(List<String> macs, String time) { QueryWrapper<HistoryHourly> queryWrapper = new QueryWrapper<>(); queryWrapper.select("time", "value") .likeRight("time", time) .in("mac", macs); Map<String, Object> mapParams = new HashMap<>(); mapParams.put("time",time); mapParams.put("macs",macs); Date date = DateUtils.getDate(time, DateUtils.yyyy_MM_dd_EN); List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(date, date, SeparateTableType.MONTH); return multiTableQuery(queryWrapper, tableNames); return multiTableQueryLike(mapParams, tableNames); } @Override public List<HistoryHourly> getHourlyDataByMacs(List<String> macs, String time) { QueryWrapper<HistoryHourly> queryWrapper = new QueryWrapper<>(); queryWrapper.select("mac","time", "value") .likeRight("time", time) .in("mac", macs); Map<String, Object> mapParams = new HashMap<>(); mapParams.put("time",time); mapParams.put("macs",macs); Date date = DateUtils.getDate(time, DateUtils.yyyy_MM_dd_EN); List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(date, date, SeparateTableType.MONTH); return multiTableQuery(queryWrapper, tableNames); return multiTableQueryLike(mapParams, tableNames); } @Override @@ -848,14 +849,22 @@ * @Author: 陈凯裕 * @Date: 2021/9/23 */ private List<HistoryHourly> multiTableQuery(QueryWrapper<HistoryHourly> wrapper, List<String> tableNames) { private List<HistoryHourly> multiTableQuery(Map<String, Object> params, List<String> tableNames) { List<HistoryHourly> result = new ArrayList<>(); for (String tableName : tableNames) { MybatisPlusConfig.tableName.set(tableName); List<HistoryHourly> datas = historyHourlyMapper.selectList(wrapper); params.put("table",tableName); List<HistoryHourly> datas = historyHourlyMapper.listResult(params); result.addAll(datas); } MybatisPlusConfig.tableName.remove(); return result; } private List<HistoryHourly> multiTableQueryLike(Map<String, Object> params, List<String> tableNames) { List<HistoryHourly> result = new ArrayList<>(); for (String tableName : tableNames) { params.put("table",tableName); List<HistoryHourly> datas = historyHourlyMapper.listLikeResult(params); result.addAll(datas); } return result; } screen-api/src/main/resources/application-dev.yml
@@ -1,5 +1,7 @@ server: port: 8081 servlet: context-path: /api spring: profiles: active: dev screen-api/src/main/resources/mapper/DeviceMapper.xml
@@ -39,8 +39,8 @@ <foreach collection="macs" item="mac" index="index" open="(" close=")" separator=","> #{mac} </foreach> AND `time` <![CDATA[>=]]> #{start} AND `time` <![CDATA[<]]> #{end} AND DATE_FORMAT(`time`,'%Y-%m-%d %H') <![CDATA[>=]]> #{start} AND DATE_FORMAT(`time`,'%Y-%m-%d %H') <![CDATA[<]]> #{end} ORDER BY `time` </select> <select id="deviceList" resultType="java.util.Map"> screen-api/src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -104,4 +104,22 @@ order by time desc </select> <select id="listLikeResult" resultType="com.moral.api.entity.HistoryHourly"> SELECT mac,time,value,version FROM history_hourly${table} WHERE 1 =1 <if test="macs != null and macs.size!=0"> and mac in <foreach collection="macs" item="id" index="index" open="(" close=")" separator=","> #{id} </foreach> </if> <if test="mac != null and mac != ''"> and mac = #{mac} </if> and time like concat(#{time},'%') order by time desc </select> </mapper> screen-api/src/main/resources/mapper/HistorySecondCruiserMapper.xml
@@ -50,8 +50,8 @@ AND `time` <![CDATA[<=]]> #{time2} </select> <select id="getDust" resultType="java.lang.Double"> select JSON_EXTRACT(value,'$.dustld') <select id="getDust" resultType="java.lang.String"> select value ->>'$.dustld' from `history_second_cruiser` WHERE mac = #{mac} AND `time` <![CDATA[>=]]> #{start} screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateController.java
@@ -21,13 +21,6 @@ import com.moral.api.service.ManageCoordinateService; import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @Slf4j @RestController @@ -41,19 +34,19 @@ private ManageCoordinateMapper manageCoordinateMapper; /** * 添加路段信息 * * @param params * @return */ @PostMapping("interCruiserRoad") public ResultMessage interCruiserRoad(@RequestBody Map<String, Object> params) { public ResultMessage interCruiserRoad(@RequestBody Map<String,Object> params){ if (!params.containsKey("startPoint") || !params.containsKey("mac")) { return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } Integer integer = manageCoordinateService.interCoordinate(params); if (integer == null) { if (integer==null){ return ResultMessage.ok("路段已存在"); } return ResultMessage.ok(); @@ -62,13 +55,12 @@ /** * 修改路段信息 * * @param manageCoordinate * @return */ @PostMapping("updateCruiserRoad") public ResultMessage updateCruiserRoad(@RequestBody ManageCoordinate manageCoordinate) { if (ObjectUtils.isEmpty(manageCoordinate)) { public ResultMessage updateCruiserRoad(@RequestBody ManageCoordinate manageCoordinate){ if (ObjectUtils.isEmpty(manageCoordinate)){ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } manageCoordinateService.updateCoordinate(manageCoordinate); @@ -77,13 +69,12 @@ /** * 删除路段信息 * * @param id * @return */ @GetMapping("deleteCruiserRoad") public ResultMessage deleteCruiser(Integer id) { if (id == null) { public ResultMessage deleteCruiser(Integer id){ if (id==null){ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } @@ -97,8 +88,8 @@ * @return */ @GetMapping("selectCruiserRoad") public ResultMessage selectCruiser(String name, String mac) { List<ManageCoordinate> manageCoordinates = manageCoordinateService.selectCoordinate(name, mac); public ResultMessage selectCruiser(String name,String mac){ List<ManageCoordinate> manageCoordinates = manageCoordinateService.selectCoordinate(name,mac); return ResultMessage.ok(manageCoordinates); } } screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
@@ -10,6 +10,7 @@ import com.moral.api.pojo.redisBean.AccountInfoDTO; import com.moral.api.service.ManageCoordinateDetailService; import com.moral.api.util.RoadUtils; import com.moral.constant.Constants; import com.moral.constant.RedisConstants; import com.moral.util.DateUtils; import com.moral.util.TokenUtils;