Merge branch 'cjl' into qa
# Conflicts:
# screen-manage/src/main/java/com/moral/api/controller/ManageCoordinateController.java
# screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
| | |
| | | package com.moral.api.config.mybatis; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.DbType; |
| | | import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; |
| | | import com.baomidou.mybatisplus.core.MybatisConfiguration; |
| | | import com.baomidou.mybatisplus.extension.parsers.DynamicTableNameParser; |
| | | import com.baomidou.mybatisplus.extension.parsers.ITableNameHandler; |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; |
| | | import com.moral.api.entity.HistoryFiveMinutely; |
| | | import com.moral.api.mapper.HistoryFiveMinutelyMapper; |
| | | import com.moral.api.service.HistorySecondUavService; |
| | |
| | | import com.moral.api.service.impl.OrganizationServiceImpl; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.apache.ibatis.session.SqlSessionFactory; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.Primary; |
| | | |
| | | import javax.sql.DataSource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | /*@Configuration*/ |
| | | public class MybatisPlusConfig { |
| | | |
| | | public static ThreadLocal<String> tableName = new ThreadLocal<>(); |
| | | |
| | | |
| | | @Bean |
| | | public MybatisPlusInterceptor mybatisPlusInterceptor() { |
| | |
| | | |
| | | dynamicTableNameInnerInterceptor.setTableNameHandlerMap(map); |
| | | interceptor.addInnerInterceptor(dynamicTableNameInnerInterceptor); |
| | | |
| | | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); |
| | | return interceptor; |
| | | } |
| | | @Bean |
| | | public ConfigurationCustomizer configurationCustomizer() { |
| | | return configuration -> configuration.setUseDeprecatedExecutor(false); |
| | | } |
| | | |
| | | |
| | | public static ThreadLocal<String> tableName = new ThreadLocal<>(); |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | //@Component |
| | | @Component |
| | | @Slf4j |
| | | public class CruiserDataConsumer implements ConsumerSeekAware { |
| | | |
| | |
| | | |
| | | |
| | | |
| | | //@Component |
| | | @Component |
| | | @Slf4j |
| | | public class SecondDataConsumer implements ConsumerSeekAware { |
| | | |
| | |
| | | |
| | | import com.moral.api.entity.HistoryFiveMinutely; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.entity.HistoryHourly; |
| | | import com.moral.api.pojo.dto.Wind.WindData; |
| | | |
| | | /** |
| | |
| | | |
| | | List<WindData> getAreaWindData(Map<String, Object> params); |
| | | |
| | | List<HistoryFiveMinutely> listResult(Map<String, Object> params); |
| | | |
| | | List<HistoryFiveMinutely> listResultOne(Map<String, Object> params); |
| | | |
| | | } |
| | |
| | | void insertHistoryHourly(Map<String, Object> params); |
| | | |
| | | void updateHistoryHourly(Map<String, Object> params); |
| | | |
| | | List<HistoryHourly> listResult(Map<String, Object> params); |
| | | } |
| | |
| | | Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_EN); |
| | | List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH); |
| | | for (String mac:macs) { |
| | | QueryWrapper<HistoryHourly> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("mac", mac); |
| | | wrapper.between("time", startDate, endDate); |
| | | List<HistoryHourly> historyHourlies = multiTableQuery(wrapper, tableNames); |
| | | Map<String, Object> mapParams = new HashMap<>(); |
| | | mapParams.put("startDate",startDate); |
| | | mapParams.put("endDate",endDate); |
| | | mapParams.put("mac",mac); |
| | | List<HistoryHourly> historyHourlies = multiTableQuery(mapParams, tableNames); |
| | | historyHourlies = historyHourlies.stream().distinct().collect(Collectors.toList()); |
| | | List<HistoryHourly> distinctHistoryHourlies = new ArrayList<>(); |
| | | Map<String, Object> disMap = new HashMap<>(); |
| | |
| | | Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH); |
| | | for (String mac:macs) { |
| | | QueryWrapper<HistoryFiveMinutely> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("mac", mac); |
| | | wrapper.between("time", startDate, endDate); |
| | | List<HistoryFiveMinutely> HistoryFiveMinutelys = FiveMinuteTableQuery(wrapper, tableNames); |
| | | Map<String, Object> mapParams = new HashMap<>(); |
| | | mapParams.put("startDate",startDate); |
| | | mapParams.put("endDate",endDate); |
| | | mapParams.put("mac",mac); |
| | | List<HistoryFiveMinutely> HistoryFiveMinutelys = FiveMinuteTableQuery(mapParams, tableNames); |
| | | HistoryFiveMinutelys = HistoryFiveMinutelys.stream().distinct().collect(Collectors.toList()); |
| | | List<HistoryFiveMinutely> distinctHistoryHourlies = new ArrayList<>(); |
| | | Map<String, Object> disMap = new HashMap<>(); |
| | |
| | | * @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<HistoryFiveMinutely> FiveMinuteTableQuery(QueryWrapper<HistoryFiveMinutely> wrapper, List<String> tableNames) { |
| | | private List<HistoryFiveMinutely> FiveMinuteTableQuery(Map<String, Object> params, List<String> tableNames) { |
| | | List<HistoryFiveMinutely> result = new ArrayList<>(); |
| | | for (String tableName : tableNames) { |
| | | MybatisPlusConfig.tableName.set(tableName); |
| | | List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.selectList(wrapper); |
| | | params.put("table",tableName); |
| | | List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.listResult(params); |
| | | result.addAll(datas); |
| | | } |
| | | MybatisPlusConfig.tableName.remove(); |
| | | return result; |
| | | } |
| | | |
| | |
| | | //如果没有数据从数据库查询 |
| | | if (sensorValues != null) |
| | | return sensorValues; |
| | | QueryWrapper<HistoryFiveMinutely> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("mac", mac); |
| | | queryWrapper.orderByDesc("time"); |
| | | queryWrapper.last("limit 0,1"); |
| | | Map<String, Object> mapParams = new HashMap<>(); |
| | | mapParams.put("mac",mac); |
| | | //获取当月的表名 |
| | | Date date = new Date(); |
| | | List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(date, date, SeparateTableType.MONTH); |
| | | List<HistoryFiveMinutely> datas = multiTableQuery(queryWrapper, tableNames); |
| | | List<HistoryFiveMinutely> datas = multiTableQuery(mapParams, tableNames); |
| | | if (ObjectUtils.isEmpty(datas)) |
| | | return null; |
| | | HistoryFiveMinutely historyFiveMinutely = datas.get(0); |
| | |
| | | * @Date: 2021/9/23 |
| | | */ |
| | | public List<HistoryFiveMinutely> getValueByMacAndTime(String mac, Date startDate, Date endDate) { |
| | | QueryWrapper<HistoryFiveMinutely> 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<HistoryFiveMinutely> datas = multiTableQuery(wrapper, tableNames); |
| | | List<HistoryFiveMinutely> datas = multiTableQueryResult(mapParams, tableNames); |
| | | return datas; |
| | | } |
| | | |
| | |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/23 |
| | | */ |
| | | private List<HistoryFiveMinutely> multiTableQuery(QueryWrapper<HistoryFiveMinutely> wrapper, List<String> tableNames) { |
| | | private List<HistoryFiveMinutely> multiTableQuery(Map<String, Object> params, List<String> tableNames) { |
| | | List<HistoryFiveMinutely> result = new ArrayList<>(); |
| | | for (String tableName : tableNames) { |
| | | MybatisPlusConfig.tableName.set(tableName); |
| | | List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.selectList(wrapper); |
| | | params.put("table",tableName); |
| | | List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.listResultOne(params); |
| | | result.addAll(datas); |
| | | } |
| | | MybatisPlusConfig.tableName.remove(); |
| | | return result; |
| | | } |
| | | private List<HistoryFiveMinutely> multiTableQueryResult(Map<String, Object> params, List<String> tableNames) { |
| | | List<HistoryFiveMinutely> result = new ArrayList<>(); |
| | | for (String tableName : tableNames) { |
| | | params.put("table",tableName); |
| | | List<HistoryFiveMinutely> datas = historyFiveMinutelyMapper.listResult(params); |
| | | result.addAll(datas); |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | |
| | | AND h.time = (SELECT max(time) FROM history_five_minutely_${timeUnits}) |
| | | </select> |
| | | |
| | | <select id="listResult" resultType="com.moral.api.entity.HistoryFiveMinutely"> |
| | | SELECT mac,time,value FROM history_five_minutely${table} |
| | | WHERE (mac = #{mac} AND time BETWEEN #{startDate} AND #{endDate}) |
| | | order by time desc |
| | | </select> |
| | | <select id="listResultOne" resultType="com.moral.api.entity.HistoryFiveMinutely"> |
| | | SELECT mac,time,value FROM history_five_minutely${table} |
| | | WHERE (mac = #{mac}) |
| | | order by time desc |
| | | limit 1 |
| | | </select> |
| | | </mapper> |
| | |
| | | UPDATE history_hourly_${timeUnits} SET `value` = #{value} |
| | | where mac = #{mac} and time = #{time} and version = #{version} |
| | | </insert> |
| | | |
| | | <select id="listResult" 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 BETWEEN #{startDate} and #{endDate} |
| | | |
| | | order by time desc |
| | | </select> |
| | | </mapper> |
| | |
| | | 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 |
| | |
| | | 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(); |
| | |
| | | |
| | | /** |
| | | * 修改路段信息 |
| | | * |
| | | * @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); |
| | |
| | | |
| | | /** |
| | | * 删除路段信息 |
| | | * |
| | | * @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()); |
| | | } |
| | |
| | | * @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); |
| | | } |
| | | } |
| | |
| | | /* |
| | | * 1:系统内置,无法更改 0:可以更改 |
| | | * */ |
| | | @TableField("`system`") |
| | | private Integer system; |
| | | |
| | | /** |
| | |
| | | /* |
| | | package com.moral.api.kafka.consumer; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.service.*; |
| | | import com.moral.constant.KafkaConstants; |
| | | import com.moral.constant.RedisConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.kafka.clients.consumer.ConsumerRecord; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.constant.KafkaConstants; |
| | | import com.moral.constant.RedisConstants; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | import com.moral.api.entity.SysDictType; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface SysDictTypeMapper extends BaseMapper<SysDictType> { |
| | | |
| | | SysDictType listOne(@Param("name") String name); |
| | | } |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.entity.ManageAccount; |
| | |
| | | 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; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | //获取要插入的实体 |
| | | SysDictType sysDictType = form.formConvertEntity(); |
| | | //判断name是否已经存在 |
| | | QueryWrapper<SysDictType> existNameWrapper = new QueryWrapper<>(); |
| | | existNameWrapper.eq("name",sysDictType.getName()); |
| | | existNameWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | SysDictType existType = sysDictTypeMapper.selectOne(existNameWrapper); |
| | | SysDictType existType = sysDictTypeMapper.listOne(sysDictType.getName()); |
| | | if(!ObjectUtils.isEmpty(existType)){ |
| | | dto.setCode(ResponseCodeEnum.DICTTYPE_EXIST.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.DICTTYPE_EXIST.getMsg()); |
| | |
| | | <result column="is_delete" property="isDelete" /> |
| | | </resultMap> |
| | | |
| | | <select id="listOne" resultType="com.moral.api.entity.SysDictType"> |
| | | SELECT |
| | | t.id, |
| | | t.name, |
| | | t.desc, |
| | | t.system, |
| | | t.create_time, |
| | | t.update_time, |
| | | t.is_delete |
| | | FROM |
| | | sys_dict_type t |
| | | WHERE |
| | | t.name =#{name} AND is_delete = '0' |
| | | </select> |
| | | </mapper> |