a24316bc 张雷

修改包名及结构

1 个父辈 58106dbe
正在显示 16 个修改的文件 包含 84 行增加47 行删除
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4 <modelVersion>4.0.0</modelVersion> 4 <modelVersion>4.0.0</modelVersion>
5 <groupId>com.it</groupId> 5 <groupId>com.jkdata</groupId>
6 <artifactId>skreceive</artifactId> 6 <artifactId>skreceive</artifactId>
7 <version>1.0</version> 7 <version>1.0</version>
8 <name>skreceive</name> 8 <name>skreceive</name>
9 <description>Demo project for Spring Boot</description> 9 <description>Receive CMCC Position</description>
10 10
11 <properties> 11 <properties>
12 <java.version>1.8</java.version> 12 <java.version>1.8</java.version>
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
114 <artifactId>spring-boot-maven-plugin</artifactId> 114 <artifactId>spring-boot-maven-plugin</artifactId>
115 <version>2.5.3</version> 115 <version>2.5.3</version>
116 <configuration> 116 <configuration>
117 <mainClass>com.it.SkApplication</mainClass> 117 <mainClass>com.jkdata.SkApplication</mainClass>
118 </configuration> 118 </configuration>
119 <executions> 119 <executions>
120 <execution> 120 <execution>
......
1 package com.it; 1 package com.jkdata;
2 2
3 import lombok.extern.slf4j.Slf4j; 3 import lombok.extern.slf4j.Slf4j;
4 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.SpringApplication;
......
1 package com.it.config; 1 package com.jkdata.config;
2 2
3 import lombok.extern.slf4j.Slf4j; 3 import lombok.extern.slf4j.Slf4j;
4 import org.springframework.context.annotation.Bean; 4 import org.springframework.context.annotation.Bean;
......
1 package com.it.config; 1 package com.jkdata.config;
2 2
3 import com.google.common.base.Predicates; 3 import com.google.common.base.Predicates;
4 import org.springframework.context.annotation.Bean; 4 import org.springframework.context.annotation.Bean;
......
1 package com.it.controller; 1 package com.jkdata.controller;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.it.service.IThirdService; 4 import com.jkdata.service.IThirdService;
5 import com.it.entity.Result; 5 import com.jkdata.tool.Result;
6 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.web.bind.annotation.*; 7 import org.springframework.web.bind.annotation.*;
8 8
9 import javax.servlet.http.HttpServletRequest; 9 import javax.servlet.http.HttpServletRequest;
10 import javax.servlet.http.HttpServletResponse; 10 import javax.servlet.http.HttpServletResponse;
11 import java.io.BufferedReader; 11 import java.io.BufferedReader;
12 import java.util.HashMap;
12 import java.util.Map; 13 import java.util.Map;
13 14
14 @RestController 15 @RestController
...@@ -21,12 +22,15 @@ public class ThirdController { ...@@ -21,12 +22,15 @@ public class ThirdController {
21 @PostMapping("/receivePosition") 22 @PostMapping("/receivePosition")
22 public Result<Map<String,Object>> save(HttpServletRequest request, HttpServletResponse response) { 23 public Result<Map<String,Object>> save(HttpServletRequest request, HttpServletResponse response) {
23 Result<Map<String,Object>> result = new Result<Map<String,Object>>(); 24 Result<Map<String,Object>> result = new Result<Map<String,Object>>();
25 Map<String,Object> map = new HashMap<>();
24 String resMsg = getPostData(request); 26 String resMsg = getPostData(request);
25 JSONObject jsonObject = initData(resMsg); 27 JSONObject jsonObject = initData(resMsg);
26 String type = jsonObject.getString("Type"); 28 String type = jsonObject.getString("Type");
27 //判断消息类型 29 //判断消息类型
28 if("location_pos".equals(type)){ 30 if("location_pos".equals(type)){
31 map.put("message",resMsg);
29 thirdService.savePosition(jsonObject); 32 thirdService.savePosition(jsonObject);
33 result.setResult(map);
30 result.setSuccess(true); 34 result.setSuccess(true);
31 }else{ 35 }else{
32 result.error500("类型错误!"); 36 result.error500("类型错误!");
...@@ -36,14 +40,14 @@ public class ThirdController { ...@@ -36,14 +40,14 @@ public class ThirdController {
36 40
37 //初始化数据 41 //初始化数据
38 private JSONObject initData(String resMsg) { 42 private JSONObject initData(String resMsg) {
39 // resMsg = "{\"Gateway\":\"10030049\"," + 43 resMsg = "{\"Gateway\":\"10030049\"," +
40 // "\"NodeId\":\"CB8A1DEB\"," + 44 "\"NodeId\":\"CB8A1DEB\"," +
41 // "\"SystemId\":\"10990145\"," + 45 "\"SystemId\":\"10990145\"," +
42 // "\"Type\":\"location_pos\"," + 46 "\"Type\":\"location_pos\"," +
43 // "\"group\":\"5\"," + 47 "\"group\":\"5\"," +
44 // "\"groupNumber\":1," + 48 "\"groupNumber\":1," +
45 // "\"position\":{\"x\":214.44541185285127,\"y\":210.15474327170986}," + 49 "\"position\":{\"x\":214.44541185285127,\"y\":210.15474327170986}," +
46 // "\"scale\":0}"; 50 "\"scale\":0}";
47 System.out.println("***"+System.currentTimeMillis()+"报文***"+resMsg); 51 System.out.println("***"+System.currentTimeMillis()+"报文***"+resMsg);
48 JSONObject jsonObject = new JSONObject(); 52 JSONObject jsonObject = new JSONObject();
49 jsonObject = JSONObject.parseObject(resMsg); 53 jsonObject = JSONObject.parseObject(resMsg);
......
1 package com.it.entity; 1 package com.jkdata.entity;
2 2
3 import com.baomidou.mybatisplus.annotation.IdType; 3 import com.baomidou.mybatisplus.annotation.IdType;
4 import com.baomidou.mybatisplus.annotation.TableId; 4 import com.baomidou.mybatisplus.annotation.TableId;
5 import lombok.Data; 5 import lombok.Data;
6 import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
7 6
8 @Data 7 @Data
9 public class ThirdPosition { 8 public class ThirdPosition {
......
1 package com.it.mapper; 1 package com.jkdata.mapper;
2 2
3 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 import com.it.entity.ThirdPosition; 4 import com.jkdata.entity.ThirdPosition;
5 import org.apache.ibatis.annotations.Mapper; 5 import org.apache.ibatis.annotations.Mapper;
6 import org.apache.ibatis.annotations.Param; 6 import org.apache.ibatis.annotations.Param;
7 7
......
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 <mapper namespace="com.it.mapper.ThirdMapper"> 3 <mapper namespace="com.jkdata.mapper.ThirdMapper">
4 4
5 <insert id="addDataToDataBase"> 5 <insert id="addDataToDataBase">
6 ${sql} 6 ${sql}
......
1 package com.it.service; 1 package com.jkdata.service;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 4
......
1 package com.it.service.impl; 1 package com.jkdata.service.impl;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.fasterxml.jackson.annotation.ObjectIdGenerators; 4 import com.jkdata.tool.CommonConstant;
5 import com.it.entity.CommonConstant; 5 import com.jkdata.entity.ThirdPosition;
6 import com.it.entity.ThirdPosition; 6 import com.jkdata.mapper.ThirdMapper;
7 import com.it.mapper.ThirdMapper; 7 import com.jkdata.service.IThirdService;
8 import com.it.service.IThirdService; 8 import com.jkdata.tool.RedisUtil;
9 import com.it.tool.RedisUtil; 9 import com.jkdata.tool.UUIDGenerator;
10 import com.it.tool.UUIDGenerator;
11 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Service; 11 import org.springframework.stereotype.Service;
13 12
...@@ -43,7 +42,9 @@ public class IThirdServiceImpl implements IThirdService { ...@@ -43,7 +42,9 @@ public class IThirdServiceImpl implements IThirdService {
43 thirdPosition.setGroup(jsonObject.getString("group")); 42 thirdPosition.setGroup(jsonObject.getString("group"));
44 thirdPosition.setGroupNumber(jsonObject.getInteger("groupNumber")); 43 thirdPosition.setGroupNumber(jsonObject.getInteger("groupNumber"));
45 thirdPosition.setCreateTime(t); 44 thirdPosition.setCreateTime(t);
46 changCoordinate(thirdPosition); 45 //判断是B1、B2
46 changCoordinateB1(thirdPosition);
47 // changCoordinateB2(thirdPosition);
47 } 48 }
48 49
49 50
...@@ -54,7 +55,8 @@ public class IThirdServiceImpl implements IThirdService { ...@@ -54,7 +55,8 @@ public class IThirdServiceImpl implements IThirdService {
54 * @param jsonObject 55 * @param jsonObject
55 */ 56 */
56 private boolean addMsgLog(JSONObject jsonObject, String format) { 57 private boolean addMsgLog(JSONObject jsonObject, String format) {
57 String sql = "INSERT INTO sys_msg_log ( mag_log,create_by,create_time ) VALUES ( '"+jsonObject.toJSONString()+"','cmcc','"+format+"' )"; 58 String sql = "INSERT INTO sys_msg_log ( mag_log,create_by,create_time ) VALUES " +
59 "( '"+jsonObject.toJSONString()+"','"+CommonConstant.CMCC+"','"+format+"' )";
58 System.out.println("**********"+sql); 60 System.out.println("**********"+sql);
59 boolean ok = addDataToDataBase(sql); 61 boolean ok = addDataToDataBase(sql);
60 return ok; 62 return ok;
...@@ -66,15 +68,15 @@ public class IThirdServiceImpl implements IThirdService { ...@@ -66,15 +68,15 @@ public class IThirdServiceImpl implements IThirdService {
66 return ok; 68 return ok;
67 } 69 }
68 70
69 private void changCoordinate(ThirdPosition thirdPosition) { 71 //B1定位坐标
72 private void changCoordinateB1(ThirdPosition thirdPosition) {
70 // String x1 = "101.1636962890625"; 73 // String x1 = "101.1636962890625";
71 // String y1 = "325.2133483886719"; 74 // String y1 = "325.2133483886719";
72 String x1 = thirdPosition.getPositionx(); 75 String x1 = thirdPosition.getPositionx();
73 String y1 = thirdPosition.getPositiony(); 76 String y1 = thirdPosition.getPositiony();
74 double blc = 100/2.54;//比例尺
75 77
76 double fd_x = blc*(Double.valueOf(x1)-CommonConstant.LT_B1_X)+CommonConstant.LT_B1_X; 78 double fd_x = CommonConstant.BLC1*(Double.valueOf(x1)-CommonConstant.LT_B1_X)+CommonConstant.LT_B1_X;
77 double fd_y = blc*(Double.valueOf(y1)+CommonConstant.LT_B1_Y)-CommonConstant.LT_B1_Y; 79 double fd_y = CommonConstant.BLC1*(Double.valueOf(y1)+CommonConstant.LT_B1_Y)-CommonConstant.LT_B1_Y;
78 System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y); 80 System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
79 81
80 double a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x 82 double a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x
...@@ -94,14 +96,37 @@ public class IThirdServiceImpl implements IThirdService { ...@@ -94,14 +96,37 @@ public class IThirdServiceImpl implements IThirdService {
94 addPositionInfo(thirdPosition);//添加转换后坐标信息 96 addPositionInfo(thirdPosition);//添加转换后坐标信息
95 } 97 }
96 98
99 //B2定位坐标
100 private void changCoordinateB2(ThirdPosition thirdPosition) {
101 String x1 = thirdPosition.getPositionx();
102 String y1 = thirdPosition.getPositiony();
103
104 double fd_x = CommonConstant.BLC2*(Double.valueOf(x1)-CommonConstant.LT_B2_X)+CommonConstant.LT_B2_X;
105 double fd_y = CommonConstant.BLC2*(Double.valueOf(y1)+CommonConstant.LT_B2_Y)-CommonConstant.LT_B2_Y;
106 System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
107
108 double a = CommonConstant.MQ_B2_X - CommonConstant.LT_B2_X;//原点偏移x
109 double b = CommonConstant.MQ_B2_Y - CommonConstant.LT_B2_Y;//原点偏移y
110 System.out.println("偏移a:"+a+",b:"+b);
111
112 double x = Double.valueOf(fd_x) + a;
113 double y = Double.valueOf(fd_y) + b;
114 System.out.println("新坐标为:X:"+x+",Y:-"+y);
115
116 thirdPosition.setPositionx(String.valueOf(x));
117 thirdPosition.setPositiony(String.valueOf(y));
118 addPositionInfo(thirdPosition);//添加转换后坐标信息
119 }
120
97 private boolean addPositionInfo(ThirdPosition thirdPosition) { 121 private boolean addPositionInfo(ThirdPosition thirdPosition) {
98 String uuid = UUIDGenerator.creatUUID(); 122 String uuid = UUIDGenerator.creatUUID();
99 String sql = "INSERT INTO sys_cmcc_position ( `position_id`,`node_id`,`system_id`,`type`,`group`," + 123 String sql = "INSERT INTO sys_cmcc_position ( `position_id`,`node_id`,`system_id`,`type`,`group`," +
100 "`group_number`,`position_x`,`position_y`,`create_by`,`create_time` ) VALUES " + 124 "`group_number`,`position_x`,`position_y`,`create_by`,`create_time` ) VALUES " +
101 " ( '"+uuid+"','"+thirdPosition.getNodeId()+"','"+thirdPosition.getSystemId()+"','"+thirdPosition.getType()+"','"+thirdPosition.getGroup()+"'," + 125 " ( '"+uuid+"','"+thirdPosition.getNodeId()+"','"+thirdPosition.getSystemId()+"','"+thirdPosition.getType()+"','"+thirdPosition.getGroup()+"'," +
102 ""+thirdPosition.getGroupNumber()+",'"+thirdPosition.getPositionx()+"','"+thirdPosition.getPositiony()+"','cmcc','"+sf.format(thirdPosition.getCreateTime())+"' )"; 126 ""+thirdPosition.getGroupNumber()+",'"+thirdPosition.getPositionx()+"','"+thirdPosition.getPositiony()+"','"+CommonConstant.CMCC+"','"+sf.format(thirdPosition.getCreateTime())+"' )";
103 System.out.println("**********"+sql); 127 System.out.println("**********"+sql);
104 boolean ok = addDataToDataBase(sql); 128 boolean ok = addDataToDataBase(sql);
105 return ok; 129 return ok;
106 } 130 }
131
107 } 132 }
......
1 package com.it.entity; 1 package com.jkdata.tool;
2 2
3 public interface CommonConstant { 3 public interface CommonConstant {
4 Integer SC_ERROR_500 = 500; 4
5 Integer SC_OK_200 = 200; 5 //**********************返回参数代码***************************
6 Integer SC_ERROR_500 = 500;//错误代码
7 Integer SC_OK_200 = 200;//成功代码
6 8
7 //**********************联通中心坐标*************************** 9 //**********************联通中心坐标***************************
8 Double LT_B1_X = 379.2256164550781;//联通B1层X坐标 10 Double LT_B1_X = 379.2256164550781;//联通B1层X坐标
...@@ -16,4 +18,11 @@ public interface CommonConstant { ...@@ -16,4 +18,11 @@ public interface CommonConstant {
16 Double MQ_B2_X = -178.527924;//鸣启B2层X坐标 18 Double MQ_B2_X = -178.527924;//鸣启B2层X坐标
17 Double MQ_B2_Y = -1226.708374;//鸣启B2层Y坐标 19 Double MQ_B2_Y = -1226.708374;//鸣启B2层Y坐标
18 20
21 //**********************比例尺***************************
22 Double BLC1 = 100/2.54;//比例尺
23 Double BLC2 = 100/2.54;//比例尺
24
25 //**********************推送用户***************************
26 String CMCC = "CMCC";//联通推送用户
27
19 } 28 }
......
1 package com.it.tool; 1 package com.jkdata.tool;
2 2
3 import org.springframework.data.redis.core.RedisTemplate; 3 import org.springframework.data.redis.core.RedisTemplate;
4 import org.springframework.stereotype.Component; 4 import org.springframework.stereotype.Component;
......
1 package com.it.entity; 1 package com.jkdata.tool;
2 2
3 import io.swagger.annotations.ApiModelProperty; 3 import io.swagger.annotations.ApiModelProperty;
4 4
......
1 package com.it.tool; 1 package com.jkdata.tool;
2 2
3 import java.net.InetAddress; 3 import java.net.InetAddress;
4 import java.util.UUID; 4 import java.util.UUID;
......
...@@ -14,7 +14,7 @@ spring: ...@@ -14,7 +14,7 @@ spring:
14 # host: redis 14 # host: redis
15 15
16 mybatis-plus: 16 mybatis-plus:
17 mapper-locations: classpath*:com/it/mapper/xml/*Mapper.xml 17 mapper-locations: classpath*:com/jkdata/mapper/xml/*Mapper.xml
18 global-config: 18 global-config:
19 db-config: 19 db-config:
20 #使用数据库的自增策略 20 #使用数据库的自增策略
......
1 package com.it; 1 package com.jkdata;
2 2
3 import org.junit.jupiter.api.Test; 3 import org.junit.jupiter.api.Test;
4 import org.springframework.boot.test.context.SpringBootTest; 4 import org.springframework.boot.test.context.SpringBootTest;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!