1、增加SIM卡流量查询
2、增加基站数据推送到ntrip server
This commit is contained in:
parent
00634964fe
commit
8f7e425c96
@ -66,4 +66,6 @@ public class GnssDevice {
|
|||||||
// 日志记录控制
|
// 日志记录控制
|
||||||
private Short loggingmode;
|
private Short loggingmode;
|
||||||
private String remark;
|
private String remark;
|
||||||
|
private String iccid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
51
sec-api/src/main/java/com/imdroid/secapi/dto/SimCard.java
Normal file
51
sec-api/src/main/java/com/imdroid/secapi/dto/SimCard.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package com.imdroid.secapi.dto;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "simcards")
|
||||||
|
public class SimCard {
|
||||||
|
public static final int STATUS_UNKNOWN = -1; // 未知
|
||||||
|
public static final int STATUS_WAIT_ACTIVE = 1; // 待激活
|
||||||
|
public static final int STATUS_ACTIVATED = 2; // 已激活
|
||||||
|
public static final int STATUS_SUSPENDED = 3; // 停机
|
||||||
|
public static final int STATUS_CANCELLED = 4; // 注销
|
||||||
|
public static final int STATUS_IN_STOCK = 5; // 库存
|
||||||
|
public static final int STATUS_TESTABLE = 6; // 可测试
|
||||||
|
public static final int STATUS_INVALID = 7; // 失效
|
||||||
|
public static final int STATUS_NOT_EXIST = 99; // 号码不存在
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
@ExcelProperty("ID")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ExcelProperty("更新时间")
|
||||||
|
private Date updatetime;
|
||||||
|
|
||||||
|
@ExcelProperty("ICCID")
|
||||||
|
private String iccid;
|
||||||
|
|
||||||
|
@ExcelProperty("物联卡号码")
|
||||||
|
private String msisdn;
|
||||||
|
|
||||||
|
@ExcelProperty("设备ID")
|
||||||
|
private String deviceid;
|
||||||
|
|
||||||
|
@ExcelProperty("状态")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ExcelProperty("剩余流量(MB)")
|
||||||
|
private BigDecimal remaining;
|
||||||
|
|
||||||
|
@ExcelProperty("总流量(MB)")
|
||||||
|
private BigDecimal total;
|
||||||
|
|
||||||
|
@ExcelProperty("已用流量(MB)")
|
||||||
|
private BigDecimal used;
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.imdroid.secapi.dto;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface SimCardsMapper extends MPJBaseMapper<SimCard>{
|
||||||
|
@Select({"select * from simcards where deviceid = #{deviceId} limit 1"})
|
||||||
|
SimCard queryByDeviceId(String deviceId);
|
||||||
|
|
||||||
|
@Select("select * from simcards where iccid = #{iccid} limit 1")
|
||||||
|
SimCard queryByIccid(String iccid);
|
||||||
|
|
||||||
|
@Update("UPDATE simcards SET " +
|
||||||
|
"updatetime = #{updatetime}, " +
|
||||||
|
"msisdn = #{msisdn}, " +
|
||||||
|
"status = #{status}, " +
|
||||||
|
"remaining = #{remaining}, " +
|
||||||
|
"total = #{total}, " +
|
||||||
|
"used = #{used} " +
|
||||||
|
"WHERE deviceid = #{deviceid}")
|
||||||
|
int updateSimCardInfo(SimCard simCard);
|
||||||
|
|
||||||
|
@Update("UPDATE simcards SET " +
|
||||||
|
"updatetime = #{updatetime}, " +
|
||||||
|
"remaining = #{remaining}, " +
|
||||||
|
"total = #{total}, " +
|
||||||
|
"used = #{used} " +
|
||||||
|
"WHERE deviceid = #{deviceid}")
|
||||||
|
int updateFlowInfo(SimCard simCard);
|
||||||
|
|
||||||
|
@Update("UPDATE simcards SET " +
|
||||||
|
"updatetime = #{updatetime}, " +
|
||||||
|
"status = #{status} " +
|
||||||
|
"WHERE deviceid = #{deviceid}")
|
||||||
|
int updateStatus(SimCard simCard);
|
||||||
|
}
|
||||||
|
|
||||||
@ -8,6 +8,7 @@ spring.jpa.show-sql = true
|
|||||||
spring.jpa.hibernate.ddl-auto = none
|
spring.jpa.hibernate.ddl-auto = none
|
||||||
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
|
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
|
||||||
spring.datasource.url = jdbc:mysql://localhost:3306/beidou?characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
spring.datasource.url = jdbc:mysql://localhost:3306/beidou?characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
|
#spring.datasource.url=jdbc:mysql://139.9.51.237:3306/beidou?characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||||
spring.datasource.username = admin
|
spring.datasource.username = admin
|
||||||
spring.datasource.password = DBMgr_2022
|
spring.datasource.password = DBMgr_2022
|
||||||
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
|
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
|
||||||
@ -29,6 +30,9 @@ xfz.server.port = 31035
|
|||||||
gxlj.server.host = 222.216.2.131
|
gxlj.server.host = 222.216.2.131
|
||||||
gxlj.server.port = 895
|
gxlj.server.port = 895
|
||||||
|
|
||||||
|
gzb.server.host = 58.49.25.171
|
||||||
|
gzb.server.port = 3011
|
||||||
|
|
||||||
#gzy.server.host = 8.134.84.223
|
#gzy.server.host = 8.134.84.223
|
||||||
#gzy.server.port = 8088
|
#gzy.server.port = 8088
|
||||||
gzy.server.host = 127.0.0.1
|
gzy.server.host = 127.0.0.1
|
||||||
@ -46,4 +50,13 @@ kingma.server.login_host = https://www.everiaction.com/IOT-ADAPTER-CUSTOM/auth/a
|
|||||||
kingma.server.data_host = https://www.everiaction.com/IOT-DATA-GATHER/receive/data/formula
|
kingma.server.data_host = https://www.everiaction.com/IOT-DATA-GATHER/receive/data/formula
|
||||||
|
|
||||||
zny.server.host = http://119.3.203.174:8080/cs-detection-1.2/bsn/xyz/addDefo
|
zny.server.host = http://119.3.203.174:8080/cs-detection-1.2/bsn/xyz/addDefo
|
||||||
zny.server.host2 = http://119.3.203.174:8080/cs-detection-2.0/bsn/xyz/addDefo
|
zny.server.host2 = http://119.3.203.174:8080/cs-detection-2.0/bsn/xyz/addDefo
|
||||||
|
|
||||||
|
gxjk.mqtt.server.brokerUrl = tcp://111.59.245.231:5220
|
||||||
|
gxjk.mqtt.server.username = slopeUser01
|
||||||
|
gxjk.mqtt.server.password = Slope#pd23@1201
|
||||||
|
gxjk.mqtt.server.clientid = GXJK_client
|
||||||
|
|
||||||
|
sass.server.host = 127.0.0.1
|
||||||
|
sass.server.port = 9933
|
||||||
|
sass.server.enabled = false
|
||||||
@ -15,7 +15,7 @@ import static com.imdroid.sideslope.bd.GeoCoordConverterUtil.*;
|
|||||||
*/
|
*/
|
||||||
public class FocusCalculator3 extends FocusCalculator1{
|
public class FocusCalculator3 extends FocusCalculator1{
|
||||||
//final static long scale = 100000000L;//地球1°:111km,放大到mm乘以100,000,000
|
//final static long scale = 100000000L;//地球1°:111km,放大到mm乘以100,000,000
|
||||||
final static int bad_change_mm = 500;//固定解跳变连续10次超过500mm,认为是周跳
|
final static int bad_change_mm = 300;//固定解跳变连续10次超过500mm,认为是周跳
|
||||||
final static int bad_duration = 10;
|
final static int bad_duration = 10;
|
||||||
|
|
||||||
int bad_count = 0;
|
int bad_count = 0;
|
||||||
|
|||||||
@ -5,6 +5,9 @@ import com.imdroid.common.util.ByteUtil;
|
|||||||
import com.imdroid.common.util.StringUtil;
|
import com.imdroid.common.util.StringUtil;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static java.lang.Math.*;
|
import static java.lang.Math.*;
|
||||||
|
|
||||||
@ -13,6 +16,110 @@ public class RtcmGgaUtil {
|
|||||||
//gga样本:*后面跟的是校验和,其中76代表校验和,对$和*之间的数据(不包括这两个字符)按字节进行异或运算(二进制)的结果
|
//gga样本:*后面跟的是校验和,其中76代表校验和,对$和*之间的数据(不包括这两个字符)按字节进行异或运算(二进制)的结果
|
||||||
private static final String ggaExample = "$GNGGA,020850.50,2258.10508,N,11317.67958,E,4,12,0.74,3.9,M,-5.4,M,1.3,0000*76";
|
private static final String ggaExample = "$GNGGA,020850.50,2258.10508,N,11317.67958,E,4,12,0.74,3.9,M,-5.4,M,1.3,0000*76";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取多条rtcm
|
||||||
|
* 因为存在d331...rtcm...d331...rtcm..这样的数据
|
||||||
|
* 还存在d331...rtcm rtcm rtcm...这样的数据
|
||||||
|
* @param hex
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<String> getRtcms(String hex){
|
||||||
|
return splitStartWith(hex,"d300","d301","d302").stream()
|
||||||
|
.map(com.imdroid.sideslope.bd.RtcmGgaUtil::getRtcm)
|
||||||
|
.filter(s -> s != null && !s.isEmpty())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取一条rtcm
|
||||||
|
* @param hex
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getRtcm(String hex){
|
||||||
|
try {
|
||||||
|
int index = getIndex(hex,"d300","d301","d302");
|
||||||
|
if (index != -1 && index < hex.length()-6) {
|
||||||
|
//d300数据长度
|
||||||
|
int length = Integer.parseInt(hex.substring(index + 3, index + 6), 16);
|
||||||
|
if(index + (3+length +3)*2 <= hex.length()){
|
||||||
|
return hex.substring(index, index + (3 + length + 3) * 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getIndex(String... regex){
|
||||||
|
for (int i = 1; i < regex.length; i++) {
|
||||||
|
if(regex[0].contains(regex[i])){
|
||||||
|
return regex[0].indexOf(regex[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按前缀切割分段
|
||||||
|
* @param regex 第一个是要处理的数据,其他是要检测的前缀
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<String> splitStartWith(String... regex){
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
try{
|
||||||
|
List<Integer> indexs = getIndexs(regex);
|
||||||
|
int start = 0;
|
||||||
|
for (int i = 0; i < indexs.size(); i++) {
|
||||||
|
if(indexs.get(i) != 0){
|
||||||
|
list.add(regex[0].substring(start,indexs.get(i)));
|
||||||
|
start = indexs.get(i);
|
||||||
|
}
|
||||||
|
if(i == indexs.size() -1){
|
||||||
|
list.add(regex[0].substring(indexs.get(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按多个规则搜索索引
|
||||||
|
* @param regex
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<Integer> getIndexs(String... regex){
|
||||||
|
List<Integer> list =new ArrayList<>();
|
||||||
|
for (int i = 1; i < regex.length; i++) {
|
||||||
|
list.addAll(findAllIndex(regex[0],0,regex[i]));
|
||||||
|
}
|
||||||
|
list.sort((o1, o2) -> o1-o2);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按规则搜索所有索引
|
||||||
|
* @param string
|
||||||
|
* @param index
|
||||||
|
* @param findStr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<Integer> findAllIndex(String string, int index, String findStr){
|
||||||
|
List<Integer> list =new ArrayList<>();
|
||||||
|
int num = string.indexOf(findStr,index);
|
||||||
|
if(num != -1){
|
||||||
|
list.add(num);
|
||||||
|
//递归进行查找
|
||||||
|
List myList = findAllIndex(string,num+1,findStr);
|
||||||
|
list.addAll(myList);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取rtcm数据类型
|
* 获取rtcm数据类型
|
||||||
* @param bytes
|
* @param bytes
|
||||||
|
|||||||
@ -172,8 +172,6 @@ public class SingleLineGNSSCalcService implements GNSSDataCalcService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,13 +4,17 @@ import com.imdroid.common.util.DataTypeUtil;
|
|||||||
import com.imdroid.common.util.ThreadManager;
|
import com.imdroid.common.util.ThreadManager;
|
||||||
import com.imdroid.secapi.client.BeidouClient;
|
import com.imdroid.secapi.client.BeidouClient;
|
||||||
import com.imdroid.secapi.dto.GnssDevice;
|
import com.imdroid.secapi.dto.GnssDevice;
|
||||||
|
import com.imdroid.common.util.ByteUtil;
|
||||||
import com.imdroid.sideslope.bd.Gga;
|
import com.imdroid.sideslope.bd.Gga;
|
||||||
import com.imdroid.sideslope.message.D331RtcmMessage;
|
import com.imdroid.sideslope.message.D331RtcmMessage;
|
||||||
|
import com.imdroid.sideslope.ntrip.UdpNtripServer;
|
||||||
import com.imdroid.sideslope.sal.Device;
|
import com.imdroid.sideslope.sal.Device;
|
||||||
import com.imdroid.sideslope.sal.DeviceService;
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
import com.imdroid.sideslope.server.DeviceChannel;
|
import com.imdroid.sideslope.server.DeviceChannel;
|
||||||
import com.imdroid.sideslope.server.OnlineChannels;
|
import com.imdroid.sideslope.server.OnlineChannels;
|
||||||
import com.imdroid.sideslope.service.DataPersistService;
|
import com.imdroid.sideslope.service.DataPersistService;
|
||||||
|
import com.imdroid.sideslope.bd.RtcmGgaUtil;
|
||||||
|
//import com.imdroid.common.util.RtcmGgaUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -21,6 +25,8 @@ import org.springframework.stereotype.Component;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Layton
|
* @author Layton
|
||||||
@ -37,6 +43,9 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
private BeidouClient beidouClient;
|
private BeidouClient beidouClient;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataPersistService dataPersistService;
|
private DataPersistService dataPersistService;
|
||||||
|
@Autowired
|
||||||
|
UdpNtripServer ntripServer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void execute(D331RtcmMessage message) {
|
public Void execute(D331RtcmMessage message) {
|
||||||
String id = message.getId();
|
String id = message.getId();
|
||||||
@ -115,13 +124,16 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
Gga gga = message.getGga();
|
Gga gga = message.getGga();
|
||||||
if(gga != null) {
|
if(gga != null) {
|
||||||
deviceBs.updateSatelitesNum(gga.getSatellitesInUsed());
|
deviceBs.updateSatelitesNum(gga.getSatellitesInUsed());
|
||||||
//if(gga.isFixed()) { //基站的quality不会是4
|
deviceBs.setLatitude(gga.getLatitude());
|
||||||
deviceBs.setLatitude(gga.getLatitude());
|
deviceBs.setLongitude(gga.getLongitude());
|
||||||
deviceBs.setLongitude(gga.getLongitude());
|
deviceBs.setAltitude(gga.getAltitude());
|
||||||
deviceBs.setAltitude(gga.getAltitude());
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加NTRIP处理
|
||||||
|
byte[] srcdata = message.getSrcData();
|
||||||
|
String rtcm = ByteUtil.bytesToHexString(srcdata);
|
||||||
|
sendToNtrip(id, rtcm);
|
||||||
|
|
||||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||||
// 原始码流输出到日志文件 -- INFO 级别
|
// 原始码流输出到日志文件 -- INFO 级别
|
||||||
// 只有测站开了日志记录,或者消息来自基站,才将原码记录到日志文件
|
// 只有测站开了日志记录,或者消息来自基站,才将原码记录到日志文件
|
||||||
@ -133,6 +145,25 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendToNtrip(String mountpoint, String hexData) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
// 将原始字节转换为16进制字符串用于RTCM提取
|
||||||
|
//String hexData = ByteUtil.bytesToHexString(rawData);
|
||||||
|
//System.out.println(hexData);
|
||||||
|
|
||||||
|
// 提取RTCM数据并发送到NtripServer,使用设备ID作为挂载点
|
||||||
|
Optional.ofNullable(RtcmGgaUtil.getRtcms(hexData))
|
||||||
|
.ifPresent(rtcm -> {
|
||||||
|
//System.out.println("挂载点: " + mountpoint);
|
||||||
|
//System.out.println("RTCM数据: " + rtcm);
|
||||||
|
ntripServer.send(mountpoint, rtcm);
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("处理NTRIP数据失败, 挂载点: {}, 错误: {}", mountpoint, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getMessageType() {
|
public Class<?> getMessageType() {
|
||||||
return D331RtcmMessage.class;
|
return D331RtcmMessage.class;
|
||||||
|
|||||||
@ -41,6 +41,8 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DataPersistService dataPersistService;
|
private DataPersistService dataPersistService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private GnssDeviceMapper gnssDeviceMapper;
|
||||||
|
@Autowired
|
||||||
GnssMsgMapper msgMapper;
|
GnssMsgMapper msgMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -66,6 +68,8 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
device.updateRx(message.getHeader(),message.getLen(),1);
|
device.updateRx(message.getHeader(),message.getLen(),1);
|
||||||
|
|
||||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||||
|
// 检查是否需要更新设备的 ICCID
|
||||||
|
checkAndAskICCID(device);
|
||||||
// 检查是否需要对设备的F9P进行冷启动操作
|
// 检查是否需要对设备的F9P进行冷启动操作
|
||||||
if(device.getDeviceType() == Device.DEVICE_ROVER){
|
if(device.getDeviceType() == Device.DEVICE_ROVER){
|
||||||
if(device.getModel() == GnssDevice.MODEL_G505){
|
if(device.getModel() == GnssDevice.MODEL_G505){
|
||||||
@ -179,6 +183,28 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
rtcmClient.config(device.getDeviceId(), sendCmd);
|
rtcmClient.config(device.getDeviceId(), sendCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkAndAskICCID(Device device){
|
||||||
|
// 如果设备的 ICCID 存在,那么就不用发送 "AT+ICCID" 指令
|
||||||
|
|
||||||
|
if(device.getIccid() != null && !device.getIccid().trim().isEmpty()){
|
||||||
|
GnssDevice gnssDevice = gnssDeviceMapper.queryByDeviceId(device.getDeviceId());
|
||||||
|
if(gnssDevice.getIccid() != null && !gnssDevice.getIccid().trim().isEmpty()){
|
||||||
|
// 状态和流量查询更新需要 1-2 小时,期间 DataPersistService 更新可能不及时
|
||||||
|
// 若是数据库的设备已经更新了 iccid 号,将它同步到 DataPersistService 缓存中
|
||||||
|
device.setIccid(gnssDevice.getIccid());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String sendCmd = "AT+ICCID";
|
||||||
|
int msgType = 0xD310 + 10; // DTU
|
||||||
|
short len = (short) (sendCmd.length() + 5);
|
||||||
|
sendCmd = Integer.toHexString(msgType) + HexUtil.Short2HexString(len)+
|
||||||
|
HexUtil.Int2HexString(Integer.parseInt(device.getDeviceId()))+
|
||||||
|
"01"+HexUtil.String2HexString(sendCmd);
|
||||||
|
rtcmClient.config(device.getDeviceId(),sendCmd);
|
||||||
|
// TODO: 将这个消息写到 msg 表中
|
||||||
|
logger.info(sendCmd);
|
||||||
|
}
|
||||||
private void checkAndResetBTGnss(Device device){
|
private void checkAndResetBTGnss(Device device){
|
||||||
if(device.getNoFixedAndFloatResult()>0 &&device.getAbnormalD341Num()>10){
|
if(device.getNoFixedAndFloatResult()>0 &&device.getAbnormalD341Num()>10){
|
||||||
if(isBaseStationFwd(device)) startBTResetTask(device);
|
if(isBaseStationFwd(device)) startBTResetTask(device);
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
package com.imdroid.sideslope.ntrip;
|
||||||
|
|
||||||
|
import com.imdroid.common.util.HttpUtils;
|
||||||
|
import com.imdroid.common.util.ThreadManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
/**
|
||||||
|
* @author likongyong
|
||||||
|
* @date 2023/10/19 11:49
|
||||||
|
*/
|
||||||
|
public class HttpNtripServer {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(HttpNtripServer.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改挂载点获取xingyu差分的gga
|
||||||
|
* @param mount
|
||||||
|
* @param gga
|
||||||
|
*/
|
||||||
|
public static void sendGGA(String mount, String gga){
|
||||||
|
ThreadManager.getSingleThreadPool(HttpNtripServer.class.getName()).execute(()->{
|
||||||
|
try{
|
||||||
|
String url = "http://localhost:11001/ntrip/sendGGA/" + mount + "/" + gga;
|
||||||
|
String result = HttpUtils.getUrl(url);
|
||||||
|
logger.debug("{} send gga {} {}",mount, gga, result);
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
package com.imdroid.sideslope.ntrip;
|
||||||
|
|
||||||
|
import com.imdroid.common.util.ByteUtil;
|
||||||
|
import com.imdroid.common.util.ThreadManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.net.DatagramPacket;
|
||||||
|
import java.net.DatagramSocket;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本地udp发送差分数据到ntrip-forward-server项目
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UdpNtripServer {
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(UdpNtripServer.class);
|
||||||
|
@Value("${ntrip_server.port:9903}")
|
||||||
|
private Integer port;
|
||||||
|
private DatagramSocket socket;
|
||||||
|
private DatagramPacket outPacket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向某挂载点提供差分信息
|
||||||
|
* @param mount 挂载点名称
|
||||||
|
* @param hexRtcm 差分信息16进制字符串
|
||||||
|
*/
|
||||||
|
public void send(String mount, String hexRtcm){
|
||||||
|
ThreadManager.getSingleThreadPool(UdpNtripServer.class.getName()).execute(()->{
|
||||||
|
try{
|
||||||
|
//随机端口
|
||||||
|
if(socket == null) socket = new DatagramSocket();
|
||||||
|
if(outPacket == null) outPacket = new DatagramPacket(new byte[0],0, InetAddress.getByName("localhost"),port);
|
||||||
|
outPacket.setData(encode(ByteUtil.addBytes(mount.getBytes(), ByteUtil.hexStringTobyte(hexRtcm))));
|
||||||
|
socket.send(outPacket);
|
||||||
|
}catch (Exception e){
|
||||||
|
socket = null;
|
||||||
|
outPacket = null;
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向某挂载点提供差分信息
|
||||||
|
* @param mount 挂载点名称
|
||||||
|
* @param hexRtcm 差分信息16进制字符串
|
||||||
|
*/
|
||||||
|
public void send(String mount, List<String> hexRtcm){
|
||||||
|
logger.debug(mount + ":" + hexRtcm.size());
|
||||||
|
for (String s : hexRtcm) {
|
||||||
|
send(mount,s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//加入校验位,用于校验数据是否完整
|
||||||
|
private byte[] encode(byte[] bytes) {
|
||||||
|
byte[] bytes1 = new byte[bytes.length + 1];
|
||||||
|
//校验位
|
||||||
|
byte b = bytes[0];
|
||||||
|
bytes1[0] = bytes[0];
|
||||||
|
for (int i = 1; i < bytes.length; i++) {
|
||||||
|
b ^= bytes[i];
|
||||||
|
bytes1[i] = bytes[i];
|
||||||
|
}
|
||||||
|
bytes1[bytes1.length - 1] = b;
|
||||||
|
return bytes1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -44,6 +44,7 @@ public class DbDeviceServiceImpl implements DeviceService {
|
|||||||
device.setEcefy(gnssDevice.getEcefy());
|
device.setEcefy(gnssDevice.getEcefy());
|
||||||
device.setEcefz(gnssDevice.getEcefz());
|
device.setEcefz(gnssDevice.getEcefz());
|
||||||
device.setLoggingmode(gnssDevice.getLoggingmode());
|
device.setLoggingmode(gnssDevice.getLoggingmode());
|
||||||
|
device.setIccid(gnssDevice.getIccid());
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import com.imdroid.sideslope.bd.Gga;
|
|||||||
import com.imdroid.sideslope.bd.UBXUtil;
|
import com.imdroid.sideslope.bd.UBXUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,6 +68,11 @@ public class Device {
|
|||||||
Double iPosn;
|
Double iPosn;
|
||||||
Double iPosd;
|
Double iPosd;
|
||||||
|
|
||||||
|
String iccid;
|
||||||
|
private BigDecimal remaining;
|
||||||
|
private BigDecimal total;
|
||||||
|
private BigDecimal used;
|
||||||
|
|
||||||
LocalDateTime lastRxTime;
|
LocalDateTime lastRxTime;
|
||||||
LocalDateTime lastD3f2Time;
|
LocalDateTime lastD3f2Time;
|
||||||
short noFixedAndFloatResult=0;
|
short noFixedAndFloatResult=0;
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.imdroid.sideslope.service;
|
||||||
|
|
||||||
|
import com.imdroid.sideslope.sal.Device;
|
||||||
|
import com.imdroid.sideslope.simcard.*;
|
||||||
|
|
||||||
|
public interface SimCardQueryService {
|
||||||
|
|
||||||
|
// 查询卡基本信息
|
||||||
|
BaseResponse<CardInfoData> queryCardInfo(Device device);
|
||||||
|
|
||||||
|
// 查询卡状态
|
||||||
|
BaseResponse<CardStatusData> queryCardStatus(Device device);
|
||||||
|
|
||||||
|
// 查询流量信息
|
||||||
|
BaseResponse<GprsData> queryGprs(Device device);
|
||||||
|
|
||||||
|
// 查询卡详细信息
|
||||||
|
BaseResponse<CardDetailData> queryCardDetail(Device device);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,178 @@
|
|||||||
|
package com.imdroid.sideslope.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.MapperFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.imdroid.secapi.dto.SimCard;
|
||||||
|
import com.imdroid.secapi.dto.SimCardsMapper;
|
||||||
|
import com.imdroid.sideslope.sal.Device;
|
||||||
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
|
import com.imdroid.sideslope.simcard.*;
|
||||||
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SimCardQueryServiceImpl implements SimCardQueryService{
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
@Value("${sim.url}")
|
||||||
|
private String BASE_URL;
|
||||||
|
@Value("${sim.username}")
|
||||||
|
private String USERNAME;
|
||||||
|
@Value("${sim.key}")
|
||||||
|
private String KEY;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SimCardsMapper simCardsMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse<CardInfoData> queryCardInfo(Device device) {
|
||||||
|
return executeQuery(device, "/api/Service/Cardinfo", CardInfoData.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse<CardStatusData> queryCardStatus(Device device) {
|
||||||
|
return executeQuery(device, "/api/Service/QueryCardStatus", CardStatusData.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse<GprsData> queryGprs(Device device) {
|
||||||
|
return executeQuery(device, "/api/Service/QueryGprs", GprsData.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse<CardDetailData> queryCardDetail(Device device) {
|
||||||
|
return executeQuery(device, "/api/Service/QueryCard", CardDetailData.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> BaseResponse<T> executeQuery(Device device, String path, Class<T> responseType) {
|
||||||
|
try {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("username", USERNAME);
|
||||||
|
params.put("key", KEY);
|
||||||
|
params.put("card", device.getIccid());
|
||||||
|
params.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000));
|
||||||
|
|
||||||
|
String signature = calculateSignature(params);
|
||||||
|
params.put("signature", signature);
|
||||||
|
|
||||||
|
logger.info("Request params: {}", params);
|
||||||
|
String response = sendHttpPost(path, params);
|
||||||
|
logger.info("查询响应: 设备={}, ICCID={}, 响应={}",
|
||||||
|
device.getDeviceId(), device.getIccid(), response);
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
|
||||||
|
|
||||||
|
// 特殊处理CardStatus的数组响应
|
||||||
|
if (responseType == CardStatusData.class) {
|
||||||
|
JsonNode root = mapper.readTree(response);
|
||||||
|
if (root.get("Status").asInt() == 1 && root.get("Data").isArray()) {
|
||||||
|
CardStatusData statusData = new CardStatusData();
|
||||||
|
statusData.setStatusCode(root.get("Data").get(0).asInt());
|
||||||
|
statusData.setStatusDesc(root.get("Data").get(1).asText());
|
||||||
|
BaseResponse<CardStatusData> baseResponse = new BaseResponse<>();
|
||||||
|
baseResponse.setStatus(1);
|
||||||
|
baseResponse.setMessage("Success");
|
||||||
|
baseResponse.setData(statusData);
|
||||||
|
return (BaseResponse<T>) baseResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JavaType type = mapper.getTypeFactory().constructParametricType(BaseResponse.class, responseType);
|
||||||
|
return mapper.readValue(response, type);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询失败: 设备={}, 错误={}", device.getDeviceId(), e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String calculateSignature(Map<String, String> params) {
|
||||||
|
try {
|
||||||
|
List<String> paramList = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
paramList.add(entry.getKey() + "=" + entry.getValue());
|
||||||
|
}
|
||||||
|
Collections.sort(paramList);
|
||||||
|
|
||||||
|
String paramString = String.join("&", paramList);
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
byte[] digest = md.digest(paramString.getBytes());
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (byte b : digest) {
|
||||||
|
sb.append(String.format("%02x", b));
|
||||||
|
}
|
||||||
|
String signature = sb.toString();
|
||||||
|
logger.debug("Signature: {}", signature);
|
||||||
|
return signature;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("签名计算失败: {}", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String sendHttpPost(String path, Map<String, String> params) throws Exception {
|
||||||
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
||||||
|
HttpPost httpPost = new HttpPost(BASE_URL + path);
|
||||||
|
|
||||||
|
List<BasicNameValuePair> pairs = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
pairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
httpPost.setEntity(new UrlEncodedFormEntity(pairs));
|
||||||
|
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
|
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
||||||
|
return EntityUtils.toString(response.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasValidIccid(Device device) {
|
||||||
|
return device.getIccid() != null && !device.getIccid().trim().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimCard CreateOrUpdateSimCard(Device device) {
|
||||||
|
SimCard simCard = simCardsMapper.queryByDeviceId(device.getDeviceId());
|
||||||
|
if (simCard == null) {
|
||||||
|
simCard = createNewSimCard(device);
|
||||||
|
}
|
||||||
|
return simCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimCard createNewSimCard(Device device) {
|
||||||
|
SimCard newCard = new SimCard();
|
||||||
|
newCard.setDeviceid(device.getDeviceId());
|
||||||
|
newCard.setUpdatetime(new Date());
|
||||||
|
newCard.setIccid(device.getIccid());
|
||||||
|
newCard.setStatus(-1);
|
||||||
|
newCard.setMsisdn("");
|
||||||
|
newCard.setRemaining(BigDecimal.ZERO);
|
||||||
|
newCard.setUsed(BigDecimal.ZERO);
|
||||||
|
newCard.setTotal(BigDecimal.ZERO);
|
||||||
|
|
||||||
|
simCardsMapper.insert(newCard);
|
||||||
|
return newCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValidResponse(BaseResponse<?> response) {
|
||||||
|
return response != null && response.getStatus() == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -261,7 +261,7 @@ public class WarningServiceImpl implements WarningService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// 检查SIM卡状态
|
// 检查SIM卡状态
|
||||||
public void checkSimCardStatus(Device device, SimCard simCard) {
|
public void checkSimCardStatus(Device device, SimCard simCard) {
|
||||||
GnssStatus status = gnssStatusMapper.getByDeviceId(device.getDeviceId());
|
GnssStatus status = gnssStatusMapper.getByDeviceId(device.getDeviceId());
|
||||||
@ -334,7 +334,7 @@ public class WarningServiceImpl implements WarningService {
|
|||||||
gnssStatusMapper.updateById(status);
|
gnssStatusMapper.updateById(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
public void generate_warning_logs(String device_id,int warning_type,String warning_type_name){
|
public void generate_warning_logs(String device_id,int warning_type,String warning_type_name){
|
||||||
// 连续无固定解 和 掉电 警告
|
// 连续无固定解 和 掉电 警告
|
||||||
if (warning_type == WarningCfg.TYPE_NO_FIXED_RESULT || warning_type == WarningCfg.TYPE_LOW_VOLTAGE) {
|
if (warning_type == WarningCfg.TYPE_NO_FIXED_RESULT || warning_type == WarningCfg.TYPE_LOW_VOLTAGE) {
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.imdroid.sideslope.simcard;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BaseResponse<T> {
|
||||||
|
private Integer status;
|
||||||
|
private String message;
|
||||||
|
private T data;
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package com.imdroid.sideslope.simcard;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CardDetailData {
|
||||||
|
private Integer operatortype;
|
||||||
|
private String activetime;
|
||||||
|
private String starttime;
|
||||||
|
private String stoptime;
|
||||||
|
private String silentdate;
|
||||||
|
private Integer status;
|
||||||
|
private String msisdn;
|
||||||
|
private String iccid;
|
||||||
|
private String imsi;
|
||||||
|
private Integer packageid;
|
||||||
|
private String packagename;
|
||||||
|
private String net;
|
||||||
|
|
||||||
|
private GprsInfo gprs;
|
||||||
|
private ApnInfo apn;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class GprsInfo {
|
||||||
|
private Double total;
|
||||||
|
private Double used;
|
||||||
|
private Double left;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ApnInfo {
|
||||||
|
private String apnid;
|
||||||
|
private String status;
|
||||||
|
private String ip;
|
||||||
|
private String rat;
|
||||||
|
private String onoffstatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.imdroid.sideslope.simcard;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CardInfoData {
|
||||||
|
private String imsi;
|
||||||
|
private String msisdn;
|
||||||
|
private String iccid;
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.imdroid.sideslope.simcard;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CardStatusData {
|
||||||
|
private Integer statusCode;
|
||||||
|
private String statusDesc;
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.imdroid.sideslope.simcard;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GprsData {
|
||||||
|
private Integer operatortype;
|
||||||
|
private List<GprsUsage> gps;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class GprsUsage {
|
||||||
|
private Double left;
|
||||||
|
private Double total;
|
||||||
|
private Double used;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回数据格式
|
||||||
|
// {
|
||||||
|
// "Status": 1,
|
||||||
|
// "Message": "Success",
|
||||||
|
// "Data": {
|
||||||
|
// "operatortype": 1,
|
||||||
|
// "GPS": [
|
||||||
|
// {
|
||||||
|
// "Left": "2023",
|
||||||
|
// "Total": "2.0",
|
||||||
|
// "Used": "25"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public GprsUsage getFirstGprsUsage() {
|
||||||
|
if (gps != null && !gps.isEmpty()) {
|
||||||
|
return gps.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,207 @@
|
|||||||
|
package com.imdroid.sideslope.task;
|
||||||
|
|
||||||
|
import com.alibaba.excel.util.StringUtils;
|
||||||
|
import com.imdroid.common.util.ThreadManager;
|
||||||
|
import com.imdroid.secapi.dto.*;
|
||||||
|
import com.imdroid.sideslope.sal.Device;
|
||||||
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
|
import com.imdroid.sideslope.service.SimCardQueryServiceImpl;
|
||||||
|
import com.imdroid.sideslope.service.WarningServiceImpl;
|
||||||
|
import com.imdroid.sideslope.simcard.BaseResponse;
|
||||||
|
import com.imdroid.sideslope.simcard.CardInfoData;
|
||||||
|
import com.imdroid.sideslope.simcard.CardStatusData;
|
||||||
|
import com.imdroid.sideslope.simcard.GprsData;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
@EnableScheduling
|
||||||
|
public class SimStatusChecker {
|
||||||
|
// SIM 卡流量和状态查询定时任务
|
||||||
|
// 1. 每小时任务
|
||||||
|
// a. 通过CardInfo 检查 iccid 和 sim卡号
|
||||||
|
// b. 通过QueryCardStatus 检查SIM卡当前的状态
|
||||||
|
// 2. 每两小时任务
|
||||||
|
// a. QueryGprs 检查 SIM 流量
|
||||||
|
final Logger logger = LoggerFactory.getLogger(SimStatusChecker.class);
|
||||||
|
@Autowired
|
||||||
|
private GnssStatusMapper gnssStatusMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WarningServiceImpl warningService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SimCardsMapper simCardsMapper;
|
||||||
|
@Resource(name = "local")
|
||||||
|
private DeviceService deviceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SimCardQueryServiceImpl simCardQueryServiceImpl;
|
||||||
|
|
||||||
|
// 每小时执行一次状态检查调度
|
||||||
|
@Scheduled(cron = "0 0 * * * ?")
|
||||||
|
//@Scheduled(cron = "0 */10 * * * ?")
|
||||||
|
private void scheduleSimCardStatusCheck() {
|
||||||
|
List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline();
|
||||||
|
logger.info("当前在线设备数量: {}", onlineDevices.size());
|
||||||
|
|
||||||
|
for (GnssStatusJoin onlineDevice : onlineDevices) {
|
||||||
|
int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 3600 );
|
||||||
|
logger.info("- 设备: {}, SIM状态查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||||
|
|
||||||
|
ThreadManager.getScheduledThreadPool().schedule(
|
||||||
|
() -> checkDeviceSimCardStatus(onlineDevice.getDeviceid()),
|
||||||
|
delay,
|
||||||
|
TimeUnit.SECONDS
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 每两小时执行一次流量检查调度
|
||||||
|
@Scheduled(cron = "0 0 0/2 * * ?")
|
||||||
|
private void scheduleSimCardTrafficCheck() {
|
||||||
|
List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline();
|
||||||
|
logger.info("当前在线设备数量: {}", onlineDevices.size());
|
||||||
|
|
||||||
|
for (GnssStatusJoin onlineDevice : onlineDevices) {
|
||||||
|
int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 7200);
|
||||||
|
logger.debug("- 设备: {}, SIM流量查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||||
|
|
||||||
|
ThreadManager.getScheduledThreadPool().schedule(
|
||||||
|
() -> checkDeviceSimCardTraffic(onlineDevice.getDeviceid()),
|
||||||
|
delay,
|
||||||
|
TimeUnit.SECONDS
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkDeviceSimCardStatus(String deviceId) {
|
||||||
|
try {
|
||||||
|
Device device = deviceService.findByDeviceId(deviceId);
|
||||||
|
// 不允许尚未从自检得到 ICCID 的设备参加 SIM 卡状态查询
|
||||||
|
if (!simCardQueryServiceImpl.hasValidIccid(device)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// SimCards 表中没有数据就初始化,这其实说明它在自检中刚获得属于自己的 ICCID 号
|
||||||
|
SimCard simCard = simCardQueryServiceImpl.CreateOrUpdateSimCard(device);
|
||||||
|
updateSimCardInfo(device, simCard);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("设备{}状态查询失败: ", deviceId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkDeviceSimCardTraffic(String deviceId) {
|
||||||
|
try {
|
||||||
|
Device device = deviceService.findByDeviceId(deviceId);
|
||||||
|
// 不允许尚未从自检得到 ICCID 的设备参加 SIM 卡状态查询
|
||||||
|
if (!simCardQueryServiceImpl.hasValidIccid(device)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// SimCards 表中没有数据就初始化,这说明它在自检中获得属于自己的 ICCID 号
|
||||||
|
SimCard simCard = simCardQueryServiceImpl.CreateOrUpdateSimCard(device);
|
||||||
|
// 如果该卡状态不是已激活,而是其他状态,那么不运行它参与 SIM 卡流量检测
|
||||||
|
if(simCard.getStatus() != SimCard.STATUS_ACTIVATED){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateSimCardTrafficFromAPI(device, simCard);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("设备{}查询失败: ", deviceId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSimCardInfo(Device device, SimCard simCard) throws Exception {
|
||||||
|
// 自检中只是获取保存了设备的 ICCID ,所有如果判断如果没有 MSISDN,先更新基本信息
|
||||||
|
if (StringUtils.isBlank(simCard.getMsisdn())) {
|
||||||
|
updateSimCardBasicInfoFromAPI(device, simCard);
|
||||||
|
}
|
||||||
|
// 更新状态
|
||||||
|
updateSimCardStatusFromAPI(device, simCard);
|
||||||
|
}
|
||||||
|
private void updateSimCardBasicInfoFromAPI(Device device, SimCard simCard) {
|
||||||
|
try {
|
||||||
|
BaseResponse<CardInfoData> response = simCardQueryServiceImpl.queryCardInfo(device);
|
||||||
|
if (!simCardQueryServiceImpl.isValidResponse(response)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CardInfoData info = response.getData();
|
||||||
|
simCard.setUpdatetime(new Date());
|
||||||
|
simCard.setMsisdn(info.getMsisdn());
|
||||||
|
simCardsMapper.updateSimCardInfo(simCard);
|
||||||
|
|
||||||
|
logger.info("更新SIM卡基本信息 - imsi: {}, msisdn: {}, iccid: {}",
|
||||||
|
info.getImsi(), info.getMsisdn(), info.getIccid());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("更新设备{}的SIM卡基本信息失败: ", device.getDeviceId(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void updateSimCardStatusFromAPI(Device device, SimCard simCard) {
|
||||||
|
try {
|
||||||
|
BaseResponse<CardStatusData> response = simCardQueryServiceImpl.queryCardStatus(device);
|
||||||
|
if (!simCardQueryServiceImpl.isValidResponse(response)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CardStatusData status = response.getData();
|
||||||
|
simCard.setUpdatetime(new Date());
|
||||||
|
simCard.setStatus(status.getStatusCode());
|
||||||
|
simCardsMapper.updateSimCardInfo(simCard);
|
||||||
|
|
||||||
|
warningService.checkSimCardStatus(device, simCard);
|
||||||
|
|
||||||
|
logger.info("更新SIM卡状态 - Code: {}, 描述: {}",
|
||||||
|
status.getStatusCode(), status.getStatusDesc());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("更新设备{}的SIM卡状态失败: ", device.getDeviceId(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSimCardTrafficFromAPI(Device device, SimCard simCard) {
|
||||||
|
try {
|
||||||
|
BaseResponse<GprsData> response = simCardQueryServiceImpl.queryGprs(device);
|
||||||
|
if (!simCardQueryServiceImpl.isValidResponse(response)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GprsData gprsData = response.getData();
|
||||||
|
GprsData.GprsUsage usage = gprsData.getFirstGprsUsage();
|
||||||
|
if (usage == null) {
|
||||||
|
logger.warn("无可用流量数据查询, deviceId: {}", device.getDeviceId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
simCard.setUpdatetime(new Date());
|
||||||
|
simCard.setRemaining(BigDecimal.valueOf(usage.getLeft()));
|
||||||
|
simCard.setUsed(BigDecimal.valueOf(usage.getUsed()));
|
||||||
|
simCard.setTotal(BigDecimal.valueOf(usage.getTotal()));
|
||||||
|
simCardsMapper.updateSimCardInfo(simCard);
|
||||||
|
|
||||||
|
warningService.checkSimCardTraffic(device, simCard);
|
||||||
|
|
||||||
|
logger.info("更新流量信息成功 - deviceId: {}, 剩余: {}MB, 总量: {}MB, 已用: {}MB",
|
||||||
|
device.getIccid(),
|
||||||
|
simCard.getRemaining(),
|
||||||
|
simCard.getTotal(),
|
||||||
|
simCard.getUsed());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("设备{}更新SIM卡流量失败: ", device.getDeviceId(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -136,7 +136,6 @@ public class ApiController {
|
|||||||
Map<String, Object> status = new HashMap<>();
|
Map<String, Object> status = new HashMap<>();
|
||||||
HttpResp resp = new HttpResp();
|
HttpResp resp = new HttpResp();
|
||||||
// get channel0/channel1 type
|
// get channel0/channel1 type
|
||||||
String[] paras = cmd.split("=| ");
|
|
||||||
Device device = localDeviceService.findByDeviceId(deviceId);
|
Device device = localDeviceService.findByDeviceId(deviceId);
|
||||||
if(device!=null){
|
if(device!=null){
|
||||||
resp.setResponseMessage("set OK.");
|
resp.setResponseMessage("set OK.");
|
||||||
|
|||||||
@ -35,4 +35,6 @@ xfz.server.host = 171.106.48.63
|
|||||||
xfz.server.port = 52000
|
xfz.server.port = 52000
|
||||||
xfz.server.data.send = false
|
xfz.server.data.send = false
|
||||||
|
|
||||||
warning.log.directory=./log
|
warning.log.directory=./log
|
||||||
|
|
||||||
|
ntrip_server.port = 11100
|
||||||
@ -59,6 +59,9 @@ public class APIController extends BasicController{
|
|||||||
//转成字符串
|
//转成字符串
|
||||||
String dtuAck = configAck.substring(9*2);
|
String dtuAck = configAck.substring(9*2);
|
||||||
rxInfo += configAck+"("+HexUtil.HexString2String(dtuAck)+")";
|
rxInfo += configAck+"("+HexUtil.HexString2String(dtuAck)+")";
|
||||||
|
|
||||||
|
// 检查是否需要更新 ICCID
|
||||||
|
updateICCID(device,dtuAck);
|
||||||
}
|
}
|
||||||
else if(msgType == 0xd313&&configAck.length()>=100){
|
else if(msgType == 0xd313&&configAck.length()>=100){
|
||||||
//转成字符串
|
//转成字符串
|
||||||
@ -192,4 +195,18 @@ public class APIController extends BasicController{
|
|||||||
msgMapper.insert(gnssMsg);
|
msgMapper.insert(gnssMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateICCID(GnssDevice device, String dtuAck) {
|
||||||
|
// 只检查 "ICCID:" 的十六进制部分
|
||||||
|
if(!dtuAck.contains("49434349443a")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String content = HexUtil.HexString2String(dtuAck);
|
||||||
|
if(content.contains("+ICCID:")){
|
||||||
|
//System.out.println(content);
|
||||||
|
String iccid = content.substring(content.indexOf("+ICCID:") + 8).trim();
|
||||||
|
iccid = iccid.split("\r\n")[0].trim();
|
||||||
|
device.setIccid(iccid);
|
||||||
|
deviceMapper.updateById(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,13 +5,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.github.yulichang.query.MPJQueryWrapper;
|
import com.github.yulichang.query.MPJQueryWrapper;
|
||||||
|
import com.imdroid.beidou.common.HttpResult;
|
||||||
import com.imdroid.beidou.service.CommonExcelService;
|
import com.imdroid.beidou.service.CommonExcelService;
|
||||||
import com.imdroid.secapi.dto.*;
|
import com.imdroid.secapi.dto.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -34,6 +37,8 @@ public class GnssCalcDataController extends BasicController implements CommonExc
|
|||||||
TenantMapper tenantMapper;
|
TenantMapper tenantMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
GnssDeviceMapper deviceMapper;
|
GnssDeviceMapper deviceMapper;
|
||||||
|
@Autowired
|
||||||
|
OpLogManager opLogManager;
|
||||||
boolean isJoinQuery = false;
|
boolean isJoinQuery = false;
|
||||||
final DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
final DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
@ -54,6 +59,29 @@ public class GnssCalcDataController extends BasicController implements CommonExc
|
|||||||
return "/page/gnss_data_calc";
|
return "/page/gnss_data_calc";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/page/gnssUpdateEnabled")
|
||||||
|
@ResponseBody
|
||||||
|
public String gnssUpdateEnabled(HttpSession session, @RequestParam Long id) throws Exception {
|
||||||
|
int num = 0;
|
||||||
|
GnssCalcData calcData = dataMapper.selectById(id);
|
||||||
|
if(calcData != null){
|
||||||
|
calcData.setEnabled(!calcData.getEnabled()); // 使用Boolean类型
|
||||||
|
calcData.setUpdatetime(LocalDateTime.now());
|
||||||
|
num = dataMapper.updateById(calcData);
|
||||||
|
}
|
||||||
|
|
||||||
|
opLogManager.addLog(getLoginUser(session),getTenantId(session),
|
||||||
|
OpLogManager.OP_TYPE_DEL,
|
||||||
|
OpLogManager.OP_OBJ_DEVICE,
|
||||||
|
calcData.getDeviceid() + " "+calcData.getCreatetime()+" gnss data changed");
|
||||||
|
if (num == 0) {
|
||||||
|
return HttpResult.failed();
|
||||||
|
} else{
|
||||||
|
return HttpResult.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**** 推送数据 *****/
|
/**** 推送数据 *****/
|
||||||
@RequestMapping("/gnss/data/list_calc")
|
@RequestMapping("/gnss/data/list_calc")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|||||||
@ -0,0 +1,206 @@
|
|||||||
|
package com.imdroid.beidou.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
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.imdroid.secapi.dto.*;
|
||||||
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class SimCardController extends BasicController {
|
||||||
|
@Value("${sim.url}")
|
||||||
|
private String BASE_URL;
|
||||||
|
@Value("${sim.username}")
|
||||||
|
private String USERNAME;
|
||||||
|
@Value("${sim.key}")
|
||||||
|
private String KEY;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SimCardsMapper simCardsMapper;
|
||||||
|
|
||||||
|
@RequestMapping("/page/sim_status")
|
||||||
|
public String simStatus(Model m, HttpSession session) {
|
||||||
|
initModel(m, session);
|
||||||
|
|
||||||
|
return "/page/sim_status";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/sim/list")
|
||||||
|
@ResponseBody
|
||||||
|
public JSONObject list(HttpSession session,
|
||||||
|
int page,
|
||||||
|
int limit,
|
||||||
|
String searchType,
|
||||||
|
String searchContent,
|
||||||
|
Integer status) {
|
||||||
|
Page<SimCard> pageable = new Page<>(page, limit);
|
||||||
|
|
||||||
|
QueryWrapper<SimCard> queryWrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(searchContent)) {
|
||||||
|
switch(searchType) {
|
||||||
|
case "deviceId":
|
||||||
|
queryWrapper.like("deviceid", searchContent.trim());
|
||||||
|
break;
|
||||||
|
case "iccid":
|
||||||
|
queryWrapper.like("iccid", searchContent.trim());
|
||||||
|
break;
|
||||||
|
case "simNumber":
|
||||||
|
queryWrapper.like("msisdn", searchContent.trim());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status != null) {
|
||||||
|
queryWrapper.eq("status", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
queryWrapper.orderByDesc("updatetime");
|
||||||
|
IPage<SimCard> cs = simCardsMapper.selectPage(pageable, queryWrapper);
|
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("code", 0);
|
||||||
|
jsonObject.put("msg", "");
|
||||||
|
jsonObject.put("count", cs.getTotal());
|
||||||
|
jsonObject.put("data", cs.getRecords());
|
||||||
|
System.out.println(jsonObject.toString());
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/page/sim_traffic_query")
|
||||||
|
public String simTrafficQuery(Model m, HttpSession session) {
|
||||||
|
initModel(m, session);
|
||||||
|
|
||||||
|
return "/page/sim_traffic_query";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 代理转发
|
||||||
|
@RequestMapping("/api/proxy/sim/query")
|
||||||
|
@ResponseBody
|
||||||
|
public JSONObject proxySimQuery(
|
||||||
|
@RequestParam String type,
|
||||||
|
@RequestParam String content
|
||||||
|
){
|
||||||
|
CloseableHttpClient httpClient = null;
|
||||||
|
CloseableHttpResponse response = null;
|
||||||
|
try {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("username", USERNAME);
|
||||||
|
params.put("key", KEY);
|
||||||
|
|
||||||
|
switch(type) {
|
||||||
|
case "iccid":
|
||||||
|
params.put("card", content);
|
||||||
|
break;
|
||||||
|
case "deviceId":
|
||||||
|
if (content.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("设备ID不能为空");
|
||||||
|
}
|
||||||
|
SimCard simCard = simCardsMapper.queryByDeviceId(content.trim());
|
||||||
|
if (simCard == null) {
|
||||||
|
throw new IllegalArgumentException("未找到该设备ID对应的SIM卡信息");
|
||||||
|
}
|
||||||
|
params.put("card", simCard.getIccid());
|
||||||
|
break;
|
||||||
|
case "simNumber":
|
||||||
|
params.put("card", content);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("无效的查询类型: " + type);
|
||||||
|
}
|
||||||
|
|
||||||
|
params.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000));
|
||||||
|
|
||||||
|
String signature = calculateSignature(params);
|
||||||
|
if (signature == null) {
|
||||||
|
throw new Exception("签名计算失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder urlBuilder = new StringBuilder(BASE_URL);
|
||||||
|
urlBuilder.append("/api/Service/QueryCard?");
|
||||||
|
urlBuilder.append("username=").append(USERNAME);
|
||||||
|
urlBuilder.append("&key=").append(KEY);
|
||||||
|
urlBuilder.append("&card=").append(params.get("card"));
|
||||||
|
urlBuilder.append("×tamp=").append(params.get("timestamp"));
|
||||||
|
urlBuilder.append("&signature=").append(signature);
|
||||||
|
|
||||||
|
httpClient = HttpClients.createDefault();
|
||||||
|
HttpGet httpGet = new HttpGet(urlBuilder.toString());
|
||||||
|
|
||||||
|
// System.out.println("Sending request: " + urlBuilder.toString());
|
||||||
|
response = httpClient.execute(httpGet);
|
||||||
|
HttpEntity entity = response.getEntity();
|
||||||
|
|
||||||
|
|
||||||
|
String result = EntityUtils.toString(entity);
|
||||||
|
// System.out.println("Received response: " + result);
|
||||||
|
|
||||||
|
return JSONObject.parseObject(result);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// System.out.println("Query failed: " + e.getMessage());
|
||||||
|
JSONObject errorResponse = new JSONObject();
|
||||||
|
errorResponse.put("Status", 0);
|
||||||
|
errorResponse.put("Message", "查询失败: " + e.getMessage());
|
||||||
|
return errorResponse;
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (response != null) {
|
||||||
|
response.close();
|
||||||
|
}
|
||||||
|
if (httpClient != null) {
|
||||||
|
httpClient.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String calculateSignature(Map<String, String> params) {
|
||||||
|
try {
|
||||||
|
List<String> paramList = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
paramList.add(entry.getKey() + "=" + entry.getValue());
|
||||||
|
}
|
||||||
|
Collections.sort(paramList);
|
||||||
|
|
||||||
|
String paramString = String.join("&", paramList);
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
byte[] digest = md.digest(paramString.getBytes());
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (byte b : digest) {
|
||||||
|
sb.append(String.format("%02x", b));
|
||||||
|
}
|
||||||
|
String signature = sb.toString();
|
||||||
|
// System.out.println("Signature: " + signature);
|
||||||
|
return signature;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
//System.out.println("Signature: " + e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,4 +47,8 @@ aliyun.oss.accessSecret = GHVzHKLLor8i5ZR1qyeoi4KMf3mjHb
|
|||||||
aliyun.oss.bucket = imdroid-device-management
|
aliyun.oss.bucket = imdroid-device-management
|
||||||
aliyun.oss.publicReadUrl = https://imdroid-device-management.oss-cn-shanghai.aliyuncs.com
|
aliyun.oss.publicReadUrl = https://imdroid-device-management.oss-cn-shanghai.aliyuncs.com
|
||||||
|
|
||||||
warning.log.directory=./log
|
warning.log.directory=./log
|
||||||
|
|
||||||
|
sim.url = http://120.78.169.220:8089
|
||||||
|
sim.username = gzyzdz
|
||||||
|
sim.key = 632629d1269a202c9d49a574623e4e4c
|
||||||
@ -68,6 +68,7 @@ CREATE TABLE IF NOT EXISTS `gnssdevices` (
|
|||||||
`imei` varchar(16) DEFAULT NULL,
|
`imei` varchar(16) DEFAULT NULL,
|
||||||
`model` smallint DEFAULT 0,
|
`model` smallint DEFAULT 0,
|
||||||
`loggingmode` smallint DEFAULT 0 COMMENT '日志模式: 0-精简模式(仅D3F0和D3F2), 1-完整模式',
|
`loggingmode` smallint DEFAULT 0 COMMENT '日志模式: 0-精简模式(仅D3F0和D3F2), 1-完整模式',
|
||||||
|
`iccid` VARCHAR(36) DEFAULT NULL COMMENT 'ICCID号,唯一',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
@ -328,6 +329,9 @@ CREATE TABLE IF NOT EXISTS `ApiKey` (
|
|||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
/***
|
||||||
|
GNSS 单次解记录表
|
||||||
|
*/
|
||||||
CREATE TABLE IF NOT EXISTS `gnssdevicesinglerecords` (
|
CREATE TABLE IF NOT EXISTS `gnssdevicesinglerecords` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
`deviceid` varchar(64) NOT NULL COMMENT '设备ID',
|
`deviceid` varchar(64) NOT NULL COMMENT '设备ID',
|
||||||
@ -342,6 +346,26 @@ CREATE TABLE IF NOT EXISTS `gnssdevicesinglerecords` (
|
|||||||
KEY `idx_createtime` (`createtime`)
|
KEY `idx_createtime` (`createtime`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='GNSS单次解算记录表';
|
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='GNSS单次解算记录表';
|
||||||
|
|
||||||
|
/***
|
||||||
|
SIM卡记录表
|
||||||
|
*/
|
||||||
|
CREATE TABLE IF NOT EXISTS `simcards` (
|
||||||
|
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增,唯一',
|
||||||
|
`updatetime` DATETIME DEFAULT NULL COMMENT '最新一次查询接口记录的时间',
|
||||||
|
`iccid` VARCHAR(36) NOT NULL COMMENT 'ICCID号,唯一',
|
||||||
|
`msisd` VARCHAR(20) NOT NULL COMMENT '物联卡号码,SIM号,唯一',
|
||||||
|
`deviceid` VARCHAR(20) DEFAULT NULL COMMENT '设备ID号',
|
||||||
|
`status` TINYINT DEFAULT -1 COMMENT 'SIM卡状态(-1:未知, 1:待激活, 2:已激活, 3:停机, 4:注销, 5:库存, 6:可测试, 7:失效, 99:号码不存在)',
|
||||||
|
`remaining` DECIMAL(10,2) DEFAULT 0.00 COMMENT '剩余流量,单位为MB,保留两位小数',
|
||||||
|
`total` DECIMAL(10,2) DEFAULT 0.00 COMMENT '总流量,单位为MB,保留两位小数',
|
||||||
|
`used` DECIMAL(10,2) DEFAULT 0.00 COMMENT '已用流量,单位为MB,保留两位小数',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_iccid` (`iccid`),
|
||||||
|
UNIQUE KEY `uk_msisd` (`msisd`),
|
||||||
|
INDEX `idx_deviceid` (`deviceid`),
|
||||||
|
INDEX `idx_status` (`status`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SIM卡信息表';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `ehm` (
|
CREATE TABLE IF NOT EXISTS `ehm` (
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
`tenantid` int DEFAULT 0,
|
`tenantid` int DEFAULT 0,
|
||||||
|
|||||||
@ -117,6 +117,26 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": "SIM卡管理",
|
||||||
|
"href": "",
|
||||||
|
"icon": "fa fa-signal",
|
||||||
|
"target": "_self",
|
||||||
|
"child": [
|
||||||
|
{
|
||||||
|
"title": "总览",
|
||||||
|
"href": "page/sim_status",
|
||||||
|
"icon": "fa fa-minus",
|
||||||
|
"target": "_self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "卡信息查询",
|
||||||
|
"href": "page/sim_traffic_query",
|
||||||
|
"icon": "fa fa-minus",
|
||||||
|
"target": "_self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "数据推送",
|
"title": "数据推送",
|
||||||
"href": "",
|
"href": "",
|
||||||
|
|||||||
@ -93,6 +93,26 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": "SIM卡管理",
|
||||||
|
"href": "",
|
||||||
|
"icon": "fa fa-signal",
|
||||||
|
"target": "_self",
|
||||||
|
"child": [
|
||||||
|
{
|
||||||
|
"title": "总览",
|
||||||
|
"href": "page/sim_status",
|
||||||
|
"icon": "fa fa-minus",
|
||||||
|
"target": "_self"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "卡信息查询",
|
||||||
|
"href": "page/sim_traffic_query",
|
||||||
|
"icon": "fa fa-minus",
|
||||||
|
"target": "_self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "数据推送",
|
"title": "数据推送",
|
||||||
"href": "",
|
"href": "",
|
||||||
|
|||||||
@ -97,10 +97,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/html" id="currentTableBar">
|
<script type="text/html" id="currentTableBar">
|
||||||
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="cmd">命令行</a>
|
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">状态修改</a>
|
||||||
</script>
|
<!-- <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>-->
|
||||||
|
<!-- <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="cmd"></a>-->
|
||||||
|
</script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -129,12 +131,14 @@
|
|||||||
{field: 'r9250e', title: '拟合东', templet: "<div>{{d.r9250e==null?'':d.r9250e.toFixed(2)}}</div>"},
|
{field: 'r9250e', title: '拟合东', templet: "<div>{{d.r9250e==null?'':d.r9250e.toFixed(2)}}</div>"},
|
||||||
{field: 'r9250n', title: '拟合北', templet: "<div>{{d.r9250n==null?'':d.r9250n.toFixed(2)}}</div>"},
|
{field: 'r9250n', title: '拟合北', templet: "<div>{{d.r9250n==null?'':d.r9250n.toFixed(2)}}</div>"},
|
||||||
{field: 'r9250d', title: '拟合天', templet: "<div>{{d.r9250d==null?'':d.r9250d.toFixed(2)}}</div>"},
|
{field: 'r9250d', title: '拟合天', templet: "<div>{{d.r9250d==null?'':d.r9250d.toFixed(2)}}</div>"},
|
||||||
{field: 'enabled', title: '有效',templet: '#enabledTrans'}
|
{field: 'enabled', title: '有效',templet: '#enabledTrans'},
|
||||||
|
{title: '操作', toolbar: '#currentTableBar', fixed: "right", width: 100}
|
||||||
];
|
];
|
||||||
if([[${role}]] != "SUPER_ADMIN") {
|
if([[${role}]] != "SUPER_ADMIN") {
|
||||||
data_cols[9].hide = true;
|
data_cols[9].hide = true;
|
||||||
data_cols[10].hide = true;
|
data_cols[10].hide = true;
|
||||||
data_cols[11].hide = true;
|
data_cols[11].hide = true;
|
||||||
|
data_cols[13].hide = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 初始化表单,要加上,不然刷新部分组件可能会不加载
|
* 初始化表单,要加上,不然刷新部分组件可能会不加载
|
||||||
@ -174,6 +178,32 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 监听工具条事件
|
||||||
|
table.on('tool(currentTableFilter)', function(obj) {
|
||||||
|
var data = obj.data;
|
||||||
|
if (obj.event === 'edit') {
|
||||||
|
layer.confirm('确定要修改状态吗?', {
|
||||||
|
btn: ['确定', '取消']
|
||||||
|
}, function(index) {
|
||||||
|
$.ajax({
|
||||||
|
url: '/page/gnssUpdateEnabled',
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
id: data.id,
|
||||||
|
},
|
||||||
|
success: function(res) {
|
||||||
|
table.reload('currentTableId');
|
||||||
|
layer.close(index);
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
layer.msg('操作失败');
|
||||||
|
layer.close(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 监听搜索操作
|
// 监听搜索操作
|
||||||
form.on('submit(data-search-btn)', function (data) {
|
form.on('submit(data-search-btn)', function (data) {
|
||||||
var result = JSON.stringify(data.field);
|
var result = JSON.stringify(data.field);
|
||||||
|
|||||||
278
sec-beidou/src/main/resources/templates/page/sim_status.html
Normal file
278
sec-beidou/src/main/resources/templates/page/sim_status.html
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>SIM卡信息查询</title>
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
|
<link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="../css/public.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layuimini-container">
|
||||||
|
<div class="layuimini-main">
|
||||||
|
<fieldset class="table-search-fieldset">
|
||||||
|
<legend>搜索信息</legend>
|
||||||
|
<div style="margin: 10px 10px 10px 10px">
|
||||||
|
<form class="layui-form layui-form-pane" action="" id="searchForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label">查询类型</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<select name="searchType" lay-verify="required">
|
||||||
|
<option value="deviceId">设备号</option>
|
||||||
|
<option value="iccid">ICCID</option>
|
||||||
|
<option value="simNumber">SIM卡号</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label">搜索内容</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="searchContent" id="searchInput" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label">状态</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<select name="status">
|
||||||
|
<option value="">全部</option>
|
||||||
|
<option value="1">待激活</option>
|
||||||
|
<option value="2">已激活</option>
|
||||||
|
<option value="3">停机</option>
|
||||||
|
<option value="4">注销</option>
|
||||||
|
<option value="5">库存</option>
|
||||||
|
<option value="6">可测试</option>
|
||||||
|
<option value="7">失效</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="searchSubmit"><i class="layui-icon"></i> 搜 索</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<div class="layui-tab layui-tab-card" lay-filter="data-tab">
|
||||||
|
<ul class="layui-tab-title">
|
||||||
|
<li class="layui-this">数据表格</li>
|
||||||
|
<li>流量图表</li>
|
||||||
|
</ul>
|
||||||
|
<div class="layui-tab-content">
|
||||||
|
<div class="layui-tab-item layui-show">
|
||||||
|
<table class="layui-hide" id="simTable" lay-filter="simTableFilter"></table>
|
||||||
|
</div>
|
||||||
|
<div class="layui-tab-item">
|
||||||
|
<div id="trafficChart" style="min-height:300px;padding: 10px"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="../js/lay-module/echarts/echartsTheme.js" charset="utf-8"></script>
|
||||||
|
<script src="../js/lay-module/echarts/echarts.js" charset="utf-8"></script>
|
||||||
|
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
|
||||||
|
<script type="text/html" id="statusTpl">
|
||||||
|
{{# if(d.status === 1){ }}
|
||||||
|
<span class="layui-badge layui-bg-orange">待激活</span>
|
||||||
|
{{# } else if(d.status === 2){ }}
|
||||||
|
<span class="layui-badge layui-bg-green">已激活</span>
|
||||||
|
{{# } else if(d.status === 3){ }}
|
||||||
|
<span class="layui-badge layui-bg-red">停机</span>
|
||||||
|
{{# } else if(d.status === 4){ }}
|
||||||
|
<span class="layui-badge layui-bg-black">注销</span>
|
||||||
|
{{# } else if(d.status === 5){ }}
|
||||||
|
<span class="layui-badge layui-bg-blue">库存</span>
|
||||||
|
{{# } else if(d.status === 6){ }}
|
||||||
|
<span class="layui-badge layui-bg-cyan">可测试</span>
|
||||||
|
{{# } else if(d.status === 7){ }}
|
||||||
|
<span class="layui-badge">失效</span>
|
||||||
|
{{# } }}
|
||||||
|
</script>
|
||||||
|
<script th:inline="javascript">
|
||||||
|
|
||||||
|
layui.use(['form', 'table','layer','element'], function () {
|
||||||
|
var table = layui.table
|
||||||
|
,form = layui.form
|
||||||
|
,layer = layui.layer
|
||||||
|
,element = layui.element;
|
||||||
|
|
||||||
|
var flowChart;
|
||||||
|
function initEcharts() {
|
||||||
|
if (!flowChart) {
|
||||||
|
flowChart = echarts.init(document.getElementById('trafficChart'), 'theme');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function updateFlowChart(simData) {
|
||||||
|
initEcharts();
|
||||||
|
|
||||||
|
var used = parseFloat(simData.used) || 0;
|
||||||
|
var remaining = parseFloat(simData.remaining) || 0;
|
||||||
|
var total = parseFloat(simData.total) || (used + remaining);
|
||||||
|
|
||||||
|
var option = {
|
||||||
|
title: {
|
||||||
|
text: 'SIM卡流量使用情况',
|
||||||
|
left: 'center',
|
||||||
|
top: 20,
|
||||||
|
textStyle: {
|
||||||
|
fontSize: 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
trigger: 'item',
|
||||||
|
formatter: '{a} <br/>{b}: {c}MB ({d}%)'
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
orient: 'horizontal', // 改为水平布局
|
||||||
|
bottom: 20, // 放在底部
|
||||||
|
left: 'center', // 居中对齐
|
||||||
|
itemWidth: 25,
|
||||||
|
itemHeight: 14
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: '流量使用情况',
|
||||||
|
type: 'pie',
|
||||||
|
radius: ['40%', '60%'], // 调整饼图大小
|
||||||
|
center: ['50%', '50%'], // 居中显示
|
||||||
|
avoidLabelOverlap: false,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
position: 'outside', // 标签位置改为外部
|
||||||
|
formatter: function(params) {
|
||||||
|
return params.name + '\n' +
|
||||||
|
params.value + 'MB\n' +
|
||||||
|
params.percent + '%';
|
||||||
|
},
|
||||||
|
fontSize: 14,
|
||||||
|
lineHeight: 20
|
||||||
|
},
|
||||||
|
labelLine: {
|
||||||
|
show: true,
|
||||||
|
length: 15,
|
||||||
|
length2: 10
|
||||||
|
},
|
||||||
|
emphasis: {
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: 'bold'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
value: used,
|
||||||
|
name: '已使用流量',
|
||||||
|
itemStyle: { color: '#FF5722' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: remaining,
|
||||||
|
name: '剩余流量',
|
||||||
|
itemStyle: { color: '#009688' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
document.getElementById('trafficChart').style.height = '400px';
|
||||||
|
|
||||||
|
flowChart.setOption(option);
|
||||||
|
flowChart.resize(); // 重新调整大小
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var data_cols = [
|
||||||
|
{field: 'deviceid', title: '设备号'},
|
||||||
|
{field: 'iccid', title: 'ICCID'},
|
||||||
|
{field: 'msisdn', title: 'SIM 卡号'},
|
||||||
|
{field: 'updatetime', title: '更新时间'},
|
||||||
|
{field: 'status', title: '状态',templet: '#statusTpl'},
|
||||||
|
{field: 'remaining', title: '剩余流量(MB)'},
|
||||||
|
{field: 'used', title: '已使用流量(MB)'},
|
||||||
|
{field: 'total', title: '总流量(MB)'}
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
form.render();
|
||||||
|
table.render({
|
||||||
|
elem: '#simTable',
|
||||||
|
url: '/sim/list',
|
||||||
|
toolbar: '#toolbarDemo', //开启头部工具栏
|
||||||
|
defaultToolbar: ['filter'],
|
||||||
|
cols: [
|
||||||
|
data_cols
|
||||||
|
],
|
||||||
|
limits: [20, 50, 100, 200, 300],
|
||||||
|
limit: 20,
|
||||||
|
page: true,
|
||||||
|
skin: 'line',
|
||||||
|
done: function(res) {
|
||||||
|
if(res.code !== 0) {
|
||||||
|
layer.msg(res.msg || '查询失败', {icon: 2});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
form.verify({
|
||||||
|
searchContent: function(value, item) {
|
||||||
|
var type = $('select[name="searchType"]').val();
|
||||||
|
if(!value) {
|
||||||
|
return '请输入搜索内容';
|
||||||
|
}
|
||||||
|
if(type === 'iccid' && !/^\d{19,20}$/.test(value)) {
|
||||||
|
return 'ICCID必须是19-20位数字';
|
||||||
|
}
|
||||||
|
if(type === 'simNumber' && !/^\d{11,13}$/.test(value)) {
|
||||||
|
return 'SIM卡号必须是11-13位数字';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
form.on('submit(searchSubmit)', function(data){
|
||||||
|
var loadIndex = layer.load(1);
|
||||||
|
table.reload('simTable', {
|
||||||
|
page: {
|
||||||
|
curr: 1
|
||||||
|
}
|
||||||
|
,where: {
|
||||||
|
searchType: data.field.searchType,
|
||||||
|
searchContent: data.field.searchContent,
|
||||||
|
status: data.field.status
|
||||||
|
}
|
||||||
|
,done: function(res) {
|
||||||
|
layer.close(loadIndex);
|
||||||
|
if(res.code !== 0) {
|
||||||
|
layer.msg(res.msg || '查询失败', {icon: 2});
|
||||||
|
} else if(res.count === 0) {
|
||||||
|
layer.msg('未找到符合条件的数据', {icon: 0});
|
||||||
|
}else if(res.count === 1) {
|
||||||
|
// 当查询结果只有一条数据时,使用该数据绘制饼图
|
||||||
|
updateFlowChart(res.data[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
//监听Tab切换,重新resize图表,否则显示不出来
|
||||||
|
element.on('tab(data-tab)', function(data){
|
||||||
|
if(data.index === 1 && flowChart) {
|
||||||
|
flowChart.resize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听窗口大小变化
|
||||||
|
window.addEventListener('resize', function() {
|
||||||
|
if (flowChart) {
|
||||||
|
flowChart.resize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -0,0 +1,290 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>SIM卡信息查询</title>
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
|
<link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="../css/public.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layuimini-container">
|
||||||
|
<div class="layuimini-main">
|
||||||
|
<fieldset class="table-search-fieldset">
|
||||||
|
<legend>SIM卡相关信息聚合查询</legend>
|
||||||
|
<div style="margin: 10px 10px 10px 10px">
|
||||||
|
<form class="layui-form layui-form-pane" action="" id="searchForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">搜索类型</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<select id="searchType" name="searchType" lay-search="" lay-filter="searchType">
|
||||||
|
<option value="iccid">ICCID</option>
|
||||||
|
<option value="deviceId">设备ID</option>
|
||||||
|
<option value="simNumber">SIM卡号</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">搜索内容</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="searchInput" name="searchContent" autocomplete="off" placeholder="搜索内容" lay-verify="required" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<button type="button" class="layui-btn" onclick="searchSIM()" lay-submit lay-filter="searchSubmit"><i class="layui-icon"></i>搜索</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div id="resultContainer" class="result-container layui-hide">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body" id="resultContent">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
|
||||||
|
<script>
|
||||||
|
layui.use(['form', 'layer', 'element'], function(){
|
||||||
|
var form = layui.form;
|
||||||
|
var layer = layui.layer;
|
||||||
|
var element = layui.element;
|
||||||
|
|
||||||
|
form.render();
|
||||||
|
form.on('submit(searchSubmit)', function(data){
|
||||||
|
searchSIM();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function searchSIM() {
|
||||||
|
const searchInput = document.getElementById('searchInput');
|
||||||
|
const searchContent = searchInput.value.trim();
|
||||||
|
const searchType = document.querySelector('select[name="searchType"]').value;
|
||||||
|
|
||||||
|
if (!searchContent) {
|
||||||
|
layer.msg('请输入搜索内容');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchType === 'iccid' && !/^\d{19,20}$/.test(searchContent)) {
|
||||||
|
layer.msg('ICCID必须是19-20位数字');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchType === 'simNumber' && !/^\d{11,13}$/.test(searchContent)) {
|
||||||
|
layer.msg('SIM卡号必须是11-13位数字');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const loadingIndex = layer.load(1, {
|
||||||
|
shade: [0.1, '#fff']
|
||||||
|
});
|
||||||
|
|
||||||
|
fetch(`/api/proxy/sim/query?type=${searchType}&content=${searchContent}`)
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Network response was not ok');
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(result => {
|
||||||
|
layer.close(loadingIndex);
|
||||||
|
console.log('API Response:', result);
|
||||||
|
|
||||||
|
if (result.Status === 1 && result.Data) {
|
||||||
|
displayResult(result.Data);
|
||||||
|
} else {
|
||||||
|
layer.msg(result.Message || '查询失败');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
layer.close(loadingIndex);
|
||||||
|
console.error('Error:', error);
|
||||||
|
layer.msg('请求处理失败:' + error.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayResult(data) {
|
||||||
|
const resultContainer = document.getElementById('resultContainer');
|
||||||
|
const resultContent = document.getElementById('resultContent');
|
||||||
|
|
||||||
|
if (!resultContainer || !resultContent) {
|
||||||
|
console.error('Result container elements not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultContainer.classList.remove('layui-hide');
|
||||||
|
|
||||||
|
// 格式化状态和其他信息
|
||||||
|
const statusText = getStatusText(data.status);
|
||||||
|
const statusClass = getStatusClass(data.status);
|
||||||
|
const operatorText = getOperatorText(data.operatortype);
|
||||||
|
|
||||||
|
// 格式化流量数据
|
||||||
|
const gprsInfo = {
|
||||||
|
total: parseFloat(data.gprs?.total) || 0,
|
||||||
|
used: parseFloat(data.gprs?.used) || 0,
|
||||||
|
left: parseFloat(data.gprs?.left) || 0
|
||||||
|
};
|
||||||
|
|
||||||
|
const usagePercentage = calculateUsagePercentage(gprsInfo);
|
||||||
|
|
||||||
|
resultContent.innerHTML = `
|
||||||
|
<table class="layui-table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td width="120">运营商</td>
|
||||||
|
<td>${operatorText}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>ICCID</td>
|
||||||
|
<td>${data.iccid || '-'}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>SIM卡号</td>
|
||||||
|
<td>${data.msisdn || '-'}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>IMSI</td>
|
||||||
|
<td>${data.imsi || '-'}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>套餐信息</td>
|
||||||
|
<td>
|
||||||
|
ID: ${data.packageid || '-'}<br>
|
||||||
|
名称: ${data.packagename || '-'}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>时间信息</td>
|
||||||
|
<td>
|
||||||
|
激活时间: ${data.activetime || '-'}<br>
|
||||||
|
有效期: ${data.starttime || '-'} 至 ${data.stoptime || '-'}<br>
|
||||||
|
沉默期结束: ${data.silentdate || '-'}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>状态</td>
|
||||||
|
<td><span class="layui-badge ${statusClass}">${statusText}</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>APN信息</td>
|
||||||
|
<td>
|
||||||
|
${data.apn ? `
|
||||||
|
<div>ID: ${data.apn.apnid || '-'}</div>
|
||||||
|
<div>状态: ${data.apn.status === '01' ?
|
||||||
|
'<span class="layui-badge layui-bg-green">在线</span>' :
|
||||||
|
'<span class="layui-badge layui-bg-gray">离线</span>'}</div>
|
||||||
|
<div>IP: ${data.apn.ip || '-'}</div>
|
||||||
|
<div>网络: ${getNetworkText(data.apn.rat)}</div>
|
||||||
|
<div>设备状态: ${data.apn.onoffstatus === '1' ?
|
||||||
|
'<span class="layui-badge layui-bg-green">开机</span>' :
|
||||||
|
'<span class="layui-badge layui-bg-gray">关机</span>'}</div>
|
||||||
|
` : '-'}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>GPRS流量</td>
|
||||||
|
<td>
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md4">总流量: ${formatFlowSize(gprsInfo.total)} MB</div>
|
||||||
|
<div class="layui-col-md4">已用: ${formatFlowSize(gprsInfo.used)} MB</div>
|
||||||
|
<div class="layui-col-md4">剩余: ${formatFlowSize(gprsInfo.left)} MB</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-progress layui-progress-big" style="margin-top: 10px;">
|
||||||
|
<div class="layui-progress-bar ${getProgressBarColor(gprsInfo)}"
|
||||||
|
style="width: ${usagePercentage}%">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// 重新渲染进度条
|
||||||
|
layui.element.render('progress');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatusText(status) {
|
||||||
|
const statusMap = {
|
||||||
|
1: '待激活',
|
||||||
|
2: '已激活',
|
||||||
|
3: '停机',
|
||||||
|
4: '注销',
|
||||||
|
5: '库存',
|
||||||
|
6: '可测试',
|
||||||
|
7: '失效'
|
||||||
|
};
|
||||||
|
return statusMap[status] || '未知状态';
|
||||||
|
}
|
||||||
|
function getOperatorText(type) {
|
||||||
|
const operatorMap = {
|
||||||
|
1: '中国移动',
|
||||||
|
2: '中国联通',
|
||||||
|
3: '中国电信'
|
||||||
|
};
|
||||||
|
return operatorMap[type] || '未知运营商';
|
||||||
|
}
|
||||||
|
function getNetworkText(rat) {
|
||||||
|
const networkMap = {
|
||||||
|
'1': '3G',
|
||||||
|
'2': '2G',
|
||||||
|
'6': '4G',
|
||||||
|
'8': 'NB'
|
||||||
|
};
|
||||||
|
return networkMap[rat] || '未知网络';
|
||||||
|
}
|
||||||
|
function getStatusClass(status) {
|
||||||
|
const classMap = {
|
||||||
|
1: 'layui-bg-orange', // 待激活
|
||||||
|
2: 'layui-bg-green', // 已激活
|
||||||
|
3: 'layui-bg-red', // 停机
|
||||||
|
4: 'layui-bg-gray', // 注销
|
||||||
|
5: 'layui-bg-blue', // 库存
|
||||||
|
6: 'layui-bg-cyan', // 可测试
|
||||||
|
7: 'layui-bg-black' // 失效
|
||||||
|
};
|
||||||
|
return classMap[status] || 'layui-bg-gray';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProgressBarColor(gprsInfo) {
|
||||||
|
const percentage = calculateUsagePercentage(gprsInfo);
|
||||||
|
if (percentage >= 90) return 'layui-bg-red';
|
||||||
|
if (percentage >= 70) return 'layui-bg-orange';
|
||||||
|
return 'layui-bg-green';
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateUsagePercentage(gprsInfo) {
|
||||||
|
// 确保所有值都是数字,并且total不为0
|
||||||
|
const total = parseFloat(gprsInfo.total) || 0;
|
||||||
|
const used = parseFloat(gprsInfo.used) || 0;
|
||||||
|
|
||||||
|
if (total <= 0) return 0;
|
||||||
|
|
||||||
|
const percentage = (used / total) * 100;
|
||||||
|
return Math.min(100, Math.round(percentage));
|
||||||
|
}
|
||||||
|
function formatFlowSize(size) {
|
||||||
|
if (typeof size !== 'number' || isNaN(size)) return '0.00';
|
||||||
|
return size.toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按回车键触发查询
|
||||||
|
document.getElementById('searchInput').addEventListener('keypress', function(e) {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
e.preventDefault();
|
||||||
|
searchSIM();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -207,6 +207,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
<div class="layui-form-item" th:if="${role=='SUPER_ADMIN'}">
|
||||||
|
<label class="layui-form-label">ICCID</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="iccid" id="iccid" class="layui-input" placeholder="请输入19-20位的ICCID号码">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="layui-form-item" th:if="${role=='SUPER_ADMIN'}">
|
<div class="layui-form-item" th:if="${role=='SUPER_ADMIN'}">
|
||||||
<label class="layui-form-label">备注</label>
|
<label class="layui-form-label">备注</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
@ -320,6 +326,7 @@
|
|||||||
$('#model').val(data.model);
|
$('#model').val(data.model);
|
||||||
$('#sector').val(data.sector);
|
$('#sector').val(data.sector);
|
||||||
$('#remark').val(data.remark);
|
$('#remark').val(data.remark);
|
||||||
|
$('#iccid').val(data.iccid);
|
||||||
setEcefEditor();
|
setEcefEditor();
|
||||||
form.render();
|
form.render();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user