结算申请(单个)详情,四项导出以及融合导出,提交结算

This commit is contained in:
hongchao 2025-01-16 09:26:20 +08:00
parent 8109f4b9d2
commit 4cf7c2e397
11 changed files with 1400 additions and 50 deletions

View File

@ -8,6 +8,7 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.RegionUtil;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -205,6 +206,193 @@ public class PoiOutPage {
return workbook;
}
public static HSSFWorkbook excelForcheckTwo(List<Map<String, Object>> result, List<String> list, String filename, String unit, String projectName, BigDecimal totalCost) {
// 创建工作簿和工作表
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
sheet.setDefaultColumnWidth(15); // 设置列宽
// 创建样式
HSSFCellStyle titleStyle = createTitleStyle(workbook);
HSSFCellStyle headerStyle = createHeaderStyle(workbook);
HSSFCellStyle contentStyle = createCellStyle(workbook);
// 设置工作簿名称
workbook.setSheetName(0, filename);
// 填充标题行
int rowNum = 0;
rowNum = createTitleRowStyle(sheet, rowNum, filename, titleStyle, list.size());
rowNum = createProjectAndUnitRow(sheet, rowNum, projectName, unit, titleStyle, list.size());
// 填充表头
rowNum = createHeaderRow(sheet, rowNum, list, headerStyle);
// 填充数据行
if (result != null && !result.isEmpty()) {
rowNum = createDataRows(sheet, rowNum, result, contentStyle, list.size());
} else {
// 如果没有数据则仅显示表头
rowNum++;
}
rowNum = createTotalRow(sheet, rowNum, list, totalCost, headerStyle);
return workbook;
}
public static HSSFWorkbook excelForcheckAll(List<Map<String, Object>> resultLease,List<Map<String, Object>> resultLose,List<Map<String, Object>> resultRepair,List<Map<String, Object>> resultScrap,
List<String> listLease,List<String> listLose,List<String> listRepair,List<String> listScrap, String filename, String unit, String projectName,
BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap) {
// 创建工作簿和工作表
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
sheet.setDefaultColumnWidth(15); // 设置列宽
// 创建样式
HSSFCellStyle titleStyle = createTitleStyle(workbook);
HSSFCellStyle headerStyle = createHeaderStyle(workbook);
HSSFCellStyle contentStyle = createCellStyle(workbook);
// 设置工作簿名称
workbook.setSheetName(0, filename);
// 填充标题行
int rowNum = 0;
rowNum = createTitleRowStyle(sheet, rowNum, filename, titleStyle, listLease.size());
rowNum = createProjectAndUnitRow(sheet, rowNum, projectName, unit, titleStyle, listLease.size());
/**
* 租赁费用明细
*/
rowNum = createTitleRowStyleCost(sheet, rowNum, "租赁费用明细", titleStyle, listLease.size());
// 填充表头
rowNum = createHeaderRow(sheet, rowNum, listLease, headerStyle);
// 填充数据行
if (resultLease != null && !resultLease.isEmpty()) {
rowNum = createDataRows(sheet, rowNum, resultLease, contentStyle, listLease.size());
} else {
// 如果没有数据则仅显示表头
rowNum++;
}
rowNum = createTotalRow(sheet, rowNum, listLease, totalCostLease, headerStyle);
/**
* 丢失费用明细
*/
// 填充标题行
rowNum = createTitleRowStyleCost(sheet, rowNum, "丢失费用明细", titleStyle, listLose.size());
// 填充表头
rowNum = createHeaderRow(sheet, rowNum, listLose, headerStyle);
// 填充数据行
if (resultLose!= null &&!resultLose.isEmpty()) {
rowNum = createDataRows(sheet, rowNum, resultLose, contentStyle, listLose.size());
} else {
// 如果没有数据则仅显示表头
rowNum++;
}
rowNum = createTotalRow(sheet, rowNum, listLose, totalCostLose, headerStyle);
/**
* 维修费用明细
*/
// 填充标题行
rowNum = createTitleRowStyleCost(sheet, rowNum, "维修费用明细", titleStyle, listRepair.size());
// 填充表头
rowNum = createHeaderRow(sheet, rowNum, listRepair, headerStyle);
// 填充数据行
if (resultRepair!= null &&!resultRepair.isEmpty()) {
rowNum = createDataRows(sheet, rowNum, resultRepair, contentStyle, listRepair.size());
} else {
// 如果没有数据则仅显示表头
rowNum++;
}
rowNum = createTotalRow(sheet, rowNum, listRepair, totalCostRepair, headerStyle);
/**
* 报废费用明细
*/
// 填充标题行
rowNum = createTitleRowStyleCost(sheet, rowNum, "报废费用明细", titleStyle, listScrap.size());
// 填充表头
rowNum = createHeaderRow(sheet, rowNum, listScrap, headerStyle);
// 填充数据行
if (resultScrap!= null &&!resultScrap.isEmpty()) {
rowNum = createDataRows(sheet, rowNum, resultScrap, contentStyle, listScrap.size());
} else {
// 如果没有数据则仅显示表头
rowNum++;
}
rowNum = createTotalRow(sheet, rowNum, listScrap, totalCostScrap, headerStyle);
//合计
BigDecimal totalCostAll = totalCostLease.add(totalCostLose).add(totalCostRepair).add(totalCostScrap);
rowNum = createTotalRowAll(sheet, rowNum, listScrap, totalCostAll, headerStyle);
return workbook;
}
/**
* 在数据的最后一行添加费用小计
*
* @param sheet 工作表
* @param rowNum 当前行号
* @param list 列名列表
* @param totalCost 总费用
* @param headerStyle 表头样式
*/
private static int createTotalRow(HSSFSheet sheet, int rowNum, List<String> list, BigDecimal totalCost, HSSFCellStyle headerStyle) {
HSSFRow row = sheet.createRow(rowNum++);
HSSFCell cell = row.createCell(0);
cell.setCellStyle(headerStyle);
cell.setCellValue("费用小计:");
sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, (short) (list.size() - 2)));
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 1, (short) (list.size() - 2));
// 设置边框样式
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet);
// 假设总费用应该放在最后一列
int totalCostColumnIndex = list.size() - 1;
cell = row.createCell(totalCostColumnIndex);
cell.setCellStyle(headerStyle);
cell.setCellValue(String.format("%.2f", totalCost));
return rowNum;
}
/**
* 在数据的最后一行添加合计费用
*
* @param sheet 工作表
* @param rowNum 当前行号
* @param list 列名列表
* @param totalCost 总费用
* @param headerStyle 表头样式
*/
private static int createTotalRowAll(HSSFSheet sheet, int rowNum, List<String> list, BigDecimal totalCost, HSSFCellStyle headerStyle) {
HSSFRow row = sheet.createRow(rowNum++);
HSSFCell cell = row.createCell(0);
cell.setCellStyle(headerStyle);
cell.setCellValue("合计:");
sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, (short) (list.size() - 2)));
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 1, (short) (list.size() - 2));
// 设置边框样式
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet);
// 假设总费用应该放在最后一列
int totalCostColumnIndex = list.size() - 1;
cell = row.createCell(totalCostColumnIndex);
cell.setCellStyle(headerStyle);
cell.setCellValue(String.format("%.2f", totalCost));
return rowNum;
}
/**
* 创建标题行
*/
@ -218,6 +406,107 @@ public class PoiOutPage {
return rowNum;
}
/**
* 创建标题行以及样式
*/
private static int createTitleRowStyle(HSSFSheet sheet, int rowNum, String filename, HSSFCellStyle titleStyle, int nColumn) {
HSSFRow row = sheet.createRow(rowNum++);
row.setHeightInPoints(30);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (short) (nColumn - 1)));
HSSFCell cell = row.createCell(0);
cell.setCellStyle(titleStyle);
cell.setCellValue(filename);
// 添加边框
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, rowNum - 1, (short) (nColumn - 1));
// 设置边框样式
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet);
return rowNum;
}
/**
* 创建标题行以及样式--all
*/
private static int createTitleRowStyleCost(HSSFSheet sheet, int rowNum, String filename, HSSFCellStyle titleStyle, int nColumn) {
HSSFRow row = sheet.createRow(rowNum++);
row.setHeightInPoints(30);
sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 0, (short) (nColumn - 1)));
HSSFCell cell = row.createCell(0);
cell.setCellStyle(titleStyle);
cell.setCellValue(filename);
// 添加边框
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (nColumn - 1));
// 设置边框样式
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange, sheet);
return rowNum;
}
/**
* 创建结算单位和结算工程行
*/
private static int createProjectAndUnitRow(HSSFSheet sheet, int rowNum, String projectName, String unitName,HSSFCellStyle titleStyle, int nColumn) {
// 第一行结算单位
HSSFRow row1 = sheet.createRow(rowNum++);
row1.setHeightInPoints(30);
// bug修复修改合并单元格区域确保包含两个或以上单元格
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 结算单位 占8
HSSFCell cell1 = row1.createCell(0);
cell1.setCellStyle(titleStyle);
cell1.setCellValue("结算单位:");
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1))); // unitName 占剩余的22
HSSFCell cell2 = row1.createCell(2);
cell2.setCellStyle(titleStyle);
cell2.setCellValue(unitName);
// 第二行结算工程
HSSFRow row2 = sheet.createRow(rowNum++);
row2.setHeightInPoints(30);
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 结算工程 占8
HSSFCell cell3 = row2.createCell(0);
cell3.setCellStyle(titleStyle);
cell3.setCellValue("结算工程:");
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1))); // projectName 占剩余的22
HSSFCell cell4 = row2.createCell(2);
cell4.setCellStyle(titleStyle);
cell4.setCellValue(projectName);
// 添加边框
CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 1);
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 2, rowNum - 2, 2, (short) (nColumn - 1));
CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1);
CellRangeAddress cellRange4 = new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1));
// 设置边框样式
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange1, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange1, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange1, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange1, sheet);
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange2, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange2, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange2, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange2, sheet);
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange3, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange3, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange3, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange3, sheet);
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange4, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange4, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange4, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange4, sheet);
return rowNum;
}
/**
* 创建项目名称和单位信息行
*/

View File

@ -1,13 +1,32 @@
package com.bonus.material.settlement.controller;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.convert.Convert;
import com.bonus.common.biz.config.PoiOutPage;
import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.lease.domain.vo.LeaseOutVo;
import com.bonus.material.settlement.domain.SltAgreementApply;
import com.bonus.material.settlement.domain.vo.SltInfoVo;
import com.bonus.material.settlement.domain.vo.SltLeaseInfo;
import com.bonus.material.settlement.mapper.SltAgreementInfoMapper;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.mapper.TmTaskMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -35,11 +54,18 @@ import com.bonus.common.core.web.page.TableDataInfo;
@Api(tags = "结算信息接口")
@RestController
@RequestMapping("/slt_agreement_info")
@Slf4j
public class SltAgreementInfoController extends BaseController {
@Autowired
private ISltAgreementInfoService sltAgreementInfoService;
@Autowired
private SltAgreementInfoMapper sltAgreementInfoMapper;
@Autowired
private TmTaskMapper taskMapper;
/**
* 查询结算信息列表
*/
@ -114,6 +140,430 @@ public class SltAgreementInfoController extends BaseController {
util.exportExcel(response, list, "结算信息数据");
}
/**
* 导出结算单
* @param response
* @param list
* @param filename
* @throws Exception
*/
private void expOutExcel(HttpServletResponse response, List<SltLeaseInfo> list, String filename,String projectName,String unitName,BigDecimal totalCost,int type)
throws Exception {
if (list != null) {
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
int size = list.size();
for (int i = 0; i < size; i++) {
SltLeaseInfo bean = list.get(i);
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean,type,0);
results.add(maps);
}
List<String> headers = receiveDetailsHeader(type,0);
HSSFWorkbook workbook = PoiOutPage.excelForcheckTwo(results, headers, filename,projectName,unitName,totalCost);
OutputStream out = null;
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.addHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls");
response.setHeader("Pragma", "No-cache");
out = response.getOutputStream();
workbook.write(out);
out.flush();
out.close();
}else{
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
List<String> headers = receiveDetailsHeader(type,0);
HSSFWorkbook workbook = PoiOutPage.excel(results, headers, filename);
OutputStream out = null;
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.addHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls");
response.setHeader("Pragma", "No-cache");
out = response.getOutputStream();
workbook.write(out);
out.flush();
out.close();
}
}
/**
* 导出结算单--all
* @throws Exception
*/
private void expOutExcelAll(HttpServletResponse response, List<SltLeaseInfo> lease,List<SltLeaseInfo> lose,List<SltLeaseInfo> repair,List<SltLeaseInfo> scrap,
String filename,String projectName,String unitName,BigDecimal totalCostLease,BigDecimal totalCostLose,BigDecimal totalCostRepair,BigDecimal totalCostScrap)
throws Exception {
List<Map<String, Object>> resultsLease = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> resultsLose = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> resultsRepair = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> resultsScrap = new ArrayList<Map<String, Object>>();
if (lease!= null) {
int sizeLease = lease.size();
for (int i = 0; i < sizeLease; i++) {
SltLeaseInfo bean = lease.get(i);
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean,1,1);
resultsLease.add(maps);
}
}
if (lose!= null) {
int sizeLose = lose.size();
for (int i = 0; i < sizeLose; i++) {
SltLeaseInfo bean = lose.get(i);
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean,2,1);
resultsLose.add(maps);
}
}
if (repair!= null) {
int sizeRepair = repair.size();
for (int i = 0; i < sizeRepair; i++) {
SltLeaseInfo bean = repair.get(i);
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean,3,1);
resultsRepair.add(maps);
}
}
if (scrap!= null) {
int sizeScrap = scrap.size();
for (int i = 0; i < sizeScrap; i++) {
SltLeaseInfo bean = scrap.get(i);
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean,4,1);
resultsScrap.add(maps);
}
}
List<String> headersLease = receiveDetailsHeader(1,1);
List<String> headersLose = receiveDetailsHeader(2,1);
List<String> headersRepair = receiveDetailsHeader(3,1);
List<String> headersScrap = receiveDetailsHeader(4,1);
HSSFWorkbook workbook = PoiOutPage.excelForcheckAll(resultsLease,resultsLose,resultsRepair,resultsScrap, headersLease,headersLose,headersRepair,headersScrap, filename,projectName,unitName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap);
OutputStream out = null;
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.addHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls");
response.setHeader("Pragma", "No-cache");
out = response.getOutputStream();
workbook.write(out);
out.flush();
out.close();
}
/**
* 租赁费用单数据转换
* @param bean
* @return
*/
private Map<String, Object> outReceiveDetailsBeanToMap(SltLeaseInfo bean,int type,int flag) {
// 创建一个SimpleDateFormat对象定义日期格式
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> maps = new LinkedHashMap<String, Object>();
if(type==1){
// maps.put("unitName", bean.getUnitName());
// maps.put("projectName", bean.getProjectName());
maps.put("typeName", bean.getTypeName());
maps.put("modelName", bean.getModelName());
maps.put("mtUnitName", bean.getMtUnitName());
maps.put("leasePrice", bean.getLeasePrice());
maps.put("num", bean.getNum());
maps.put("startTime", bean.getStartTime()==null ? null:dateFormat.format(bean.getStartTime()));
maps.put("endTime", bean.getEndTime()==null ? null:dateFormat.format(bean.getEndTime()));
maps.put("leaseDays", bean.getLeaseDays());
maps.put("costs", bean.getCosts().setScale(2, RoundingMode.HALF_UP));
}else if(type==2) {
if(flag==0){
maps.put("typeName", bean.getTypeName());
maps.put("modelName", bean.getModelName());
maps.put("mtUnitName", bean.getMtUnitName());
maps.put("num", bean.getNum());
maps.put("costs", bean.getCosts());
}else{
maps.put("typeName", bean.getTypeName());
maps.put("modelName", bean.getModelName());
maps.put("mtUnitName", bean.getMtUnitName());
maps.put("num", bean.getNum());
maps.put("costs", bean.getCosts());
maps.put("t1", "");
maps.put("t2", "");
maps.put("t3", "");
maps.put("t4", "");
}
}else if(type==3){
if(flag==0){
maps.put("typeName", bean.getTypeName());
maps.put("modelName", bean.getModelName());
maps.put("mtUnitName", bean.getMtUnitName());
maps.put("num", bean.getNum());
maps.put("partType", bean.getPartType());
maps.put("costs", bean.getCosts());
}else{
maps.put("typeName", bean.getTypeName());
maps.put("modelName", bean.getModelName());
maps.put("mtUnitName", bean.getMtUnitName());
maps.put("num", bean.getNum());
maps.put("partType", bean.getPartType());
maps.put("costs", bean.getCosts());
maps.put("t1", "");
maps.put("t2", "");
maps.put("t3", "");
}
}else if(type==4){
if(flag==0){
maps.put("typeName", bean.getTypeName());
maps.put("modelName", bean.getModelName());
maps.put("mtUnitName", bean.getMtUnitName());
maps.put("num", bean.getNum());
maps.put("partType", bean.getPartType());
maps.put("costs", bean.getCosts());
}else{
maps.put("typeName", bean.getTypeName());
maps.put("modelName", bean.getModelName());
maps.put("mtUnitName", bean.getMtUnitName());
maps.put("num", bean.getNum());
maps.put("partType", bean.getPartType());
maps.put("costs", bean.getCosts());
maps.put("t1", "");
maps.put("t2", "");
maps.put("t3", "");
maps.put("t4", "");
}
}
return maps;
}
/**
* 租赁费用单表头
* @return
*/
private List<String> receiveDetailsHeader(int type,int flag) {
ArrayList<String> list = new ArrayList<String>();
if(type==1){
// list.add("结算单位");
// list.add("结算工程");
list.add("设备名称");
list.add("规格型号");
list.add("计量单位");
list.add("租赁单价");
list.add("租赁数量");
list.add("租赁日期");
list.add("归还日期");
list.add("租赁天数");
list.add("租赁费用(元)");
}else if(type==2){
if(flag==0){
list.add("设备名称");
list.add("规格型号");
list.add("计量单位");
list.add("丢失数量");
list.add("丢失费用(元)");
}else{
list.add("设备名称");
list.add("规格型号");
list.add("计量单位");
list.add("丢失数量");
list.add("丢失费用(元)");
list.add(" ");
list.add(" ");
list.add(" ");
list.add(" ");
}
}else if(type==3){
if(flag==0){
list.add("设备名称");
list.add("规格型号");
list.add("计量单位");
list.add("维修数量");
list.add("是否收费");
list.add("维修费用(元)");
}else{
list.add("设备名称");
list.add("规格型号");
list.add("计量单位");
list.add("维修数量");
list.add("是否收费");
list.add("维修费用(元)");
list.add("");
list.add("");
list.add("");
}
}else if(type==4){
if(flag==0){
list.add("设备名称");
list.add("规格型号");
list.add("计量单位");
list.add("报废数量");
list.add("是否收费");
list.add("报废费用(元)");
}else{
list.add("设备名称");
list.add("规格型号");
list.add("计量单位");
list.add("报废数量");
list.add("是否收费");
list.add("报废费用(元)");
list.add("");
list.add("");
list.add("");
}
}
return list;
}
/**
* 导出租赁明细
*/
@ApiOperation(value = "导出结算信息列表")
@PreventRepeatSubmit
// @RequiresPermissions("settlement:info:export")
@SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出租赁明细")
@PostMapping("/exportLease")
public void exportLease(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) {
try {
String fileName = "租赁费用明细表";
String projectName = sltAgreementInfo.getProjectName();
String unitName = sltAgreementInfo.getUnitName();
BigDecimal totalCost = BigDecimal.valueOf(0.00);
List<SltAgreementInfo> leaseList = new ArrayList<>();
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseList(sltAgreementInfo);
leaseList.addAll(oneOfList);
for (SltAgreementInfo bean : leaseList) {
if (null == bean.getLeasePrice()) {
bean.setLeasePrice(BigDecimal.valueOf(0.00));
}else{
bean.setLeasePrice(bean.getLeasePrice().setScale(2, BigDecimal.ROUND_HALF_UP));
}
if (null == bean.getNum()) {
bean.setNum(BigDecimal.valueOf(0L));
}
if (null == bean.getLeaseDays()) {
bean.setLeaseDay(0L);
}
BigDecimal leasePrice = bean.getLeasePrice();
BigDecimal num = bean.getNum();
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, BigDecimal.ROUND_HALF_UP);
if(costs!=null){
totalCost = totalCost.add(costs);
}
bean.setCosts(costs);
}
List<SltLeaseInfo> lease = Convert.toList(SltLeaseInfo.class, leaseList);
expOutExcel(response,lease,fileName,projectName,unitName,totalCost,1);
} catch (Exception e) {
log.error(e.toString(), e);
}
}
/**
* 导出丢失费用明细
*/
@ApiOperation(value = "导出结算信息列表")
@PreventRepeatSubmit
// @RequiresPermissions("settlement:info:export")
@SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出丢失费用明细")
@PostMapping("/exportLose")
public void exportLose(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) {
try {
String fileName = "丢失费用明细表";
String projectName = sltAgreementInfo.getProjectName();
String unitName = sltAgreementInfo.getUnitName();
BigDecimal totalCost = BigDecimal.valueOf(0.00);
List<SltAgreementInfo> loseList = new ArrayList<>();
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLoseList(sltAgreementInfo);
loseList.addAll(oneOfList);
for (SltAgreementInfo bean : loseList) {
if (null == bean.getBuyPrice()) {
bean.setBuyPrice(BigDecimal.valueOf(0.00));
}
if (null == bean.getNum()) {
bean.setNum(BigDecimal.valueOf(0L));
}
BigDecimal buyPrice = bean.getBuyPrice();
BigDecimal num = bean.getNum();
// 原价 x 数量
BigDecimal costs = buyPrice.multiply(num);
if(costs!=null){
totalCost = totalCost.add(costs);
}
//计算租赁费用
bean.setCosts(costs);
}
List<SltLeaseInfo> lose = Convert.toList(SltLeaseInfo.class, loseList);
expOutExcel(response,lose,fileName,projectName,unitName,totalCost,2);
} catch (Exception e) {
log.error(e.toString(), e);
}
}
/**
* 导出维修费用明细
*/
@ApiOperation(value = "导出结算信息列表")
@PreventRepeatSubmit
// @RequiresPermissions("settlement:info:export")
@SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出维修费用明细")
@PostMapping("/exportRepair")
public void exportRepair(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) {
try {
String fileName = "维修费用明细表";
String projectName = sltAgreementInfo.getProjectName();
String unitName = sltAgreementInfo.getUnitName();
BigDecimal totalCost = BigDecimal.valueOf(0.00);
List<SltAgreementInfo> repairList = new ArrayList<>();
List<TmTask> taskList = taskMapper.getTaskIdList(sltAgreementInfo);
if (null != taskList && !taskList.isEmpty()) {
List<SltAgreementInfo> repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList);
repairList.addAll(repairDetailsList);
}
for (SltAgreementInfo bean : repairList) {
if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) {
totalCost = totalCost.add(bean.getCosts());
}
}
List<SltLeaseInfo> repair = Convert.toList(SltLeaseInfo.class, repairList);
expOutExcel(response,repair,fileName,projectName,unitName,totalCost,3);
} catch (Exception e) {
log.error(e.toString(), e);
}
}
/**
* 导出报废费用明细
*/
@ApiOperation(value = "导出结算信息列表")
@PreventRepeatSubmit
// @RequiresPermissions("settlement:info:export")
@SysLog(title = "报废信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出报废费用明细")
@PostMapping("/exportScrap")
public void exportScrap(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) {
try {
String fileName = "报废费用明细表";
String projectName = sltAgreementInfo.getProjectName();
String unitName = sltAgreementInfo.getUnitName();
BigDecimal totalCost = BigDecimal.valueOf(0.00);
List<SltAgreementInfo> scrapList = new ArrayList<>();
List<TmTask> taskList = taskMapper.getTaskIdList(sltAgreementInfo);
if (null != taskList && !taskList.isEmpty()) {
List<SltAgreementInfo> scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(taskList);
scrapList.addAll(scrapDetailsList);
}
for (SltAgreementInfo bean : scrapList) {
if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) {
totalCost = totalCost.add(bean.getCosts());
}
}
List<SltLeaseInfo> scrap = Convert.toList(SltLeaseInfo.class, scrapList);
expOutExcel(response,scrap,fileName,projectName,unitName,totalCost,4);
} catch (Exception e) {
log.error(e.toString(), e);
}
}
/**
* 获取结算信息详细信息
*/
@ -140,6 +590,107 @@ public class SltAgreementInfoController extends BaseController {
}
}
/**
* 导出结算信息列表--all
*/
@ApiOperation(value = "导出结算信息列表")
@PreventRepeatSubmit
// @RequiresPermissions("settlement:info:export")
@SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出租赁明细")
@PostMapping("/exportAll")
public void exportAll(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) {
try {
String fileName = "结算明细";
String projectName = sltAgreementInfo.getProjectName();
String unitName = sltAgreementInfo.getUnitName();
//租赁费用明细
BigDecimal totalCostLease = BigDecimal.valueOf(0.00);
List<SltAgreementInfo> leaseList = new ArrayList<>();
List<SltAgreementInfo> oneOfListLease = sltAgreementInfoMapper.getLeaseList(sltAgreementInfo);
leaseList.addAll(oneOfListLease);
for (SltAgreementInfo bean : leaseList) {
if (null == bean.getLeasePrice()) {
bean.setLeasePrice(BigDecimal.valueOf(0.00));
}
if (null == bean.getNum()) {
bean.setNum(BigDecimal.valueOf(0L));
}
if (null == bean.getLeaseDays()) {
bean.setLeaseDay(0L);
}
BigDecimal leasePrice = bean.getLeasePrice();
BigDecimal num = bean.getNum();
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
if(costs!=null){
totalCostLease = totalCostLease.add(costs);
}
bean.setCosts(costs);
}
List<SltLeaseInfo> lease = Convert.toList(SltLeaseInfo.class, leaseList);
//丢失费用明细
BigDecimal totalCostLose = BigDecimal.valueOf(0.00);
List<SltAgreementInfo> loseList = new ArrayList<>();
List<SltAgreementInfo> oneOfListLose = sltAgreementInfoMapper.getLoseList(sltAgreementInfo);
loseList.addAll(oneOfListLose);
for (SltAgreementInfo bean : loseList) {
if (null == bean.getBuyPrice()) {
bean.setBuyPrice(BigDecimal.valueOf(0.00));
}
if (null == bean.getNum()) {
bean.setNum(BigDecimal.valueOf(0L));
}
BigDecimal buyPrice = bean.getBuyPrice();
BigDecimal num = bean.getNum();
// 原价 x 数量
BigDecimal costs = buyPrice.multiply(num);
if(costs!=null){
totalCostLose = totalCostLose.add(costs);
}
//计算租赁费用
bean.setCosts(costs);
}
List<SltLeaseInfo> lose = Convert.toList(SltLeaseInfo.class, loseList);
//维修费用明细
BigDecimal totalCostRepair = BigDecimal.valueOf(0.00);
List<SltAgreementInfo> repairList = new ArrayList<>();
List<TmTask> taskListRepair = taskMapper.getTaskIdList(sltAgreementInfo);
if (null != taskListRepair && !taskListRepair.isEmpty()) {
List<SltAgreementInfo> repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskListRepair);
repairList.addAll(repairDetailsList);
}
for (SltAgreementInfo bean : repairList) {
if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) {
totalCostRepair = totalCostRepair.add(bean.getCosts());
}
}
List<SltLeaseInfo> repair = Convert.toList(SltLeaseInfo.class, repairList);
//报废费用明细
BigDecimal totalCostScrap = BigDecimal.valueOf(0.00);
List<SltAgreementInfo> scrapList = new ArrayList<>();
List<TmTask> taskListScrap = taskMapper.getTaskIdList(sltAgreementInfo);
if (null != taskListScrap && !taskListScrap.isEmpty()) {
List<SltAgreementInfo> scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(taskListScrap);
scrapList.addAll(scrapDetailsList);
}
for (SltAgreementInfo bean : scrapList) {
if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) {
totalCostScrap = totalCostScrap.add(bean.getCosts());
}
}
List<SltLeaseInfo> scrap = Convert.toList(SltLeaseInfo.class, scrapList);
expOutExcelAll(response,lease,lose,repair,scrap,fileName,projectName,unitName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap);
} catch (Exception e) {
log.error(e.toString(), e);
}
}
/**
* 修改结算信息
*/
@ -167,4 +718,15 @@ public class SltAgreementInfoController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(sltAgreementInfoService.deleteSltAgreementInfoByIds(ids));
}
@ApiOperation(value = "提交结算清单")
@PostMapping("/submitCosts")
public AjaxResult submitCosts(@RequestBody SltInfoVo sltInfoVo) {
try {
return toAjax(sltAgreementInfoService.submitCosts(sltInfoVo));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
}

View File

@ -169,6 +169,26 @@ public class SltAgreementInfo extends BaseEntity {
@ApiModelProperty(value = "结算状态")
private String sltStatus;
/**
* 维修类型
*/
private String repairType;
/**
* 是否收费
*/
private String partType;
/**
* 费用id
*/
private Long costId;
/**
* 维修状态
*/
private String repairStatus;
private String typeModelName;
private String maCode;

View File

@ -1,9 +1,14 @@
package com.bonus.material.settlement.domain.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.settlement.domain.SltAgreementRelation;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@ -12,6 +17,15 @@ import java.util.List;
*/
@Data
public class SltInfoVo {
/**
* 结算单位
*/
private String unitName;
/**
* 结算工程
*/
private String projectName;
/**
* 租赁费用列表
*/
@ -31,6 +45,62 @@ public class SltInfoVo {
List<SltAgreementRelation> relations;
/**
* 租赁费用小计
*/
@ApiModelProperty(value = "租赁费用小计")
private BigDecimal leaseCost;
/**
* 维修费用小计
*/
@ApiModelProperty(value = "维修费用小计")
private BigDecimal repairCost;
/**
* 报废费用小计
*/
@ApiModelProperty(value = "报废费用小计")
private BigDecimal scrapCost;
/**
* 丢失费用小计
*/
@ApiModelProperty(value = "丢失费用小计")
private BigDecimal loseCost;
/**
* 合计
*/
@ApiModelProperty(value = "合计")
private BigDecimal totalCostAll;
@Excel(name = "创建人")
private String createBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 协议id */
@ApiModelProperty(value = "协议id")
private Long agreementId;
/**
* 协议编号
*/
@ApiModelProperty(value = "协议编号")
private String agreementCode;
private Long id; //申请id
String cost;
}

View File

@ -0,0 +1,209 @@
package com.bonus.material.settlement.domain.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
import java.util.Date;
/**
* 结算信息对象 slt_agreement_info
*
* @author xsheng
* @date 2024-10-16
*/
@Data
@ToString
public class SltLeaseInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
/** 协议id */
@ApiModelProperty(value = "协议id")
private Long agreementId;
/**
* 协议编号
*/
@ApiModelProperty(value = "协议编号")
private String agreementCode;
/**
* 项目名称
*/
@Excel(name = "结算单位")
private String unitName;
/**
* 工程名称
*/
@Excel(name = "结算工程")
private String projectName;
/** 机具规格id */
@ApiModelProperty(value = "机具规格id")
private Long typeId;
/**
* 设备名称
*/
@Excel(name = "设备名称")
private String typeName;
/**
* 规格型号
*/
@Excel(name = "规格型号")
private String modelName;
/**
* 计量单位
*/
@Excel(name = "计量单位")
private String mtUnitName;
/** 租赁单价 */
@Excel(name = "租赁单价")
@ApiModelProperty(value = "租赁单价")
private BigDecimal leasePrice;
/** 租赁数量 */
@Excel(name = "租赁数量")
@ApiModelProperty(value = "领料数量")
private BigDecimal num;
/** 领料时间 */
@ApiModelProperty(value = "租赁日期")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "租赁日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date startTime;
/** 退料时间 */
@ApiModelProperty(value = "归还日期")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "归还日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date endTime;
/**
* 租赁天数
*/
@Excel(name = "租赁天数")
private String leaseDays;
/**
* 租赁费用
*/
@Excel(name = "租赁费用")
@ApiModelProperty(value = "租赁费用")
private BigDecimal costs;
/** 机具id */
@ApiModelProperty(value = "机具id")
private Long maId;
private Integer backNum;
/** 0在用1退回 */
@ApiModelProperty(value = "0在用1退回")
private String status;
/** 领料id */
@ApiModelProperty(value = "领料id")
private Long leaseId;
/** 退料id */
@ApiModelProperty(value = "退料id")
private Long backId;
/** 原值 */
@ApiModelProperty(value = "原值")
private BigDecimal buyPrice;
/** 是否结算 */
@ApiModelProperty(value = "是否结算")
private String isSlt;
/** 结算时间 */
@ApiModelProperty(value = "结算时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date sltTime;
/** $column.columnComment */
private Long companyId;
/** 领用类型0工程1长期 */
private String leaseType;
/** 调整天数 */
@ApiModelProperty(value = "调整天数")
private Long trimDay;
/**
* 租赁天数
*/
@ApiModelProperty(value = "租赁天数")
private Long leaseDay;
@ApiModelProperty(value = "往来单位id")
private Long unitId;
/**
* 工程标段ID
*/
@ApiModelProperty(value = "工程标段ID")
private Long projectId;
@ApiModelProperty(value = "结算状态")
private String sltStatus;
/**
* 维修类型
*/
private String repairType;
/**
* 是否收费
*/
private String partType;
/**
* 费用id
*/
private Long costId;
/**
* 维修状态
*/
private String repairStatus;
private String typeModelName;
private String maCode;
private Double useNum;
private String keyWord;
}

View File

@ -7,6 +7,7 @@ import com.bonus.material.ma.domain.Type;
import com.bonus.material.settlement.domain.SltAgreementApply;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.settlement.domain.SltAgreementRelation;
import com.bonus.material.settlement.domain.vo.SltInfoVo;
import com.bonus.material.task.domain.TmTask;
import org.apache.ibatis.annotations.Param;
@ -104,4 +105,52 @@ public interface SltAgreementInfoMapper {
* @return
*/
int deleteSltInfo(@Param("record") LeaseOutDetails leaseOutDetails);
/**
* 新增结算审核信息
*
* @param sltInfoVo 结算信息
* @return 结果
*/
public int insertSltAgreementApply(SltInfoVo sltInfoVo);
/**
* 修改结算审核信息
*
* @param sltInfoVo 结算信息
* @return 结果
*/
public int updateBmAgreementStatus(SltInfoVo sltInfoVo);
/**
* 新增租赁结算明细
* @param list
* @param id
* @return
*/
int insertSltAgreementDetailLease(@Param("list") List<SltAgreementInfo> list,@Param("id") Long id);
/**
* 新增维修结算明细
* @param list
* @param id
* @return
*/
int insertSltAgreementDetailRepair(@Param("list") List<SltAgreementInfo> list,@Param("id") Long id);
/**
* 新增报废结算明细
* @param list
* @param id
* @return
*/
int insertSltAgreementDetailScrap(@Param("list") List<SltAgreementInfo> list,@Param("id") Long id);
/**
* 新增丢失结算明细
* @param list
* @param id
* @return
*/
int insertSltAgreementDetailLose(@Param("list") List<SltAgreementInfo> list,@Param("id") Long id);
}

View File

@ -70,4 +70,13 @@ public interface ISltAgreementInfoService {
* @return 结果
*/
public int deleteSltAgreementInfoById(Long id);
/**
* 提交结算信息
*
* @param sltInfoVo 结算信息
* @return 结果
*/
public int submitCosts(SltInfoVo sltInfoVo);
}

View File

@ -66,6 +66,12 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
@Override
public SltInfoVo getSltInfo(List<SltAgreementInfo> list) {
SltInfoVo sltInfoVo = new SltInfoVo();
sltInfoVo.setUnitName(list.get(0).getUnitName());
sltInfoVo.setProjectName(list.get(0).getProjectName());
BigDecimal leaseCost = BigDecimal.valueOf(0.00);
BigDecimal repairCost = BigDecimal.valueOf(0.00);
BigDecimal scrapCost = BigDecimal.valueOf(0.00);
BigDecimal loseCost = BigDecimal.valueOf(0.00);
//租赁费用列表
List<SltAgreementInfo> leaseList = getLeaseList(list);
//维修费用列表
@ -78,6 +84,31 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
sltInfoVo.setRepairList(repairList);
sltInfoVo.setScrapList(scrapList);
sltInfoVo.setLoseList(loseList);
for (SltAgreementInfo lease : leaseList) {
if(lease.getCosts()!=null){
leaseCost = leaseCost.add(lease.getCosts());
}
}
for (SltAgreementInfo repair : repairList) {
if(repair.getCosts()!=null && (repair.getPartType().equals("收费"))){
repairCost = repairCost.add(repair.getCosts());
}
}
for (SltAgreementInfo scrap : scrapList) {
if(scrap.getCosts()!=null && (scrap.getPartType().equals("收费"))){
scrapCost = scrapCost.add(scrap.getCosts());
}
}
for (SltAgreementInfo lose : loseList) {
if(lose.getCosts()!=null){
loseCost = loseCost.add(lose.getCosts());
}
}
sltInfoVo.setLeaseCost(leaseCost);
sltInfoVo.setRepairCost(repairCost);
sltInfoVo.setScrapCost(scrapCost);
sltInfoVo.setLoseCost(loseCost);
List<SltAgreementRelation> relations = getRelations(leaseList, repairList, scrapList, loseList, list);
sltInfoVo.setRelations(relations);
return sltInfoVo;
@ -212,17 +243,19 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
for (SltAgreementInfo bean : leaseList) {
if (null == bean.getLeasePrice()) {
bean.setLeasePrice(BigDecimal.valueOf(0.00));
}else{
bean.setLeasePrice(bean.getLeasePrice().setScale(2, BigDecimal.ROUND_HALF_UP));
}
if (null == bean.getNum()) {
bean.setNum(BigDecimal.valueOf(0L));
}
if (null == bean.getLeaseDay()) {
if (null == bean.getLeaseDays()) {
bean.setLeaseDay(0L);
}
BigDecimal leasePrice = bean.getLeasePrice();
BigDecimal num = bean.getNum();
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDay());
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, BigDecimal.ROUND_HALF_UP);
bean.setCosts(costs);
}
return leaseList;
@ -230,10 +263,17 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
public List<SltAgreementInfo> getRepairList(List<SltAgreementInfo> list) {
List<SltAgreementInfo> repairList = new ArrayList<>();
Integer taskType = TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId();
for (SltAgreementInfo bean : list) {
List<TmTask> taskList = taskMapper.getTaskList(bean, taskType);
if (null != taskList && !taskList.isEmpty()) {
// Integer taskType = TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId();
// for (SltAgreementInfo bean : list) {
// List<TmTask> taskList = taskMapper.getTaskList(bean, taskType);
// if (null != taskList && !taskList.isEmpty()) {
// List<SltAgreementInfo> repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList);
// repairList.addAll(repairDetailsList);
// }
// }
for(SltAgreementInfo bean : list){
List<TmTask> taskList = taskMapper.getTaskIdList(bean);
if (null!= taskList &&!taskList.isEmpty()) {
List<SltAgreementInfo> repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList);
repairList.addAll(repairDetailsList);
}
@ -243,29 +283,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
public List<SltAgreementInfo> getScrapList(List<SltAgreementInfo> list) {
List<SltAgreementInfo> scrapList = new ArrayList<>();
Integer taskType = TmTaskTypeEnum.TM_TASK_SCRAP.getTaskTypeId();
for (SltAgreementInfo bean : list) {
List<TmTask> taskList = taskMapper.getTaskList(bean, taskType);
List<TmTask> taskList = taskMapper.getTaskIdList(bean);
if (null != taskList && !taskList.isEmpty()) {
List<SltAgreementInfo> scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(taskList);
scrapList.addAll(scrapDetailsList);
}
}
if (!scrapList.isEmpty()) {
for (SltAgreementInfo bean : scrapList) {
if (null == bean.getBuyPrice()) {
bean.setBuyPrice(BigDecimal.valueOf(0.00));
}
if (null == bean.getNum()) {
bean.setNum(BigDecimal.valueOf(0L));
}
BigDecimal buyPrice = bean.getBuyPrice();
BigDecimal num = bean.getNum();
BigDecimal costs = buyPrice.multiply(num);
//计算总金额
bean.setCosts(costs);
}
}
return scrapList;
}
@ -343,4 +367,35 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
}
return relations;
}
/**
* 提交结算信息
*
* @param sltInfoVo 结算信息
* @return 结果
*/
@Override
public int submitCosts(SltInfoVo sltInfoVo) {
sltInfoVo.setCreateTime(DateUtils.getNowDate());
sltInfoVo.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
try {
int countOne = sltAgreementInfoMapper.insertSltAgreementApply(sltInfoVo);
if(countOne!=1){
throw new ServiceException("slt_agreement_apply新增失败");
}
// 插入成功后sltInfoVo id 属性将被自动设置为新生成的主键值
Long newId = sltInfoVo.getId();
int countTwo = sltAgreementInfoMapper.updateBmAgreementStatus(sltInfoVo);
if(countTwo!=1){
throw new ServiceException("bm_agreement_info修改失败");
}
sltAgreementInfoMapper.insertSltAgreementDetailLease(sltInfoVo.getLeaseList(),newId);
sltAgreementInfoMapper.insertSltAgreementDetailRepair(sltInfoVo.getRepairList(),newId);
sltAgreementInfoMapper.insertSltAgreementDetailScrap(sltInfoVo.getScrapList(),newId);
return sltAgreementInfoMapper.insertSltAgreementDetailLose(sltInfoVo.getLoseList(),newId);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
}
}
}

View File

@ -90,4 +90,6 @@ public interface TmTaskMapper {
List<TmTask> getTaskList(@Param("bean") SltAgreementInfo bean, @Param("taskType")Integer taskType);
List<TmTask> getTaskIdList(SltAgreementInfo bean);
}

View File

@ -176,8 +176,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getSltAgreementInfo4Project" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT bai.agreement_id, bai.agreement_code, contract_code,file_url ,file_name,sign_time,
bui.unit_id,bui.unit_name , bp.pro_id as projectId , bp.pro_name as projectName,
SELECT bai.agreement_id as agreementId, bai.agreement_code as agreementCode, contract_code,file_url ,file_name,sign_time,
bui.unit_id as unitId,bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName,
plan_start_time,lease_day,auth_person,phone,saa.remark,bai.protocol,sar.cost as cost,sar.is_commit as isCommit,
case when sar.id is null then '1' when sar.status = '0' then '2' when sar.status = '1' then '3' when sar.status = '2' then '4' end as sltStatus
FROM bm_agreement_info bai
@ -276,6 +276,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select tta.agreement_id as agreementId,
bui.unit_name as unitName,
bp.pro_name as projectName,
rc.id as costId,
rc.type_id as typeId,
rc.ma_id as maId,
mt1.type_name as typeName,
@ -283,8 +284,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.unit_name as mtUnitName,
rc.repair_num as num,
rc.costs as costs,
case rc.repair_type when '1' then '内部维修' when '2' then '返厂维修' else '' end as partType,
rc.company_id as companyId
case rc.part_type when '0' then '不收费' when '1' then '收费' else '' end as partType,
case rc.repair_type when '1' then '内部维修' when '2' then '返厂维修' else '' end as repairType,
rc.company_id as companyId,
case rc.status when '0' then '未审核' when '1' then '已审核' when '2' then '已驳回' else '' end as repairStatus
from repair_cost rc
LEFT JOIN tm_task_agreement tta on rc.task_id = tta.task_id
LEFT JOIN tm_task tt on rc.task_id = tt.task_id
@ -293,7 +296,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
left join ma_type mt on rc.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where rc.status in ('0','1')
where rc.status in ('0','1') and rc.repair_type in ('1','2')
<if test="taskList != null and taskList.size() > 0">
and rc.task_id in
<foreach item="task" collection="taskList" open="(" separator="," close=")">
@ -304,32 +307,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getScrapDetailsList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
select tta.agreement_id as agreementId,
bui.unit_name as unitName,
bp.pro_name as projectName,
sad.type_id as typeId,
sad.ma_id as maId,
mt1.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as mtUnitName,
sum(sad.scrap_num) as num,
mt.buy_price as buyPrice,
case sad.scrap_type when '0' then '自然' when '1' then '人为' else '' end as scrapType,
sad.company_id as companyId
from scrap_apply_details sad
left join tm_task_agreement tta on sad.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai on tta.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
left join ma_type mt on sad.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where sad.status in ('0','1')
bui.unit_name as unitName,
bp.pro_name as projectName,
rc.id as costId,
rc.type_id as typeId,
rc.ma_id as maId,
mt1.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as mtUnitName,
rc.repair_num as num,
rc.costs as costs,
case rc.part_type when '0' then '不收费' when '1' then '收费' else '' end as partType,
case rc.repair_type when '1' then '内部维修' when '2' then '返厂维修' else '' end as repairType,
rc.company_id as companyId,
case rc.status when '0' then '未审核' when '1' then '已审核' when '2' then '已驳回' else '' end as repairStatus
from repair_cost rc
LEFT JOIN tm_task_agreement tta on rc.task_id = tta.task_id
LEFT JOIN tm_task tt on rc.task_id = tt.task_id
LEFT JOIN bm_agreement_info bai on tta.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
left join ma_type mt on rc.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where rc.status in ('0','1') and rc.repair_type = '3'
<if test="taskList != null and taskList.size() > 0">
and sad.task_id in
and rc.task_id in
<foreach item="task" collection="taskList" open="(" separator="," close=")">
#{task.taskId}
</foreach>
</if>
group by sad.type_id,sad.ma_id,sad.scrap_type
</select>
<select id="getLoseList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
@ -415,4 +421,77 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where
bai.task_id = #{backTaskId} and sai.status = '1'
</update>
<insert id="insertSltAgreementApply" parameterType="com.bonus.material.settlement.domain.vo.SltInfoVo" useGeneratedKeys="true" keyProperty="id">
insert into slt_agreement_apply
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="agreementId != null">agreement_id,</if>
<if test="agreementCode != null">code,</if>
<if test="createBy != null">creator,</if>
<if test="createTime != null">create_time,</if>
status,
<if test="totalCostAll != null">cost,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="agreementId != null">#{agreementId},</if>
<if test="agreementCode != null">#{agreementCode},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
0,
<if test="totalCostAll != null">#{totalCostAll},</if>
</trim>
</insert>
<update id="updateBmAgreementStatus">
update
bm_agreement_info bai
set
bai.is_slt = 1, bai.update_by = #{createBy}, bai.update_time = #{createTime}
where
bai.agreement_id = #{agreementId}
</update>
<!-- 循环插入lease -->
<insert id="insertSltAgreementDetailLease" parameterType="com.bonus.material.settlement.domain.SltAgreementInfo">
insert into slt_agreement_details (apply_id, type_id,ma_id,slt_type,unit_name,num,start_time,end_time,price,money)
values
<foreach collection="list" item="item" separator=",">
(#{id}, #{item.typeId}, #{item.maId},1, #{item.mtUnitName},#{item.num},#{item.startTime},#{item.endTime},#{item.leasePrice},#{item.costs})
</foreach>
</insert>
<!-- 循环插入repair -->
<insert id="insertSltAgreementDetailRepair" parameterType="com.bonus.material.settlement.domain.SltAgreementInfo">
insert into slt_agreement_details (apply_id, type_id,ma_id,slt_type,unit_name,num,money,is_charge)
values
<foreach collection="list" item="item" separator=",">
(#{id}, #{item.typeId}, #{item.maId},3, #{item.mtUnitName},#{item.num},#{item.costs},
<choose>
<when test="item.partType == '收费'">1</when>
<otherwise>0</otherwise>
</choose>)
</foreach>
</insert>
<!-- 循环插入scrap -->
<insert id="insertSltAgreementDetailScrap" parameterType="com.bonus.material.settlement.domain.SltAgreementInfo">
insert into slt_agreement_details (apply_id, type_id,ma_id,slt_type,unit_name,num,money,is_charge)
values
<foreach collection="list" item="item" separator=",">
(#{id}, #{item.typeId}, #{item.maId},4, #{item.mtUnitName},#{item.num},#{item.costs},
<choose>
<when test="item.partType == '收费'">1</when>
<otherwise>0</otherwise>
</choose>)
</foreach>
</insert>
<!-- 循环插入lose -->
<insert id="insertSltAgreementDetailLose" parameterType="com.bonus.material.settlement.domain.SltAgreementInfo">
insert into slt_agreement_details (apply_id, type_id,ma_id,slt_type,unit_name,num,money)
values
<foreach collection="list" item="item" separator=",">
(#{id}, #{item.typeId}, #{item.maId},2, #{item.mtUnitName},#{item.num},#{item.costs})
</foreach>
</insert>
</mapper>

View File

@ -139,4 +139,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join tm_task tt on tta.task_id = tt.task_id
where tta.agreement_id = #{bean.agreementId} and tt.task_type = #{taskType}
</select>
<select id="getTaskIdList" resultType="com.bonus.material.task.domain.TmTask">
select tta.task_id as taskId
from tm_task_agreement tta
where tta.agreement_id = #{agreementId}
</select>
</mapper>