Просмотр исходного кода

Merge branch 'develop' of https://git.youlane.cn/server/formallProject into develop

release_toaliyun_real
Burce 6 лет назад
Родитель
Сommit
b6529c09b4
5 измененных файлов: 48 добавлений и 59 удалений
  1. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java
  2. +0
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java
  3. +41
    -50
      mallinkService/src/main/java/com/iformall/utils/WordUtil.java
  4. Двоичные данные
      mallinkService/src/main/resources/contract-word-template/settle.docx
  5. +6
    -6
      mallinkService/src/main/resources/mapper/WxBillAllMapper.xml

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java Просмотреть файл

@@ -844,7 +844,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
} }
wordDocTableVo.setParams(rowsParams); wordDocTableVo.setParams(rowsParams);
wordDocTableVo.setTableIndex(0); wordDocTableVo.setTableIndex(0);
wordDocTableVo.setRowIndex(1);
wordDocTableVo.setRowIndex(2);


String templatePath = "contract-word-template/settle.docx"; String templatePath = "contract-word-template/settle.docx";
String filepath = fmUploadDir; String filepath = fmUploadDir;


+ 0
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java Просмотреть файл

@@ -12,8 +12,6 @@ import com.iformall.service.ExcelService;
import com.iformall.service.WxBillSettleService; import com.iformall.service.WxBillSettleService;
import com.iformall.service.WxFlowService; import com.iformall.service.WxFlowService;
import com.iformall.utils.DateUtils; import com.iformall.utils.DateUtils;
import org.apache.commons.collections.CollectionUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;


+ 41
- 50
mallinkService/src/main/java/com/iformall/utils/WordUtil.java Просмотреть файл

@@ -3,14 +3,10 @@ package com.iformall.utils;
import cn.afterturn.easypoi.word.WordExportUtil; import cn.afterturn.easypoi.word.WordExportUtil;
import com.iformall.domain.vo.WordDocTableVo; import com.iformall.domain.vo.WordDocTableVo;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.*; import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;

import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
@@ -99,59 +95,54 @@ public class WordUtil {
public static void insertValueToTable(XWPFDocument xwpfDocument, WordDocTableVo wordDocTableVo) throws Exception { public static void insertValueToTable(XWPFDocument xwpfDocument, WordDocTableVo wordDocTableVo) throws Exception {
List<XWPFTable> tableList = xwpfDocument.getTables(); List<XWPFTable> tableList = xwpfDocument.getTables();
XWPFTable table = tableList.get(wordDocTableVo.getTableIndex()); XWPFTable table = tableList.get(wordDocTableVo.getTableIndex());
List<XWPFTableRow> rows = table.getRows();


int rowIndex = wordDocTableVo.getRowIndex();
XWPFTableRow tmpRow = rows.get(rowIndex);
addOrRemoveRow(table,wordDocTableVo.getParams().size(),wordDocTableVo.getRowIndex());


int row = wordDocTableVo.getRowIndex();
for (List<String> stringList : wordDocTableVo.getParams()) { for (List<String> stringList : wordDocTableVo.getParams()) {
table.addRow(tmpRow,rowIndex);
rowIndex++;
//替换新行内容
XWPFTableRow tableRow = rows.get(rowIndex);
row++;
for (int i = 0; i < stringList.size(); i++) { for (int i = 0; i < stringList.size(); i++) {
tableRow.getTableCells().get(i).setText(stringList.get(i));
table.getRow(row).getCell(i).setText(stringList.get(i));
} }
} }
tmpRow.getTableCells().get(0).setText("aaaa");

// //模板的那一行
// XWPFTableRow tmpRow = rows.get(2);
// List<XWPFTableCell> tmpCells = null;
// List<XWPFTableCell> cells2 = null;
// XWPFTableCell tmpCell = null;
// tmpCells = tmpRow.getTableCells();
//
// String cellText = null;
// String cellTextKey = null;
// Map<String,Object> totalMap = null;
// for (int i = 0, len = params.size(); i < len; i++) {
// Map<String,String> map = params.get(i);
// // 创建新的一行
// XWPFTableRow row = table.createRow();
// // 获取模板的行高 设置为新一行的行高
// row.setHeight(tmpRow.getHeight());
// cells = row.a();
// for (int k = 0, klen = tmpCells.size(); k < klen; k++) {
// tmpCell = tmpCells.get(k);
// XWPFTableCell cell = cells.get(k);
// cellText = tmpCell.getText();
// if (StringUtils.isNotBlank(cellText)) {
// //转换为mapkey对应的字段
// cellTextKey = cellText.replace("$", "").replace("{", "").replace("}", "");
// if (map.containsKey(cellTextKey)) {
// // 填充内容 并且复制模板行的属性
// setCellText(tmpCell,cell,map.get(cellTextKey));
// }
// }
// }
//
// }
// // 删除模版行
// table.removeRow(2);
table.removeRow(wordDocTableVo.getRowIndex());
} }


/*
* @param table 对应表格
* @param add 增加或删除行数 if add>0 增加行 add<0 删除行
* @param fromRow 添加开始行位置(fromRow-1是模版行)
*/
public static void addOrRemoveRow(XWPFTable table, int add,int fromRow) {
XWPFTableRow row = table.getRow(fromRow-1);
if(add>0) {
while(add>0) {
copyPro(row,table.insertNewTableRow(fromRow));
add--;
}
}else {
while(add<0) {
table.removeRow(fromRow-1);
add++;
}
}
}




public static void copyPro(XWPFTableRow sourceRow,XWPFTableRow targetRow) {
//复制行属性
targetRow.getCtRow().setTrPr(sourceRow.getCtRow().getTrPr());
List<XWPFTableCell> cellList = sourceRow.getTableCells();
if(null==cellList) {
return ;
}
//添加列、复制列以及列中段落属性
XWPFTableCell targetCell = null;
for(XWPFTableCell sourceCell:cellList) {
targetCell = targetRow.addNewTableCell();
//列属性
targetCell.getCTTc().setTcPr(sourceCell.getCTTc().getTcPr());
//段落属性
targetCell.getParagraphs().get(0).getCTP().setPPr(sourceCell.getParagraphs().get(0).getCTP().getPPr());
}
}
} }

Двоичные данные
mallinkService/src/main/resources/contract-word-template/settle.docx Просмотреть файл


+ 6
- 6
mallinkService/src/main/resources/mapper/WxBillAllMapper.xml Просмотреть файл

@@ -56,24 +56,24 @@
shopInfo,bill.comments,bill.price_detail,updatetime,bill.freeze shopInfo,bill.comments,bill.price_detail,updatetime,bill.freeze
from ( from (
select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金' select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,
endtime,rent_shop_type,case when shop_info is null then '[]' else shop_info end shop_info,comments,'' endtime,rent_shop_type,case when shop_info is null then '[]' else shop_info end shop_info,comments,''
price_detail,updatetime,freeze price_detail,updatetime,freeze
from wx_bill_rent where tenant_id=#{tenantId} and is_preview = 0 from wx_bill_rent where tenant_id=#{tenantId} and is_preview = 0
union all union all
select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金'
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,
endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime,freeze from wx_bill_rent_deposit where endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime,freeze from wx_bill_rent_deposit where
tenant_id=#{tenantId} tenant_id=#{tenantId}
union all union all
select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费' select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费'
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,
endtime,rent_shop_type,case when shop_info is null then '[]' else shop_info end shop_info,comments,'' endtime,rent_shop_type,case when shop_info is null then '[]' else shop_info end shop_info,comments,''
price_detail,updatetime,freeze price_detail,updatetime,freeze
from wx_bill_property where tenant_id=#{tenantId} and is_preview = 0 from wx_bill_property where tenant_id=#{tenantId} and is_preview = 0
union all union all
select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金' select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金'
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,
endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime,freeze from wx_bill_property_deposit where endtime,rent_shop_type,shop_info,NULL comments,'' price_detail,updatetime,freeze from wx_bill_property_deposit where
tenant_id=#{tenantId} tenant_id=#{tenantId}
union all union all
@@ -85,13 +85,13 @@
from wx_bill_daily where tenant_id=#{tenantId} from wx_bill_daily where tenant_id=#{tenantId}
union all union all
select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,concat('其他费用-',name) as bill_type,0 as
need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,
need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,
rent_shop_type,'[]' shop_info,comments,'' price_detail,updatetime,freeze rent_shop_type,'[]' shop_info,comments,'' price_detail,updatetime,freeze
from wx_bill_other where tenant_id=#{tenantId} from wx_bill_other where tenant_id=#{tenantId}
union all union all
select id,merchant_id,shop_id,tenant_id,comments as name,8 bill_type_value,concat('其他押金-',comments) as select id,merchant_id,shop_id,tenant_id,comments as name,8 bill_type_value,concat('其他押金-',comments) as
bill_type,0 as bill_type,0 as
need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,
need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,
rent_shop_type,'[]' shop_info,comments,'' price_detail,updatetime,freeze rent_shop_type,'[]' shop_info,comments,'' price_detail,updatetime,freeze
from wx_bill_other_deposit where tenant_id=#{tenantId} from wx_bill_other_deposit where tenant_id=#{tenantId}
) bill ) bill


Загрузка…
Отмена
Сохранить