| @@ -233,8 +233,8 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| Cell shopNumberCell = row.createCell(0); | |||
| Cell merchantNameCell = row.createCell(1); | |||
| Cell billNameCell = row.createCell(2); | |||
| Cell needPayCell = row.createCell(3); | |||
| Cell receivePayCell = row.createCell(4); | |||
| Cell receivePayCell = row.createCell(3); | |||
| Cell payCell = row.createCell(4); | |||
| Cell oweCell = row.createCell(5); | |||
| Cell receiveDateCell = row.createCell(6); | |||
| Cell expiredDayCell = row.createCell(7); | |||
| @@ -243,11 +243,11 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| shopNumberCell.setCellValue("商铺号"); | |||
| merchantNameCell.setCellValue("商户名称"); | |||
| billNameCell.setCellValue("费用类型"); | |||
| needPayCell.setCellValue("实际应收金额(元)"); | |||
| receivePayCell.setCellValue("实收金额(元)"); | |||
| receivePayCell.setCellValue("实际应收金额(元)"); | |||
| payCell.setCellValue("实收金额(元)"); | |||
| oweCell.setCellValue("欠缴金额(元)"); | |||
| receiveDateCell.setCellValue("缴款截止日期"); | |||
| expiredDayCell.setCellValue("过期时间"); | |||
| expiredDayCell.setCellValue("逾期天数"); | |||
| statusCell.setCellValue("账单状态"); | |||
| for (int i = 0,size=billList.size(); i < size; i++) { | |||
| @@ -255,8 +255,8 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| shopNumberCell = row.createCell(0); | |||
| merchantNameCell = row.createCell(1); | |||
| billNameCell = row.createCell(2); | |||
| needPayCell = row.createCell(3); | |||
| receivePayCell = row.createCell(4); | |||
| receivePayCell = row.createCell(3); | |||
| payCell = row.createCell(4); | |||
| oweCell = row.createCell(5); | |||
| receiveDateCell = row.createCell(6); | |||
| expiredDayCell = row.createCell(7); | |||
| @@ -266,8 +266,8 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| shopNumberCell.setCellValue(billMap.get("shopNumber").toString()); | |||
| merchantNameCell.setCellValue(billMap.get("merchantName").toString()); | |||
| billNameCell.setCellValue(billMap.get("name").toString()); | |||
| BigDecimal needPay = new BigDecimal(billMap.get("needPay").toString()).divide(new BigDecimal(100)); | |||
| needPayCell.setCellValue(needPay.toString()); | |||
| BigDecimal needPay = new BigDecimal(billMap.get("pay").toString()).divide(new BigDecimal(100)); | |||
| payCell.setCellValue(needPay.toString()); | |||
| BigDecimal receivePay = new BigDecimal(billMap.get("receivePay").toString()).divide(new BigDecimal(100)); | |||
| receivePayCell.setCellValue(receivePay.toString()); | |||
| BigDecimal owe = new BigDecimal(billMap.get("owe").toString()).divide(new BigDecimal(100)); | |||
| @@ -291,7 +291,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| workbook.write(fileOut); | |||
| fileOut.close(); | |||
| workbook.close(); | |||
| downFile(filepath, filename, response, request); | |||
| downFile(filepath, filename, "账单数据.xlsx",response, request); | |||
| FileUtils.forceDelete(file); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| @@ -300,7 +300,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| } | |||
| public void downFile(String filePath, String filename, HttpServletResponse response, | |||
| public void downFile(String filePath, String filename, String exportFileName,HttpServletResponse response, | |||
| HttpServletRequest req) throws IOException { | |||
| try { | |||
| response.reset(); | |||
| @@ -309,13 +309,13 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| if (agent.contains("Firefox")) { | |||
| response.setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + new String(filename.getBytes("GB2312"), | |||
| + new String(exportFileName.getBytes("GB2312"), | |||
| "ISO-8859-1")); | |||
| } else { | |||
| response | |||
| .setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + java.net.URLEncoder.encode(filename, | |||
| + java.net.URLEncoder.encode(exportFileName, | |||
| "UTF-8")); | |||
| } | |||
| // 循环取出流中的数据 | |||
| @@ -265,14 +265,14 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| workbook.write(fileOut); | |||
| fileOut.close(); | |||
| workbook.close(); | |||
| downFile(filepath, filename, response, request); | |||
| downFile(filepath, filename,"会员信息数据.xlsx",response, request); | |||
| FileUtils.forceDelete(file); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public void downFile(String filePath, String filename, HttpServletResponse response, | |||
| public void downFile(String filePath, String filename,String exportFileName, HttpServletResponse response, | |||
| HttpServletRequest req) throws IOException { | |||
| try { | |||
| response.reset(); | |||
| @@ -281,13 +281,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| if (agent.contains("Firefox")) { | |||
| response.setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + new String(filename.getBytes("GB2312"), | |||
| + new String(exportFileName.getBytes("GB2312"), | |||
| "ISO-8859-1")); | |||
| } else { | |||
| response | |||
| .setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + java.net.URLEncoder.encode(filename, | |||
| + java.net.URLEncoder.encode(exportFileName, | |||
| "UTF-8")); | |||
| } | |||
| // 循环取出流中的数据 | |||
| @@ -422,7 +422,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| workbook.write(fileOut); | |||
| fileOut.close(); | |||
| workbook.close(); | |||
| downFile(filepath, filename, response, request); | |||
| downFile(filepath, filename, "会员信息模板.xlsx",response, request); | |||
| FileUtils.forceDelete(file); | |||
| } catch (Exception e) { | |||
| logger.error("导出模板:" + e.getMessage()); | |||
| @@ -398,8 +398,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| pDest.mkdirs(); | |||
| } | |||
| try { | |||
| String exportFileName=wxPropertyContract.getFilename()+filesuffix; | |||
| downLoadFromUrl(wxPropertyContract.getFilepath(), filename, filepath); | |||
| downFile(destPath, wxPropertyContract.getFilename(), response, request); | |||
| downFile(destPath, wxPropertyContract.getFilename(), exportFileName,response, request); | |||
| org.apache.commons.io.FileUtils.forceDelete(dest); | |||
| } catch (IOException e) { | |||
| logger.info("创建本地文件失败" + e.getMessage()); | |||
| @@ -587,16 +588,16 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| return bos.toByteArray(); | |||
| } | |||
| public void downFile(String filePath, String filename, HttpServletResponse response, | |||
| public void downFile(String filePath, String filename, String exportFileName, HttpServletResponse response, | |||
| HttpServletRequest req) { | |||
| try { | |||
| response.reset(); | |||
| response.setContentType("bin"); | |||
| String agent = req.getHeader("user-agent"); | |||
| if (agent.contains("Firefox")) { | |||
| response.setHeader("Content-disposition", "attachment; filename=" + new String(filename.getBytes("GB2312"), "ISO-8859-1")); | |||
| response.setHeader("Content-disposition", "attachment; filename=" + new String(exportFileName.getBytes("GB2312"), "ISO-8859-1")); | |||
| } else { | |||
| response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(filename, "UTF-8")); | |||
| response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(exportFileName, "UTF-8")); | |||
| } | |||
| // 循环取出流中的数据 | |||
| byte[] b = new byte[1024]; | |||
| @@ -442,8 +442,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| pDest.mkdirs(); | |||
| } | |||
| try { | |||
| String exportFileName=wxRentContract.getFilename()+filesuffix; | |||
| downLoadFromUrl(wxRentContract.getFilepath(), filename, filepath); | |||
| downFile(destPath, wxRentContract.getFilename(), response, request); | |||
| downFile(destPath, wxRentContract.getFilename(),exportFileName, response, request); | |||
| org.apache.commons.io.FileUtils.forceDelete(dest); | |||
| } catch (IOException e) { | |||
| logger.info("创建本地文件失败" + e.getMessage()); | |||
| @@ -641,16 +642,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return bos.toByteArray(); | |||
| } | |||
| public void downFile(String filePath, String filename, HttpServletResponse response, | |||
| public void downFile(String filePath, String filename, String exportFileName, HttpServletResponse response, | |||
| HttpServletRequest req) { | |||
| try { | |||
| response.reset(); | |||
| response.setContentType("bin"); | |||
| String agent = req.getHeader("user-agent"); | |||
| if (agent.contains("Firefox")) { | |||
| response.setHeader("Content-disposition", "attachment; filename=" + new String(filename.getBytes("GB2312"), "ISO-8859-1")); | |||
| response.setHeader("Content-disposition", "attachment; filename=" + new String(exportFileName.getBytes("GB2312"), "ISO-8859-1")); | |||
| } else { | |||
| response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(filename, "UTF-8")); | |||
| response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode(exportFileName, "UTF-8")); | |||
| } | |||
| // 循环取出流中的数据 | |||
| byte[] b = new byte[1024]; | |||
| @@ -688,7 +689,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| String filepath = Constant.fileDirectory; | |||
| String filename = UUID.randomUUID() + ".docx"; | |||
| exportWord(templatePath, filepath, filename, result, request, response); | |||
| String exportFileName = result.get("merchantName").toString() + "合同.docx"; | |||
| exportWord(templatePath, filepath, filename, exportFileName,result, request, response); | |||
| } | |||
| @Override | |||
| @@ -721,6 +723,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| result.put("operationArea", wxShop.get("operationArea")); | |||
| //商户信息 | |||
| WxMerchant merchant = wxMerchantService.getById(wxRentContract.getMerchantId()); | |||
| result.put("merchantName",merchant.getName()); | |||
| if (merchant!=null) { | |||
| //法人信息 | |||
| WxMerchantCorp wxMerchantCorp = merchant.getWxMerchantCorp(); | |||
| @@ -898,7 +901,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| double payRatio = wxRentContract.getPayRatio() != null ? wxRentContract.getPayRatio() / 100.0 : 0; | |||
| //常规租期 | |||
| for (int i = 0; i < count; i++) { | |||
| for (int i = 0; i <=count; i++) { | |||
| //开始时间 | |||
| Calendar instance = Calendar.getInstance(); | |||
| instance.setTime(wxRentContract.getRentalStartDate()); | |||
| @@ -970,7 +973,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| public void areaWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, double adjustRatio, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { | |||
| //常规租期 | |||
| for (int i = 0; i < count; i++) { | |||
| for (int i = 0; i <=count; i++) { | |||
| //开始时间 | |||
| Calendar instance = Calendar.getInstance(); | |||
| instance.setTime(wxRentContract.getRentalStartDate()); | |||
| @@ -1058,11 +1061,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| * @param request HttpServletRequest | |||
| * @param response HttpServletResponse | |||
| */ | |||
| public void exportWord(String templatePath, String temDir, String fileName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) { | |||
| public void exportWord(String templatePath, String temDir, String fileName, String exportFileName,Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) { | |||
| Assert.notNull(templatePath, "模板路径不能为空"); | |||
| Assert.notNull(temDir, "临时文件路径不能为空"); | |||
| Assert.notNull(fileName, "导出文件名不能为空"); | |||
| Assert.isTrue(fileName.endsWith(".docx"), "word导出请使用docx格式"); | |||
| Assert.notNull(exportFileName, "导出文件名不能为空"); | |||
| Assert.isTrue(exportFileName.endsWith(".docx"), "word导出请使用docx格式"); | |||
| if (!temDir.endsWith("/")) { | |||
| temDir = temDir + File.separator; | |||
| } | |||
| @@ -1071,12 +1074,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| dir.mkdirs(); | |||
| } | |||
| try { | |||
| String userAgent = request.getHeader("user-agent").toLowerCase(); | |||
| if (userAgent.contains("msie") || userAgent.contains("like gecko")) { | |||
| fileName = URLEncoder.encode(fileName, "UTF-8"); | |||
| } else { | |||
| fileName = new String(fileName.getBytes("utf-8"), "ISO-8859-1"); | |||
| } | |||
| // String userAgent = request.getHeader("user-agent").toLowerCase(); | |||
| // if (userAgent.contains("msie") || userAgent.contains("like gecko")) { | |||
| // exportFileName = URLEncoder.encode(exportFileName, "UTF-8"); | |||
| // } else { | |||
| // exportFileName = new String(exportFileName.getBytes("utf-8"), "ISO-8859-1"); | |||
| // } | |||
| XWPFDocument doc = WordExportUtil.exportWord07(templatePath, params); | |||
| String tmpPath = temDir + fileName; | |||
| FileOutputStream fos = new FileOutputStream(tmpPath); | |||
| @@ -1084,7 +1089,20 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| // 设置强制下载不打开 | |||
| response.setContentType("application/force-download"); | |||
| // 设置文件名 | |||
| response.addHeader("Content-Disposition", "attachment;fileName=" + fileName); | |||
| response.addHeader("Content-Disposition", "attachment;fileName=" + exportFileName); | |||
| String userAgent = request.getHeader("user-agent"); | |||
| if (userAgent.contains("Firefox")) { | |||
| response.setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + new String(exportFileName.getBytes("GB2312"), | |||
| "ISO-8859-1")); | |||
| } else { | |||
| response | |||
| .setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + java.net.URLEncoder.encode(exportFileName, | |||
| "UTF-8")); | |||
| } | |||
| OutputStream out = response.getOutputStream(); | |||
| doc.write(out); | |||
| out.close(); | |||
| @@ -1095,14 +1113,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| public static void main(String[] args) { | |||
| BigDecimal multiply = new BigDecimal(8059.99).multiply(new BigDecimal(0.07)); | |||
| BigDecimal add = multiply.add(new BigDecimal(8059.99)).setScale(2, RoundingMode.HALF_EVEN); | |||
| System.out.println(add.doubleValue()); | |||
| } | |||
| /** | |||
| * 数字金额大写转换,思想先写个完整的然后将如零拾替换成零 要用到正则表达式 | |||
| */ | |||