|
|
@@ -7,7 +7,6 @@ import com.inspur.device.domain.constants.DeviceTaskConstants;
|
|
|
import com.inspur.device.domain.vo.*;
|
|
|
import com.inspur.device.mapper.SmsbDeviceTaskMapper;
|
|
|
import com.inspur.device.service.*;
|
|
|
-import com.inspur.device.domain.vo.AgentAuthRes;
|
|
|
import com.inspur.source.domain.vo.FrontItemSourceVO;
|
|
|
import com.inspur.source.domain.vo.FrontPushInfoVo;
|
|
|
import com.inspur.source.service.ISmsbItemPushDeviceService;
|
|
|
@@ -15,11 +14,14 @@ import com.inspur.source.service.ISmsbItemPushService;
|
|
|
import jakarta.validation.constraints.NotNull;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.json.utils.JsonUtils;
|
|
|
+import org.dromara.common.sm4.MessageHandlerPool;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -53,6 +55,9 @@ public class SmsbFrontController {
|
|
|
@Autowired
|
|
|
private ISmsbDeviceLogPushService smsbDeviceLogPushService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MessageHandlerPool decryptAndEncryptHandlerPool;
|
|
|
+
|
|
|
/**
|
|
|
* 根据设备identifier 获取该设备最新内容下发记录
|
|
|
*
|
|
|
@@ -60,14 +65,26 @@ public class SmsbFrontController {
|
|
|
*/
|
|
|
@SaIgnore
|
|
|
@GetMapping("/push/{identifier}")
|
|
|
- public R<List<FrontPushInfoVo>> getItemPushInfo(@NotNull(message = "identifier不能为空") @PathVariable String identifier) {
|
|
|
- return smsbItemPushService.getItemPushInfo(identifier);
|
|
|
+ public R<String> getItemPushInfo(@NotNull(message = "identifier不能为空") @PathVariable String identifier) {
|
|
|
+ String decryptIdentifier = decryptAndEncryptHandlerPool.decryptMessage(identifier);
|
|
|
+ R<List<FrontPushInfoVo>> response = smsbItemPushService.getItemPushInfo(decryptIdentifier);
|
|
|
+ if (R.isSuccess(response) && null != response.getData()) {
|
|
|
+ String decryptData = decryptAndEncryptHandlerPool.encryptMessage(JsonUtils.toJsonString(response.getData()));
|
|
|
+ return R.ok("SUCCESS", decryptData);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
@SaIgnore
|
|
|
@GetMapping("/itemSource/{itemId}")
|
|
|
- public R<List<FrontItemSourceVO>> getItemSourceList(@NotNull(message = "itemId不能为空") @PathVariable Long itemId) {
|
|
|
- return smsbItemPushService.getItemSourceList(itemId);
|
|
|
+ public R<String> getItemSourceList(@NotNull(message = "itemId不能为空") @PathVariable String itemId) {
|
|
|
+ String decryptItemId = decryptAndEncryptHandlerPool.decryptMessage(itemId);
|
|
|
+ R<List<FrontItemSourceVO>> response = smsbItemPushService.getItemSourceList(Long.parseLong(decryptItemId));
|
|
|
+ if (R.isSuccess(response) && null != response.getData()) {
|
|
|
+ String decryptData = decryptAndEncryptHandlerPool.encryptMessage(JsonUtils.toJsonString(response.getData()));
|
|
|
+ return R.ok("SUCCESS", decryptData);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -80,8 +97,10 @@ public class SmsbFrontController {
|
|
|
@SaIgnore
|
|
|
@GetMapping("/push/update/end/{identifier}/{pushId}")
|
|
|
public R<Void> itemUpdateEnd(@NotNull(message = "identifier不能为空") @PathVariable String identifier,
|
|
|
- @NotNull(message = "pushId不能为空") @PathVariable Long pushId) {
|
|
|
- return smsbItemPushService.itemUpdateEnd(identifier,pushId);
|
|
|
+ @NotNull(message = "pushId不能为空") @PathVariable String pushId) {
|
|
|
+ String decryptIdentifier = decryptAndEncryptHandlerPool.decryptMessage(identifier);
|
|
|
+ String decryptPushId = decryptAndEncryptHandlerPool.decryptMessage(pushId);
|
|
|
+ return smsbItemPushService.itemUpdateEnd(decryptIdentifier,Long.parseLong(decryptPushId));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -92,8 +111,14 @@ public class SmsbFrontController {
|
|
|
*/
|
|
|
@SaIgnore
|
|
|
@GetMapping("/ota/check/{identifier}")
|
|
|
- public R<SmsbOtaRecordVo> deviceCheckOta(@NotNull(message = "identifier不能为空") @PathVariable String identifier) {
|
|
|
- return iSmsbOtaRecordService.deviceCheckOta(identifier);
|
|
|
+ public R<String> deviceCheckOta(@NotNull(message = "identifier不能为空") @PathVariable String identifier) {
|
|
|
+ String decryptIdentifier = decryptAndEncryptHandlerPool.decryptMessage(identifier);
|
|
|
+ R<SmsbOtaRecordVo> response = iSmsbOtaRecordService.deviceCheckOta(decryptIdentifier);
|
|
|
+ if (R.isSuccess(response) && null != response.getData()) {
|
|
|
+ String decryptData = decryptAndEncryptHandlerPool.encryptMessage(JsonUtils.toJsonString(response.getData()));
|
|
|
+ return R.ok("SUCCESS", decryptData);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -103,9 +128,11 @@ public class SmsbFrontController {
|
|
|
*/
|
|
|
@SaIgnore
|
|
|
@PostMapping("/screenshot/upload")
|
|
|
- public R<Void> screenshotUpload(@RequestParam("identifier") String identifier,@RequestParam("timestamp") Long timestamp,
|
|
|
+ public R<Void> screenshotUpload(@RequestParam("identifier") String identifier,@RequestParam("timestamp") String timestamp,
|
|
|
@RequestBody MultipartFile file) {
|
|
|
- return smsbDeviceService.screenshotUpload(identifier,timestamp, file);
|
|
|
+ String decryptIdentifier = decryptAndEncryptHandlerPool.decryptMessage(identifier);
|
|
|
+ String decryptTimestamp = decryptAndEncryptHandlerPool.decryptMessage(timestamp);
|
|
|
+ return smsbDeviceService.screenshotUpload(decryptIdentifier,Long.parseLong(decryptTimestamp), file);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -115,8 +142,17 @@ public class SmsbFrontController {
|
|
|
*/
|
|
|
@SaIgnore
|
|
|
@PostMapping("/heartbeat")
|
|
|
- public R<HttpHeartbeatRspVo> heartbeat(@RequestBody HttpHeartbeatReq requestParam) {
|
|
|
- return smsbDeviceService.heartbeat(requestParam);
|
|
|
+ public R<String> heartbeat(@RequestBody HttpHeartbeatReq requestParam) {
|
|
|
+ // 获取解密后内容
|
|
|
+ String decryptMessage = decryptAndEncryptHandlerPool.decryptMessage(requestParam.getData());
|
|
|
+ // 将字符串转成json
|
|
|
+ HttpHeartbeatReq decryptedRequest = JsonUtils.parseObject(decryptMessage, HttpHeartbeatReq.class);
|
|
|
+ R<HttpHeartbeatRspVo> response = smsbDeviceService.heartbeat(decryptedRequest);
|
|
|
+ if (null == response.getData()) {
|
|
|
+ String rspEncryptMessage = decryptAndEncryptHandlerPool.encryptMessage(JsonUtils.toJsonString(response.getData()));
|
|
|
+ return R.ok("SUCCESS", rspEncryptMessage);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -128,7 +164,16 @@ public class SmsbFrontController {
|
|
|
@SaIgnore
|
|
|
@PostMapping("/login")
|
|
|
public R<String> deviceLogin(@RequestBody HttpHeartbeatReq requestParam) {
|
|
|
- return smsbDeviceLoginService.deviceLogin(requestParam);
|
|
|
+ // 获取解密后内容
|
|
|
+ String decryptMessage = decryptAndEncryptHandlerPool.decryptMessage(requestParam.getData());
|
|
|
+ // 将字符串转成json
|
|
|
+ HttpHeartbeatReq decryptedRequest = JsonUtils.parseObject(decryptMessage, HttpHeartbeatReq.class);
|
|
|
+ R<String> response = smsbDeviceLoginService.deviceLogin(decryptedRequest);
|
|
|
+ if (response.getCode() == R.SUCCESS) {
|
|
|
+ String rspEncryptMessage = decryptAndEncryptHandlerPool.encryptMessage(response.getData());
|
|
|
+ return R.ok("SUCCESS", rspEncryptMessage);
|
|
|
+ }
|
|
|
+ return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -139,7 +184,16 @@ public class SmsbFrontController {
|
|
|
@SaIgnore
|
|
|
@PostMapping("/auth")
|
|
|
public R<String> deviceAuth(@RequestBody HttpHeartbeatReq requestParam) {
|
|
|
- return smsbDeviceAuthService.deviceAuth(requestParam);
|
|
|
+ // 获取解密后内容
|
|
|
+ String decryptMessage = decryptAndEncryptHandlerPool.decryptMessage(requestParam.getData());
|
|
|
+ // 将字符串转成json
|
|
|
+ HttpHeartbeatReq decryptedRequest = JsonUtils.parseObject(decryptMessage, HttpHeartbeatReq.class);
|
|
|
+ R<String> response = smsbDeviceAuthService.deviceAuth(decryptedRequest);
|
|
|
+ if (response.getCode() == R.SUCCESS) {
|
|
|
+ String rspEncryptMessage = decryptAndEncryptHandlerPool.encryptMessage(response.getMsg());
|
|
|
+ return R.ok("SUCCESS", rspEncryptMessage);
|
|
|
+ }
|
|
|
+ return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -161,8 +215,15 @@ public class SmsbFrontController {
|
|
|
*/
|
|
|
@SaIgnore
|
|
|
@GetMapping("/task")
|
|
|
- public R<SmsbDeviceTaskVo> getDeviceTask(@RequestParam("identifier") String identifier,@RequestParam("taskType") Integer taskType) {
|
|
|
- return smsbDeviceTaskService.getDeviceTask(identifier,taskType);
|
|
|
+ public R<String> getDeviceTask(@RequestParam("identifier") String identifier,@RequestParam("taskType") String taskType) {
|
|
|
+ String decryptIdentifier = decryptAndEncryptHandlerPool.decryptMessage(identifier);
|
|
|
+ String decryptTaskType = decryptAndEncryptHandlerPool.decryptMessage(taskType);
|
|
|
+ R<SmsbDeviceTaskVo> response = smsbDeviceTaskService.getDeviceTask(decryptIdentifier,Integer.parseInt(decryptTaskType));
|
|
|
+ if (R.isSuccess(response) && null != response.getData()) {
|
|
|
+ String decryptData = decryptAndEncryptHandlerPool.encryptMessage(JsonUtils.toJsonString(response.getData()));
|
|
|
+ return R.ok("SUCCESS", decryptData);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -173,18 +234,20 @@ public class SmsbFrontController {
|
|
|
*/
|
|
|
@SaIgnore
|
|
|
@GetMapping("/task/status")
|
|
|
- public R<Void> uploadTaskStatus(@RequestParam("taskId") Long taskId,@RequestParam("taskStatus") Integer taskStatus) {
|
|
|
- SmsbDeviceTask smsbDeviceTask = smsbDeviceTaskMapper.selectById(taskId);
|
|
|
+ public R<Void> uploadTaskStatus(@RequestParam("taskId") String taskId,@RequestParam("taskStatus") String taskStatus) {
|
|
|
+ Long decryptTaskId = Long.parseLong(decryptAndEncryptHandlerPool.decryptMessage(taskId));
|
|
|
+ Integer decryptTaskStatus = Integer.parseInt(decryptAndEncryptHandlerPool.decryptMessage(taskStatus));
|
|
|
+ SmsbDeviceTask smsbDeviceTask = smsbDeviceTaskMapper.selectById(decryptTaskId);
|
|
|
// 如果是任务完成且为时间线更新任务
|
|
|
- if (taskStatus.equals(DeviceTaskConstants.DEVICE_TASK_STATUS_END)
|
|
|
+ if (decryptTaskStatus.equals(DeviceTaskConstants.DEVICE_TASK_STATUS_END)
|
|
|
&& smsbDeviceTask.getTaskType().equals(DeviceTaskConstants.DEVICE_TASK_PLAY_LINE_UPDATE)) {
|
|
|
smsbItemPushDeviceService.updateDevicePushStatus(3,smsbDeviceTask);
|
|
|
}
|
|
|
// 任务类型为OTA升级
|
|
|
if (smsbDeviceTask.getTaskType().equals(DeviceTaskConstants.DEVICE_TASK_OTA)) {
|
|
|
- iSmsbOtaRecordService.updateOtaStatus(smsbDeviceTask,taskStatus);
|
|
|
+ iSmsbOtaRecordService.updateOtaStatus(smsbDeviceTask,decryptTaskStatus);
|
|
|
}
|
|
|
- return smsbDeviceTaskService.uploadTaskStatus(taskId,taskStatus,smsbDeviceTask);
|
|
|
+ return smsbDeviceTaskService.uploadTaskStatus(decryptTaskId,decryptTaskStatus,smsbDeviceTask);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -195,7 +258,11 @@ public class SmsbFrontController {
|
|
|
@SaIgnore
|
|
|
@PostMapping("/multiCard")
|
|
|
public R<Void> uploadTaskStatus(@RequestBody FrontMultiCardUploadVo frontMultiCardUploadVo) {
|
|
|
- return smsbDeviceService.uploadMultiCard(frontMultiCardUploadVo);
|
|
|
+ // 获取解密后内容
|
|
|
+ String decryptMessage = decryptAndEncryptHandlerPool.decryptMessage(frontMultiCardUploadVo.getData());
|
|
|
+ // 将字符串转成json
|
|
|
+ FrontMultiCardUploadVo multiCardUploadVo = JsonUtils.parseObject(decryptMessage, FrontMultiCardUploadVo.class);
|
|
|
+ return smsbDeviceService.uploadMultiCard(multiCardUploadVo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -205,8 +272,14 @@ public class SmsbFrontController {
|
|
|
*/
|
|
|
@SaIgnore
|
|
|
@PostMapping("/chat/config/{identifier}")
|
|
|
- public R<SmsbDeviceChatKeyVo> getChatConfig(@PathVariable("identifier")String identifier) {
|
|
|
- return smsbDeviceChatKeyService.getChatConfig(identifier);
|
|
|
+ public R<String> getChatConfig(@PathVariable("identifier")String identifier) {
|
|
|
+ String decryptIdentifier = decryptAndEncryptHandlerPool.decryptMessage(identifier);
|
|
|
+ R<SmsbDeviceChatKeyVo> response = smsbDeviceChatKeyService.getChatConfig(decryptIdentifier);
|
|
|
+ if (R.isSuccess(response) && null != response.getData()) {
|
|
|
+ String decryptData = decryptAndEncryptHandlerPool.encryptMessage(JsonUtils.toJsonString(response.getData()));
|
|
|
+ return R.ok("SUCCESS", decryptData);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -222,7 +295,7 @@ public class SmsbFrontController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 前端设备人流量上报
|
|
|
+ * 前端设备 日志抓取上报
|
|
|
*
|
|
|
* @param identifier
|
|
|
* @param file
|
|
|
@@ -230,7 +303,8 @@ public class SmsbFrontController {
|
|
|
@SaIgnore
|
|
|
@PostMapping("/deviceLog/upload")
|
|
|
public R<Void> deviceLogUpload(@RequestParam("identifier") String identifier,@RequestBody MultipartFile file) {
|
|
|
- return smsbDeviceLogPushService.deviceLogUpload(identifier,file);
|
|
|
+ String decryptIdentifier = decryptAndEncryptHandlerPool.decryptMessage(identifier);
|
|
|
+ return smsbDeviceLogPushService.deviceLogUpload(decryptIdentifier,file);
|
|
|
}
|
|
|
|
|
|
}
|