初始提交
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
package com.mosty.wzzx;
|
||||
|
||||
import com.mosty.common.base.timeconsume.EnableTimeConsume;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 位置中心 微服务
|
||||
* @author zengbo
|
||||
* @date 2022/7/11 14:29 PM[
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@EnableTimeConsume
|
||||
@EnableFeignClients(basePackages = "com.mosty.base.feign.service")
|
||||
@MapperScan("com.mosty.wzzx.mapper")
|
||||
@EnableDiscoveryClient
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class MostyWzzxApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(MostyWzzxApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.mosty.wzzx.config;
|
||||
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Configuration
|
||||
public class FeignConfig implements RequestInterceptor {
|
||||
|
||||
@Override
|
||||
public void apply(RequestTemplate requestTemplate) {
|
||||
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (attr != null) {
|
||||
HttpServletRequest request = attr.getRequest();
|
||||
// 添加token
|
||||
requestTemplate.header("Authorization", request.getHeader("Authorization"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.mosty.wzzx.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 全局配置
|
||||
* @author kevin
|
||||
* @date 2022/5/25 1:56 上午
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties("exclude.path-patterns")
|
||||
public class GlobalYmlConfig {
|
||||
|
||||
/**
|
||||
* swagger 静态文件的放行列表
|
||||
*/
|
||||
private List<String> swagger;
|
||||
|
||||
}
|
120
mosty-wzzx/src/main/java/com/mosty/wzzx/config/WebMvcConfig.java
Normal file
120
mosty-wzzx/src/main/java/com/mosty/wzzx/config/WebMvcConfig.java
Normal file
@ -0,0 +1,120 @@
|
||||
package com.mosty.wzzx.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
||||
import com.mosty.common.token.SysUserInterceptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单体服务拦截器
|
||||
* @author kevin
|
||||
* @date 2022/3/21 11:17 PM
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class WebMvcConfig implements WebMvcConfigurer, InitializingBean {
|
||||
|
||||
private static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
|
||||
private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
|
||||
private static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
@Value("${server.servlet.context-path:/}")
|
||||
private String contextPath;
|
||||
|
||||
@Autowired
|
||||
private GlobalYmlConfig globalYmlConfig;
|
||||
|
||||
@Override
|
||||
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||
ObjectMapper objectMapper = converter.getObjectMapper();
|
||||
// 生成JSON时,将所有Long转换成String
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
//日期格式化
|
||||
simpleModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
|
||||
simpleModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
|
||||
simpleModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
|
||||
simpleModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
|
||||
simpleModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
|
||||
simpleModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
|
||||
objectMapper.registerModule(simpleModule);
|
||||
// 时间格式化
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
|
||||
objectMapper.configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true);
|
||||
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
// 设置格式化内容
|
||||
converter.setObjectMapper(objectMapper);
|
||||
converters.add(0, converter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
log.info("当前服务的 contextPath={}", contextPath);
|
||||
log.info("当前服务的 swaggerExcludePathPatterns={}", JSON.toJSONString(globalYmlConfig.getSwagger()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
||||
configurer.defaultContentType(MediaType.APPLICATION_JSON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(userInfoInterceptor()).addPathPatterns("/**")
|
||||
.excludePathPatterns(globalYmlConfig.getSwagger());
|
||||
log.info("初始化WebMvcConfig 监控拦截器SysUserInterceptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
if (!registry.hasMappingForPattern("/template/**")) {
|
||||
registry.addResourceHandler("/template/**").addResourceLocations("classpath:/template/");
|
||||
}
|
||||
registry.addResourceHandler("swagger-ui.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("docs.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
WebMvcConfigurer.super.addResourceHandlers(registry);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SysUserInterceptor userInfoInterceptor() {
|
||||
log.info("初始化WebMvcConfig 拦截器SysUserInterceptor");
|
||||
return new SysUserInterceptor();
|
||||
}
|
||||
}
|
@ -0,0 +1,177 @@
|
||||
package com.mosty.wzzx.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mosty.base.model.dto.wzzx.LocationConvertDTO;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSswz;
|
||||
import com.mosty.base.utils.CoordinateTransform;
|
||||
import com.mosty.base.utils.CoordinateUtils;
|
||||
import com.mosty.base.utils.DateUtils;
|
||||
import com.mosty.common.base.domain.BaseController;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.entity.log.BusinessType;
|
||||
import com.mosty.common.base.entity.log.Log;
|
||||
import com.mosty.wzzx.service.LocationInfoService;
|
||||
import com.mosty.wzzx.service.impl.TbWzSswzServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ydb
|
||||
* 位置信息实体Controller
|
||||
* @since 2022年4月21日
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/gxga/locationInfo")
|
||||
@Api(tags = "位置信息实体", value = "位置信息实体")
|
||||
public class LocationInfoController extends BaseController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LocationInfoController.class);
|
||||
|
||||
private final TbWzSswzServiceImpl tbWzSswzService;
|
||||
private final LocationInfoService locationInfoService;
|
||||
|
||||
@PostMapping("/now")
|
||||
@ApiOperation(value = "根据条件获取当前最新一条位置信息", notes = "位置信息实体")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", dataType = "String"),
|
||||
@ApiImplicitParam(name = "accessNumber", value = "接入编号", dataType = "String")
|
||||
})
|
||||
public ResponseResult<TbWzSswz> getNowLoaction(String userId, String accessNumber) {
|
||||
Map<String, Object> requestMap = Maps.newHashMap();
|
||||
if (!StrUtil.isBlank(userId)) {
|
||||
requestMap.put("USER_ID", userId);
|
||||
}
|
||||
if (!StrUtil.isBlank(accessNumber)) {
|
||||
requestMap.put("ACCESS_NUMBER", accessNumber);
|
||||
}
|
||||
if (requestMap.isEmpty()) {
|
||||
return ResponseResult.fail("请确保至少传入一个查询参数");
|
||||
}
|
||||
return ResponseResult.success(tbWzSswzService.querySswzNow(userId, accessNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取位置信息实体详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "参数键名", dataTypeClass = String.class, required = true, paramType = "path")
|
||||
@ApiOperation(value = "位置信息实体-详细信息", notes = "位置信息实体")
|
||||
public ResponseResult<TbWzSswz> queryById(@PathVariable("id") String id) {
|
||||
TbWzSswz sswz = this.tbWzSswzService.queryById(id);
|
||||
return ResponseResult.success(sswz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增位置信息实体
|
||||
*/
|
||||
@PostMapping(value = "add")
|
||||
@ApiOperation(value = "新增位置信息实体", notes = "位置信息实体")
|
||||
@Log(title = "新增人员位置", businessType = BusinessType.OTHER, isScSj = true)
|
||||
public ResponseResult<LocationInfo> add(@Validated @RequestBody LocationInfo locationInfo, BindingResult result) {
|
||||
System.out.println(DateUtils.getQueryDateString(new Date(), "02") + "收到位置服务上报 :{" + JSONObject.toJSONString(locationInfo) + "}");
|
||||
if (result.hasErrors() && result.getFieldError() != null) {
|
||||
return ResponseResult.fail(result.getFieldError().getDefaultMessage());
|
||||
}
|
||||
// 后台验证
|
||||
if (locationInfo.getLat() == 0 || locationInfo.getLng() == 0) {
|
||||
return ResponseResult.fail("报送错误! 定位坐标信息不能为空!");
|
||||
}
|
||||
if (StringUtils.isBlank(locationInfo.getUserId())) {
|
||||
return ResponseResult.fail("用户ID不存在,该位置不上报!");
|
||||
}
|
||||
locationInfo.setSourceName("移动设备");
|
||||
locationInfo.setSourceCode("02");
|
||||
// Long startTime = System.currentTimeMillis();
|
||||
// 入库之前将坐标进行转换
|
||||
locationInfo.setSourceLat(locationInfo.getLat());
|
||||
locationInfo.setSourceLng(locationInfo.getLng());
|
||||
// double[] transfromPonint = CoordinateTransform.transformGCJ02ToWGS84(locationInfo.getLng(),
|
||||
// locationInfo.getLat());
|
||||
// // 只保留8位小数
|
||||
// BigDecimal reLngBd = BigDecimal.valueOf(transfromPonint[0]);
|
||||
// double reLngDouble = reLngBd.setScale(8, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
// locationInfo.setLng(reLngDouble);
|
||||
// // 只保留8位小数
|
||||
// BigDecimal reLatBd = BigDecimal.valueOf(transfromPonint[1]);
|
||||
// double reLatDouble = reLatBd.setScale(8, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
// locationInfo.setLat(reLatDouble);
|
||||
//上传坐标转行
|
||||
if (locationInfo.getLastLng() != null && locationInfo.getLastLat() != null) {
|
||||
double[] lastTransfromPonint = CoordinateTransform.transformGCJ02ToWGS84(locationInfo.getLastLng(),
|
||||
locationInfo.getLastLat());
|
||||
// 只保留8位小数
|
||||
BigDecimal lastReLngBd = BigDecimal.valueOf(lastTransfromPonint[0]);
|
||||
double lastReLngDouble = lastReLngBd.setScale(8, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
locationInfo.setLastLng(lastReLngDouble);
|
||||
// 只保留8位小数
|
||||
BigDecimal lastReLatBd = BigDecimal.valueOf(lastTransfromPonint[1]);
|
||||
double lastReLatDouble = lastReLatBd.setScale(8, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
locationInfo.setLastLat(lastReLatDouble);
|
||||
}
|
||||
if (locationInfo.getTime() == null) {
|
||||
locationInfo.setTime(new Date());
|
||||
}
|
||||
//实时存储位置
|
||||
locationInfoService.locationReceive(locationInfo);
|
||||
Long endTime = System.currentTimeMillis();
|
||||
locationInfo.setLastLat(locationInfo.getLat());
|
||||
locationInfo.setLastLng(locationInfo.getLng());
|
||||
return ResponseResult.success("添加成功", locationInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换定位坐标系
|
||||
*/
|
||||
@GetMapping(value = "wgs842Mercator")
|
||||
@ApiOperation(value = "转换定位坐标系", notes = "转换定位坐标系")
|
||||
public ResponseResult<LocationConvertDTO> wgs842Mercator(LocationConvertDTO dto) {
|
||||
if(ObjectUtils.isEmpty(dto) || dto.getLongitude() == null || dto.getLatitude() == null){
|
||||
return ResponseResult.fail("参数不能为空");
|
||||
}
|
||||
Coordinate resPoint = CoordinateUtils.wgs842Mercator(dto.getLongitude(), dto.getLatitude());
|
||||
if(ObjectUtils.isEmpty(resPoint)){
|
||||
return ResponseResult.fail("数据转换错误");
|
||||
}
|
||||
Coordinate resPoint2 = CoordinateUtils.mercator2wgs84(resPoint);
|
||||
if(ObjectUtils.isEmpty(resPoint2)){
|
||||
return ResponseResult.fail("数据转换错误");
|
||||
}
|
||||
return ResponseResult.success(new LocationConvertDTO(resPoint2.x, resPoint2.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换定位坐标系
|
||||
*/
|
||||
@GetMapping(value = "wgs842Cgcs2000")
|
||||
@ApiOperation(value = "转换定位坐标系", notes = "转换定位坐标系")
|
||||
public ResponseResult<LocationConvertDTO> wgs842Cgcs2000(LocationConvertDTO dto) {
|
||||
if(ObjectUtils.isEmpty(dto) || dto.getLongitude() == null || dto.getLatitude() == null){
|
||||
return ResponseResult.fail("参数不能为空");
|
||||
}
|
||||
Coordinate resPoint = CoordinateUtils.wgs842Cgcs2000(dto.getLongitude(), dto.getLatitude());
|
||||
if(ObjectUtils.isEmpty(resPoint)){
|
||||
return ResponseResult.fail("数据转换错误");
|
||||
}
|
||||
return ResponseResult.success(new LocationConvertDTO(resPoint.x, resPoint.y));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package com.mosty.wzzx.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mosty.base.model.dto.wzzx.SswzQuery;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.base.model.query.wzzx.TbWzRywzSearchDto;
|
||||
import com.mosty.base.model.query.wzzx.TbWzSswzSearchDto;
|
||||
import com.mosty.base.model.vo.base.DeptInfoVo;
|
||||
import com.mosty.base.utils.Constant;
|
||||
import com.mosty.base.utils.DateUtils;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.entity.log.BusinessType;
|
||||
import com.mosty.common.base.entity.log.Log;
|
||||
import com.mosty.common.core.business.entity.SysDept;
|
||||
import com.mosty.common.redis.service.RedisService;
|
||||
import com.mosty.common.token.JwtSysUser;
|
||||
import com.mosty.common.token.UserInfo;
|
||||
import com.mosty.common.token.UserInfoManager;
|
||||
import com.mosty.wzzx.remote.TbBaseAdaptRemoteService;
|
||||
import com.mosty.wzzx.service.TbWzSswzService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 位置-人员位置
|
||||
*
|
||||
* @author
|
||||
* @since 2022-07-14 15:37:38
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@Api(tags = "人员位置相关接口")
|
||||
@RequestMapping("/gxga/rywz")
|
||||
public class TbWzRywzController {
|
||||
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final RedisService redisService;
|
||||
private final TbWzSswzService tbWzSswzService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "人员位置redis数据列表")
|
||||
@Log(title = "人员位置redis数据列表", businessType = BusinessType.OTHER)
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<TbWzRywz>> getList(SswzQuery dto) {
|
||||
List<TbWzRywz> list = new ArrayList<>();
|
||||
String key = Constant.WZ_RYWZ + "*";
|
||||
Set<String> sets = redisTemplate.keys(key);
|
||||
if (!CollectionUtils.isEmpty(sets)) {
|
||||
list = redisTemplate.opsForValue().multiGet(sets);
|
||||
// 权限
|
||||
UserInfo user = UserInfoManager.get();
|
||||
String ids = "";
|
||||
if (user != null && user.getUserPermissionsInfo() != null) {
|
||||
ids = user.getUserPermissionsInfo().getIds();
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
if (!StringUtils.isEmpty(ids)) {
|
||||
String finalIds = ids;
|
||||
list = list.stream().filter(item -> finalIds.contains(item.getSsbmid())).collect(Collectors.toList());
|
||||
}
|
||||
// 关键字筛选
|
||||
if (!StringUtils.isEmpty(dto.getKeyword())) {
|
||||
list = list.stream().filter(item ->
|
||||
(!StringUtils.isEmpty(item.getYhXm()) && item.getYhXm().contains(dto.getKeyword())) ||
|
||||
(!StringUtils.isEmpty(item.getYhSfzh()) && item.getYhSfzh().contains(dto.getKeyword())) ||
|
||||
(!StringUtils.isEmpty(item.getSsbm()) && item.getSsbm().contains(dto.getKeyword())) ||
|
||||
(!StringUtils.isEmpty(item.getYhId()) && item.getYhId().contains(dto.getKeyword()))
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
// 排序
|
||||
list.sort((a, a1) -> (int) (a1.getXtCjsj().getTime() - a.getXtCjsj().getTime()));
|
||||
list.forEach(item -> item.setZb(null));
|
||||
}
|
||||
}
|
||||
return ResponseResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/getRygj")
|
||||
@ApiOperation(value = "获取redis中的人员的轨迹信息")
|
||||
public ResponseResult<TbWzRywz> getXfgj(String sfzh) {
|
||||
if (StringUtils.isEmpty(sfzh)) return null;
|
||||
String redisKey = Constant.WZ_RYWZ + sfzh + "-"
|
||||
+ DateUtils.getQueryDateString(new Date(), "01");
|
||||
TbWzRywz rywz = redisService.getCacheObject(redisKey);
|
||||
return ResponseResult.success(rywz);
|
||||
}
|
||||
|
||||
@GetMapping("/getRygjList")
|
||||
@ApiOperation(value = "获取时间段类的人员轨迹信息俩表")
|
||||
public ResponseResult<IPage<TbWzSswz>> getRygjList(TbWzSswzSearchDto dto) {
|
||||
return ResponseResult.success(this.tbWzSswzService.getRygjList(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/getRywz")
|
||||
@ApiOperation(value = "查询某一天的人员位置信息")
|
||||
public ResponseResult<TbWzRywz> getRywz(TbWzRywzSearchDto dto) {
|
||||
return ResponseResult.success(this.tbWzSswzService.getRywz(dto));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,92 @@
|
||||
package com.mosty.wzzx.controller;
|
||||
|
||||
import com.mosty.base.model.dto.wzzx.SswzQuery;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import com.mosty.base.utils.Constant;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.entity.log.BusinessType;
|
||||
import com.mosty.common.base.entity.log.Log;
|
||||
import com.mosty.common.redis.service.RedisService;
|
||||
import com.mosty.common.token.JwtSysUser;
|
||||
import com.mosty.common.token.UserInfo;
|
||||
import com.mosty.common.token.UserInfoManager;
|
||||
import com.mosty.wzzx.service.TbWzSblswzService;
|
||||
import com.mosty.wzzx.service.TbWzSbsswzService;
|
||||
import com.mosty.wzzx.udp.UdpLzEntity;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 位置-巡防报备控制层
|
||||
*
|
||||
* @author
|
||||
* @since 2022-07-14 15:37:38
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "设备实时位置相关接口")
|
||||
@RequestMapping("/gxga/sbsswz")
|
||||
public class TbWzSbsswzController {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private TbWzSbsswzService tbWzSbsswzService;
|
||||
@Resource
|
||||
private TbWzSblswzService tbWzSblswzService;
|
||||
|
||||
@PostMapping("/locationHandleLz")
|
||||
@ApiOperation(value = "测试udp数据")
|
||||
@JwtSysUser
|
||||
public ResponseResult<Void> locationHandleLz(@RequestBody UdpLzEntity dto) {
|
||||
TbWzSbsswz sswz = this.tbWzSbsswzService.saveSbsswz(dto);
|
||||
this.tbWzSblswzService.saveSblswz(sswz);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "获取设备实时redis数据列表")
|
||||
@Log(title = "获取设备实时redis数据列表", businessType = BusinessType.OTHER)
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<TbWzSbsswz>> getList(SswzQuery dto) {
|
||||
List<TbWzSbsswz> list = new ArrayList<>();
|
||||
String key = Constant.WZ_SBWZ + "*";
|
||||
Set<String> sets = redisTemplate.keys(key);
|
||||
if (!CollectionUtils.isEmpty(sets)) {
|
||||
list = redisTemplate.opsForValue().multiGet(sets);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
// 关键字筛选
|
||||
if (!StringUtils.isEmpty(dto.getKeyword())) {
|
||||
list = list.stream().filter(item ->
|
||||
(!StringUtils.isEmpty(item.getYhXm()) && item.getYhXm().contains(dto.getKeyword())) ||
|
||||
(!StringUtils.isEmpty(item.getYhSfzh()) && item.getYhSfzh().contains(dto.getKeyword())) ||
|
||||
(!StringUtils.isEmpty(item.getSsbm()) && item.getSsbm().contains(dto.getKeyword())) ||
|
||||
(!StringUtils.isEmpty(item.getSbmc()) && item.getSbmc().contains(dto.getKeyword())) ||
|
||||
(!StringUtils.isEmpty(item.getSbid()) && item.getSbid().contains(dto.getKeyword())) ||
|
||||
(!StringUtils.isEmpty(item.getYhId()) && item.getYhId().contains(dto.getKeyword()))
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
// 排序
|
||||
list.sort((a, a1) -> (int) (a1.getXtCjsj().getTime() - a.getXtCjsj().getTime()));
|
||||
list.forEach(item -> item.setZb(null));
|
||||
}
|
||||
}
|
||||
return ResponseResult.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
package com.mosty.wzzx.controller;
|
||||
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.base.utils.Constant;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.redis.service.RedisService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 位置-巡防报备控制层
|
||||
*
|
||||
* @author
|
||||
* @since 2022-07-14 15:37:38
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@Api(tags = "巡防位置相关接口")
|
||||
@RequestMapping("/gxga/xfbb")
|
||||
public class TbWzXfbbController {
|
||||
|
||||
private final RedisService redisService;
|
||||
private final RedisTemplate redisTemplate;
|
||||
|
||||
@GetMapping("/remove")
|
||||
@ApiImplicitParam(name = "bbid", value = "报备ID", dataTypeClass = String.class, required = true, paramType = "path")
|
||||
@ApiOperation(value = "清除redis数据")
|
||||
public ResponseResult<Boolean> locationReceive(String bbid) {
|
||||
String redisKey = Constant.WZ_XFWZ + bbid;
|
||||
redisService.deleteObject(redisKey);
|
||||
return ResponseResult.success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "获取报备redis数据")
|
||||
public ResponseResult<List<TbWzXfwz>> locationReceive() {
|
||||
List<TbWzXfwz> array = new ArrayList<>();
|
||||
String key = Constant.WZ_XFWZ + "*";
|
||||
Set<String> sets = redisTemplate.keys(key);
|
||||
if (!CollectionUtils.isEmpty(sets)) {
|
||||
List<TbWzXfwz> list = redisTemplate.opsForValue().multiGet(sets);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(item -> {
|
||||
item.setZb(null);
|
||||
array.add(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
return ResponseResult.success(array);
|
||||
}
|
||||
|
||||
@GetMapping("/getXfgj")
|
||||
@ApiOperation(value = "获取redis中的巡组的巡防轨迹信息")
|
||||
public ResponseResult<TbWzXfwz> getXfgj(String bbid) {
|
||||
if (StringUtils.isEmpty(bbid)) return null;
|
||||
String key = Constant.WZ_XFWZ + bbid;
|
||||
TbWzXfwz xfwz = redisService.getCacheObject(key);
|
||||
return ResponseResult.success(xfwz);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,98 @@
|
||||
package com.mosty.wzzx.controller;
|
||||
|
||||
import com.mosty.base.model.query.wzzx.TbWzLswzSearchDto;
|
||||
import com.mosty.base.model.query.wzzx.TbWzSbLswzSearchDto;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.entity.log.BusinessType;
|
||||
import com.mosty.common.base.entity.log.Log;
|
||||
import com.mosty.common.token.JwtSysUser;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.base.model.dto.wzzx.AppLocationReceiveDto;
|
||||
import com.mosty.wzzx.service.TbWzXfwzService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@Api(tags = "巡防位置相关接口")
|
||||
@RequestMapping("/tbWzXfwz")
|
||||
public class TbWzXfwzController {
|
||||
|
||||
private final TbWzXfwzService tbWzXfwzService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询所有数据")
|
||||
@JwtSysUser
|
||||
public ResponseEntity<List> queryAll() {
|
||||
return ResponseEntity.ok(this.tbWzXfwzService.queryAll());
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation(value = "通过主键查询单条数据")
|
||||
@JwtSysUser
|
||||
public ResponseEntity<TbWzXfwz> queryById(@PathVariable("id") String id) {
|
||||
return ResponseEntity.ok(this.tbWzXfwzService.queryById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增数据")
|
||||
@JwtSysUser
|
||||
public ResponseEntity<TbWzXfwz> add(TbWzXfwz tbWzXfwz) {
|
||||
return ResponseEntity.ok(this.tbWzXfwzService.insert(tbWzXfwz));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "编辑数据")
|
||||
@JwtSysUser
|
||||
public ResponseEntity<TbWzXfwz> edit(TbWzXfwz tbWzXfwz) {
|
||||
return ResponseEntity.ok(this.tbWzXfwzService.update(tbWzXfwz));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "删除数据")
|
||||
@JwtSysUser
|
||||
public ResponseEntity<Boolean> deleteById(String id) {
|
||||
return ResponseEntity.ok(this.tbWzXfwzService.deleteById(id));
|
||||
}
|
||||
|
||||
@PostMapping("/selectTrack")
|
||||
@ApiOperation(value = "大屏-地图-轨迹回放")
|
||||
@Log(title = "大屏-地图-轨迹回放", businessType = BusinessType.OTHER)
|
||||
@JwtSysUser
|
||||
public ResponseResult selectTrack(@RequestBody TbWzXfwz tbWzXfwz) {
|
||||
return ResponseResult.success(tbWzXfwzService.selectTrack(tbWzXfwz));
|
||||
}
|
||||
|
||||
@PostMapping("/selectLswz")
|
||||
@ApiOperation(value = "历史位置轨迹回放")
|
||||
@Log(title = "历史位置轨迹回放", businessType = BusinessType.OTHER)
|
||||
@JwtSysUser
|
||||
public ResponseResult selectLswz(@RequestBody TbWzLswzSearchDto dto) {
|
||||
return ResponseResult.success(tbWzXfwzService.selectLswz(dto));
|
||||
}
|
||||
|
||||
@PostMapping("/locationReceive")
|
||||
@ApiOperation(value = "接收app端位置数据")
|
||||
@Log(title = "接收app端位置数据", businessType = BusinessType.OTHER)
|
||||
@JwtSysUser
|
||||
public ResponseResult locationReceive(@RequestBody AppLocationReceiveDto receiveDto) {
|
||||
return ResponseResult.success(this.tbWzXfwzService.locationReceive(receiveDto));
|
||||
}
|
||||
|
||||
@PostMapping("/selectSbLswz")
|
||||
@ApiOperation(value = "设备历史位置轨迹回放")
|
||||
@Log(title = "设备历史位置轨迹回放", businessType = BusinessType.OTHER)
|
||||
@JwtSysUser
|
||||
public ResponseResult selectSbLswz(@RequestBody TbWzSbLswzSearchDto dto) {
|
||||
return ResponseResult.success(tbWzXfwzService.selectSbLswz(dto));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.mosty.wzzx.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.mosty.base.model.dto.wzzx.WzcxQuery;
|
||||
import com.mosty.base.model.dto.wzzx.WztjQuery;
|
||||
import com.mosty.common.base.domain.BaseController;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.token.JwtSysUser;
|
||||
import com.mosty.wzzx.service.WztjService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
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;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@Api(tags = "位置查询--原magic接口")
|
||||
@RequestMapping("/wzcx")
|
||||
public class WzcxController extends BaseController {
|
||||
|
||||
private final WztjService wztjService;
|
||||
|
||||
@GetMapping("/bbgjcx")
|
||||
@ApiOperation(value = "报备轨迹查询")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> bbgjcx(WzcxQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.bbgjcx(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/bbwzcx")
|
||||
@ApiOperation(value = "报备位置查询")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> bbwzcx(WzcxQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.bbwzcx(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/mjgjcx")
|
||||
@ApiOperation(value = "民警轨迹查询")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> mjgjcx(WzcxQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.mjgjcx(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/wbbwz")
|
||||
@ApiOperation(value = "未报备位置查询")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> wbbwz(WzcxQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.wbbwz(dto));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,114 @@
|
||||
package com.mosty.wzzx.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.mosty.base.model.dto.wzzx.WztjQuery;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSblswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.common.base.domain.BaseController;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.token.JwtSysUser;
|
||||
import com.mosty.wzzx.service.WztjService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@Api(tags = "位置统计--原magic接口")
|
||||
@RequestMapping("/wztj")
|
||||
public class WztjController extends BaseController {
|
||||
|
||||
private final WztjService wztjService;
|
||||
|
||||
@GetMapping("/dt/rywz")
|
||||
@ApiOperation(value = "人员位置")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> rywz(WztjQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.rywz(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/dt/xz")
|
||||
@ApiOperation(value = "巡组位置")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> xz(WztjQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.xz(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/tj/jrlcs")
|
||||
@ApiOperation(value = "里程数")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> jrlcs(WztjQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.jrlcs(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/tj/rslcxz")
|
||||
@ApiOperation(value = "人数里程巡组整合")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> rslcxz(WztjQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.rslcxz(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/tj/jrwzrs")
|
||||
@ApiOperation(value = "位置人数")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> jrwzrs(WztjQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.jrwzrs(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/tj/jrxzwzs")
|
||||
@ApiOperation(value = "巡组位置数")
|
||||
@JwtSysUser
|
||||
public ResponseResult<List<Map<String, Object>>> jrxzwzs(WztjQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.jrxzwzs(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/wz/rywzlb")
|
||||
@ApiOperation(value = "人员位置列表")
|
||||
@JwtSysUser
|
||||
public ResponseResult<IPage<Map<String, Object>>> rywzlb(WztjQuery dto) {
|
||||
return ResponseResult.success(this.wztjService.rywzlb(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/tj/xfsltj")
|
||||
@ApiOperation(value = "巡组数量统计")
|
||||
@JwtSysUser
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "1.今天 2.7天 3.30天", required = true, dataType = "String"),
|
||||
})
|
||||
public ResponseResult<Map<String, Object>> xfsltj(String type) {
|
||||
return ResponseResult.success(this.wztjService.xfsltj(type));
|
||||
}
|
||||
|
||||
@GetMapping("/tj/rysltj")
|
||||
@ApiOperation(value = "人员数量统计")
|
||||
@JwtSysUser
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "1.今天 2.7天 3.30天", required = true, dataType = "String"),
|
||||
})
|
||||
public ResponseResult<Map<String, Object>> rysltj(String type) {
|
||||
return ResponseResult.success(this.wztjService.rysltj(type));
|
||||
}
|
||||
|
||||
@GetMapping("/tj/sblswz")
|
||||
@ApiOperation(value = "设备数量统计")
|
||||
@JwtSysUser
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "1.今天 2.7天 3.30天", required = true, dataType = "String"),
|
||||
})
|
||||
public ResponseResult<Map<String, Object>> sblswz(String type) {
|
||||
return ResponseResult.success(this.wztjService.sblswz(type));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.dto.wzzx.XfbbUpdateDto;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
/**
|
||||
* <p>
|
||||
* 巡防报备表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zengbo
|
||||
* @since 2022-06-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbQwXfbbMapper extends BaseMapper<TbQwXfbb> {
|
||||
|
||||
@ApiOperation("id查询")
|
||||
TbQwXfbb queryById(@Param("id") String id);
|
||||
|
||||
@ApiOperation("修改巡防报备")
|
||||
Integer updateXfbb(XfbbUpdateDto xfbbUpdateDto);
|
||||
|
||||
@ApiOperation("查询是否报备")
|
||||
int getsfbb(String id);
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwZnzb;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 巡防排班或报备或值班-通讯装备表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zengbo
|
||||
* @since 2022-06-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbQwZnzbMapper extends BaseMapper<TbQwZnzb> {
|
||||
|
||||
/**
|
||||
* 根据 业务ID查询
|
||||
*
|
||||
* @param ywidList
|
||||
* @return
|
||||
*/
|
||||
List<TbQwZnzb> queryListByYwid(@Param("list") List<String> ywidList);
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.dto.wzzx.SjCyjlUpdateDto;
|
||||
import com.mosty.base.model.entity.sjzx.TbSjCyjl;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件参与警力 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zengbo
|
||||
* @since 2022-06-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbSjCyjlMapper extends BaseMapper<TbSjCyjl> {
|
||||
|
||||
@ApiOperation("id查询")
|
||||
TbSjCyjl queryBySfzh(@Param("sfzh") String sfzh);
|
||||
|
||||
@ApiOperation("修改参与警力坐标")
|
||||
Integer updateZb(SjCyjlUpdateDto sjCyjlUpdateDto);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzLswz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 位置-历史位置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zengbo
|
||||
* @since 2022-08-29
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbWzLswzMapper extends BaseMapper<TbWzLswz> {
|
||||
|
||||
@ApiOperation("历史位置")
|
||||
int insertEntity(TbWzLswz tbWzLswz);
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.query.wzzx.TbWzRywzSearchDto;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 位置-人员位置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zengbo
|
||||
* @since 2022-08-29
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbWzRywzMapper extends BaseMapper<TbWzRywz> {
|
||||
|
||||
@ApiOperation("添加人员位置信息")
|
||||
int insertEntity(TbWzRywz tbWzRywz);
|
||||
|
||||
@ApiOperation("修改盘查车辆对象")
|
||||
void updateEntity(TbWzRywz tbWzRywz);
|
||||
|
||||
TbWzRywz queryBySfzh(@Param("yhSfzh") String yhSfzh);
|
||||
|
||||
@ApiOperation("查询人员位置信息")
|
||||
TbWzRywz selectBySfz(TbWzRywzSearchDto dto);
|
||||
|
||||
@ApiOperation("去重人员数量统计")
|
||||
int getRysltjCount(@Param("kssj") String kssj,
|
||||
@Param("jssj") String jssj,
|
||||
@Param("useSql") String useSql);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSblswz;
|
||||
import com.mosty.base.model.query.wzzx.TbWzSbLswzSearchDto;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 位置-设备历史位置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zengbo
|
||||
* @since 2022-08-29
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbWzSblswzMapper extends BaseMapper<TbWzSblswz> {
|
||||
|
||||
@ApiOperation("设备历史位置")
|
||||
int insertEntity(TbWzSblswz tbWzSblswz);
|
||||
|
||||
@ApiOperation("去重设备数量统计")
|
||||
int getSblswzCount(@Param("kssj") String kssj,
|
||||
@Param("jssj") String jssj,
|
||||
@Param("useSql") String useSql);
|
||||
|
||||
@ApiOperation("设备历史位置")
|
||||
List<TbWzSblswz> selectSbLswz(TbWzSbLswzSearchDto dto);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 位置-设备实时位置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zengbo
|
||||
* @since 2022-08-29
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbWzSbsswzMapper extends BaseMapper<TbWzSbsswz> {
|
||||
|
||||
@ApiOperation("设备实时位置")
|
||||
Integer insertEntity(TbWzSbsswz tbWzSbsswz);
|
||||
|
||||
@ApiOperation("删除7日前的设备实时位置")
|
||||
Integer delHistory();
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSswz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 位置-实时位置表(只存7天数据) Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zengbo
|
||||
* @since 2022-08-29
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbWzSswzMapper extends BaseMapper<TbWzSswz> {
|
||||
|
||||
@ApiOperation("添加实时位置表")
|
||||
int insertEntity(TbWzSswz tbWzSswz);
|
||||
|
||||
@ApiOperation("根据ID查询实时位置")
|
||||
TbWzSswz queryById(@Param("id") String id);
|
||||
|
||||
@ApiOperation("查询用户最新的位置")
|
||||
TbWzSswz querySswzNow(@Param("yhId") String yhId, @Param("jrbh") String jrbh);
|
||||
|
||||
@ApiOperation("查询当日的实时位置")
|
||||
List<TbWzSswz> querySswzToday(@Param("yhId") String yhId, @Param("jrbh") String jrbh);
|
||||
|
||||
@ApiOperation("查询当日的用户ID")
|
||||
List<String> querySswzYhid();
|
||||
|
||||
@ApiOperation("删除7日前的实时位置")
|
||||
Integer delHistory();
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 位置-巡防位置表(TbWzXfwz)表数据库访问层
|
||||
*
|
||||
* @author zhangHaiJun
|
||||
* @since 2022-07-14 15:37:38
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbWzXfwzMapper extends BaseMapper<TbWzXfwz> {
|
||||
|
||||
@ApiOperation("查询所有数据")
|
||||
List<TbWzXfwz> queryAll();
|
||||
|
||||
@ApiOperation("通过ID查询单条数据")
|
||||
TbWzXfwz queryById(String id);
|
||||
|
||||
@ApiOperation("统计总行数")
|
||||
long count(TbWzXfwz tbWzXfwz);
|
||||
|
||||
@ApiOperation("新增数据")
|
||||
int insert(TbWzXfwz tbWzXfwz);
|
||||
|
||||
@ApiOperation("批量新增数据(MyBatis原生foreach方法)")
|
||||
int insertBatch(@Param("entities") List<TbWzXfwz> entities);
|
||||
|
||||
@ApiOperation("批量新增或按主键更新数据(MyBatis原生foreach方法)")
|
||||
int insertOrUpdateBatch(@Param("entities") List<TbWzXfwz> entities);
|
||||
|
||||
@ApiOperation("修改数据")
|
||||
int update(TbWzXfwz tbWzXfwz);
|
||||
|
||||
@ApiOperation("通过主键删除数据")
|
||||
int deleteById(String id);
|
||||
|
||||
@ApiOperation("查询所有数据")
|
||||
TbWzXfwz queryByBbid(@Param("bbid") String bbid);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,49 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface WztjMapper {
|
||||
|
||||
@ApiOperation("人员位置")
|
||||
List<Map<String, Object>> jwzbmlbtj(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("巡组位置")
|
||||
List<Map<String, Object>> xz(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("里程数")
|
||||
List<Map<String, Object>> jrlcs(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("人数里程巡组整合")
|
||||
List<Map<String, Object>> rslcxz(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("位置人数")
|
||||
List<Map<String, Object>> jrwzrs(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("巡组位置数")
|
||||
List<Map<String, Object>> jrxzwzs(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("人员位置数量")
|
||||
int rywzlbCount(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("人员位置列表")
|
||||
List<Map<String, Object>> rywzlb(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("报备轨迹查询")
|
||||
List<Map<String, Object>> bbgjcx(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("报备位置查询")
|
||||
List<Map<String, Object>> bbwzcx(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("民警轨迹查询")
|
||||
List<Map<String, Object>> mjgjcx(Map<String, Object> map);
|
||||
|
||||
@ApiOperation("未报备位置查询")
|
||||
List<Map<String, Object>> wbbwz(Map<String, Object> map);
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.mosty.wzzx.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mosty.common.core.business.entity.SysUser;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户服务dao层
|
||||
* @author kevin
|
||||
* @date 2022/2/12 10:10 PM
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface WzzxUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
@ApiOperation("分页查询用户信息")
|
||||
List<SysUser> selectByPage();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,117 @@
|
||||
package com.mosty.wzzx.mybatisplus;
|
||||
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.mosty.common.base.exception.BusinessException;
|
||||
import com.mosty.common.base.util.IpUtil;
|
||||
import com.mosty.common.token.UserInfo;
|
||||
import com.mosty.common.token.UserInfoManager;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* MybatisPlus注入处理器
|
||||
*
|
||||
* @author Lhh
|
||||
* @date 2021/4/25
|
||||
*/
|
||||
public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
try {
|
||||
UserInfo userInfo = UserInfoManager.getUser();
|
||||
//根据属性名字设置要填充的值
|
||||
if (metaObject.hasGetter("xtCjip")) {
|
||||
if (metaObject.getValue("xtCjip") == null) {
|
||||
this.strictInsertFill(metaObject, "xtCjip", String.class, IpUtil.getIpAddress());
|
||||
}
|
||||
}
|
||||
//根据属性名字设置要填充的值
|
||||
if (metaObject.hasGetter("xtSjzt")) {
|
||||
if (metaObject.getValue("xtSjzt") == null) {
|
||||
this.strictInsertFill(metaObject, "xtSjzt", String.class, "1");
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("xtScbz")) {
|
||||
if (metaObject.getValue("xtScbz") == null) {
|
||||
this.strictInsertFill(metaObject, "xtScbz", String.class, "0");
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("xtCjsj")) {
|
||||
if (metaObject.getValue("xtCjsj") == null) {
|
||||
this.strictInsertFill(metaObject, "xtCjsj", Timestamp.class, new Timestamp(System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(userInfo)) {
|
||||
if (metaObject.hasGetter("xtCjrId")) {
|
||||
if (metaObject.getValue("xtCjrId") == null) {
|
||||
this.strictInsertFill(metaObject, "xtCjrId", String.class, String.valueOf(userInfo.userId));
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("xtCjr")) {
|
||||
if (metaObject.getValue("xtCjr") == null) {
|
||||
this.strictInsertFill(metaObject, "xtCjr", String.class, String.valueOf(userInfo.userName));
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("xtCjbmdm")) {
|
||||
if (metaObject.getValue("xtCjbmdm") == null) {
|
||||
this.strictInsertFill(metaObject, "xtCjbmdm", String.class, String.valueOf(userInfo.getDeptId()));
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("xtCjbmmc")) {
|
||||
if (metaObject.getValue("xtCjbmmc") == null) {
|
||||
this.strictInsertFill(metaObject, "xtCjbmmc", String.class, userInfo.getDeptName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
try {
|
||||
UserInfo userInfo = UserInfoManager.getUser();
|
||||
if (metaObject.hasGetter("xtZhgxip")) {
|
||||
if (metaObject.getValue("xtZhgxip") == null) {
|
||||
this.strictUpdateFill(metaObject, "xtZhgxip", String.class, IpUtil.getIpAddress());
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("xtZhgxsj")) {
|
||||
if (metaObject.getValue("xtZhgxsj") == null) {
|
||||
this.strictUpdateFill(metaObject, "xtZhgxsj", Timestamp.class, new Timestamp(System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(userInfo)) {
|
||||
if (metaObject.hasGetter("xtZhgxrid")) {
|
||||
if (metaObject.getValue("xtZhgxrid") == null) {
|
||||
this.strictUpdateFill(metaObject, "xtZhgxrid", String.class, String.valueOf(userInfo.userId));
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("xtZhgxr")) {
|
||||
if (metaObject.getValue("xtZhgxr") == null) {
|
||||
this.strictUpdateFill(metaObject, "xtZhgxr", String.class, userInfo.userName);
|
||||
}
|
||||
}
|
||||
|
||||
if (metaObject.hasGetter("xtZhgxbmdm")) {
|
||||
if (metaObject.getValue("xtZhgxbmdm") == null) {
|
||||
this.strictUpdateFill(metaObject, "xtZhgxbmdm", String.class, String.valueOf(userInfo.getDeptId()));
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("xtZhgxbm")) {
|
||||
if (metaObject.getValue("xtZhgxbm") == null) {
|
||||
this.strictUpdateFill(metaObject, "xtZhgxbm", String.class, userInfo.getDeptName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.mosty.wzzx.mybatisplus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* mybatis-plus配置类
|
||||
*
|
||||
* @author Lhh
|
||||
*/
|
||||
@EnableTransactionManagement(proxyTargetClass = true)
|
||||
@Configuration
|
||||
@MapperScan("com.mosty.wzzx.mapper")
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 元对象字段填充控制器
|
||||
* https://baomidou.com/guide/auto-fill-metainfo.html
|
||||
*/
|
||||
@Bean
|
||||
public MetaObjectHandler metaObjectHandler() {
|
||||
return new CreateAndUpdateMetaObjectHandler();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.mosty.wzzx.remote;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mosty.base.model.dto.base.GetSsbmDto;
|
||||
import com.mosty.base.model.dto.base.SysDeptDTO;
|
||||
import com.mosty.base.feign.service.MostyBaseFeignService;
|
||||
import com.mosty.base.model.vo.base.DeptInfoVo;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.exception.BusinessException;
|
||||
import com.mosty.common.core.business.entity.SysUser;
|
||||
import com.mosty.common.core.business.entity.vo.SysUserVO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 调用部门信息远程适配层
|
||||
*
|
||||
* @author kevin
|
||||
* @date 2022/7/6 10:37 上午
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TbBaseAdaptRemoteService {
|
||||
|
||||
private final MostyBaseFeignService mostyBaseFeignService;
|
||||
|
||||
// 根据部门编码查询部门信息
|
||||
public DeptInfoVo getOrgByDeptId(String deptId) {
|
||||
if (StringUtils.isBlank(deptId)) {
|
||||
return null;
|
||||
}
|
||||
ResponseResult<DeptInfoVo> responseResult = mostyBaseFeignService.getOrgByDeptId(deptId);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("调用部门编码查询部门信息异常 responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("调用部门编码查询部门信息异常");
|
||||
}
|
||||
return responseResult.getData();
|
||||
}
|
||||
|
||||
// 获取用户部门信息
|
||||
public DeptInfoVo getDeptInfoByUserId(String userId) {
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return null;
|
||||
}
|
||||
ResponseResult<DeptInfoVo> responseResult = mostyBaseFeignService.getDeptInfoByUserId(userId);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("获取用户部门信息异常 responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("获取用户部门信息异常");
|
||||
}
|
||||
return responseResult.getData();
|
||||
}
|
||||
// 获取权限查询条件
|
||||
public String getSsbm(String ssbmdm, String isChild) {
|
||||
GetSsbmDto dto = new GetSsbmDto(ssbmdm, isChild);
|
||||
ResponseResult<String> responseResult = mostyBaseFeignService.getSsbm(dto);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("获取权限查询条件异常 responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("获取权限查询条件异常");
|
||||
}
|
||||
return responseResult.getData();
|
||||
}
|
||||
// 获取用户信息
|
||||
public SysUser getUserInfoBySfzh(String sfzh) {
|
||||
ResponseResult<SysUser> responseResult = mostyBaseFeignService.getUserInfoBySfzh(sfzh);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("获取用户信息失败, responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("获取用户信息失败");
|
||||
}
|
||||
return responseResult.getData();
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.mosty.wzzx.remote;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mosty.base.feign.service.MostyQwzxFeignService;
|
||||
import com.mosty.base.model.dto.qwzx.TbQwJlDto;
|
||||
import com.mosty.base.model.dto.qwzx.TbQwXfbbVo;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.exception.BusinessException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 勤务中心远程调用
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TbQwzxAdaptRemoteService {
|
||||
|
||||
private final MostyQwzxFeignService mostyQwzxFeignService;
|
||||
|
||||
// 根据设备ID查询该设备所在的巡组
|
||||
public List<TbQwXfbb> getBbList(String sbid) {
|
||||
ResponseResult<List<TbQwXfbb>> responseResult = mostyQwzxFeignService.getBbList(sbid);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("获取巡组信息 失败 responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("获取巡组信息异常!");
|
||||
}
|
||||
return responseResult.getData();
|
||||
}
|
||||
|
||||
// 根据设备ID查询该设备所在的巡组
|
||||
public List<TbQwXfbb> getClBbList(String sbid) {
|
||||
ResponseResult<List<TbQwXfbb>> responseResult = mostyQwzxFeignService.getClBbList(sbid);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("获取巡组信息 失败 responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("获取巡组信息异常!");
|
||||
}
|
||||
return responseResult.getData();
|
||||
}
|
||||
|
||||
// 查询报备信息
|
||||
public TbQwXfbb getBbxxInfo(String id) {
|
||||
ResponseResult<TbQwXfbb> responseResult = mostyQwzxFeignService.getBbxxInfo(id);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("查询报备信息 失败 responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("查询报备信息异常!");
|
||||
}
|
||||
return responseResult.getData();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.mosty.wzzx.remote;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mosty.base.feign.service.MostyWebSocketFeignService;
|
||||
import com.mosty.base.model.dto.websocket.WebSocketObject;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dw
|
||||
* @since 2022/7/23
|
||||
* websocket外部调用基础管理接口
|
||||
**/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TbWebSocketAdaptRemoteService {
|
||||
|
||||
@Resource
|
||||
private MostyWebSocketFeignService mostyWebSocketFeignService;
|
||||
|
||||
// 发送报备数据websocket信息
|
||||
public void sendBbMessage(WebSocketObject obj) {
|
||||
ResponseResult<Void> responseResult = this.mostyWebSocketFeignService.sendBbMessage(obj);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("发送报备数据websocket信息 异常 Result = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("发送报备数据websocket信息 异常");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.mosty.wzzx.remote;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mosty.base.feign.service.MostyQwzxFeignService;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Created by
|
||||
*
|
||||
* @ClassName TbXfbbAdaptRemoteService
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TbXfbbAdaptRemoteService {
|
||||
|
||||
private final MostyQwzxFeignService mostyQwzxFeignService;
|
||||
|
||||
/**
|
||||
* 查询预警信息
|
||||
* @param id 内容
|
||||
* @return 部门信息
|
||||
*/
|
||||
public JSONObject getBbxx(String id) {
|
||||
ResponseResult responseResult = mostyQwzxFeignService.getBbInfo(id);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("查询报备信息异常Result = {}", JSON.toJSONString(responseResult));
|
||||
return null;
|
||||
}
|
||||
return JSONObject.parseObject(JSONObject.toJSONString(responseResult.getData()));
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.mosty.wzzx.remote;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mosty.base.feign.service.MostyYjzlFeignService;
|
||||
import com.mosty.base.model.dto.yjzl.TbZlxxInsertDto;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import com.mosty.base.model.vo.wzzx.TbWzSblswzVo;
|
||||
import com.mosty.base.model.vo.yjzl.TbFzJlVo;
|
||||
import com.mosty.common.base.domain.ResponseResult;
|
||||
import com.mosty.common.base.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dw
|
||||
* @since 2022/12/9
|
||||
* 外部调用预警指令要素接口
|
||||
**/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TbYjzlAdaptRemoteService {
|
||||
|
||||
@Resource
|
||||
private MostyYjzlFeignService mostyYjzlFeignService;
|
||||
|
||||
// 添加指令信息
|
||||
public void addZl(TbZlxxInsertDto dto) {
|
||||
ResponseResult<Void> responseResult = this.mostyYjzlFeignService.addZl(dto);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("添加指令信息失败 responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("添加指令信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 修改预警信息是否发送指令
|
||||
public void updateYjxxSffszl(String id) {
|
||||
ResponseResult<Void> responseResult = this.mostyYjzlFeignService.updateYjxxSffszl(id);
|
||||
if (responseResult == null || !responseResult.isSuccess()) {
|
||||
log.error("修改预警信息是否发送指令失败 responseResult = {}", JSON.toJSONString(responseResult));
|
||||
throw new BusinessException("修改预警信息是否发送指令失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.mosty.base.model.dto.wzzx.AppLocationReceiveDto;
|
||||
import com.mosty.base.model.dto.wzzx.LocationConvertDTO;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
public interface LocationInfoService {
|
||||
|
||||
@ApiOperation("位置接收")
|
||||
void locationReceive(LocationInfo locationInfo);
|
||||
|
||||
@ApiOperation("保存人员位置")
|
||||
TbWzRywz saveRywz(LocationInfo locationInfo);
|
||||
|
||||
@ApiOperation("保存巡防位置")
|
||||
Integer saveXfwz(TbQwXfbb bb, LocationInfo locationInfo, TbWzRywz rywz);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
public interface TbQwXfbbService {
|
||||
|
||||
@ApiOperation("根据ID更新")
|
||||
Integer updateXfbb(TbQwXfbb bb,LocationInfo locationInfo, TbWzRywz rywz,Integer lc);
|
||||
|
||||
@ApiOperation("根据ID更新")
|
||||
Integer updateById(String id, LocationInfo locationInfo);
|
||||
|
||||
@ApiOperation("udp更新报备位置")
|
||||
void updateXfbbUdp(TbQwXfbb bb, TbWzSbsswz sbsswz,Integer lc);
|
||||
|
||||
@ApiOperation("查询是否报备")
|
||||
int getsfbb(String id);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
|
||||
import com.mosty.base.model.entity.qwzx.TbQwZnzb;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbQwZnzbService {
|
||||
|
||||
@ApiOperation("根据业务ID查询智能装备")
|
||||
List<TbQwZnzb> queryListByYwid(List<String> ywidList);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.dto.wzzx.SjCyjlUpdateDto;
|
||||
import com.mosty.base.model.entity.sjzx.TbSjCyjl;
|
||||
import com.mosty.base.utils.GeoHashKit;
|
||||
import com.mosty.base.utils.JtsUtils;
|
||||
import com.mosty.wzzx.mapper.TbSjCyjlMapper;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public interface TbSjCyjlService {
|
||||
|
||||
@ApiOperation("更新事件参与警力坐标")
|
||||
Integer updateJlZb(LocationInfo locationInfo);
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
public interface TbWzLswzService{
|
||||
|
||||
@ApiOperation("保存历史记录")
|
||||
void saveLswz(LocationInfo locationInfo, TbWzRywz rywz);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
public interface TbWzSblswzService {
|
||||
|
||||
@ApiOperation("保存设备历史位置记录")
|
||||
void saveSblswz(TbWzSbsswz sbsswz);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import com.mosty.wzzx.udp.UdpLzEntity;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
public interface TbWzSbsswzService{
|
||||
|
||||
@ApiOperation("删除历史数据")
|
||||
void delHistory();
|
||||
|
||||
@ApiOperation("保存泸州设备实时位置")
|
||||
TbWzSbsswz saveSbsswz(UdpLzEntity lzEntity);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSswz;
|
||||
import com.mosty.base.model.query.wzzx.TbWzRywzSearchDto;
|
||||
import com.mosty.base.model.query.wzzx.TbWzSswzSearchDto;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TbWzSswzService {
|
||||
|
||||
@ApiOperation("保存实时记录")
|
||||
void saveSswz(LocationInfo locationInfo, TbWzRywz rywz);
|
||||
|
||||
@ApiOperation("添加位置")
|
||||
TbWzSswz insert(LocationInfo locationInfo);
|
||||
|
||||
@ApiOperation("添加位置")
|
||||
TbWzSswz insertEntity(TbWzSswz sswz);
|
||||
|
||||
@ApiOperation("根据ID查询")
|
||||
TbWzSswz queryById(String id);
|
||||
|
||||
@ApiOperation("")
|
||||
TbWzSswz querySswzNow(String yhid, String jrbh);
|
||||
|
||||
@ApiOperation("删除历史数据")
|
||||
void delHistory();
|
||||
|
||||
@ApiOperation("获取时间段类的人员轨迹信息俩表")
|
||||
IPage<TbWzSswz> getRygjList(TbWzSswzSearchDto dto);
|
||||
|
||||
@ApiOperation("查询某一天的人员位置信息")
|
||||
TbWzRywz getRywz(TbWzRywzSearchDto dto);
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.base.model.dto.wzzx.AppLocationReceiveDto;
|
||||
import com.mosty.base.model.query.wzzx.TbWzLswzSearchDto;
|
||||
import com.mosty.base.model.query.wzzx.TbWzSbLswzSearchDto;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 位置-巡防位置表(TbWzXfwz)表服务接口
|
||||
*/
|
||||
public interface TbWzXfwzService {
|
||||
|
||||
@ApiOperation("查询所有数据")
|
||||
List<TbWzXfwz> queryAll();
|
||||
|
||||
@ApiOperation("通过ID查询单条数据")
|
||||
TbWzXfwz queryById(String id);
|
||||
|
||||
@ApiOperation("新增数据")
|
||||
TbWzXfwz insert(TbWzXfwz tbWzXfwz);
|
||||
|
||||
@ApiOperation("修改数据")
|
||||
TbWzXfwz update(TbWzXfwz tbWzXfwz);
|
||||
|
||||
@ApiOperation("通过主键删除数据")
|
||||
boolean deleteById(String id);
|
||||
|
||||
@ApiOperation("大屏-地图-轨迹回放")
|
||||
Object selectTrack(TbWzXfwz tbWzXfwz);
|
||||
|
||||
@ApiOperation("历史位置轨迹回放")
|
||||
Object selectLswz(TbWzLswzSearchDto dto);
|
||||
|
||||
@ApiOperation("位置接收")
|
||||
Boolean locationReceive(AppLocationReceiveDto receiveDto);
|
||||
|
||||
@ApiOperation("设备历史位置轨迹回放")
|
||||
Object selectSbLswz(TbWzSbLswzSearchDto dto);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.mosty.base.model.dto.wzzx.WzcxQuery;
|
||||
import com.mosty.base.model.dto.wzzx.WztjQuery;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface WztjService {
|
||||
|
||||
@ApiOperation("人员位置")
|
||||
List<Map<String,Object>> rywz(WztjQuery dto);
|
||||
|
||||
@ApiOperation("巡组位置")
|
||||
List<Map<String,Object>> xz(WztjQuery dto);
|
||||
|
||||
@ApiOperation("里程数")
|
||||
List<Map<String,Object>> jrlcs(WztjQuery dto);
|
||||
|
||||
@ApiOperation("人数里程巡组整合")
|
||||
List<Map<String,Object>> rslcxz(WztjQuery dto);
|
||||
|
||||
@ApiOperation("位置人数")
|
||||
List<Map<String,Object>> jrwzrs(WztjQuery dto);
|
||||
|
||||
@ApiOperation("巡组位置数")
|
||||
List<Map<String,Object>> jrxzwzs(WztjQuery dto);
|
||||
|
||||
@ApiOperation("人员位置列表")
|
||||
IPage<Map<String,Object>> rywzlb(WztjQuery dto);
|
||||
|
||||
@ApiOperation("报备轨迹查询")
|
||||
List<Map<String,Object>> bbgjcx(WzcxQuery dto);
|
||||
|
||||
@ApiOperation("报备位置查询")
|
||||
List<Map<String,Object>> bbwzcx(WzcxQuery dto);
|
||||
|
||||
@ApiOperation("民警轨迹查询")
|
||||
List<Map<String,Object>> mjgjcx(WzcxQuery dto);
|
||||
|
||||
@ApiOperation("未报备位置查询")
|
||||
List<Map<String,Object>> wbbwz(WzcxQuery dto);
|
||||
|
||||
@ApiOperation("巡组数量统计")
|
||||
Map<String, Object> xfsltj(String type);
|
||||
|
||||
@ApiOperation("人员数量统计")
|
||||
Map<String, Object> rysltj(String type);
|
||||
|
||||
@ApiOperation("设备数量统计")
|
||||
Map<String, Object> sblswz(String type);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.mosty.wzzx.service;
|
||||
|
||||
import com.mosty.common.core.business.entity.SysUser;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface WzzxSysUserService {
|
||||
|
||||
@ApiOperation("添加位置")
|
||||
List<SysUser> queryList();
|
||||
|
||||
}
|
@ -0,0 +1,429 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.dto.yjzl.TbZlxxInsertDto;
|
||||
import com.mosty.base.model.dto.yjzl.TbZlxxZxrDtoInsertDto;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.base.model.entity.yjzl.TbYjxx;
|
||||
import com.mosty.base.model.vo.base.DeptInfoVo;
|
||||
import com.mosty.base.utils.*;
|
||||
import com.mosty.common.redis.service.RedisService;
|
||||
import com.mosty.wzzx.mapper.TbWzRywzMapper;
|
||||
import com.mosty.wzzx.mapper.TbWzXfwzMapper;
|
||||
import com.mosty.wzzx.remote.TbBaseAdaptRemoteService;
|
||||
import com.mosty.wzzx.remote.TbQwzxAdaptRemoteService;
|
||||
import com.mosty.wzzx.remote.TbYjzlAdaptRemoteService;
|
||||
import com.mosty.wzzx.service.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class LocationInfoServiceImpl extends ServiceImpl<TbWzXfwzMapper, TbWzXfwz> implements LocationInfoService {
|
||||
|
||||
|
||||
private final TbWzRywzMapper tbWzRywzMapper;
|
||||
private final TbQwXfbbService tbQwXfbbService;
|
||||
private final TbWzSswzService tbWzSswzService;
|
||||
private final TbWzLswzService tbWzLswzService;
|
||||
private final TbSjCyjlService tbSjCyjlService;
|
||||
private final RedisService redisService;
|
||||
private final TbBaseAdaptRemoteService tbBaseAdaptRemoteService;
|
||||
private final TbQwzxAdaptRemoteService tbQwzxAdaptRemoteService;
|
||||
private final TbYjzlAdaptRemoteService tbYjzlAdaptRemoteService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void locationReceive(LocationInfo locationInfo) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
long rytime = 0;
|
||||
long bbtime = 0;
|
||||
long xftime = 0;
|
||||
long sswzTime = 0;
|
||||
long lswzTime = 0;
|
||||
long xfbbTime = 0;
|
||||
|
||||
|
||||
//经度、纬度为空不接收数据
|
||||
try {
|
||||
if (locationInfo.getLng() == null && locationInfo.getLat() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 绵阳存在问题 后台结束报备以后 app没有更新报备id 一直上传位置
|
||||
if (StringUtils.isNotEmpty(locationInfo.getBbid()) || !"null".equals(locationInfo.getBbid())) {
|
||||
int getsfbb = tbQwXfbbService.getsfbb(locationInfo.getBbid());
|
||||
if (getsfbb < 1) {
|
||||
locationInfo.setBbid(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(locationInfo.getBbid()) || "null".equals(locationInfo.getBbid())) {
|
||||
locationInfo.setBbid(null);
|
||||
locationInfo.setJzid(null);
|
||||
locationInfo.setJzmc(null);
|
||||
//保存人员位置
|
||||
TbWzRywz oldRywz = this.saveRywz(locationInfo);
|
||||
// 保存实时位置
|
||||
this.tbWzSswzService.saveSswz(locationInfo, oldRywz);
|
||||
// 保存历史位置
|
||||
this.tbWzLswzService.saveLswz(locationInfo, oldRywz);
|
||||
} else {
|
||||
String bbid, jzid, jzmc;
|
||||
String[] bbidList = locationInfo.getBbid().split("\\(__\\)");
|
||||
String[] jzidList = null;
|
||||
String[] jzmcList = null;
|
||||
if (StringUtils.isNoneBlank(locationInfo.getJzid())) {
|
||||
jzidList = locationInfo.getJzid().split("\\(__\\)");
|
||||
}
|
||||
if (StringUtils.isNoneBlank(locationInfo.getJzmc())) {
|
||||
jzmcList = locationInfo.getJzmc().split("\\(__\\)");
|
||||
}
|
||||
for (int i = 0; i < bbidList.length; i++) {
|
||||
bbid = bbidList[i];
|
||||
if (jzidList != null) {
|
||||
jzid = jzidList[i];
|
||||
locationInfo.setJzid(jzid);
|
||||
}
|
||||
if (jzmcList != null) {
|
||||
jzmc = jzmcList[i];
|
||||
locationInfo.setJzmc(jzmc);
|
||||
}
|
||||
locationInfo.setBbid(bbid);
|
||||
|
||||
// 保存人员位置
|
||||
TbWzRywz oldRywz = this.saveRywz(locationInfo);
|
||||
rytime = System.currentTimeMillis() - startTime;
|
||||
//警务通采集经纬度为辅
|
||||
TbQwXfbb bb = this.tbQwzxAdaptRemoteService.getBbxxInfo(locationInfo.getBbid());
|
||||
bbtime = System.currentTimeMillis() - startTime;
|
||||
// 保存巡防位置
|
||||
Integer lc = this.saveXfwz(bb, locationInfo, oldRywz);
|
||||
xftime = System.currentTimeMillis() - startTime;
|
||||
// log.info("TbQwXfbb :{}", System.currentTimeMillis() - startTime);
|
||||
// 查询巡组实时位置,如果5分钟没有GPS信号,则保存设备的位置信息 (直接判断bb是否在线 在线不添加 不在线 写入数据)
|
||||
// if (bb.getXfzt().equals("2")) {
|
||||
|
||||
// 保存实时位置
|
||||
tbWzSswzService.saveSswz(locationInfo, oldRywz);
|
||||
sswzTime = System.currentTimeMillis() - startTime;
|
||||
// 保存历史位置
|
||||
tbWzLswzService.saveLswz(locationInfo, oldRywz);
|
||||
lswzTime = System.currentTimeMillis() - startTime;
|
||||
// 修改巡防报备的坐标
|
||||
tbQwXfbbService.updateXfbb(bb, locationInfo, oldRywz, lc);
|
||||
xfbbTime = System.currentTimeMillis() - startTime;
|
||||
}
|
||||
|
||||
}
|
||||
long zsc = System.currentTimeMillis() - startTime;
|
||||
if (zsc > 1000) {
|
||||
System.out.println("位置服务上报保存时长{" + zsc + "}----保存人员位置{" + rytime + "}---" +
|
||||
"报备查询{" + bbtime + "}---保存巡防位置{" + xftime + "}-----用户{" + locationInfo.getUserId() + "}----" +
|
||||
"保存实时位置{" + sswzTime + "}---保存历史位置{" + lswzTime + "}---修改巡防报备的坐标{" + xfbbTime + "}-----用户{" + locationInfo.getUserId() + "}");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 生成指令信息
|
||||
private void createdZl(LocationInfo item, TbQwXfbb bb) {
|
||||
String key = Constant.LZYJ_DATA_QKSD;
|
||||
List<TbYjxx> yjxxList = this.redisService.getCacheList(key);
|
||||
if (yjxxList != null && yjxxList.size() > 0) {
|
||||
// 依图人像(脸)
|
||||
List<TbYjxx> ytList = yjxxList.stream().filter(yjxx -> {
|
||||
// 判断相似度大于等于95%
|
||||
if (yjxx.getXsd() == null) {
|
||||
return false;
|
||||
}
|
||||
int a = yjxx.getXsd().compareTo(new BigDecimal("95"));
|
||||
if (a < 0) {
|
||||
return false;
|
||||
}
|
||||
// 预警时间半小时之内
|
||||
if (System.currentTimeMillis() - yjxx.getYjSj().getTime() > 30 * 60 * 1000) {
|
||||
return false;
|
||||
}
|
||||
// 当前位置500米范围内
|
||||
double jl = Kit.getDistance(item.getLng(), item.getLat(), yjxx.getJd().doubleValue(), yjxx.getWd().doubleValue());
|
||||
return !(jl >= 500.0);
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(ytList)) {
|
||||
// 发送指令到巡组
|
||||
this.sendZl(ytList, bb);
|
||||
}
|
||||
// 旅店网吧
|
||||
List<TbYjxx> ldList = yjxxList.stream().filter(yjxx -> {
|
||||
if (yjxx.getXsd() != null) {
|
||||
return false;
|
||||
}
|
||||
// 预警时间两小时之内
|
||||
if (System.currentTimeMillis() - yjxx.getYjSj().getTime() > 120 * 60 * 1000) {
|
||||
return false;
|
||||
}
|
||||
// 当前位置2000米范围内
|
||||
double jl = Kit.getDistance(item.getLng(), item.getLat(), yjxx.getJd().doubleValue(), yjxx.getWd().doubleValue());
|
||||
return !(jl >= 2000);
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(ldList)) {
|
||||
// 发送指令到巡组
|
||||
this.sendZl(ldList, bb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 发送指令到巡组
|
||||
private void sendZl(List<TbYjxx> yjxxList, TbQwXfbb bb) {
|
||||
if (bb != null) {
|
||||
yjxxList.forEach(yjxx -> {
|
||||
TbZlxxInsertDto zl = new TbZlxxInsertDto();
|
||||
zl.setId(UUIDGenerator.getUUID()).setYwId(yjxx.getId()).setZllx("02").setZlly("02").setZlzxlx("1")
|
||||
.setZlbt("请核查" + yjxx.getYjBt()).setZlnr(yjxx.getYjNr() + "请核查!")
|
||||
.setZldj(yjxx.getYjJb()).setJd(yjxx.getJd()).setWd(yjxx.getWd()).setZlfsddxzqh(yjxx.getYjDzXzqh())
|
||||
.setZlfsdd(yjxx.getYjDz()).setZltp(yjxx.getYjTp());
|
||||
zl.setZljsdx("03");
|
||||
zl.setSsbmid(bb.getSsbmid());
|
||||
List<TbZlxxZxrDtoInsertDto> zxrDtoList = new ArrayList<>();
|
||||
TbZlxxZxrDtoInsertDto zxr = new TbZlxxZxrDtoInsertDto();
|
||||
zxr.setZlId(zl.getId()).setZxrLx("03").setZxrXzid(bb.getId());
|
||||
zxrDtoList.add(zxr);
|
||||
yjxx.setBz("范围内500米查询到巡组《" + bb.getJzMc() + "》,已下发");
|
||||
zl.setZxrDtoList(zxrDtoList);
|
||||
this.tbYjzlAdaptRemoteService.addZl(zl);
|
||||
// 修改预警信息相关信息
|
||||
this.tbYjzlAdaptRemoteService.updateYjxxSffszl(yjxx.getId());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbWzRywz saveRywz(LocationInfo locationInfo) {
|
||||
BigDecimal jd = BigDecimal.valueOf(locationInfo.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(locationInfo.getLat());
|
||||
String redisKey = Constant.WZ_RYWZ + locationInfo.getUserId() + "-"
|
||||
+ DateUtils.getQueryDateString(new Date(), "01");
|
||||
Object obj = redisService.getCacheObject(redisKey);
|
||||
TbWzRywz rywz = null;
|
||||
if(obj != null){
|
||||
String objStr = JSONObject.toJSONString(obj, SerializerFeature.DisableCircularReferenceDetect);
|
||||
rywz = JSONObject.parseObject(objStr, TbWzRywz.class);
|
||||
}
|
||||
// TbWzRywz oldRywz = redisService.getCacheObject(redisKey);
|
||||
if (rywz == null) {
|
||||
rywz = new TbWzRywz();
|
||||
}
|
||||
rywz.setYhId(locationInfo.getYhid());
|
||||
rywz.setYhXm(locationInfo.getUserName());
|
||||
rywz.setYhSfzh(locationInfo.getUserId());
|
||||
List<BigDecimal[]> list = rywz.getZbList();
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
Date oldTime = null;
|
||||
if (locationInfo.getLastTime() != null) {
|
||||
oldTime = locationInfo.getLastTime();
|
||||
}
|
||||
|
||||
Integer lc = DistanceUtils.getLc(rywz.getLc(), rywz.getJd(), rywz.getWd(), jd, wd);
|
||||
Integer sc = DistanceUtils.getSc(oldTime);
|
||||
BigDecimal[] decimals = new BigDecimal[2];
|
||||
decimals[0] = jd;
|
||||
decimals[1] = wd;
|
||||
list.add(decimals);
|
||||
if (list.size() == 1) {
|
||||
BigDecimal[] decimals2 = new BigDecimal[2];
|
||||
decimals2[0] = jd.add(new BigDecimal("0.00000001"));
|
||||
decimals2[1] = wd.add(new BigDecimal("0.00000001"));
|
||||
list.add(decimals2);
|
||||
}
|
||||
if (list.size() >= 3) {
|
||||
BigDecimal[] decimal0 = list.get(0);
|
||||
BigDecimal[] decimal1 = list.get(1);
|
||||
if (decimal0 == decimal1) {
|
||||
list.remove(0);
|
||||
}
|
||||
}
|
||||
rywz.setLc(lc);
|
||||
rywz.setSc(sc);
|
||||
rywz.setZb(JtsUtils.createLine(list));
|
||||
rywz.setZbsl(list.size());
|
||||
rywz.setJd(jd);
|
||||
rywz.setWd(wd);
|
||||
rywz.setXtSjly("1");
|
||||
if (StringUtils.isBlank(rywz.getSsbm())) {
|
||||
DeptInfoVo dept = this.tbBaseAdaptRemoteService.getOrgByDeptId(locationInfo.getDeptId());
|
||||
if (dept != null) {
|
||||
rywz.setSsbm(dept.getDeptname());
|
||||
rywz.setSsbmdm(dept.getDeptcode());
|
||||
rywz.setSsbmid(dept.getDeptid());
|
||||
rywz.setSsxgaj(dept.getFxjname());
|
||||
rywz.setSsxgajid(dept.getFxjid());
|
||||
rywz.setSsxgajdm(dept.getFxjcode());
|
||||
rywz.setSssgajid(dept.getDszid());
|
||||
rywz.setSssgaj(dept.getDszname());
|
||||
rywz.setSssgajdm(dept.getDszcode());
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(rywz.getId())) {
|
||||
rywz.setKssj(new Date());
|
||||
rywz.setDwrq(new Date());
|
||||
tbWzRywzMapper.insertEntity(rywz);
|
||||
} else {
|
||||
tbWzRywzMapper.updateEntity(rywz);
|
||||
}
|
||||
rywz.setZb(null);
|
||||
rywz.setZbList(list);
|
||||
redisService.setCacheObject(redisKey, rywz);
|
||||
return rywz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer saveXfwz(TbQwXfbb bb, LocationInfo locationInfo, TbWzRywz rywz) {
|
||||
if (ObjectUtils.isEmpty(locationInfo) && ObjectUtils.isEmpty(rywz) && ObjectUtils.isEmpty(rywz.getJd())) {
|
||||
return 0;
|
||||
}
|
||||
String redisKey = Constant.WZ_XFWZ + locationInfo.getBbid();
|
||||
//直接去redis存在问题 20240307
|
||||
TbWzXfwz xfwz = redisService.getCacheObject(redisKey);
|
||||
Integer lc = 0;
|
||||
// TbWzXfwz xfwz = this.baseMapper.queryByBbid(locationInfo.getBbid());
|
||||
if (ObjectUtils.isEmpty(xfwz)) {
|
||||
xfwz = new TbWzXfwz();
|
||||
}
|
||||
|
||||
// else {
|
||||
// List<BigDecimal[]> list = JtsUtils.getz(xfwz.getZb());
|
||||
// if (CollectionUtils.isEmpty(list)) {
|
||||
// list = new ArrayList<>();
|
||||
// }
|
||||
// if (list.size() >= 3) {
|
||||
// BigDecimal[] decimal0 = list.get(0);
|
||||
// BigDecimal[] decimal1 = list.get(1);
|
||||
// if (decimal0 == decimal1) {
|
||||
// list.remove(0);
|
||||
// }
|
||||
// }
|
||||
// xfwz.setZb(null);
|
||||
// xfwz.setZbList(list);
|
||||
//
|
||||
// }
|
||||
// 查询位置人员是否为改报备巡组的报备人员,
|
||||
// 如果是则直接添加修改位置
|
||||
// 查询巡防位置
|
||||
// TbQwXfbb bb = this.tbQwzxAdaptRemoteService.getBbxxInfo(locationInfo.getBbid());
|
||||
boolean flag = false;
|
||||
if ((bb != null && bb.getFzrSfzh().equals(locationInfo.getUserId()))) {
|
||||
// 是报备负责人
|
||||
flag = true;
|
||||
} else {
|
||||
// 如果redis中没得数据,则直接添加数据
|
||||
if (xfwz.getKssj() == null) {
|
||||
flag = true;
|
||||
} else {
|
||||
// 不是报备本人。需要判断之前的时间是否超过5分钟,超过就更新位置数据,不超过
|
||||
// 就不需要更新
|
||||
Date kssj = xfwz.getKssj();
|
||||
if (System.currentTimeMillis() - kssj.getTime() > 5 * 60 * 1000) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
BigDecimal jd = BigDecimal.valueOf(locationInfo.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(locationInfo.getLat());
|
||||
lc = DistanceUtils.getLc(bb.getXflc(), xfwz.getJd(), xfwz.getWd(), jd, wd);
|
||||
xfwz.setBbId(locationInfo.getBbid());
|
||||
xfwz.setYhId(locationInfo.getYhid());
|
||||
xfwz.setYhSfzh(locationInfo.getUserId());
|
||||
xfwz.setYhXm(locationInfo.getUserName());
|
||||
xfwz.setJzId(locationInfo.getJzid());
|
||||
xfwz.setJzMc(locationInfo.getJzmc());
|
||||
xfwz.setSc(rywz.getSc());
|
||||
xfwz.setLc(rywz.getLc());
|
||||
List<BigDecimal[]> list = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(xfwz.getZbList())) {
|
||||
list = xfwz.getZbList();
|
||||
}
|
||||
BigDecimal[] decimals = new BigDecimal[2];
|
||||
decimals[0] = jd;
|
||||
decimals[1] = wd;
|
||||
list.add(decimals);
|
||||
if (list.size() == 1) {
|
||||
BigDecimal[] decimals2 = new BigDecimal[2];
|
||||
decimals2[0] = jd.add(new BigDecimal("0.00000001"));
|
||||
decimals2[1] = wd.add(new BigDecimal("0.00000001"));
|
||||
list.add(decimals2);
|
||||
}
|
||||
if (list.size() >= 3) {
|
||||
BigDecimal[] decimal0 = list.get(0);
|
||||
BigDecimal[] decimal1 = list.get(1);
|
||||
if (decimal0 == decimal1) {
|
||||
list.remove(0);
|
||||
}
|
||||
}
|
||||
xfwz.setZb(JtsUtils.createLine(list));
|
||||
xfwz.setZbsl(list.size());
|
||||
xfwz.setDwrq(new Date());
|
||||
xfwz.setKssj(new Date());
|
||||
xfwz.setJd(jd);
|
||||
xfwz.setWd(wd);
|
||||
xfwz.setZhgxsj(new Date());
|
||||
xfwz.setXtSjly("1");
|
||||
if (ObjectUtils.isNotEmpty(rywz)) {
|
||||
xfwz.setSsbm(rywz.getSsbm());
|
||||
xfwz.setSsbmdm(rywz.getSsbmdm());
|
||||
xfwz.setSsbmid(rywz.getSsbmid());
|
||||
xfwz.setSsxgaj(rywz.getSsxgaj());
|
||||
xfwz.setSsxgajid(rywz.getSsxgajid());
|
||||
xfwz.setSsxgajdm(rywz.getSsxgajdm());
|
||||
xfwz.setSssgajid(rywz.getSssgajid());
|
||||
xfwz.setSssgaj(rywz.getSssgaj());
|
||||
xfwz.setSssgajdm(rywz.getSssgajdm());
|
||||
} else {
|
||||
DeptInfoVo dept = this.tbBaseAdaptRemoteService.getOrgByDeptId(locationInfo.getDeptId());
|
||||
if (dept != null) {
|
||||
xfwz.setSsbm(dept.getDeptname());
|
||||
xfwz.setSsbmdm(dept.getDeptcode());
|
||||
xfwz.setSsbmid(dept.getDeptid());
|
||||
xfwz.setSsxgaj(dept.getFxjname());
|
||||
xfwz.setSsxgajid(dept.getFxjid());
|
||||
xfwz.setSsxgajdm(dept.getFxjcode());
|
||||
xfwz.setSssgajid(dept.getDszid());
|
||||
xfwz.setSssgaj(dept.getDszname());
|
||||
xfwz.setSssgajdm(dept.getDszcode());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
xfwz.setZxzt("1");
|
||||
if (StringUtils.isBlank(xfwz.getId())) {
|
||||
xfwz.setId(UUIDGenerator.getUUID());
|
||||
this.baseMapper.insert(xfwz);
|
||||
} else {
|
||||
this.baseMapper.update(xfwz);
|
||||
}
|
||||
xfwz.setZb(null);
|
||||
xfwz.setZbList(list);
|
||||
redisService.setCacheObject(redisKey, xfwz);
|
||||
}
|
||||
return lc;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.dto.websocket.WebSocketObject;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.dto.wzzx.XfbbUpdateDto;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzLswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import com.mosty.base.model.vo.yjzl.TbFzJlVo;
|
||||
import com.mosty.base.utils.DistanceUtils;
|
||||
import com.mosty.base.utils.GeoHashKit;
|
||||
import com.mosty.base.utils.JtsUtils;
|
||||
import com.mosty.base.utils.UUIDGenerator;
|
||||
import com.mosty.common.core.business.entity.SysUser;
|
||||
import com.mosty.common.core.util.http.HttpUtils;
|
||||
import com.mosty.wzzx.mapper.TbQwXfbbMapper;
|
||||
import com.mosty.wzzx.mapper.TbWzLswzMapper;
|
||||
import com.mosty.wzzx.remote.TbBaseAdaptRemoteService;
|
||||
import com.mosty.wzzx.remote.TbQwzxAdaptRemoteService;
|
||||
import com.mosty.wzzx.remote.TbWebSocketAdaptRemoteService;
|
||||
import com.mosty.wzzx.remote.TbYjzlAdaptRemoteService;
|
||||
import com.mosty.wzzx.service.TbQwXfbbService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbQwXfbbServiceImpl extends ServiceImpl<TbQwXfbbMapper, TbQwXfbb> implements TbQwXfbbService {
|
||||
|
||||
@Resource
|
||||
private TbBaseAdaptRemoteService tbBaseAdaptRemoteService;
|
||||
@Resource
|
||||
private TbQwzxAdaptRemoteService tbQwzxAdaptRemoteService;
|
||||
@Resource
|
||||
private TbWebSocketAdaptRemoteService tbWebSocketAdaptRemoteService;
|
||||
@Resource
|
||||
private TbYjzlAdaptRemoteService tbYjzlAdaptRemoteService;
|
||||
@Resource
|
||||
private TbWzLswzMapper tbWzLswzMapper;
|
||||
|
||||
public Integer updateXfbb(TbQwXfbb xfbb, LocationInfo locationInfo, TbWzRywz oldRywz, Integer lc) {
|
||||
if (StringUtils.isBlank(locationInfo.getBbid())) {
|
||||
return 0;
|
||||
}
|
||||
XfbbUpdateDto dto = new XfbbUpdateDto();
|
||||
BigDecimal jd = BigDecimal.valueOf(locationInfo.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(locationInfo.getLat());
|
||||
dto.setId(locationInfo.getBbid());
|
||||
dto.setJd(jd);
|
||||
dto.setWd(wd);
|
||||
dto.setZb(JtsUtils.getPoint(jd, wd));
|
||||
dto.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
//计算位置
|
||||
dto.setDqwz(locationInfo.getAddress());
|
||||
dto.setZbsj(new Date());
|
||||
//计算巡防里程
|
||||
// Integer lc = DistanceUtils.getLc(xfbb.getXflc(), xfbb.getJd(), xfbb.getWd(), jd, wd);
|
||||
dto.setXflc(lc);
|
||||
dto.setXfzt("0");
|
||||
// dto.setXfsc(oldRywz.getSc());
|
||||
this.baseMapper.updateXfbb(dto);
|
||||
// 推送位置信息给前端
|
||||
// TbQwXfbb xfbb = this.tbQwzxAdaptRemoteService.getBbxxInfo(locationInfo.getBbid());
|
||||
|
||||
if (xfbb != null) {
|
||||
xfbb.setZb(null);
|
||||
xfbb.setXfzt("0");
|
||||
if (StringUtils.isNotBlank(xfbb.getFzrSfzh())) {
|
||||
SysUser user1 = this.tbBaseAdaptRemoteService.getUserInfoBySfzh(xfbb.getFzrSfzh());
|
||||
xfbb.setLx(user1.getType());
|
||||
}
|
||||
WebSocketObject obj = new WebSocketObject("04", xfbb, null);
|
||||
this.tbWebSocketAdaptRemoteService.sendBbMessage(obj);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateXfbbUdp(TbQwXfbb bb, TbWzSbsswz sbsswz, Integer lc) {
|
||||
XfbbUpdateDto dto = new XfbbUpdateDto();
|
||||
BigDecimal jd = sbsswz.getJd();
|
||||
BigDecimal wd = sbsswz.getWd();
|
||||
dto.setId(bb.getId());
|
||||
dto.setJd(jd);
|
||||
dto.setWd(wd);
|
||||
dto.setZb(JtsUtils.getPoint(jd, wd));
|
||||
dto.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
dto.setZbsj(new Date());
|
||||
dto.setXflc(lc);
|
||||
dto.setXfzt("0");
|
||||
// 保存犯罪数据
|
||||
bb.setZb(null);
|
||||
TbFzJlVo vo = new TbFzJlVo();
|
||||
BeanUtils.copyProperties(vo, bb);
|
||||
String xzmc = bb.getJzMc();
|
||||
if (StringUtils.isEmpty(xzmc)) {
|
||||
xzmc = bb.getFzrXm() + "警组";
|
||||
}
|
||||
vo.setBbid(bb.getId());
|
||||
vo.setXzmc(xzmc);
|
||||
vo.setJd(jd);
|
||||
vo.setWd(wd);
|
||||
this.baseMapper.updateXfbb(dto);
|
||||
TbWzLswz lswz = new TbWzLswz();
|
||||
lswz.setId(UUIDGenerator.getUUID());
|
||||
lswz.setSjly("UDP推送:" + sbsswz.getSbmc());
|
||||
lswz.setSjlydm("01");
|
||||
lswz.setYwid(bb.getId());
|
||||
lswz.setYhId(bb.getFzrId());
|
||||
lswz.setYhXm(bb.getFzrXm());
|
||||
lswz.setYhSfzh(bb.getFzrSfzh());
|
||||
lswz.setJzId(bb.getJzId());
|
||||
lswz.setJzMc(bb.getJzMc());
|
||||
lswz.setDwrq(new Date());
|
||||
lswz.setDwsj(new Date());
|
||||
lswz.setJd(jd);
|
||||
lswz.setWd(wd);
|
||||
lswz.setZb(JtsUtils.getPoint(jd, wd));
|
||||
lswz.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
lswz.setWztgz("01");
|
||||
lswz.setSsbm(bb.getSsbm());
|
||||
lswz.setSsbmdm(bb.getSsbmdm());
|
||||
lswz.setSsbmid(bb.getSsbmid());
|
||||
lswz.setSsxgaj(bb.getSsxgaj());
|
||||
lswz.setSsxgajid(bb.getSsxgajid());
|
||||
lswz.setSsxgajdm(bb.getSsxgajdm());
|
||||
lswz.setSssgajid(bb.getSssgajid());
|
||||
lswz.setSssgaj(bb.getSssgaj());
|
||||
lswz.setSssgajdm(bb.getSssgajdm());
|
||||
lswz.setDwbz("UDP");
|
||||
lswz.setDzxz(sbsswz.getDzxz());
|
||||
this.tbWzLswzMapper.insertEntity(lswz);
|
||||
// 推送位置信息给前端
|
||||
TbQwXfbb xfbb = this.tbQwzxAdaptRemoteService.getBbxxInfo(bb.getId());
|
||||
if (xfbb != null) {
|
||||
xfbb.setZb(null);
|
||||
xfbb.setXfzt("0");
|
||||
if (StringUtils.isNotBlank(xfbb.getFzrSfzh())) {
|
||||
SysUser user1 = this.tbBaseAdaptRemoteService.getUserInfoBySfzh(xfbb.getFzrSfzh());
|
||||
xfbb.setLx(user1.getType());
|
||||
}
|
||||
WebSocketObject obj = new WebSocketObject("04", xfbb, null);
|
||||
this.tbWebSocketAdaptRemoteService.sendBbMessage(obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getsfbb(String id) {
|
||||
return this.baseMapper.getsfbb(id);
|
||||
}
|
||||
|
||||
|
||||
public Integer updateById(String id, LocationInfo locationInfo) {
|
||||
TbQwXfbb xfbb = this.baseMapper.queryById(id);
|
||||
if (xfbb == null) {
|
||||
return 0;
|
||||
}
|
||||
XfbbUpdateDto dto = new XfbbUpdateDto();
|
||||
BigDecimal jd = BigDecimal.valueOf(locationInfo.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(locationInfo.getLat());
|
||||
Integer lc = DistanceUtils.getLc(xfbb.getXflc(), xfbb.getJd(), xfbb.getWd(), jd, wd);
|
||||
Integer sc = DistanceUtils.getSc(xfbb.getBbkssj());
|
||||
dto.setId(xfbb.getId());
|
||||
dto.setJd(jd);
|
||||
dto.setWd(wd);
|
||||
dto.setZb(JtsUtils.getPoint(jd, wd));
|
||||
dto.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
dto.setZbsj(new Date());
|
||||
dto.setXflc(lc);
|
||||
// dto.setXfsc(sc);
|
||||
return this.baseMapper.updateXfbb(dto);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwZnzb;
|
||||
import com.mosty.wzzx.mapper.TbQwZnzbMapper;
|
||||
import com.mosty.wzzx.service.TbQwZnzbService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbQwZnzbServiceImpl extends ServiceImpl<TbQwZnzbMapper, TbQwZnzb> implements TbQwZnzbService {
|
||||
|
||||
public List<TbQwZnzb> queryListByYwid(List<String> ywidList) {
|
||||
return this.baseMapper.queryListByYwid(ywidList);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.dto.wzzx.SjCyjlUpdateDto;
|
||||
import com.mosty.base.model.entity.sjzx.TbSjCyjl;
|
||||
import com.mosty.base.utils.GeoHashKit;
|
||||
import com.mosty.base.utils.JtsUtils;
|
||||
import com.mosty.wzzx.mapper.TbSjCyjlMapper;
|
||||
import com.mosty.wzzx.remote.TbBaseAdaptRemoteService;
|
||||
import com.mosty.wzzx.service.TbSjCyjlService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbSjCyjlServiceImpl extends ServiceImpl<TbSjCyjlMapper, TbSjCyjl> implements TbSjCyjlService {
|
||||
|
||||
@Resource
|
||||
private TbBaseAdaptRemoteService tbBaseAdaptRemoteService;
|
||||
|
||||
public Integer updateJlZb(LocationInfo locationInfo) {
|
||||
if (StringUtils.isBlank(locationInfo.getUserId())) {
|
||||
return 0;
|
||||
}
|
||||
TbSjCyjl cyjl = this.baseMapper.queryBySfzh(locationInfo.getUserId());
|
||||
if (cyjl != null) {
|
||||
SjCyjlUpdateDto dto = new SjCyjlUpdateDto();
|
||||
BigDecimal jd = BigDecimal.valueOf(locationInfo.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(locationInfo.getLat());
|
||||
dto.setId(cyjl.getId());
|
||||
dto.setJd(jd);
|
||||
dto.setWd(wd);
|
||||
dto.setZb(JtsUtils.getPoint(jd, wd));
|
||||
dto.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
dto.setZbsj(new Date());
|
||||
return this.baseMapper.updateZb(dto);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzLswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSswz;
|
||||
import com.mosty.base.model.vo.base.DeptInfoVo;
|
||||
import com.mosty.base.utils.DistanceUtils;
|
||||
import com.mosty.base.utils.GeoHashKit;
|
||||
import com.mosty.base.utils.JtsUtils;
|
||||
import com.mosty.base.utils.UUIDGenerator;
|
||||
import com.mosty.wzzx.mapper.TbWzLswzMapper;
|
||||
import com.mosty.wzzx.mapper.TbWzSswzMapper;
|
||||
import com.mosty.wzzx.remote.TbBaseAdaptRemoteService;
|
||||
import com.mosty.wzzx.service.TbWzLswzService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import sun.util.resources.sq.LocaleNames_sq;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbWzLswzServiceImpl extends ServiceImpl<TbWzSswzMapper, TbWzSswz> implements TbWzLswzService {
|
||||
|
||||
private final TbWzLswzMapper tbWzLswzMapper;
|
||||
private final TbBaseAdaptRemoteService tbBaseAdaptRemoteService;
|
||||
|
||||
public void saveLswz(LocationInfo locationInfo, TbWzRywz oldRywz) {
|
||||
BigDecimal jd = BigDecimal.valueOf(locationInfo.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(locationInfo.getLat());
|
||||
BigDecimal oldJd = null;
|
||||
BigDecimal oldWd = null;
|
||||
Date oldTime = null;
|
||||
if (oldRywz != null) {
|
||||
oldJd = oldRywz.getJd();
|
||||
oldWd = oldRywz.getWd();
|
||||
// oldTime = oldRywz.getJssj();
|
||||
}
|
||||
if (locationInfo.getLastTime() != null) {
|
||||
oldTime = locationInfo.getLastTime();
|
||||
}
|
||||
TbWzLswz lswz = new TbWzLswz();
|
||||
Integer lc = DistanceUtils.getLc(0, oldJd, oldWd, jd, wd);
|
||||
Integer sc = DistanceUtils.getSc(oldTime);
|
||||
String sjly = "移动设备";
|
||||
if (StringUtils.isNotBlank(locationInfo.getUserName())) {
|
||||
sjly = sjly + "-" + locationInfo.getUserName();
|
||||
}
|
||||
if (StringUtils.isNotBlank(locationInfo.getUserId())) {
|
||||
sjly = sjly + "-" + locationInfo.getUserId();
|
||||
}
|
||||
lswz.setSjly(sjly);
|
||||
lswz.setSjlydm("02");
|
||||
lswz.setYwid(locationInfo.getBbid());
|
||||
lswz.setJzId(locationInfo.getJzid());
|
||||
lswz.setJzMc(locationInfo.getJzmc());
|
||||
lswz.setDwrq(new Date());
|
||||
lswz.setDwsj(new Date());
|
||||
lswz.setJd(jd);
|
||||
lswz.setWd(wd);
|
||||
lswz.setXfsc(sc);
|
||||
lswz.setXflc(lc);
|
||||
lswz.setZb(JtsUtils.getPoint(jd, wd));
|
||||
lswz.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
lswz.setYhId(locationInfo.getYhid());
|
||||
lswz.setYhXm(locationInfo.getUserName());
|
||||
lswz.setYhSfzh(locationInfo.getUserId());
|
||||
lswz.setWztgz("02");//综合定位
|
||||
lswz.setXtSjly("1");
|
||||
|
||||
if (ObjectUtils.isNotEmpty(oldRywz)) {
|
||||
lswz.setSsbm(oldRywz.getSsbm());
|
||||
lswz.setSsbmdm(oldRywz.getSsbmdm());
|
||||
lswz.setSsbmid(oldRywz.getSsbmid());
|
||||
lswz.setSsxgaj(oldRywz.getSsxgaj());
|
||||
lswz.setSsxgajid(oldRywz.getSsxgajid());
|
||||
lswz.setSsxgajdm(oldRywz.getSsxgajdm());
|
||||
lswz.setSssgajid(oldRywz.getSssgajid());
|
||||
lswz.setSssgaj(oldRywz.getSssgaj());
|
||||
lswz.setSssgajdm(oldRywz.getSssgajdm());
|
||||
} else {
|
||||
DeptInfoVo dept = this.tbBaseAdaptRemoteService.getOrgByDeptId(locationInfo.getDeptId());
|
||||
if (dept != null) {
|
||||
lswz.setSsbm(dept.getDeptname());
|
||||
lswz.setSsbmdm(dept.getDeptcode());
|
||||
lswz.setSsbmid(dept.getDeptid());
|
||||
lswz.setSsxgaj(dept.getFxjname());
|
||||
lswz.setSsxgajid(dept.getFxjid());
|
||||
lswz.setSsxgajdm(dept.getFxjcode());
|
||||
lswz.setSssgajid(dept.getDszid());
|
||||
lswz.setSssgaj(dept.getDszname());
|
||||
lswz.setSssgajdm(dept.getDszcode());
|
||||
}
|
||||
}
|
||||
lswz.setGuo(locationInfo.getCountry());
|
||||
lswz.setSheng(locationInfo.getProvinc());
|
||||
lswz.setShi(locationInfo.getCity());
|
||||
lswz.setCsbm(locationInfo.getCityCode());
|
||||
lswz.setSsqx(locationInfo.getDistrict());
|
||||
lswz.setQxbm(locationInfo.getAdCode());
|
||||
lswz.setDzxz(locationInfo.getAddress());
|
||||
lswz.setDzjc(locationInfo.getPoiName());
|
||||
lswz.setDwbz(locationInfo.getZbly());
|
||||
tbWzLswzMapper.insertEntity(lswz);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSblswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import com.mosty.base.utils.JtsUtils;
|
||||
import com.mosty.wzzx.mapper.TbWzSblswzMapper;
|
||||
import com.mosty.wzzx.service.TbWzSblswzService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class TbWzSblswzServiceImpl extends ServiceImpl<TbWzSblswzMapper, TbWzSblswz>
|
||||
implements TbWzSblswzService {
|
||||
|
||||
public void saveSblswz(TbWzSbsswz sbsswz) {
|
||||
if (ObjectUtils.isNotEmpty(sbsswz)) {
|
||||
TbWzSblswz wz = new TbWzSblswz();
|
||||
BeanUtils.copyProperties(sbsswz, wz);
|
||||
wz.setZb(JtsUtils.getPoint(wz.getJd(), wz.getWd()));
|
||||
this.baseMapper.insertEntity(wz);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,244 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.base.model.vo.base.DeptInfoVo;
|
||||
import com.mosty.base.model.vo.jcgl.TbJcglSbdwVo;
|
||||
import com.mosty.base.model.vo.yjzl.TbFzJlVo;
|
||||
import com.mosty.base.model.vo.yjzl.TbFzycPzVo;
|
||||
import com.mosty.base.utils.*;
|
||||
import com.mosty.common.core.util.http.HttpUtils;
|
||||
import com.mosty.common.redis.service.RedisService;
|
||||
import com.mosty.wzzx.mapper.TbWzSbsswzMapper;
|
||||
import com.mosty.wzzx.mapper.TbWzXfwzMapper;
|
||||
import com.mosty.wzzx.remote.TbBaseAdaptRemoteService;
|
||||
import com.mosty.wzzx.remote.TbQwzxAdaptRemoteService;
|
||||
import com.mosty.wzzx.remote.TbWebSocketAdaptRemoteService;
|
||||
import com.mosty.wzzx.remote.TbYjzlAdaptRemoteService;
|
||||
import com.mosty.wzzx.service.TbQwXfbbService;
|
||||
import com.mosty.wzzx.service.TbWzSbsswzService;
|
||||
import com.mosty.wzzx.udp.UdpLzEntity;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbWzSbsswzServiceImpl extends ServiceImpl<TbWzSbsswzMapper, TbWzSbsswz> implements TbWzSbsswzService {
|
||||
|
||||
private final RedisService redisService;
|
||||
private final TbQwzxAdaptRemoteService tbQwzxAdaptRemoteService;
|
||||
private final TbWzXfwzMapper tbWzXfwzMapper;
|
||||
private final TbYjzlAdaptRemoteService tbYjzlAdaptRemoteService;
|
||||
private final TbQwXfbbService tbQwXfbbService;
|
||||
|
||||
// 查询巡组实时位置,如果5分钟没有GPS信号,则保存设备的位置信息
|
||||
private void saveXzwz(TbQwXfbb bb, TbWzSbsswz sbsswz) {
|
||||
String redisKey = Constant.WZ_XFWZ + sbsswz.getYwid();
|
||||
TbWzXfwz xfwz = redisService.getCacheObject(redisKey);
|
||||
// TbWzXfwz xfwz = this.tbWzXfwzMapper.queryByBbid(bb.getId());
|
||||
if (ObjectUtils.isNotEmpty(xfwz)) {
|
||||
Integer lc = DistanceUtils.getLc(bb.getXflc(), xfwz.getJd(), xfwz.getWd(), sbsswz.getJd(), sbsswz.getWd());
|
||||
List<BigDecimal[]> list = xfwz.getZbList();
|
||||
// if (sbsswz.getDwsj().getTime() - xfwz.getZhgxsj().getTime() >= 5 * 60 * 1000) {
|
||||
xfwz.setJd(sbsswz.getJd());
|
||||
xfwz.setWd(sbsswz.getWd());
|
||||
xfwz.setZhgxsj(new Date());
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
BigDecimal[] decimals = new BigDecimal[2];
|
||||
decimals[0] = sbsswz.getJd();
|
||||
decimals[1] = sbsswz.getWd();
|
||||
list.add(decimals);
|
||||
if (list.size() == 1) {
|
||||
list.add(decimals);
|
||||
}
|
||||
if (list.size() >= 3) {
|
||||
BigDecimal[] decimal0 = list.get(0);
|
||||
BigDecimal[] decimal1 = list.get(1);
|
||||
if (decimal0 == decimal1) {
|
||||
list.remove(0);
|
||||
}
|
||||
}
|
||||
xfwz.setZb(JtsUtils.createLine(list));
|
||||
xfwz.setZbsl(list.size());
|
||||
xfwz.setZbList(list);
|
||||
xfwz.setZxzt("1");
|
||||
this.tbWzXfwzMapper.update(xfwz);
|
||||
xfwz.setZb(null);
|
||||
//修改数据 报备数据
|
||||
this.tbQwXfbbService.updateXfbbUdp(bb, sbsswz, lc);
|
||||
redisService.setCacheObject(redisKey, xfwz);
|
||||
// }
|
||||
} else {
|
||||
xfwz = new TbWzXfwz();
|
||||
xfwz.setJd(sbsswz.getJd());
|
||||
xfwz.setWd(sbsswz.getWd());
|
||||
xfwz.setZhgxsj(new Date());
|
||||
List<BigDecimal[]> list = new ArrayList<>();
|
||||
BigDecimal[] decimals = new BigDecimal[2];
|
||||
decimals[0] = sbsswz.getJd();
|
||||
decimals[1] = sbsswz.getWd();
|
||||
list.add(decimals);
|
||||
if (list.size() == 1) {
|
||||
list.add(decimals);
|
||||
}
|
||||
if (list.size() >= 3) {
|
||||
BigDecimal[] decimal0 = list.get(0);
|
||||
BigDecimal[] decimal1 = list.get(1);
|
||||
if (decimal0 == decimal1) {
|
||||
list.remove(0);
|
||||
}
|
||||
}
|
||||
xfwz.setZb(JtsUtils.createLine(list));
|
||||
xfwz.setZbsl(list.size());
|
||||
xfwz.setZxzt("1");
|
||||
xfwz.setZbList(list);
|
||||
xfwz.setBbId(bb.getId());
|
||||
xfwz.setYhId(bb.getFzrId());
|
||||
xfwz.setYhSfzh(bb.getFzrSfzh());
|
||||
xfwz.setYhXm(bb.getFzrXm());
|
||||
xfwz.setJzId(bb.getJzId());
|
||||
xfwz.setJzMc(bb.getJzId());
|
||||
xfwz.setId(UUIDGenerator.getUUID());
|
||||
xfwz.setZbsl(list.size());
|
||||
xfwz.setDwrq(new Date());
|
||||
xfwz.setKssj(new Date());
|
||||
xfwz.setXtSjly("1");
|
||||
xfwz.setSsbm(bb.getSsbm());
|
||||
xfwz.setSsbmdm(bb.getSsbmdm());
|
||||
xfwz.setSsbmid(bb.getSsbmid());
|
||||
xfwz.setSsxgaj(bb.getSsxgaj());
|
||||
xfwz.setSsxgajid(bb.getSsxgajid());
|
||||
xfwz.setSsxgajdm(bb.getSsxgajdm());
|
||||
xfwz.setSssgajid(bb.getSssgajid());
|
||||
xfwz.setSssgaj(bb.getSssgaj());
|
||||
xfwz.setSssgajdm(bb.getSssgajdm());
|
||||
|
||||
this.tbWzXfwzMapper.insert(xfwz);
|
||||
xfwz.setZb(null);
|
||||
//修改数据 报备数据
|
||||
this.tbQwXfbbService.updateXfbbUdp(bb, sbsswz, 0);
|
||||
redisService.setCacheObject(redisKey, xfwz);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbWzSbsswz saveSbsswz(UdpLzEntity lzEntity) {
|
||||
TbJcglSbdwVo sbdwVo = redisService.getCacheObject(Constant.PGIS_SB + lzEntity.getPgisId());
|
||||
//udp数量太多 如果设备里面没有数据 udp数据就先不保存
|
||||
if (ObjectUtils.isNotEmpty(sbdwVo)) {
|
||||
String redisKey = Constant.WZ_SBWZ + lzEntity.getPgisId() + "-" +
|
||||
DateUtils.getQueryDateString(new Date(), "01");
|
||||
BigDecimal jd = BigDecimal.valueOf(lzEntity.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(lzEntity.getLat());
|
||||
TbWzSbsswz oldSbsswz = redisService.getCacheObject(redisKey);
|
||||
BigDecimal oldJd = null;
|
||||
BigDecimal oldWd = null;
|
||||
Timestamp oldTime = null;
|
||||
if (oldSbsswz != null) {
|
||||
oldJd = oldSbsswz.getJd();
|
||||
oldWd = oldSbsswz.getWd();
|
||||
oldTime = new Timestamp(oldSbsswz.getDwsj().getTime());
|
||||
}
|
||||
|
||||
TbWzSbsswz sbsswz = new TbWzSbsswz();
|
||||
Integer lc = DistanceUtils.getLc(0, oldJd, oldWd, jd, wd);
|
||||
Integer sc = DistanceUtils.getSc(oldTime);
|
||||
sbsswz.setSbid(lzEntity.getPgisId());
|
||||
sbsswz.setSbmc("LZ-" + lzEntity.getPgisId());
|
||||
sbsswz.setSjly("UDP推送位置信息");
|
||||
sbsswz.setSjlydm("86");
|
||||
sbsswz.setDwrq(lzEntity.getTime());
|
||||
sbsswz.setDwsj(lzEntity.getTime());
|
||||
sbsswz.setJd(jd);
|
||||
sbsswz.setWd(wd);
|
||||
sbsswz.setXfsc(sc);
|
||||
sbsswz.setXflc(lc);
|
||||
sbsswz.setZb(JtsUtils.getPoint(jd, wd));
|
||||
sbsswz.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
sbsswz.setWztgz("03");
|
||||
sbsswz.setXtSjly("1");
|
||||
sbsswz.setDwbz("03");
|
||||
sbsswz.setSsbm("四川省德阳市公安局");
|
||||
sbsswz.setSsbmdm("510600000000");
|
||||
sbsswz.setSsbmid("44015");
|
||||
sbsswz.setSsxgaj("四川省德阳市公安局");
|
||||
sbsswz.setSsxgajid("44015");
|
||||
sbsswz.setSsxgajdm("510600000000");
|
||||
sbsswz.setSssgajid("44015");
|
||||
sbsswz.setSssgaj("四川省德阳市公安局");
|
||||
sbsswz.setSssgajdm("510600000000");
|
||||
|
||||
List<TbQwXfbb> bbList = new ArrayList<>();
|
||||
if (ObjectUtils.isNotEmpty(sbdwVo)) {
|
||||
sbsswz.setSbmc(sbdwVo.getSbmc());
|
||||
sbsswz.setSjlydm(sbdwVo.getScode());
|
||||
sbsswz.setSsbm(sbdwVo.getSsbm());
|
||||
sbsswz.setSsbmdm(sbdwVo.getSsbmdm());
|
||||
sbsswz.setSsbmid(sbdwVo.getSsbmid());
|
||||
sbsswz.setSsxgaj(sbdwVo.getSsxgaj());
|
||||
sbsswz.setSsxgajid(sbdwVo.getSsxgajid());
|
||||
sbsswz.setSsxgajdm(sbdwVo.getSsxgajdm());
|
||||
sbsswz.setSssgajid(sbdwVo.getSssgajid());
|
||||
sbsswz.setSssgaj(sbdwVo.getSssgaj());
|
||||
sbsswz.setSssgajdm(sbdwVo.getSssgajdm());
|
||||
}
|
||||
// 查询是否有该设备的报备信息
|
||||
if (StringUtils.isNotEmpty(sbsswz.getSjlydm()) && sbsswz.getSjlydm().equals("05")) {
|
||||
bbList = this.tbQwzxAdaptRemoteService.getClBbList(lzEntity.getPgisId());
|
||||
} else {
|
||||
bbList = this.tbQwzxAdaptRemoteService.getBbList(lzEntity.getPgisId());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(bbList)) {
|
||||
for (TbQwXfbb bb : bbList) {
|
||||
// TbQwXfbb bb = bbList.get(0);
|
||||
sbsswz.setYhId(bb.getFzrId());
|
||||
sbsswz.setYhXm(bb.getFzrXm());
|
||||
sbsswz.setYhSfzh(bb.getFzrSfzh());
|
||||
sbsswz.setJzId(bb.getJzId());
|
||||
sbsswz.setJzMc(bb.getJzMc());
|
||||
sbsswz.setYwid(bb.getId());
|
||||
sbsswz.setSsbm(bb.getSsbm());
|
||||
sbsswz.setSsbmdm(bb.getSsbmdm());
|
||||
sbsswz.setSsbmid(bb.getSsbmid());
|
||||
sbsswz.setSssgaj(bb.getSssgaj());
|
||||
sbsswz.setSssgajdm(bb.getSssgajdm());
|
||||
sbsswz.setSssgajid(bb.getSssgajid());
|
||||
// 查询巡组实时位置,如果5分钟没有GPS信号,则保存设备的位置信息 (直接判断bb是否在线 在线不添加 不在线 写入数据)
|
||||
if (bb.getXfzt().equals("2")) {
|
||||
this.saveXzwz(bb, sbsswz);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.baseMapper.insertEntity(sbsswz);
|
||||
sbsswz.setZb(null);
|
||||
redisService.setCacheObject(redisKey, sbsswz);
|
||||
return sbsswz;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void delHistory() {
|
||||
this.baseMapper.delHistory();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,228 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.dto.wzzx.LocationInfo;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzLswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSswz;
|
||||
import com.mosty.base.model.query.wzzx.TbWzRywzSearchDto;
|
||||
import com.mosty.base.model.query.wzzx.TbWzSswzSearchDto;
|
||||
import com.mosty.base.model.vo.base.DeptInfoVo;
|
||||
import com.mosty.base.utils.*;
|
||||
import com.mosty.wzzx.mapper.TbWzLswzMapper;
|
||||
import com.mosty.wzzx.mapper.TbWzRywzMapper;
|
||||
import com.mosty.wzzx.mapper.TbWzSswzMapper;
|
||||
import com.mosty.wzzx.remote.TbBaseAdaptRemoteService;
|
||||
import com.mosty.wzzx.service.TbWzSswzService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbWzSswzServiceImpl extends ServiceImpl<TbWzSswzMapper, TbWzSswz> implements TbWzSswzService {
|
||||
|
||||
private final TbBaseAdaptRemoteService tbBaseAdaptRemoteService;
|
||||
private final TbWzLswzMapper tbWzLswzMapper;
|
||||
private final TbWzRywzMapper tbWzRywzMapper;
|
||||
|
||||
public void saveSswz(LocationInfo locationInfo, TbWzRywz oldRywz) {
|
||||
BigDecimal jd = BigDecimal.valueOf(locationInfo.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(locationInfo.getLat());
|
||||
BigDecimal oldJd = null;
|
||||
BigDecimal oldWd = null;
|
||||
Date oldTime = null;
|
||||
if (oldRywz != null) {
|
||||
oldJd = oldRywz.getJd();
|
||||
oldWd = oldRywz.getWd();
|
||||
}
|
||||
if (locationInfo.getLastTime() != null) {
|
||||
oldTime = locationInfo.getLastTime();
|
||||
}
|
||||
TbWzSswz sswz = new TbWzSswz();
|
||||
Integer lc = DistanceUtils.getLc(0, oldJd, oldWd, jd, wd);
|
||||
Integer sc = DistanceUtils.getSc(oldTime);
|
||||
sswz.setSjlydm("02");
|
||||
String sjly = "移动设备";
|
||||
if (StringUtils.isNotBlank(locationInfo.getUserName())) {
|
||||
sjly = sjly + "-" + locationInfo.getUserName();
|
||||
}
|
||||
if (StringUtils.isNotBlank(locationInfo.getUserId())) {
|
||||
sjly = sjly + "-" + locationInfo.getUserId();
|
||||
}
|
||||
sswz.setSjly(sjly);
|
||||
sswz.setYwid(locationInfo.getBbid());
|
||||
sswz.setJzId(locationInfo.getJzid());
|
||||
sswz.setJzMc(locationInfo.getJzmc());
|
||||
sswz.setDwrq(new Date());
|
||||
sswz.setDwsj(new Date());
|
||||
sswz.setJd(jd);
|
||||
sswz.setWd(wd);
|
||||
sswz.setXfsc(sc);
|
||||
sswz.setXflc(lc);
|
||||
sswz.setZb(JtsUtils.getPoint(jd, wd));
|
||||
sswz.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
sswz.setYhId(locationInfo.getYhid());
|
||||
sswz.setYhXm(locationInfo.getUserName());
|
||||
sswz.setYhSfzh(locationInfo.getUserId());
|
||||
sswz.setJrbh(locationInfo.getAccessNumber());
|
||||
sswz.setWztgz("02");//综合定位
|
||||
if (ObjectUtils.isNotEmpty(oldRywz)) {
|
||||
sswz.setSsbm(oldRywz.getSsbm());
|
||||
sswz.setSsbmdm(oldRywz.getSsbmdm());
|
||||
sswz.setSsbmid(oldRywz.getSsbmid());
|
||||
sswz.setSsxgaj(oldRywz.getSsxgaj());
|
||||
sswz.setSsxgajid(oldRywz.getSsxgajid());
|
||||
sswz.setSsxgajdm(oldRywz.getSsxgajdm());
|
||||
sswz.setSssgajid(oldRywz.getSssgajid());
|
||||
sswz.setSssgaj(oldRywz.getSssgaj());
|
||||
sswz.setSssgajdm(oldRywz.getSssgajdm());
|
||||
} else {
|
||||
DeptInfoVo dept = this.tbBaseAdaptRemoteService.getOrgByDeptId(locationInfo.getDeptId());
|
||||
if (dept != null) {
|
||||
sswz.setSsbm(dept.getDeptname());
|
||||
sswz.setSsbmdm(dept.getDeptcode());
|
||||
sswz.setSsbmid(dept.getDeptid());
|
||||
sswz.setSsxgaj(dept.getFxjname());
|
||||
sswz.setSsxgajid(dept.getFxjid());
|
||||
sswz.setSsxgajdm(dept.getFxjcode());
|
||||
sswz.setSssgajid(dept.getDszid());
|
||||
sswz.setSssgaj(dept.getDszname());
|
||||
sswz.setSssgajdm(dept.getDszcode());
|
||||
}
|
||||
}
|
||||
sswz.setGuo(locationInfo.getCountry());
|
||||
sswz.setSheng(locationInfo.getProvinc());
|
||||
sswz.setShi(locationInfo.getCity());
|
||||
sswz.setCsbm(locationInfo.getCityCode());
|
||||
sswz.setSsqx(locationInfo.getDistrict());
|
||||
sswz.setQxbm(locationInfo.getAdCode());
|
||||
sswz.setDzxz(locationInfo.getAddress());
|
||||
sswz.setDzjc(locationInfo.getPoiName());
|
||||
sswz.setDwbz(locationInfo.getZbly());
|
||||
this.baseMapper.insertEntity(sswz);
|
||||
}
|
||||
|
||||
public TbWzSswz insert(LocationInfo locationInfo) {
|
||||
TbWzSswz fronSswz = this.baseMapper.querySswzNow(locationInfo.getUserId(), null);
|
||||
TbWzSswz sswz = new TbWzSswz();
|
||||
BigDecimal jd = BigDecimal.valueOf(locationInfo.getLng());
|
||||
BigDecimal wd = BigDecimal.valueOf(locationInfo.getLat());
|
||||
Integer lc = 0;
|
||||
Integer sc = 0;
|
||||
if (fronSswz != null) {
|
||||
lc = DistanceUtils.getLc(0, fronSswz.getJd(), fronSswz.getWd(), jd, wd);
|
||||
sc = DistanceUtils.getSc(fronSswz.getDwsj());
|
||||
}
|
||||
sswz.setYhId(locationInfo.getUserId());
|
||||
sswz.setYhXm(locationInfo.getUserName());
|
||||
sswz.setYhSfzh(locationInfo.getUserId());
|
||||
String sjly = "移动设备";
|
||||
if (StringUtils.isNotBlank(locationInfo.getUserName())) {
|
||||
sjly = sjly + "-" + locationInfo.getUserName();
|
||||
}
|
||||
if (StringUtils.isNotBlank(locationInfo.getUserId())) {
|
||||
sjly = sjly + "-" + locationInfo.getUserId();
|
||||
}
|
||||
sswz.setSjly(sjly);
|
||||
sswz.setSjlydm("02");
|
||||
sswz.setDwrq(new Date());
|
||||
sswz.setDwsj(new Date());
|
||||
sswz.setJd(jd);
|
||||
sswz.setWd(wd);
|
||||
sswz.setZb(JtsUtils.getPoint(jd, wd));
|
||||
sswz.setZbhash(GeoHashKit.encode(jd, wd));
|
||||
sswz.setJrbh(locationInfo.getAccessNumber());
|
||||
sswz.setWztgz("02");//综合定位
|
||||
sswz.setXtSjly("1");
|
||||
sswz.setId(UUIDGenerator.getUUID());
|
||||
sswz.setGuo(locationInfo.getCountry());
|
||||
sswz.setSheng(locationInfo.getProvinc());
|
||||
sswz.setShi(locationInfo.getCity());
|
||||
sswz.setQxbm(locationInfo.getCityCode());
|
||||
sswz.setDzxz(locationInfo.getAddress());
|
||||
sswz.setDzjc(locationInfo.getPoiName());
|
||||
sswz.setYwid(locationInfo.getBbid());
|
||||
DeptInfoVo dept = this.tbBaseAdaptRemoteService.getOrgByDeptId(locationInfo.getDeptId());
|
||||
if (dept != null) {
|
||||
sswz.setSsbm(dept.getDeptname());
|
||||
sswz.setSsbmdm(dept.getDeptcode());
|
||||
sswz.setSsbmid(dept.getDeptid());
|
||||
sswz.setSsxgaj(dept.getFxjname());
|
||||
sswz.setSsxgajid(dept.getFxjid());
|
||||
sswz.setSsxgajdm(dept.getFxjcode());
|
||||
sswz.setSssgajid(dept.getDszid());
|
||||
sswz.setSssgaj(dept.getDszname());
|
||||
sswz.setSssgajdm(dept.getDszcode());
|
||||
}
|
||||
sswz.setXfsc(sc);
|
||||
sswz.setXflc(lc);
|
||||
this.baseMapper.insertEntity(sswz);
|
||||
return sswz;
|
||||
}
|
||||
|
||||
public TbWzSswz insertEntity(TbWzSswz sswz) {
|
||||
this.baseMapper.insertEntity(sswz);
|
||||
return sswz;
|
||||
}
|
||||
|
||||
public TbWzSswz queryById(String id) {
|
||||
return this.baseMapper.queryById(id);
|
||||
}
|
||||
|
||||
public TbWzSswz querySswzNow(String yhid, String jrbh) {
|
||||
return this.baseMapper.querySswzNow(yhid, jrbh);
|
||||
}
|
||||
|
||||
public void delHistory() {
|
||||
this.baseMapper.delHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<TbWzSswz> getRygjList(TbWzSswzSearchDto dto) {
|
||||
IPage<TbWzLswz> page = this.tbWzLswzMapper.selectPage(
|
||||
new Page<>(dto.getPageCurrent(), dto.getPageSize()),
|
||||
new LambdaQueryWrapper<TbWzLswz>()
|
||||
.eq(TbWzLswz::getYhSfzh, dto.getSfzh())
|
||||
.eq(TbWzLswz::getXtSjzt, "1")
|
||||
.ge(TbWzLswz::getDwrq, dto.getDwrq())
|
||||
);
|
||||
IPage<TbWzSswz> resPage = new Page<>(dto.getPageCurrent(), dto.getPageSize());
|
||||
List<TbWzSswz> resList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(page.getRecords())) {
|
||||
page.getRecords().forEach(item -> {
|
||||
TbWzSswz sswz = new TbWzSswz();
|
||||
BeanUtils.copyProperties(item, sswz);
|
||||
sswz.setZb(null);
|
||||
resList.add(sswz);
|
||||
});
|
||||
resPage.setRecords(resList);
|
||||
resPage.setTotal(page.getTotal());
|
||||
}
|
||||
return resPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbWzRywz getRywz(TbWzRywzSearchDto dto) {
|
||||
TbWzRywz wz = this.tbWzRywzMapper.selectBySfz(dto);
|
||||
if (wz != null) {
|
||||
wz.setZbList(JtsUtils.decodeLineString(wz.getZb()));
|
||||
wz.setZb(null);
|
||||
}
|
||||
return wz;
|
||||
}
|
||||
}
|
@ -0,0 +1,316 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.base.model.dto.wzzx.AppLocationReceiveDto;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
|
||||
import com.mosty.base.model.entity.wzzx.*;
|
||||
import com.mosty.base.model.query.wzzx.TbWzLswzSearchDto;
|
||||
import com.mosty.base.model.query.wzzx.TbWzSbLswzSearchDto;
|
||||
import com.mosty.base.utils.*;
|
||||
import com.mosty.common.base.exception.BusinessException;
|
||||
import com.mosty.wzzx.mapper.*;
|
||||
import com.mosty.wzzx.service.TbWzXfwzService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbWzXfwzServiceImpl extends ServiceImpl<TbWzXfwzMapper, TbWzXfwz> implements TbWzXfwzService {
|
||||
|
||||
private final TbWzRywzMapper tbWzRywzMapper;
|
||||
private final TbWzSswzMapper tbWzSswzMapper;
|
||||
private final TbWzLswzMapper tbWzLswzMapper;
|
||||
private final TbQwXfbbMapper tbQwXfbbMapper;
|
||||
private final TbWzSblswzMapper tbWzSblswzMapper;
|
||||
|
||||
public List<TbWzXfwz> queryAll() {
|
||||
return this.baseMapper.queryAll();
|
||||
}
|
||||
|
||||
public TbWzXfwz queryById(String id) {
|
||||
return this.baseMapper.queryById(id);
|
||||
}
|
||||
|
||||
public TbWzXfwz insert(TbWzXfwz tbWzXfwz) {
|
||||
this.baseMapper.insert(tbWzXfwz);
|
||||
return tbWzXfwz;
|
||||
}
|
||||
|
||||
public TbWzXfwz update(TbWzXfwz tbWzXfwz) {
|
||||
this.baseMapper.update(tbWzXfwz);
|
||||
return this.queryById(tbWzXfwz.getId());
|
||||
}
|
||||
|
||||
public boolean deleteById(String id) {
|
||||
return this.baseMapper.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
public Object selectTrack(TbWzXfwz tbWzXfwz) {
|
||||
TbWzXfwz xfwz = this.baseMapper.queryByBbid(tbWzXfwz.getBbId());
|
||||
if (ObjectUtils.isNotEmpty(xfwz)) {
|
||||
List<BigDecimal[]> list = JtsUtils.decodeLineString(xfwz.getZb());
|
||||
/* if (CollectionUtils.isEmpty(list)) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
if (list.size() >= 3) {
|
||||
BigDecimal[] decimal0 = list.get(0);
|
||||
BigDecimal[] decimal1 = list.get(1);
|
||||
if (decimal0 == decimal1) {
|
||||
list.remove(0);
|
||||
}
|
||||
}*/
|
||||
xfwz.setZb(null);
|
||||
xfwz.setZbList(list);
|
||||
}
|
||||
return xfwz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object selectLswz(TbWzLswzSearchDto dto) {
|
||||
if (StringUtils.isEmpty(dto.getBbId())) throw new BusinessException("报备业务ID为空!");
|
||||
if (StringUtils.isEmpty(dto.getKssj())) {
|
||||
dto.setKssj(DateUtils.getSystemDateString());
|
||||
}
|
||||
List<TbWzLswz> tbWzLswzs = this.tbWzLswzMapper.selectList(new LambdaQueryWrapper<TbWzLswz>()
|
||||
.eq(StringUtils.isNotBlank(dto.getBbId()), TbWzLswz::getYwid, dto.getBbId())
|
||||
.ge(StringUtils.isNotBlank(dto.getKssj()), TbWzLswz::getDwsj, dto.getKssj())
|
||||
.le(StringUtils.isNotBlank(dto.getJssj()), TbWzLswz::getDwsj, dto.getJssj())
|
||||
.orderByAsc(TbWzLswz::getDwsj)
|
||||
);
|
||||
return tbWzLswzs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object selectSbLswz(TbWzSbLswzSearchDto dto) {
|
||||
if (StringUtils.isEmpty(dto.getGpsId())) throw new BusinessException("设备id为空!");
|
||||
if (StringUtils.isEmpty(dto.getKssj())) {
|
||||
dto.setKssj(DateUtils.getSystemDateString());
|
||||
}
|
||||
List<TbWzSblswz> tbWzLswzs = this.tbWzSblswzMapper.selectList(new LambdaQueryWrapper<TbWzSblswz>()
|
||||
.eq(StringUtils.isNotBlank(dto.getGpsId()), TbWzSblswz::getSbid, dto.getGpsId())
|
||||
.ge(StringUtils.isNotBlank(dto.getKssj()), TbWzSblswz::getXtCjsj, dto.getKssj())
|
||||
.le(StringUtils.isNotBlank(dto.getJssj()), TbWzSblswz::getXtCjsj, dto.getJssj())
|
||||
.orderByAsc(TbWzSblswz::getXtCjsj)
|
||||
);
|
||||
return tbWzLswzs;
|
||||
}
|
||||
|
||||
|
||||
public Boolean locationReceive(AppLocationReceiveDto receiveDto) {
|
||||
//经度、纬度为空不接收数据
|
||||
if (receiveDto.getJd() == null && receiveDto.getWd() == null) {
|
||||
return false;
|
||||
}
|
||||
//保存人员预警
|
||||
TbWzRywz rywz = saveRywz(receiveDto);
|
||||
TbQwXfbb bbxx = null;
|
||||
if (StringUtils.isNotBlank(receiveDto.getBbid())) {
|
||||
bbxx = tbQwXfbbMapper.queryById(receiveDto.getBbid());
|
||||
}
|
||||
saveSsjl(receiveDto, bbxx, rywz);
|
||||
saveLsjl(receiveDto, bbxx, rywz);
|
||||
if (bbxx != null) {
|
||||
saveXfwz(receiveDto, bbxx, rywz);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public TbWzRywz saveRywz(AppLocationReceiveDto receiveDto) {
|
||||
TbWzRywz rywz = tbWzRywzMapper.queryBySfzh(receiveDto.getYhSfzh());
|
||||
if (rywz == null) {
|
||||
rywz = new TbWzRywz();
|
||||
}
|
||||
rywz.setYhId(receiveDto.getYhid());
|
||||
rywz.setYhXm(receiveDto.getYhxm());
|
||||
rywz.setYhSfzh(receiveDto.getYhSfzh());
|
||||
rywz.setXtZhgxsj(new Timestamp(System.currentTimeMillis()));
|
||||
List<BigDecimal[]> list = JtsUtils.decodeLineString(rywz.getZb());
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
Integer lc = DistanceUtils.getLc(rywz.getLc(), rywz.getJd(), rywz.getWd(), receiveDto.getJd(),
|
||||
receiveDto.getWd());
|
||||
Integer sc = DistanceUtils.getSc(rywz.getZhgxsj());
|
||||
BigDecimal[] decimals = new BigDecimal[2];
|
||||
decimals[0] = receiveDto.getJd();
|
||||
decimals[1] = receiveDto.getWd();
|
||||
list.add(decimals);
|
||||
if (list.size() == 1) {
|
||||
list.add(decimals);
|
||||
}
|
||||
if (list.size() >= 3) {
|
||||
BigDecimal[] decimal0 = list.get(0);
|
||||
BigDecimal[] decimal1 = list.get(1);
|
||||
if (decimal0 == decimal1) {
|
||||
list.remove(0);
|
||||
}
|
||||
}
|
||||
rywz.setLc(lc);
|
||||
rywz.setSc(sc);
|
||||
rywz.setZb(JtsUtils.createLine(list));
|
||||
rywz.setZbsl(list.size());
|
||||
rywz.setJd(receiveDto.getJd());
|
||||
rywz.setWd(receiveDto.getWd());
|
||||
rywz.setZhgxsj(new Timestamp(System.currentTimeMillis()));
|
||||
rywz.setXtSjly("1");
|
||||
rywz.setJd(receiveDto.getJd());
|
||||
rywz.setWd(receiveDto.getWd());
|
||||
rywz.setSsxgajdm("510109000000");
|
||||
rywz.setSsxgajid("1");
|
||||
rywz.setSsxgaj("高新区分局");
|
||||
rywz.setSssgaj("成都市公安局");
|
||||
rywz.setSssgajdm("510100000000");
|
||||
rywz.setSssgajid("10001");
|
||||
if (StringUtils.isBlank(rywz.getId())) {
|
||||
rywz.setId(UUIDGenerator.getUUID());
|
||||
rywz.setKssj(new Date());
|
||||
rywz.setDwrq(new Date());
|
||||
rywz.setXtCjsj(new Timestamp(System.currentTimeMillis()));
|
||||
tbWzRywzMapper.insertEntity(rywz);
|
||||
} else {
|
||||
tbWzRywzMapper.updateEntity(rywz);
|
||||
}
|
||||
return rywz;
|
||||
}
|
||||
|
||||
public void saveXfwz(AppLocationReceiveDto receiveDto, TbQwXfbb bbxx, TbWzRywz rywz) {
|
||||
TbWzXfwz xfwz = this.baseMapper.queryByBbid(receiveDto.getBbid());
|
||||
if (xfwz == null) {
|
||||
xfwz = new TbWzXfwz();
|
||||
}
|
||||
Integer lc = DistanceUtils.getLc(rywz.getLc(), rywz.getJd(), rywz.getWd(), receiveDto.getJd(),
|
||||
receiveDto.getWd());
|
||||
Integer sc = DistanceUtils.getSc(rywz.getZhgxsj());
|
||||
xfwz.setBbId(receiveDto.getBbid());
|
||||
xfwz.setYhId(receiveDto.getYhid());
|
||||
xfwz.setYhSfzh(receiveDto.getYhSfzh());
|
||||
xfwz.setYhXm(receiveDto.getYhxm());
|
||||
xfwz.setJzId(bbxx.getJzId());
|
||||
xfwz.setJzMc(bbxx.getJzMc());
|
||||
xfwz.setSc(sc);
|
||||
xfwz.setLc(lc);
|
||||
List<BigDecimal[]> list = JtsUtils.decodeLineString(xfwz.getZb());
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
BigDecimal[] decimals = new BigDecimal[2];
|
||||
decimals[0] = receiveDto.getJd();
|
||||
decimals[1] = receiveDto.getWd();
|
||||
list.add(decimals);
|
||||
if (list.size() == 1) {
|
||||
list.add(decimals);
|
||||
}
|
||||
if (list.size() >= 3) {
|
||||
BigDecimal[] decimal0 = list.get(0);
|
||||
BigDecimal[] decimal1 = list.get(1);
|
||||
if (decimal0 == decimal1) {
|
||||
list.remove(0);
|
||||
}
|
||||
}
|
||||
xfwz.setZb(JtsUtils.createLine(list));
|
||||
xfwz.setZbsl(list.size());
|
||||
xfwz.setDwrq(new Date());
|
||||
xfwz.setKssj(new Date());
|
||||
xfwz.setJd(receiveDto.getJd());
|
||||
xfwz.setWd(receiveDto.getWd());
|
||||
xfwz.setZhgxsj(new Date());
|
||||
xfwz.setXtSjly("1");
|
||||
xfwz.setSsxgajdm("510109000000");
|
||||
xfwz.setSsxgajid("1");
|
||||
xfwz.setSsxgaj("高新区分局");
|
||||
xfwz.setSssgaj("成都市公安局");
|
||||
xfwz.setSssgajdm("510100000000");
|
||||
xfwz.setSssgajid("10001");
|
||||
if (StringUtils.isBlank(xfwz.getId())) {
|
||||
xfwz.setId(UUIDGenerator.getUUID());
|
||||
xfwz.setXtCjsj(new Timestamp(System.currentTimeMillis()));
|
||||
this.baseMapper.insert(xfwz);
|
||||
} else {
|
||||
xfwz.setJssj(new Date());
|
||||
this.baseMapper.update(xfwz);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSsjl(AppLocationReceiveDto receiveDto, TbQwXfbb bbxx, TbWzRywz rywz) {
|
||||
TbWzSswz sswz = new TbWzSswz();
|
||||
Integer lc = DistanceUtils.getLc(0, rywz.getJd(), rywz.getWd(), receiveDto.getJd(), receiveDto.getWd());
|
||||
Integer sc = DistanceUtils.getSc(rywz.getZhgxsj());
|
||||
BeanUtils.copyProperties(receiveDto, sswz);
|
||||
sswz.setSjly("移动设备-" + receiveDto.getYhxm() + "-" + receiveDto.getYhSfzh());
|
||||
sswz.setSjlydm("02");
|
||||
sswz.setYwid(receiveDto.getBbid());
|
||||
if (bbxx != null) {
|
||||
sswz.setJzId(bbxx.getJzId());
|
||||
sswz.setJzMc(bbxx.getJzMc());
|
||||
}
|
||||
sswz.setDwrq(new Date());
|
||||
sswz.setDwsj(new Date());
|
||||
sswz.setJd(receiveDto.getJd());
|
||||
sswz.setWd(receiveDto.getWd());
|
||||
sswz.setXfsc(sc);
|
||||
sswz.setXflc(lc);
|
||||
if (receiveDto.getJd() != null && receiveDto.getWd() != null) {
|
||||
sswz.setZb(JtsUtils.getPoint(receiveDto.getJd(), receiveDto.getWd()));
|
||||
sswz.setZbhash(GeoHashKit.encode(receiveDto.getJd(), receiveDto.getWd()));
|
||||
}
|
||||
sswz.setYhId(receiveDto.getYhid());
|
||||
sswz.setYhXm(receiveDto.getYhxm());
|
||||
sswz.setJrbh(receiveDto.getJrbh());
|
||||
sswz.setWztgz("02");//综合定位
|
||||
sswz.setXtSjly("1");
|
||||
sswz.setSsxgajdm("510109000000");
|
||||
sswz.setSsxgajid("1");
|
||||
sswz.setSsxgaj("高新区分局");
|
||||
sswz.setSssgaj("成都市公安局");
|
||||
sswz.setSssgajdm("510100000000");
|
||||
sswz.setSssgajid("10001");
|
||||
tbWzSswzMapper.insertEntity(sswz);
|
||||
}
|
||||
|
||||
public void saveLsjl(AppLocationReceiveDto receiveDto, TbQwXfbb bbxx, TbWzRywz rywz) {
|
||||
TbWzLswz lswz = new TbWzLswz();
|
||||
BeanUtils.copyProperties(receiveDto, lswz);
|
||||
Integer lc = DistanceUtils.getLc(0, rywz.getJd(), rywz.getWd(), receiveDto.getJd(), receiveDto.getWd());
|
||||
Integer sc = DistanceUtils.getSc(rywz.getZhgxsj());
|
||||
lswz.setSjly("移动设备" + receiveDto.getYhxm() + "-" + receiveDto.getYhSfzh());
|
||||
lswz.setSjlydm("02");
|
||||
lswz.setYwid(receiveDto.getBbid());
|
||||
if (bbxx != null) {
|
||||
lswz.setJzId(bbxx.getJzId());
|
||||
lswz.setJzMc(bbxx.getJzMc());
|
||||
}
|
||||
lswz.setDwrq(new Date());
|
||||
lswz.setDwsj(new Date());
|
||||
lswz.setJd(receiveDto.getJd());
|
||||
lswz.setWd(receiveDto.getWd());
|
||||
lswz.setXfsc(sc);
|
||||
lswz.setXflc(lc);
|
||||
if (receiveDto.getJd() != null && receiveDto.getWd() != null) {
|
||||
lswz.setZb(JtsUtils.getPoint(receiveDto.getJd(), receiveDto.getWd()));
|
||||
lswz.setZbhash(GeoHashKit.encode(receiveDto.getJd(), receiveDto.getWd()));
|
||||
}
|
||||
lswz.setYhId(receiveDto.getYhid());
|
||||
lswz.setYhXm(receiveDto.getYhxm());
|
||||
lswz.setWztgz("02");//综合定位
|
||||
lswz.setXtSjly("1");
|
||||
lswz.setSsxgajdm("510109000000");
|
||||
lswz.setSsxgajid("1");
|
||||
lswz.setSsxgaj("高新区分局");
|
||||
lswz.setSssgaj("成都市公安局");
|
||||
lswz.setSssgajdm("510100000000");
|
||||
lswz.setSssgajid("10001");
|
||||
tbWzLswzMapper.insertEntity(lswz);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,265 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mosty.base.model.dto.wzzx.WzcxQuery;
|
||||
import com.mosty.base.model.dto.wzzx.WztjQuery;
|
||||
import com.mosty.base.model.entity.qwzx.TbQwXfBxfsq;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzRywz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSblswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.base.utils.DateUtils;
|
||||
import com.mosty.common.token.UserInfo;
|
||||
import com.mosty.common.token.UserInfoManager;
|
||||
import com.mosty.common.util.PermissionsUtil;
|
||||
import com.mosty.wzzx.mapper.TbWzRywzMapper;
|
||||
import com.mosty.wzzx.mapper.TbWzSblswzMapper;
|
||||
import com.mosty.wzzx.mapper.TbWzXfwzMapper;
|
||||
import com.mosty.wzzx.mapper.WztjMapper;
|
||||
import com.mosty.wzzx.remote.TbBaseAdaptRemoteService;
|
||||
import com.mosty.wzzx.service.WztjService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class WztjServiceImpl implements WztjService {
|
||||
|
||||
private final WztjMapper wztjMapper;
|
||||
private final TbWzXfwzMapper tbWzXfwzMapper;
|
||||
private final TbWzRywzMapper tbWzRywzMapper;
|
||||
private final TbWzSblswzMapper tbWzSblswzMapper;
|
||||
private final TbBaseAdaptRemoteService tbBaseAdaptRemoteService;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> rywz(WztjQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.jwzbmlbtj(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> xz(WztjQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.xz(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> jrlcs(WztjQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.jrlcs(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> rslcxz(WztjQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.rslcxz(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> jrwzrs(WztjQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.jrwzrs(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> jrxzwzs(WztjQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.jrxzwzs(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Map<String, Object>> rywzlb(WztjQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("pageIndex", (dto.getPageCurrent() - 1) * dto.getPageSize());
|
||||
map.put("pageSize", dto.getPageSize());
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
int count = this.wztjMapper.rywzlbCount(map);
|
||||
List<Map<String, Object>> list = this.wztjMapper.rywzlb(map);
|
||||
IPage<Map<String, Object>> page = new Page<>(dto.getPageCurrent(), dto.getPageSize());
|
||||
page.setTotal(count);
|
||||
page.setRecords(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> bbgjcx(WzcxQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.bbgjcx(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> bbwzcx(WzcxQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.bbwzcx(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> mjgjcx(WzcxQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.mjgjcx(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> wbbwz(WzcxQuery dto) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserInfo user = UserInfoManager.get();
|
||||
map.put("useSql", PermissionsUtil.createSql("", user));
|
||||
map.put("dto", dto);
|
||||
return this.wztjMapper.wbbwz(map);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> xfsltj(String type) {
|
||||
String kssj = null, jssj = null, startTime = null, endTime = null;
|
||||
if ("1".equals(type)) { // 类型如果为 1 说明是当天
|
||||
kssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
// 当天的环比
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
|
||||
} else if ("2".equals(type)) { // 7天
|
||||
kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
// 环比7天的 开始时间,结束时间
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -14), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
|
||||
} else if ("3".equals(type)) { // 30天
|
||||
kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
// 环比的30天,开始时间,结束时间
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -60), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
|
||||
}
|
||||
// UserInfo user = UserInfoManager.get(); // 获取登陆信息
|
||||
QueryWrapper<TbWzXfwz> qw = new QueryWrapper<>(); // mybatisplus
|
||||
// PermissionsUtil.queryWrapperUtil(qw, user); // mybatisplus
|
||||
String ssbm = this.tbBaseAdaptRemoteService.getSsbm(null, null);
|
||||
|
||||
qw.likeRight(StringUtils.isNotBlank(ssbm), "ssbmdm", ssbm);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
int nowCount = this.tbWzXfwzMapper.selectCount( // 近期的count:计数 lambda遍历 根据日期开始时间结束时间计数 比较ge大于开始时间,le小于结束时间
|
||||
qw.lambda().ge(TbWzXfwz::getDwrq, kssj)
|
||||
.le(TbWzXfwz::getDwrq, jssj)
|
||||
);
|
||||
// 近期的count
|
||||
map.put("nowCount", nowCount);
|
||||
// 上一期的数量
|
||||
int prevCount = this.tbWzXfwzMapper.selectCount(
|
||||
qw.lambda().ge(TbWzXfwz::getDwrq, startTime)
|
||||
.le(TbWzXfwz::getDwrq, endTime)
|
||||
);
|
||||
map.put("prevCount", prevCount);
|
||||
map.put("hb", prevCount != 0 ? ( // 环比, 三目, 保存两位小数, BigDecimal,
|
||||
new BigDecimal((nowCount - prevCount)).divide(new BigDecimal(prevCount), BigDecimal.ROUND_HALF_UP, 4)
|
||||
) : 0);
|
||||
map.put("hbCount", nowCount - prevCount); // 环比计数 近期的count - 上期的count
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> rysltj(String type) {
|
||||
String kssj = null, jssj = null, startTime = null, endTime = null;
|
||||
if ("1".equals(type)) {
|
||||
kssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
|
||||
} else if ("2".equals(type)) {
|
||||
kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -14), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
|
||||
} else if ("3".equals(type)) {
|
||||
kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -60), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
|
||||
}
|
||||
UserInfo user = UserInfoManager.get();
|
||||
String useSql = PermissionsUtil.createSql("",user);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
int nowCount = tbWzRywzMapper.getRysltjCount(kssj,jssj,useSql); // 需要去重
|
||||
// 近期
|
||||
map.put("nowCount", nowCount);
|
||||
// 上一期的数量
|
||||
int prevCount = tbWzRywzMapper.getRysltjCount(startTime,endTime,useSql);
|
||||
map.put("prevCount", prevCount);
|
||||
map.put("hb", prevCount != 0 ? (
|
||||
new BigDecimal((nowCount - prevCount)).divide(new BigDecimal(prevCount), BigDecimal.ROUND_HALF_UP, 4)
|
||||
) : 0);
|
||||
map.put("hbCount", nowCount - prevCount); // 环比计数 近期的count - 上期的count
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> sblswz(String type) {
|
||||
String kssj = null, jssj = null, startTime = null, endTime = null;
|
||||
if ("1".equals(type)) {
|
||||
kssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -1), "01");
|
||||
} else if ("2".equals(type)) {
|
||||
kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -14), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -7), "01");
|
||||
} else if ("3".equals(type)) {
|
||||
kssj = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
|
||||
jssj = DateUtils.getQueryDateString(new Date(), "01");
|
||||
startTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -60), "01");
|
||||
endTime = DateUtils.getQueryDateString(DateUtils.getNextDate(new Date(), "D", -30), "01");
|
||||
}
|
||||
UserInfo user = UserInfoManager.get();
|
||||
String useSql = PermissionsUtil.createSql("",user);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
int nowCount = tbWzSblswzMapper.getSblswzCount(kssj,jssj,useSql);
|
||||
// 近期
|
||||
map.put("nowCount", nowCount);
|
||||
// 上一期的数量
|
||||
int prevCount = tbWzSblswzMapper.getSblswzCount(startTime,endTime,useSql);
|
||||
map.put("prevCount", prevCount);
|
||||
map.put("hb", prevCount != 0 ? (
|
||||
new BigDecimal((nowCount - prevCount)).divide(new BigDecimal(prevCount), BigDecimal.ROUND_HALF_UP, 4)
|
||||
) : 0);
|
||||
map.put("hbCount", nowCount - prevCount);
|
||||
return map;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.mosty.wzzx.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mosty.common.core.business.entity.SysUser;
|
||||
import com.mosty.wzzx.mapper.WzzxUserMapper;
|
||||
import com.mosty.wzzx.service.WzzxSysUserService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class WzzxSysUserServiceImpl extends ServiceImpl<WzzxUserMapper, SysUser> implements WzzxSysUserService {
|
||||
|
||||
public List<SysUser> queryList() {
|
||||
return this.baseMapper.selectByPage();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package com.mosty.wzzx.task;
|
||||
|
||||
import com.mosty.base.model.entity.qwzx.TbQwZnzb;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import com.mosty.base.model.entity.wzzx.TbWzXfwz;
|
||||
import com.mosty.base.utils.Constant;
|
||||
import com.mosty.base.utils.DistanceUtils;
|
||||
import com.mosty.base.utils.JtsUtils;
|
||||
import com.mosty.common.redis.service.RedisService;
|
||||
import com.mosty.wzzx.service.TbWzXfwzService;
|
||||
import com.mosty.wzzx.service.impl.TbQwZnzbServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 位置定时器
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class LocationCenterTask {
|
||||
|
||||
private final RedisService redisService;
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final TbWzXfwzService tbWzXfwzService;
|
||||
private final TbQwZnzbServiceImpl tbQwZnzbService;
|
||||
|
||||
// @Scheduled(cron = "0 0/2 * * * ? ")
|
||||
public void locationCompletion() {
|
||||
System.out.println("开始执行位置定时器补全坐标位置");
|
||||
//巡防位置
|
||||
String key = Constant.WZ_XFWZ + "*";
|
||||
Set<String> sets = redisTemplate.keys(key);
|
||||
if (!CollectionUtils.isEmpty(sets)) {
|
||||
List<TbWzXfwz> zfwzList = redisTemplate.opsForValue().multiGet(sets);
|
||||
//设备实时位置
|
||||
String sbwzKey = Constant.WZ_SBWZ + "*";
|
||||
Set<String> sbwzSets = redisTemplate.keys(sbwzKey);
|
||||
if (!CollectionUtils.isEmpty(sbwzSets)) {
|
||||
List<TbWzSbsswz> sbwzList = redisTemplate.opsForValue().multiGet(sbwzSets);
|
||||
if (!CollectionUtils.isEmpty(zfwzList) && !CollectionUtils.isEmpty(sbwzList)) {
|
||||
List<String> bbList = zfwzList.stream().map(TbWzXfwz::getBbId).collect(Collectors.toList());
|
||||
List<TbQwZnzb> znnbList = tbQwZnzbService.queryListByYwid(bbList);
|
||||
for (TbWzXfwz xfwz : zfwzList) {
|
||||
Date zhgxsj = xfwz.getZhgxsj();
|
||||
//上报时长
|
||||
long sbsc = System.currentTimeMillis() - zhgxsj.getTime();
|
||||
if (sbsc >= 60000) {//超过1分钟离线
|
||||
xfwz.setZxzt("0");
|
||||
if (!CollectionUtils.isEmpty(znnbList)) {
|
||||
//获取当前报备的智能装备
|
||||
List<TbQwZnzb> bbzbList =
|
||||
znnbList.stream().filter(item -> item.getYwid().equals(xfwz.getBbId())).collect(Collectors.toList());
|
||||
//获取报备装备呼号
|
||||
List<String> hhList = bbzbList.stream().map(TbQwZnzb::getHh).collect(Collectors.toList());
|
||||
//获取缓存报备装备位置
|
||||
List<TbWzSbsswz> bbSbwzList =
|
||||
sbwzList.stream().filter(entity -> hhList.contains(entity.getSbid())).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(bbSbwzList)) {
|
||||
//对报备装备根据定位时间排序
|
||||
bbSbwzList.stream().sorted(Comparator.comparing(TbWzSbsswz::getDwsj).reversed());
|
||||
TbWzSbsswz sswz = bbSbwzList.get(0);
|
||||
//如果实时位置最新坐标的时间大于
|
||||
if (sswz.getDwsj().getTime() > xfwz.getZhgxsj().getTime()) {
|
||||
//更新巡防位置坐标
|
||||
BigDecimal jd = sswz.getJd();
|
||||
BigDecimal wd = sswz.getWd();
|
||||
Integer lc = DistanceUtils.getLc(xfwz.getLc(), xfwz.getJd(), xfwz.getWd(), jd,
|
||||
wd);
|
||||
Integer sc = DistanceUtils.getSc(xfwz.getZhgxsj());
|
||||
xfwz.setSc(sc);
|
||||
xfwz.setLc(lc);
|
||||
List<BigDecimal[]> list = JtsUtils.decodeLineString(xfwz.getZb());
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
BigDecimal[] decimals = new BigDecimal[2];
|
||||
decimals[0] = jd;
|
||||
decimals[1] = wd;
|
||||
list.add(decimals);
|
||||
if (list.size() == 1) {
|
||||
list.add(decimals);
|
||||
}
|
||||
xfwz.setZb(JtsUtils.createLine(list));
|
||||
xfwz.setZbsl(list.size());
|
||||
xfwz.setDwrq(sswz.getDwrq());
|
||||
xfwz.setJd(jd);
|
||||
xfwz.setWd(wd);
|
||||
xfwz.setZhgxsj(sswz.getXtZhgxsj());
|
||||
}
|
||||
}
|
||||
}
|
||||
tbWzXfwzService.update(xfwz);
|
||||
String redisKey = Constant.WZ_XFWZ + xfwz.getBbId();
|
||||
redisService.setCacheObject(redisKey, xfwz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.mosty.wzzx.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.mosty.base.utils.Constant;
|
||||
import com.mosty.base.utils.DateUtils;
|
||||
import com.mosty.wzzx.service.TbWzSbsswzService;
|
||||
import com.mosty.wzzx.service.TbWzSswzService;
|
||||
import com.mosty.wzzx.service.impl.TbWzSbsswzServiceImpl;
|
||||
import com.mosty.wzzx.service.impl.TbWzSswzServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class LocationClearTask {
|
||||
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final TbWzSbsswzService tbWzSbsswzService;
|
||||
private final TbWzSswzService tbWzSswzService;
|
||||
|
||||
//每天凌晨执行(删除redis数据,删除实时位置的7天前的数据)
|
||||
@Scheduled(cron = "0 0 1 * * ? ")
|
||||
public void locationClear() {
|
||||
System.out.println("开始执行位置定时器位置清理");
|
||||
//清除人员位置
|
||||
String key = Constant.WZ_RYWZ + "*";
|
||||
Set<String> ryKeys = redisTemplate.keys(key);
|
||||
if (CollectionUtils.isNotEmpty(ryKeys)) {
|
||||
ryKeys.forEach(v -> {
|
||||
if (!v.contains(DateUtils.getSystemDateString())) {
|
||||
redisTemplate.delete(v);
|
||||
}
|
||||
});
|
||||
}
|
||||
//清除设备位置
|
||||
String sbwzKey = Constant.WZ_SBWZ + "*";
|
||||
Set<String> sbKeys = redisTemplate.keys(sbwzKey);
|
||||
if (CollectionUtils.isNotEmpty(sbKeys)) {
|
||||
sbKeys.forEach(v -> {
|
||||
if (!v.contains(DateUtils.getSystemDateString())) {
|
||||
redisTemplate.delete(v);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//删除实时位置7天前数据
|
||||
tbWzSswzService.delHistory();
|
||||
//删除设备实时位置7天前数据
|
||||
tbWzSbsswzService.delHistory();
|
||||
}
|
||||
|
||||
}
|
201
mosty-wzzx/src/main/java/com/mosty/wzzx/udp/UdpLzEntity.java
Normal file
201
mosty-wzzx/src/main/java/com/mosty/wzzx/udp/UdpLzEntity.java
Normal file
@ -0,0 +1,201 @@
|
||||
package com.mosty.wzzx.udp;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mosty.base.utils.DateUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 泸州udp转换
|
||||
*
|
||||
* @author esacpe
|
||||
*/
|
||||
@Data
|
||||
public class UdpLzEntity {
|
||||
|
||||
/**
|
||||
* pgisId
|
||||
*/
|
||||
private String pgisId;
|
||||
/**
|
||||
* 经度,单位度
|
||||
*/
|
||||
private Double lng;
|
||||
/**
|
||||
* 纬度,单位度
|
||||
*/
|
||||
private Double lat;
|
||||
/**
|
||||
* 高程,单位米
|
||||
*/
|
||||
private Integer altitude;
|
||||
/**
|
||||
* 速度,单位Km/h
|
||||
*/
|
||||
private Integer speed;
|
||||
/**
|
||||
* 方向,0-359,正北为0,顺时针
|
||||
*/
|
||||
private Integer direction;
|
||||
/**
|
||||
* 定位时间
|
||||
*/
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* 精度
|
||||
*/
|
||||
private Integer precision;
|
||||
|
||||
//解析
|
||||
public boolean parseLz(byte[] data) {
|
||||
return parseLz(data, data.length);
|
||||
}
|
||||
|
||||
private int destPos = 0;
|
||||
|
||||
public boolean parseLz(byte[] data, int dataLength) {
|
||||
if (data == null || dataLength < 10 || dataLength > data.length) {
|
||||
return false;
|
||||
}
|
||||
if (data[0] == 0xAA) {
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] bytes3 = new byte[20];
|
||||
// System.arraycopy(data, 10, bytes3, 0, 20);
|
||||
//
|
||||
// pgisId = new String(bytes3, Charset.forName("UTF-8"));
|
||||
// pgisId = new String(bytes3, Charset.forName("UTF-8"));
|
||||
destPos = 10;
|
||||
pgisId = (new String(arraycopy(data, destPos, 20,20), Charset.forName("UTF-8"))).trim();
|
||||
|
||||
// byte[] jdbt=new byte[8];
|
||||
// System.arraycopy(data, 30, jdbt, 0, 8);
|
||||
// lng = bytes2Double(jdbt);
|
||||
|
||||
lng = bytes2Double(arraycopy(data, destPos, 8,8));
|
||||
|
||||
// byte[] wdbt=new byte[8];
|
||||
// System.arraycopy(data, 38, wdbt, 0, 8);
|
||||
// lat = bytes2Double(wdbt);
|
||||
|
||||
lat = bytes2Double(arraycopy(data, destPos, 8,8));
|
||||
|
||||
|
||||
// byte[] dspeedbyte=new byte[8];
|
||||
// System.arraycopy(data, 46, dspeedbyte, 0, 2);
|
||||
// speed = byte2int(dspeedbyte);
|
||||
|
||||
speed = byte2int(arraycopy(data, destPos, 2,4));
|
||||
|
||||
|
||||
// byte[] dirsbyte=new byte[8];
|
||||
// System.arraycopy(data, 48, dirsbyte, 0, 2);
|
||||
// direction = byte2int(dirsbyte);
|
||||
|
||||
direction = byte2int(arraycopy(data, destPos, 2,4));
|
||||
|
||||
altitude = byte2int(arraycopy(data, destPos, 2,4));
|
||||
|
||||
precision = byte2int(arraycopy(data, destPos, 2,4));
|
||||
|
||||
Integer year = byte2int(arraycopyYear(data, destPos, 2,4));
|
||||
Integer month = byte2int(arraycopy(data, destPos, 1,4));
|
||||
Integer day = byte2int(arraycopy(data, destPos, 1,4));
|
||||
Integer hours = byte2int(arraycopy(data, destPos, 1,4));
|
||||
Integer minutes = byte2int(arraycopy(data, destPos, 1,4));
|
||||
Integer seconds = byte2int(arraycopy(data, destPos, 1,4));
|
||||
try {
|
||||
time = DateUtils.stringToDate(year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds, "yyyy-MM-dd HH:mm:ss");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return time != null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密有问题 把54 55单独替换位置
|
||||
* @param arr
|
||||
* @param dest
|
||||
* @param len
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
private byte[] arraycopyYear(byte[] arr, int dest, int len,int end) {
|
||||
byte[] copy = new byte[end];
|
||||
System.arraycopy(arr, 55, copy, 0, 1);
|
||||
System.arraycopy(arr, 54, copy, 1, 1);
|
||||
destPos = dest + len;
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
private byte[] arraycopy(byte[] arr, int dest, int len,int end) {
|
||||
byte[] copy = new byte[end];
|
||||
System.arraycopy(arr, dest, copy, 0, len);
|
||||
destPos = dest + len;
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
private double bytes2Double(byte[] arr) {
|
||||
long value = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
value |= ((long) (arr[i] & 0xff)) << (8 * i);
|
||||
}
|
||||
return Double.longBitsToDouble(value);
|
||||
}
|
||||
|
||||
public int byte2int(byte[] res) {
|
||||
int targets = (res[0] & 0xff) | ((res[1] << 8) & 0xff00) | ((res[2] << 24) >>> 8) | (res[3] << 24);
|
||||
return targets;
|
||||
}
|
||||
|
||||
public static byte[] hexStringToByte(String hexstr) {
|
||||
if (hexstr == null)
|
||||
return null;
|
||||
byte[] b = new byte[hexstr.length() / 2];
|
||||
int j = 0;
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
char c0 = hexstr.charAt(j++);
|
||||
char c1 = hexstr.charAt(j++);
|
||||
b[i] = ((byte) (charToInt(c0) << 4 | charToInt(c1)));
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
// char转换成int
|
||||
public static int charToInt(char c) {
|
||||
if (c >= 'a') {
|
||||
return c - 'a' + 10 & 0xF;
|
||||
}
|
||||
if (c >= 'A') {
|
||||
return c - 'A' + 10 & 0xF;
|
||||
}
|
||||
return c - '0' & 0xF;
|
||||
}
|
||||
public static String byteArrayToString(byte[] data) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : data) {
|
||||
sb.append(String.format("%02X", b));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
UdpLzEntity lzEntity = new UdpLzEntity();
|
||||
byte[] bytes2 = UdpLzEntity.hexStringToByte("AAAACCCC002200000033313334303430313837343700000000000000000016A6EF3504305A403BC43F6CE9BD3F400000000001E4000007E8040B100402");
|
||||
lzEntity.parseLz(bytes2);
|
||||
|
||||
System.out.println(JSON.toJSONString(lzEntity));
|
||||
}
|
||||
}
|
115
mosty-wzzx/src/main/java/com/mosty/wzzx/udp/UdpServerForLz.java
Normal file
115
mosty-wzzx/src/main/java/com/mosty/wzzx/udp/UdpServerForLz.java
Normal file
@ -0,0 +1,115 @@
|
||||
package com.mosty.wzzx.udp;
|
||||
|
||||
import com.mosty.base.model.entity.wzzx.TbWzSbsswz;
|
||||
import com.mosty.wzzx.service.TbWzSblswzService;
|
||||
import com.mosty.wzzx.service.TbWzSbsswzService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.integration.annotation.Filter;
|
||||
import org.springframework.integration.annotation.Router;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.ip.dsl.Udp;
|
||||
import org.springframework.messaging.handler.annotation.Headers;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* esacpe
|
||||
* 泸州udp
|
||||
* 2023-01-10
|
||||
*/
|
||||
@Component
|
||||
public class UdpServerForLz {
|
||||
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UdpServerForLz.class);
|
||||
|
||||
@Value("${custom.udp.LzUdpPort}")
|
||||
private Integer bureauPort;
|
||||
@Resource
|
||||
private TbWzSbsswzService tbWzSbsswzService;
|
||||
@Resource
|
||||
private TbWzSblswzService tbWzSblswzService;
|
||||
|
||||
// UDP服务
|
||||
@Bean(name = "integrationLzUdp")
|
||||
public IntegrationFlow integrationFlow() {
|
||||
logger.info("UDP-UDP-启动成功,端口号为: {}", bureauPort);
|
||||
return IntegrationFlows.from(Udp.inboundAdapter(bureauPort)).channel("udpChannelLz").get();
|
||||
}
|
||||
|
||||
|
||||
// 数据转换器
|
||||
@Transformer(inputChannel = "udpChannelLz", outputChannel = "udpFilterLz")
|
||||
public UdpLzEntity transformer(@Payload byte[] payload) {
|
||||
// logger.info("UDP-定位接收服务-开始转换数据");
|
||||
UdpLzEntity lzEntity = new UdpLzEntity();
|
||||
try {
|
||||
String s = UdpLzEntity.byteArrayToString(payload);
|
||||
// logger.info("UDP推送信息---》", s);
|
||||
if (lzEntity.parseLz(payload)) {
|
||||
|
||||
if (ObjectUtils.isNotEmpty(lzEntity)) {
|
||||
// long time = new Date().getTime();
|
||||
// long i = time - lzEntity.getTime().getTime();
|
||||
// if (i > 300000) {
|
||||
// logger.info("UDP-定位接收服务-返回位置信息异常 : {}", s);
|
||||
// }
|
||||
lzEntity.setPgisId(lzEntity.getPgisId().replace("000", ""));
|
||||
}
|
||||
return lzEntity;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new UdpLzEntity();
|
||||
}
|
||||
|
||||
|
||||
// 过滤器
|
||||
@Filter(inputChannel = "udpFilterLz", outputChannel = "udpRouterLz")
|
||||
public boolean filter(@Headers Map<String, Object> headers) {
|
||||
String id = headers.get("id").toString();
|
||||
String ip = headers.get("ip_address").toString();
|
||||
String port = headers.get("ip_port").toString();
|
||||
// System.err.println("filter-id : " + id + ",filter-ip : " + ip + ",filter-port : " + port);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 路由分发处理器 - 可根据消息或者headers数据进行分发处理
|
||||
@Router(inputChannel = "udpRouterLz")
|
||||
public String router(UdpLzEntity lzEntity) {
|
||||
if (null == lzEntity.getLat() || lzEntity.getLat() == 0
|
||||
|| null == lzEntity.getLng() || lzEntity.getLng() == 0) {
|
||||
return "locationExceptionHandleLz";
|
||||
}
|
||||
return "locationHandleLz";
|
||||
}
|
||||
|
||||
|
||||
// 位置信息处理方法
|
||||
@ServiceActivator(inputChannel = "locationHandleLz")
|
||||
public void locationHandleLz(UdpLzEntity lzEntity) {
|
||||
// logger.info("UDP-定位接收服务-获取到正常位置信息 : {}", lzEntity.toString());
|
||||
TbWzSbsswz sswz = this.tbWzSbsswzService.saveSbsswz(lzEntity);
|
||||
this.tbWzSblswzService.saveSblswz(sswz);
|
||||
}
|
||||
|
||||
|
||||
// 位置信息解析异常处理方法
|
||||
@ServiceActivator(inputChannel = "locationExceptionHandleLz")
|
||||
public void locationExceptionHandleLz(UdpLzEntity lzEntity) {
|
||||
logger.error("UDP-定位接收服务-获取到解析异常位置信息 : {} ", lzEntity.toString());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user