工程预付款统计功能开发
This commit is contained in:
parent
f13a35d40a
commit
8076cefae6
|
|
@ -17,6 +17,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -168,4 +169,16 @@ public class PrepaymentController {
|
|||
return list.size() > 0 ? R.okTable(list, list.size()):R.failTable("暂无数据");
|
||||
}
|
||||
|
||||
@GetMapping("/expPrepayment")
|
||||
@ApiOperation(value = "工程预付款统计-导出")
|
||||
public void expPrepayment(HttpServletResponse response, PageTableRequest request) {
|
||||
service.expPrepayment(response,request.getParams());
|
||||
}
|
||||
|
||||
@GetMapping("/expOperations")
|
||||
@ApiOperation(value = "工程预付款统计-数据更新-导出")
|
||||
public void expOperations(HttpServletResponse response, PageTableRequest request) {
|
||||
service.expOperations(response,request.getParams());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,4 +42,6 @@ public class OperationsBean {
|
|||
|
||||
private String userId; //用户id
|
||||
private String userName; //用户名
|
||||
|
||||
private String projectName; //工程名称
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.boot.manager.ca.bm.service;
|
|||
import com.bonus.boot.manager.ca.bm.entity.OperationsBean;
|
||||
import com.bonus.boot.manager.ca.bm.entity.PrepaymentBean;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -86,4 +87,18 @@ public interface PrepaymentService {
|
|||
* @return
|
||||
*/
|
||||
OperationsBean getOperationsById(String id);
|
||||
|
||||
/**
|
||||
* 导出工程预付款统计
|
||||
* @param response
|
||||
* @param params
|
||||
*/
|
||||
void expPrepayment(HttpServletResponse response, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 导出工程预付款统计数据更新
|
||||
* @param response
|
||||
* @param params
|
||||
*/
|
||||
void expOperations(HttpServletResponse response, Map<String, Object> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,25 @@
|
|||
package com.bonus.boot.manager.ca.bm.service.impl;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.bonus.boot.manager.ca.bm.dao.PrepaymentDao;
|
||||
import com.bonus.boot.manager.ca.bm.entity.OperationsBean;
|
||||
import com.bonus.boot.manager.ca.bm.entity.PrepaymentBean;
|
||||
import com.bonus.boot.manager.ca.bm.service.PrepaymentService;
|
||||
import com.bonus.boot.manager.ca.im.dao.PayableDao;
|
||||
import com.bonus.boot.manager.manager.entity.LoginUser;
|
||||
import com.bonus.boot.manager.manager.utils.UserUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* packageName com.bonus.boot.manager.ca.bm.service.impl
|
||||
|
|
@ -113,4 +121,174 @@ public class PrepaymentServiceImpl implements PrepaymentService {
|
|||
public OperationsBean getOperationsById(String id) {
|
||||
return dao.getOperationsById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expPrepayment(HttpServletResponse response, Map<String, Object> params) {
|
||||
List<PrepaymentBean> list=dao.getList(params,1,1000);
|
||||
//根据工程计算出合并单元格的数量
|
||||
Map<String, Long> collect = list.stream().collect(Collectors.groupingBy(PrepaymentBean::getId, Collectors.counting()));
|
||||
List<Long> integerList = new ArrayList<>();
|
||||
collect.forEach((k,v) -> integerList.add(v));
|
||||
|
||||
String fileName = "工程预付款统计信息";
|
||||
//记录用于合并的rowIndex
|
||||
ArrayList<HashMap<String, Integer>> mergeRows = new ArrayList<>();
|
||||
int startRowIndex = 3, start = 0;
|
||||
start = startRowIndex;
|
||||
int end = 0;
|
||||
for (int i = 0; i < integerList.size(); i++) {
|
||||
end = (int) (start + integerList.get(i)) - 1;
|
||||
if(end != start){
|
||||
HashMap<String, Integer> map = new HashMap<>();
|
||||
map.put("start", start);
|
||||
map.put("end", end);
|
||||
mergeRows.add(map);
|
||||
}
|
||||
start = end + 1;
|
||||
}
|
||||
// 导出标题
|
||||
ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getWriter(true);
|
||||
writer.merge(9, fileName,false);
|
||||
|
||||
// 合并二级表头
|
||||
writer.writeCellValue(0,1,"序号");
|
||||
writer.setColumnWidth(0, 8);
|
||||
writer.writeCellValue(1,1,"承揽合同编码");
|
||||
writer.setColumnWidth(1, 45);
|
||||
writer.writeCellValue(2,1,"承揽合同名称(工程名称)");
|
||||
writer.setColumnWidth(2, 55);
|
||||
writer.writeCellValue(3,1,"责任单位");
|
||||
writer.setColumnWidth(3, 25);
|
||||
writer.writeCellValue(4,1,"往来单位");
|
||||
writer.setColumnWidth(4, 25);
|
||||
|
||||
writer.writeCellValue(5,1,"预付款类型");
|
||||
writer.setColumnWidth(5, 25);
|
||||
writer.writeCellValue(6,1,"初始金额");
|
||||
writer.setColumnWidth(6, 25);
|
||||
writer.writeCellValue(7,1,"首次支付日期");
|
||||
writer.setColumnWidth(7, 25);
|
||||
writer.writeCellValue(8,1,"当前余额");
|
||||
writer.setColumnWidth(8, 25);
|
||||
writer.writeCellValue(9,1,"状态");
|
||||
writer.setColumnWidth(9, 25);
|
||||
|
||||
// 设置表头高度、单元格宽度
|
||||
writer.setRowHeight(0, 35);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
writer.writeCellValue(0, 2 + i, i + 1);
|
||||
writer.writeCellValue(1, 2 + i, list.get(i).getProjectCode()==null?"":list.get(i).getProjectCode());
|
||||
writer.writeCellValue(2, 2 + i, list.get(i).getProjectName()==null?"":list.get(i).getProjectName());
|
||||
writer.writeCellValue(3, 2 + i, list.get(i).getBusinessUnit()==null?"":list.get(i).getBusinessUnit());
|
||||
writer.writeCellValue(4, 2 + i, list.get(i).getContactUnit()==null?"":list.get(i).getContactUnit());
|
||||
|
||||
writer.writeCellValue(5, 2 + i, list.get(i).getType()==null?"":list.get(i).getType());
|
||||
writer.writeCellValue(6, 2 + i, list.get(i).getInitialAmount()==null?"":list.get(i).getInitialAmount());
|
||||
writer.writeCellValue(7, 2 + i, list.get(i).getFirstPaymentDate()==null?"":list.get(i).getFirstPaymentDate());
|
||||
writer.writeCellValue(8, 2 + i, list.get(i).getCurrentBalance()==null?"":list.get(i).getCurrentBalance());
|
||||
writer.writeCellValue(9, 2 + i, list.get(i).getState()=="0"?"已冲销":"未完成");
|
||||
writer.setRowHeight(2 + i, 35);
|
||||
}
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
try {
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ServletOutputStream out = null;
|
||||
try {
|
||||
out = response.getOutputStream();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
writer.flush(out, true);
|
||||
writer.close();
|
||||
IoUtil.close(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expOperations(HttpServletResponse response, Map<String, Object> params) {
|
||||
List<OperationsBean> list=dao.getOperationsList(params,1,1000);
|
||||
//根据工程计算出合并单元格的数量
|
||||
Map<String, Long> collect = list.stream().collect(Collectors.groupingBy(OperationsBean::getId, Collectors.counting()));
|
||||
List<Long> integerList = new ArrayList<>();
|
||||
collect.forEach((k,v) -> integerList.add(v));
|
||||
String fileName = "工程预付款统计";
|
||||
if(list.size()>0){
|
||||
fileName = "-" + list.get(0).getProjectName();
|
||||
}
|
||||
//记录用于合并的rowIndex
|
||||
ArrayList<HashMap<String, Integer>> mergeRows = new ArrayList<>();
|
||||
int startRowIndex = 3, start = 0;
|
||||
start = startRowIndex;
|
||||
int end = 0;
|
||||
for (int i = 0; i < integerList.size(); i++) {
|
||||
end = (int) (start + integerList.get(i)) - 1;
|
||||
if(end != start){
|
||||
HashMap<String, Integer> map = new HashMap<>();
|
||||
map.put("start", start);
|
||||
map.put("end", end);
|
||||
mergeRows.add(map);
|
||||
}
|
||||
start = end + 1;
|
||||
}
|
||||
// 导出标题
|
||||
ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getWriter(true);
|
||||
writer.merge(9, fileName,false);
|
||||
|
||||
// 合并二级表头
|
||||
writer.writeCellValue(0,1,"序号");
|
||||
writer.setColumnWidth(0, 8);
|
||||
writer.writeCellValue(1,1,"月份");
|
||||
writer.setColumnWidth(1, 25);
|
||||
writer.writeCellValue(2,1,"冲销或新增情况");
|
||||
writer.setColumnWidth(2, 35);
|
||||
writer.writeCellValue(3,1,"冲销或新增金额");
|
||||
writer.setColumnWidth(3, 20);
|
||||
writer.writeCellValue(4,1,"经办人");
|
||||
writer.setColumnWidth(4, 25);
|
||||
|
||||
writer.writeCellValue(5,1,"备注");
|
||||
writer.setColumnWidth(5, 55);
|
||||
writer.writeCellValue(6,1,"月度冲销计划及措施");
|
||||
writer.setColumnWidth(6, 25);
|
||||
writer.writeCellValue(7,1,"拟冲销金额");
|
||||
writer.setColumnWidth(7, 25);
|
||||
writer.writeCellValue(8,1,"责任人");
|
||||
writer.setColumnWidth(8, 25);
|
||||
writer.writeCellValue(9,1,"备注");
|
||||
writer.setColumnWidth(9, 55);
|
||||
|
||||
// 设置表头高度、单元格宽度
|
||||
writer.setRowHeight(0, 35);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
writer.writeCellValue(0, 2 + i, i + 1);
|
||||
writer.writeCellValue(1, 2 + i, list.get(i).getMonth()==null?"":list.get(i).getMonth());
|
||||
writer.writeCellValue(2, 2 + i, list.get(i).getOperationType()=="1"?"冲销":"新增");
|
||||
writer.writeCellValue(3, 2 + i, list.get(i).getAmount()==null?"":list.get(i).getAmount());
|
||||
writer.writeCellValue(4, 2 + i, list.get(i).getExecutor()==null?"":list.get(i).getExecutor());
|
||||
|
||||
writer.writeCellValue(5, 2 + i, list.get(i).getRemarks()==null?"":list.get(i).getRemarks());
|
||||
writer.writeCellValue(6, 2 + i, list.get(i).getNextMonth()==null?"":list.get(i).getNextMonth());
|
||||
writer.writeCellValue(7, 2 + i, list.get(i).getProposedAmount()==null?"":list.get(i).getProposedAmount());
|
||||
writer.writeCellValue(8, 2 + i, list.get(i).getHandler()==null?"":list.get(i).getHandler());
|
||||
writer.writeCellValue(9, 2 + i, list.get(i).getNextRemarks()==null?"":list.get(i).getNextRemarks());
|
||||
writer.setRowHeight(2 + i, 35);
|
||||
}
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
try {
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ServletOutputStream out = null;
|
||||
try {
|
||||
out = response.getOutputStream();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
writer.flush(out, true);
|
||||
writer.close();
|
||||
IoUtil.close(out);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,8 +172,10 @@
|
|||
bm.p_id as prepaymentId, bm.month, bm.operation_type as operationType,
|
||||
bm.amount, u2.username as executor, bm.remarks, bm.next_month as nextMonth,
|
||||
bm.proposed_amount as proposedAmount, bm.handler, bm.next_remarks as nextRemarks,
|
||||
u.username as operator, bm.created_time as createdTime, bm.updated_time as updatedTime
|
||||
u.username as operator, bm.created_time as createdTime, bm.updated_time as updatedTime
|
||||
,pro.project_name as projectName
|
||||
FROM `bm_monthly_operations` bm
|
||||
LEFT JOIN bm_project_prepayment pro ON pro.id = bm.p_id
|
||||
LEFT JOIN sys_user u ON u.id = bm.operator
|
||||
LEFT JOIN sys_user u2 ON u2.id = bm.executor
|
||||
WHERE bm.is_active = '1' AND bm.p_id = #{params.prepaymentId}
|
||||
|
|
|
|||
|
|
@ -183,4 +183,29 @@ function del(id) {
|
|||
|
||||
layer.close(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$("#exportBt").click(function () {
|
||||
var token = localStorage.getItem("token");
|
||||
var loadingMsg = layer.msg('下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
||||
var url = ctxPath + "/prepayment/expOperations?prepaymentId=" + prepaymentId + "&token=" + token;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("get", url, true);
|
||||
xhr.responseType = "blob"; // 转换流
|
||||
xhr.onload = function () {
|
||||
layer.close(loadingMsg);
|
||||
if (this.status === 200) {
|
||||
var blob = this.response;
|
||||
var a = document.createElement("a");
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
a.href = url;
|
||||
var projectName = document.getElementById('projectName').textContent
|
||||
a.download = "工程预付款统计-"+projectName+".xlsx"; // 文件名
|
||||
} else {
|
||||
layer.msg('导出发生异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
|
||||
}
|
||||
a.click()
|
||||
window.URL.revokeObjectURL(url)
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
|
|
@ -143,7 +143,7 @@ $("#searchBt").click(function () {
|
|||
$("#exportBt").click(function () {
|
||||
var token = localStorage.getItem("token");
|
||||
var loadingMsg = layer.msg('下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
||||
var url = ctxPath + "/supplierInfo/exp?state=" + $("#state").val().trim() + "&keyword=" + $("#keyword").val().trim() + "&token=" + token;
|
||||
var url = ctxPath + "/prepayment/expPrepayment?state=" + $("#state").val().trim() + "&keyword=" + $("#keyword").val().trim() + "&token=" + token;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("get", url, true);
|
||||
xhr.responseType = "blob"; // 转换流
|
||||
|
|
@ -154,7 +154,7 @@ $("#exportBt").click(function () {
|
|||
var a = document.createElement("a");
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
a.href = url;
|
||||
a.download = "供应商信息.xlsx"; // 文件名
|
||||
a.download = "工程预付款统计-列表.xlsx"; // 文件名
|
||||
} else {
|
||||
layer.msg('导出发生异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@
|
|||
<button class="layui-btn layui-btn-primary" onclick="updateForm()">
|
||||
修改
|
||||
</button>
|
||||
<button class="layui-btn layui-btn-primary">
|
||||
<button id="exportBt" class="layui-btn layui-btn-primary">
|
||||
导出
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue