瀏覽代碼

word调整

LAPTOP-FO2T5SIU\35838 9 月之前
父節點
當前提交
b2178f1f6a

+ 2 - 1
pro-base/src/main/java/com/idea/customerManagement/service/CustomerManagementService.java

@@ -353,6 +353,7 @@ public class CustomerManagementService implements BaseService<CustomerManagement
             Map<String, Object> data = new HashMap<>();
             Map<String, Object> picData = new HashMap<>();
             Map<String, Object> sealData = new HashMap<>();
+            Map<String, Object> settingData = new HashMap<>();
             data.put("${name}", name);
             data.put("${identityCard}", identityCard);
             data.put("${roomSelectionNumber}", roomSelectionNumber);
@@ -360,7 +361,7 @@ public class CustomerManagementService implements BaseService<CustomerManagement
             data.put("${month}", month);
             data.put("${date}", date);
             data.put("${region}", region);
-            ReplaceWord.operateWord(response,filePath,fileName,data, picData,sealData);
+            ReplaceWord.operateWord(response,filePath,fileName,data, picData,sealData,settingData);
         }
 
 

+ 4 - 2
pro-base/src/main/java/com/idea/customerManagement/service/IntentionalDepositService.java

@@ -419,6 +419,7 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
 
         IntentionalDeposit newRecord = selectByPrimaryKey(model.getId());
         String filePath = "/home/project/settleDown/tem/receipt.docx";
+        String sealPath = "/home/project/settleDown/tem/seal.png";
         String fileName = "意向金收据.docx";
         String customerManagementId = newRecord.getCustomerManagementId();
         BuyerExample buyerExample = new BuyerExample();
@@ -457,6 +458,7 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
         Map<String, Object> data = new HashMap<>();
         Map<String, Object> picData = new HashMap<>();
         Map<String, Object> sealData = new HashMap<>();
+        Map<String, Object> settingData = new HashMap<>();
         data.put("${serialNumber}", serialNumber);
         data.put("${name}", builder.toString());
         data.put("${collectionTime}", collectionTime);
@@ -465,8 +467,8 @@ public class IntentionalDepositService implements BaseService<IntentionalDeposit
         data.put("${fullName}", fullName);
         data.put("${capital}", capital);
         data.put("${receivedAmount}", receivedAmount);
-
-        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData);
+        sealData.put("${seal}", sealPath);
+        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
 
 
     }

+ 8 - 9
pro-base/src/main/java/com/idea/customerManagement/service/RoomSelectionInfoService.java

@@ -298,8 +298,6 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
     public void downLoad(RoomSelectionInfoDto model, HttpServletRequest request, HttpServletResponse response) {
 
         String filePath = "/home/project/settleDown/tem/roomConfirmationSheet.docx";
-//        String picturePath = "C:\\Users\\35838\\Pictures\\liuhaizhu.jpg";
-//        String sealPath = "C:\\Users\\35838\\Pictures\\seal.png";
         String fileName = "房源确认单.docx";
         String customerManagementId = model.getCustomerManagementId();
         BuyerExample buyerExample = new BuyerExample();
@@ -317,6 +315,8 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
             Map<String, Object> data = new HashMap<>();
             Map<String, Object> picData = new HashMap<>();
             Map<String, Object> sealData = new HashMap<>();
+            Map<String, Object> settingData = new HashMap<>();
+
             data.put("${name}", buyer.getName());
             data.put("${identityCard}", buyer.getIdentityCard());
             data.put("${address}", fullName);
@@ -324,9 +324,7 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
             data.put("${roomNumber}", roomResponse.getRoomNumber());
             data.put("${roomChooseDate}", roomChooseDate);
             data.put("${username}", loginName);
-//            picData.put("${picture}", picturePath);
-//            sealData.put("${seal}", sealPath);
-            ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData);
+            ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
         }
 
 
@@ -366,11 +364,11 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
         List<Buyer> buyers = buyerService.selectByExample(buyerExample);
         StringBuilder builder = new StringBuilder();
         if (CollectionUtils.isNotEmpty(buyers)) {
-            for(Buyer buyer: buyers){
+            for (Buyer buyer : buyers) {
                 builder.append(buyer.getName()).append(",");
             }
-            if(builder.length() > 0){
-                builder.deleteCharAt(builder.length()-1);
+            if (builder.length() > 0) {
+                builder.deleteCharAt(builder.length() - 1);
             }
         }
 
@@ -394,6 +392,7 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
         Map<String, Object> data = new HashMap<>();
         Map<String, Object> picData = new HashMap<>();
         Map<String, Object> sealData = new HashMap<>();
+        Map<String, Object> settingData = new HashMap<>();
         data.put("${serialNumber}", serialNumber);
         data.put("${name}", builder.toString());
         data.put("${collectionTime}", collectionTime);
@@ -403,7 +402,7 @@ public class RoomSelectionInfoService implements BaseService<RoomSelectionInfo,
         data.put("${capital}", capital);
         data.put("${receivedAmount}", receivedAmount);
 
-        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData);
+        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
 
 
     }

+ 13 - 1
pro-base/src/main/java/com/idea/invoice/controller/ReceiptManageController.java

@@ -1,6 +1,7 @@
 package com.idea.invoice.controller;
 
 import com.github.pagehelper.PageInfo;
+import com.idea.customerManagement.model.IntentionalDeposit;
 import com.idea.invoice.dto.ReceiptManageDto;
 import com.idea.invoice.model.ReceiptManage;
 import com.idea.invoice.service.ReceiptManageService;
@@ -10,10 +11,13 @@ import com.rockstar.frame.model.extend.Tablepar;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import javax.servlet.http.HttpServletResponse;
+
 @Controller
 @RequestMapping(value = "ReceiptManageController")
 @Api(value="票据管理")
@@ -32,7 +36,15 @@ public class ReceiptManageController extends BaseController {
 
 
 
-
+    /**
+     * 意向金收据下载
+     * @param id
+     * @param response
+     */
+    @GetMapping(value = "downLoadReceipt",produces = {"application/json;charset=UTF-8"})
+    public void downLoadReceipt(String id, HttpServletResponse response) {
+        modelService.downLoadReceipt(id,response);
+    }
 
 
 

+ 164 - 10
pro-base/src/main/java/com/idea/invoice/service/ReceiptManageService.java

@@ -3,21 +3,38 @@ package com.idea.invoice.service;
 import cn.hutool.core.util.IdUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.idea.buildManage.mapper.ParkRoomExtendMapper;
+import com.idea.buildManage.response.ParkRoomResponse;
+import com.idea.customerManagement.mapper.CustomerManagementMapper;
+import com.idea.customerManagement.mapper.IntentionalDepositMapper;
+import com.idea.customerManagement.mapper.RoomSelectionInfoMapper;
+import com.idea.customerManagement.model.*;
+import com.idea.customerManagement.service.BuyerService;
 import com.idea.invoice.dto.ReceiptManageDto;
 import com.idea.invoice.mapper.ReceiptManageExtendMapper;
 import com.idea.invoice.mapper.ReceiptManageMapper;
 import com.idea.invoice.model.InvoiceManage;
 import com.idea.invoice.model.ReceiptManage;
 import com.idea.invoice.model.ReceiptManageExample;
+import com.idea.paymentManagement.model.PayLog;
+import com.idea.paymentManagement.service.PayLogService;
+import com.idea.util.DateUtils;
+import com.idea.util.MoneyUtils;
+import com.idea.util.ReplaceWord;
 import com.rockstar.common.base.BaseService;
 import com.rockstar.frame.model.extend.Tablepar;
 import com.rockstar.shiro.util.ShiroUtils;
+import com.rockstar.system.service.SysDictService;
 import com.rockstar.util.StringUtils;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptManageExample> {
@@ -26,7 +43,20 @@ public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptM
     private ReceiptManageMapper modelMapper;
     @Autowired
     private ReceiptManageExtendMapper extendMapper;
-
+    @Autowired
+    private BuyerService buyerService;
+    @Autowired
+    private CustomerManagementMapper customerManagementMapper;
+    @Autowired
+    private ParkRoomExtendMapper roomExtendMapper;
+    @Autowired
+    private SysDictService sysDictService;
+    @Autowired
+    private IntentionalDepositMapper intentionalDepositMapper;
+    @Autowired
+    private RoomSelectionInfoMapper roomSelectionInfoMapper;
+    @Autowired
+    private PayLogService payLogService;
 
     @Override
     public int deleteByPrimaryKey(String s) {
@@ -51,12 +81,12 @@ public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptM
 
     @Override
     public int updateByExampleSelective(ReceiptManage receiptManage, ReceiptManageExample receiptManageExample) {
-        return modelMapper.updateByExampleSelective(receiptManage,receiptManageExample);
+        return modelMapper.updateByExampleSelective(receiptManage, receiptManageExample);
     }
 
     @Override
     public int updateByExample(ReceiptManage receiptManage, ReceiptManageExample receiptManageExample) {
-        return modelMapper.updateByExample(receiptManage,receiptManageExample);
+        return modelMapper.updateByExample(receiptManage, receiptManageExample);
     }
 
     @Override
@@ -74,34 +104,34 @@ public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptM
         return modelMapper.deleteByExample(receiptManageExample);
     }
 
-    public ReceiptManageExample getCondition(ReceiptManage model){
+    public ReceiptManageExample getCondition(ReceiptManage model) {
 
         ReceiptManageExample example = new ReceiptManageExample();
         example.setOrderByClause("created_at");
         ReceiptManageExample.Criteria criteria = example.createCriteria();
-        if(StringUtils.isNotEmpty(model.getHouseName())){
+        if (StringUtils.isNotEmpty(model.getHouseName())) {
             criteria.andHouseNameLike("%" + model.getHouseName() + "%");
         }
         return example;
     }
 
-    public PageInfo listByModel(Tablepar tablepar, ReceiptManageDto model){
+    public PageInfo listByModel(Tablepar tablepar, ReceiptManageDto model) {
 
-        PageHelper.startPage(tablepar.getPageNum(),tablepar.getPageSize());
+        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
         List<ReceiptManageDto> receiptManages = extendMapper.listByModel(model);
         return new PageInfo<ReceiptManageDto>(receiptManages);
     }
 
 
-
     /**
      * 新增票据 其他业务调用
+     *
      * @param model
      * @return
      */
-    public int add(ReceiptManage model){
+    public int add(ReceiptManage model) {
 
-        if(model.getReceiptStatus() == null){
+        if (model.getReceiptStatus() == null) {
             // 默认 已开
             model.setReceiptStatus(1);
         }
@@ -111,5 +141,129 @@ public class ReceiptManageService implements BaseService<ReceiptManage, ReceiptM
         return result;
     }
 
+    /**
+     * 票据管理 收款收据下载
+     *
+     * @param id
+     * @param response
+     */
+    public void downLoadReceipt(String id, HttpServletResponse response) {
+
+        ReceiptManage receiptManage = selectByPrimaryKey(id);
+        String filePath = "/home/project/settleDown/tem/receipt.docx";
+        String sealPath = "/home/project/settleDown/tem/seal.png";
+        String sealPath2 = "/home/project/settleDown/tem/huanpiao.png";
+        String fileName = "";
+        String serialNumber = "";
+        String collectionTime = "";
+        String content = "";
+        String dictLabel = "";
+        String paymentMethod = "";
+        switch (receiptManage.getReceiptType()) {
+            case "1":
+                fileName = "意向金收据.docx";
+                IntentionalDeposit record = intentionalDepositMapper.selectByPrimaryKey(receiptManage.getBusinessId());
+                serialNumber = record.getSerialNumber();
+                collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, record.getCollectionTime());
+                dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", record.getPaymentMethod().toString());
+                if (StringUtils.isNotEmpty(dictLabel)) {
+                    paymentMethod = dictLabel;
+                }
+                content = "意向金";
+                break;
+            case "2":
+                fileName = "定金收据.docx";
+                RoomSelectionInfo deposit = roomSelectionInfoMapper.selectByPrimaryKey(receiptManage.getBusinessId());
+                serialNumber = deposit.getSerialNumber();
+                collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, deposit.getCollectionTime());
+                dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", deposit.getPaymentMethod().toString());
+                if (StringUtils.isNotEmpty(dictLabel)) {
+                    paymentMethod = dictLabel;
+                }
+                content = "意向金";
+                break;
+            case "3":
+                fileName = "首期收据.docx";
+                content = "首期";
+                break;
+            case "4":
+                fileName = "银行按揭收据.docx";
+                content = "银行按揭";
+                break;
+            default:
+                PayLog payLog = payLogService.selectByPrimaryKey(receiptManage.getBusinessId());
+                collectionTime = DateUtils.parseDateToStr(DateUtils.DATE_CH, payLog.getPayTime());
+                dictLabel = sysDictService.getDictLabel("COLLECTION_METHODS", payLog.getPaymentMethod().toString());
+                if (StringUtils.isNotEmpty(dictLabel)) {
+                    paymentMethod = dictLabel;
+                }
+        }
+        String customerManagementId = receiptManage.getCustomerManagementId();
+        CustomerManagement customerManagement = customerManagementMapper.selectByPrimaryKey(customerManagementId);
+        BuyerExample buyerExample = new BuyerExample();
+        buyerExample.setOrderByClause("order_num asc");
+        buyerExample.createCriteria().andCustomerManagementIdEqualTo(customerManagementId);
+        List<Buyer> buyers = buyerService.selectByExample(buyerExample);
+        StringBuilder builder = new StringBuilder();
+        if (CollectionUtils.isNotEmpty(buyers)) {
+            for (Buyer buyer : buyers) {
+                builder.append(buyer.getName()).append(",");
+            }
+            if (builder.length() > 0) {
+                builder.deleteCharAt(builder.length() - 1);
+            }
+        }
+        String fullName = "";
+        // 意向金只有选房后 才有houseId
+        if (StringUtils.isNotEmpty(customerManagement.getHouseId())) {
+            ParkRoomResponse roomResponse = roomExtendMapper.getFullName(customerManagement.getHouseId());
+            fullName = roomResponse.getGroupName() + "-"
+                    + roomResponse.getDiscName() + "-"
+                    + roomResponse.getBuildName() + "-"
+                    + roomResponse.getRoomNo();
+        }
+
+        String receivedAmount = receiptManage.getReceiptMoney().toString();
+        String capital = MoneyUtils.amountConversion(receivedAmount);
+
+        Map<String, Object> data = new HashMap<>();
+        Map<String, Object> picData = new HashMap<>();
+        Map<String, Object> sealData = new HashMap<>();
+        Map<String, Object> settingData = new HashMap<>();
+        Map<String, Object> settingInfoData;
+
+        data.put("${serialNumber}", serialNumber);
+        data.put("${name}", builder.toString());
+        data.put("${collectionTime}", collectionTime);
+        data.put("${content}", content);
+        data.put("${paymentMethod}", paymentMethod);
+        data.put("${fullName}", fullName);
+        data.put("${capital}", capital);
+        data.put("${receivedAmount}", receivedAmount);
+        sealData.put("${seal}", sealPath);
+
+        settingInfoData = new HashMap<>();
+        settingInfoData.put("leftOffset", "50");
+        settingInfoData.put("topOffset", "-50");
+        settingData.put("${seal}",settingInfoData);
+
+
+        // 已换票 已红冲
+        if (receiptManage.getReceiptStatus() == 2 || receiptManage.getReceiptStatus() == 3) {
+            filePath = "/home/project/settleDown/tem/receipt_huanpiao.docx";
+            sealData.put("${huanpiao}", sealPath2);
+
+            settingInfoData = new HashMap<>();
+            settingInfoData.put("leftOffset", "300");
+            settingInfoData.put("topOffset", "-50");
+            settingData.put("${huanpiao}",settingInfoData);
+
+        }
+
+        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
+
+
+    }
+
 
 }

+ 4 - 2
pro-base/src/main/java/com/idea/paymentManagement/service/PayLogService.java

@@ -316,6 +316,7 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
 
         PayLog payLog = selectByPrimaryKey(id);
         Integer contentType = payLog.getContentType();
+        String sealPath = "/home/project/settleDown/tem/seal.png";
         String filePath = "";
         String fileName = "";
         switch (contentType){
@@ -368,6 +369,7 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
         Map<String, Object> data = new HashMap<>();
         Map<String, Object> picData = new HashMap<>();
         Map<String, Object> sealData = new HashMap<>();
+        Map<String, Object> settingData = new HashMap<>();
         data.put("${name}", name);
         data.put("${collectionTime}", collectionTime);
         data.put("${fullName}", fullName);
@@ -375,8 +377,8 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
         data.put("${paymentMethod}", paymentMethod);
         data.put("${capital}", capital);
         data.put("${receivedAmount}", receivedAmount);
-
-        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData);
+        sealData.put("${seal}", sealPath);
+        ReplaceWord.operateWord(response, filePath, fileName, data, picData, sealData, settingData);
 
 
     }

+ 15 - 7
pro-base/src/main/java/com/idea/util/ReplaceWord.java

@@ -79,12 +79,13 @@ public class ReplaceWord {
 
     /**
      * 替换印章图片
+     *
      * @param document
      * @param sealData
      * @throws Exception
      */
     public static void changeSeal(XWPFDocument document, Map<String, Object> sealData,
-                                  int leftOffset, int topOffset, boolean behind) throws Exception {
+                                  Map<String, Object> settingData) throws Exception {
         // 获取段落集合
         Iterator<XWPFParagraph> iterator = document.getParagraphsIterator();
         XWPFParagraph paragraph;
@@ -93,7 +94,7 @@ public class ReplaceWord {
             // 判断此段落是否需要替换
             String text = paragraph.getText();
             if (checkText(text)) {
-                replaceSealValue(paragraph, sealData,leftOffset,topOffset,behind);
+                replaceSealValue(paragraph, sealData, settingData);
             }
         }
     }
@@ -226,11 +227,18 @@ public class ReplaceWord {
     }
 
     public static void replaceSealValue(XWPFParagraph paragraph, Map<String, Object> sealData,
-                                        int leftOffset, int topOffset, boolean behind) throws Exception {
+                                        Map<String, Object> settingData) throws Exception {
         List<XWPFRun> runs = paragraph.getRuns();
         for (XWPFRun run : runs) {
             Object value = changeValue(run.toString(), sealData);
             if (sealData.containsKey(run.toString())) {
+                int leftOffset = 0, topOffset = 0;
+                boolean behind = false;
+                if(settingData.containsKey(run.toString())){
+                    Map<String, Object> settingInfo = (Map<String, Object>) settingData.get(run.toString());
+                    leftOffset = Integer.parseInt(settingInfo.get("leftOffset").toString());
+                    topOffset = Integer.parseInt(settingInfo.get("topOffset").toString());
+                }
                 //清空内容
                 run.setText("", 0);
                 FileInputStream is = new FileInputStream((String) value);
@@ -295,7 +303,7 @@ public class ReplaceWord {
         operateWord(data, picData);
     }
 
-    public static void operateWord(Map<String, Object> data, Map<String, Object> picData){
+    public static void operateWord(Map<String, Object> data, Map<String, Object> picData) {
         try {
             FileInputStream is = new FileInputStream("C:\\Users\\35838\\Desktop\\中低收入家庭购买共有产权保障房房源确认单(惠景).docx");
             XWPFDocument document = new XWPFDocument(is);
@@ -320,8 +328,8 @@ public class ReplaceWord {
         }
     }
 
-    public static void operateWord(HttpServletResponse response,String filePath,String fileName, Map<String, Object> data,
-                                   Map<String, Object> picData,Map<String, Object> sealData){
+    public static void operateWord(HttpServletResponse response, String filePath, String fileName, Map<String, Object> data,
+                                   Map<String, Object> picData, Map<String, Object> sealData, Map<String, Object> settingData) {
         try {
             FileInputStream is = new FileInputStream(filePath);
             XWPFDocument document = new XWPFDocument(is);
@@ -339,7 +347,7 @@ public class ReplaceWord {
             }
             if (sealData.size() > 0) {
                 // 替换内容图片
-                ReplaceWord.changeSeal(document, sealData,0,0,false);
+                ReplaceWord.changeSeal(document, sealData, settingData);
             }
             response.setContentType("text/html;charset=UTF-8");
             response.setContentType("application/msword");