|
@@ -2,16 +2,14 @@ package com.fdkankan.manage.inner.controller;
|
|
|
|
|
|
import cn.hutool.extra.servlet.ServletUtil;
|
|
|
import cn.hutool.log.Log;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fdkankan.common.util.SecurityUtil;
|
|
|
import com.fdkankan.manage.common.CacheUtil;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.manage.common.ResultData;
|
|
|
import com.fdkankan.manage.controller.BaseController;
|
|
|
-import com.fdkankan.manage.entity.RtkAccount;
|
|
|
-import com.fdkankan.manage.entity.RtkDevice;
|
|
|
-import com.fdkankan.manage.entity.RtkInfo;
|
|
|
-import com.fdkankan.manage.entity.RtkUseLog;
|
|
|
+import com.fdkankan.manage.entity.*;
|
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
|
import com.fdkankan.manage.service.*;
|
|
|
import com.fdkankan.manage.util.RsaUtils;
|
|
@@ -88,6 +86,8 @@ public class InnerController extends BaseController {
|
|
|
IRtkDeviceService rtkDeviceService;
|
|
|
@Autowired
|
|
|
IRtkUseLogService rtkUseLogService;
|
|
|
+ @Autowired
|
|
|
+ IRtkUpdateLogService rtkUpdateLogService;
|
|
|
|
|
|
/**
|
|
|
* 相机开启rtk获取账号
|
|
@@ -143,6 +143,14 @@ public class InnerController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping("/infoByTk/{rtkSnCode}")
|
|
|
public synchronized ResultData infoByTk(@PathVariable String rtkSnCode){
|
|
|
+ JSONObject jsonObject = checkRtkSign();
|
|
|
+ if(jsonObject == null){
|
|
|
+ throw new BusinessException(ResultCode.RTK_TOKEN_ERROR);
|
|
|
+ }
|
|
|
+ String string = jsonObject.getString("rtkSnCode");
|
|
|
+ if(!string.equals(rtkSnCode)){
|
|
|
+ throw new BusinessException(ResultCode.RTK_TOKEN_ERROR);
|
|
|
+ }
|
|
|
if(StringUtils.isBlank(rtkSnCode)){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
@@ -157,10 +165,20 @@ public class InnerController extends BaseController {
|
|
|
|
|
|
@PostMapping("/updateRtkInfo")
|
|
|
public ResultData updateRtkInfo(@RequestBody RtkInfo param){
|
|
|
-
|
|
|
if(StringUtils.isNotBlank(param.getRtkSnCode())){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
+
|
|
|
+ JSONObject jsonObject = checkRtkSign();
|
|
|
+ if(jsonObject == null){
|
|
|
+ throw new BusinessException(ResultCode.RTK_TOKEN_ERROR);
|
|
|
+ }
|
|
|
+ String string = jsonObject.getString("rtkSnCode");
|
|
|
+ if(!string.equals(param.getRtkSnCode())){
|
|
|
+ throw new BusinessException(ResultCode.RTK_TOKEN_ERROR);
|
|
|
+ }
|
|
|
+ String account = jsonObject.getString("account");
|
|
|
+
|
|
|
RtkDevice rtkDevice = rtkDeviceService.getByRtkSnCode(param.getRtkSnCode());
|
|
|
if(rtkDevice == null){
|
|
|
throw new BusinessException(ResultCode.RTK_SN_CODE_NOT_EXIT);
|
|
@@ -168,6 +186,7 @@ public class InnerController extends BaseController {
|
|
|
if(rtkDevice.getAccountType() == 0){ //账号池
|
|
|
throw new BusinessException(ResultCode.RTK_UPDATE_ERROR);
|
|
|
}
|
|
|
+
|
|
|
LambdaUpdateWrapper<RtkDevice> wrapper = new LambdaUpdateWrapper<>();
|
|
|
wrapper.eq(RtkDevice::getId,rtkDevice.getId());
|
|
|
wrapper.set(RtkDevice::getUserName,param.getUserName());
|
|
@@ -178,6 +197,12 @@ public class InnerController extends BaseController {
|
|
|
wrapper.set(RtkDevice::getFailureTime,null);
|
|
|
rtkDeviceService.update(wrapper);
|
|
|
|
|
|
+ RtkUpdateLog rtkUpdateLog = new RtkUpdateLog();
|
|
|
+ rtkUpdateLog.setRtkSnCode(param.getRtkSnCode());
|
|
|
+ rtkUpdateLog.setFdAccount(account);
|
|
|
+ rtkUpdateLog.setOldJsonData(JSONObject.toJSONString(rtkDevice));
|
|
|
+ rtkUpdateLog.setNewJsonData(JSONObject.toJSONString(rtkDeviceService.getById(rtkDevice.getId())));
|
|
|
+ rtkUpdateLogService.save(rtkUpdateLog);
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
}
|