Bladeren bron

小区整改提交

wang_xy 1 jaar geleden
bovenliggende
commit
ee10e2c959

+ 92 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zdsz/ZAreaController.java

@@ -1,13 +1,22 @@
 package com.ruoyi.web.controller.zdsz;
 
-import java.util.List;
-import java.util.Arrays;
+import java.io.IOException;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
+import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
+import com.ruoyi.common.convert.ExcelBigNumberConvert;
+import com.ruoyi.common.utils.file.FileUtils;
+import com.ruoyi.zdsz.domain.vo.GExportsVo;
+import com.ruoyi.zdsz.domain.vo.GImportVo;
 import com.ruoyi.zdsz.service.*;
 import lombok.RequiredArgsConstructor;
 
 import javax.annotation.Resource;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.constraints.*;
 
@@ -27,6 +36,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.zdsz.domain.vo.ZAreaVo;
 import com.ruoyi.zdsz.domain.bo.ZAreaBo;
 import com.ruoyi.common.core.page.TableDataInfo;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 小区管理
@@ -40,6 +50,9 @@ import com.ruoyi.common.core.page.TableDataInfo;
 @RequestMapping("/zdsz/area")
 public class ZAreaController extends BaseController {
 
+    private String bfb="0";
+    private String message;
+
     private final IZAreaService iZAreaService;
     @Resource
     private IZBuildingService buildingService;
@@ -135,4 +148,81 @@ public class ZAreaController extends BaseController {
         }
         return toAjax(iZAreaService.deleteWithValidByIds(Arrays.asList(ids), true));
     }
+
+    @GetMapping("/importTemplate")
+    @Log(title = "下载导入模板", businessType = BusinessType.EXPORT)
+    public void importTemplate(HttpServletResponse response) {
+        ExcelUtil.exportExcel(new ArrayList<>(), "小区", GImportVo.class, response);
+    }
+
+    /**
+     * 批量下载生成文件夹打压缩包
+     */
+    @GetMapping("/upload")
+    @Log(title = "批量下载生成文件夹打压缩包", businessType = BusinessType.EXPORT)
+    public void upload(HttpServletRequest request, HttpServletResponse response, @RequestParam String id) throws Exception {
+        iZAreaService.upload(request, response, id);
+    }
+
+    /**
+     * 导出所属包功能
+     */
+    @Log(title = "导出所属包功能", businessType = BusinessType.EXPORT)
+    @GetMapping("/exports")
+    public void exports(@Validated ZAreaBo bo, HttpServletResponse response) {
+        String filename = iZAreaService.getDictNameOfAffiliatedPackage(bo);
+        List<GExportsVo> list = iZAreaService.getExport(bo);
+        try {
+            response.reset();
+            FileUtils.setAttachmentResponseHeader(response, filename+ ".xlsx");
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
+            ServletOutputStream os = response.getOutputStream();
+            EasyExcel.write(os, GExportsVo.class)
+                .autoCloseStream(false)
+                // 自动适配
+                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
+                // 大数值自动转换 防止失真
+                .registerConverter(new ExcelBigNumberConvert())
+                .sheet(filename).doWrite(list);
+        } catch (IOException e) {
+            throw new RuntimeException("导出Excel异常");
+        }
+
+    }
+//    @Log(title = "导入小区列表", businessType = BusinessType.EXPORT)
+//    @ApiImplicitParams({
+//        @ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true),
+//    })
+//    @PostMapping("/importData")
+//    public synchronized AjaxResult<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
+//        List<GImportVo> listVo = ExcelUtil.importExcel(file.getInputStream(), GImportVo.class);
+//        List<GImportVo> list = BeanUtil.copyToList(listVo, GImportVo.class);
+//        String operName = getUsername();
+//        if(Double.valueOf(bfb)<=0){
+//            forImportData(list,true,operName,0,0);
+//        }
+//        return AjaxResult.success(message);
+//    }
+
+    /**
+     * 进度条刷新,
+     */
+    @GetMapping(value = "/flushProgress")
+    public R<Map> flushProgress() throws Exception
+    {
+        Map<String,String> ret = new HashMap<>();
+        ret.put("bfb",bfb);
+        ret.put("message",message);
+        return R.ok(ret);
+    }
+    /**
+     * 结束进度条刷新,
+     */
+    @GetMapping(value = "/clearFlushProgress")
+    public R<Void> clearFlushProgress() throws Exception
+    {
+        bfb="0";
+        message="";
+        return R.ok();
+    }
 }

+ 3 - 3
ruoyi-admin/src/main/resources/application-dev.yml

@@ -98,13 +98,13 @@ spring:
 spring:
   redis:
     # 地址
-    host: localhost
+    host: 127.0.0.1
     # 端口,默认为6379
-    port: 6379
+    port: 16379
     # 数据库索引
     database: 0
     # 密码(如没有密码请注释掉)
-    # password:
+    password: sooka123456
     # 连接超时时间
     timeout: 10s
     # 是否开启ssl

+ 13 - 8
ruoyi-admin/src/main/resources/application-prod.yml

@@ -52,17 +52,17 @@ spring:
           driverClassName: com.mysql.cj.jdbc.Driver
           # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
           # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
-          url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
+          url: jdbc:mysql://192.168.10.15:63306/sj_zdsz?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
           username: root
-          password: root
+          password: sooka1a2b3c4d%...
         # 从库数据源
         slave:
           lazy: true
           type: ${spring.datasource.type}
           driverClassName: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
-          username:
-          password:
+          url: jdbc:mysql://192.168.10.15:63306/sj_zdsz?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
+          username: root
+          password: sooka1a2b3c4d%...
 #        oracle:
 #          type: ${spring.datasource.type}
 #          driverClassName: oracle.jdbc.OracleDriver
@@ -103,11 +103,11 @@ spring:
     # 地址
     host: localhost
     # 端口,默认为6379
-    port: 6379
+    port: 16379
     # 数据库索引
     database: 0
     # 密码(如没有密码请注释掉)
-    # password:
+#    password: sooka123456
     # 连接超时时间
     timeout: 10s
     # 是否开启ssl
@@ -191,4 +191,9 @@ huawei:
       endPoint: obs.cn-north-4.myhuaweicloud.com
     access:
       endPoint: https://szrqgz1.obs.cn-north-4.myhuaweicloud.com
-    bucketName: szrqgz1
+    bucketName: szrqgz1
+tableNames:
+  #动态表名月分(该处为需要动态表的表名,号分割)
+  Month: z_engineering_review,z_engiineering_photo,z_engineering_info,z_engineering_material,z_engineering_node
+  #动态表名年度
+  Year: z_engineering_review

+ 40 - 0
ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/domain/vo/GExportsVo.java

@@ -0,0 +1,40 @@
+package com.ruoyi.zdsz.domain.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.ruoyi.common.annotation.ExcelDictFormat;
+import com.ruoyi.common.convert.ExcelDictConvert;
+import lombok.Data;
+
+
+/**
+ * 小区视图对象 g_area
+ *
+ * @author ruoyi
+ * @date 2021-11-15
+ */
+@Data
+@ExcelIgnoreUnannotated
+public class GExportsVo {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    @ExcelProperty(value = "小区")
+    private String areaName;
+    @ExcelProperty(value = "行政区", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "district")
+    private String district;
+    @ExcelProperty(value = "核算行政区", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "district")
+    private String calculateDistrict;
+    @ExcelProperty(value = "小区规模")
+    private String scale;
+    @ExcelProperty(value = "实际规模")
+    private String count;
+    @ExcelProperty(value = "所属包", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "affiliated_package")
+    private String belongingPack;
+
+}

+ 34 - 0
ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/domain/vo/GImportVo.java

@@ -0,0 +1,34 @@
+package com.ruoyi.zdsz.domain.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.ruoyi.common.annotation.ExcelDictFormat;
+import com.ruoyi.common.convert.ExcelDictConvert;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 导入VO
+ *
+ * @author Lion Li
+ */
+
+@Data
+@NoArgsConstructor
+// @Accessors(chain = true) // 导入不允许使用 会找不到set方法
+public class GImportVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ExcelProperty(value = "行政区")
+    private String district;
+    @ExcelProperty(value = "小区")
+    private String areaName;
+    @ExcelProperty(value = "楼宇")
+    private String buildName;
+    @ExcelProperty(value = "单元")
+    private String unitName;
+    @ExcelProperty(value = "房屋")
+    private String houseName;
+
+}

+ 5 - 0
ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/mapper/ZAreaMapper.java

@@ -1,6 +1,8 @@
 package com.ruoyi.zdsz.mapper;
 
 import com.ruoyi.zdsz.domain.ZArea;
+import com.ruoyi.zdsz.domain.bo.ZAreaBo;
+import com.ruoyi.zdsz.domain.vo.GExportsVo;
 import com.ruoyi.zdsz.domain.vo.ZAreaVo;
 import com.ruoyi.common.core.mapper.BaseMapperPlus;
 
@@ -14,4 +16,7 @@ import java.util.List;
  */
 public interface ZAreaMapper extends BaseMapperPlus<ZAreaMapper, ZArea, ZAreaVo> {
     List<ZAreaVo> getArea(String district);
+
+    String getDictNameOfAffiliatedPackage(ZAreaBo bo);
+    List<GExportsVo> getExport(ZAreaBo bo);
 }

+ 8 - 0
ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/service/IZAreaService.java

@@ -1,11 +1,14 @@
 package com.ruoyi.zdsz.service;
 
 import com.ruoyi.zdsz.domain.ZArea;
+import com.ruoyi.zdsz.domain.vo.GExportsVo;
 import com.ruoyi.zdsz.domain.vo.ZAreaVo;
 import com.ruoyi.zdsz.domain.bo.ZAreaBo;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.core.domain.PageQuery;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.util.Collection;
 import java.util.List;
 
@@ -47,4 +50,9 @@ public interface IZAreaService {
      * 校验并批量删除小区管理信息
      */
     Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
+
+    String getDictNameOfAffiliatedPackage(ZAreaBo bo);
+
+    List<GExportsVo> getExport(ZAreaBo bo);
+    void upload(HttpServletRequest request, HttpServletResponse response, String id);
 }

+ 66 - 0
ruoyi-zdsz/src/main/java/com/ruoyi/zdsz/service/impl/ZAreaServiceImpl.java

@@ -7,8 +7,13 @@ import com.ruoyi.common.core.domain.PageQuery;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ruoyi.framework.obs.FileUtil;
+import com.ruoyi.zdsz.domain.vo.GExportsVo;
 import com.ruoyi.zdsz.service.IZBuildingService;
 import lombok.RequiredArgsConstructor;
+import lombok.Value;
+import org.mybatis.logging.Logger;
+import org.mybatis.logging.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.zdsz.domain.bo.ZAreaBo;
@@ -18,6 +23,14 @@ import com.ruoyi.zdsz.mapper.ZAreaMapper;
 import com.ruoyi.zdsz.service.IZAreaService;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Collection;
@@ -32,6 +45,11 @@ import java.util.Collection;
 @Service
 public class ZAreaServiceImpl implements IZAreaService {
 
+    private static final Logger logger = LoggerFactory.getLogger(ZAreaServiceImpl.class);
+
+    @Value("${filePath}")
+    private String path;
+
     @Resource
     private ZAreaMapper baseMapper;
 
@@ -126,4 +144,52 @@ public class ZAreaServiceImpl implements IZAreaService {
         }
         return baseMapper.deleteBatchIds(ids) > 0;
     }
+
+    /**
+     * 导出所属包功能(名称查询)
+     */
+    @Override
+    public String getDictNameOfAffiliatedPackage(ZAreaBo bo) {
+        return baseMapper.getDictNameOfAffiliatedPackage(bo);
+    }
+
+    /**
+     * 导出所属包功能(数据查询)
+     */
+    @Override
+    public List<GExportsVo> getExport(ZAreaBo bo) {
+        return baseMapper.getExport(bo);
+    }
+
+    /**
+     * 图片下载
+     */
+    @Override
+    public void upload(HttpServletRequest request, HttpServletResponse response, String name) {
+        // 设置文件夹时间戳和路径位置
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        String format = sdf.format(new Date());
+        // 文件夹的路径,写入服务器的 /tmp 文件夹下
+        String filePath = path + name;
+        // 导出的zip路径
+        String zipFilePath = path + "tmp_" + format + ".zip";
+        // 导出的zip名字
+        String zipName = "PHOTO_" + format + ".zip";
+
+        // 调用工具类压缩文件夹
+        FileOutputStream fileOutputStream = null;
+        try {
+            fileOutputStream = new FileOutputStream(new File(zipFilePath));
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+        FileUtil.toZip(filePath, fileOutputStream, true);
+
+        // 调用工具类设置响应格式
+        try {
+            FileUtil.downLoadFile(request, response, zipName, zipFilePath);
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("导出失败~"+e);
+        }
+    }
 }

+ 21 - 0
ruoyi-zdsz/src/main/resources/mapper/zdsz/ZAreaMapper.xml

@@ -29,5 +29,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and district = #{district}
         </if>
     </select>
+    <select id="getExport" resultType="com.ruoyi.zdsz.domain.vo.GExportsVo">
+        SELECT a.name                  AS areaName,
+               a.district              AS district,
+               a.calculate_district AS calculateDistrict,
+               a.scale             AS scale,
+               a.belonging_pack    AS belongingPack,
+               COUNT(b.area_id) AS count
+        FROM z_area a
+            LEFT JOIN z_engineering_civil b ON (b.area_id = a.id AND b.del_flag = '0')
+        WHERE a.del_flag = '0'
+          AND a.calculate_district = #{calculateDistrict}
+          AND a.belonging_pack = #{belongingPack}
+        GROUP BY b.area_id
 
+    </select>
+    <select id="getDictNameOfAffiliatedPackage" resultType="string">
+        SELECT
+            CONCAT(a.dict_label,'-工程任务单(',b.dict_label,')') AS name
+        FROM `sys_dict_data` a
+        LEFT JOIN sys_dict_data b ON (b.dict_type = 'belonging_pack' AND b.dict_value = #{belongingPack})
+        WHERE a.dict_type = 'district' AND a.dict_value = #{calculateDistrict}
+    </select>
 </mapper>