459242451@qq.com 3 年之前
父節點
當前提交
205c9fa778

+ 35 - 31
ruoyi-admin/src/main/java/com/ruoyi/web/controller/qdtl/TlInspectionLocationController.java

@@ -1,56 +1,63 @@
 package com.ruoyi.web.controller.qdtl;
 
-import java.util.ArrayList;
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.StrUtil;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.qdtl.domain.TlArea;
 import com.ruoyi.qdtl.domain.TlInspectionDevice;
+import com.ruoyi.qdtl.domain.TlInspectionLocation;
+import com.ruoyi.qdtl.service.ITlAreaService;
 import com.ruoyi.qdtl.service.ITlInspectionDeviceService;
-import org.springframework.security.access.prepost.PreAuthorize;
+import com.ruoyi.qdtl.service.ITlInspectionLocationService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.common.annotation.Log;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.qdtl.domain.TlInspectionLocation;
-import com.ruoyi.qdtl.service.ITlInspectionLocationService;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 巡检点管理Controller
- * 
+ *
  * @author ruoyi
  * @date 2022-02-22
  */
 @RestController
 @RequestMapping("/qdtl/location")
-public class TlInspectionLocationController extends BaseController
-{
+public class TlInspectionLocationController extends BaseController {
     @Autowired
     private ITlInspectionLocationService tlInspectionLocationService;
     @Autowired
     private ITlInspectionDeviceService tlInspectionDeviceService;
+    @Autowired
+    private ITlAreaService tlAreaService;
 
     /**
      * 查询巡检点管理列表
      */
     @PreAuthorize("@ss.hasPermi('qdtl:location:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TlInspectionLocation tlInspectionLocation)
-    {
+    public TableDataInfo list(TlInspectionLocation tlInspectionLocation) {
         startPage();
         List<TlInspectionLocation> list = tlInspectionLocationService.selectTlInspectionLocationList(tlInspectionLocation);
+        // 查询区域数据
+        List<TlArea> areas = tlAreaService.selectTlAreaList(new TlArea());
+        Map<Long, String> areaCollect = areas.stream().collect(Collectors.toMap(TlArea::getId, TlArea::getAreaName));
 
         for (TlInspectionLocation inspectionLocation : list) {
             List<TlInspectionDevice> devices = new ArrayList<>();
@@ -64,6 +71,8 @@ public class TlInspectionLocationController extends BaseController
                 }
             }
             inspectionLocation.setDeviceNames(devices);
+            inspectionLocation.setDeviceNamesText(devices.stream().map(TlInspectionDevice::getDeviceName).collect(Collectors.joining(",")));
+            inspectionLocation.setAreaName(areaCollect.getOrDefault(inspectionLocation.getAreaId(), ""));
         }
         return getDataTable(list);
     }
@@ -74,8 +83,7 @@ public class TlInspectionLocationController extends BaseController
     @PreAuthorize("@ss.hasPermi('qdtl:location:export')")
     @Log(title = "巡检点管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, TlInspectionLocation tlInspectionLocation)
-    {
+    public void export(HttpServletResponse response, TlInspectionLocation tlInspectionLocation) {
         List<TlInspectionLocation> list = tlInspectionLocationService.selectTlInspectionLocationList(tlInspectionLocation);
         ExcelUtil<TlInspectionLocation> util = new ExcelUtil<TlInspectionLocation>(TlInspectionLocation.class);
         util.exportExcel(response, list, "巡检点管理数据");
@@ -86,8 +94,7 @@ public class TlInspectionLocationController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('qdtl:location:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return AjaxResult.success(tlInspectionLocationService.selectTlInspectionLocationById(id));
     }
 
@@ -97,8 +104,7 @@ public class TlInspectionLocationController extends BaseController
     @PreAuthorize("@ss.hasPermi('qdtl:location:add')")
     @Log(title = "巡检点管理", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TlInspectionLocation tlInspectionLocation)
-    {
+    public AjaxResult add(@RequestBody TlInspectionLocation tlInspectionLocation) {
         return toAjax(tlInspectionLocationService.insertTlInspectionLocation(tlInspectionLocation));
     }
 
@@ -108,8 +114,7 @@ public class TlInspectionLocationController extends BaseController
     @PreAuthorize("@ss.hasPermi('qdtl:location:edit')")
     @Log(title = "巡检点管理", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TlInspectionLocation tlInspectionLocation)
-    {
+    public AjaxResult edit(@RequestBody TlInspectionLocation tlInspectionLocation) {
         return toAjax(tlInspectionLocationService.updateTlInspectionLocation(tlInspectionLocation));
     }
 
@@ -118,9 +123,8 @@ public class TlInspectionLocationController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('qdtl:location:remove')")
     @Log(title = "巡检点管理", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(tlInspectionLocationService.deleteTlInspectionLocationByIds(ids));
     }
 }

+ 8 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/XunTask.java

@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.task;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
@@ -128,7 +129,13 @@ public class XunTask {
         if (maxDate == null) {
             startTime = DateUtil.offsetDay(new Date(), -20).getTime();
         } else {
-            startTime = DateUtil.offsetSecond(maxDate, 1).getTime();
+            // 判断最后的日期和当前是否大于1个月
+            long between = DateUtil.between(maxDate, new Date(), DateUnit.DAY);
+            if (between >= 30) {
+                startTime = DateUtil.offsetDay(new Date(), -29).getTime();
+            } else {
+                startTime = DateUtil.offsetSecond(maxDate, 1).getTime();
+            }
         }
         JSONArray checkpointLogs = qdCommonService.getCheckpointLog(startTime, endTime);
         if (checkpointLogs != null && checkpointLogs.size() > 0) {

+ 8 - 8
ruoyi-admin/src/main/resources/logback.xml

@@ -18,8 +18,8 @@
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
             <!-- 日志文件名格式 -->
             <fileNamePattern>${log.path}/sys-console.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大 1天 -->
-            <maxHistory>1</maxHistory>
+            <!-- 日志最大 2天 -->
+            <maxHistory>2</maxHistory>
         </rollingPolicy>
         <encoder>
             <pattern>${log.pattern}</pattern>
@@ -79,19 +79,19 @@
     </appender>
 
     <!-- 用户访问日志输出  -->
-    <appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
+    <!--<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
         <file>${log.path}/sys-user.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
-            <!-- 按天回滚 daily -->
+            &lt;!&ndash; 按天回滚 daily &ndash;&gt;
             <fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
+            &lt;!&ndash; 日志最大的历史 60天 &ndash;&gt;
             <maxHistory>60</maxHistory>
             <maxFileSize>20MB</maxFileSize>
         </rollingPolicy>
         <encoder>
             <pattern>${log.pattern}</pattern>
         </encoder>
-    </appender>
+    </appender>-->
 
     <!-- 系统模块日志级别控制  -->
     <logger name="com.ruoyi" level="info"/>
@@ -109,7 +109,7 @@
     </root>
 
     <!--系统用户操作日志-->
-    <logger name="sys-user" level="info">
+    <!--<logger name="sys-user" level="info">
         <appender-ref ref="sys-user"/>
-    </logger>
+    </logger>-->
 </configuration> 

+ 20 - 0
ruoyi-system/src/main/java/com/ruoyi/qdtl/domain/TlInspectionLocation.java

@@ -49,12 +49,16 @@ public class TlInspectionLocation extends BaseEntity {
 
     private List<TlInspectionDevice> deviceNames;
 
+    private String deviceNamesText;
+
     /**
      * 所属区域
      */
     @Excel(name = "所属区域")
     private Long areaId;
 
+    private String areaName;
+
     /**
      * 经纬度
      */
@@ -203,4 +207,20 @@ public class TlInspectionLocation extends BaseEntity {
     public void setLocationId(Long locationId) {
         this.locationId = locationId;
     }
+
+    public String getAreaName() {
+        return areaName;
+    }
+
+    public void setAreaName(String areaName) {
+        this.areaName = areaName;
+    }
+
+    public String getDeviceNamesText() {
+        return deviceNamesText;
+    }
+
+    public void setDeviceNamesText(String deviceNamesText) {
+        this.deviceNamesText = deviceNamesText;
+    }
 }