This commit is contained in:
hayu 2025-02-20 20:40:53 +08:00
parent a1375eda07
commit 4715df61b1
24 changed files with 611 additions and 41 deletions

View File

@ -1,5 +1,6 @@
package com.bonus.common.biz.config;
import com.bonus.common.biz.utils.NumberToChinese;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
@ -248,9 +249,9 @@ public class PoiOutPage {
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 projectName, String unit,
BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap) {
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<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,
BigDecimal totalCostLease, BigDecimal totalCostLose, BigDecimal totalCostRepair, BigDecimal totalCostScrap,BigDecimal totalCostReduction) {
// 创建工作簿和工作表
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
@ -267,7 +268,18 @@ public class PoiOutPage {
// 填充标题行
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());
BigDecimal totalCost1 = totalCostLease.subtract(totalCostReduction);
//合计
BigDecimal totalCostAll = totalCostLease.add(totalCostLose).add(totalCostRepair).add(totalCostScrap).subtract(totalCostReduction);
String all= NumberToChinese.number2CN(totalCostAll);
rowNum = createProjectAndUnitRows(sheet, rowNum, "一、施工机具有偿使用费:", totalCost1+"", titleStyle, listLease.size());
rowNum = createProjectAndUnitRows(sheet, rowNum, "二、施工机具维修费:", totalCostRepair+"", titleStyle, listLease.size());
rowNum = createProjectAndUnitRows(sheet, rowNum, "三、施工机具丢失费:", totalCostLose+"", titleStyle, listLease.size());
rowNum = createProjectAndUnitRows(sheet, rowNum, "四、施工机具损坏赔偿费:", totalCostScrap+"", titleStyle, listLease.size());
rowNum = createProjectAndUnitRowss(sheet,rowNum,"费用合计金额(大写)",all,totalCostAll+"", titleStyle, listLease.size());
rowNum = createProjectAndUnitRows(sheet, rowNum, "说明", "本协议一式三份,甲方一份,乙方一份,经双方签字后生效。", titleStyle, listLease.size());
rowNum = createProjectAndUnitRows(sheet, rowNum, "备注", "此费用仅为在机具设备分公司发生费用,未计从项目部领用机具费用。", titleStyle, listLease.size());
/**
* 租赁费用明细
@ -381,8 +393,34 @@ public class PoiOutPage {
}
rowNum = createTotalRow(sheet, rowNum, listLose, totalCostLose, headerStyle);
//合计
BigDecimal totalCostAll = totalCostLease.add(totalCostLose).add(totalCostRepair).add(totalCostScrap);
/**
* 减免费用明细
*/
// 填充标题行
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);
rowNum = createTotalRowAll(sheet, rowNum, listScrap, totalCostAll, headerStyle);
return workbook;
@ -564,6 +602,79 @@ public class PoiOutPage {
return rowNum;
}
/**
* 创建结算单位和结算工程行
*/
private static int createProjectAndUnitRows(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, 2)); // 结算单位 占8
HSSFCell cell1 = row1.createCell(0);
cell1.setCellStyle(titleStyle);
cell1.setCellValue(projectName);
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 3, (short) (nColumn - 1))); // unitName 占剩余的22
HSSFCell cell2 = row1.createCell(3);
cell2.setCellStyle(titleStyle);
cell2.setCellValue(unitName);
// 添加边框
CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 2);
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 2, rowNum - 2, 3, (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);
return rowNum;
}
private static int createProjectAndUnitRowss(HSSFSheet sheet, int rowNum, String projectName, String unitName,String data,HSSFCellStyle titleStyle, int nColumn) {
// 第一行结算单位
HSSFRow row1 = sheet.createRow(rowNum++);
row1.setHeightInPoints(30);
// bug修复修改合并单元格区域确保包含两个或以上单元格
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 2)); // 结算单位 占8
HSSFCell cell1 = row1.createCell(0);
cell1.setCellStyle(titleStyle);
cell1.setCellValue(projectName);
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 3, 5)); // 结算单位 占8
HSSFCell cell2 = row1.createCell(3);
cell2.setCellStyle(titleStyle);
cell2.setCellValue(unitName);
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 6, (short) (nColumn - 1))); // unitName 占剩余的22
HSSFCell cell3 = row1.createCell(6);
cell3.setCellStyle(titleStyle);
cell3.setCellValue(data);
// 添加边框
CellRangeAddress cellRange1 = new CellRangeAddress(rowNum - 2, rowNum - 2, 0, 2);
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 2, rowNum - 2, 3, 5);
CellRangeAddress cellRange3 = new CellRangeAddress(rowNum - 2, rowNum - 2, 6, (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);
return rowNum;
}
/**
* 创建项目名称和单位信息行
*/

View File

@ -0,0 +1,82 @@
package com.bonus.common.biz.utils;
import java.math.BigDecimal;
public class NumberToChinese {
private static final String[] NUMBERS = {"", "", "", "", "", "", "", "", "", ""};
private static final String[] UNITS = {"", "", "", ""};
private static final String[] BIG_UNITS = {"", "", "亿", ""};
public static String number2CN(BigDecimal number) {
// 分离整数和小数部分
BigDecimal integerPart = number.setScale(0, BigDecimal.ROUND_DOWN);
BigDecimal decimalPart = number.subtract(integerPart).multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP);
StringBuilder result = new StringBuilder();
if (integerPart.compareTo(BigDecimal.ZERO) > 0) {
result.append(integerToChinese(integerPart.longValue())).append("");
}
if (decimalPart.compareTo(BigDecimal.ZERO) > 0) {
int jiao = decimalPart.intValue() / 10;
int fen = decimalPart.intValue() % 10;
if(jiao > 0){
result.append(NUMBERS[jiao]).append("");
}
if(fen > 0){
result.append(NUMBERS[fen]).append("");
} else if(jiao == 0 && fen == 0){
result.append("");
}
} else {
result.append("");
}
return result.toString();
}
private static String integerToChinese(long num) {
if (num == 0) return NUMBERS[0]; // 如果是0直接返回""
StringBuilder chineseNum = new StringBuilder();
int unitPos = 0;
boolean needZero = false;
while (num > 0) {
long index = num % 10; // 获取当前位的数字
if (index != 0 || unitPos % 4 == 0 && num / 10 % 10 != 0) { // 只有在非零或特定位置亿等才添加单位
chineseNum.insert(0, UNITS[unitPos % 4]); // 添加对应的单位
chineseNum.insert(0, NUMBERS[(int)index]); // 添加对应的数字字符
needZero = false;
} else if (!needZero) { // 避免连续的零
if (!(chineseNum.length() > 0 && chineseNum.charAt(0) == NUMBERS[0].charAt(0))) {
chineseNum.insert(0, NUMBERS[0]);
}
needZero = true;
}
num /= 10;
unitPos++;
if(unitPos % 4 == 0 && num > 0){
chineseNum.insert(0, BIG_UNITS[unitPos / 4]);
}
}
// 清理多余的
String result = chineseNum.toString().replaceAll("零[仟佰拾]", "")
.replaceAll("零{2,}", "")
.replaceFirst("^零", "");
// 处理特殊情况如壹拾前加的情况
result = result.replaceAll("壹拾", "");
return result;
}
// public static void main(String[] args) {
// BigDecimal totalCostAll = new BigDecimal("84341.59000");
// System.out.println(number2CN(totalCostAll));
// }
}

View File

@ -125,7 +125,19 @@ public class DirectRotationController extends BaseController {
} catch (Exception e) {
return AjaxResult.success(new DirectApplyInfo());
}
}
/**
* 用于APP
*/
@ApiOperation(value = "查看详情")
@GetMapping("/getInfoApp")
public AjaxResult getInfoApp(SltAgreementInfo sltAgreementInfo) {
try {
return AjaxResult.success(service.getInfoApp(sltAgreementInfo));
} catch (Exception e) {
return AjaxResult.success(new DirectApplyInfo());
}
}
/**

View File

@ -43,6 +43,13 @@ public interface DirectRotationService {
*/
DirectApplyInfo getInfoById(SltAgreementInfo sltAgreementInfo);
/**
* 查看详情
* @param sltAgreementInfo
* @return
*/
DirectApplyInfo getInfoApp(SltAgreementInfo sltAgreementInfo);
/**
* 修改直转申请
* @param directApplyInfoDetails

View File

@ -121,6 +121,7 @@ public class DirectRotationImpl implements DirectRotationService {
int i2 = workSiteDirectManageService.saveDirectApplyDetails(directApplyDetail);
}
}
return AjaxResult.success("修改成功");
}
} else {
return AjaxResult.error("修改失败");
@ -128,7 +129,7 @@ public class DirectRotationImpl implements DirectRotationService {
} else {
return AjaxResult.error("修改失败");
}
return null;
return AjaxResult.success();
}
@Override
@ -148,6 +149,28 @@ public class DirectRotationImpl implements DirectRotationService {
return directApplyInfo;
}
@Override
public DirectApplyInfo getInfoApp(SltAgreementInfo sltAgreementInfo) {
DirectApplyInfo directApplyInfo = mapper.getInfoById(sltAgreementInfo);
if (directApplyInfo != null){
if (sltAgreementInfo.getAgreementId()!=directApplyInfo.getLeaseAgreementId()){
return new DirectApplyInfo();
}
}
if (directApplyInfo.getDirUrl()!= null){
//用逗号分割放入数组
String[] split = directApplyInfo.getDirUrl().split(",");
List<DirectApplyUrl> list1 = new ArrayList<>();
for (String s : split) {
list1.add(new DirectApplyUrl(s));
}
directApplyInfo.setDirUrls(list1);
}
List<DirectApplyDetails> detailById = mapper.getDetailById(sltAgreementInfo);
directApplyInfo.setDirectApplyDetails(detailById);
return directApplyInfo;
}
@Override
public int delData(Long id) {
try {

View File

@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
@ -62,6 +63,16 @@ public class DerateRecordQueryController extends BaseController {
}
}
/**
* 减免记录详情查看
*/
@ApiOperation(value = "减免记录详情查看")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@NotNull(message = "减免任务ID不能为空") @PathVariable("id") Long id,
@RequestParam(value = "keyWord", required = false) String keyWord) {
return success(service.getInfo(id, keyWord));
}
/**
* 删除减免记录
*/

View File

@ -52,7 +52,7 @@ public class SltRecordQueryController extends BaseController {
@GetMapping("/getAppList")
public AjaxResult getAppList(SltAgreementInfo bean) {
try {
List<SltAgreementInfo> list = service.getList(bean);
List<SltAgreementInfo> list = service.getAppList(bean);
return AjaxResult.success(list);
} catch (Exception e) {
return AjaxResult.success(new ArrayList<>());

View File

@ -1,6 +1,7 @@
package com.bonus.material.record.mapper;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.settlement.domain.SltAgreementReduce;
@ -26,4 +27,25 @@ public interface DerateRecordQueryMapper {
* @return
*/
int delData(Long id);
/**
* 减免记录详情查看
* @param id
* @return
*/
SltAgreementReduce getInfo(Long id);
/**
* 减免记录附件
* @param info
* @return
*/
List<BmFileInfo> getBmFileInfos(SltAgreementReduce info);
/**
* 减免记录详情查看
* @param id
* @return
*/
List<SltAgreementReduce> getDetailList(Long id);
}

View File

@ -26,4 +26,12 @@ public interface IDerateReocrdQueryService {
* @return
*/
int delData(Long id);
/**
* 根据ID获取减免记录
* @param id
* @param keyWord
* @return
*/
SltAgreementReduce getInfo(Long id, String keyWord);
}

View File

@ -18,4 +18,11 @@ public interface ISltReocrdQueryService {
* @return
*/
List<SltAgreementInfo> getList(SltAgreementInfo bean);
/**
* 根据条件获取结算记录
* @param bean
* @return
*/
List<SltAgreementInfo> getAppList(SltAgreementInfo bean);
}

View File

@ -1,5 +1,6 @@
package com.bonus.material.record.service.impl;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.material.record.mapper.DerateRecordQueryMapper;
import com.bonus.material.record.mapper.SltRecordQueryMapper;
import com.bonus.material.record.service.IDerateReocrdQueryService;
@ -35,4 +36,27 @@ public class DerateRecordQueryServiceImpl implements IDerateReocrdQueryService {
return 0;
}
}
@Override
public SltAgreementReduce getInfo(Long id, String keyWord) {
try {
//先根据Id查询apply信息
SltAgreementReduce info = mapper.getInfo(id);
if (info != null && info.getId() != null) {
//查询附件
List<BmFileInfo> bmFileInfos= mapper.getBmFileInfos(info);
if (bmFileInfos != null && bmFileInfos.size() > 0){
info.setBmFileInfos(bmFileInfos);
}
//查询详情
List<SltAgreementReduce> detailList = mapper.getDetailList(id);
if (detailList != null && detailList.size() > 0){
info.setDetailList(detailList);
}
}
return info;
} catch (Exception e) {
return new SltAgreementReduce();
}
}
}

View File

@ -3,10 +3,13 @@ package com.bonus.material.record.service.impl;
import com.bonus.material.record.mapper.SltRecordQueryMapper;
import com.bonus.material.record.service.ISltReocrdQueryService;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.settlement.domain.vo.SltInfoVo;
import com.bonus.material.settlement.service.ISltAgreementInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
/**
@ -19,13 +22,31 @@ public class SltRecordQueryServiceImpl implements ISltReocrdQueryService {
@Resource
private SltRecordQueryMapper mapper;
@Autowired
private ISltAgreementInfoService sltAgreementInfoService;
@Override
public List<SltAgreementInfo> getList(SltAgreementInfo bean) {
return mapper.getList(bean);
}
@Override
public List<SltAgreementInfo> getAppList(SltAgreementInfo bean) {
List<SltAgreementInfo> list = mapper.getList(bean);
if (list.size()>0){
for (SltAgreementInfo sltAgreementInfo : list) {
if (sltAgreementInfo.getAgreementId()!=null){
//todo 后面优化
SltInfoVo beans = sltAgreementInfoService.getSltRecordDetailsList(sltAgreementInfo);
if (beans!=null){
sltAgreementInfo.setLeaseCost(beans.getLeaseCost());
sltAgreementInfo.setRepairCost(beans.getRepairCost());
sltAgreementInfo.setScrapCost(beans.getScrapCost());
sltAgreementInfo.setLoseCost(beans.getLoseCost());
sltAgreementInfo.setReductionCost(beans.getReductionCost());
BigDecimal totalCostAll = beans.getLeaseCost().add(beans.getLoseCost()).add(beans.getRepairCost()).add(beans.getScrapCost()).subtract(beans.getReductionCost());
sltAgreementInfo.setTotalCostAll(totalCostAll);
}
}
}
}

View File

@ -262,7 +262,8 @@ public class SltAgreementInfoController extends BaseController {
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);
List<String> headersReduction = receiveDetailsHeader(5,1);
HSSFWorkbook workbook = PoiOutPage.excelForcheckAll(resultsLease,resultsLose,resultsRepair,resultsScrap,resultsReduction, headersLease,headersLose,headersRepair,headersScrap,headersReduction, filename,projectName,unitName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap,totalCostReduction);
OutputStream out = null;
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.addHeader("Content-Disposition",
@ -287,15 +288,28 @@ public class SltAgreementInfoController extends BaseController {
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));
if (flag==0){
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("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("typeName", bean.getTypeName());
@ -313,6 +327,7 @@ public class SltAgreementInfoController extends BaseController {
maps.put("t2", "");
maps.put("t3", "");
maps.put("t4", "");
maps.put("t5", "");
}
}else if(type==3){
if(flag==0){
@ -332,6 +347,7 @@ public class SltAgreementInfoController extends BaseController {
maps.put("t1", "");
maps.put("t2", "");
maps.put("t3", "");
maps.put("t4", "");
}
}else if(type==4){
if(flag==0){
@ -356,14 +372,14 @@ public class SltAgreementInfoController extends BaseController {
} else if(type==5){
maps.put("typeName", bean.getTypeName());
maps.put("modelName", bean.getModelName());
maps.put("mtUnitName", bean.getMtUnitName());
maps.put("mtUnitName", bean.getUnitName());
maps.put("leasePrice", bean.getLeasePrice());
maps.put("num", bean.getNum());
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("costs", bean.getCosts().setScale(2, RoundingMode.HALF_UP));
maps.put("leaseDays", bean.getDays());
maps.put("remark", bean.getRemark());
maps.put("costs", bean.getLeaseMoney().setScale(2, RoundingMode.HALF_UP));
}
return maps;
}
@ -378,15 +394,28 @@ public class SltAgreementInfoController extends BaseController {
// list.add("结算单位");
// list.add("结算工程");
list.add("设备名称");
list.add("规格型号");
list.add("计量单位");
list.add("租赁单价");
list.add("租赁数量");
list.add("租赁日期");
list.add("归还日期");
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("租赁费用(元)");
}else {
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("设备名称");
@ -404,7 +433,7 @@ public class SltAgreementInfoController extends BaseController {
list.add(" ");
list.add(" ");
list.add(" ");
list.add(" ");
}
}else if(type==3){
@ -425,6 +454,7 @@ public class SltAgreementInfoController extends BaseController {
list.add("");
list.add("");
list.add("");
list.add(" ");
}
}else if(type==4){
if(flag==0){
@ -444,7 +474,19 @@ public class SltAgreementInfoController extends BaseController {
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("减免费用(元)");
}
return list;
}
@ -597,7 +639,7 @@ public class SltAgreementInfoController extends BaseController {
}
}
List<SltLeaseInfo> repair = Convert.toList(SltLeaseInfo.class, reductionList);
expOutExcel(response,repair,fileName,projectName,unitName,reductionCost,3);
expOutExcel(response,repair,fileName,projectName,unitName,reductionCost,5);
} catch (Exception e) {
log.error(e.toString(), e);
}
@ -672,7 +714,7 @@ public class SltAgreementInfoController extends BaseController {
@PostMapping("/exportAll")
public void exportAll(HttpServletResponse response, SltAgreementInfo sltAgreementInfo) {
try {
String fileName = "结算明细";
String fileName = "结算费用明细";
String projectName = sltAgreementInfo.getProjectName();
String unitName = sltAgreementInfo.getUnitName();

View File

@ -109,4 +109,19 @@ public class SltAgreementReduceController extends BaseController {
return error("系统错误, " + e.getMessage());
}
}
/**
* 修改减免申请
*/
@ApiOperation(value = "修改减免申请")
@SysLog(title = "减免申请记录查询", businessType = OperaType.UPDATE, logType = 1,module = "减免申请记录查询->修改减免申请")
@PostMapping("/editApply")
public AjaxResult editApply( @RequestBody SltAgreementReduce sltAgreement) {
try {
return sltAgreementReduceService.editApply(sltAgreement);
} catch (Exception e) {
return error("修改失败");
}
}
}

View File

@ -221,4 +221,13 @@ public class SltAgreementInfo extends BaseEntity {
private Integer isApp;
private BigDecimal leaseCost;
private BigDecimal repairCost;
private BigDecimal scrapCost;
private BigDecimal loseCost;
private BigDecimal reductionCost;
//结算费用
private BigDecimal totalCostAll;
}

View File

@ -123,7 +123,14 @@ public class SltAgreementReduce extends BaseEntity {
private List<SltAgreementReduce> detailList;
private String typeName;
private String modeName;
private String modelName;
private Integer unitId;
private String unitName;
private Integer proId;
private String projectName;
}

View File

@ -106,6 +106,8 @@ public class SltLeaseInfo extends BaseEntity {
@ApiModelProperty(value = "租赁费用")
private BigDecimal costs;
private BigDecimal leaseMoney;
/** 机具id */
@ApiModelProperty(value = "机具id")
@ -135,8 +137,9 @@ public class SltLeaseInfo extends BaseEntity {
@ApiModelProperty(value = "原值")
private BigDecimal buyPrice;
/** 是否结算 */
private BigDecimal reduceNum;
/** 是否结算 */
@ApiModelProperty(value = "是否结算")
private String isSlt;
@ -165,6 +168,8 @@ public class SltLeaseInfo extends BaseEntity {
@ApiModelProperty(value = "租赁天数")
private Long leaseDay;
private Long days;
@ApiModelProperty(value = "往来单位id")
private Long unitId;

View File

@ -38,4 +38,18 @@ public interface SltAgreementReduceMapper {
* @return
*/
List<SltAgreementReduce> getReductionList(SltAgreementReduce bean);
/**
* 根据Id删除减免明细
* @param id
* @return
*/
int deleteReduceDetail(Long id);
/**
* 修改减免申请
* @param sltAgreement
* @return
*/
Long updateReduce(SltAgreementReduce sltAgreement);
}

View File

@ -22,4 +22,11 @@ public interface ISltAgreementReduceService {
List<SltAgreementReduce> selectByMatype(SltAgreementReduce sltAgreement);
List<SltAgreementReduce> selectByMaModel(SltAgreementReduce sltAgreement);
/**
* 修改减免申请
* @param sltAgreement
* @return
*/
AjaxResult editApply(SltAgreementReduce sltAgreement);
}

View File

@ -2,6 +2,7 @@ package com.bonus.material.settlement.service.impl;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.settlement.domain.SltAgreementReduce;
import com.bonus.material.settlement.mapper.SltAgreementReduceMapper;
@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
@ -62,6 +64,7 @@ public class SltAgreementReduceServiceImpl implements ISltAgreementReduceService
}
if(list != null){
sltAgreement.setCreator(SecurityUtils.getUserId().toString());
Long rs = sltAgreementRecudceMapper.insertReduce(sltAgreement);
Long id = sltAgreement.getId();
AtomicBoolean addFileInfoResult = new AtomicBoolean(false);
@ -111,6 +114,61 @@ public class SltAgreementReduceServiceImpl implements ISltAgreementReduceService
return sltAgreementRecudceMapper.selectByMaModel(sltAgreement);
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult editApply(SltAgreementReduce sltAgreement) {
try {
//先删除详情表和附件表数据
sltAgreementRecudceMapper.deleteReduceDetail(sltAgreement.getId());
List<SltAgreementReduce> list = sltAgreement.getDetailList();
// 初始化 SltAgreementReduce 对象
initSltAgreement(sltAgreement);
List<SltAgreementReduce> applyReduction = applyReduction(sltAgreement);
if (applyReduction.size() > 0 && applyReduction!= null) {
list = applyReduction;
}else{
list = null;
}
if(list != null){
Long rs = sltAgreementRecudceMapper.updateReduce(sltAgreement);
Long id = sltAgreement.getId();
AtomicBoolean addFileInfoResult = new AtomicBoolean(false);
if(sltAgreement.getBmFileInfos()!=null){
sltAgreement.getBmFileInfos().forEach(bmFileInfo -> {
bmFileInfo.setModelId(id);
bmFileInfo.setCreateTime(DateUtils.getNowDate());
addFileInfoResult.set(bmFileInfoMapper.insertBmFileInfo(bmFileInfo) > 0);
});
}
if (list != null) {
// 批量插入明细
List<SltAgreementReduce> detailList = list.stream()
.peek(detail -> detail.setId(id))
.collect(Collectors.toList());
sltAgreementRecudceMapper.insertBatchReduceDetail(detailList);
}
}else{
//回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.warn("检索历史申请减免区间数据,已申请减免,请勿在提交申请单!");
}
return AjaxResult.success();
} catch (DataAccessException e) {
// 记录详细的数据库操作异常日志
log.error("数据库操作失败: {}", e.getMessage(), e);
return AjaxResult.error("系统错误, 数据库操作失败");
} catch (Exception e) {
// 记录其他异常日志
log.error("系统错误: {}", e.getMessage(), e);
return AjaxResult.error("系统错误, " + e.getMessage());
}
}
private void initSltAgreement(SltAgreementReduce sltAgreement) {
sltAgreement.setCode(generateCode());
sltAgreement.setCreateTime(new Date());

View File

@ -33,6 +33,7 @@
<result property="leaseProjectId" column="project_id"/>
<result property="leaseUnit" column="unit_name"/>
<result property="leaseUnitId" column="unit_id"/>
<result property="agreementId" column="agreement_id"/>
<result property="agreementCode" column="agreement_code"/>
<result property="leaseSignUrl" column="lease_sign_url"/>
<result property="leaseSignType" column="lease_sign_type"/>
@ -109,7 +110,7 @@
lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id,
lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url,
lai.lease_sign_type,
bai.unit_id,bai.project_id,bu.unit_name, bp.pro_name, bai.agreement_code, tt.task_status as taskStatus,
bai.unit_id,bai.project_id,bu.unit_name, bp.pro_name,bai.agreement_id, bai.agreement_code, tt.task_status as taskStatus,
case tt.task_status
when 0 then '待审核'
when 1 then '待审核'

View File

@ -63,6 +63,7 @@
DATE(sai.start_time) as startTime,
sai.ma_id as maId,
sai.type_id as typeId,
lai.create_time as createTime,
sai.*
FROM
slt_agreement_info sai
@ -77,9 +78,14 @@
<if test="maId != null">
and mt.parent_id = #{maId}
</if>
<if test="startDate != null and endDate != ''">
AND DATE_FORMAT(lai.create_time, '%Y-%m-%d' ) BETWEEN #{startDate} AND #{endDate}
</if>
<if test="keyWord != null and keyWord != ''">
and (mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%'))
mt.type_name like concat('%', #{keyWord}, '%') or
mt.ma_code like concat('%', #{keyWord}, '%')
)
</if>
GROUP BY
sai.ma_id,sai.type_id

View File

@ -36,10 +36,10 @@
where 1=1
<if test="startTime != null and endTime != ''">
AND sra.create_time BETWEEN #{startTime} AND #{endTime}
AND DATE_FORMAT(sra.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if>
<if test="startDate != null and endDate != ''">
AND sra.create_time BETWEEN #{startDate} AND #{endDate}
AND DATE_FORMAT(sra.create_time, '%Y-%m-%d' ) BETWEEN #{startDate} AND #{endDate}
</if>
<if test="keyWord != null and keyWord != ''">
AND (
@ -57,6 +57,56 @@
GROUP BY sra.id
ORDER BY sra.create_time DESC
</select>
<select id="getInfo" resultType="com.bonus.material.settlement.domain.SltAgreementReduce">
SELECT sra.id,
sra.agreement_id as agreementId,
sra.r_start_time as reduceStartTime,
sra.r_end_time as reduceEndTime,
sra.remark,
bp.pro_id as proId,
bp.pro_name as projectName,
bu.unit_id as unitId,
bu.unit_name as unitName
FROM slt_reduce_apply sra
LEFT JOIN bm_agreement_info bai ON sra.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bu ON bu.unit_id = bai.unit_id
where sra.id = #{id}
</select>
<select id="getBmFileInfos" resultType="com.bonus.common.biz.domain.BmFileInfo">
select id,
task_type as taskType,
task_id as taskId,
model_id as modelId,
name,
url,
file_type as fileType,
create_by as createBy,
create_time as createTime
from bm_file_info
where model_id = #{id}
</select>
<select id="getDetailList" resultType="com.bonus.material.settlement.domain.SltAgreementReduce">
SELECT
srd.reduce_num as reduceNum,
mt2.type_name as maName,
mt.type_name as maModel,
srd.type_id as typeId,
srd.num,
srd.start_time as startTime,
srd.end_time as endTime,
srd.lease_price as leasePrice,
srd.days as reduceDays,
srd.lease_money as reduceLeaseMoney,
srd.r_start_time as reduceStartTime,
srd.r_end_time as reduceEndTime
FROM
slt_reduce_details srd
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
srd.apply_id=#{id}
</select>
<delete id="delData">

View File

@ -30,6 +30,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, code, creator, create_time, update_time, status, company_id, cost, remark from slt_reduce_apply
</sql>
<delete id="deleteReduceDetail">
delete
from slt_reduce_details
where apply_id = #{id};
delete
from bm_file_info
where model_id = #{id}
</delete>
<select id="selectSltAgreementReduceList" parameterType="com.bonus.material.settlement.domain.SltAgreementReduce" resultMap="SltAgreementReudceResult">
<include refid="selectSltAgreementReduceVo"/>
<where>
@ -118,6 +127,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="companyId != null">company_id,</if>
<if test="cost != null">cost,</if>
<if test="remark != null">remark,</if>
<if test="reduceStartTime != null">r_start_time,</if>
<if test="reduceEndTime != null">r_end_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">#{code},</if>
@ -128,10 +139,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="companyId != null">#{companyId},</if>
<if test="cost != null">#{cost},</if>
<if test="remark != null">#{remark},</if>
<if test="reduceStartTime != null">#{reduceStartTime},</if>
<if test="reduceEndTime != null">#{reduceEndTime},</if>
</trim>
</insert>
<update id="updateReduce">
update slt_reduce_apply
set
<if test="code != null">code = #{code},</if>
<if test="agreementId != null">agreement_id=#{agreementId},</if>
<if test="status != null">status=#{status},</if>
<if test="companyId != null">company_id=#{companyId},</if>
<if test="remark != null">remark=#{remark},</if>
<if test="reduceStartTime != null">r_start_time=#{reduceStartTime},</if>
<if test="reduceEndTime != null">r_end_time=#{reduceEndTime},</if>
update_time = now()
where id = #{id}
</update>
<insert id="insertReduceDetail">
insert into slt_reduce_details
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -235,7 +262,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</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 modeName,
mt.type_name as modelName,
mt.unit_name as unitName,
srd.lease_price as leasePrice,
srd.reduce_num as reduceNum,