Browse Source

未完成导出备份

jichaobo 2 years ago
parent
commit
d5e103f6db

+ 25 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionSiteController.java

@@ -128,5 +128,30 @@ public class PatrolInspectionSiteController {
         return ApiResult.success();
     }
 
+//    /**
+//     * 巡查自检-巡检地点-列表导出
+//     *
+//     * @param areaId   区域id
+//     * @param siteName 地点名称
+//     * @param id       地点ID
+//     * @return
+//     */
+//    @GetMapping("/patrolInspectionSiteListExport")
+//    public void export(HttpServletResponse response,
+//                       @RequestParam(required = false) Integer areaId,
+//                       @RequestParam(required = false) String siteName,
+//                       @RequestParam(required = false) Integer id) throws IOException {
+//        List<PatrolInspectionSiteExportVo> list = patrolInspectionSiteService.patrolInspectionSiteListExport(areaId, siteName, id);
+//        ExcelUtil<PatrolInspectionSiteExportVo> util = new ExcelUtil<PatrolInspectionSiteExportVo>(PatrolInspectionSiteExportVo.class);
+//        util.exportExcel(response, list, "巡检地点列表");
+//    }
+//
+//    @GetMapping("correspondDeviceExport")
+//    public ApiResult<String> correspondDeviceExport(@RequestParam(required = false) Integer areaId,
+//                                                    @RequestParam(required = false) String siteName,
+//                                                    @RequestParam(required = false) Integer id) {
+//        return ApiResult.success(patrolInspectionSiteService.correspondDeviceExport(areaId,siteName,id));
+//    }
+
 }
 

+ 5 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionSiteService.java

@@ -20,7 +20,7 @@ public interface PatrolInspectionSiteService extends CrudService<PatrolInspectio
 
     List<PatrolInspectionAreaVo> areaLeftList();
 
-    CommonPage<PatrolInspectionSite> patrolInspectionSiteList(Integer areaId, String siteName, Integer pageNum, Integer pageSize,Integer id);
+    CommonPage<PatrolInspectionSite> patrolInspectionSiteList(Integer areaId, String siteName, Integer pageNum, Integer pageSize, Integer id);
 
     void updatePatrolInspectionSiteList(List<PatrolInspectionSite> patrolInspectionSiteList);
 
@@ -31,4 +31,8 @@ public interface PatrolInspectionSiteService extends CrudService<PatrolInspectio
     void addSiteContent(List<SiteContent> siteContentList);
 
     Integer[] siteContentList(Integer siteId);
+
+//    List<PatrolInspectionSiteExportVo> patrolInspectionSiteListExport(Integer areaId, String siteName, Integer id);
+//
+//    String correspondDeviceExport(Integer areaId, String siteName, Integer id);
 }

+ 107 - 3
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionSiteServiceImpl.java

@@ -53,14 +53,14 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionArea::getEnable, 1)
                 .eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId());
-        if ("00".equals(userType)){
+        if ("00".equals(userType)) {
             queryWrapper.eq(PatrolInspectionArea::getCreator, SecurityUtils.getUsername());
         }
         List<PatrolInspectionArea> patrolInspectionAreaList = patrolInspectionAreaService.list(queryWrapper);
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapperOne = Wrappers.lambdaQuery();
         queryWrapperOne.eq(PatrolInspectionSite::getEnable, 1)
                 .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
-        if("00".equals(userType)){
+        if ("00".equals(userType)) {
             queryWrapperOne.eq(PatrolInspectionSite::getCreator, SecurityUtils.getUsername());
         }
         List<PatrolInspectionSite> list = this.list(queryWrapperOne);
@@ -108,7 +108,7 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(PatrolInspectionSite::getEnable, 1)
                 .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
-        if("00".equals(userType)){
+        if ("00".equals(userType)) {
             queryWrapper.eq(PatrolInspectionSite::getCreator, SecurityUtils.getUsername());
         }
         if (areaId != null) {
@@ -202,4 +202,108 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
     }
 
 
+//    @Override
+//    public List<PatrolInspectionSiteExportVo> patrolInspectionSiteListExport(Integer areaId, String siteName, Integer id) {
+//
+////        LoginUser a = SecurityUtils.getLoginUser();
+////        String userType = SecurityUtils.getLoginUser().getUserType();
+//        String userType = null;
+//        LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
+//        queryWrapper.eq(PatrolInspectionSite::getEnable, 1)
+//                .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
+//        if ("00".equals(userType)) {
+//            queryWrapper.eq(PatrolInspectionSite::getCreator, SecurityUtils.getUsername());
+//        }
+//        if (areaId != null) {
+//            queryWrapper.eq(PatrolInspectionSite::getAreaId, areaId);
+//        }
+//        if (id != null && id != 0) {
+//            queryWrapper.eq(PatrolInspectionSite::getId, id);
+//        }
+//        if (siteName != null && !"".equals(siteName)) {
+//            queryWrapper.like(PatrolInspectionSite::getSiteName, siteName);
+//        }
+//        queryWrapper.orderByDesc(PatrolInspectionSite::getId);
+//        List<PatrolInspectionSite> patrolInspectionSiteList = this.list(queryWrapper);
+//        List<PatrolInspectionSiteExportVo> list = new ArrayList<>();
+//        for (int i = 0; i < patrolInspectionSiteList.size(); i++) {
+//            PatrolInspectionSiteExportVo patrolInspectionSiteExportVo = new PatrolInspectionSiteExportVo();
+//            patrolInspectionSiteExportVo.setXh(i + 1);
+//            patrolInspectionSiteExportVo.setSiteName(patrolInspectionSiteList.get(i).getSiteName());
+//            patrolInspectionSiteExportVo.setSiteNubmber(patrolInspectionSiteList.get(i).getSiteNubmber());
+//            patrolInspectionSiteExportVo.setLatitude(patrolInspectionSiteList.get(i).getLatitude());
+//            patrolInspectionSiteExportVo.setLongitude(patrolInspectionSiteList.get(i).getLongitude());
+//            patrolInspectionSiteExportVo.setPictureUrl(patrolInspectionSiteList.get(i).getPictureUrl());
+//            patrolInspectionSiteExportVo.setCreateTime("1111");
+//            list.add(patrolInspectionSiteExportVo);
+//        }
+//        return list;
+//    }
+//
+//
+//    @Override
+//    public String correspondDeviceExport(Integer areaId, String siteName, Integer id) {
+//        DateFormat dFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
+//        SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        Workbook workbook = null;
+//        File file = null;
+//        try {
+//            ExportParams params = new ExportParams(null, "巡检地点列表");
+//            workbook = ExcelExportUtil.exportBigExcel(params, PatrolInspectionSiteExportOneVo.class,
+//                    (o, i) -> {
+//                        String userType = null;
+//                        LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
+//                        queryWrapper.eq(PatrolInspectionSite::getEnable, 1)
+//                                .eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
+//                        if ("00".equals(userType)) {
+//                            queryWrapper.eq(PatrolInspectionSite::getCreator, SecurityUtils.getUsername());
+//                        }
+//                        if (areaId != null) {
+//                            queryWrapper.eq(PatrolInspectionSite::getAreaId, areaId);
+//                        }
+//                        if (id != null && id != 0) {
+//                            queryWrapper.eq(PatrolInspectionSite::getId, id);
+//                        }
+//                        if (siteName != null && !"".equals(siteName)) {
+//                            queryWrapper.like(PatrolInspectionSite::getSiteName, siteName);
+//                        }
+//                        queryWrapper.orderByDesc(PatrolInspectionSite::getId);
+//                        List<PatrolInspectionSite> patrolInspectionSiteList = this.list(queryWrapper);
+//                        List<PatrolInspectionSiteExportVo> list = new ArrayList<>();
+//                        for (int j = 0; j < patrolInspectionSiteList.size(); j++) {
+//                            PatrolInspectionSiteExportVo patrolInspectionSiteExportVo = new PatrolInspectionSiteExportVo();
+//                            patrolInspectionSiteExportVo.setId(patrolInspectionSiteList.get(j).getId());
+//                            patrolInspectionSiteExportVo.setXh(j + 1);
+//                            patrolInspectionSiteExportVo.setSiteName(patrolInspectionSiteList.get(j).getSiteName());
+//                            patrolInspectionSiteExportVo.setSiteNubmber(patrolInspectionSiteList.get(j).getSiteNubmber());
+//                            patrolInspectionSiteExportVo.setLatitude(patrolInspectionSiteList.get(j).getLatitude());
+//                            patrolInspectionSiteExportVo.setLongitude(patrolInspectionSiteList.get(j).getLongitude());
+//                            patrolInspectionSiteExportVo.setPictureUrl(patrolInspectionSiteList.get(j).getPictureUrl());
+//                            patrolInspectionSiteExportVo.setCreateTime("1111");
+//                            list.add(patrolInspectionSiteExportVo);
+//                        }
+//                        return new ArrayList<>(BeanMapperUtils.mapList(list, PatrolInspectionSiteExportVo.class, PatrolInspectionSiteExportOneVo.class));
+//                    }, null);
+//            if (null != workbook) {
+//                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "巡检地点列表", dFormat.format(System.currentTimeMillis()) + ""));
+//                FileUtils.createFile(file.getAbsolutePath());
+//                FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
+//                workbook.write(allListingFileOutputStream);
+//            } else {
+//                throw new BusinessException("表格数据为空");
+//            }
+//        } catch (Exception e) {
+//            log.error("导出文件失败", e);
+//            throw new BusinessException("导出文件失败");
+//        } finally {
+//            if (workbook != null) {
+//                try {
+//                    workbook.close();
+//                } catch (IOException e) {
+//                    log.error("===export spec=== 关闭workbook失败", e);
+//                }
+//            }
+//        }
+//        return file.getName();
+//    }
 }

+ 42 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionSiteExportOneVo.java

@@ -0,0 +1,42 @@
+package com.usky.fire.service.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-13
+ */
+@Data
+public class PatrolInspectionSiteExportOneVo {
+    /**
+     * 设备表主键ID
+     */
+    private Integer id;
+
+    @Excel(name = "序号", height = 6, width = 20)
+    private Integer xh;
+
+    @Excel(name = "地点名称", height = 6, width = 20)
+    private String siteName;
+
+    @Excel(name = "地点号码", height = 6, width = 20)
+    private String siteNubmber;
+
+    @Excel(name = "经度", height = 6, width = 20)
+    private String longitude;
+
+    @Excel(name = "纬度", height = 6, width = 20)
+    private String latitude;
+
+    @Excel(name = "图片地址", height = 6, width = 20)
+    private String pictureUrl;
+
+    @Excel(name = "创建时间", height = 6, width = 20)
+    private String createTime;
+
+}

+ 65 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionSiteExportVo.java

@@ -0,0 +1,65 @@
+package com.usky.fire.service.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-13
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionSiteExportVo implements Serializable {
+
+    /**
+     * 设备表主键ID
+     */
+    private Integer id;
+
+    /**
+     * 序号
+     */
+    private Integer xh;
+
+    /**
+     * 地点名称
+     */
+    private String siteName;
+
+    /**
+     * 地点号码
+     */
+    private String siteNubmber;
+
+    /**
+     * 经度
+     */
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    private String latitude;
+
+    /**
+     * 图片地址
+     */
+    private String pictureUrl;
+
+    /**
+     * 创建时间
+     */
+    private String createTime;
+
+}