| 
					
				 | 
			
			
				@@ -0,0 +1,82 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package org.springblade.manager.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.json.JSONUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.druid.support.json.JSONUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.nacos.common.utils.MD5Utils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springblade.core.tool.jackson.JsonUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springblade.manager.entity.QProfilerOffset; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springblade.manager.entity.profiler.ProfilerResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springblade.manager.entity.profiler.ProfilerSaveDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springblade.manager.service.QProfilerOffsetService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springblade.manager.mapper.QProfilerOffsetMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.multipart.MultipartFile; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.time.Instant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+* @author LHB 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+* @description 针对表【q_profiler_offset(断面仪-基础信息+测量者信息)】的数据库操作Service实现 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+* @createDate 2025-10-27 15:58:56 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class QProfilerOffsetServiceImpl extends ServiceImpl<QProfilerOffsetMapper, QProfilerOffset> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    implements QProfilerOffsetService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //第三方的appKey 固定值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private final static  String APP_KEY = "QDM123"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //第三方密钥 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private final static  String APP_SECRET = "MDc1YWI4OTMtY2M0NC00NDViLTlkZmUtYzAzZTVmZTUxMmE1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 时间戳有效期(秒),防止重放攻击 // 5分钟 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final long TIMESTAMP_EXPIRE = 300; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ProfilerResult save(ProfilerSaveDTO save, MultipartFile file) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!save.getAppKey().equals(APP_KEY)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ProfilerResult.error("10006","appKey错误",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String s = MD5Utils.md5Hex(APP_KEY + save.getTimestamp() + APP_SECRET, "UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!s.equals(save.getSign())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ProfilerResult.error("10007","sign错误",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!isValidTimestamp(save.getTimestamp())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ProfilerResult.error("10008","签名验证失败:timeTicks的时间和当前时间必须小于30分钟",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //断面仪测量设备编码或名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String deviceCode = save.getDeviceCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //字符串转json 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        JSONObject jsonObject = JSONUtil.parseObj(deviceCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取基础信息 + 测量者信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println(save); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 验证时间戳有效性 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param timestamp 时间戳字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 是否有效 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static boolean isValidTimestamp(Long timestamp) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            long currentTs = Instant.now().getEpochSecond(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 检查时间戳是否在有效期内(前后5分钟) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return Math.abs(currentTs - timestamp) <= TIMESTAMP_EXPIRE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (NumberFormatException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static void main(String[] args) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println(MD5Utils.md5Hex("QDM123" + 1761554359 + "MDc1YWI4OTMtY2M0NC00NDViLTlkZmUtYzAzZTVmZTUxMmE1", "UTF-8")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 |