Commit 0502bf33 authored by liyuan.chen's avatar liyuan.chen

对账单,付款申请上传附件,收支一览表,租金催收修改

parent cf17f6c3
package com.hand.hls.hlcm.cont.controllers;
/**
* @Author: Liyuan.Chen
* @Date: 2020/8/19
* @Purpose:
*/
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import com.hand.hap.system.controllers.BaseController;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
@Validated
public class BaseFrontController extends BaseController {
/**
* slf4j 日志 logger
*/
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 下载文件,纯SpringMVC的API来完成
*
* @param is
* 文件输入流
* @param name
* 文件名称,带后缀名
*
* @throws Exception
*/
public ResponseEntity<byte[]> buildResponseEntity(InputStream is, String name) throws Exception {
logger.info(">>>>>>>>>>>>>>>>>>>>开始下载文件>>>>>>>>>>");
if (this.logger.isDebugEnabled())
this.logger.debug("download: " + name);
HttpHeaders header = new HttpHeaders();
String fileSuffix = name.substring(name.lastIndexOf('.') + 1);
fileSuffix = fileSuffix.toLowerCase();
Map<String, String> arguments = new HashMap<String, String>();
arguments.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
arguments.put("xls", "application/vnd.ms-excel");
String contentType = arguments.get(fileSuffix);
header.add("Content-Type", (StringUtils.hasText(contentType) ? contentType : "application/x-download"));
if(is!=null && is.available()!=0){
header.add("Content-Length", String.valueOf(is.available()));
header.add("Content-Disposition", "attachment;filename*=utf-8'zh_cn'" + URLEncoder.encode(name, "UTF-8"));
byte[] bs = IOUtils.toByteArray(is);
logger.info(">>>>>>>>>>>>>>>>>>>>结束下载文件-有记录>>>>>>>>>>");
logger.info(">>>>>>>>>>结束导出excel>>>>>>>>>>");
return new ResponseEntity<>(bs, header, HttpStatus.OK);
}else{
String string="数据为空";
header.add("Content-Length", "0");
header.add("Content-Disposition", "attachment;filename*=utf-8'zh_cn'" + URLEncoder.encode(name, "UTF-8"));
logger.info(">>>>>>>>>>>>>>>>>>>>结束下载文件-无记录>>>>>>>>>>");
logger.info(">>>>>>>>>>结束导出excel>>>>>>>>>>");
return new ResponseEntity<>(string.getBytes(), header, HttpStatus.OK);
}
}
}
package com.hand.hls.hlcm.cont.controllers;
/**
* @Author: Liyuan.Chen
* @Date: 2020/8/19
* @Purpose:
*/
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.system.dto.ResponseData;
import com.hand.hls.hlcm.cont.service.ConExportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
@Controller
public class ConExportController extends BaseController {
@Autowired
private ConExportService conExportService;
// 导出excel
@RequestMapping(value = "/con/contract/conExportExcel")
public void exportExcel(HttpServletRequest request, HttpServletResponse response, @RequestParam("contractId") int contractId) {
System.out.println(contractId);
try {
conExportService.exportExcel(request, response, contractId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.hand.hls.hlcm.cont.mapper;
import com.hand.hap.mybatis.common.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.*;
/**
* @Author: Liyuan.Chen
* @Date: 2020/8/19
* @Purpose:
*/
public interface ConExportMapper {
public LinkedList<LinkedHashMap<String, Object>> selectCashflowList(@Param("contractId") int contractId);
public HashMap<String, Object> selectContractDetailList(@Param("contractId") int contractId);
/* public List<HashMap<String, Object>> selectTemplateDetailInfo(HashMap<String, Object> hm);
public int updateTemplateDetail(HashMap<String, Object> hm);*/
}
package com.hand.hls.hlcm.cont.service;
/**
* @Author: Liyuan.Chen
* @Date: 2020/8/19
* @Purpose:
*/
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.hand.hap.core.ProxySelf;
import org.springframework.http.ResponseEntity;
import java.util.Map;
public interface ConExportService extends ProxySelf<ConExportService> {
void exportExcel(HttpServletRequest request, HttpServletResponse response, int contractId) throws Exception;
}
package com.hand.hls.hlcm.cont.service.impl;
import com.hand.hls.hlcm.cont.mapper.ConExportMapper;
import com.hand.hls.hlcm.cont.service.ConExportService;
/**
* @Author: Liyuan.Chen
* @Date: 2020/8/19
* @Purpose:
*/
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URL;
import java.net.URLEncoder;
import java.util.*;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.hand.hls.hlcm.cont.util.ExcelFormatUtil;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.*;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ConExportServiceImpl implements ConExportService {
//Logger logger = LoggerFactory.getLogger(ConExportServiceImpl.class);
@Autowired
private ConExportMapper conExportMapper;
@Override
public void exportExcel(HttpServletRequest request, HttpServletResponse response, int contractId) {
try {
//logger.info(">>>>>>>>>>开始导出excel>>>>>>>>>>");
// 造几条数据
HashMap<String, Object> mapContract = conExportMapper.selectContractDetailList(contractId);
LinkedList<LinkedHashMap<String, Object>> list = (LinkedList<LinkedHashMap<String, Object>>) conExportMapper.selectCashflowList(contractId);
/*BaseFrontController baseFrontController = new BaseFrontController();
return baseFrontController.buildResponseEntity(export((List<User>) list), "用户表.xls");*/
export(mapContract, list, response);
} catch (Exception e) {
e.printStackTrace();
//logger.error(">>>>>>>>>>导出excel 异常,原因为:" + e.getMessage());
}
//return null;
}
private void export(HashMap map, LinkedList list, HttpServletResponse response) {
//logger.info(">>>>>>>>>>>>>>>>>>>>开始进入导出方法>>>>>>>>>>");
SXSSFWorkbook wb = new SXSSFWorkbook(1000);// 保留1000条数据在内存中
SXSSFSheet sheet = wb.createSheet();
sheet.setDisplayGridlines(false);
// 设置报表头样式
BufferedImage bufferImg = null;
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
try {
ClassLoader classLoader = this.getClass().getClassLoader();
URL resource = classLoader.getResource("/");
String path = resource.getPath();
System.out.println(path);
bufferImg = ImageIO.read(new File(path +"com/hand/hls/hlcm/cont/img/HonglingNew.jpg"));
ImageIO.write(bufferImg, "jpg", byteArrayOut);
} catch (IOException e) {
e.printStackTrace();
}
//画图的顶级管理器,一个sheet只能获取一个(一定要注意这点)
SXSSFDrawing patriarch = sheet.createDrawingPatriarch();
//Drawing patriarch = sheet.createDrawingPatriarch();
//anchor主要用于设置图片的属性
XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 255, 255,(short) 3, 1, (short) 7, 4);
anchor.setAnchorType(ClientAnchor.AnchorType.byId(3));
//插入图片
patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
CellRangeAddress regionTitle0 = new CellRangeAddress(0, 3, 0, 9);
sheet.addMergedRegion(regionTitle0);
CellStyle header = ExcelFormatUtil.headSytle(wb);// cell样式
CellStyle content = ExcelFormatUtil.contentStyle(wb);// 报表体样式
CellStyle contentLine = ExcelFormatUtil.contentStyleLine(wb);// 报表体样式
CellStyle contentTable = ExcelFormatUtil.contentTableStyle(wb);
// 头部分
CellStyle style1 = wb.createCellStyle();// cell样式
style1.setAlignment(HorizontalAlignment.CENTER );// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);
String contentTitle = "96 Ying Chun Road, Pudong New Area Shanghai, China 200127";
SXSSFRow rowTitle = sheet.createRow(5);
SXSSFCell cellTitle = rowTitle.createCell(3);
cellTitle.setCellValue(contentTitle);
cellTitle.setCellStyle(style1);
CellRangeAddress regionTitle = new CellRangeAddress(5, 5, 3, 6);
sheet.addMergedRegion(regionTitle);
contentTitle = "中国上海市浦东新区迎春路96号";
SXSSFRow rowTitle1 = sheet.createRow(6);
SXSSFCell cellTitle1 = rowTitle1.createCell(4);
cellTitle1.setCellValue(contentTitle);
cellTitle1.setCellStyle(style1);
CellRangeAddress regionTitle1 = new CellRangeAddress(6, 6, 4, 5);
sheet.addMergedRegion(regionTitle1);
contentTitle = "Tel:+86-(0)21-5056-3050\tFax:+86-(0)21-5056-3077";
SXSSFRow rowTitle2 = sheet.createRow(7);
SXSSFCell cellTitle2 = rowTitle2.createCell(3);
cellTitle2.setCellValue(contentTitle);
cellTitle2.setCellStyle(style1);
CellRangeAddress regionTitle2 = new CellRangeAddress(7, 7, 3, 6);
sheet.addMergedRegion(regionTitle2);
SXSSFRow rowTitle3 = sheet.createRow(8);
for (int i = 0; i < 10; i++) {
SXSSFCell cellTitle3 = rowTitle3.createCell(i);
cellTitle3.setCellValue("");
cellTitle3.setCellStyle(contentLine);
}
CellRangeAddress regionTitle3 = new CellRangeAddress(8, 8, 0, 9);
sheet.addMergedRegion(regionTitle3);
ExcelFormatUtil.initTitle(sheet, header, "对账单", 9, 0);
String contentExcel = "(承租人)";
SXSSFRow rowBpName = sheet.createRow(12);
SXSSFCell cellBpName = rowBpName.createCell(0);
//设置每一列的字段名
cellBpName.setCellValue(contentExcel);
cellBpName.setCellStyle(content);
contentExcel = (String) map.get("BP_NAME") ;
SXSSFCell cellBpValue = rowBpName.createCell(1);
//设置每一列的字段名
cellBpValue.setCellValue(contentExcel);
cellBpValue.setCellStyle(contentLine);
SXSSFCell cellBpValue2 = rowBpName.createCell(2);
cellBpValue2.setCellValue("");
cellBpValue2.setCellStyle(contentLine);
SXSSFCell cellBpValue3 = rowBpName.createCell(3);
cellBpValue3.setCellValue("");
cellBpValue3.setCellStyle(contentLine);
SXSSFCell cellBpValue4 = rowBpName.createCell(4);
cellBpValue4.setCellValue(":");
cellBpValue4.setCellStyle(content);
CellRangeAddress region = new CellRangeAddress(12, 12, 1, 3);
sheet.addMergedRegion(region);
contentExcel = "依据您与宏菱融资租赁(上海)有限公司签订的《融资租赁合同》,(合同号:" +
(String) map.get("CONTRACT_NUMBER") + ";机号:" + (String) map.get("MACHINE_NUMBER") + ")";
ExcelFormatUtil.initContent(sheet, content, contentExcel, 14, 1);
contentExcel = "我公司已经按约向您交付了租赁物,截止" +
(String) map.get("TODAY") + ",您已支付我公司以下性质和金额的款项:";
ExcelFormatUtil.initContent(sheet, content, contentExcel, 16, 0);
if (list != null && list.size() > 1) {
//logger.info(">>>>>>>>>>>>>>>>>>>>开始遍历数据组装单元格内容>>>>>>>>>>");
// 每一列字段名
String[] strs = new String[]{"款项性质", "期次", "约定支付日", "应付金额(人民币)", "实际收款日", "收款金额", "实收违约金", "未收金额"};
// 字段名所在表格的宽度
int[] ints = new int[]{5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000};
// 设置表头样式
ExcelFormatUtil.initColumn(sheet, contentTable, strs, ints, 18);
//logger.info(">>>>>>>>>>>>>>>>>>>>表头样式设置完成>>>>>>>>>>");
for (int i = 0; i < list.size(); i++) {
LinkedHashMap<String, Object> map1 = (LinkedHashMap<String, Object>) list.get(i);
SXSSFRow row = sheet.createRow(i + 19);
int j = 1;
SXSSFCell cell = row.createCell(j++);
if(map1.get("CF_ITEM_N") != null){
cell.setCellValue((String) map1.get("CF_ITEM_N")); // 款项性质
}else{
cell.setCellValue(""); // 款项性质
}
cell.setCellStyle(contentTable);
cell = row.createCell(j++);
if(map1.get("TIMES") != null){
cell.setCellValue(ExcelFormatUtil.getBigDecimal(map1.get("TIMES")).toString()); // 期次
}else{
cell.setCellValue(""); // 期次
}
cell.setCellStyle(contentTable);
cell = row.createCell(j++);
if(map1.get("DUE_DATE") != null){
cell.setCellValue((String) map1.get("DUE_DATE")); // 应付日
}else{
cell.setCellValue(""); // 应付日
}
cell.setCellStyle(contentTable);
cell = row.createCell(j++);
if(map1.get("DUE_AMOUNT") != null){
cell.setCellValue((String) map1.get("DUE_AMOUNT")); // 应付金额
}else{
cell.setCellValue(""); // 应付金额
}
cell.setCellStyle(contentTable);
cell = row.createCell(j++);
if(map1.get("TRANSACTION_DATE") != null){
cell.setCellValue((String) map1.get("TRANSACTION_DATE")); // 实际收款日
}else{
cell.setCellValue(""); // 实际收款日
}
cell.setCellStyle(contentTable);
cell = row.createCell(j++);
if(map1.get("RECEIVED_AMOUNT") != null){
cell.setCellValue((String) map1.get("RECEIVED_AMOUNT")); // 收款金额
}else{
cell.setCellValue(""); // 收款金额
}
cell.setCellStyle(contentTable);
cell = row.createCell(j++);
if(map1.get("RECEIVED_AMOUNT_9") != null){
cell.setCellValue((String) map1.get("RECEIVED_AMOUNT_9")); // 实收违约金
}else{
cell.setCellValue(""); // 实收违约金
}
cell.setCellStyle(contentTable);
cell = row.createCell(j++);
if(map1.get("UNRECEIVED_AMOUNT") != null){
cell.setCellValue((String) map1.get("UNRECEIVED_AMOUNT")); // 未收金额
}else{
cell.setCellValue(""); // 未收金额
}
cell.setCellStyle(contentTable);
}
}
//logger.info(">>>>>>>>>>>>>>>>>>>>结束遍历数据组装单元格内容>>>>>>>>>>");
contentExcel = "由于入账处理需要时间,以上还款金额可能未包含最近一次的还款记录。";
ExcelFormatUtil.initContent(sheet, content, contentExcel, list.size() + 18 + 2, 1);
contentExcel = "请参考。";
ExcelFormatUtil.initContent(sheet, content, contentExcel, list.size() + 18 + 4, 1);
contentExcel = "宏菱融资租赁(上海)有限公司";
ExcelFormatUtil.initContent(sheet, content, contentExcel, list.size() + 18 + 6, 6);
contentExcel = "(公章)";
ExcelFormatUtil.initContent(sheet, content, contentExcel, list.size() + 18 + 8, 5);
contentExcel = (String) map.get("TODAY");
ExcelFormatUtil.initContent(sheet, content, contentExcel, list.size() + 18 + 9, 6);
try {
outputResponse(response, wb, "对账单(" + (String) map.get("BP_NAME") + (String) map.get("CONTRACT_NUMBER") + ").xlsx");
} catch (Exception e) {
e.printStackTrace();
}
}
private void outputResponse(HttpServletResponse response, SXSSFWorkbook sheets, String fileName) throws IOException {
response.addHeader("Content-Disposition", "attachment;filename=\"" + URLEncoder.encode(fileName, "UTF-8") + "\"");
response.setContentType(sheets.getXSSFWorkbook().getWorkbookType().getContentType() + ";charset=" + "UTF-8");
response.setHeader("Accept-Ranges", "bytes");
sheets.write(response.getOutputStream());
sheets.dispose();
}
}
package com.hand.hls.hlcm.cont.util;
/**
* @Author: Liyuan.Chen
* @Date: 2020/8/19
* @Purpose:
*/
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
* excle样式工具类
* @author linry
*
*/
public class ExcelFormatUtil {
/**
* 设置报表头样式
* @param workbook
* @return
*/
public static CellStyle headSytle(SXSSFWorkbook workbook){
// 设置style1的样式,此样式运用在第二行
CellStyle style1 = workbook.createCellStyle();// cell样式
// 设置单元格背景色,设置单元格背景色以下两句必须同时设置
/*style1.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);// 设置填充样式
style1.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);// 设置填充色*/
// 设置单元格上、下、左、右的边框线
/*style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
style1.setBorderTop(HSSFCellStyle.BORDER_THIN);*/
Font font1 = workbook.createFont();// 创建一个字体对象
font1.setBold(true);
//font1.setBoldweight((short) 16);// 设置字体的宽度
font1.setFontHeightInPoints((short) 16);// 设置字体的高度
font1.setFontName("等线");
//font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 粗体显示
style1.setFont(font1);// 设置style1的字体
style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.CENTER);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
return style1;
}
/**
* 设置报表体样式
* @param wb
* @return
*/
public static CellStyle contentStyle(SXSSFWorkbook wb){
// 设置style1的样式,此样式运用在第二行
CellStyle style1 = wb.createCellStyle();// cell样式
// 设置单元格上、下、左、右的边框线
/*style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
style1.setBorderTop(HSSFCellStyle.BORDER_THIN);*/
//style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.LEFT);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
return style1;
}
public static CellStyle contentStyleLine(SXSSFWorkbook wb){
// 设置style1的样式,此样式运用在第二行
CellStyle style1 = wb.createCellStyle();// cell样式
// 设置单元格上、下、左、右的边框线
style1.setBorderBottom(BorderStyle.THIN);
/* style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
style1.setBorderTop(HSSFCellStyle.BORDER_THIN);*/
style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.LEFT);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
return style1;
}
public static CellStyle contentTableStyle(SXSSFWorkbook wb){
// 设置style1的样式,此样式运用在第二行
CellStyle style1 = wb.createCellStyle();// cell样式
// 设置单元格上、下、左、右的边框线
style1.setBorderBottom(BorderStyle.THIN);
style1.setBorderLeft(BorderStyle.THIN);
style1.setBorderRight(BorderStyle.THIN);
style1.setBorderTop(BorderStyle.THIN);
style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.CENTER);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
return style1;
}
/**
* 设置报表标题样式
* @param workbook
* @return
*/
public static HSSFCellStyle titleSytle(HSSFWorkbook workbook,short color,short fontSize){
// 设置style1的样式,此样式运用在第二行
HSSFCellStyle style1 = workbook.createCellStyle();// cell样式
// 设置单元格背景色,设置单元格背景色以下两句必须同时设置
//style1.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);// 设置填充样式
//short fcolor = color;
// 设置单元格上、下、左、右的边框线
style1.setBorderBottom(BorderStyle.THIN);
style1.setBorderLeft(BorderStyle.THIN);
style1.setBorderRight(BorderStyle.THIN);
style1.setBorderTop(BorderStyle.THIN);
HSSFFont font1 = workbook.createFont();// 创建一个字体对象
font1.setBold(true);
font1.setFontHeightInPoints(fontSize);// 设置字体的高度
style1.setFont(font1);// 设置style1的字体
style1.setWrapText(true);// 设置自动换行
style1.setAlignment(HorizontalAlignment.CENTER);// 设置单元格字体显示居中(左右方向)
style1.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格字体显示居中(上下方向)
return style1;
}
/**
*设置表头
* @param sheet
*/
public static void initTitleEX(SXSSFSheet sheet, CellStyle header,String title[],int titleLength[]) {
SXSSFRow row0 = sheet.createRow(0);
row0.setHeight((short) 800);
for(int j = 0;j<title.length; j++) {
SXSSFCell cell = row0.createCell(j);
//设置每一列的字段名
cell.setCellValue(title[j]);
cell.setCellStyle(header);
sheet.setColumnWidth(j, titleLength[j]);
}
}
/**
*设置表头
* @param sheet
*/
public static void initTitle(SXSSFSheet sheet, CellStyle header, String title, int firstRow, int firstrCol) {
SXSSFRow row = sheet.createRow(firstRow);
SXSSFCell cell = row.createCell(firstrCol);
//设置每一列的字段名
cell.setCellValue(title);
cell.setCellStyle(header);
CellRangeAddress region = new CellRangeAddress(firstRow, firstRow+1, firstrCol, 9);
sheet.addMergedRegion(region);
}
public static void initContent(SXSSFSheet sheet, CellStyle contentType, String content, int firstRow, int firstrCol) {
SXSSFRow row = sheet.createRow(firstRow);
SXSSFCell cell = row.createCell(firstrCol);
//设置每一列的字段名
cell.setCellValue(content);
cell.setCellStyle(contentType);
CellRangeAddress region = new CellRangeAddress(firstRow, firstRow, firstrCol, 9);
sheet.addMergedRegion(region);
}
public static void initColumn(SXSSFSheet sheet, CellStyle contentTable,String title[],int titleLength[], int firstRow) {
SXSSFRow row = sheet.createRow(firstRow);
for(int j = 1;j<=title.length; j++) {
SXSSFCell cell = row.createCell(j);
//设置每一列的字段名
cell.setCellValue(title[j-1]);
cell.setCellStyle(contentTable);
sheet.setColumnWidth(j, titleLength[j-1]);
}
}
public static BigDecimal getBigDecimal(Object value) {
BigDecimal ret = null;
if (value != null) {
if (value instanceof BigDecimal) {
ret = (BigDecimal) value;
} else if (value instanceof String) {
ret = new BigDecimal((String) value);
} else if (value instanceof BigInteger) {
ret = new BigDecimal((BigInteger) value);
} else if (value instanceof Number) {
ret = new BigDecimal(((Number) value).doubleValue());
} else {
throw new ClassCastException("Not possible to coerce [" + value + "] from class " + value.getClass() + " into a BigDecimal.");
}
}
return ret;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hand.hls.hlcm.cont.mapper.ConExportMapper">
<!--<resultMap id="BaseResultMap" type="com.hand.hls.hlcm.hls.dto.HlsMaster">
<result column="TPL_NO" property="tplNo" jdbcType="VARCHAR"/>
<result column="TPL_TITLE" property="tplTitle" jdbcType="VARCHAR"/>
<result column="LAST_UPDATED_USER" property="lastUpdatedUser" jdbcType="VARCHAR"/>
<result column="LAST_UPDATE_DATE" property="lastUpdateDate" jdbcType="DATE"/>
</resultMap>-->
<select id="selectCashflowList" parameterType="integer" resultType="java.util.LinkedHashMap">
Select
contract_id,
cashflow_id,
write_off_id,
cf_item,
cf_item_n,
times,
due_date,
to_char(due_amount, 'fm999,999,999,990.00') due_amount,
transaction_date,
write_off_date,
to_char(received_amount, 'fm999,999,999,990.00') received_amount,
to_char(unreceived_amount, 'fm999,999,999,990.00') unreceived_amount,
times_9,
to_char(due_amount_9, 'fm999,999,999,990.00') due_amount_9,
to_char(nvl(received_amount_9, 0), 'fm999,999,999,990.00') received_amount_9,
to_char(unreceived_amount_9, 'fm999,999,999,990.00') unreceived_amount_9
from
(select *
From (Select
t1.contract_id,
t1.cashflow_id,
t1.write_off_id,
t1.cf_item,
t1.cf_item_n,
t1.times,
t1.due_date,
t1.due_amount,
t1.transaction_date,
t1.write_off_date,
t1.received_amount,
t1.unreceived_amount,
nvl(t2.times, t1.times) As times_9,
nvl(t2.due_amount, 0) As due_amount_9,
nvl(t2.received_amount, 0) As received_amount_9,
nvl(t2.unreceived_amount, 0) As unreceived_amount_9
From (Select
c.contract_id,
cwo.cashflow_id,
cwo.write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, 'yyyy-mm-dd') due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;= cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, &apos;yyyy-mm-dd&apos;) transaction_date,
to_char(cwo.write_off_date, &apos;yyyy-mm-dd&apos;) write_off_date,
--实收金额
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;= cwo.creation_date),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
csh_write_off cwo,
csh_transaction t
Where cwo.cashflow_id = ccc.cashflow_id
And ccc.contract_id = c.contract_id
And cwo.csh_transaction_id = t.transaction_id
And nvl(cwo.reversed_flag, &apos;N&apos;) = &apos;N&apos;
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item Not In (0, 9)
And c.contract_id = #{contractId}
Order By ccc.times,
ccc.cf_item,
t.transaction_date,
cwo.write_off_id) t1,
(Select
c.contract_id,
cwo.cashflow_id,
cwo.write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;= cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, &apos;yyyy-mm-dd&apos;) transaction_date,
to_char(cwo.write_off_date, &apos;yyyy-mm-dd&apos;) write_off_date,
--实收金额
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;= cwo.creation_date),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
csh_write_off cwo,
csh_transaction t
Where cwo.cashflow_id = ccc.cashflow_id
And ccc.contract_id = c.contract_id
And cwo.csh_transaction_id = t.transaction_id
And nvl(cwo.reversed_flag, &apos;N&apos;) = &apos;N&apos;
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item = 9
And c.contract_id = #{contractId}
Order By ccc.times,
ccc.cf_item,
t.transaction_date,
cwo.write_off_id) t2
Where t1.transaction_date = t2.transaction_date (+)
And t1.times = t2.times (+)
Union
Select
nvl(t1.contract_id, t2.contract_id) contract_id,
nvl(t1.cashflow_id, t2.cashflow_id) cashflow_id,
nvl(t1.write_off_id, t2.write_off_id) write_off_id,
nvl(t1.cf_item,
(Select cc2.cf_item
From con_contract_cashflow cc2
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;)) cf_item,
nvl(t1.cf_item_n,
(Select h.description
From con_contract_cashflow cc2, hls_cashflow_item h
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;
And h.cf_item = cc2.cf_item)) cf_item_n,
nvl(t1.times, t2.times) As times,
nvl(t1.due_date,
(Select to_char(cc2.due_date, &apos;yyyy-mm-dd&apos;)
From con_contract_cashflow cc2
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;)) due_date,
nvl(t1.due_amount,
(Select cc2.due_amount - nvl(cc2.received_amount, 0)
From con_contract_cashflow cc2
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;)) As due_amount,
nvl(t1.transaction_date, t2.transaction_date) transaction_date,
nvl(t1.write_off_date, t2.write_off_date) write_off_date,
nvl(t1.received_amount, 0) As received_amount,
nvl(t1.unreceived_amount,
(Select cc2.due_amount - nvl(cc2.received_amount, 0)
From con_contract_cashflow cc2
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;)) As unreceived_amount,
t2.times As times_9,
nvl(t2.due_amount, 0) As due_amount_9,
nvl(t2.received_amount, 0) As received_amount_9,
nvl(t2.unreceived_amount, 0) As unreceived_amount_9
From (Select
c.contract_id,
cwo.cashflow_id,
cwo.write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;= cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, &apos;yyyy-mm-dd&apos;) transaction_date,
to_char(cwo.write_off_date, &apos;yyyy-mm-dd&apos;) write_off_date,
--实收金额
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;= cwo.creation_date),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
hls_bp_master h,
csh_write_off cwo,
csh_transaction t
Where cwo.cashflow_id = ccc.cashflow_id
And ccc.contract_id = c.contract_id
And cwo.csh_transaction_id = t.transaction_id
And nvl(cwo.reversed_flag, &apos;N&apos;) = &apos;N&apos;
And h.bp_id = c.bp_id_tenant
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item Not In (0, 9)
And c.contract_id = #{contractId}
Order By ccc.times,
ccc.cf_item,
t.transaction_date,
cwo.write_off_id) t1,
(Select
c.contract_id,
cwo.cashflow_id,
cwo.write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;= cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, &apos;yyyy-mm-dd&apos;) transaction_date,
to_char(cwo.write_off_date, &apos;yyyy-mm-dd&apos;) write_off_date,
--实收金额
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;= cwo.creation_date),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
csh_write_off cwo,
csh_transaction t
Where cwo.cashflow_id = ccc.cashflow_id
And ccc.contract_id = c.contract_id
And cwo.csh_transaction_id = t.transaction_id
And nvl(cwo.reversed_flag, &apos;N&apos;) = &apos;N&apos;
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item = 9
And c.contract_id = #{contractId}
Order By ccc.times,
ccc.cf_item,
t.transaction_date,
cwo.write_off_id) t2
Where t1.transaction_date (+) = t2.transaction_date
And t1.times (+) = t2.times
Union
Select
ccc.contract_id,
ccc.cashflow_id,
Null write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
ccc.due_amount,
&apos;&apos; transaction_date,
&apos;&apos; write_off_date,
nvl(ccc.received_amount, 0) received_amount,
(ccc.due_amount - nvl(ccc.received_amount, 0)) unreceived_amount,
(Select cc1.times
From con_contract_cashflow cc1
Where cc1.contract_id = ccc.contract_id
And cc1.times = ccc.times
And cc1.cf_direction = &apos;INFLOW&apos;
And cc1.cf_status = &apos;RELEASE&apos;
And cc1.cf_item = 9) As times_9,
(Select cc1.due_amount
From con_contract_cashflow cc1
Where cc1.contract_id = ccc.contract_id
And cc1.times = ccc.times
And cc1.cf_direction = &apos;INFLOW&apos;
And cc1.cf_status = &apos;RELEASE&apos;
And cc1.cf_item = 9) As due_amount_9,
(Select nvl(cc1.received_amount, 0)
From con_contract_cashflow cc1
Where cc1.contract_id = ccc.contract_id
And cc1.times = ccc.times
And cc1.cf_direction = &apos;INFLOW&apos;
And cc1.cf_status = &apos;RELEASE&apos;
And cc1.cf_item = 9) As received_amount_9,
(Select cc1.due_amount - nvl(cc1.received_amount, 0)
From con_contract_cashflow cc1
Where cc1.contract_id = ccc.contract_id
And cc1.times = ccc.times
And cc1.cf_direction = &apos;INFLOW&apos;
And cc1.cf_status = &apos;RELEASE&apos;
And cc1.cf_item = 9) unreceived_amount_9
From con_contract_cashflow ccc
Where ccc.contract_id = #{contractId}
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item Not In (0, 9)
And ccc.times &gt;
nvl((Select Max(cc2.times)
From con_contract_cashflow cc2
Where cc2.contract_id = ccc.contract_id
And cc2.cf_item &lt;&gt; 0
And nvl(cc2.received_amount, 0) &lt;&gt; 0), -1)
Union
Select
Null contract_id,
Null cashflow_id,
Null write_off_id,
100 cf_item,
&apos;合计&apos; cf_item_n,
Null times,
&apos;&apos; due_date,
Sum(due_amount) due_amount,
&apos;&apos; transaction_date,
&apos;&apos; write_off_date,
Sum(received_amount) received_amount,
Sum(unreceived_amount) unreceived_amount,
Null times_9,
Sum(due_amount_9) due_amount_9,
Sum(received_amount_9) received_amount_9,
Sum(unreceived_amount_9) unreceived_amount_9
From (Select
t1.*,
nvl(t2.times, t1.times) As times_9,
nvl(t2.due_amount, 0) As due_amount_9,
nvl(t2.received_amount, 0) As received_amount_9,
nvl(t2.unreceived_amount, 0) As unreceived_amount_9
From (Select
c.contract_id,
cwo.cashflow_id,
cwo.write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, &apos;yyyy-mm-dd&apos;) transaction_date,
to_char(cwo.write_off_date, &apos;yyyy-mm-dd&apos;) write_off_date,
--实收金额
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
csh_write_off cwo,
csh_transaction t
Where cwo.cashflow_id = ccc.cashflow_id
And ccc.contract_id = c.contract_id
And cwo.csh_transaction_id = t.transaction_id
And nvl(cwo.reversed_flag, &apos;N&apos;) = &apos;N&apos;
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item Not In (0, 9)
And c.contract_id = #{contractId}
Order By ccc.times,
ccc.cf_item,
t.transaction_date,
cwo.write_off_id) t1,
(Select
c.contract_id,
cwo.cashflow_id,
cwo.write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, &apos;yyyy-mm-dd&apos;) transaction_date,
to_char(cwo.write_off_date, &apos;yyyy-mm-dd&apos;) write_off_date,
--实收金额
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
csh_write_off cwo,
csh_transaction t
Where cwo.cashflow_id = ccc.cashflow_id
And ccc.contract_id = c.contract_id
And cwo.csh_transaction_id = t.transaction_id
And nvl(cwo.reversed_flag, &apos;N&apos;) = &apos;N&apos;
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item = 9
And c.contract_id = #{contractId}
Order By ccc.times,
ccc.cf_item,
t.transaction_date,
cwo.write_off_id) t2
Where t1.transaction_date = t2.transaction_date (+)
And t1.times = t2.times (+)
Union
Select
nvl(t1.contract_id, t2.contract_id) contract_id,
nvl(t1.cashflow_id, t2.cashflow_id) cashflow_id,
nvl(t1.write_off_id, t2.write_off_id) write_off_id,
nvl(t1.cf_item,
(Select cc2.cf_item
From con_contract_cashflow cc2
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;)) cf_item,
nvl(t1.cf_item_n,
(Select h.description
From con_contract_cashflow cc2,
hls_cashflow_item h
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;
And h.cf_item = cc2.cf_item)) cf_item_n,
nvl(t1.times, t2.times) As times,
nvl(t1.due_date,
(Select to_char(cc2.due_date, &apos;yyyy-mm-dd&apos;)
From con_contract_cashflow cc2
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;)) due_date,
nvl(t1.due_amount,
(Select cc2.due_amount - nvl(cc2.received_amount, 0)
From con_contract_cashflow cc2
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;)) As due_amount,
nvl(t1.transaction_date, t2.transaction_date) transaction_date,
nvl(t1.write_off_date, t2.write_off_date) write_off_date,
nvl(t1.received_amount, 0) As received_amount,
nvl(t1.unreceived_amount,
(Select cc2.due_amount - nvl(cc2.received_amount, 0)
From con_contract_cashflow cc2
Where cc2.contract_id = t2.contract_id
And cc2.times = t2.times
And cc2.cf_item Not In (0, 9)
And cc2.cf_direction = &apos;INFLOW&apos;
And cc2.cf_status = &apos;RELEASE&apos;)) As unreceived_amount,
t2.times As times_9,
nvl(t2.due_amount, 0) As due_amount_9,
nvl(t2.received_amount, 0) As received_amount_9,
nvl(t2.unreceived_amount, 0) As unreceived_amount_9
From (Select
c.contract_id,
cwo.cashflow_id,
cwo.write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, &apos;yyyy-mm-dd&apos;) transaction_date,
to_char(cwo.write_off_date, &apos;yyyy-mm-dd&apos;) write_off_date,
--实收金额
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
hls_bp_master h,
csh_write_off cwo,
csh_transaction t
Where cwo.cashflow_id = ccc.cashflow_id
And ccc.contract_id = c.contract_id
And cwo.csh_transaction_id = t.transaction_id
And nvl(cwo.reversed_flag, &apos;N&apos;) = &apos;N&apos;
And h.bp_id = c.bp_id_tenant
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item Not In (0, 9)
And c.contract_id = #{contractId}
Order By ccc.times,
ccc.cf_item,
t.transaction_date,
cwo.write_off_id) t1,
(Select
c.contract_id,
cwo.cashflow_id,
cwo.write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0) + cwo.write_off_due_amount) As due_amount,
--收款日
to_char(t.transaction_date, &apos;yyyy-mm-dd&apos;) transaction_date,
to_char(cwo.write_off_date, &apos;yyyy-mm-dd&apos;) write_off_date,
--实收金额
cwo.write_off_due_amount received_amount,
(ccc.due_amount -
nvl((Select Sum(tn.write_off_due_amount)
From csh_write_off tn
Where tn.cashflow_id = cwo.cashflow_id
And tn.creation_date &lt;=
cwo.creation_date),
0)) As unreceived_amount
From con_contract_cashflow ccc,
con_contract c,
csh_write_off cwo,
csh_transaction t
Where cwo.cashflow_id = ccc.cashflow_id
And ccc.contract_id = c.contract_id
And cwo.csh_transaction_id = t.transaction_id
And nvl(cwo.reversed_flag, &apos;N&apos;) = &apos;N&apos;
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item = 9
And c.contract_id = #{contractId}
Order By ccc.times,
ccc.cf_item,
t.transaction_date,
cwo.write_off_id) t2
Where t1.transaction_date (+) = t2.transaction_date
And t1.times (+) = t2.times
Union
Select
ccc.contract_id,
ccc.cashflow_id,
Null write_off_id,
ccc.cf_item,
(Select h.description
From hls_cashflow_item h
Where h.cf_item = ccc.cf_item) cf_item_n,
ccc.times,
to_char(ccc.due_date, &apos;yyyy-mm-dd&apos;) due_date,
ccc.due_amount,
&apos;&apos; transaction_date,
&apos;&apos; write_off_date,
nvl(ccc.received_amount, 0) received_amount,
(ccc.due_amount - nvl(ccc.received_amount, 0)) unreceived_amount,
(Select cc1.times
From con_contract_cashflow cc1
Where cc1.contract_id = ccc.contract_id
And cc1.times = ccc.times
And cc1.cf_direction = &apos;INFLOW&apos;
And cc1.cf_status = &apos;RELEASE&apos;
And cc1.cf_item = 9) As times_9,
(Select cc1.due_amount
From con_contract_cashflow cc1
Where cc1.contract_id = ccc.contract_id
And cc1.times = ccc.times
And cc1.cf_direction = &apos;INFLOW&apos;
And cc1.cf_status = &apos;RELEASE&apos;
And cc1.cf_item = 9) As due_amount_9,
(Select nvl(cc1.received_amount, 0)
From con_contract_cashflow cc1
Where cc1.contract_id = ccc.contract_id
And cc1.times = ccc.times
And cc1.cf_direction = &apos;INFLOW&apos;
And cc1.cf_status = &apos;RELEASE&apos;
And cc1.cf_item = 9) As received_amount_9,
(Select cc1.due_amount - nvl(cc1.received_amount, 0)
From con_contract_cashflow cc1
Where cc1.contract_id = ccc.contract_id
And cc1.times = ccc.times
And cc1.cf_direction = &apos;INFLOW&apos;
And cc1.cf_status = &apos;RELEASE&apos;
And cc1.cf_item = 9) unreceived_amount_9
From con_contract_cashflow ccc
Where ccc.contract_id = #{contractId}
And ccc.cf_direction = &apos;INFLOW&apos;
And ccc.cf_status = &apos;RELEASE&apos;
And ccc.cf_item Not In (0, 9)
And ccc.times &gt;
nvl((Select Max(cc2.times)
From con_contract_cashflow cc2
Where cc2.contract_id = ccc.contract_id
And cc2.cf_item &lt;&gt; 0
And nvl(cc2.received_amount, 0) &lt;&gt; 0), -1)))
Order By times, cf_item, due_amount Desc, transaction_date, write_off_date)
</select>
<select id="selectContractDetailList" parameterType="integer" resultType="java.util.HashMap">
Select
hb.bp_name,
c.contract_number,
(Select cl.machine_number
From con_contract_lease_item cl
Where cl.contract_id = c.contract_id) As machine_number,
to_char(Sysdate, &apos;yyyy"年"mm"月"dd"日"&apos;) As today
From con_contract c, hls_bp_master hb
Where c.bp_id_tenant = hb.bp_id
and c.contract_id = #{contractId}
</select>
<!--<select id="selectTemplateDetailInfo" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT A.TPL_NO
, A.DTL_DIV
, A.DTL_NO
, A.APPROVE_DIV
, A.APPROVE_VAL
, A.APPROVE_TP
FROM DS_EXP_TEMPLATE_DTL A
WHERE A.TPL_NO = #{sch_tpl_no}
AND A.DTL_DIV = #{sch_dtl_div}
AND A.DTL_NO = #{sch_dtl_no}
ORDER BY A.TPL_NO
</select>
<update id="updateTemplateDetail" parameterType="java.util.HashMap">
MERGE INTO DS_EXP_TEMPLATE_DTL DI
USING
(
select #{inp_tpl_no} AS TPL_NO
, #{inp_dtl_div} AS DTL_DIV
, #{inp_dtl_no} AS DTL_NO
, #{inp_approve_div} AS APPROVE_DIV
, #{inp_approve_val} AS APPROVE_VAL
, #{inp_approve_tp} AS APPROVE_TP
from DUAL
) A_DI
ON (DI.TPL_NO = A_DI.TPL_NO AND DI.DTL_DIV = A_DI.DTL_DIV AND DI.DTL_NO = A_DI.DTL_NO)
WHEN MATCHED THEN
UPDATE SET
DI.APPROVE_DIV = A_DI.APPROVE_DIV
,DI.APPROVE_VAL = A_DI.APPROVE_VAL
,DI.APPROVE_TP = A_DI.APPROVE_TP
WHEN NOT MATCHED THEN
INSERT (
TPL_NO
,DTL_DIV
,DTL_NO
,APPROVE_DIV
,APPROVE_VAL
,APPROVE_TP
)VALUES(
A_DI.TPL_NO
,A_DI.DTL_DIV
,A_DI.DTL_NO
,A_DI.APPROVE_DIV
,A_DI.APPROVE_VAL
,A_DI.APPROVE_TP
)
</update>-->
</mapper>
\ No newline at end of file
...@@ -65,12 +65,12 @@ ...@@ -65,12 +65,12 @@
WHERE hd.enabled_flag = 'Y' WHERE hd.enabled_flag = 'Y'
AND hd.division = cc.division) division_n, AND hd.division = cc.division) division_n,
cc.division, cc.division,
/*contract_item_query_pkg.calc_ac_overdue_times(p_contract_id => cc.contract_id, contract_item_query_pkg.calc_ac_overdue_times(p_contract_id => cc.contract_id,
p_calc_date => SYSDATE, p_calc_date => SYSDATE,
p_user_id => -1) account_due_times, p_user_id => -1) account_due_times,
contract_item_query_pkg.calc_ac_overdue_days(p_contract_id => cc.contract_id, contract_item_query_pkg.calc_ac_overdue_days(p_contract_id => cc.contract_id,
p_calc_date => SYSDATE, p_calc_date => SYSDATE,
p_user_id => -1) account_due_days,*/ p_user_id => -1) account_due_days,
(SELECT SUM(ccc.due_amount) (SELECT SUM(ccc.due_amount)
...@@ -89,12 +89,12 @@ ...@@ -89,12 +89,12 @@
and gwo.contract_id = ccw.contract_id and gwo.contract_id = ccw.contract_id
AND trunc(ccw.due_date) <= trunc(SYSDATE)), 0) account_due_amount, AND trunc(ccw.due_date) <= trunc(SYSDATE)), 0) account_due_amount,
/*contract_item_query_pkg.calc_business_overdue_times(p_contract_id => cc.contract_id, contract_item_query_pkg.calc_business_overdue_times(p_contract_id => cc.contract_id,
p_calc_date => SYSDATE, p_calc_date => SYSDATE,
p_user_id => -1) business_due_times, p_user_id => -1) business_due_times,
contract_item_query_pkg.calc_bussiness_overdue_days(p_contract_id => cc.contract_id, contract_item_query_pkg.calc_bussiness_overdue_days(p_contract_id => cc.contract_id,
p_calc_date => SYSDATE, p_calc_date => SYSDATE,
p_user_id => -1) business_due_days,*/ p_user_id => -1) business_due_days,
(SELECT SUM(ccc.due_amount) (SELECT SUM(ccc.due_amount)
FROM con_contract_cashflow ccc FROM con_contract_cashflow ccc
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
AND ccc.cf_status = 'RELEASE' AND ccc.cf_status = 'RELEASE'
AND ccc.cf_item IN (1, 8, 250) AND ccc.cf_item IN (1, 8, 250)
) total_due_amount, ) total_due_amount,
cc.contract_status, cc.contract_status/*,
(Select Count(1) (Select Count(1)
From con_contract_cashflow ccc From con_contract_cashflow ccc
Where ccc.contract_id = cc.contract_id Where ccc.contract_id = cc.contract_id
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
And gwo.contract_id = ccc.contract_id And gwo.contract_id = ccc.contract_id
And gwo.times = ccc.times And gwo.times = ccc.times
And gwo.cf_item = ccc.cf_item), And gwo.cf_item = ccc.cf_item),
0)) As account_due_days -- 会计逾期天数 0)) As account_due_days -- 会计逾期天数*/
FROM con_contract cc FROM con_contract cc
WHERE WHERE
......
...@@ -27,36 +27,36 @@ ...@@ -27,36 +27,36 @@
'金', '金',
7, 7,
'土') named_day, '土') named_day,
(SELECT SUM(due_amount - nvl(received_amount, 0)) (SELECT SUM(ccc.due_amount - nvl(ccc.received_amount, 0))
FROM con_contract_cashflow FROM con_contract_cashflow ccc
WHERE cf_item = 8 WHERE ccc.cf_item = 8
AND due_date = t.calendar_date AND ccc.due_date = t.calendar_date
AND EXISTS AND EXISTS
(SELECT 1 (SELECT 1
FROM con_contract ct FROM con_contract ct
WHERE ct.contract_status IN WHERE ct.contract_status IN
('INCEPT', 'PENDING','ETING', 'REPURING') ('INCEPT', 'PENDING','ETING', 'REPURING')
AND ct.contract_id = contract_id)) purchase_amount, --留购金 AND ct.contract_id = ccc.contract_id)) purchase_amount, --留购金
(SELECT SUM(due_amount - nvl(received_amount, 0)) (SELECT SUM(ccc.due_amount - nvl(ccc.received_amount, 0))
FROM con_contract_cashflow FROM con_contract_cashflow ccc
WHERE cf_item = 2 WHERE ccc.cf_item = 2
AND due_date = t.calendar_date AND ccc.due_date = t.calendar_date
AND EXISTS AND EXISTS
(SELECT 1 (SELECT 1
FROM con_contract ct FROM con_contract ct
WHERE ct.contract_status IN WHERE ct.contract_status IN
('INCEPT', 'PENDING','ETING', 'REPURING') ('INCEPT', 'PENDING','ETING', 'REPURING')
AND ct.contract_id = contract_id)) down_payment, --首付款 AND ct.contract_id = ccc.contract_id)) down_payment, --首付款
(SELECT SUM(due_amount) (SELECT SUM(ccc.due_amount)
FROM con_contract_cashflow ccc FROM con_contract_cashflow ccc
WHERE cf_item = 1 WHERE ccc.cf_item = 1
AND due_date = t.calendar_date AND ccc.due_date = t.calendar_date
AND EXISTS AND EXISTS
(SELECT 1 (SELECT 1
FROM con_contract ct FROM con_contract ct
WHERE ct.contract_status IN WHERE ct.contract_status IN
('INCEPT', 'PENDING','ETING', 'REPURING') ('INCEPT', 'PENDING','ETING', 'REPURING')
AND ct.contract_id = contract_id)) lease_amount, --租金 AND ct.contract_id = ccc.contract_id)) lease_amount, --租金
(CASE (CASE
WHEN to_char(SYSDATE, 'dd') <= 20 AND WHEN to_char(SYSDATE, 'dd') <= 20 AND
to_char(t.calendar_date, 'yyyymmdd') = to_char(t.calendar_date, 'yyyymmdd') =
......
...@@ -27,36 +27,36 @@ ...@@ -27,36 +27,36 @@
'金', '金',
7, 7,
'土') named_day, '土') named_day,
(SELECT SUM(due_amount - nvl(received_amount, 0)) (SELECT SUM(ccc.due_amount - nvl(ccc.received_amount, 0))
FROM con_contract_cashflow FROM con_contract_cashflow ccc
WHERE cf_item = 8 WHERE ccc.cf_item = 8
AND due_date = t.calendar_date AND ccc.due_date = t.calendar_date
AND EXISTS AND EXISTS
(SELECT 1 (SELECT 1
FROM con_contract ct FROM con_contract ct
WHERE ct.contract_status IN WHERE ct.contract_status IN
('INCEPT', 'PENDING', 'ETING', 'REPURING') ('INCEPT', 'PENDING', 'ETING', 'REPURING')
AND ct.contract_id = contract_id)) purchase_amount, --留购金 AND ct.contract_id = ccc.contract_id)) purchase_amount, --留购金
(SELECT SUM(due_amount - nvl(received_amount, 0)) (SELECT SUM(ccc.due_amount - nvl(ccc.received_amount, 0))
FROM con_contract_cashflow FROM con_contract_cashflow ccc
WHERE cf_item = 2 WHERE ccc.cf_item = 2
AND due_date = t.calendar_date AND ccc.due_date = t.calendar_date
AND EXISTS AND EXISTS
(SELECT 1 (SELECT 1
FROM con_contract ct FROM con_contract ct
WHERE ct.contract_status IN WHERE ct.contract_status IN
('INCEPT', 'PENDING', 'ETING', 'REPURING') ('INCEPT', 'PENDING', 'ETING', 'REPURING')
AND ct.contract_id = contract_id)) down_payment, --首付款 AND ct.contract_id = ccc.contract_id)) down_payment, --首付款
(SELECT SUM(due_amount) (SELECT SUM(ccc.due_amount)
FROM con_contract_cashflow ccc FROM con_contract_cashflow ccc
WHERE cf_item = 1 WHERE ccc.cf_item = 1
AND due_date = t.calendar_date AND ccc.due_date = t.calendar_date
AND EXISTS AND EXISTS
(SELECT 1 (SELECT 1
FROM con_contract ct FROM con_contract ct
WHERE ct.contract_status IN WHERE ct.contract_status IN
('INCEPT', 'PENDING', 'ETING', 'REPURING') ('INCEPT', 'PENDING', 'ETING', 'REPURING')
AND ct.contract_id = contract_id)) lease_amount, --租金 AND ct.contract_id = ccc.contract_id)) lease_amount, --租金
(CASE (CASE
WHEN to_char(SYSDATE, 'dd') <= 20 AND WHEN to_char(SYSDATE, 'dd') <= 20 AND
to_char(t.calendar_date, 'yyyymmdd') = to_char(t.calendar_date, 'yyyymmdd') =
......
...@@ -217,6 +217,18 @@ ...@@ -217,6 +217,18 @@
fullScreen: true fullScreen: true
}); });
}; };
window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function () {
debugger;
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var record = $(ds_id).getSelected()[0];
var url;
url ='${/request/@context_path}/con/contract/conExportExcel?contractId=' + record.get('contract_id');
window.open(href = url);
//window.location.href='${/request/@context_path}/con/contract/conExportExcel?contractId='+record.get('contract_id');
};
]]></script> ]]></script>
<a:screen-include <a:screen-include
screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON501"/> screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON501"/>
......
...@@ -7,9 +7,16 @@ ...@@ -7,9 +7,16 @@
--> -->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" customizationEnabled="true" <a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" customizationEnabled="true"
dynamiccreateenabled="true" trace="true"> dynamiccreateenabled="true" trace="true">
<a:init-procedure>
<s:server-script import="contract_print_path.js"><![CDATA[
$ctx.parameter.file_path = con_print_path['con_print_path'];
$ctx.parameter.tomcat_source = con_print_path['tomcat_source'];
]]>
</s:server-script>
<a:model-query model="cont.CON620.get_sys_role" rootPath="role_info"/>
</a:init-procedure>
<a:view> <a:view>
<a:link id="${/parameter/@layout_code}_con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
<script type="text/javascript"><![CDATA[ <script type="text/javascript"><![CDATA[
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<a:link id="penalty_change_id" <a:link id="penalty_change_id"
url="${/request/@context_path}/modules/cont/CON747/con_contract_penatly_change_req_detail.lview"/> url="${/request/@context_path}/modules/cont/CON747/con_contract_penatly_change_req_detail.lview"/>
<a:link id="con_contract_dun_detail_link_id" <a:link id="con_contract_dun_detail_link_id"
url="${/request/@context_path}/modules/cont/CON620/con_contract_rent_detail.lview"/> url="${/request/@context_pacon_contract_dun_for_queryth}/modules/cont/CON620/con_contract_rent_detail.lview"/>
<a:link id="con_contract_account_detail_link_id" <a:link id="con_contract_account_detail_link_id"
url="${/request/@context_path}/modules/cont/CON620/con_contract_account_detail.lview"/> url="${/request/@context_path}/modules/cont/CON620/con_contract_account_detail.lview"/>
<a:link id="con_contract_query_link_id" <a:link id="con_contract_query_link_id"
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<script type="text/javascript"><![CDATA[ <script type="text/javascript"><![CDATA[
Leaf.onReady(function(){ Leaf.onReady(function(){
//付款打印按钮只有会计担当和会计部长可见 //付款打印按钮只有会计担当和会计部长可见
if("${/model/role_info/record/@role_code}"!="0013"&&"${/model/role_info/record/@role_code}"!="0014") { if("${/model/role_info/record/@role_code}"!="0013"&&"${/model/role_info/record/@role_code}"!="0014"&&"${/model/role_info/record/@role_code}"!="0010") {
//$('${/parameter/@layout_code}_user_button5').style.display='none'; //$('${/parameter/@layout_code}_user_button5').style.display='none';
Ext.fly('${/parameter/@layout_code}_user_button5').dom.style.display="none"; Ext.fly('${/parameter/@layout_code}_user_button5').dom.style.display="none";
}else{ }else{
......
...@@ -191,7 +191,9 @@ var csh_return_atm_id = '${/model/csh_return_list_id/record/@return_list_id}'; ...@@ -191,7 +191,9 @@ var csh_return_atm_id = '${/model/csh_return_list_id/record/@return_list_id}';
<a:textField name="opposite_band_na" bindTarget="csh_transaction_deposit_return_maintain_ds" <a:textField name="opposite_band_na" bindTarget="csh_transaction_deposit_return_maintain_ds"
prompt="CSH510.CSH_TRANSACTION.YOUR_BANK_NAME"/> prompt="CSH510.CSH_TRANSACTION.YOUR_BANK_NAME"/>
<a:textField name="bp_bank_account_num" bindTarget="csh_transaction_deposit_return_maintain_ds" <a:textField name="bp_bank_account_num" bindTarget="csh_transaction_deposit_return_maintain_ds"
prompt="CSH510.CSH_TRANSACTION.YOUR_ACCOUNT_USERNAME"/> prompt="CSH510.CSH_TRANSACTION.YOUR_ACCOUNT_USERNAME" width="170"/>
<!--<a:numberField name="bp_bank_account_num" allowdecimals="false" bindTarget="csh_transaction_deposit_return_maintain_ds"
prompt="CSH510.CSH_TRANSACTION.YOUR_ACCOUNT_USERNAME" width="170"/>-->
<a:hBox> <a:hBox>
<a>附件上传:</a><a href="javascript:upload_attachment_win()" style="color:red"> 附件上传</a> <a>附件上传:</a><a href="javascript:upload_attachment_win()" style="color:red"> 附件上传</a>
</a:hBox> </a:hBox>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment