Browse Source

Merge branch 'server-165' of http://47.111.81.118:3000/uskycloud/usky-modules into fu-dev

fuyuhchuan 1 year ago
parent
commit
851f4195ef

+ 10 - 5
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/controller/api/patrolAgboxControllerApi.java

@@ -3,6 +3,7 @@ package com.usky.agbox.controller.api;
 import com.alibaba.fastjson.JSONObject;
 import com.usky.agbox.RemotePatrolAgBoxService;
 import com.usky.agbox.service.job.patrolAgbox;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -12,28 +13,32 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 public class patrolAgboxControllerApi implements RemotePatrolAgBoxService {
+
+    @Autowired
+    private patrolAgbox agBox;
+
     @Override
     public JSONObject getEventCode() {
-        return patrolAgbox.getEventCode();
+        return agBox.getEventCode();
     }
 
     @Override
     public JSONObject getDeviceList() {
-        return patrolAgbox.getDeviceList();
+        return agBox.getDeviceList();
     }
 
     @Override
     public JSONObject updateHeart(@RequestBody String requestBody){
-        return patrolAgbox.updateHeart(requestBody);
+        return agBox.updateHeart(requestBody);
     }
 
     @Override
     public JSONObject addEvent(@RequestBody String requestBody){
-        return patrolAgbox.addEvent(requestBody);
+        return agBox.addEvent(requestBody);
     }
 
     @Override
     public JSONObject getEvent(@RequestBody String requestBody){
-        return patrolAgbox.getEvent(requestBody);
+        return agBox.getEvent(requestBody);
     }
 }

+ 10 - 5
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/controller/web/patrolAgboxController.java

@@ -4,6 +4,7 @@ package com.usky.agbox.controller.web;
 import com.alibaba.fastjson.JSONObject;
 import com.usky.agbox.service.job.patrolAgbox;
 import com.usky.common.core.bean.ApiResult;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -16,13 +17,17 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/patrolAgbox")
 public class patrolAgboxController {
+
+    @Autowired
+    private patrolAgbox agBox;
+
     /**
      * 获取事件编码信息
      * @return
      */
     @PostMapping("/getEventCode")
     public ApiResult<JSONObject> getEventCode(){
-        return ApiResult.success(patrolAgbox.getEventCode());
+        return ApiResult.success(agBox.getEventCode());
     }
 
     /**
@@ -31,7 +36,7 @@ public class patrolAgboxController {
      */
     @PostMapping("/getDeviceList")
     public ApiResult<JSONObject> getDeviceList(){
-        return ApiResult.success(patrolAgbox.getDeviceList());
+        return ApiResult.success(agBox.getDeviceList());
     }
 
     /**
@@ -40,7 +45,7 @@ public class patrolAgboxController {
      */
     @PostMapping("/addEvent")
     public ApiResult<JSONObject> addEvent(@RequestBody String requestBody){
-        return ApiResult.success(patrolAgbox.addEvent(requestBody));
+        return ApiResult.success(agBox.addEvent(requestBody));
     }
 
     /**
@@ -49,7 +54,7 @@ public class patrolAgboxController {
      */
     @PostMapping("/updateHeart")
     public ApiResult<JSONObject> updateHeart(@RequestBody String requestBody){
-        return ApiResult.success(patrolAgbox.updateHeart(requestBody));
+        return ApiResult.success(agBox.updateHeart(requestBody));
     }
 
     /**
@@ -58,6 +63,6 @@ public class patrolAgboxController {
      */
     @PostMapping("/getEvent")
     public ApiResult<JSONObject> getEvent(@RequestBody String requestBody){
-        return ApiResult.success(patrolAgbox.getEvent(requestBody));
+        return ApiResult.success(agBox.getEvent(requestBody));
     }
 }

+ 12 - 8
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/service/job/patrolAgbox.java

@@ -2,19 +2,23 @@ package com.usky.agbox.service.job;
 
 import com.alibaba.fastjson.JSONObject;
 import com.usky.agbox.service.util.HttpClientUtils;
-
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
 import java.util.HashMap;
 
+@Component
 public class patrolAgbox {
 
-    private static String KEY = "44c2710b-f7ff-4487-a556-bfae08232a09";
-    private static String URL = "http://172.16.120.245/agbox/device/patrol";
+    @Value("${agBox.key}")
+    private String KEY;
+    @Value("${agBox.url}")
+    private String URL;
 
     /**
      * 获取事件编码信息
      * @return
      */
-    public static JSONObject getEventCode() {
+    public JSONObject getEventCode() {
         HashMap map = new HashMap();
         map.put("key", KEY);
         map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"getPatrolEventCode\"}");
@@ -27,7 +31,7 @@ public class patrolAgbox {
      * 获取设备列表信息
      * @return
      */
-    public static JSONObject getDeviceList() {
+    public JSONObject getDeviceList() {
         HashMap map = new HashMap();
         map.put("key", KEY);
         map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"getDeviceList\"}");
@@ -40,7 +44,7 @@ public class patrolAgbox {
      * 添加事件信息
      * @return
      */
-    public static JSONObject addEvent(String requestBody) {
+    public JSONObject addEvent(String requestBody) {
         JSONObject eventVO = JSONObject.parseObject(requestBody);
         HashMap map = new HashMap();
         map.put("key", KEY);
@@ -56,7 +60,7 @@ public class patrolAgbox {
      * 更新心跳信息
      * @return
      */
-    public static JSONObject updateHeart(String requestBody) {
+    public JSONObject updateHeart(String requestBody) {
         JSONObject eventVO = JSONObject.parseObject(requestBody);
         HashMap map = new HashMap();
         map.put("key", KEY);
@@ -71,7 +75,7 @@ public class patrolAgbox {
      * 获取事件信息
      * @return
      */
-    public static JSONObject getEvent(String requestBody) {
+    public JSONObject getEvent(String requestBody) {
         JSONObject eventVO = JSONObject.parseObject(requestBody);
         HashMap map = new HashMap();
         map.put("key", KEY);

+ 13 - 2
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionAttendanceServiceImpl.java

@@ -19,10 +19,12 @@ import com.usky.fire.service.PatrolInspectionPersonnelService;
 import com.usky.fire.service.PatrolInspectionTypeService;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import com.usky.system.RemoteDeptService;
 
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -53,6 +55,10 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
 
     @Autowired
     private RemotePatrolAgBoxService remotePatrolAgboxService;
+
+    @Value("${agBox.push}")
+    private Integer pushFlag;
+
     @Override
     public IPage<Map<String, Object>> pageList(Integer pageNum, Integer pageSize, String operateCode, String operator, LocalDateTime startTime, LocalDateTime endTime) {
         IPage<PatrolInspectionAttendance> page = new Page<>(pageNum, pageSize);
@@ -132,7 +138,10 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
         patrolInspectionPersonnelService.updateSignStatus(patrolInspectionAttendance.getSignInType());
         JSONObject jsonObj = new JSONObject();
         jsonObj.put("deviceId", patrolInspectionAttendance.getDeviceCode());
-        jsonObj.put("triggerTime", LocalDateTime.now());
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String formattedTime = now.format(formatter);
+        jsonObj.put("triggerTime", formattedTime);
         Integer eventCode = 17;
         if(patrolInspectionAttendance.getSignInType().equals(0)){
             eventCode=1;
@@ -142,7 +151,9 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
         jsonObj.put("eventCode", eventCode);
         jsonObj.put("name", SecurityUtils.getUsername());
         jsonObj.put("certifiedNo", patrolInspectionAttendance.getIdentificationNumber());
-        JSONObject a = remotePatrolAgboxService.addEvent(jsonObj.toJSONString());
+        if (pushFlag.equals(1)){
+            JSONObject a = remotePatrolAgboxService.addEvent(jsonObj.toJSONString());
+        }
     }
 
     /**

+ 7 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/BaseAppInfoServiceImpl.java

@@ -8,6 +8,7 @@ import com.usky.iot.mapper.BaseAppInfoMapper;
 import com.usky.iot.service.BaseAppInfoService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.web.context.request.RequestAttributes;
 import org.springframework.web.context.request.RequestContextHolder;
@@ -30,6 +31,9 @@ public class BaseAppInfoServiceImpl extends AbstractCrudService<BaseAppInfoMappe
     @Autowired
     private RemotePatrolAgBoxService remotePatrolAgboxService;
 
+    @Value("${agBox.push}")
+    private Integer pushFlag;
+
     public String getIpAddress(HttpServletRequest request) {
         String ip = request.getHeader("X-Forwarded-For");
         if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
@@ -57,7 +61,6 @@ public class BaseAppInfoServiceImpl extends AbstractCrudService<BaseAppInfoMappe
     public void add(BaseAppInfo baseAppInfo){
         JSONObject jsonObj = new JSONObject();
         jsonObj.put("deviceId", baseAppInfo.getDeviceId());
-        JSONObject a = remotePatrolAgboxService.updateHeart(jsonObj.toJSONString());
 //        baseAppInfo.setNetworkService(a.toJSONString());
         HttpServletRequest request = getHttpServletRequest();
         String accessIp = getIpAddress(request);
@@ -66,5 +69,8 @@ public class BaseAppInfoServiceImpl extends AbstractCrudService<BaseAppInfoMappe
         baseAppInfo.setCreateTime(LocalDateTime.now());
         baseAppInfo.setTenantId(SecurityUtils.getTenantId());
         this.save(baseAppInfo);
+        if (pushFlag.equals(1)){
+            JSONObject a = remotePatrolAgboxService.updateHeart(jsonObj.toJSONString());
+        }
     }
 }