a24316bc 张雷

修改包名及结构

1 个父辈 58106dbe
正在显示 16 个修改的文件 包含 83 行增加46 行删除
......@@ -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>
......
package com.it;
package com.jkdata;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
......
package com.it.config;
package com.jkdata.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
......
package com.it.config;
package com.jkdata.config;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
......
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);
......
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 {
......
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;
......
<?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}
......
package com.it.service;
package com.jkdata.service;
import com.alibaba.fastjson.JSONObject;
......
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;
}
}
......
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";//联通推送用户
}
......
package com.it.tool;
package com.jkdata.tool;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
......
package com.it.entity;
package com.jkdata.tool;
import io.swagger.annotations.ApiModelProperty;
......
package com.it.tool;
package com.jkdata.tool;
import java.net.InetAddress;
import java.util.UUID;
......
......@@ -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:
#使用数据库的自增策略
......
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!