Parcourir la source

Merge remote-tracking branch 'origin/demo_' into demo_

il y a 2 ans
Parent
commit
5152bab02e

+ 7 - 0
platform-dao/src/main/java/com/platform/dao/dto/remote/RemoteOpcDTO.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
+import javax.persistence.Transient;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -202,4 +203,10 @@ public class RemoteOpcDTO extends BaseDTO implements Serializable {
      */
     private String keyword;
 
+    @Transient
+    private Integer searchDay;
+    @Transient
+    private LocalDateTime startTime;
+    @Transient
+    private LocalDateTime endTime;
 }

+ 2 - 1
platform-dao/src/main/java/com/platform/dao/influxdb/InfluxDBService.java

@@ -1,6 +1,7 @@
 package com.platform.dao.influxdb;
 
 import com.influxdb.query.FluxTable;
+import com.platform.dao.dto.remote.RemoteOpcDTO;
 import com.platform.dao.vo.query.remote.RemoteOpcVO;
 
 import java.time.LocalDateTime;
@@ -18,5 +19,5 @@ public interface InfluxDBService {
 
     void delete(LocalDateTime start, LocalDateTime stop);
 
-    RemoteOpcVO select(String id, Integer type);
+    RemoteOpcVO select(RemoteOpcDTO remoteOpcDTO);
 }

+ 27 - 17
platform-dao/src/main/java/com/platform/dao/influxdb/impl/InfluxDBServiceImpl.java

@@ -12,6 +12,7 @@ import com.influxdb.query.FluxTable;
 import com.platform.common.exception.BusinessException;
 import com.platform.common.util.BeanConverterUtil;
 import com.platform.common.util.DateUtils;
+import com.platform.dao.dto.remote.RemoteOpcDTO;
 import com.platform.dao.entity.remote.RemoteOpc;
 import com.platform.dao.influxdb.InfluxDBService;
 import com.platform.dao.influxdb.builder.InfluxDbBuilder;
@@ -102,39 +103,48 @@ public class InfluxDBServiceImpl implements InfluxDBService {
     /**
      * 查询数据: 查询某个点位,某个时间段的数据*,表格数据,图表数据
      *
-     * @param id   positionNum值
-     * @param type 1: 5分钟
      */
     @Override
-    public RemoteOpcVO select(String id, Integer type) {
-        RemoteOpc remoteOpc = remoteOpcMapper.selectByPrimaryKey(id);
+    public RemoteOpcVO select(RemoteOpcDTO remoteOpcDTO) {
+        RemoteOpc remoteOpc = remoteOpcMapper.selectByPrimaryKey(remoteOpcDTO.getId());
         RemoteOpcVO vo = BeanConverterUtil.copyObjectProperties(remoteOpc, RemoteOpcVO.class);
         StringBuffer stringBuilder = new StringBuffer();
+        if(remoteOpcDTO.getStartTime() == null){
+            throw new BusinessException("请选择查询开始时间");
+        }
+        if(remoteOpcDTO.getEndTime() == null){
+            throw new BusinessException("请选择查询截止时间");
+        }
+        if(remoteOpcDTO.getEndTime().isAfter(LocalDateTime.now())){
+            throw new BusinessException("截止时间不能晚于当前系统时间");
+        }
         try {
-
-            LocalDateTime start = LocalDateTime.now().minusHours(8);
-            LocalDateTime stop = LocalDateTime.now().minusHours(8);
+            LocalDateTime start = remoteOpcDTO.getStartTime().minusHours(8);
+            LocalDateTime stop = remoteOpcDTO.getEndTime().minusHours(8);
+            /*Integer type = remoteOpcDTO.getSearchDay();
             if (type == 1) {// 5分钟
                 start = start.minusMinutes(5);
-            } else if (type == 2) {// 5分钟
+            } else if (type == 2) {// 15分钟
                 start = start.minusMinutes(15);
-            }else if (type == 3) {// 5分钟
+            }else if (type == 3) {// 1小时
                 start = start.minusHours(1);
-            }else if (type == 4) {// 5分钟
+            }else if (type == 4) {// 3小时
                 start = start.minusHours(3);
-            }else if (type == 5) {// 5分钟
+            }else if (type == 5) {// 6小时
                 start = start.minusHours(6);
-            }else if (type == 6) {// 5分钟
+            }else if (type == 6) {// 12小时
                 start = start.minusHours(12);
-            }else if (type == 7) {// 5分钟
+            }else if (type == 7) {// 24小时
                 start = start.minusHours(24);
-            }else if (type == 8) {// 5分钟
+            }else if (type == 8) {// 2天
                 start = start.minusDays(2);
-            }else if (type == 9) {// 5分钟
+            }else if (type == 9) {// 7天
                 start = start.minusDays(7);
-            }else{
+            }else if (type == 10) {// 30天
                 start = start.minusDays(30);
-            }
+            }else{// 1年
+                start = start.minusYears(1);
+            }*/
             InfluxDBFluxExpression.appendCommonFlux(stringBuilder, InfluxDBFluxExpression.bucket, InfluxDBFluxExpression.measurement, DateUtils.localDateTimeToUTC(start), DateUtils.localDateTimeToUTC(stop));
         } catch (ParseException e) {
             e.printStackTrace();

+ 3 - 0
platform-dao/src/main/resources/mapper/repair/RepairApplicationFormMapper.xml

@@ -113,6 +113,9 @@
             <if test="reportLeaderId != null and reportLeaderId != ''">
                 and application.report_leader_id = #{reportLeaderId}
             </if>
+            <if test="sbPositionId != null and sbPositionId != ''">
+                and sb.position_id = #{sbPositionId}
+            </if>
         </where>
     </select>
     <select id="selectById" parameterType="java.lang.Object"

+ 8 - 8
platform-rest/src/main/java/com/platform/rest/controller/influxdb/InfluxDBController.java

@@ -101,23 +101,23 @@ public class InfluxDBController {
     /**
      * 通过positionNum查询数据历史记录
      *
-     * @param id 主键
+     * @param remoteOpcDTO
      * @return R
      */
-    @GetMapping("/{id}/{type}")
-    public R<RemoteOpcVO> getById(@PathVariable("id") String id, @PathVariable("type") Integer type) {
-        return new R<>(influxDBService.select(id, type));
+    @GetMapping("/select")
+    public R<RemoteOpcVO> select(RemoteOpcDTO remoteOpcDTO) {
+        return new R<>(influxDBService.select(remoteOpcDTO));
     }
 
     /**
      * opc记录表导出-导出某个点位的某个时间段数据
      * @return R
      */
-    @GetMapping("/export/{id}/{type}")
-    @SysLog("opc导出某个点位的某天数据")
+    @GetMapping("/export")
+    @SysLog("opc导出某个点位的数据")
     @PreAuthorize("@pms.hasPermission('remote-opc-logs-export')")
-    public void exportOneDay(HttpServletResponse response, @PathVariable("id") String id, @PathVariable("type") Integer type) {
-        RemoteOpcVO vo = influxDBService.select(id, type);
+    public void exportOneDay(HttpServletResponse response, RemoteOpcDTO remoteOpcDTO) {
+        RemoteOpcVO vo = influxDBService.select(remoteOpcDTO);
         String str = vo.getDataJsonStr();
         JSONArray array = JSONArray.parseArray(str);
         List<ExportRemoteOpcLogOneDayVO> list = new ArrayList<>();

+ 1 - 1
platform-service/src/main/java/com/platform/service/repair/strategy/impl/LongYanRepairStrategy.java

@@ -1145,7 +1145,7 @@ public class LongYanRepairStrategy extends AbstractRepairBaseStrategy {
         String detailUrl = "pages/service-detail/service-detail?id=" + form.getId();
         switch (type){
             case CommonConstants.CALL_REPAIR_NOTICE:
-                values = new String[]{"有一条新的报修消息!",form.getNo(),sbInfo.getName(),form.getContent(),form.getSbCph(),"请知悉"};
+                values = new String[]{"有一条新的报修消息!",form.getNo(),sbInfo.getPositionNo() + "【" + sbInfo.getName() + "】",form.getContent(),form.getSbCph(),"请知悉"};
                 break;
             case CommonConstants.REPAIR_FAIL_NOTICE:
                 values = new String[]{"维修单终止维修消息!",form.getNo(),sbInfo.getName(),form.getContent(),form.getSbCph(),"请再次派工"};