Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
skreceive
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
a24316bc
由
张雷
编写于
2022-08-17 19:12:07 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改包名及结构
1 个父辈
58106dbe
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
83 行增加
和
46 行删除
pom.xml
src/main/java/com/it/SkApplication.java → src/main/java/com/jkdata/SkApplication.java
src/main/java/com/it/config/RedisConfig.java → src/main/java/com/jkdata/config/RedisConfig.java
src/main/java/com/it/config/SwaggerConfig.java → src/main/java/com/jkdata/config/SwaggerConfig.java
src/main/java/com/it/controller/ThirdController.java → src/main/java/com/jkdata/controller/ThirdController.java
src/main/java/com/it/entity/ThirdPosition.java → src/main/java/com/jkdata/entity/ThirdPosition.java
src/main/java/com/it/mapper/ThirdMapper.java → src/main/java/com/jkdata/mapper/ThirdMapper.java
src/main/java/com/it/mapper/xml/ThirdMapper.xml → src/main/java/com/jkdata/mapper/xml/ThirdMapper.xml
src/main/java/com/it/service/IThirdService.java → src/main/java/com/jkdata/service/IThirdService.java
src/main/java/com/it/service/impl/IThirdServiceImpl.java → src/main/java/com/jkdata/service/impl/IThirdServiceImpl.java
src/main/java/com/it/entity/CommonConstant.java → src/main/java/com/jkdata/tool/CommonConstant.java
src/main/java/com/it/tool/RedisUtil.java → src/main/java/com/jkdata/tool/RedisUtil.java
src/main/java/com/it/entity/Result.java → src/main/java/com/jkdata/tool/Result.java
src/main/java/com/it/tool/UUIDGenerator.java → src/main/java/com/jkdata/tool/UUIDGenerator.java
src/main/resources/application.yml
src/test/java/com/it/SkApplicationTests.java → src/test/java/com/jkdata/SkApplicationTests.java
pom.xml
查看文件 @
a24316b
...
...
@@ -2,11 +2,11 @@
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.
it
</groupId>
<groupId>
com.
jkdata
</groupId>
<artifactId>
skreceive
</artifactId>
<version>
1.0
</version>
<name>
skreceive
</name>
<description>
Demo project for Spring Boot
</description>
<description>
Receive CMCC Position
</description>
<properties>
<java.version>
1.8
</java.version>
...
...
@@ -114,7 +114,7 @@
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
2.5.3
</version>
<configuration>
<mainClass>
com.
it
.SkApplication
</mainClass>
<mainClass>
com.
jkdata
.SkApplication
</mainClass>
</configuration>
<executions>
<execution>
...
...
src/main/java/com/
it
/SkApplication.java
→
src/main/java/com/
jkdata
/SkApplication.java
查看文件 @
a24316b
package
com
.
it
;
package
com
.
jkdata
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.SpringApplication
;
...
...
src/main/java/com/
it
/config/RedisConfig.java
→
src/main/java/com/
jkdata
/config/RedisConfig.java
查看文件 @
a24316b
package
com
.
it
.
config
;
package
com
.
jkdata
.
config
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.annotation.Bean
;
...
...
src/main/java/com/
it
/config/SwaggerConfig.java
→
src/main/java/com/
jkdata
/config/SwaggerConfig.java
查看文件 @
a24316b
package
com
.
it
.
config
;
package
com
.
jkdata
.
config
;
import
com.google.common.base.Predicates
;
import
org.springframework.context.annotation.Bean
;
...
...
src/main/java/com/
it
/controller/ThirdController.java
→
src/main/java/com/
jkdata
/controller/ThirdController.java
查看文件 @
a24316b
package
com
.
it
.
controller
;
package
com
.
jkdata
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.
it
.service.IThirdService
;
import
com.
it.entity
.Result
;
import
com.
jkdata
.service.IThirdService
;
import
com.
jkdata.tool
.Result
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedReader
;
import
java.util.HashMap
;
import
java.util.Map
;
@RestController
...
...
@@ -21,12 +22,15 @@ public class ThirdController {
@PostMapping
(
"/receivePosition"
)
public
Result
<
Map
<
String
,
Object
>>
save
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Result
<
Map
<
String
,
Object
>>
result
=
new
Result
<
Map
<
String
,
Object
>>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
String
resMsg
=
getPostData
(
request
);
JSONObject
jsonObject
=
initData
(
resMsg
);
String
type
=
jsonObject
.
getString
(
"Type"
);
//判断消息类型
if
(
"location_pos"
.
equals
(
type
)){
map
.
put
(
"message"
,
resMsg
);
thirdService
.
savePosition
(
jsonObject
);
result
.
setResult
(
map
);
result
.
setSuccess
(
true
);
}
else
{
result
.
error500
(
"类型错误!"
);
...
...
@@ -36,14 +40,14 @@ public class ThirdController {
//初始化数据
private
JSONObject
initData
(
String
resMsg
)
{
//
resMsg = "{\"Gateway\":\"10030049\"," +
//
"\"NodeId\":\"CB8A1DEB\"," +
//
"\"SystemId\":\"10990145\"," +
//
"\"Type\":\"location_pos\"," +
//
"\"group\":\"5\"," +
//
"\"groupNumber\":1," +
//
"\"position\":{\"x\":214.44541185285127,\"y\":210.15474327170986}," +
//
"\"scale\":0}";
resMsg
=
"{\"Gateway\":\"10030049\","
+
"\"NodeId\":\"CB8A1DEB\","
+
"\"SystemId\":\"10990145\","
+
"\"Type\":\"location_pos\","
+
"\"group\":\"5\","
+
"\"groupNumber\":1,"
+
"\"position\":{\"x\":214.44541185285127,\"y\":210.15474327170986},"
+
"\"scale\":0}"
;
System
.
out
.
println
(
"***"
+
System
.
currentTimeMillis
()+
"报文***"
+
resMsg
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
=
JSONObject
.
parseObject
(
resMsg
);
...
...
src/main/java/com/
it
/entity/ThirdPosition.java
→
src/main/java/com/
jkdata
/entity/ThirdPosition.java
查看文件 @
a24316b
package
com
.
it
.
entity
;
package
com
.
jkdata
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
net.sf.jsqlparser.expression.DateTimeLiteralExpression
;
@Data
public
class
ThirdPosition
{
...
...
src/main/java/com/
it
/mapper/ThirdMapper.java
→
src/main/java/com/
jkdata
/mapper/ThirdMapper.java
查看文件 @
a24316b
package
com
.
it
.
mapper
;
package
com
.
jkdata
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.
it
.entity.ThirdPosition
;
import
com.
jkdata
.entity.ThirdPosition
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
...
...
src/main/java/com/
it
/mapper/xml/ThirdMapper.xml
→
src/main/java/com/
jkdata
/mapper/xml/ThirdMapper.xml
查看文件 @
a24316b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.
it
.mapper.ThirdMapper"
>
<mapper
namespace=
"com.
jkdata
.mapper.ThirdMapper"
>
<insert
id=
"addDataToDataBase"
>
${sql}
...
...
src/main/java/com/
it
/service/IThirdService.java
→
src/main/java/com/
jkdata
/service/IThirdService.java
查看文件 @
a24316b
package
com
.
it
.
service
;
package
com
.
jkdata
.
service
;
import
com.alibaba.fastjson.JSONObject
;
...
...
src/main/java/com/
it
/service/impl/IThirdServiceImpl.java
→
src/main/java/com/
jkdata
/service/impl/IThirdServiceImpl.java
查看文件 @
a24316b
package
com
.
it
.
service
.
impl
;
package
com
.
jkdata
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.annotation.ObjectIdGenerators
;
import
com.it.entity.CommonConstant
;
import
com.it.entity.ThirdPosition
;
import
com.it.mapper.ThirdMapper
;
import
com.it.service.IThirdService
;
import
com.it.tool.RedisUtil
;
import
com.it.tool.UUIDGenerator
;
import
com.jkdata.tool.CommonConstant
;
import
com.jkdata.entity.ThirdPosition
;
import
com.jkdata.mapper.ThirdMapper
;
import
com.jkdata.service.IThirdService
;
import
com.jkdata.tool.RedisUtil
;
import
com.jkdata.tool.UUIDGenerator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -43,7 +42,9 @@ public class IThirdServiceImpl implements IThirdService {
thirdPosition
.
setGroup
(
jsonObject
.
getString
(
"group"
));
thirdPosition
.
setGroupNumber
(
jsonObject
.
getInteger
(
"groupNumber"
));
thirdPosition
.
setCreateTime
(
t
);
changCoordinate
(
thirdPosition
);
//判断是B1、B2
changCoordinateB1
(
thirdPosition
);
// changCoordinateB2(thirdPosition);
}
...
...
@@ -54,7 +55,8 @@ public class IThirdServiceImpl implements IThirdService {
* @param jsonObject
*/
private
boolean
addMsgLog
(
JSONObject
jsonObject
,
String
format
)
{
String
sql
=
"INSERT INTO sys_msg_log ( mag_log,create_by,create_time ) VALUES ( '"
+
jsonObject
.
toJSONString
()+
"','cmcc','"
+
format
+
"' )"
;
String
sql
=
"INSERT INTO sys_msg_log ( mag_log,create_by,create_time ) VALUES "
+
"( '"
+
jsonObject
.
toJSONString
()+
"','"
+
CommonConstant
.
CMCC
+
"','"
+
format
+
"' )"
;
System
.
out
.
println
(
"**********"
+
sql
);
boolean
ok
=
addDataToDataBase
(
sql
);
return
ok
;
...
...
@@ -66,15 +68,15 @@ public class IThirdServiceImpl implements IThirdService {
return
ok
;
}
private
void
changCoordinate
(
ThirdPosition
thirdPosition
)
{
//B1定位坐标
private
void
changCoordinateB1
(
ThirdPosition
thirdPosition
)
{
// String x1 = "101.1636962890625";
// String y1 = "325.2133483886719";
String
x1
=
thirdPosition
.
getPositionx
();
String
y1
=
thirdPosition
.
getPositiony
();
double
blc
=
100
/
2.54
;
//比例尺
double
fd_x
=
blc
*(
Double
.
valueOf
(
x1
)-
CommonConstant
.
LT_B1_X
)+
CommonConstant
.
LT_B1_X
;
double
fd_y
=
blc
*(
Double
.
valueOf
(
y1
)+
CommonConstant
.
LT_B1_Y
)-
CommonConstant
.
LT_B1_Y
;
double
fd_x
=
CommonConstant
.
BLC1
*(
Double
.
valueOf
(
x1
)-
CommonConstant
.
LT_B1_X
)+
CommonConstant
.
LT_B1_X
;
double
fd_y
=
CommonConstant
.
BLC1
*(
Double
.
valueOf
(
y1
)+
CommonConstant
.
LT_B1_Y
)-
CommonConstant
.
LT_B1_Y
;
System
.
out
.
println
(
"放大后的坐标为:X:"
+
fd_x
+
",Y:"
+
fd_y
);
double
a
=
CommonConstant
.
MQ_B1_X
-
CommonConstant
.
LT_B1_X
;
//原点偏移x
...
...
@@ -94,14 +96,37 @@ public class IThirdServiceImpl implements IThirdService {
addPositionInfo
(
thirdPosition
);
//添加转换后坐标信息
}
//B2定位坐标
private
void
changCoordinateB2
(
ThirdPosition
thirdPosition
)
{
String
x1
=
thirdPosition
.
getPositionx
();
String
y1
=
thirdPosition
.
getPositiony
();
double
fd_x
=
CommonConstant
.
BLC2
*(
Double
.
valueOf
(
x1
)-
CommonConstant
.
LT_B2_X
)+
CommonConstant
.
LT_B2_X
;
double
fd_y
=
CommonConstant
.
BLC2
*(
Double
.
valueOf
(
y1
)+
CommonConstant
.
LT_B2_Y
)-
CommonConstant
.
LT_B2_Y
;
System
.
out
.
println
(
"放大后的坐标为:X:"
+
fd_x
+
",Y:"
+
fd_y
);
double
a
=
CommonConstant
.
MQ_B2_X
-
CommonConstant
.
LT_B2_X
;
//原点偏移x
double
b
=
CommonConstant
.
MQ_B2_Y
-
CommonConstant
.
LT_B2_Y
;
//原点偏移y
System
.
out
.
println
(
"偏移a:"
+
a
+
",b:"
+
b
);
double
x
=
Double
.
valueOf
(
fd_x
)
+
a
;
double
y
=
Double
.
valueOf
(
fd_y
)
+
b
;
System
.
out
.
println
(
"新坐标为:X:"
+
x
+
",Y:-"
+
y
);
thirdPosition
.
setPositionx
(
String
.
valueOf
(
x
));
thirdPosition
.
setPositiony
(
String
.
valueOf
(
y
));
addPositionInfo
(
thirdPosition
);
//添加转换后坐标信息
}
private
boolean
addPositionInfo
(
ThirdPosition
thirdPosition
)
{
String
uuid
=
UUIDGenerator
.
creatUUID
();
String
sql
=
"INSERT INTO sys_cmcc_position ( `position_id`,`node_id`,`system_id`,`type`,`group`,"
+
"`group_number`,`position_x`,`position_y`,`create_by`,`create_time` ) VALUES "
+
" ( '"
+
uuid
+
"','"
+
thirdPosition
.
getNodeId
()+
"','"
+
thirdPosition
.
getSystemId
()+
"','"
+
thirdPosition
.
getType
()+
"','"
+
thirdPosition
.
getGroup
()+
"',"
+
""
+
thirdPosition
.
getGroupNumber
()+
",'"
+
thirdPosition
.
getPositionx
()+
"','"
+
thirdPosition
.
getPositiony
()+
"','
cmcc
','"
+
sf
.
format
(
thirdPosition
.
getCreateTime
())+
"' )"
;
""
+
thirdPosition
.
getGroupNumber
()+
",'"
+
thirdPosition
.
getPositionx
()+
"','"
+
thirdPosition
.
getPositiony
()+
"','
"
+
CommonConstant
.
CMCC
+
"
','"
+
sf
.
format
(
thirdPosition
.
getCreateTime
())+
"' )"
;
System
.
out
.
println
(
"**********"
+
sql
);
boolean
ok
=
addDataToDataBase
(
sql
);
return
ok
;
}
}
...
...
src/main/java/com/
it/entity
/CommonConstant.java
→
src/main/java/com/
jkdata/tool
/CommonConstant.java
查看文件 @
a24316b
package
com
.
it
.
entity
;
package
com
.
jkdata
.
tool
;
public
interface
CommonConstant
{
Integer
SC_ERROR_500
=
500
;
Integer
SC_OK_200
=
200
;
//**********************返回参数代码***************************
Integer
SC_ERROR_500
=
500
;
//错误代码
Integer
SC_OK_200
=
200
;
//成功代码
//**********************联通中心坐标***************************
Double
LT_B1_X
=
379.2256164550781
;
//联通B1层X坐标
...
...
@@ -16,4 +18,11 @@ public interface CommonConstant {
Double
MQ_B2_X
=
-
178.527924
;
//鸣启B2层X坐标
Double
MQ_B2_Y
=
-
1226.708374
;
//鸣启B2层Y坐标
//**********************比例尺***************************
Double
BLC1
=
100
/
2.54
;
//比例尺
Double
BLC2
=
100
/
2.54
;
//比例尺
//**********************推送用户***************************
String
CMCC
=
"CMCC"
;
//联通推送用户
}
...
...
src/main/java/com/
it
/tool/RedisUtil.java
→
src/main/java/com/
jkdata
/tool/RedisUtil.java
查看文件 @
a24316b
package
com
.
it
.
tool
;
package
com
.
jkdata
.
tool
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
...
...
src/main/java/com/
it/entity
/Result.java
→
src/main/java/com/
jkdata/tool
/Result.java
查看文件 @
a24316b
package
com
.
it
.
entity
;
package
com
.
jkdata
.
tool
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
src/main/java/com/
it
/tool/UUIDGenerator.java
→
src/main/java/com/
jkdata
/tool/UUIDGenerator.java
查看文件 @
a24316b
package
com
.
it
.
tool
;
package
com
.
jkdata
.
tool
;
import
java.net.InetAddress
;
import
java.util.UUID
;
...
...
src/main/resources/application.yml
查看文件 @
a24316b
...
...
@@ -14,7 +14,7 @@ spring:
# host: redis
mybatis-plus
:
mapper-locations
:
classpath*:com/
it
/mapper/xml/*Mapper.xml
mapper-locations
:
classpath*:com/
jkdata
/mapper/xml/*Mapper.xml
global-config
:
db-config
:
#使用数据库的自增策略
...
...
src/test/java/com/
it
/SkApplicationTests.java
→
src/test/java/com/
jkdata
/SkApplicationTests.java
查看文件 @
a24316b
package
com
.
it
;
package
com
.
jkdata
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论