Browse Source

修改支付机构sql

hym 3 years ago
parent
commit
b91cf92eb0

+ 2 - 30
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/AbstractDownloadExcelTemplate.java

@@ -1,6 +1,6 @@
 package com.zcxk.rmcp.pay.excel;
 
-import com.zcxk.rmcp.pay.commom.util.FileUtil;
+import cn.hutool.core.io.FileUtil;
 import org.jxls.common.Context;
 import org.jxls.util.JxlsHelper;
 
@@ -29,7 +29,7 @@ public abstract class AbstractDownloadExcelTemplate {
         this.sysId = sysId;
         this.response = response;
         setParam();
-        downloadExcel();
+
     }
 
     /**
@@ -41,33 +41,5 @@ public abstract class AbstractDownloadExcelTemplate {
     /**
      * 下载
      */
-    private final void downloadExcel(){
-        try {
-            InputStream in = this.getClass().getClassLoader().getResourceAsStream(templatePath);
-            FileOutputStream out = new FileOutputStream(filePath);
-            //将List<Exam>列表数据按照模板文件中的格式生成到scoreOutput.xls文件中
-            JxlsHelper.getInstance().processTemplate(in, out, context);
-
-            //下面步骤为浏览器下载部分
-            //指定数据生成后的文件输入流(将上述out的路径作为文件的输入流)
-            FileInputStream fileInputStream = new FileInputStream(filePath);
-            //导出excel文件,设置文件名
-            String filename = URLEncoder.encode( downloadName+".xlsx", "UTF-8");
-            //设置下载头
-            response.setHeader("Content-Disposition", "attachment;filename=" + filename);
-            ServletOutputStream outputStream = response.getOutputStream();
 
-            //将文件写入浏览器
-            byte[] bys = new byte[fileInputStream.available()];
-            fileInputStream.read(bys);
-            outputStream.write(bys);
-            outputStream.flush();
-            outputStream.close();
-        }catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            FileUtil.deleteFile(filePath);
-        }
-
-    }
 }

+ 69 - 30
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/download/template/InstallPlanDownloadExcelTemplate.java

@@ -1,6 +1,11 @@
 package com.zcxk.rmcp.pay.excel.download.template;
 
 
+import cn.hutool.core.io.FileUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.excel.write.metadata.fill.FillConfig;
 import com.bz.zoneiot.core.common.pojo.AjaxMessage;
 import com.zcxk.rmcp.api.dto.OrgDto;
 import com.zcxk.rmcp.api.dto.product.ProductVo;
@@ -12,6 +17,9 @@ import com.zcxk.rmcp.pay.dto.LoginUser;
 import com.zcxk.rmcp.pay.entity.Community;
 import com.zcxk.rmcp.pay.entity.Customer;
 import com.zcxk.rmcp.pay.excel.AbstractDownloadExcelTemplate;
+import com.zcxk.rmcp.pay.excel.model.CommImportData;
+import com.zcxk.rmcp.pay.excel.model.InstallPlanExcelData;
+import com.zcxk.rmcp.pay.excel.model.InstallPlanInfoData;
 import com.zcxk.rmcp.pay.service.CommunityService;
 import com.zcxk.rmcp.pay.service.CustomerService;
 import com.zcxk.rmcp.pay.service.pay.PaySyncDataService;
@@ -21,9 +29,15 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
+import javax.servlet.ServletOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URLEncoder;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import static com.google.common.collect.Lists.newArrayList;
 
@@ -55,46 +69,71 @@ public class InstallPlanDownloadExcelTemplate extends AbstractDownloadExcelTempl
 
     @Override
     protected void setParam() {
+        String filesPath=getFilePath();
+        templatePath="excel/installPlanTemplate.xlsx";
         LoginUser loginUser = UserUtil.getCurrentUser();
-        filePath = getFilePath();
-        templatePath = "excel/payBaseAccountTemplate20210130.xlsx";
-
-        DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMdd");
-        LocalDateTime date = LocalDateTime.now();
-        downloadName = "批量创建装表计划模板"+ "_" + date.format(f);
-
-
+        InputStream in = this.getClass().getClassLoader().getResourceAsStream(templatePath);
+        ExcelWriter excelWriter = EasyExcel.write(filesPath).withTemplate(in).build();
+        OrgDto dto=new OrgDto();
+        dto.setOrgType("company");
+        List<OrgDto> companys = syncDataClient.getOrgs(dto);
+        //填充设备数据
+        WriteSheet installPalnSheet = EasyExcel.writerSheet("安装计划模板").build();
+        WriteSheet deviceTypeSheet = EasyExcel.writerSheet("设备型号").build();
+        WriteSheet orgSheet = EasyExcel.writerSheet("公司").build();
+        WriteSheet communitySheet = EasyExcel.writerSheet("小区").build();
         //1、获取小区列表数据
         List<Community> communityList = communityService.findByCustomerId(loginUser.getTenantId());
+        //4、获取水表类型数据
+        List<ProductVo> productList = syncDataClient.getProductLists();
 
-
-        //2、获取建筑列表数据
-        //List<Building> buildingList = buildingMapper.findBySiteId(loginUser.getSiteId(),null, UserUtil.getCustomerIds());
+        excelWriter.fill(convertProductData(productList), deviceTypeSheet);
+        excelWriter.fill(convertOrgData(companys), orgSheet);
+        excelWriter.fill(convertCommunityData(communityList), communitySheet);
 
 
 
-        //3、获取客户列表数据
-        List<Customer> customerList = customerService.getCustomerList(loginUser.getSiteId());
-        OrgDto dto=new OrgDto();
-        dto.setOrgType("company");
-        List<OrgDto> companys = syncDataClient.getOrgs(dto);
-        dto.setOrgType("department");
-        List<OrgDto> departs = syncDataClient.getOrgs(dto);
+        FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
+        List<InstallPlanExcelData>installPlanExcelDataList=new ArrayList<>();
+        excelWriter.fill(new InstallPlanInfoData(), fillConfig, installPalnSheet);
+        excelWriter.fill(installPlanExcelDataList, fillConfig, installPalnSheet);
+        DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMdd");
+        LocalDateTime date = LocalDateTime.now();
+        String downloadName = "批量创建装表计划模板"+ "_" + date.format(f)+".xlsx";
+        // 千万别忘记关闭流
+        excelWriter.finish();
+        downloadExcel(filesPath,downloadName);
+    }
 
+    private List<CommImportData> convertCommunityData(List<Community> list){
+        return list.stream().map(vo ->new CommImportData(vo.getName(),Math.toIntExact(vo.getId()))).collect(Collectors.toList());
+    }
 
-        this.context = new Context();
-        this.context.putVar("communityList", communityList);
-        this.context.putVar("buildingList", newArrayList());
-        //this.context.putVar("customerList", customerList);
-        this.context.putVar("companyList", companys);
-        this.context.putVar("departList", departs);
-        //this.context.putVar("deviceTypeList", deviceTypeList);
+    private List<CommImportData> convertOrgData(List<OrgDto> list){
+        return list.stream().map(vo ->new CommImportData(vo.getOrgName(),Math.toIntExact(vo.getId()))).collect(Collectors.toList());
+    }
+    private List<CommImportData> convertProductData(List<ProductVo> list){
+        return list.stream().map(vo ->new CommImportData(vo.getManufacturerName()+"/"+vo.getProductName()+"/"+vo.getProductModel(),Math.toIntExact(vo.getId()))).collect(Collectors.toList());
+    }
+    private final void downloadExcel(String filesPath,String downLoadName){
+        try (FileInputStream fileInputStream = new FileInputStream(filesPath)){
+            String filename = URLEncoder.encode( downLoadName, "UTF-8");
+            //设置下载头
+            response.setHeader("Content-Disposition", "attachment;filename=" + filename);
+            ServletOutputStream outputStream =response.getOutputStream();
+
+            //将文件写入浏览器
+            byte[] bys = new byte[fileInputStream.available()];
+            fileInputStream.read(bys);
+            outputStream.write(bys);
+            outputStream.flush();
+            outputStream.close();
+        }catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            FileUtil.del(filesPath);
+        }
 
-        //4、获取水表类型数据
-        List<ProductVo> productList = syncDataClient.getProductLists();
-        if(!CollectionUtils.isEmpty(productList)){
-            this.context.putVar("deviceTypeList", productList);
 
-        }
     }
 }

+ 20 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/model/CommImportData.java

@@ -0,0 +1,20 @@
+package com.zcxk.rmcp.pay.excel.model;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author linqingwei
+ * @date 2021-07-22 18:40
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CommImportData {
+    @ExcelProperty(index = 0)
+    private String name;
+    @ExcelProperty(index = 1)
+    private Integer id;
+}

+ 42 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/model/DeviceImportData.java

@@ -0,0 +1,42 @@
+package com.zcxk.rmcp.pay.excel.model;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+/**
+ * @author linqingwei
+ * @date 2021-07-22 17:54
+ */
+@Data
+public class DeviceImportData {
+
+    @ExcelProperty(index = 0)
+    private String deviceNo;
+    @ExcelProperty(index = 1)
+    private String deviceTypeName;
+    @ExcelProperty(index = 2)
+    private String meterNo;
+    @ExcelProperty(index = 3)
+    private String companyOrgName;
+    @ExcelProperty(index = 4)
+    private String deptOrgName;
+    @ExcelProperty(index = 5)
+    private String fileNo;
+    @ExcelProperty(index = 6)
+    private String sealNo;
+    @ExcelProperty(index = 7)
+    private String username;
+    @ExcelProperty(index = 8)
+    private String phone;
+    @ExcelProperty(index = 9)
+    private String idCard;
+    @ExcelProperty(index = 10)
+    private String readData;
+    @ExcelProperty(index = 11)
+    private String communityName;
+    @ExcelProperty(index = 12)
+    private String address;
+    @ExcelProperty(index = 13)
+    private String remark;
+
+}

+ 27 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/model/DownloadExcelData.java

@@ -0,0 +1,27 @@
+package com.zcxk.rmcp.pay.excel.model;
+
+import lombok.Data;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * @author linqingwei
+ * @date 2021-07-23 15:08
+ */
+@Data
+public class DownloadExcelData {
+    private Integer id;
+    private Integer categoryId;
+    private String filePath;
+    private String templatePath;
+    private String downloadName;
+    private HttpServletResponse response;
+    private List<DeviceImportData> deviceImportDataList;
+    private List<CommImportData> productDataList;
+    private List<CommImportData> communityDataList;
+    private List<CommImportData> orgDataList;
+    private List<InstallMeterData> installMeterDataList;
+    private InstallPlanInfoData installPlanInfoData;
+    private List<InstallPlanExcelData> installPlanExcelDataList;
+}

+ 49 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/model/InstallMeterData.java

@@ -0,0 +1,49 @@
+package com.zcxk.rmcp.pay.excel.model;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author linqingwei
+ * @date 2021-07-27 17:11
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class InstallMeterData {
+    @ExcelProperty(index = 0)
+    private Integer id;
+    @ExcelProperty(index = 1)
+    private String doorNo;
+    @ExcelProperty(index = 2)
+    private String meterNo;
+    @ExcelProperty(index = 3)
+    private String deviceNo;
+    @ExcelProperty(index = 4)
+    private String fileNo;
+    @ExcelProperty(index = 5)
+    private String sealNo;
+    @ExcelProperty(index = 6)
+    private String startDegree;
+    @ExcelProperty(index = 7)
+    private String endDegree;
+    @ExcelProperty(index = 8)
+    private String username;
+    @ExcelProperty(index = 9)
+    private String phone;
+    @ExcelProperty(index = 10)
+    private String idCard;
+    @ExcelProperty(index = 11)
+    private String remark;
+
+    public InstallMeterData(Integer id, String doorNo, String fileNo, String username, String phone, String idCard) {
+        this.id = id;
+        this.doorNo = doorNo;
+        this.fileNo = fileNo;
+        this.username = username;
+        this.phone = phone;
+        this.idCard = idCard;
+    }
+}

+ 31 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/model/InstallPlanExcelData.java

@@ -0,0 +1,31 @@
+package com.zcxk.rmcp.pay.excel.model;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+/**
+ * @author linqingwei
+ * @date 2021-07-30 10:59
+ */
+@Data
+public class InstallPlanExcelData {
+
+    @ExcelProperty(index = 0)
+    private String buildingName;
+    @ExcelProperty(index = 1)
+    private String unitName;
+    @ExcelProperty(index = 2)
+    private String floorName;
+    @ExcelProperty(index = 3)
+    private String doorNo;
+    @ExcelProperty(index = 4)
+    private String fileNo;
+    @ExcelProperty(index = 5)
+    private String username;
+    @ExcelProperty(index = 6)
+    private String phone;
+    @ExcelProperty(index = 7)
+    private String idCard;
+    @ExcelProperty(index = 8)
+    private String remark;
+}

+ 18 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/model/InstallPlanInfoData.java

@@ -0,0 +1,18 @@
+package com.zcxk.rmcp.pay.excel.model;
+
+import lombok.Data;
+
+/**
+ * @author linqingwei
+ * @date 2021-07-30 11:17
+ */
+@Data
+public class InstallPlanInfoData {
+    private String installPlanName;
+    private String companyName;
+    private String deptName;
+    private String communityName;
+    private String deviceTypeName;
+    private String unit;
+    private String phone;
+}

BIN
zoniot-pay/zoniot-pay-web/src/main/resources/excel/installPlanTemplate.xlsx