Explorar o código

新增巡检异常记录导出接口

zhaojinyu hai 15 horas
pai
achega
baae54f311

+ 34 - 2
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionAbnormalController.java

@@ -1,20 +1,24 @@
 package com.usky.fire.controller.web;
 
 
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
 import com.usky.common.core.bean.ApiResult;
 import com.usky.common.core.bean.CommonPage;
+import com.usky.common.log.annotation.Log;
+import com.usky.common.log.enums.BusinessType;
 import com.usky.fire.domain.PatrolInspectionAbnormal;
 import com.usky.fire.domain.PatrolInspectionRecord;
 import com.usky.fire.domain.PatrolInspectionRoute;
 import com.usky.fire.service.PatrolInspectionAbnormalService;
+import com.usky.fire.service.vo.PatrolInspectionAbnormalExportVo;
 import com.usky.fire.service.vo.PatrolInspectionAbnormalVo;
 import com.usky.fire.service.vo.PatrolInspectionRecordVo;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import org.springframework.stereotype.Controller;
-
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -56,5 +60,33 @@ public class PatrolInspectionAbnormalController {
     public ApiResult<List<PatrolInspectionAbnormalVo>> recordDetails(@RequestParam(value = "id") Integer id) {
         return ApiResult.success(patrolInspectionAbnormalService.recordDetails(id));
     }
+
+    /**
+     * 巡检异常记录导出
+     *
+     * @param response      HttpServletResponse
+     * @param areaName      区域名称(可选)
+     * @param siteName      地点名称(可选)
+     * @param name          人员名称(可选)
+     * @param planType      计划类型(可选)
+     * @param routeId       路线ID(可选)
+     * @param startDateTime 开始时间(可选)
+     * @param endDateTime   结束时间(可选)
+     * @throws IOException
+     */
+    @Log(title = "巡检异常记录", businessType = BusinessType.EXPORT)
+    @PostMapping("/abnormalListExport")
+    public void export(HttpServletResponse response,
+                       @RequestParam(value = "areaName", required = false) String areaName,
+                       @RequestParam(value = "siteName", required = false) String siteName,
+                       @RequestParam(value = "name", required = false) String name,
+                       @RequestParam(value = "planType", required = false) Integer planType,
+                       @RequestParam(value = "routeId", required = false) Integer routeId,
+                       @RequestParam(value = "startDateTime", required = false) String startDateTime,
+                       @RequestParam(value = "endDateTime", required = false) String endDateTime) throws IOException {
+        List<PatrolInspectionAbnormalExportVo> list = patrolInspectionAbnormalService.abnormalListExport(areaName, siteName, name, planType, routeId, startDateTime, endDateTime);
+        ExcelUtil<PatrolInspectionAbnormalExportVo> util = new ExcelUtil<>(PatrolInspectionAbnormalExportVo.class);
+        util.exportExcel(response, list, "巡检异常记录", "巡检异常记录");
+    }
 }
 

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionAbnormalService.java

@@ -4,6 +4,7 @@ import com.usky.common.core.bean.CommonPage;
 import com.usky.fire.domain.PatrolInspectionAbnormal;
 import com.usky.common.mybatis.core.CrudService;
 import com.usky.fire.domain.PatrolInspectionRecord;
+import com.usky.fire.service.vo.PatrolInspectionAbnormalExportVo;
 import com.usky.fire.service.vo.PatrolInspectionAbnormalVo;
 import com.usky.fire.service.vo.PatrolInspectionRecordVo;
 
@@ -48,4 +49,19 @@ public interface PatrolInspectionAbnormalService extends CrudService<PatrolInspe
      * @return
      */
     List<PatrolInspectionAbnormalVo> recordDetails(Integer id);
+
+    /**
+     * 异常记录导出
+     * @param areaName      区域名称
+     * @param siteName      地点名称
+     * @param name          人员名称
+     * @param planType      计划类型
+     * @param routeId       路线id
+     * @param startDateTime 开始时间
+     * @param endDateTime   结束时间
+     * @return
+     */
+    List<PatrolInspectionAbnormalExportVo> abnormalListExport(String areaName, String siteName, String name,
+                                                              Integer planType, Integer routeId,
+                                                              String startDateTime, String endDateTime);
 }

+ 47 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionAbnormalServiceImpl.java

@@ -16,6 +16,7 @@ import com.usky.fire.mapper.PatrolInspectionPlanSonMapper;
 import com.usky.fire.service.*;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.fire.service.vo.ContentOptionVo;
+import com.usky.fire.service.vo.PatrolInspectionAbnormalExportVo;
 import com.usky.fire.service.vo.PatrolInspectionAbnormalVo;
 import com.usky.fire.service.vo.PatrolInspectionContentVo;
 import com.usky.fire.service.vo.PatrolInspectionRecordVo;
@@ -307,4 +308,50 @@ public class PatrolInspectionAbnormalServiceImpl extends AbstractCrudService<Pat
         }
         return list;
     }
+
+    @Override
+    public List<PatrolInspectionAbnormalExportVo> abnormalListExport(String areaName, String siteName, String name,
+                                                                     Integer planType, Integer routeId,
+                                                                     String startDateTime, String endDateTime) {
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        String userType = null;
+        if (loginUser != null && !"".equals(loginUser)) {
+            userType = loginUser.getUserType();
+        }
+        LambdaQueryWrapper<PatrolInspectionAbnormal> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionAbnormal::getTenantId, SecurityUtils.getTenantId())
+                .like(StringUtils.isNotBlank(areaName), PatrolInspectionAbnormal::getAreaName, areaName)
+                .like(StringUtils.isNotBlank(siteName), PatrolInspectionAbnormal::getSiteName, siteName)
+                .like(StringUtils.isNotBlank(name), PatrolInspectionAbnormal::getName, name)
+                .eq(planType != null && planType != 0, PatrolInspectionAbnormal::getPlanType, planType)
+                .eq(routeId != null, PatrolInspectionAbnormal::getRouteId, routeId)
+                .between(StringUtils.isNotBlank(startDateTime) && StringUtils.isNotBlank(endDateTime), PatrolInspectionAbnormal::getCreateTime, startDateTime, endDateTime)
+                .eq("00".equals(userType), PatrolInspectionAbnormal::getCreator, SecurityUtils.getUsername());
+        queryWrapper.orderByDesc(PatrolInspectionAbnormal::getId);
+        List<PatrolInspectionAbnormal> recordList = this.list(queryWrapper);
+
+        List<PatrolInspectionAbnormalExportVo> list = new ArrayList<>();
+        for (int i = 0; i < recordList.size(); i++) {
+            PatrolInspectionAbnormalExportVo vo = new PatrolInspectionAbnormalExportVo();
+            vo.setXh(i + 1);
+            vo.setSiteNubmber(recordList.get(i).getSiteNubmber());
+            vo.setSiteType(recordList.get(i).getSiteType());
+            vo.setAreaName(recordList.get(i).getAreaName());
+            vo.setSiteName(recordList.get(i).getSiteName());
+            vo.setName(recordList.get(i).getName());
+            vo.setPhone(recordList.get(i).getPhone());
+            vo.setPlanType(recordList.get(i).getPlanType());
+            vo.setLongitude(recordList.get(i).getLongitude());
+            vo.setLatitude(recordList.get(i).getLatitude());
+            vo.setStartDate(recordList.get(i).getStartDate() != null ? recordList.get(i).getStartDate().format(df) : "");
+            vo.setEndDate(recordList.get(i).getEndDate() != null ? recordList.get(i).getEndDate().format(df) : "");
+            vo.setCreateTime(recordList.get(i).getCreateTime() != null ? recordList.get(i).getCreateTime().format(df) : "");
+            vo.setAbnormalStatus(recordList.get(i).getAbnormalStatus());
+            vo.setRemarks(recordList.get(i).getRemarks());
+            vo.setCreator(recordList.get(i).getCreator());
+            list.add(vo);
+        }
+        return list;
+    }
 }

+ 120 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionAbnormalExportVo.java

@@ -0,0 +1,120 @@
+package com.usky.fire.service.vo;
+
+import com.ruoyi.common.core.annotation.Excel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 巡检异常记录导出VO
+ * </p>
+ *
+ * @author fu
+ * @since 2024-06-13
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionAbnormalExportVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 序号
+     */
+    @Excel(name = "序号")
+    private Integer xh;
+
+    /**
+     * 地点号码
+     */
+    @Excel(name = "地点号码")
+    private String siteNubmber;
+
+    /**
+     * 地点类型
+     */
+    @Excel(name = "地点类型", readConverterExp = "1=二维码,2=NFC")
+    private Integer siteType;
+
+    /**
+     * 区域名称
+     */
+    @Excel(name = "区域名称")
+    private String areaName;
+
+    /**
+     * 地点名称
+     */
+    @Excel(name = "地点名称")
+    private String siteName;
+
+    /**
+     * 巡检人员
+     */
+    @Excel(name = "巡检人员")
+    private String name;
+
+    /**
+     * 联系电话
+     */
+    @Excel(name = "联系电话")
+    private String phone;
+
+    /**
+     * 计划类型(1 普通计划,2 按次计划)
+     */
+    @Excel(name = "计划类型", readConverterExp = "1=普通计划,2=按次计划")
+    private Integer planType;
+
+    /**
+     * 经度
+     */
+    @Excel(name = "经度")
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    @Excel(name = "纬度")
+    private String latitude;
+
+    /**
+     * 开始时间
+     */
+    @Excel(name = "开始时间")
+    private String startDate;
+
+    /**
+     * 结束时间
+     */
+    @Excel(name = "结束时间")
+    private String endDate;
+
+    /**
+     * 巡检时间
+     */
+    @Excel(name = "巡检时间")
+    private String createTime;
+
+    /**
+     * 异常状态 (1=巡检异常,2=未知区域)
+     */
+    @Excel(name = "异常状态", readConverterExp = "1=巡检异常,2=未知区域")
+    private Integer abnormalStatus;
+
+    /**
+     * 巡检备注
+     */
+    @Excel(name = "巡检备注")
+    private String remarks;
+
+    /**
+     * 创建用户
+     */
+    @Excel(name = "创建用户")
+    private String creator;
+}