| @@ -8,6 +8,7 @@ import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.BaseEntity; | |||
| import com.iformall.domain.po.WxBillSettle; | |||
| import com.iformall.domain.po.WxBillSettleRecord; | |||
| import com.iformall.service.WxBillAllService; | |||
| import com.iformall.service.WxBillSettleRecordService; | |||
| import com.iformall.service.WxBillSettleService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -32,6 +33,8 @@ public class WxBillSettleController extends BaseController { | |||
| private WxBillSettleService wxBillSettleService; | |||
| @Autowired | |||
| private WxBillSettleRecordService wxBillSettleRecordService; | |||
| @Autowired | |||
| private WxBillAllService wxBillAllService; | |||
| @GetMapping("list") | |||
| @ApiOperation("账单管理-结算对冲列表") | |||
| @@ -88,6 +91,6 @@ public class WxBillSettleController extends BaseController { | |||
| @SystemControllerLog(description = "账单管理-结算单-下载") | |||
| public void downloadSettle(@ModelAttribute WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response) { | |||
| wxBillSettle.setTenantId(getTenantId()); | |||
| wxBillSettleService.exportBill(request, response, wxBillSettle); | |||
| wxBillAllService.exportSettleBill(wxBillSettle,request,response); | |||
| } | |||
| } | |||
| @@ -786,7 +786,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| String filepath = fmUploadDir; | |||
| String filename = UUID.randomUUID() + ".docx"; | |||
| String exportFileName = "催缴单.docx"; | |||
| WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response); | |||
| WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,null); | |||
| } | |||
| @Override | |||
| @@ -818,14 +818,14 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| int size = wxBillSettle.getReceiveBillIds().size() > wxBillSettle.getPayBillIds().size()?wxBillSettle.getReceiveBillIds().size():wxBillSettle.getPayBillIds().size(); | |||
| int count = 1; | |||
| for (int i = 0; i < size ; i++) { | |||
| WxBillSettleBill bill = wxBillSettle.getReceiveBillIds().get(i); | |||
| WxBillSettleBill bill = i>wxBillSettle.getReceiveBillIds().size()-1?null:wxBillSettle.getReceiveBillIds().get(i); | |||
| Map<String,String> map = new HashedMap(); | |||
| if(bill != null){ | |||
| map.put("s1",count+""); | |||
| map.put("bn1",bill.getBillName()); | |||
| map.put("money1",bill.getReceivePay()); | |||
| } | |||
| WxBillSettleBill payBill = wxBillSettle.getPayBillIds().get(i); | |||
| WxBillSettleBill payBill = i>wxBillSettle.getPayBillIds().size()-1?null:wxBillSettle.getPayBillIds().get(i); | |||
| if(payBill != null){ | |||
| map.put("bn2",payBill.getBillName()); | |||
| map.put("money2",payBill.getReceivePay()); | |||
| @@ -837,8 +837,8 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| String templatePath = "contract-word-template/settle.docx"; | |||
| String filepath = fmUploadDir; | |||
| String filename = UUID.randomUUID() + ".docx"; | |||
| String exportFileName = "催缴单.docx"; | |||
| WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response); | |||
| String exportFileName = "结算单.docx"; | |||
| WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,null); | |||
| } | |||
| @@ -1612,7 +1612,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| String filepath = fmUploadDir; | |||
| String filename = UUID.randomUUID() + ".docx"; | |||
| String exportFileName = result.get("merchantName").toString() + "合同.docx"; | |||
| WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response); | |||
| WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,null); | |||
| } | |||
| @Override | |||
| @@ -8,6 +8,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.util.Assert; | |||
| import org.springframework.util.CollectionUtils; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @@ -35,7 +36,7 @@ public class WordUtil { | |||
| * @param request HttpServletRequest | |||
| * @param response HttpServletResponse | |||
| */ | |||
| public static void exportWord(String templatePath, String temDir, String fileName, String exportFileName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) { | |||
| public static void exportWord(String templatePath, String temDir, String fileName, String exportFileName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response,List<Map<String,String>> rowsParams) { | |||
| Assert.notNull(templatePath, "模板路径不能为空"); | |||
| Assert.notNull(temDir, "临时文件路径不能为空"); | |||
| Assert.notNull(exportFileName, "导出文件名不能为空"); | |||
| @@ -57,6 +58,9 @@ public class WordUtil { | |||
| XWPFDocument doc = WordExportUtil.exportWord07(templatePath, params); | |||
| if(!CollectionUtils.isEmpty(rowsParams)) | |||
| insertValueToTable(doc,rowsParams,1); | |||
| String tmpPath = temDir + fileName; | |||
| FileOutputStream fos = new FileOutputStream(tmpPath); | |||
| doc.write(fos); | |||
| @@ -94,7 +98,7 @@ public class WordUtil { | |||
| * @param tableIndex | |||
| * @throws Exception | |||
| */ | |||
| private void insertValueToTable(XWPFDocument xwpfDocument, List<Map<String,String>> params, int tableIndex) throws Exception { | |||
| public static 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对应的表格不存在"); | |||
| @@ -105,7 +109,7 @@ public class WordUtil { | |||
| throw new Exception("tableIndex对应表格应该为2行"); | |||
| } | |||
| //模板的那一行 | |||
| XWPFTableRow tmpRow = rows.get(1); | |||
| XWPFTableRow tmpRow = rows.get(3); | |||
| List<XWPFTableCell> tmpCells = null; | |||
| List<XWPFTableCell> cells = null; | |||
| XWPFTableCell tmpCell = null; | |||
| @@ -147,7 +151,7 @@ public class WordUtil { | |||
| * @param text | |||
| * @throws Exception | |||
| */ | |||
| private void setCellText(XWPFTableCell tmpCell, XWPFTableCell cell,String text) throws Exception { | |||
| public static void setCellText(XWPFTableCell tmpCell, XWPFTableCell cell,String text) throws Exception { | |||
| CTTc cttc2 = tmpCell.getCTTc(); | |||
| CTTcPr ctPr2 = cttc2.getTcPr(); | |||
| CTTc cttc = cell.getCTTc(); | |||