diff --git a/src/main/java/cn/palmte/work/controller/backend/ProjectController.java b/src/main/java/cn/palmte/work/controller/backend/ProjectController.java index 4c4dbe4..3e2f4d8 100644 --- a/src/main/java/cn/palmte/work/controller/backend/ProjectController.java +++ b/src/main/java/cn/palmte/work/controller/backend/ProjectController.java @@ -605,15 +605,15 @@ public class ProjectController extends BaseController { public ResponseMsg budgetEditSaveBudgetPayPlan(@RequestBody String body) { JSONObject jsonObject = JSON.parseObject(body); JSONArray details = jsonObject.getJSONArray(DETAILS); - List detailList = new ArrayList<>(details.size()); + List detailList = new ArrayList<>(details.size()); for (int i = 0; i < details.size(); i++) { - ProjectBudgetPayPlan detail = details.getObject(i, ProjectBudgetPayPlan.class); + ProjectBudgetPayPlanTemp detail = details.getObject(i, ProjectBudgetPayPlanTemp.class); detailList.add(detail); } Project project = projectService.getProject(jsonObject.getInteger(PROJECT_ID)); - projectBudgetService.saveBudgetPayPlan(project, detailList); + projectBudgetService.saveBudgetPayPlanTemp(project, detailList); return ResponseMsg.buildSuccessMsg("成功"); } @@ -1254,8 +1254,8 @@ public class ProjectController extends BaseController { //收入明细 List budgetIncomeDetail = projectBudgetService.getBudgetIncomeDetail(project); BigDecimal incomeTotalAmount = projectBudgetService.getBudgetIncomeAmount(project); - String[] headers2 = {"序号", "类别", "名称", "规格类型", "参数", "单位", "数量", "单价", "税率(%)", "含税总金额(元)", "不含税金额(元)", "税金(元)"}; - String[] columns2 = {"tempId", "type", "name", "spec", "param", "unit", "amount", "price", "taxRate", "totalTaxInclude", "totalTaxExclude", "totalTax"}; + String[] headers2 = {"序号", "产品大类", "名称", "税率(%)", "含税总金额(元)", "不含税金额(元)", "税金(元)"}; + String[] columns2 = {"tempId", "type", "name", "taxRate", "totalTaxInclude", "totalTaxExclude", "totalTax"}; exportExcelUtils.exportIncomeDetailExcel(headers2, columns2, project, budgetBean, budgetIncomeDetail, incomeTotalAmount, "yyyy-MM-dd", 0, "收入明细表", outputStream); exportExcelUtils.end(outputStream); @@ -1302,8 +1302,8 @@ public class ProjectController extends BaseController { BigDecimal costPayAmountTotal = projectBudgetService.getBudgetCostPayAmountTotal(project); List procurementTypes = procurementTypeService.allProcurementTypeList(); Map procurementMap = procurementTypes.stream().collect(Collectors.toMap(ProcurementType::getId, ProcurementType::getName)); - String[] headers3 = {"序号", "费用项目", "采购类别", "名称", "单位", "数量", "单价", "税率(%)", "含税总金额(元)", "不含税金额(元)", "税金(元)", "签约方", "是否垫资", "预估垫资金额(元)", "支出时间", "支出金额(元)", "付款方式", "备注"}; - String[] columns3 = {"tempId", "type", "category", "name", "unit", "amount", "price", "taxRate", "totalTaxInclude", "totalTaxExclude", "totalTax", "contractParty", "isUnderwritten", "underwrittenAmount", "payTime", "payAmount", "payWay", "remark"}; + String[] headers3 = {"序号", "采购成本项目", "产品大类", "税率(%)", "含税总金额(元)", "不含税金额(元)", "税金(元)", "供应商", "备注"}; + String[] columns3 = {"tempId", "type", "category", "taxRate", "totalTaxInclude", "totalTaxExclude", "totalTax", "contractParty", "remark"}; exportExcelUtils.exportCostDetailExcel(headers3, columns3, project, budgetBean, budgetCostDetail, costTotalAmount, costUnderwrittenAmountTotal, costPayAmountTotal, procurementMap, "yyyy-MM-dd", 0, "采购成本明细表", outputStream); exportExcelUtils.end(outputStream); @@ -1325,8 +1325,8 @@ public class ProjectController extends BaseController { List budgetCostProjectManageDetail = projectBudgetService.getBudgetCostProjectManageDetail(project); BigDecimal costProjectManageTotalAmount = projectBudgetService.getBudgetCostProjectManageAmount(project); BigDecimal managePayAmountTotal = projectBudgetService.getBudgetCostProjectManagePayAmount(project); - String[] headers4 = {"序号", "财务费用类别", "业务项目", "项目明细", "单位", "数量", "单价", "总金额(元)", "支出时间", "支出金额(元)", "预估计算方法", "预估依据", "备注"}; - String[] columns4 = {"tempId", "type", "name", "detail", "unit", "amount", "price", "total", "payTime", "payAmount", "predictMethod", "predictWhy", "remark"}; + String[] headers4 = {"序号", "费用类别", "业务项目", "项目明细", "总金额(元)", "支出时间", "支出金额(元)", "预估计算方法", "预估依据", "备注"}; + String[] columns4 = {"tempId", "type", "name", "detail", "total", "payTime", "payAmount", "predictMethod", "predictWhy", "remark"}; exportExcelUtils.exportCostManageDetailExcel(headers4, columns4, project, budgetBean, budgetCostProjectManageDetail, costProjectManageTotalAmount, managePayAmountTotal, "yyyy-MM-dd", 0, "项目管理成本表", outputStream); exportExcelUtils.end(outputStream); diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetPayPlanTemp.java b/src/main/java/cn/palmte/work/model/ProjectBudgetPayPlanTemp.java new file mode 100644 index 0000000..17aaf00 --- /dev/null +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetPayPlanTemp.java @@ -0,0 +1,19 @@ +package cn.palmte.work.model; + +import org.springframework.beans.BeanUtils; + +import javax.persistence.Entity; +import javax.persistence.Table; + +/** + * 项目付款计划表 + */ +@Entity +@Table(name = "project_budget_pay_plan_temp") +public class ProjectBudgetPayPlanTemp extends ProjectBudgetPayPlanBase { + public ProjectBudgetPayPlan toProjectBudgetPayPlanDetail() { + ProjectBudgetPayPlan projectBudgetPayPlan = new ProjectBudgetPayPlan(); + BeanUtils.copyProperties(this, projectBudgetPayPlan); + return projectBudgetPayPlan; + } +} \ No newline at end of file diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetPayPlanTempRepository.java b/src/main/java/cn/palmte/work/model/ProjectBudgetPayPlanTempRepository.java new file mode 100644 index 0000000..e527afb --- /dev/null +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetPayPlanTempRepository.java @@ -0,0 +1,10 @@ +package cn.palmte.work.model; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface ProjectBudgetPayPlanTempRepository extends JpaRepository { + List findAllByProjectIdEquals(int id); + +} diff --git a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java index 7994279..8740341 100644 --- a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java +++ b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java @@ -13,7 +13,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import top.jfunc.common.utils.CollectionUtil; -import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; @@ -41,6 +40,8 @@ public class ProjectBudgetService { @Autowired private ProjectBudgetPayPlanRepository projectBudgetPayPlanRepository; @Autowired + private ProjectBudgetPayPlanTempRepository projectBudgetPayPlanTempRepository; + @Autowired private ProjectBudgetIncomePlanDetailTempRepository projectBudgetIncomePlanDetailTempRepository; @Autowired private ProjectBudgetCostDetailRepository projectBudgetCostDetailRepository; @@ -1105,6 +1106,14 @@ public class ProjectBudgetService { .collect(Collectors.toList()); projectBudgetCostDetailRepository.save(costDetails); } + //付款计划表 + List projectBudgetPayPlanTemps = projectBudgetPayPlanTempRepository.findAllByProjectIdEquals(p.getId()); + if(CollectionUtil.isNotEmpty(projectBudgetPayPlanTemps)){ + List costDetails = projectBudgetPayPlanTemps.stream() + .map(ProjectBudgetPayPlanTemp::toProjectBudgetPayPlanDetail) + .collect(Collectors.toList()); + projectBudgetPayPlanRepository.save(costDetails); + } //项目管理明细 List projectBudgetCostProjectManageDetailTemps = projectBudgetCostProjectManageDetailTempRepository.findAllByProjectIdEquals(p.getId()); if(CollectionUtil.isNotEmpty(projectBudgetCostProjectManageDetailTemps)){ @@ -1345,13 +1354,13 @@ public class ProjectBudgetService { return projectBudgetPayPlanRepository.findAllByProjectIdEquals(project.getId()); } - public void saveBudgetPayPlan(Project project, List detailList) { + public void saveBudgetPayPlanTemp(Project project, List detailList) { if(CollectionUtil.isNotEmpty(detailList)){ - for (ProjectBudgetPayPlan temp : detailList) { + for (ProjectBudgetPayPlanTemp temp : detailList) { temp.setProjectId(project.getId()); // temp.setUnderwrittenTaxRate(project.getUnderwrittenTaxRate()); } - projectBudgetPayPlanRepository.save(detailList); + projectBudgetPayPlanTempRepository.save(detailList); } } } diff --git a/src/main/java/cn/palmte/work/utils/excel/ExportExcelUtils.java b/src/main/java/cn/palmte/work/utils/excel/ExportExcelUtils.java index ec94315..6243552 100644 --- a/src/main/java/cn/palmte/work/utils/excel/ExportExcelUtils.java +++ b/src/main/java/cn/palmte/work/utils/excel/ExportExcelUtils.java @@ -7,18 +7,14 @@ import cn.palmte.work.utils.ObjectKit; import cn.palmte.work.utils.Utils; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.*; -import org.apache.poi.xssf.streaming.SXSSFSheet; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import top.jfunc.common.db.bean.Record; import javax.servlet.ServletOutputStream; import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -196,7 +192,7 @@ public class ExportExcelUtils { index = index + 3; // 成本 Row costRow = sheet.createRow(index++); - createTitleRow(costRow, "成本"); + createTitleRow(costRow, "采购成本"); index = createCostRow(budgetBean, sheet, index, otherName, costTaxRates); index = index + 3; // 管理 @@ -363,7 +359,7 @@ public class ExportExcelUtils { createEngineerCostRow(budgetBean, sheet, index++); createServiceCostRow(budgetBean, sheet, index++); createOtherCostRow(budgetBean, sheet, index++); - createManageCostRow(budgetBean, sheet, index++); + // createManageCostRow(budgetBean, sheet, index++); createOtherRow(budgetBean, sheet, index++, otherName); createTotalCostRow(budgetBean, sheet, index++); Row row = sheet.createRow(index++); @@ -443,7 +439,7 @@ public class ExportExcelUtils { Cell thirdCell = row.createCell(2); thirdCell.setCellStyle(style2); thirdCell.setCellType(CellType.STRING); - thirdCell.setCellValue("施工"); + thirdCell.setCellValue("工程"); Cell fourthCell = row.createCell(3); fourthCell.setCellStyle(style2); fourthCell.setCellType(CellType.NUMERIC); @@ -523,23 +519,11 @@ public class ExportExcelUtils { Cell secondCell = row.createCell(1); secondCell.setCellStyle(style2); secondCell.setCellType(CellType.STRING); - secondCell.setCellValue("项目管理成本"); + secondCell.setCellValue("项目管理费用"); Cell thirdCell = row.createCell(2); thirdCell.setCellStyle(style2); thirdCell.setCellType(CellType.STRING); - thirdCell.setCellValue("项目管理成本"); - Cell fourthCell = row.createCell(3); - fourthCell.setCellStyle(style2); - fourthCell.setCellType(CellType.NUMERIC); - fourthCell.setCellValue(Utils.format(budgetBean.getCostProjectManageTaxInclude())); - Cell fifthCell = row.createCell(4); - fifthCell.setCellStyle(style2); - fifthCell.setCellType(CellType.NUMERIC); - fifthCell.setCellValue(Utils.format(budgetBean.getCostProjectManageTaxExclude())); - Cell sixthCell = row.createCell(5); - sixthCell.setCellStyle(style2); - sixthCell.setCellType(CellType.STRING); - sixthCell.setCellValue("财务计取以不含税方式核算"); + thirdCell.setCellValue(Utils.format(budgetBean.getCostProjectManageTaxExclude())); } private void createOtherRow(BudgetBean budgetBean, XSSFSheet sheet, int index, String otherName) { @@ -598,10 +582,28 @@ public class ExportExcelUtils { sixthCell.setCellValue(Utils.format(budgetBean.getCostTotalTax())); } + private void createManageTotalCostRow(BudgetBean budgetBean, XSSFSheet sheet, int index) { + Row row = sheet.createRow(index); + Cell firstCell = row.createCell(0); + firstCell.setCellStyle(style2); + firstCell.setCellType(CellType.STRING); + firstCell.setCellValue("合计"); + Cell secondCell = row.createCell(1); + secondCell.setCellStyle(style2); + secondCell.setCellType(CellType.STRING); + secondCell.setCellValue(""); + Cell thirdCell = row.createCell(2); + thirdCell.setCellStyle(style2); + thirdCell.setCellType(CellType.STRING); + thirdCell.setCellValue(Utils.format(budgetBean.getCostProjectManageTaxExclude().add(budgetBean.getCostExpropriationTaxExclude()))); + } + private int createManageRow(BudgetBean budgetBean, XSSFSheet sheet, int index) { createSubTitleManageRow(sheet, index++); createExpropriationRow(budgetBean, sheet, index++); - createCompanyManageRow(budgetBean, sheet, index++); + createManageCostRow(budgetBean, sheet, index++); + createManageTotalCostRow(budgetBean, sheet, index++); + // createCompanyManageRow(budgetBean, sheet, index++); Row row = sheet.createRow(index++); Cell remarkCell = row.createCell(0); remarkCell.setCellStyle(style); @@ -663,7 +665,7 @@ public class ExportExcelUtils { createGrossProfitARow(budgetBean, sheet, index++); createGrossProfitRow(budgetBean, sheet, index++); // createGrossProfitMarginRow(budgetBean, sheet, index++); - createContributionProfitRow(budgetBean, sheet, index++); +// createContributionProfitRow(budgetBean, sheet, index++); // createContributionProfitRateRow(budgetBean, sheet, index++); return index; } @@ -706,7 +708,7 @@ public class ExportExcelUtils { Cell fourthCell = row.createCell(3); fourthCell.setCellStyle(style2); fourthCell.setCellType(CellType.STRING); - fourthCell.setCellValue("毛利=收入总计(不含税)-成本总计(不含税)"); + fourthCell.setCellValue("项目毛利A=收入合计(不含税)-采购成本合计(不含税)"); } private void createGrossProfitRow(BudgetBean budgetBean, XSSFSheet sheet, int index) { @@ -714,7 +716,7 @@ public class ExportExcelUtils { Cell firstCell = row.createCell(0); firstCell.setCellStyle(style2); firstCell.setCellType(CellType.STRING); - firstCell.setCellValue("项目毛利(元)"); + firstCell.setCellValue("项目毛利B(元)"); Cell secondCell = row.createCell(1); secondCell.setCellStyle(style2); secondCell.setCellType(CellType.NUMERIC); @@ -722,11 +724,11 @@ public class ExportExcelUtils { Cell thirdCell = row.createCell(2); thirdCell.setCellStyle(style2); thirdCell.setCellType(CellType.NUMERIC); - thirdCell.setCellValue(Utils.format(budgetBean.getProjectGrossProfit())); + thirdCell.setCellValue(Utils.format(budgetBean.getProjectGrossProfitA().subtract(budgetBean.getCostProjectManageTaxExclude()).subtract(budgetBean.getCostExpropriationTaxExclude()))); Cell fourthCell = row.createCell(3); fourthCell.setCellStyle(style2); fourthCell.setCellType(CellType.STRING); - fourthCell.setCellValue("毛利=收入总计(不含税)-成本总计(不含税)-财务费用总计(不含税)"); + fourthCell.setCellValue("项目毛利B=项目毛利A-财务费用-项目管理费用"); } // private void createGrossProfitMarginRow(BudgetBean budgetBean, XSSFSheet sheet, int index) { @@ -1375,13 +1377,10 @@ public class ExportExcelUtils { if (i == 0) { totalCell.setCellType(CellType.STRING); totalCell.setCellValue("总计"); - } else if (i == 5) { - totalCell.setCellType(CellType.NUMERIC); - totalCell.setCellValue(Utils.format(costProjectManageTotalAmount)); - } else if (i == 7) { + } else if (i == 4) { totalCell.setCellType(CellType.NUMERIC); totalCell.setCellValue(Utils.format(budgetBean.getCostProjectManageTaxExclude())); - } else if (i == 9) { + } else if (i == 6) { totalCell.setCellType(CellType.NUMERIC); totalCell.setCellValue(Utils.format(managePayAmountTotal)); } else {