结算修改
This commit is contained in:
parent
5b686df136
commit
37a4600263
|
|
@ -250,6 +250,51 @@ public class PoiOutPage {
|
|||
return workbook;
|
||||
}
|
||||
|
||||
public static HSSFWorkbook excelForcheckClz(List<Map<String, Object>> result, List<String> list, String filename, String projectName, String unit, String actualTimeAndName, 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 = createProjectAndUnitRowClz(sheet, rowNum, projectName, unit,actualTimeAndName, 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 = createDataRows(sheet, rowNum, result, contentStyle, list.size());
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellStyle(headerStyle);
|
||||
cell.setCellValue("暂无数据");
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (list.size() - 1)));
|
||||
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (list.size() - 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);
|
||||
}
|
||||
rowNum = createTotalRow(sheet, rowNum, list, totalCost, headerStyle);
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static HSSFWorkbook excelForcheckLeaseOut(List<Map<String, Object>> result, List<String> list, String filename) {
|
||||
// 创建工作簿和工作表
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
|
|
@ -455,6 +500,175 @@ public class PoiOutPage {
|
|||
return workbook;
|
||||
}
|
||||
|
||||
public static HSSFWorkbook excelForcheckAllClz(List<Map<String, Object>> resultLease,List<Map<String, Object>> resultLose,List<Map<String, Object>> resultRepair,List<Map<String, Object>> resultScrap,List<Map<String, Object>> resultsReduction,
|
||||
List<String> listLease,List<String> listLose,List<String> listRepair,List<String> listScrap,List<String> listReduction, String filename, String projectName, String unit,String actualTimeAndName,
|
||||
BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap,BigDecimal totalCostReduction) {
|
||||
// 创建工作簿和工作表
|
||||
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 = createProjectAndUnitRowClz(sheet, rowNum, projectName, unit,actualTimeAndName, 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 = createDataRows(sheet, rowNum, resultLease, contentStyle, listLease.size());
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellStyle(headerStyle);
|
||||
cell.setCellValue("暂无数据");
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listLease.size() - 1)));
|
||||
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listLease.size() - 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);
|
||||
}
|
||||
rowNum = createTotalRow(sheet, rowNum, listLease, totalCostLease, 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 = createDataRows(sheet, rowNum, resultRepair, contentStyle, listRepair.size());
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellStyle(headerStyle);
|
||||
cell.setCellValue("暂无数据");
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listRepair.size() - 1)));
|
||||
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listRepair.size() - 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);
|
||||
}
|
||||
rowNum = createTotalRow(sheet, rowNum, listRepair, totalCostRepair, 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 = createDataRows(sheet, rowNum, resultLose, contentStyle, listLose.size());
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellStyle(headerStyle);
|
||||
cell.setCellValue("暂无数据");
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listLose.size() - 1)));
|
||||
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listLose.size() - 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);
|
||||
}
|
||||
rowNum = createTotalRow(sheet, rowNum, listLose, totalCostLose, 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 = createDataRows(sheet, rowNum, resultScrap, contentStyle, listScrap.size());
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellStyle(headerStyle);
|
||||
cell.setCellValue("暂无数据");
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listScrap.size() - 1)));
|
||||
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listScrap.size() - 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);
|
||||
}
|
||||
rowNum = createTotalRow(sheet, rowNum, listScrap, totalCostScrap, headerStyle);
|
||||
|
||||
/**
|
||||
* 减免费用明细
|
||||
*/
|
||||
// 填充标题行
|
||||
rowNum = createTitleRowStyleCost(sheet, rowNum, "减免费用明细", titleStyle, listReduction.size());
|
||||
// 填充表头
|
||||
rowNum = createHeaderRow(sheet, rowNum, listReduction, headerStyle);
|
||||
// 填充数据行
|
||||
if (resultsReduction != null && !resultsReduction.isEmpty()) {
|
||||
rowNum = createDataRows(sheet, rowNum, resultsReduction, contentStyle, listReduction.size());
|
||||
} else {
|
||||
// 如果没有数据,则仅显示表头
|
||||
// rowNum++;
|
||||
// rowNum = createDataRows(sheet, rowNum, resultLease, contentStyle, listLease.size());
|
||||
HSSFRow row = sheet.createRow(rowNum++);
|
||||
HSSFCell cell = row.createCell(0);
|
||||
cell.setCellStyle(headerStyle);
|
||||
cell.setCellValue("暂无数据");
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listReduction.size() - 1)));
|
||||
CellRangeAddress cellRange = new CellRangeAddress(rowNum - 1, rowNum - 1, 0, (short) (listReduction.size() - 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);
|
||||
}
|
||||
rowNum = createTotalRow(sheet, rowNum, listReduction, totalCostReduction, headerStyle);
|
||||
|
||||
|
||||
//合计
|
||||
BigDecimal totalCostAll = totalCostLease.add(totalCostLose).add(totalCostRepair).add(totalCostScrap).add(totalCostReduction);
|
||||
rowNum = createTotalRowAll(sheet, rowNum, listScrap, totalCostAll, headerStyle);
|
||||
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static void excelForcheckEach(HSSFWorkbook workbook,HSSFSheet sheet,List<Map<String, Object>> resultLease,List<Map<String, Object>> resultLose,List<Map<String, Object>> resultRepair,List<Map<String, Object>> resultScrap,List<Map<String, Object>> resultsReduction,
|
||||
List<String> listLease,List<String> listLose,List<String> listRepair,List<String> listScrap,List<String> listReduction, String projectName, String unit,
|
||||
BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap,BigDecimal totalCostReduction) {
|
||||
|
|
@ -975,6 +1189,88 @@ public class PoiOutPage {
|
|||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange4, sheet);
|
||||
|
||||
|
||||
return rowNum;
|
||||
}
|
||||
|
||||
private static int createProjectAndUnitRowClz(HSSFSheet sheet, int rowNum, String projectName, String unitName,String actualTimeAndName,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);
|
||||
|
||||
// 第二行:结算工程
|
||||
HSSFRow row3 = sheet.createRow(rowNum++);
|
||||
row3.setHeightInPoints(30);
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 结算工程: 占8
|
||||
HSSFCell cell5 = row3.createCell(0);
|
||||
cell5.setCellStyle(titleStyle);
|
||||
cell5.setCellValue("出场时间:");
|
||||
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 1)));
|
||||
HSSFCell cell6 = row3.createCell(2);
|
||||
cell6.setCellStyle(titleStyle);
|
||||
cell6.setCellValue(actualTimeAndName);
|
||||
|
||||
|
||||
|
||||
// 添加边框
|
||||
CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 3, rowNum - 3, 0, 1);
|
||||
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 3, rowNum - 3, 2, (short) (nColumn - 1));
|
||||
CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 1);
|
||||
CellRangeAddress cellRange4 = new CellRangeAddress(rowNum - 2, rowNum - 2, 2, (short) (nColumn - 1));
|
||||
CellRangeAddress cellRange5 = new CellRangeAddress(rowNum - 1 ,rowNum - 1 , 0, 1);
|
||||
CellRangeAddress cellRange6 = 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);
|
||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange5, sheet);
|
||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange5, sheet);
|
||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange5, sheet);
|
||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange5, sheet);
|
||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange6, sheet);
|
||||
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRange6, sheet);
|
||||
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRange6, sheet);
|
||||
RegionUtil.setBorderRight(BorderStyle.THIN, cellRange6, sheet);
|
||||
|
||||
|
||||
|
||||
return rowNum;
|
||||
}
|
||||
|
||||
|
|
@ -1255,4 +1551,6 @@ public class PoiOutPage {
|
|||
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,49 @@
|
|||
package com.bonus.material.clz.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.bonus.common.biz.config.PoiOutPage;
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.material.basic.domain.BmProject;
|
||||
import com.bonus.material.clz.domain.ClzSltApplyDTO;
|
||||
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
|
||||
import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo;
|
||||
import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo;
|
||||
import com.bonus.material.clz.mapper.ClzSltAgreementInfoMapper;
|
||||
import com.bonus.material.clz.service.ClzSltAgreementInfoService;
|
||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||
import com.bonus.material.common.domain.dto.SelectDto;
|
||||
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||
import com.bonus.material.settlement.domain.SltAgreementApply;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||
import com.bonus.material.settlement.domain.SltAgreementRelation;
|
||||
import com.bonus.material.settlement.domain.vo.SltLeaseInfo;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Api(tags = "材料站结算申请接口")
|
||||
@RestController
|
||||
|
|
@ -31,6 +54,35 @@ public class ClzSltAgreementInfoController extends BaseController {
|
|||
@Resource
|
||||
private ClzSltAgreementInfoService clzSltAgreementInfoService;
|
||||
|
||||
@Resource
|
||||
private ClzSltAgreementInfoMapper clzSltAgreementInfoMapper;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取材料站结算申请工程下拉选
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取材料站结算申请工程下拉选")
|
||||
@GetMapping("/getClzProjectList")
|
||||
public AjaxResult getClzProjectList(MaterialRetainedEquipmentInfo bean) {
|
||||
List<MaterialRetainedEquipmentInfo> list = clzSltAgreementInfoService.getClzProjectList(bean);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取材料站结算申请班组下拉选
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取材料站结算申请班组下拉选")
|
||||
@GetMapping("/getClzTeamList")
|
||||
public AjaxResult getClzTeamList(MaterialSltAgreementInfo bean) {
|
||||
List<MaterialSltAgreementInfo> list = clzSltAgreementInfoService.getClzTeamList(bean);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询协议结算列表
|
||||
*/
|
||||
|
|
@ -86,6 +138,779 @@ public class ClzSltAgreementInfoController extends BaseController {
|
|||
return AjaxResult.success(resultList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出租赁明细
|
||||
*/
|
||||
@ApiOperation(value = "导出材料站结算信息列表")
|
||||
@PreventRepeatSubmit
|
||||
@SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "结算管理->导出材料站租赁明细")
|
||||
@PostMapping("/exportLease")
|
||||
public void exportLease(HttpServletResponse response, @RequestParam("params") String params) {
|
||||
try {
|
||||
// 1. 修正:先将 params 解析为 JSON 对象(而非数组)
|
||||
JSONObject paramObj = JSONObject.parseObject(params);
|
||||
|
||||
// 2. 根据实际需求从 JSON 对象中提取数据(示例:提取 unitIds 和 projectId)
|
||||
List<Integer> unitIds = paramObj.getJSONArray("unitIds").toJavaList(Integer.class);
|
||||
Long projectId = paramObj.getLong("projectId");
|
||||
List<MaterialSltAgreementInfo> leaseListAll = new ArrayList<>();
|
||||
BigDecimal totalCost = BigDecimal.valueOf(0.00);
|
||||
List<String> projectNames = new ArrayList<>();
|
||||
List<String> unitNames = new ArrayList<>();
|
||||
List<String> actualTimeAndNames = new ArrayList<>();
|
||||
|
||||
// 查询协议号
|
||||
List<AgreementVo> agreementInfos = clzSltAgreementInfoMapper.getAgreementInfoById(unitIds, Math.toIntExact(projectId));
|
||||
// 过滤异常数据
|
||||
agreementInfos.removeIf(Objects::isNull);
|
||||
|
||||
// 查询每个协议的待结算明细
|
||||
if (CollectionUtils.isNotEmpty(agreementInfos)) {
|
||||
for (AgreementVo agreementInfo : agreementInfos) {
|
||||
// 数据检查
|
||||
if (agreementInfo.getAgreementId() == null || agreementInfo.getAgreementId() <= 0) {
|
||||
throw new ServiceException("协议ID为空,请反馈至管理员!");
|
||||
}
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(agreementInfo.getAgreementCode())) {
|
||||
throw new ServiceException("协议号为空,请检查!");
|
||||
}
|
||||
|
||||
// 进行Bean的类型转换,使其适配Mapper
|
||||
MaterialSltAgreementInfo sltAgreementInfo = new MaterialSltAgreementInfo();
|
||||
BeanUtil.copyProperties(agreementInfo, sltAgreementInfo, true);
|
||||
|
||||
List<MaterialSltAgreementInfo> oneOfList = clzSltAgreementInfoMapper.getLeaseList(sltAgreementInfo);
|
||||
//设定班组实际出场时间
|
||||
if(!oneOfList.isEmpty()){
|
||||
String date = clzSltAgreementInfoMapper.getTeamOutTime(oneOfList.get(0));
|
||||
if(date!=null && !date.isEmpty()){
|
||||
oneOfList.get(0).setActualExitTime(date);
|
||||
}
|
||||
actualTimeAndNames.add(oneOfList.get(0).getUnitName() + "(" + oneOfList.get(0).getActualExitTime()+")");
|
||||
projectNames.add(oneOfList.get(0).getProjectName());
|
||||
unitNames.add(oneOfList.get(0).getUnitName());
|
||||
}
|
||||
List<MaterialSltAgreementInfo> leaseList = new ArrayList<>(oneOfList);
|
||||
|
||||
for (MaterialSltAgreementInfo bean : leaseList) {
|
||||
// 数据安全检查
|
||||
if (null == bean.getLeasePrice()) {
|
||||
bean.setLeasePrice(BigDecimal.ZERO);
|
||||
} else {
|
||||
bean.setLeasePrice(bean.getLeasePrice().setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (Objects.isNull(bean.getNum())) {
|
||||
bean.setNum(BigDecimal.ZERO);
|
||||
}
|
||||
if (Objects.isNull(bean.getLeaseDays())) {
|
||||
bean.setLeaseDay(0L);
|
||||
}
|
||||
|
||||
BigDecimal leasePrice = bean.getLeasePrice();
|
||||
BigDecimal num = bean.getNum();
|
||||
// 根据班组退场时间计算租赁费用
|
||||
BigDecimal costs = calculateRentalCostByTeamExitTime(bean, leasePrice, num);
|
||||
bean.setCosts(costs);
|
||||
if(costs!=null){
|
||||
totalCost = totalCost.add(costs);
|
||||
}
|
||||
leaseListAll.add(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String fileName = "租赁费用明细表";
|
||||
String projectName = handleData(projectNames);
|
||||
String unitName = handleData(unitNames);
|
||||
String actualTimeAndName = handleData(actualTimeAndNames);
|
||||
|
||||
expOutExcel(response,leaseListAll,fileName,projectName,unitName,actualTimeAndName,totalCost,1);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出丢失明细
|
||||
*/
|
||||
@ApiOperation(value = "导出材料站结算信息列表")
|
||||
@PreventRepeatSubmit
|
||||
@SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "结算管理->导出材料站租赁明细")
|
||||
@PostMapping("/exportLose")
|
||||
public void exportLose(HttpServletResponse response, @RequestParam("params") String params) {
|
||||
try {
|
||||
// 1. 修正:先将 params 解析为 JSON 对象(而非数组)
|
||||
JSONObject paramObj = JSONObject.parseObject(params);
|
||||
|
||||
// 2. 根据实际需求从 JSON 对象中提取数据(示例:提取 unitIds 和 projectId)
|
||||
List<Integer> unitIds = paramObj.getJSONArray("unitIds").toJavaList(Integer.class);
|
||||
Long projectId = paramObj.getLong("projectId");
|
||||
List<MaterialSltAgreementInfo> loseListAll = new ArrayList<>();
|
||||
BigDecimal totalCost = BigDecimal.valueOf(0.00);
|
||||
List<String> projectNames = new ArrayList<>();
|
||||
List<String> unitNames = new ArrayList<>();
|
||||
List<String> actualTimeAndNames = new ArrayList<>();
|
||||
|
||||
// 查询协议号
|
||||
List<AgreementVo> agreementInfos = clzSltAgreementInfoMapper.getAgreementInfoById(unitIds, Math.toIntExact(projectId));
|
||||
// 过滤异常数据
|
||||
agreementInfos.removeIf(Objects::isNull);
|
||||
|
||||
// 查询每个协议的待结算明细
|
||||
if (CollectionUtils.isNotEmpty(agreementInfos)) {
|
||||
for (AgreementVo agreementInfo : agreementInfos) {
|
||||
// 数据检查
|
||||
if (agreementInfo.getAgreementId() == null || agreementInfo.getAgreementId() <= 0) {
|
||||
throw new ServiceException("协议ID为空,请反馈至管理员!");
|
||||
}
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(agreementInfo.getAgreementCode())) {
|
||||
throw new ServiceException("协议号为空,请检查!");
|
||||
}
|
||||
|
||||
// 进行Bean的类型转换,使其适配Mapper
|
||||
MaterialSltAgreementInfo sltAgreementInfo = new MaterialSltAgreementInfo();
|
||||
BeanUtil.copyProperties(agreementInfo, sltAgreementInfo, true);
|
||||
|
||||
// 获取未退还的物资(原有逻辑)
|
||||
List<MaterialSltAgreementInfo> oneOfList = clzSltAgreementInfoMapper.getLoseList(sltAgreementInfo);
|
||||
List<MaterialSltAgreementInfo> loseList = new ArrayList<>(oneOfList);
|
||||
|
||||
// 获取已退还但超期16天以上的物资
|
||||
List<MaterialSltAgreementInfo> overdueReturnedList = getOverdueReturnedMaterials(sltAgreementInfo);
|
||||
loseList.addAll(overdueReturnedList);
|
||||
//设定班组实际出场时间
|
||||
if(!loseList.isEmpty()){
|
||||
String date = clzSltAgreementInfoMapper.getTeamOutTime(loseList.get(0));
|
||||
if(date!=null && !date.isEmpty()){
|
||||
loseList.get(0).setActualExitTime(date);
|
||||
}
|
||||
actualTimeAndNames.add(loseList.get(0).getUnitName() + "(" + loseList.get(0).getActualExitTime()+")");
|
||||
projectNames.add(loseList.get(0).getProjectName());
|
||||
unitNames.add(loseList.get(0).getUnitName());
|
||||
}
|
||||
|
||||
for (MaterialSltAgreementInfo bean : loseList) {
|
||||
if (Objects.isNull(bean.getBuyPrice())) {
|
||||
bean.setBuyPrice(BigDecimal.ZERO);
|
||||
}
|
||||
if (Objects.isNull(bean.getNum())) {
|
||||
bean.setNum(BigDecimal.ZERO);
|
||||
}
|
||||
BigDecimal buyPrice = bean.getBuyPrice();
|
||||
BigDecimal num = bean.getNum();
|
||||
// 原价 x 数量
|
||||
BigDecimal costs = buyPrice.multiply(num);
|
||||
//计算租赁费用
|
||||
bean.setCosts(costs);
|
||||
if(costs!=null){
|
||||
totalCost = totalCost.add(costs);
|
||||
}
|
||||
loseListAll.add(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String fileName = "丢失费用明细表";
|
||||
String projectName = handleData(projectNames);
|
||||
String unitName = handleData(unitNames);
|
||||
String actualTimeAndName = handleData(actualTimeAndNames);
|
||||
|
||||
expOutExcel(response,loseListAll,fileName,projectName,unitName,actualTimeAndName,totalCost,2);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出结算信息列表--all
|
||||
*/
|
||||
@ApiOperation(value = "导出结算信息列表")
|
||||
@PreventRepeatSubmit
|
||||
// @RequiresPermissions("settlement:info:export")
|
||||
@SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出租赁明细")
|
||||
@PostMapping("/exportAll")
|
||||
public void exportAll(HttpServletResponse response, @RequestParam("params") String params) {
|
||||
try {
|
||||
String fileName = "结算费用明细";
|
||||
JSONObject paramObj = JSONObject.parseObject(params);
|
||||
List<Integer> unitIds = paramObj.getJSONArray("unitIds").toJavaList(Integer.class);
|
||||
Long projectId = paramObj.getLong("projectId");
|
||||
List<MaterialSltAgreementInfo> leaseListAll = new ArrayList<>();
|
||||
List<MaterialSltAgreementInfo> loseListAll = new ArrayList<>();
|
||||
List<MaterialSltAgreementInfo> repairListAll = new ArrayList<>();
|
||||
List<MaterialSltAgreementInfo> scrapListAll = new ArrayList<>();
|
||||
List<MaterialSltAgreementInfo> reductionListAll = new ArrayList<>();
|
||||
|
||||
List<MaterialSltAgreementInfo> listAll = new ArrayList<>();
|
||||
|
||||
BigDecimal totalCost = BigDecimal.valueOf(0.00);
|
||||
List<String> projectNames = new ArrayList<>();
|
||||
List<String> unitNames = new ArrayList<>();
|
||||
List<String> actualTimeAndNames = new ArrayList<>();
|
||||
|
||||
//各费用明细
|
||||
BigDecimal totalCostLease = BigDecimal.valueOf(0.00);
|
||||
BigDecimal totalCostLose = BigDecimal.valueOf(0.00);
|
||||
BigDecimal totalCostRepair = BigDecimal.valueOf(0.00);
|
||||
BigDecimal totalCostScrap = BigDecimal.valueOf(0.00);
|
||||
BigDecimal totalCostReduction = BigDecimal.valueOf(0.00);
|
||||
|
||||
// 查询协议号
|
||||
List<AgreementVo> agreementInfos = clzSltAgreementInfoMapper.getAgreementInfoById(unitIds, Math.toIntExact(projectId));
|
||||
// 过滤异常数据
|
||||
agreementInfos.removeIf(Objects::isNull);
|
||||
|
||||
|
||||
// 查询每个协议的待结算明细
|
||||
if (CollectionUtils.isNotEmpty(agreementInfos)) {
|
||||
for (AgreementVo agreementInfo : agreementInfos) {
|
||||
// 数据检查
|
||||
if (agreementInfo.getAgreementId() == null || agreementInfo.getAgreementId() <= 0) {
|
||||
throw new ServiceException("协议ID为空,请反馈至管理员!");
|
||||
}
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(agreementInfo.getAgreementCode())) {
|
||||
throw new ServiceException("协议号为空,请检查!");
|
||||
}
|
||||
|
||||
//租赁
|
||||
// 进行Bean的类型转换,使其适配Mapper
|
||||
MaterialSltAgreementInfo sltAgreementInfoLease = new MaterialSltAgreementInfo();
|
||||
BeanUtil.copyProperties(agreementInfo, sltAgreementInfoLease, true);
|
||||
|
||||
List<MaterialSltAgreementInfo> oneOfListLease = clzSltAgreementInfoMapper.getLeaseList(sltAgreementInfoLease);
|
||||
|
||||
List<MaterialSltAgreementInfo> leaseList = new ArrayList<>(oneOfListLease);
|
||||
|
||||
for (MaterialSltAgreementInfo bean : leaseList) {
|
||||
// 数据安全检查
|
||||
if (null == bean.getLeasePrice()) {
|
||||
bean.setLeasePrice(BigDecimal.ZERO);
|
||||
} else {
|
||||
bean.setLeasePrice(bean.getLeasePrice().setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (Objects.isNull(bean.getNum())) {
|
||||
bean.setNum(BigDecimal.ZERO);
|
||||
}
|
||||
if (Objects.isNull(bean.getLeaseDays())) {
|
||||
bean.setLeaseDay(0L);
|
||||
}
|
||||
|
||||
BigDecimal leasePrice = bean.getLeasePrice();
|
||||
BigDecimal num = bean.getNum();
|
||||
// 根据班组退场时间计算租赁费用
|
||||
BigDecimal costs = calculateRentalCostByTeamExitTime(bean, leasePrice, num);
|
||||
bean.setCosts(costs);
|
||||
if(costs!=null){
|
||||
totalCostLease = totalCostLease.add(costs);
|
||||
}
|
||||
leaseListAll.add(bean);
|
||||
listAll.add(bean);
|
||||
}
|
||||
|
||||
//丢失
|
||||
// 进行Bean的类型转换,使其适配Mapper
|
||||
MaterialSltAgreementInfo sltAgreementInfoLose = new MaterialSltAgreementInfo();
|
||||
BeanUtil.copyProperties(agreementInfo, sltAgreementInfoLose, true);
|
||||
|
||||
// 获取未退还的物资(原有逻辑)
|
||||
List<MaterialSltAgreementInfo> oneOfListLose = clzSltAgreementInfoMapper.getLoseList(sltAgreementInfoLose);
|
||||
List<MaterialSltAgreementInfo> loseList = new ArrayList<>(oneOfListLose);
|
||||
|
||||
// 获取已退还但超期16天以上的物资
|
||||
List<MaterialSltAgreementInfo> overdueReturnedList = getOverdueReturnedMaterials(sltAgreementInfoLose);
|
||||
loseList.addAll(overdueReturnedList);
|
||||
|
||||
|
||||
for (MaterialSltAgreementInfo bean : loseList) {
|
||||
if (Objects.isNull(bean.getBuyPrice())) {
|
||||
bean.setBuyPrice(BigDecimal.ZERO);
|
||||
}
|
||||
if (Objects.isNull(bean.getNum())) {
|
||||
bean.setNum(BigDecimal.ZERO);
|
||||
}
|
||||
BigDecimal buyPrice = bean.getBuyPrice();
|
||||
BigDecimal num = bean.getNum();
|
||||
// 原价 x 数量
|
||||
BigDecimal costs = buyPrice.multiply(num);
|
||||
//计算租赁费用
|
||||
bean.setCosts(costs);
|
||||
if(costs!=null){
|
||||
totalCostLose = totalCostLose.add(costs);
|
||||
}
|
||||
loseListAll.add(bean);
|
||||
listAll.add(bean);
|
||||
}
|
||||
//设定班组实际出场时间
|
||||
if(!listAll.isEmpty()){
|
||||
String date = clzSltAgreementInfoMapper.getTeamOutTime(listAll.get(0));
|
||||
if(date!=null && !date.isEmpty()){
|
||||
listAll.get(0).setActualExitTime(date);
|
||||
}
|
||||
projectNames.add(listAll.get(0).getProjectName());
|
||||
unitNames.add(listAll.get(0).getUnitName());
|
||||
actualTimeAndNames.add(listAll.get(0).getUnitName() + "(" + listAll.get(0).getActualExitTime()+")");
|
||||
listAll = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String projectName = handleData(projectNames);
|
||||
String unitName = handleData(unitNames);
|
||||
String actualTimeAndName = handleData(actualTimeAndNames);
|
||||
expOutExcelAll(response,leaseListAll,loseListAll,repairListAll,scrapListAll,reductionListAll,fileName,projectName,unitName,actualTimeAndName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap,totalCostReduction);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出结算单--all
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
private void expOutExcelAll(HttpServletResponse response, List<MaterialSltAgreementInfo> lease,List<MaterialSltAgreementInfo> lose,List<MaterialSltAgreementInfo> repair,List<MaterialSltAgreementInfo> scrap,List<MaterialSltAgreementInfo> reduction,
|
||||
String filename,String projectName,String unitName,String actualTimeAndName,BigDecimal totalCostLease,BigDecimal totalCostLose,BigDecimal totalCostRepair,BigDecimal totalCostScrap,BigDecimal totalCostReduction)
|
||||
throws Exception {
|
||||
List<Map<String, Object>> resultsLease = new ArrayList<>();
|
||||
List<Map<String, Object>> resultsLose = new ArrayList<>();
|
||||
List<Map<String, Object>> resultsRepair = new ArrayList<>();
|
||||
List<Map<String, Object>> resultsScrap = new ArrayList<>();
|
||||
List<Map<String, Object>> resultsReduction = new ArrayList<>();
|
||||
if (lease!= null) {
|
||||
for (MaterialSltAgreementInfo bean : lease) {
|
||||
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 1, 1);
|
||||
resultsLease.add(maps);
|
||||
}
|
||||
}
|
||||
if (lose!= null) {
|
||||
for (MaterialSltAgreementInfo bean : lose) {
|
||||
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 2, 1);
|
||||
resultsLose.add(maps);
|
||||
}
|
||||
}
|
||||
if (repair!= null) {
|
||||
for (MaterialSltAgreementInfo bean : repair) {
|
||||
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 3, 1);
|
||||
resultsRepair.add(maps);
|
||||
}
|
||||
}
|
||||
if (scrap!= null) {
|
||||
for (MaterialSltAgreementInfo bean : scrap) {
|
||||
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 4, 1);
|
||||
resultsScrap.add(maps);
|
||||
}
|
||||
}
|
||||
if (reduction!= null) {
|
||||
for (MaterialSltAgreementInfo bean : reduction) {
|
||||
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 5, 1);
|
||||
resultsReduction.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);
|
||||
List<String> headersReduction = receiveDetailsHeader(5,1);
|
||||
HSSFWorkbook workbook = PoiOutPage.excelForcheckAllClz(resultsLease,resultsLose,resultsRepair,resultsScrap,resultsReduction, headersLease,headersLose,headersRepair,headersScrap,headersReduction, filename,projectName,unitName,actualTimeAndName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap,totalCostReduction);
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已退还但超期16天以上的物资(计为丢失)
|
||||
* @param info 信息表
|
||||
*/
|
||||
private List<MaterialSltAgreementInfo> getOverdueReturnedMaterials(MaterialSltAgreementInfo info) {
|
||||
// 获取所有已退还的物资
|
||||
List<MaterialSltAgreementInfo> returnedList = clzSltAgreementInfoMapper.getLeaseList(info);
|
||||
List<MaterialSltAgreementInfo> overdueList = new ArrayList<>();
|
||||
|
||||
Date teamExitTime = simulateTeamExitTime();
|
||||
|
||||
for (MaterialSltAgreementInfo bean : returnedList) {
|
||||
// 只处理已退还的物资
|
||||
if (bean.getEndTime() != null) {
|
||||
long overdueDays = calculateOverdueDays(bean.getEndTime(), teamExitTime);
|
||||
if (overdueDays >= 16) {
|
||||
// 超期16天以上计为丢失
|
||||
overdueList.add(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return overdueList;
|
||||
}
|
||||
|
||||
private BigDecimal calculateRentalCostByTeamExitTime(MaterialSltAgreementInfo bean, BigDecimal leasePrice, BigDecimal num) {
|
||||
// 模拟班组退场时间(后续会通过参数传入)
|
||||
Date teamExitTime = simulateTeamExitTime();
|
||||
|
||||
// 物资是否已退还(根据endTime字段判断)
|
||||
boolean isReturned = bean.getEndTime() != null;
|
||||
|
||||
if (!isReturned) {
|
||||
// 1.4 如果当前领用物资还未退还,不收取任何租赁费用,直接计作丢失,收取物资原值 不在租赁费用中体现
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
// 物资已退还,按照天数来计算费用
|
||||
Date materialReturnTime = bean.getEndTime();
|
||||
|
||||
// 计算超期天数
|
||||
long overdueDays = calculateOverdueDays(materialReturnTime, teamExitTime);
|
||||
|
||||
if (overdueDays <= 0) {
|
||||
// 1.3 在班组退场之前归还的物资不收费
|
||||
return BigDecimal.ZERO;
|
||||
} else if (overdueDays >= 16) {
|
||||
// 1.2 超期15天以上也就是16天及以上计为丢失,算作丢失的话直接收取原值、所有租赁费用不收费了
|
||||
// 注意:丢失费用应该在getLoseList中处理,这里不收费
|
||||
return BigDecimal.ZERO;
|
||||
} else {
|
||||
// 计算超期费用
|
||||
return calculateOverdueCost(bean, leasePrice, num, overdueDays);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算超期费用(新逻辑:前7天不收费,第8天开始双倍收费)
|
||||
*/
|
||||
private BigDecimal calculateOverdueCost(MaterialSltAgreementInfo bean, BigDecimal leasePrice, BigDecimal num, long overdueDays) {
|
||||
BigDecimal overdueCost = BigDecimal.ZERO;
|
||||
|
||||
if (overdueDays <= 7) {
|
||||
// 超期1~7天不收费
|
||||
overdueCost = BigDecimal.ZERO;
|
||||
} else if (overdueDays <= 15) {
|
||||
// 超期第8天~第15天双倍计费
|
||||
// 前7天不收费,只计算第8天开始的双倍费用
|
||||
long doubleBillingDays = overdueDays - 7;
|
||||
overdueCost = leasePrice.multiply(num).multiply(new BigDecimal(doubleBillingDays)).multiply(new BigDecimal(2));
|
||||
}
|
||||
|
||||
return overdueCost.setScale(GlobalConstants.INT_2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算超期天数(只关注日期,不考虑时分秒)
|
||||
*/
|
||||
private long calculateOverdueDays(Date materialReturnTime, Date teamExitTime) {
|
||||
if (materialReturnTime == null || teamExitTime == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Calendar returnCal = Calendar.getInstance();
|
||||
returnCal.setTime(materialReturnTime);
|
||||
resetTimeToZero(returnCal);
|
||||
|
||||
Calendar exitCal = Calendar.getInstance();
|
||||
exitCal.setTime(teamExitTime);
|
||||
resetTimeToZero(exitCal);
|
||||
|
||||
long diffInMillies = returnCal.getTimeInMillis() - exitCal.getTimeInMillis();
|
||||
return diffInMillies / (24 * 60 * 60 * 1000);
|
||||
}
|
||||
|
||||
private void resetTimeToZero(Calendar calendar) {
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
}
|
||||
|
||||
private Date simulateTeamExitTime() {
|
||||
// 模拟班组退场时间为30天前
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -30);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public String handleData(List<String> list){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Set<String> set = new HashSet<>(list);
|
||||
for (String str : set) {
|
||||
sb.append(str).append("、");
|
||||
}
|
||||
return org.apache.commons.lang3.StringUtils.removeEnd(sb.toString(), "、");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出结算单
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
private void expOutExcel(HttpServletResponse response, List<MaterialSltAgreementInfo> list, String filename,String projectName,String unitName,String actualTimeAndName,BigDecimal totalCost,int type) throws Exception {
|
||||
if (list != null) {
|
||||
List<Map<String, Object>> results = new ArrayList<>();
|
||||
for (MaterialSltAgreementInfo bean : list) {
|
||||
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, type, 0);
|
||||
results.add(maps);
|
||||
}
|
||||
List<String> headers = receiveDetailsHeader(type,0);
|
||||
HSSFWorkbook workbook = PoiOutPage.excelForcheckClz(results, headers, filename,projectName,unitName,actualTimeAndName,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<>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 租赁费用单数据转换
|
||||
*/
|
||||
private Map<String, Object> outReceiveDetailsBeanToMap(MaterialSltAgreementInfo bean,int type,int flag) {
|
||||
// 创建一个SimpleDateFormat对象,定义日期格式
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Map<String, Object> maps = new LinkedHashMap<>();
|
||||
if(type==1){
|
||||
// maps.put("unitName", bean.getUnitName());
|
||||
// maps.put("projectName", bean.getProjectName());
|
||||
if (flag==0){
|
||||
maps.put("unitName", bean.getUnitName());
|
||||
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 {
|
||||
maps.put("unitName", bean.getUnitName());
|
||||
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));
|
||||
maps.put("t1", "");
|
||||
}
|
||||
}else if(type==2) {
|
||||
if(flag==0){
|
||||
maps.put("unitName", bean.getUnitName());
|
||||
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("unitName", bean.getUnitName());
|
||||
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", "");
|
||||
maps.put("t5", "");
|
||||
}
|
||||
}else if(type==3){
|
||||
if(flag==0){
|
||||
maps.put("unitName", bean.getUnitName());
|
||||
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("unitName", bean.getUnitName());
|
||||
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", "");
|
||||
}
|
||||
}else if(type==4){
|
||||
if(flag==0){
|
||||
maps.put("unitName", bean.getUnitName());
|
||||
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("unitName", bean.getUnitName());
|
||||
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", "");
|
||||
}
|
||||
}
|
||||
else if(type==5){
|
||||
maps.put("unitName", bean.getUnitName());
|
||||
maps.put("typeName", bean.getTypeName());
|
||||
maps.put("modelName", bean.getModelName());
|
||||
maps.put("mtUnitName", bean.getUnitName());
|
||||
maps.put("leasePrice", bean.getLeasePrice());
|
||||
maps.put("num", bean.getReduceNum());
|
||||
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("remark", bean.getRemark());
|
||||
maps.put("costs", bean.getCosts());
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
/**
|
||||
* 租赁费用单表头
|
||||
* @return
|
||||
*/
|
||||
private List<String> receiveDetailsHeader(int type,int flag) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
if(type==1){
|
||||
// list.add("结算单位");
|
||||
// list.add("结算工程");
|
||||
|
||||
if (flag==0){
|
||||
list.add("单位名称");
|
||||
list.add("设备名称");
|
||||
list.add("规格型号");
|
||||
list.add("计量单位");
|
||||
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("租赁天数");
|
||||
list.add("租赁费用(元)");
|
||||
list.add(" ");
|
||||
}
|
||||
}else if(type==2){
|
||||
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(" ");
|
||||
list.add(" ");
|
||||
list.add(" ");
|
||||
}
|
||||
|
||||
}else if(type==3){
|
||||
if(flag==0){
|
||||
list.add("单位名称");
|
||||
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("");
|
||||
list.add("");
|
||||
list.add(" ");
|
||||
}
|
||||
}else if(type==4){
|
||||
if(flag==0){
|
||||
list.add("单位名称");
|
||||
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("");
|
||||
list.add("");
|
||||
list.add(" ");
|
||||
}
|
||||
}else if (type==5){
|
||||
list.add("单位名称");
|
||||
list.add("设备名称");
|
||||
list.add("规格型号");
|
||||
list.add("单位");
|
||||
list.add("租赁单价");
|
||||
list.add("减免数量");
|
||||
list.add("减免开始日期");
|
||||
list.add("减免结束日期");
|
||||
list.add("减免天数");
|
||||
list.add("减免原因");
|
||||
list.add("减免费用(元)");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进行结算审批
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ public class MaterialSltAgreementInfo extends BaseEntity {
|
|||
@ApiModelProperty(value = "机具规格id")
|
||||
private Long typeId;
|
||||
|
||||
@ApiModelProperty(value = "是否是整数")
|
||||
private Integer unitValue;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
|
|
@ -181,6 +183,12 @@ public class MaterialSltAgreementInfo extends BaseEntity {
|
|||
@ApiModelProperty(value = "工程标段ID")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* i8工程工程ID
|
||||
*/
|
||||
@ApiModelProperty(value = "i8工程工程ID")
|
||||
private String proId;
|
||||
|
||||
@ApiModelProperty(value = "结算状态")
|
||||
private String sltStatus;
|
||||
|
||||
|
|
@ -244,4 +252,11 @@ public class MaterialSltAgreementInfo extends BaseEntity {
|
|||
|
||||
//结算费用
|
||||
private BigDecimal totalCostAll;
|
||||
|
||||
/**
|
||||
* 实际出场时间
|
||||
*/
|
||||
private String actualExitTime;
|
||||
|
||||
private BigDecimal reduceNum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,4 +129,9 @@ public class MaterialSltInfoVo {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date applyTime;
|
||||
|
||||
/**
|
||||
* 实际出场时间
|
||||
*/
|
||||
@Excel(name = "实际出场时间")
|
||||
private String actualExitTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.material.clz.mapper;
|
||||
|
||||
import com.bonus.common.biz.domain.ProjectTreeNode;
|
||||
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
|
||||
import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo;
|
||||
import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo;
|
||||
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||
|
|
@ -118,4 +119,8 @@ public interface ClzSltAgreementInfoMapper {
|
|||
* 插入协议申请详情 -- 丢失
|
||||
*/
|
||||
int insertSltAgreementDetailLose(@Param("list") List<MaterialSltAgreementInfo> list, @Param("id") Long id);
|
||||
|
||||
List<MaterialSltAgreementInfo> getClzTeamList(MaterialSltAgreementInfo bean);
|
||||
|
||||
String getTeamOutTime(MaterialSltAgreementInfo materialSltAgreementInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.material.clz.service;
|
|||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.basic.domain.BmProject;
|
||||
import com.bonus.material.clz.domain.ClzSltApplyDTO;
|
||||
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
|
||||
import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo;
|
||||
import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo;
|
||||
import com.bonus.material.common.domain.dto.SelectDto;
|
||||
|
|
@ -22,6 +23,20 @@ public interface ClzSltAgreementInfoService {
|
|||
*/
|
||||
AjaxResult costExamine(SltAgreementApply sltAgreementApply);
|
||||
|
||||
/**
|
||||
* 获取材料站结算申请工程下拉选
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<MaterialRetainedEquipmentInfo> getClzProjectList(MaterialRetainedEquipmentInfo bean);
|
||||
|
||||
/**
|
||||
* 获取材料站结算申请班组下拉选
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<MaterialSltAgreementInfo> getClzTeamList(MaterialSltAgreementInfo bean);
|
||||
|
||||
/**
|
||||
* 根据条件获取协议结算列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,12 +11,15 @@ import com.bonus.common.core.web.domain.AjaxResult;
|
|||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.basic.domain.BmProject;
|
||||
import com.bonus.material.clz.domain.ClzSltApplyDTO;
|
||||
import com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo;
|
||||
import com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo;
|
||||
import com.bonus.material.clz.domain.vo.sltAgreementInfo.MaterialSltInfoVo;
|
||||
import com.bonus.material.clz.mapper.ClzSltAgreementInfoMapper;
|
||||
import com.bonus.material.clz.mapper.MaterialMachineMapper;
|
||||
import com.bonus.material.clz.service.ClzSltAgreementInfoService;
|
||||
import com.bonus.material.common.domain.dto.SelectDto;
|
||||
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||
import com.bonus.material.common.mapper.SelectMapper;
|
||||
import com.bonus.material.settlement.domain.SltAgreementApply;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||
|
|
@ -48,6 +51,12 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
|||
@Resource
|
||||
private ClzSltAgreementInfoMapper clzSltAgreementInfoMapper;
|
||||
|
||||
@Resource
|
||||
private MaterialMachineMapper materialMachineMapper;
|
||||
|
||||
@Resource
|
||||
private SelectMapper mapper;
|
||||
|
||||
/**
|
||||
* 进行结算审批
|
||||
*
|
||||
|
|
@ -100,6 +109,46 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取材料站结算申请工程下拉选
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MaterialRetainedEquipmentInfo> getClzProjectList(MaterialRetainedEquipmentInfo bean) {
|
||||
List<MaterialRetainedEquipmentInfo> list = materialMachineMapper.getProjectList(bean);
|
||||
if (list.size()>0){
|
||||
// 查询所有未结算的工程
|
||||
List<String> projectIdList = mapper.getUnsettledProId();
|
||||
// 使用 HashSet 来加速查找过程
|
||||
Set<String> unsettledProjectIds = new HashSet<>(projectIdList);
|
||||
// 过滤掉不在未结算工程集合内的工程
|
||||
Iterator<MaterialRetainedEquipmentInfo> iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
MaterialRetainedEquipmentInfo info = iterator.next();
|
||||
String proId = info.getProId() != null ?
|
||||
info.getProId().toString() : null;
|
||||
|
||||
if (proId == null || !unsettledProjectIds.contains(proId)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取材料站结算申请班组下拉选
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<MaterialSltAgreementInfo> getClzTeamList(MaterialSltAgreementInfo bean) {
|
||||
List<MaterialSltAgreementInfo> teamList = clzSltAgreementInfoMapper.getClzTeamList(bean);
|
||||
return teamList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件获取协议结算列表
|
||||
* @param bean 查询条件
|
||||
|
|
@ -168,6 +217,9 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
|||
|
||||
List<SltAgreementReduce> reductionList = getReductionList(info);
|
||||
sltInfoVo.setLeaseList(leaseList);
|
||||
if(!CollectionUtils.isEmpty(leaseList)){
|
||||
sltInfoVo.setActualExitTime(leaseList.get(0).getActualExitTime());
|
||||
}
|
||||
sltInfoVo.setRepairList(repairList);
|
||||
sltInfoVo.setScrapList(scrapList);
|
||||
sltInfoVo.setLoseList(loseList);
|
||||
|
|
@ -308,6 +360,8 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
|||
sltInfoVo.setUnitName(sltInfoVo.getScrapList().get(0).getUnitName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 合计一下总费用
|
||||
sltInfoVo.setTotalCostAll(Optional.ofNullable(sltInfoVo.getLeaseCost()).orElse(BigDecimal.ZERO)
|
||||
.add(Optional.ofNullable(sltInfoVo.getRepairCost()).orElse(BigDecimal.ZERO))
|
||||
|
|
@ -721,6 +775,13 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
|
|||
*/
|
||||
private List<MaterialSltAgreementInfo> getLeaseList(MaterialSltAgreementInfo info) {
|
||||
List<MaterialSltAgreementInfo> oneOfList = clzSltAgreementInfoMapper.getLeaseList(info);
|
||||
//设定班组实际出场时间
|
||||
if(!oneOfList.isEmpty()){
|
||||
String date = clzSltAgreementInfoMapper.getTeamOutTime(oneOfList.get(0));
|
||||
if(date!=null && !date.isEmpty()){
|
||||
oneOfList.get(0).setActualExitTime(date);
|
||||
}
|
||||
}
|
||||
List<MaterialSltAgreementInfo> leaseList = new ArrayList<>(oneOfList);
|
||||
|
||||
for (MaterialSltAgreementInfo bean : leaseList) {
|
||||
|
|
|
|||
|
|
@ -94,20 +94,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getLeaseList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
|
||||
select sai.id,
|
||||
sai.agreement_id as agreementId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
sai.company_id as companyId,
|
||||
sai.type_id as typeId,
|
||||
sai.ma_id as maId,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sai.lease_price as leasePrice,
|
||||
sai.num as num,
|
||||
DATE(sai.start_time) as startTime,
|
||||
DATE(sai.end_time) as endTime,
|
||||
SELECT
|
||||
res.agreementId,
|
||||
res.unitName,
|
||||
res.unitId,
|
||||
res.projectName,
|
||||
res.companyId,
|
||||
res.typeId,
|
||||
res.typeName,
|
||||
res.modelName,
|
||||
res.mtUnitName,
|
||||
ROUND(res.leasePrice, 2) as leasePrice,
|
||||
CASE
|
||||
WHEN res.unitValue = 0 THEN CAST(SUM(res.num) AS UNSIGNED) -- unitValue=0 转为整数
|
||||
WHEN res.unitValue = 1 THEN ROUND(SUM(res.num), 2) -- unitValue=1 保留两位小数
|
||||
ELSE SUM(res.num) -- 其他情况默认保留原始格式
|
||||
END AS num,
|
||||
res.startTime,
|
||||
res.endTime,
|
||||
CAST(res.leaseDays AS UNSIGNED) as leaseDays
|
||||
from (
|
||||
select sai.id,
|
||||
sai.agreement_id as agreementId,
|
||||
bui.unit_id as unitId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
sai.company_id as companyId,
|
||||
sai.type_id as typeId,
|
||||
sai.ma_id as maId,
|
||||
mt.unit_value as unitValue,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sai.lease_price as leasePrice,
|
||||
sai.num as num,
|
||||
DATE(sai.start_time) as startTime,
|
||||
DATE(sai.end_time) as endTime,
|
||||
DATEDIFF(IF(sai.end_time is null,CURDATE(),sai.end_time), sai.start_time) + 1 as leaseDays
|
||||
from clz_slt_agreement_info sai
|
||||
LEFT JOIN clz_bm_agreement_info bai on sai.agreement_id = bai.agreement_id
|
||||
|
|
@ -116,50 +138,99 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join ma_type mt on sai.type_id = mt.type_id
|
||||
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||
where sai.agreement_id = #{agreementId}
|
||||
) res
|
||||
GROUP BY res.typeId,res.startTime,res.endTime
|
||||
</select>
|
||||
|
||||
<select id="getLoseList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
|
||||
select sai.id,
|
||||
sai.agreement_id as agreementId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
sai.company_id as companyId,
|
||||
sai.type_id as typeId,
|
||||
sai.ma_id as maId,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sai.buy_price as buyPrice,
|
||||
sai.num as num,
|
||||
sai.start_time as startTime,
|
||||
sai.end_time as endTime,
|
||||
DATEDIFF(sai.end_time, sai.start_time) + 1 as leaseDays
|
||||
from clz_slt_agreement_info sai
|
||||
LEFT JOIN bm_agreement_info bai on sai.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 sai.type_id = mt.type_id
|
||||
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||
where sai.agreement_id = #{agreementId} and sai.end_time is null
|
||||
SELECT
|
||||
res.agreementId,
|
||||
res.unitId,
|
||||
res.unitName,
|
||||
res.projectName,
|
||||
res.companyId,
|
||||
res.typeId,
|
||||
res.typeName,
|
||||
res.modelName,
|
||||
res.mtUnitName,
|
||||
res.buyPrice,
|
||||
CASE
|
||||
WHEN res.unitValue = 0 THEN CAST(SUM(res.num) AS UNSIGNED) -- unitValue=0 转为整数
|
||||
WHEN res.unitValue = 1 THEN ROUND(SUM(res.num), 2) -- unitValue=1 保留两位小数
|
||||
ELSE SUM(res.num) -- 其他情况默认保留原始格式
|
||||
END AS num,
|
||||
res.startTime,
|
||||
res.endTime,
|
||||
res.leaseDays
|
||||
FROM
|
||||
(
|
||||
|
||||
select sai.id,
|
||||
sai.agreement_id as agreementId,
|
||||
bui.unit_id as unitId,
|
||||
bui.unit_name as unitName,
|
||||
bp.pro_name as projectName,
|
||||
sai.company_id as companyId,
|
||||
sai.type_id as typeId,
|
||||
sai.ma_id as maId,
|
||||
mt.unit_value as unitValue,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as mtUnitName,
|
||||
sai.buy_price as buyPrice,
|
||||
sai.num as num,
|
||||
sai.start_time as startTime,
|
||||
sai.end_time as endTime,
|
||||
DATEDIFF(sai.end_time, sai.start_time) + 1 as leaseDays
|
||||
from clz_slt_agreement_info sai
|
||||
LEFT JOIN clz_bm_agreement_info bai on sai.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 sai.type_id = mt.type_id
|
||||
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||
where sai.agreement_id = #{agreementId} and sai.end_time is null
|
||||
) res
|
||||
GROUP BY res.typeId,res.startTime,res.endTime
|
||||
</select>
|
||||
|
||||
<select id="getReductionList" resultType="com.bonus.material.settlement.domain.SltAgreementReduce">
|
||||
SELECT mt2.type_name as typeName,
|
||||
mt.type_name as modeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as unitName,
|
||||
srd.lease_price as leasePrice,
|
||||
srd.reduce_num as reduceNum,
|
||||
srd.start_time as startTime,
|
||||
srd.end_time as endTime,
|
||||
srd.days as days,
|
||||
srd.lease_money as leaseMoney,
|
||||
sra.remark
|
||||
FROM clz_slt_reduce_apply sra
|
||||
INNER JOIN clz_slt_reduce_details srd on sra.id = srd.apply_id
|
||||
LEFT JOIN ma_type mt on mt.type_id = srd.type_id
|
||||
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
||||
WHERE sra.agreement_id = #{agreementId}
|
||||
SELECT
|
||||
res.typeId,
|
||||
res.typeName,
|
||||
res.modeName,
|
||||
res.modelName,
|
||||
res.unitName,
|
||||
res.leasePrice,
|
||||
CASE
|
||||
WHEN res.unitValue = 0 THEN CAST(SUM(res.reduceNum) AS UNSIGNED) -- unitValue=0 转为整数
|
||||
WHEN res.unitValue = 1 THEN ROUND(SUM(res.reduceNum), 2) -- unitValue=1 保留两位小数
|
||||
ELSE SUM(res.reduceNum) -- 其他情况默认保留原始格式
|
||||
END AS reduceNum,
|
||||
res.startTime,
|
||||
res.endTime,
|
||||
res.leaseMoney,
|
||||
res.remark
|
||||
from (
|
||||
SELECT mt.type_id as typeId,
|
||||
mt.unit_value as unitValue,
|
||||
mt2.type_name as typeName,
|
||||
mt.type_name as modeName,
|
||||
mt.type_name as modelName,
|
||||
mt.unit_name as unitName,
|
||||
srd.lease_price as leasePrice,
|
||||
srd.reduce_num as reduceNum,
|
||||
srd.start_time as startTime,
|
||||
srd.end_time as endTime,
|
||||
srd.days as days,
|
||||
srd.lease_money as leaseMoney,
|
||||
sra.remark
|
||||
FROM clz_slt_reduce_apply sra
|
||||
INNER JOIN clz_slt_reduce_details srd on sra.id = srd.apply_id
|
||||
LEFT JOIN ma_type mt on mt.type_id = srd.type_id
|
||||
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
||||
WHERE sra.agreement_id = #{agreementId}
|
||||
) res
|
||||
GROUP BY res.typeId,res.startTime,res.endTime
|
||||
</select>
|
||||
|
||||
<select id="getRejectCount" resultType="java.lang.Integer">
|
||||
|
|
@ -312,6 +383,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from clz_slt_agreement_apply
|
||||
where `code` = #{sltApplyCode}
|
||||
</select>
|
||||
<select id="getClzTeamList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
|
||||
SELECT
|
||||
bu.unit_id AS unitId,
|
||||
bu.unit_name AS unitName
|
||||
FROM
|
||||
clz_bm_agreement_info bai
|
||||
left join bm_unit bu on bai.unit_id = bu.unit_id
|
||||
WHERE
|
||||
bai.project_id = #{proId}
|
||||
</select>
|
||||
<select id="getTeamOutTime" resultType="java.lang.String">
|
||||
select
|
||||
bzj.sjccsj as time
|
||||
from
|
||||
bm_unit bu
|
||||
left join `micro-tool`.bzgl_bz bz on bz.bzz_idcard = bu.bzz_idcard
|
||||
left join `micro-tool`.bzgl_bz_jccdj bzj on bz.id = bzj.bz_id
|
||||
where bu.unit_id = #{unitId}
|
||||
and bzj.operate_type = 2
|
||||
order by bzj.sjccsj desc limit 1
|
||||
</select>
|
||||
|
||||
<update id="updateClzAgreementInfoByIds">
|
||||
update clz_bm_agreement_info
|
||||
|
|
|
|||
Loading…
Reference in New Issue