From 1ad2f74f3c8c6872d57c285809d2384bd3946aa3 Mon Sep 17 00:00:00 2001
From: renkang <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 13 一月 2025 09:16:35 +0800
Subject: [PATCH] 客户资料 巡检任务业务

---
 server/system_service/src/main/java/com/doumee/core/utils/Constants.java                                    |   46 ++++
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/SmsEmailService.java                |    6 
 /dev/null                                                                                                   |   71 ------
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwTempConfig.java                 |    1 
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java          |    2 
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/dto/YwSmsEmailBillCallDTO.java          |   28 ++
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java |  283 ++++++++++++++++++++++++
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java               |   25 ++
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/third/EmailService.java             |   47 ++++
 server/visits/dmvisit_service/src/main/java/com/doumee/core/excel/ExcelReplaceCommon.java                   |   90 ++++++++
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/SmsEmailServiceImpl.java       |   49 ++++
 11 files changed, 567 insertions(+), 81 deletions(-)

diff --git a/server/system_service/src/main/java/com/doumee/core/utils/Constants.java b/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
index 29e590d..820bb4d 100644
--- a/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1,7 +1,10 @@
 package com.doumee.core.utils;
 
 
+import cn.hutool.core.io.IoUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
 import com.doumee.core.model.LoginUserInfo;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -9,10 +12,16 @@
 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
 import io.swagger.models.auth.In;
 import org.apache.batik.util.Platform;
+import org.apache.commons.compress.archivers.zip.Zip64Mode;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.util.CollectionUtils;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.net.URLDecoder;
 import java.text.SimpleDateFormat;
@@ -1528,4 +1537,41 @@
         }
     }
 
+    public static void packFilesToZip(List<File> files, OutputStream os) throws IOException {
+        try {
+            ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(os);
+            zipOutputStream.setUseZip64(Zip64Mode.AsNeeded);
+            for (File file : files) {
+                if(!file.exists()){
+                    System.out.println("===鏂囦欢涓嶅瓨鍦�======="+file.getPath());
+                    continue;
+                }else{
+                    System.out.println("===鏂囦欢瀛樺湪======="+file.getPath());
+                }
+                ZipArchiveEntry entry = new ZipArchiveEntry(file.getName());
+                zipOutputStream.putArchiveEntry(entry);
+                FileInputStream fileInputStream = new FileInputStream(file);
+                byte[] buffer = new byte[1024];
+                int length;
+                while ((length = fileInputStream.read(buffer)) > 0) {
+                    zipOutputStream.write(buffer, 0, length);
+                }
+                zipOutputStream.closeArchiveEntry();
+                zipOutputStream.flush();
+                IoUtil.close(fileInputStream);
+                file.delete();
+            }
+        }catch (Exception e){
+            throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR.getCode(),"瀵逛笉璧凤紝涓嬭浇鍘嬬缉鏂囦欢澶辫触");
+        }finally {
+            if (os != null) {
+                try {
+                    os.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
 }
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/board/ExcelTestDemo.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/board/ExcelTestDemo.java
deleted file mode 100644
index 555a682..0000000
--- a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/board/ExcelTestDemo.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.doumee.cloud.board;
-
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
-import org.apache.poi.xwpf.usermodel.XWPFParagraph;
-import org.apache.poi.xwpf.usermodel.XWPFRun;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-/**
- * Created by IntelliJ IDEA.
- *
- * @Author : Rk
- * @create 2025/1/3 9:11
- */
-public class ExcelTestDemo {
-
-    public static void main(String[] args) {
-        modifyWordTemplate("https://bdreport.oss-cn-beijing.aliyuncs.com/xczl/20250103/temp/F0F4B90E185A4A9BA2147841B90F3909.docx", "d://output.docx", "寮犱笁", "Java璇剧▼");
-    }
-
-    public static void modifyWordTemplate(String templatePath, String outputPath, String name, String product) {
-        try (
-//            FileInputStream fis = new FileInputStream(templatePath);
-             XWPFDocument document = new XWPFDocument(getFileInputStream(templatePath))) {
-            // 姝ゅ杩炴帴鍒板悗缁浛鎹㈡楠�
-            // 閬嶅巻娈佃惤
-            for (XWPFParagraph paragraph : document.getParagraphs()) {
-                for (XWPFRun run : paragraph.getRuns()) {
-                    // 鏇挎崲鍗犱綅绗�
-                    String text = run.getText(0);
-                    if (text != null) {
-                        text = text.replace("{{name}}", name)
-                                .replace("{{text}}", product);
-                        run.setText(text, 0); // 閲嶆柊璁剧疆鏂囨湰
-                    }
-                }
-            }
-            try (FileOutputStream fos = new FileOutputStream(outputPath)) {
-                document.write(fos); // 灏嗕慨鏀瑰悗鐨勬枃妗e啓鍏ヨ緭鍑烘祦
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    /*璇诲彇缃戠粶鏂囦欢*/
-    public static InputStream getFileInputStream(String path) {
-        URL url = null;
-        try {
-            url = new URL(path);
-            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
-            //璁剧疆瓒呮椂闂翠负3绉�
-            conn.setConnectTimeout(3*1000);
-            //闃叉灞忚斀绋嬪簭鎶撳彇鑰岃繑鍥�403閿欒
-            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
-            //寰楀埌杈撳叆娴�
-            return conn.getInputStream();
-        } catch (Exception e) {
-
-        }
-        return null;
-    }
-
-
-
-}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/core/excel/ExcelReplaceCommon.java b/server/visits/dmvisit_service/src/main/java/com/doumee/core/excel/ExcelReplaceCommon.java
new file mode 100644
index 0000000..9694405
--- /dev/null
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/core/excel/ExcelReplaceCommon.java
@@ -0,0 +1,90 @@
+package com.doumee.core.excel;
+
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.utils.Constants;
+import com.doumee.dao.business.model.YwTempConfig;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.apache.poi.xwpf.usermodel.XWPFParagraph;
+import org.apache.poi.xwpf.usermodel.XWPFRun;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2025/1/3 9:11
+ */
+public class ExcelReplaceCommon {
+
+//    public static void main(String[] args) {
+//        modifyWordTemplate("https://bdreport.oss-cn-beijing.aliyuncs.com/xczl/20250110/temp/BE9C167EE35C40E78029C68BABBD0EAB.docx", "d://output.docx", "寮犱笁", "Java璇剧▼");
+//    }
+
+
+
+
+
+    public static String modifyWordTemplate(String templatePath, List<YwTempConfig> ywTempConfigList,String fileName) {
+        try (
+             XWPFDocument document = new XWPFDocument(getFileInputStream(templatePath))) {
+            // 姝ゅ杩炴帴鍒板悗缁浛鎹㈡楠�
+            // 閬嶅巻娈佃惤
+            for (XWPFParagraph paragraph : document.getParagraphs()) {
+                for (XWPFRun run : paragraph.getRuns()) {
+                    // 鏇挎崲鍗犱綅绗�
+                    String text = run.getText(0);
+                    if (text != null) {
+                        for (YwTempConfig ywTempConfig:ywTempConfigList
+                             ) {
+                            text = text.replace(ywTempConfig.getTitle(), ywTempConfig.getUrl());
+                        }
+                        run.setText(text, 0); // 閲嶆柊璁剧疆鏂囨湰
+                    }
+                }
+            }
+            String path = "d://"+fileName;
+            try (FileOutputStream fos = new FileOutputStream(path)) {
+                document.write(fos); // 灏嗕慨鏀瑰悗鐨勬枃妗e啓鍏ヨ緭鍑烘祦
+            }
+            return path;
+            /*//浜岃繘鍒禣utputStream
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            document.write(baos);//鏂囨。鍐欏叆娴�
+            //OutputStream鍐欏叆InputStream浜岃繘鍒舵祦
+            ByteArrayInputStream in = new ByteArrayInputStream(baos.toByteArray()); */
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏂囦欢杞崲寮傚父!");
+    }
+
+    /*璇诲彇缃戠粶鏂囦欢*/
+    public static InputStream getFileInputStream(String path) {
+        URL url = null;
+        try {
+            url = new URL(path);
+            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+            //璁剧疆瓒呮椂闂翠负3绉�
+            conn.setConnectTimeout(3*1000);
+            //闃叉灞忚斀绋嬪簭鎶撳彇鑰岃繑鍥�403閿欒
+            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
+            //寰楀埌杈撳叆娴�
+            return conn.getInputStream();
+        } catch (Exception e) {
+
+        }
+        return null;
+    }
+
+
+
+}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/dto/YwSmsEmailBillCallDTO.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/dto/YwSmsEmailBillCallDTO.java
new file mode 100644
index 0000000..4d71839
--- /dev/null
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/dto/YwSmsEmailBillCallDTO.java
@@ -0,0 +1,28 @@
+package com.doumee.dao.business.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Eva.Caesar Liu
+ * @date 2023/02/14 11:14
+ */
+@Data
+public class YwSmsEmailBillCallDTO implements Serializable {
+
+    @ApiModelProperty(value = "鎺ユ敹浜轰富閿�" )
+    private Integer userId;
+
+    @ApiModelProperty(value = "璐﹀崟涓婚敭", example = "1")
+    private Integer billId;
+
+    @ApiModelProperty(value = "鏄惁鍙戦�佺煭鎭� 0=鍚︼紱1=鏄�", example = "1")
+    private Integer sendSms;
+
+    @ApiModelProperty(value = "鏄惁鍙戦�侀偖浠� 0=鍚︼紱1=鏄�", example = "1")
+    private Integer sendEmail;
+
+}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java
index 9579cc6..16238e4 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwContractBill.java
@@ -209,6 +209,18 @@
     @ExcelColumn(name="鏄惁閫炬湡",index = 9,width = 6,valueMapping = "0=鏈�炬湡锛�1=宸查�炬湡")
     private Integer isOverdue;
 
+    @ApiModelProperty(value = "鍚堝悓鍗曚环锛堝厓锛�", example = "1")
+    @TableField(exist = false)
+    private BigDecimal price;
+
+    @ApiModelProperty(value = "浠樻鍛ㄦ湡绫诲瀷 0=鍏冩瘡骞崇背澶╋紱1=鍏冩瘡骞崇背鏈堬紱2=鍏冩瘡骞崇背骞达紱3=鍏冩瘡澶╋紱4=鍏冩瘡鏈堬紱5=鍏冩瘡骞达紱6=鍏冩瘡鍦猴紱", example = "1")
+    @TableField(exist = false)
+    private Integer circleType;
+
+    @ApiModelProperty(value = "鏉℃绫诲瀷 0绉熻祦鏉℃ 1鐗╀笟鏉℃", example = "1")
+    @TableField(exist = false)
+    private Integer detailType;
+
     @ApiModelProperty(value = "闄勪欢淇℃伅", example = "1")
     @TableField(exist = false)
     private List<Multifile> multifileList;
@@ -221,4 +233,17 @@
     @TableField(exist = false)
     private List<YwContractRevenue> ywContractRevenueList;
 
+    @ApiModelProperty(value = "绉熻祦鎬婚潰绉�", example = "1")
+    @TableField(exist = false)
+    private BigDecimal totalArea;
+
+    @ApiModelProperty(value = "绉熻祦鏀粯鏂瑰紡 0=涓�娆℃�т粯娆撅紱1=姣忎笁涓湀涓�浠橈紱2=鍏釜鏈堜竴浠橈紱3=涓�骞翠竴浠�", example = "1")
+    @TableField(exist = false)
+    private Integer zlPayType;
+
+    @ApiModelProperty(value = "鐗╀笟鏀粯鏂瑰紡 0=涓�娆℃�т粯娆撅紱1=姣忎笁涓湀涓�浠橈紱2=鍏釜鏈堜竴浠橈紱3=涓�骞翠竴浠�", example = "1")
+    @TableField(exist = false)
+    private Integer wyPayType;
+
+
 }
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwTempConfig.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwTempConfig.java
index 2e9eea1..586f7e9 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwTempConfig.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwTempConfig.java
@@ -1,5 +1,6 @@
 package com.doumee.dao.business.model;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.doumee.core.annotation.excel.ExcelColumn;
 import com.doumee.core.model.LoginUserModel;
 import io.swagger.annotations.ApiModel;
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/SmsEmailService.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/SmsEmailService.java
index a7cc09d..94f8efa 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/SmsEmailService.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/SmsEmailService.java
@@ -98,4 +98,10 @@
     long count(SmsEmail smsEmail);
 
     void sendWaitingSmsNotice();
+
+    Integer sendBillSms(String content,String mobile,Integer billId);
+
+    Integer sendEmail(String email,String content,Integer billId);
+
+
 }
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java
index 7880767..bc2952d 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwContractBillService.java
@@ -7,6 +7,7 @@
 import com.doumee.dao.business.vo.YwContractBillCallDataVO;
 import com.doumee.dao.business.vo.YwContractBillDataVO;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -119,6 +120,7 @@
 
     List<YwContractBillCallDataVO> getNoticeCustomerData(List<Integer> billIds);
 
+    void downloadCallFeeDoc(List<Integer> billIds, LoginUserInfo loginUserInfo, HttpServletResponse response);
 
 
 
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/SmsEmailServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/SmsEmailServiceImpl.java
index 2edabc8..8a856a8 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/SmsEmailServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/SmsEmailServiceImpl.java
@@ -18,6 +18,7 @@
 import com.doumee.dao.system.SystemUserMapper;
 import com.doumee.dao.system.model.SystemUser;
 import com.doumee.service.business.SmsEmailService;
+import com.doumee.service.business.third.EmailService;
 import com.doumee.service.business.third.EmayService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -579,4 +580,52 @@
         }
     }
 
+
+
+    @Override
+    public Integer sendBillSms(String content,String mobile,Integer billId) {
+        if(StringUtils.isBlank(mobile)){
+            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        boolean result=   emayService.sendSingleSms(mobile,content);
+        if(!result){
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鐭俊鍙戦�佸け璐ワ紝璇风◢鍚庨噸璇曪紒");
+        }
+        SmsEmail smsEmail = new SmsEmail();
+        smsEmail.setIsdeleted(Constants.ZERO);
+        smsEmail.setCreateDate(new Date());
+        smsEmail.setStatus(Constants.ZERO);
+        smsEmail.setType(Constants.ZERO);
+        smsEmail.setTitle("璐﹀崟鍌垂");
+        smsEmail.setObjId(billId);
+        smsEmail.setObjType(Constants.ZERO+"");
+        smsEmail.setContent(content);
+        smsEmailMapper.insert(smsEmail);
+        return smsEmail.getId();
+    }
+
+    @Autowired
+    private EmailService emailService;
+
+    @Override
+    public Integer sendEmail(String email,String content,Integer billId) {
+        if(StringUtils.isBlank(email)){
+            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        boolean result=   emailService.sendEmail(email,"璐﹀崟鍌垂",content,null);
+        SmsEmail smsEmail = new SmsEmail();
+        smsEmail.setRemark("閭欢鍙戠敓鎴愬姛");
+        if(!result){
+            smsEmail.setRemark("閭欢鍙戠敓澶辫触");
+        }
+        smsEmail.setIsdeleted(Constants.ZERO);
+        smsEmail.setCreateDate(new Date());
+        smsEmail.setStatus(Constants.ONE);
+        smsEmail.setType(Constants.TWO);
+        smsEmail.setObjId(billId);
+        smsEmail.setObjType(Constants.ONE+"");
+        smsEmail.setContent(content);
+        smsEmailMapper.insert(smsEmail);
+        return smsEmail.getId();
+    }
 }
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
index 5d59968..e941edb 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractBillServiceImpl.java
@@ -2,6 +2,7 @@
 
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.excel.ExcelReplaceCommon;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.model.PageData;
@@ -10,6 +11,7 @@
 import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.Utils;
 import com.doumee.dao.business.*;
+import com.doumee.dao.business.dto.YwSmsEmailBillCallDTO;
 import com.doumee.dao.business.model.*;
 import com.doumee.dao.business.vo.YwContractBillCallDataVO;
 import com.doumee.dao.business.vo.YwContractBillDataVO;
@@ -22,13 +24,18 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import lombok.extern.java.Log;
 import org.apache.commons.lang3.StringUtils;
 import org.checkerframework.checker.units.qual.C;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
 import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -61,6 +68,8 @@
     @Autowired
     private MemberMapper memberMapper;
 
+    @Autowired
+    private YwTempConfigMapper ywTempConfigMapper;
 
 
     @Override
@@ -642,6 +651,7 @@
         ){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璐﹀崟鏁版嵁閿欒锛岃鍒锋柊閲嶈瘯");
         }
+        this.dealRoomDetail(ywContractBillList);
         for (YwContractBill ywContractBill:ywContractBillList) {
             YwContractBillCallDataVO ywContractBillCallDataVO = new YwContractBillCallDataVO();
             ywContractBillCallDataVO.setBillId(ywContractBill.getId());
@@ -658,16 +668,269 @@
     }
 
 
-    public void downloadCallFeeDoc(List<Integer> billIds){
-        List<YwContractBill> ywContractBillList = ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>()
-                .selectAll(YwContractBill.class)
-                .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
-                .selectAs(YwCustomer::getUserId,YwContractBill::getCustomerUserId)
-                .selectAs(YwCustomer::getId,YwContractBill::getCustomerId)
-                .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
-                .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
-                .in(YwContractBill::getId,billIds)
-        );
+    @Override
+    public void downloadCallFeeDoc(List<Integer> billIds, LoginUserInfo loginUserInfo,HttpServletResponse response){
+        try {
+            List<YwContractBill> ywContractBillList = ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>()
+                    .selectAll(YwContractBill.class)
+                    .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
+                    .selectAs(YwCustomer::getUserId,YwContractBill::getCustomerUserId)
+                    .selectAs(YwCustomer::getId,YwContractBill::getCustomerId)
+                    .selectAs(YwContractDetail::getPrice,YwContractBill::getPrice)
+                    .selectAs(YwContract::getCompanyId,YwContractBill::getCompanyId)
+                    .selectAs(YwContractDetail::getCircleType,YwContractBill::getCircleType)
+                    .selectAs(YwContractDetail::getType,YwContractBill::getDetailType)
+                    .selectAs(YwContract::getZlPayType,YwContractBill::getZlPayType)
+                    .selectAs(YwContract::getWyPayType,YwContractBill::getWyPayType)
+                    .select(" ( select ifnull(sum(r.rent_area),0) from yw_room y left join yw_contract_room yr on y.id = yr.room_id where yr.contract_id = t.contract_id and y.IS_INVESTMENT = 0 and yr.type = 0 )  " , YwContractBill::getTotalArea)
+                    .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
+                    .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
+                    .leftJoin(YwContractDetail.class,YwContractDetail::getId,YwContractBill::getDetailId)
+                    .in(YwContractBill::getId,billIds)
+            );
+            List<YwTempConfig> ywTempConfigList = ywTempConfigMapper.selectList(new QueryWrapper<YwTempConfig>().lambda().eq(YwTempConfig::getIsdeleted,Constants.ZERO));
+            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywTempConfigList)){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌妯℃澘閰嶇疆椤�,璇疯仈绯荤鐞嗗憳");
+            }
+            List<YwTempConfig> tempList = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.FOUR)||
+                    Constants.equalsInteger(i.getType(),Constants.FIVE)||
+                    Constants.equalsInteger(i.getType(),Constants.SIX)).collect(Collectors.toList());
+            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(tempList)){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌妯℃澘閰嶇疆椤�,璇疯仈绯荤鐞嗗憳");
+            }
+            List<File> fileList = new ArrayList<>();
+            for (YwContractBill ywContractBill:ywContractBillList) {
+                this.dealTempData(tempList,ywContractBill,loginUserInfo);
+                String fileName =  "鍌垂閫氱煡鍗昣" +ywContractBill.getCode() +"_" + System.currentTimeMillis()+".docx";
+                YwTempConfig ywTempConfig = new YwTempConfig();
+                if(Constants.equalsInteger(ywContractBill.getType(),Constants.ZERO)){
+                    Optional<YwTempConfig> optional = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.TWO)).findAny();
+                    if (optional.isPresent()) {
+                        ywTempConfig = optional.get();
+                    }
+                }else{
+                    Optional<YwTempConfig> optional = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.THREE)).findAny();
+                    if (optional.isPresent()) {
+                        ywTempConfig = optional.get();
+                    }
+                }
+                if(Objects.isNull(ywTempConfig)){
+                    throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"妯℃澘淇℃伅寮傚父,璇疯仈绯荤鐞嗗憳");
+                }
+                String path = ExcelReplaceCommon.modifyWordTemplate(ywTempConfig.getUrl(),tempList,fileName);
+                File f = new File(path);
+                if(f !=null && f.isFile()){
+                    fileList.add(f);
+                }
+                if(fileList == null || fileList.size() == 0){
+                    throw  new BusinessException(ResponseStatus.DATA_EMPTY);
+                }
+            }
+            String fileName =  "鍌垂閫氱煡鍗�-" +System.currentTimeMillis();
+            String encodeFileName = URLEncoder.encode(fileName, Charset.forName("UTF-8").toString())+".zip";
+            response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName);
+            response.setContentType("application/octet-stream");
+            response.setHeader("eva-opera-type", "download");
+            response.setHeader("eva-download-filename", encodeFileName);
+            Constants.packFilesToZip(fileList,response.getOutputStream());
+        } catch (Exception e) {
+            throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+        }
     }
 
+
+    public void dealTempData(List<YwTempConfig> ywTempConfigList , YwContractBill ywContractBill, LoginUserInfo loginUserInfo){
+        //鏌ヨ鏀舵敮璐﹀彿鏁版嵁
+
+        for (YwTempConfig y:ywTempConfigList) {
+            if(y.getTitle().equals("${璐圭敤鍚嶇О}")&&Objects.nonNull(ywContractBill.getCostType())){
+                //璐圭敤绫诲瀷锛�0=绉熻祦璐癸紱1=鐗╀笟璐癸紱2=绉熻祦鎶奸噾锛�3=鐗╀笟鎶奸噾锛�4=姘寸數璐癸紱5=鏉傞」璐癸紱6=鍏朵粬; 7=淇濊瘉閲�
+                if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.ZERO)){
+                    y.setUrl("绉熻祦璐�");
+                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.ONE)){
+                    y.setUrl("鐗╀笟璐�");
+                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.TWO)){
+                    y.setUrl("绉熻祦鎶奸噾");
+                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.THREE)){
+                    y.setUrl("鐗╀笟鎶奸噾");
+                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.FOUR)){
+                    y.setUrl("姘寸數璐�");
+                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.FIVE)){
+                    y.setUrl("鏉傞」璐�");
+                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.SIX)){
+                    y.setUrl("鍏朵粬");
+                }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.SEVEN)){
+                    y.setUrl("淇濊瘉閲�");
+                }
+            }else if(y.getTitle().equals("${璁¤垂鍛ㄦ湡}")&&Objects.nonNull(ywContractBill.getDetailType())){
+                if(Constants.equalsInteger(ywContractBill.getDetailType(),Constants.ZERO)){
+                    //绉熻祦鏀粯鏂瑰紡 0=涓�娆℃�т粯娆撅紱1=姣忎笁涓湀涓�浠橈紱2=鍏釜鏈堜竴浠橈紱3=涓�骞翠竴浠�
+                    if(Objects.nonNull(ywContractBill.getZlPayType())){
+                        if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.ZERO)){
+                            y.setUrl("涓�娆℃�т粯娆�");
+                        }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.ONE)){
+                            y.setUrl("姣忎笁涓湀涓�浠�");
+                        }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.TWO)){
+                            y.setUrl("鍏釜鏈堜竴浠�");
+                        }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.THREE)){
+                            y.setUrl("涓�骞翠竴浠�");
+                        }
+                    }
+                }else{
+                    //鐗╀笟鏀粯鏂瑰紡 0=涓�娆℃�т粯娆撅紱1=姣忎笁涓湀涓�浠橈紱2=鍏釜鏈堜竴浠橈紱3=涓�骞翠竴浠�
+                    if(Objects.nonNull(ywContractBill.getWyPayType())){
+                        if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.ZERO)){
+                            y.setUrl("涓�娆℃�т粯娆�");
+                        }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.ONE)){
+                            y.setUrl("姣忎笁涓湀涓�浠�");
+                        }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.TWO)){
+                            y.setUrl("鍏釜鏈堜竴浠�");
+                        }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.THREE)){
+                            y.setUrl("涓�骞翠竴浠�");
+                        }
+                    }
+                }
+            }else if(y.getTitle().equals("${鍗曚环}")&&Objects.nonNull(ywContractBill.getPrice())){
+                y.setUrl(ywContractBill.getPrice().toString());
+            }else if(y.getTitle().equals("${鍗曚綅}")&&Objects.nonNull(ywContractBill.getCircleType())){
+                //浠樻鍛ㄦ湡绫诲瀷 0=鍏冩瘡骞崇背澶�;1=鍏冩瘡骞崇背鏈�;2=鍏冩瘡骞崇背骞�;3=鍏冩瘡澶�;4=鍏冩瘡鏈�;5=鍏冩瘡骞�;6=鍏冩瘡鍦�;
+                if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ZERO)){
+                    y.setUrl("鍏冩瘡骞崇背澶�");
+                }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
+                    y.setUrl("鍏冩瘡骞崇背鏈�");
+                }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
+                    y.setUrl("鍏冩瘡骞崇背骞�");
+                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
+                    y.setUrl("鍏冩瘡澶�");
+                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
+                    y.setUrl("鍏冩瘡鏈�");
+                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
+                    y.setUrl("鍏冩瘡骞�");
+                } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){
+                    y.setUrl("鍏冩瘡鍦�");
+                }
+            }else if(y.getTitle().equals("${搴旀敹鏃ユ湡}")&&Objects.nonNull(ywContractBill.getPlanPayDate())){
+                y.setUrl(DateUtil.formatDate(ywContractBill.getPlanPayDate(),"yyyy-MM-dd"));
+            }else if(y.getTitle().equals("${搴旀敹閲戦}")&&Objects.nonNull(ywContractBill.getReceivableFee())){
+                y.setUrl(ywContractBill.getReceivableFee().toString());
+            }else if(y.getTitle().equals("${璐﹀崟澶囨敞}")){
+                if(StringUtils.isNotBlank(ywContractBill.getRemark())){
+                    y.setUrl(ywContractBill.getRemark());
+                }else{
+                    y.setUrl("");
+                }
+            }else if(y.getTitle().equals("${绉熷鍚嶇О}")&&StringUtils.isNotBlank(ywContractBill.getCustomerName())){
+                y.setUrl(ywContractBill.getCustomerName());
+            }else if(y.getTitle().equals("${妤煎畤/妤煎眰/鎴挎簮}")){
+                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getYwContractRoomList())){
+                    StringBuilder roomPathName = new StringBuilder();
+                    for (YwContractRoom ywContractRoom:ywContractBill.getYwContractRoomList()) {
+                        if(StringUtils.isNotBlank(ywContractRoom.getProjectName())){
+                            roomPathName.append(ywContractRoom.getProjectName()+"/");
+                        }
+                        if(StringUtils.isNotBlank(ywContractRoom.getBuildingName())){
+                            roomPathName.append(ywContractRoom.getBuildingName()+"/");
+                        }
+                        if(StringUtils.isNotBlank(ywContractRoom.getFloorName())){
+                            roomPathName.append(ywContractRoom.getFloorName()+"/");
+                        }
+                        if(StringUtils.isNotBlank(ywContractRoom.getRoomName())){
+                            roomPathName.append(ywContractRoom.getRoomName());
+                        }
+                        if(StringUtils.isNotBlank(roomPathName)){
+                            roomPathName.append(";");
+                        }
+                    }
+                    y.setUrl(roomPathName.toString());
+                }
+            }else if(y.getTitle().equals("${绉熻祦闈㈢Н}")&&Objects.nonNull(ywContractBill.getTotalArea())){
+                y.setUrl(ywContractBill.getTotalArea().toString());
+            }else if(y.getTitle().equals("${鎵�灞炲叕鍙歌处鎴峰悕绉皚")){
+                y.setUrl("鎵�灞炲叕鍙歌处鎴峰悕绉�");
+            }else if(y.getTitle().equals("${鎵�灞炲叕鍙搁摱琛岃处鍙穧")){
+                y.setUrl("鎵�灞炲叕鍙搁摱琛岃处鍙�");
+            }else if(y.getTitle().equals("${鎵�灞炲叕鍙稿紑鎴烽摱琛寎")){
+                y.setUrl("鎵�灞炲叕鍙稿紑鎴烽摱琛�");
+            }else if(y.getTitle().equals("${閫氱煡鍗曠敓鎴愭棩鏈焳")){
+                y.setUrl(DateUtil.formatDate(new Date(),"yyyy-MM-dd"));
+            }else if(y.getTitle().equals("${褰撳墠鐢ㄦ埛濮撳悕}")){
+                y.setUrl(loginUserInfo.getRealname());
+            }
+        }
+    }
+
+
+    public void sendSmsEmail(List<YwSmsEmailBillCallDTO> ywSmsEmailBillCallDTOList,LoginUserInfo loginUserInfo){
+        if(CollectionUtils.isEmpty(ywSmsEmailBillCallDTOList)){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        List<YwTempConfig> ywTempConfigList = ywTempConfigMapper.selectList(new QueryWrapper<YwTempConfig>().lambda().eq(YwTempConfig::getIsdeleted,Constants.ZERO));
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywTempConfigList)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌妯℃澘閰嶇疆椤�,璇疯仈绯荤鐞嗗憳");
+        }
+        List<YwTempConfig> tempList = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.FOUR)||
+                Constants.equalsInteger(i.getType(),Constants.FIVE)||
+                Constants.equalsInteger(i.getType(),Constants.SIX)).collect(Collectors.toList());
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(tempList)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌妯℃澘閰嶇疆椤�,璇疯仈绯荤鐞嗗憳");
+        }
+        for (YwSmsEmailBillCallDTO ywSmsEmailBillCallDTO:ywSmsEmailBillCallDTOList) {
+            if(Objects.isNull(ywSmsEmailBillCallDTO)
+            || Objects.isNull(ywSmsEmailBillCallDTO.getBillId())
+                    || Objects.isNull(ywSmsEmailBillCallDTO.getUserId())
+            ||Objects.isNull(ywSmsEmailBillCallDTO.getSendEmail())
+                    || Objects.isNull(ywSmsEmailBillCallDTO.getSendSms())){
+                throw new BusinessException(ResponseStatus.BAD_REQUEST);
+            }
+
+            YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>()
+                    .selectAll(YwContractBill.class)
+                    .selectAs(YwCustomer::getName,YwContractBill::getCustomerName)
+                    .selectAs(YwCustomer::getUserId,YwContractBill::getCustomerUserId)
+                    .selectAs(YwCustomer::getId,YwContractBill::getCustomerId)
+                    .selectAs(YwContractDetail::getPrice,YwContractBill::getPrice)
+                    .selectAs(YwContract::getCompanyId,YwContractBill::getCompanyId)
+                    .selectAs(YwContractDetail::getCircleType,YwContractBill::getCircleType)
+                    .selectAs(YwContractDetail::getType,YwContractBill::getDetailType)
+                    .selectAs(YwContract::getZlPayType,YwContractBill::getZlPayType)
+                    .selectAs(YwContract::getWyPayType,YwContractBill::getWyPayType)
+                    .select(" ( select ifnull(sum(r.rent_area),0) from yw_room y left join yw_contract_room yr on y.id = yr.room_id where yr.contract_id = t.contract_id and y.IS_INVESTMENT = 0 and yr.type = 0 )  " , YwContractBill::getTotalArea)
+                    .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId)
+                    .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
+                    .leftJoin(YwContractDetail.class,YwContractDetail::getId,YwContractBill::getDetailId)
+                    .eq(YwContractBill::getId,ywSmsEmailBillCallDTO.getBillId())
+                    .last( "limit 1" )
+            );
+            this.dealTempData(tempList,ywContractBill,loginUserInfo);
+            Member member = memberMapper.selectById(ywSmsEmailBillCallDTO.getUserId());
+            if(Objects.isNull(member)){
+                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀛樺湪鏈煡璇㈠埌鐨勪汉鍛樹俊鎭�");
+            }
+
+
+        }
+
+
+        for (YwSmsEmailBillCallDTO ywSmsEmailBillCallDTO:ywSmsEmailBillCallDTOList) {
+
+
+
+
+
+        }
+
+
+
+
+
+
+
+
+
+
+        
+    }
+
+
+
 }
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/third/EmailService.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/third/EmailService.java
new file mode 100644
index 0000000..cdd7a38
--- /dev/null
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/third/EmailService.java
@@ -0,0 +1,47 @@
+package com.doumee.service.business.third;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessageHelper;
+import org.springframework.stereotype.Service;
+
+import javax.mail.internet.MimeMessage;
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class EmailService {
+    @Autowired
+    private JavaMailSender javaMailSender;//娉ㄥ叆JavaMailSender
+    @Value("${spring.mail.username}")
+    private String fromEmail;
+    public boolean sendEmail(String toEmail, String title, String content, List<Map<String,Object>> fileList) {
+        try {
+                AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
+                context.refresh();
+                MimeMessage message = javaMailSender.createMimeMessage();
+                MimeMessageHelper helper = new MimeMessageHelper(message, true);
+
+                helper.setTo(toEmail);
+                helper.setFrom(fromEmail);
+                helper.setSubject(title);
+                helper.setText(content);
+                if(fileList!=null){
+                    for (Map<String,Object> f : fileList){
+                        // 璁剧疆闄勪欢
+                        helper.addAttachment((String) f.get("name"),new FileSystemResource((File) f.get("file")));
+                    }
+                }
+            javaMailSender.send(message);
+                    System.out.println("閭欢鍙戦�佹垚鍔燂紒");
+                    return true;
+            } catch (Exception e) {
+            e.printStackTrace();
+                    return false;
+                }
+            }
+    }

--
Gitblit v1.9.3