ソースを参照

Merge branch 'develop' of gitadmin/tuoheng_air_monitor into release

tags/v1.0.2
wanjing 1年前
コミット
4d2520512f
5個のファイルの変更126行の追加10行の削除
  1. +4
    -1
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/JsonResult.java
  2. +18
    -0
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/SecurityUserUtils.java
  3. +5
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/upload/UploadFlightUrlService.java
  4. +18
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/OidcServiceImpl.java
  5. +81
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/utils/SrtDataUtil.java

+ 4
- 1
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/JsonResult.java ファイルの表示

@@ -16,7 +16,10 @@ public class JsonResult<T> implements Serializable {
* 成功
*/
public static final int SUCCESS = 0;

/**
* 专用
*/
public static final int OIDC_ERROR = -2;
/**
* 失败
*/

+ 18
- 0
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/SecurityUserUtils.java ファイルの表示

@@ -42,6 +42,7 @@ public class SecurityUserUtils {

public static String token() {
// header中获取用户token
check();
String token = ServletUtils.getRequest().getHeader("th-token");
if (StringUtils.isEmpty(token)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "token不能为空");
@@ -56,6 +57,7 @@ public class SecurityUserUtils {
*/
public static String username() {
// header中获取用户token
check();
String oUserJson = ServletUtils.getRequest().getHeader("o-user-json");
if (StringUtils.isEmpty(oUserJson)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "oUserJson不能为空");
@@ -66,4 +68,20 @@ public class SecurityUserUtils {
return username;
}

public static void check() {
String oUserJson = ServletUtils.getRequest().getHeader("o-user-json");
String json = EncryptUtil.decodeUTF8StringBase64(oUserJson);
JSONObject jsonObject = JSON.parseObject(json);
Integer isAble = jsonObject.getInteger("isAble");
Integer isExpire = jsonObject.getInteger("isExpire");
if (StringUtils.isNotNull(isAble) && StringUtils.isNotNull(isExpire)) {
if (0 == isAble) {
throw new ServiceException(JsonResult.OIDC_ERROR, "该账号已被禁用,请联系系统管理员");
}
if (0 == isExpire) {
throw new ServiceException(JsonResult.OIDC_ERROR, "系统有效期已过,请联系系统管理员");
}
}
}

}

+ 5
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/upload/UploadFlightUrlService.java ファイルの表示

@@ -173,14 +173,14 @@ public class UploadFlightUrlService {
if (type == 1) {
//解析srt文件经纬度和时间戳
flightDataList = SrtDataUtil.getByM300(txtContent, inspectionId, tenantId);
} else if(type == 2){
flightDataList = SrtDataUtil.getByYu2(txtContent, inspectionId, tenantId);
} else if(type == 3){
flightDataList = SrtDataUtil.getByYu3e(txtContent, inspectionId, tenantId);
} else {
log.info("srt文件上传, type不等于1,异常");
log.info("srt文件上传, type={}, type不等于1,2,3,异常", type);
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
if (ObjectUtils.isEmpty(flightDataList)) {
log.info("srt文件上传, 上传文件数据错误,请检查文件!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_IS_ERROR);
}
flightDataMapper.delete(new LambdaQueryWrapper<FlightData>()
.eq(FlightData::getInspectionId, inspectionId)
.eq(FlightData::getTenantId, tenantId)

+ 18
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/OidcServiceImpl.java ファイルの表示

@@ -1,5 +1,8 @@
package com.tuoheng.admin.service.third.oidc;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.domain.Role;
import com.tuoheng.admin.entity.dto.RolePermissionDto;
import com.tuoheng.admin.entity.domain.Tenant;
import com.tuoheng.admin.entity.domain.User;
@@ -7,12 +10,15 @@ import com.tuoheng.admin.mapper.MenuMapper;
import com.tuoheng.admin.entity.request.third.oidc.CreateOidcTenantRequest;
import com.tuoheng.admin.entity.request.third.oidc.DeletedOidcTenantRequest;
import com.tuoheng.admin.entity.request.third.oidc.EditOidcTenantRequest;
import com.tuoheng.admin.mapper.RoleMapper;
import com.tuoheng.admin.service.system.role.IRoleService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class OidcServiceImpl implements OidcService {
@@ -38,6 +44,9 @@ public class OidcServiceImpl implements OidcService {
@Autowired
private MenuMapper menuMapper;

@Autowired
private RoleMapper roleMapper;


public JsonResult addUser(User user, String password, Tenant tenant) {
return addOidcUserService.add(user, password, tenant);
@@ -73,9 +82,16 @@ public class OidcServiceImpl implements OidcService {
*/
@Override
public JsonResult getRoleList() {
//返回角色列表
List<Role> roles = roleMapper.selectList(new LambdaQueryWrapper<Role>()
.eq(Role::getMark, 1)
.eq(Role::getTenantId, "1")
.eq(Role::getStatus, 1));
return JsonResult.success(roles);

// JsonResult jsonResult = roleService.getRoles();


JsonResult jsonResult = roleService.getRoles();
return jsonResult;
}

/**

+ 81
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/utils/SrtDataUtil.java ファイルの表示

@@ -13,6 +13,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
* SRT文件经纬度解析工具
*
@@ -22,10 +23,84 @@ import java.util.regex.Pattern;
@Slf4j
public class SrtDataUtil {

/**
* 机型为御3E拍摄的SRT文件
*/
public static List<FlightData> getByYu3e(String srtMsg, String inspectionId, String tenantId) throws Exception {
List<FlightData> flightDataList = new ArrayList<>();
//将全部字符串按照每个font分割
List<String> msgList = new ArrayList<>();
Matcher msg = Pattern.compile(
Pattern.quote("HOME(")
+ "(.*?)"
+ Pattern.quote("ISO:")
).matcher(srtMsg);
while (msg.find()) {
String match = msg.group(1);
msgList.add(match);
}

//解析每组数据
for (String str : msgList) {
FlightData flightData = new FlightData();
flightData.setIsSrt(1);
flightData.setInspectionId(inspectionId);
flightData.setTenantId(tenantId);
//找出时间,格式为2023.02.27 15:32:19
Matcher time = Pattern.compile(Pattern.quote(") ")
+ "(.*?)"
+ Pattern.quote("GPS(")
).matcher(str);
if (time.find()) {
String match = time.group(1);
//截取时间,转为时间戳
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
Date date = simpleDateFormat.parse(match);
String timeStamp = String.valueOf(date.getTime());
flightData.setTimestamp(timeStamp);
} else {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR);
}

//找出经度
Matcher longitude = Pattern.compile(
Pattern.quote("GPS(")
+ "(.*?)"
+ Pattern.quote(",")
).matcher(str);
if (longitude.find()) {
String match = longitude.group(1);
flightData.setLng(match);
} else {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR);
}
//找出数据 格式为 GPS(120.909168,32.596070,141.100000)
Matcher latitude = Pattern.compile(
Pattern.quote("GPS(")
+ "(.*?)"
+ Pattern.quote(")")
).matcher(str);
if (latitude.find()) {
String match = latitude.group(1);
//找出纬度
String lat = match.split(",")[1];
flightData.setLat(lat);
} else {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR);
}
flightDataList.add(flightData);
}
return flightDataList;
}


/**
* 机型为御二拍摄的SRT文件
*/
public static List<FlightData> getByYu2(String srtMsg, String inspectionId) throws Exception {
public static List<FlightData> getByYu2(String srtMsg, String inspectionId, String tenantId) throws Exception {
List<FlightData> flightDataList = new ArrayList<>();
//将全部字符串按照每个font分割
List<String> msgList = new ArrayList<>();
@@ -44,6 +119,7 @@ public class SrtDataUtil {
FlightData flightData = new FlightData();
flightData.setIsSrt(1);
flightData.setInspectionId(inspectionId);
flightData.setTenantId(tenantId);
//找出时间,格式为2021-08-24 09:33:15,848,518
Matcher time = Pattern.compile(Pattern.quote("ms")
+ "(.*?)"
@@ -59,6 +135,7 @@ public class SrtDataUtil {
String timeStamp = String.valueOf(date.getTime());
flightData.setTimestamp(timeStamp);
} else {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_TIME_IS_ERROR);
}

@@ -72,6 +149,7 @@ public class SrtDataUtil {
String match = longitude.group(1);
flightData.setLng(match);
} else {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR);
}
//找出纬度
@@ -84,6 +162,7 @@ public class SrtDataUtil {
String match = latitude.group(1);
flightData.setLat(match);
} else {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LAT_IS_ERROR);
}
flightDataList.add(flightData);
@@ -148,7 +227,7 @@ public class SrtDataUtil {
String match = longitude.group(1);
flightData.setLng(match);
} else {
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!!");
log.info("获取机型为M300拍摄的SRT文件数据, 上传文件数据错误,请检查文件!!");
throw new ServiceException(ServiceExceptionEnum.FILE_DATA_LNG_IS_ERROR);
}
//找出纬度

読み込み中…
キャンセル
保存