| 
					
				 | 
			
			
				@@ -1,12 +1,30 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ruoyi.web.controller.plugin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.ccb.domain.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.ccb.domain.basic.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ruoyi.ccb.service.CcbHttpService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.common.constant.CcbConstants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.common.core.domain.AjaxResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.common.utils.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.common.utils.JsonUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.common.utils.ShaUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ruoyi.framework.web.domain.server.Sys; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.AllArgsConstructor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import okhttp3.OkHttpClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import okhttp3.Request; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.interceptor.TransactionAspectSupport; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * CCB接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -15,9 +33,9 @@ import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @AllArgsConstructor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @RequestMapping("/ccb") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-public class CcbController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class CcbController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//    private final CcbHttpService ccbHttpService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //    private final CcbHttpService ccbHttpService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private CcbHttpService ccbHttpService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -94,8 +112,7 @@ public class CcbController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostMapping("/syncOrg") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public Page syncOrg(@RequestBody SyncOrg syncOrg) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Page syncOrg(@RequestBody SyncOrg syncOrg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ccbHttpService.syncOrg(syncOrg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -195,8 +212,7 @@ public class CcbController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostMapping("/listAllDevices") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public Devices listAllDevices(@RequestBody Devices devices) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Devices listAllDevices(@RequestBody Devices devices) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ccbHttpService.listAllDevices(devices); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -207,8 +223,7 @@ public class CcbController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/findDeviceById") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public DeviceDetail findDeviceById(@RequestParam(value = "deviceId") String deviceId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public DeviceDetail findDeviceById(@RequestParam(value = "deviceId") String deviceId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ccbHttpService.findDeviceById(deviceId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -219,8 +234,7 @@ public class CcbController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostMapping("/findDevicesByStorage") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public Devices findDevicesByStorage(@RequestBody DevicesByStorage devicesByStorage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Devices findDevicesByStorage(@RequestBody DevicesByStorage devicesByStorage) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ccbHttpService.findDevicesByStorage(devicesByStorage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -231,8 +245,7 @@ public class CcbController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/findDeviceData") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public FindDeviceData findDeviceData(@RequestParam(value = "deviceId") String deviceId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public FindDeviceData findDeviceData(@RequestParam(value = "deviceId") String deviceId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ccbHttpService.findDeviceData(deviceId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -243,9 +256,82 @@ public class CcbController{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostMapping("/findDeviceHistoryData") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public FindDeviceData findDeviceHistoryData(@RequestBody HistoryData historyData) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public FindDeviceData findDeviceHistoryData(@RequestBody HistoryData historyData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ccbHttpService.findDeviceHistoryData(historyData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 设备异常告警 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("/deviceAlarm") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxResult deviceAlarm() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date date = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String time = simpleDateFormat.format(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DeviceAlarm deviceAlarm = new DeviceAlarm(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceAlarm.setReqUser("涂宝"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<DeviceException> deviceExceptionList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DeviceException deviceException = new DeviceException(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setWarehouseName("630号 "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setWarehouseNo("630号"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setShelvesName("黄岛区"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setBTypeName("设备异常"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setBType("异常"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setReMark("设备连接异常"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setETime(time); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setElectronicTag("0101"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<DevicesDetail> devicesDetailList = DevicesDetail.date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceException.setDeviceInfo(devicesDetailList.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceExceptionList.add(deviceException); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deviceAlarm.setDeviceException(deviceExceptionList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println("请求内容:"+JsonUtil.toJson(deviceAlarm)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String requestTime = DateUtils.dateTimeNow() + (Math.random() * 9 + 1) * 100000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 签名内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String str = "appId=" + CcbConstants.APP_ID + "&" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                + "secretKey=" + CcbConstants.SECRET_KEY + "&" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                + "platformId=" + CcbConstants.PLATFORM_ID + "&" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                + "requestTime=" + requestTime + "&" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                + "body=" + JsonUtil.toJson(deviceAlarm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OkHttpClient okHttpClient = new OkHttpClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Request request = new Request.Builder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .addHeader("content-type", "application/json") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .addHeader("X-RC-AppId", CcbConstants.APP_ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .addHeader("X-RC-Sign", ShaUtil.sha256(str)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .addHeader("X-RC-SignType", "SHA256") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .addHeader("X-RC-RequestTime", requestTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .addHeader("X-RC-RLF-Uid", CcbConstants.PLATFORM_ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .url(CcbConstants.DEVICE_ALARM) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .post(okhttp3.RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), JsonUtil.toJson(deviceAlarm))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String s; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            s = Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            System.out.println("请求成功返回信息:"+s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return AjaxResult.error("请求银行反馈异常," + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        JSONObject result = JSON.parseObject(s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!CcbConstants.SUCCESS.equals(result.getString("result"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return AjaxResult.error("请求银行反馈失败," + result.getString("reason")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return AjaxResult.success("成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |