| 
					
				 | 
			
			
				@@ -0,0 +1,74 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.ozs.controller.upload; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.core.domain.AjaxResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.core.domain.Result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.common.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.framework.web.service.TokenService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.system.domain.vo.ReqMsgAlarmVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.system.domain.vo.RespGeoHazardMonitorVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ozs.system.domain.vo.RespMsgAlarmVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.PostMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.RequestBody; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.RequestParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.bind.annotation.RestController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 1. 获取身份认证控制层 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @author Administrator 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class GeoHazardMonitorTokenController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TokenService tokenService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 获取访问令牌 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param grantType    授权类型,客户端模式(client_credentials) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param clientId     客户端编号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param clientSecret 客户端密钥 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("/IPAddress/token") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Result login(@RequestParam("grantType") String grantType, @RequestParam("clientId") String clientId, @RequestParam("clientSecret") String clientSecret) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 生成令牌 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ArrayList<String> objects = tokenService.createGeoHazardMonitorToken(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (objects.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            RespGeoHazardMonitorVo respGeoHazardMonitorVo = new RespGeoHazardMonitorVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            respGeoHazardMonitorVo.setAccessToken(objects.get(1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            respGeoHazardMonitorVo.setExpiresIn(Long.valueOf(objects.get(0))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            respGeoHazardMonitorVo.setTokenType("令牌类型"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new Result(1, "成功", respGeoHazardMonitorVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new Result(2, "失败", "生成token失败!!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 数据传输 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param reqMsgAlarmVo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PostMapping("/IPAddress/alarm") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Result login(@RequestBody ReqMsgAlarmVo reqMsgAlarmVo, HttpServletRequest request) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 生成令牌 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String token = tokenService.getGeoHazardMonitorToken(request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtils.isNotEmpty(token)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            RespMsgAlarmVo respMsgAlarmVo = new RespMsgAlarmVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            respMsgAlarmVo.setAlarmId(reqMsgAlarmVo.getAlarmId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            respMsgAlarmVo.setAlarmCamera(reqMsgAlarmVo.getAlarmCamera()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            respMsgAlarmVo.setCancelTime(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            respMsgAlarmVo.setIsCancel(reqMsgAlarmVo.getIsLock()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new Result(1, "成功", respMsgAlarmVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return new Result(2, "失败", "生成token失败!!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |