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

[合同][修改][开发结算单]

release_toaliyun_real
luozukai 6 лет назад
Родитель
Сommit
bb6a1fa575
6 измененных файлов: 246 добавлений и 1 удалений
  1. +2
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxBillSettleBill.java
  2. +3
    -0
      mallinkService/src/main/java/com/iformall/service/WxBillAllService.java
  3. +20
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java
  4. +7
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxBillSettleServiceImpl.java
  5. +214
    -1
      mallinkService/src/main/java/com/iformall/utils/WordUtil.java
  6. Двоичные данные
      mallinkService/src/main/resources/contract-word-template/settle.docx

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

@@ -44,8 +44,10 @@ public class WxBillSettleBill extends BaseEntity {
@Transient @Transient
private String receivePay; private String receivePay;


@Transient
@io.swagger.annotations.ApiModelProperty(value="账单开始时间",name="starttime") @io.swagger.annotations.ApiModelProperty(value="账单开始时间",name="starttime")
private Date starttime; private Date starttime;
@Transient
@io.swagger.annotations.ApiModelProperty(value="账单结束时间",name="endtime") @io.swagger.annotations.ApiModelProperty(value="账单结束时间",name="endtime")
private Date endtime; private Date endtime;
} }

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

@@ -2,6 +2,7 @@ package com.iformall.service;


import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxBillSettle;
import com.iformall.domain.vo.WxBillAll; import com.iformall.domain.vo.WxBillAll;
import com.iformall.domain.vo.WxBillExcelTemplate; import com.iformall.domain.vo.WxBillExcelTemplate;
import com.iformall.domain.vo.WxBillExcelTemplateOther; import com.iformall.domain.vo.WxBillExcelTemplateOther;
@@ -68,6 +69,8 @@ public interface WxBillAllService {


void exportOweBill(WxBillAll wxBillAll, HttpServletRequest request, HttpServletResponse response); void exportOweBill(WxBillAll wxBillAll, HttpServletRequest request, HttpServletResponse response);


void exportSettleBill(WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response);

ResultData updateReceivePay(WxBillAll wxBillAll, MallUserInfo user); ResultData updateReceivePay(WxBillAll wxBillAll, MallUserInfo user);


void addBillAction(EnumBillAction billAction, Long billId, Long oldPrice, Long newPrice, MallUserInfo mallUserInfo); void addBillAction(EnumBillAction billAction, Long billId, Long oldPrice, Long newPrice, MallUserInfo mallUserInfo);


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

@@ -779,6 +779,26 @@ public class WxBillAllServiceImpl implements WxBillAllService {
String createtime = DateUtils.getSystemTime("yyyy-MM-dd"); String createtime = DateUtils.getSystemTime("yyyy-MM-dd");
result.put("createtime", createtime); result.put("createtime", createtime);


String templatePath = "contract-word-template/bill_owe.docx";
String filepath = fmUploadDir;
String filename = UUID.randomUUID() + ".docx";
String exportFileName = "催缴单.docx";
WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response);
}

@Override
public void exportSettleBill(WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response) {
//商场名称
WxMall wxMall = wxMallMapper.getByTenantId(wxBillSettle.getTenantId());
//映射结果
Map<String, Object> result = new HashMap<>();
result.put("mall", wxMall.getName());

//编号
String number = "JF" + DateUtils.getSystemTime("yyyyMMddHHmmss");
result.put("number", number);


String templatePath = "contract-word-template/bill_owe.docx"; String templatePath = "contract-word-template/bill_owe.docx";
String filepath = fmUploadDir; String filepath = fmUploadDir;
String filename = UUID.randomUUID() + ".docx"; String filename = UUID.randomUUID() + ".docx";


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

@@ -32,6 +32,8 @@ public class WxBillSettleServiceImpl implements WxBillSettleService {
@Autowired @Autowired
private WxBillSettleMapper wxBillSettleMapper; private WxBillSettleMapper wxBillSettleMapper;
@Autowired @Autowired
private WxMerchantMapper wxMerchantMapper;
@Autowired
private WxFlowService wxFlowService; private WxFlowService wxFlowService;
@Autowired @Autowired
private WxBillSettleBillMapper wxBillSettleBillMapper; private WxBillSettleBillMapper wxBillSettleBillMapper;
@@ -70,6 +72,11 @@ public class WxBillSettleServiceImpl implements WxBillSettleService {
WxBillSettle billSettle = wxBillSettleMapper.selectByPrimaryKey(id); WxBillSettle billSettle = wxBillSettleMapper.selectByPrimaryKey(id);


if(billSettle != null) { if(billSettle != null) {
WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(billSettle.getMerchantId());
if(merchant != null){
billSettle.setMerchantName(merchant.getName());
}

if(billSettle.getReceiveMoney() > billSettle.getPayMoney()){ if(billSettle.getReceiveMoney() > billSettle.getPayMoney()){
billSettle.setSettleWay(EnumSettleWay.B.getCode()); billSettle.setSettleWay(EnumSettleWay.B.getCode());
}else{ }else{


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

@@ -2,7 +2,9 @@ package com.iformall.utils;


import cn.afterturn.easypoi.word.WordExportUtil; import cn.afterturn.easypoi.word.WordExportUtil;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.commons.lang3.StringUtils;
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;
@@ -12,6 +14,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List;
import java.util.Map; import java.util.Map;


public class WordUtil { public class WordUtil {
@@ -84,4 +87,214 @@ public class WordUtil {


} }


/**
* 循环填充表格内容
* @param xwpfDocument
* @param params
* @param tableIndex
* @throws Exception
*/
private void insertValueToTable(XWPFDocument xwpfDocument, List<Map<String,String>> params, int tableIndex) throws Exception {
List<XWPFTable> tableList = xwpfDocument.getTables();
if(tableList.size()<=tableIndex){
throw new Exception("tableIndex对应的表格不存在");
}
XWPFTable table = tableList.get(tableIndex);
List<XWPFTableRow> rows = table.getRows();
if(rows.size()<2){
throw new Exception("tableIndex对应表格应该为2行");
}
//模板的那一行
XWPFTableRow tmpRow = rows.get(1);
List<XWPFTableCell> tmpCells = null;
List<XWPFTableCell> cells = 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.getTableCells();
for (int k = 0, klen = cells.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(1);
}

/**
* 复制模板行的属性
* @param tmpCell
* @param cell
* @param text
* @throws Exception
*/
private void setCellText(XWPFTableCell tmpCell, XWPFTableCell cell,String text) throws Exception {
CTTc cttc2 = tmpCell.getCTTc();
CTTcPr ctPr2 = cttc2.getTcPr();
CTTc cttc = cell.getCTTc();
CTTcPr ctPr = cttc.addNewTcPr();
if (ctPr2.getTcW() != null) {
ctPr.addNewTcW().setW(ctPr2.getTcW().getW());
}
if (ctPr2.getVAlign() != null) {
ctPr.addNewVAlign().setVal(ctPr2.getVAlign().getVal());
}
if (cttc2.getPList().size() > 0) {
CTP ctp = cttc2.getPList().get(0);
if (ctp.getPPr() != null) {
if (ctp.getPPr().getJc() != null) {
cttc.getPList().get(0).addNewPPr().addNewJc()
.setVal(ctp.getPPr().getJc().getVal());
}
}
}
if (ctPr2.getTcBorders() != null) {
ctPr.setTcBorders(ctPr2.getTcBorders());
}

XWPFParagraph tmpP = tmpCell.getParagraphs().get(0);
XWPFParagraph cellP = cell.getParagraphs().get(0);
XWPFRun tmpR = null;
if (tmpP.getRuns() != null && tmpP.getRuns().size() > 0) {
tmpR = tmpP.getRuns().get(0);
}
XWPFRun cellR = cellP.createRun();
cellR.setText(text);
// 复制字体信息
if (tmpR != null) {
if(!cellR.isBold()){
cellR.setBold(tmpR.isBold());
}
cellR.setItalic(tmpR.isItalic());
cellR.setUnderline(tmpR.getUnderline());
cellR.setColor(tmpR.getColor());
cellR.setTextPosition(tmpR.getTextPosition());
if (tmpR.getFontSize() != -1) {
cellR.setFontSize(tmpR.getFontSize());
}
if (tmpR.getFontFamily() != null) {
cellR.setFontFamily(tmpR.getFontFamily());
}
if (tmpR.getCTR() != null) {
if (tmpR.getCTR().isSetRPr()) {
CTRPr tmpRPr = tmpR.getCTR().getRPr();
if (tmpRPr.isSetRFonts()) {
CTFonts tmpFonts = tmpRPr.getRFonts();
CTRPr cellRPr = cellR.getCTR().isSetRPr() ? cellR
.getCTR().getRPr() : cellR.getCTR().addNewRPr();
CTFonts cellFonts = cellRPr.isSetRFonts() ? cellRPr
.getRFonts() : cellRPr.addNewRFonts();
cellFonts.setAscii(tmpFonts.getAscii());
cellFonts.setAsciiTheme(tmpFonts.getAsciiTheme());
cellFonts.setCs(tmpFonts.getCs());
cellFonts.setCstheme(tmpFonts.getCstheme());
cellFonts.setEastAsia(tmpFonts.getEastAsia());
cellFonts.setEastAsiaTheme(tmpFonts.getEastAsiaTheme());
cellFonts.setHAnsi(tmpFonts.getHAnsi());
cellFonts.setHAnsiTheme(tmpFonts.getHAnsiTheme());
}
}
}

}
// 复制段落信息
cellP.setAlignment(tmpP.getAlignment());
cellP.setVerticalAlignment(tmpP.getVerticalAlignment());
cellP.setBorderBetween(tmpP.getBorderBetween());
cellP.setBorderBottom(tmpP.getBorderBottom());
cellP.setBorderLeft(tmpP.getBorderLeft());
cellP.setBorderRight(tmpP.getBorderRight());
cellP.setBorderTop(tmpP.getBorderTop());
cellP.setPageBreak(tmpP.isPageBreak());
if (tmpP.getCTP() != null) {
if (tmpP.getCTP().getPPr() != null) {
CTPPr tmpPPr = tmpP.getCTP().getPPr();
CTPPr cellPPr = cellP.getCTP().getPPr() != null ? cellP
.getCTP().getPPr() : cellP.getCTP().addNewPPr();
// 复制段落间距信息
CTSpacing tmpSpacing = tmpPPr.getSpacing();
if (tmpSpacing != null) {
CTSpacing cellSpacing = cellPPr.getSpacing() != null ? cellPPr
.getSpacing() : cellPPr.addNewSpacing();
if (tmpSpacing.getAfter() != null) {
cellSpacing.setAfter(tmpSpacing.getAfter());
}
if (tmpSpacing.getAfterAutospacing() != null) {
cellSpacing.setAfterAutospacing(tmpSpacing
.getAfterAutospacing());
}
if (tmpSpacing.getAfterLines() != null) {
cellSpacing.setAfterLines(tmpSpacing.getAfterLines());
}
if (tmpSpacing.getBefore() != null) {
cellSpacing.setBefore(tmpSpacing.getBefore());
}
if (tmpSpacing.getBeforeAutospacing() != null) {
cellSpacing.setBeforeAutospacing(tmpSpacing
.getBeforeAutospacing());
}
if (tmpSpacing.getBeforeLines() != null) {
cellSpacing.setBeforeLines(tmpSpacing.getBeforeLines());
}
if (tmpSpacing.getLine() != null) {
cellSpacing.setLine(tmpSpacing.getLine());
}
if (tmpSpacing.getLineRule() != null) {
cellSpacing.setLineRule(tmpSpacing.getLineRule());
}
}
// 复制段落缩进信息
CTInd tmpInd = tmpPPr.getInd();
if (tmpInd != null) {
CTInd cellInd = cellPPr.getInd() != null ? cellPPr.getInd()
: cellPPr.addNewInd();
if (tmpInd.getFirstLine() != null) {
cellInd.setFirstLine(tmpInd.getFirstLine());
}
if (tmpInd.getFirstLineChars() != null) {
cellInd.setFirstLineChars(tmpInd.getFirstLineChars());
}
if (tmpInd.getHanging() != null) {
cellInd.setHanging(tmpInd.getHanging());
}
if (tmpInd.getHangingChars() != null) {
cellInd.setHangingChars(tmpInd.getHangingChars());
}
if (tmpInd.getLeft() != null) {
cellInd.setLeft(tmpInd.getLeft());
}
if (tmpInd.getLeftChars() != null) {
cellInd.setLeftChars(tmpInd.getLeftChars());
}
if (tmpInd.getRight() != null) {
cellInd.setRight(tmpInd.getRight());
}
if (tmpInd.getRightChars() != null) {
cellInd.setRightChars(tmpInd.getRightChars());
}
}
}
}
}


} }

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


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