mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-08 14:44:57 +08:00
[feat] 新增历史预算管理功能
This commit is contained in:
parent
e166428f5e
commit
d9c2bc5ce6
@ -24,6 +24,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo.*;
|
import cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo.*;
|
||||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDO;
|
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDO;
|
||||||
@ -38,27 +39,12 @@ public class BudgetHistoryController {
|
|||||||
@Resource
|
@Resource
|
||||||
private BudgetHistoryService budgetHistoryService;
|
private BudgetHistoryService budgetHistoryService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@Operation(summary = "创建历史预算管理")
|
|
||||||
@PreAuthorize("@ss.hasPermission('pms:budget-history:create')")
|
|
||||||
public CommonResult<Long> createBudgetHistory(@Valid @RequestBody BudgetHistorySaveReqVO createReqVO) {
|
|
||||||
return success(budgetHistoryService.createBudgetHistory(createReqVO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新历史预算管理")
|
@Operation(summary = "更新历史预算管理")
|
||||||
@PreAuthorize("@ss.hasPermission('pms:budget-history:update')")
|
@PreAuthorize("@ss.hasPermission('pms:budget-history:update')")
|
||||||
public CommonResult<Boolean> updateBudgetHistory(@Valid @RequestBody BudgetHistorySaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateBudgetHistory(@Valid @RequestBody BudgetHistorySaveReqVO updateReqVO) {
|
||||||
budgetHistoryService.updateBudgetHistory(updateReqVO);
|
budgetHistoryService.updateBudgetHistory(getLoginUserId(), updateReqVO);
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
|
||||||
@Operation(summary = "删除历史预算管理")
|
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
|
||||||
@PreAuthorize("@ss.hasPermission('pms:budget-history:delete')")
|
|
||||||
public CommonResult<Boolean> deleteBudgetHistory(@RequestParam("id") Long id) {
|
|
||||||
budgetHistoryService.deleteBudgetHistory(id);
|
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,16 +53,16 @@ public class BudgetHistoryController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('pms:budget-history:query')")
|
@PreAuthorize("@ss.hasPermission('pms:budget-history:query')")
|
||||||
public CommonResult<BudgetHistoryRespVO> getBudgetHistory(@RequestParam("id") Long id) {
|
public CommonResult<BudgetHistoryRespVO> getBudgetHistory(@RequestParam("id") Long id) {
|
||||||
BudgetHistoryDO budgetHistory = budgetHistoryService.getBudgetHistory(id);
|
BudgetHistoryRespVO budgetHistory = budgetHistoryService.getBudgetHistory(id);
|
||||||
return success(BeanUtils.toBean(budgetHistory, BudgetHistoryRespVO.class));
|
return success(budgetHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得历史预算管理分页")
|
@Operation(summary = "获得历史预算管理分页")
|
||||||
@PreAuthorize("@ss.hasPermission('pms:budget-history:query')")
|
@PreAuthorize("@ss.hasPermission('pms:budget-history:query')")
|
||||||
public CommonResult<PageResult<BudgetHistoryRespVO>> getBudgetHistoryPage(@Valid BudgetHistoryPageReqVO pageReqVO) {
|
public CommonResult<PageResult<BudgetHistoryRespVO>> getBudgetHistoryPage(@Valid BudgetHistoryPageReqVO pageReqVO) {
|
||||||
PageResult<BudgetHistoryDO> pageResult = budgetHistoryService.getBudgetHistoryPage(pageReqVO);
|
PageResult<BudgetHistoryRespVO> pageResult = budgetHistoryService.getBudgetHistoryPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, BudgetHistoryRespVO.class));
|
return success(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@ -86,7 +72,7 @@ public class BudgetHistoryController {
|
|||||||
public void exportBudgetHistoryExcel(@Valid BudgetHistoryPageReqVO pageReqVO,
|
public void exportBudgetHistoryExcel(@Valid BudgetHistoryPageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<BudgetHistoryDO> list = budgetHistoryService.getBudgetHistoryPage(pageReqVO).getList();
|
List<BudgetHistoryRespVO> list = budgetHistoryService.getBudgetHistoryPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "历史预算管理.xls", "数据", BudgetHistoryRespVO.class,
|
ExcelUtils.write(response, "历史预算管理.xls", "数据", BudgetHistoryRespVO.class,
|
||||||
BeanUtils.toBean(list, BudgetHistoryRespVO.class));
|
BeanUtils.toBean(list, BudgetHistoryRespVO.class));
|
||||||
|
@ -13,6 +13,55 @@ import com.alibaba.excel.annotation.*;
|
|||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class BudgetHistoryRespVO {
|
public class BudgetHistoryRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "跟踪项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS24001")
|
||||||
|
@ExcelProperty("跟踪项目编号")
|
||||||
|
private String trackingProjectCode;
|
||||||
|
|
||||||
|
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SJ24001")
|
||||||
|
@ExcelProperty("项目编号")
|
||||||
|
private String projectCode;
|
||||||
|
|
||||||
|
@Schema(description = "跟踪项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "规划一路道路工程")
|
||||||
|
@ExcelProperty("跟踪项目名称")
|
||||||
|
private String trackingProjectName;
|
||||||
|
|
||||||
|
@Schema(description = "项目类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "设计")
|
||||||
|
@ExcelProperty("项目类型")
|
||||||
|
private String projectType;
|
||||||
|
|
||||||
|
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED,example = "200.0000")
|
||||||
|
@ExcelProperty("预计合同金额")
|
||||||
|
private BigDecimal expectedContractAmount;
|
||||||
|
|
||||||
|
@Schema(description = "暂定结算数")
|
||||||
|
@ExcelProperty("暂定结算数")
|
||||||
|
private BigDecimal provisionalSettlement;
|
||||||
|
|
||||||
|
@Schema(description = "包干/审定金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("包干/审定金额")
|
||||||
|
private BigDecimal approvedAmount;
|
||||||
|
|
||||||
|
@Schema(description = "外包合同金额")
|
||||||
|
@ExcelProperty("外包合同金额")
|
||||||
|
private BigDecimal outAmount;
|
||||||
|
|
||||||
|
@Schema(description = "有效合同金额")
|
||||||
|
@ExcelProperty("有效合同金额")
|
||||||
|
private BigDecimal validContractAmount;
|
||||||
|
|
||||||
|
@Schema(description = "预估利润率")
|
||||||
|
@ExcelProperty("预估利润率")
|
||||||
|
private BigDecimal estimatedProfitMargin;
|
||||||
|
|
||||||
|
@Schema(description = "实际利润率")
|
||||||
|
@ExcelProperty("实际利润率")
|
||||||
|
private BigDecimal realProfitMargin;
|
||||||
|
|
||||||
|
@Schema(description = "利润预警")
|
||||||
|
@ExcelProperty("利润预警")
|
||||||
|
private String profitWarning;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2972")
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2972")
|
||||||
@ExcelProperty("主键")
|
@ExcelProperty("主键")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo;
|
package cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -10,6 +11,55 @@ import java.math.BigDecimal;
|
|||||||
@Data
|
@Data
|
||||||
public class BudgetHistorySaveReqVO {
|
public class BudgetHistorySaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "跟踪项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS24001")
|
||||||
|
@ExcelProperty("跟踪项目编号")
|
||||||
|
private String trackingProjectCode;
|
||||||
|
|
||||||
|
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SJ24001")
|
||||||
|
@ExcelProperty("项目编号")
|
||||||
|
private String projectCode;
|
||||||
|
|
||||||
|
@Schema(description = "跟踪项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "规划一路道路工程")
|
||||||
|
@ExcelProperty("跟踪项目名称")
|
||||||
|
private String trackingProjectName;
|
||||||
|
|
||||||
|
@Schema(description = "项目类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "设计")
|
||||||
|
@ExcelProperty("项目类型")
|
||||||
|
private String projectType;
|
||||||
|
|
||||||
|
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED,example = "200.0000")
|
||||||
|
@ExcelProperty("预计合同金额")
|
||||||
|
private BigDecimal expectedContractAmount;
|
||||||
|
|
||||||
|
@Schema(description = "暂定结算数")
|
||||||
|
@ExcelProperty("暂定结算数")
|
||||||
|
private BigDecimal provisionalSettlement;
|
||||||
|
|
||||||
|
@Schema(description = "包干/审定金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("包干/审定金额")
|
||||||
|
private BigDecimal approvedAmount;
|
||||||
|
|
||||||
|
@Schema(description = "外包合同金额")
|
||||||
|
@ExcelProperty("外包合同金额")
|
||||||
|
private BigDecimal outAmount;
|
||||||
|
|
||||||
|
@Schema(description = "有效合同金额")
|
||||||
|
@ExcelProperty("有效合同金额")
|
||||||
|
private BigDecimal validContractAmount;
|
||||||
|
|
||||||
|
@Schema(description = "预估利润率")
|
||||||
|
@ExcelProperty("预估利润率")
|
||||||
|
private BigDecimal estimatedProfitMargin;
|
||||||
|
|
||||||
|
@Schema(description = "实际利润率")
|
||||||
|
@ExcelProperty("实际利润率")
|
||||||
|
private BigDecimal realProfitMargin;
|
||||||
|
|
||||||
|
@Schema(description = "利润预警")
|
||||||
|
@ExcelProperty("利润预警")
|
||||||
|
private String profitWarning;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2972")
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2972")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ -14,42 +14,27 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|||||||
*/
|
*/
|
||||||
public interface BudgetHistoryService {
|
public interface BudgetHistoryService {
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建预算管理
|
|
||||||
*
|
|
||||||
* @param createReqVO 创建信息
|
|
||||||
* @return 编号
|
|
||||||
*/
|
|
||||||
Long createBudgetHistory(@Valid BudgetHistorySaveReqVO createReqVO);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新预算管理
|
* 更新预算管理
|
||||||
*
|
*
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateBudgetHistory(@Valid BudgetHistorySaveReqVO updateReqVO);
|
void updateBudgetHistory(Long loginUserId, @Valid BudgetHistorySaveReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除预算管理
|
* 获得历史预算管理
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 现有预算管理编号
|
||||||
|
* @return 历史预算管理
|
||||||
*/
|
*/
|
||||||
void deleteBudgetHistory(Long id);
|
BudgetHistoryRespVO getBudgetHistory(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得预算管理
|
* 获得历史预算管理分页
|
||||||
*
|
|
||||||
* @param id 编号
|
|
||||||
* @return 预算管理
|
|
||||||
*/
|
|
||||||
BudgetHistoryDO getBudgetHistory(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得预算管理分页
|
|
||||||
*
|
*
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 预算管理分页
|
* @return 预算管理分页
|
||||||
*/
|
*/
|
||||||
PageResult<BudgetHistoryDO> getBudgetHistoryPage(BudgetHistoryPageReqVO pageReqVO);
|
PageResult<BudgetHistoryRespVO> getBudgetHistoryPage(BudgetHistoryPageReqVO pageReqVO);
|
||||||
|
|
||||||
}
|
}
|
@ -1,10 +1,19 @@
|
|||||||
package cn.iocoder.yudao.module.pms.service.budgethistory;
|
package cn.iocoder.yudao.module.pms.service.budgethistory;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.cms.api.contract.ContractApi;
|
||||||
|
import cn.iocoder.yudao.module.cms.api.contract.dto.ContractRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.cms.api.outscontract.OutscontractApi;
|
||||||
|
import cn.iocoder.yudao.module.pms.api.project.ProjectApi;
|
||||||
|
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.pms.service.budget.BudgetService;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo.*;
|
import cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo.*;
|
||||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDO;
|
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDO;
|
||||||
@ -15,7 +24,10 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|||||||
import cn.iocoder.yudao.module.pms.dal.mysql.budgethistory.BudgetHistoryMapper;
|
import cn.iocoder.yudao.module.pms.dal.mysql.budgethistory.BudgetHistoryMapper;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.CONTRACT_HISTORY_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS;
|
||||||
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预算管理 Service 实现类
|
* 预算管理 Service 实现类
|
||||||
@ -29,30 +41,197 @@ public class BudgetHistoryServiceImpl implements BudgetHistoryService {
|
|||||||
@Resource
|
@Resource
|
||||||
private BudgetHistoryMapper budgetHistoryMapper;
|
private BudgetHistoryMapper budgetHistoryMapper;
|
||||||
|
|
||||||
@Override
|
@Resource
|
||||||
public Long createBudgetHistory(BudgetHistorySaveReqVO createReqVO) {
|
private AdminUserApi adminUserApi;
|
||||||
// 插入
|
|
||||||
BudgetHistoryDO budgetHistory = BeanUtils.toBean(createReqVO, BudgetHistoryDO.class);
|
@Resource
|
||||||
budgetHistoryMapper.insert(budgetHistory);
|
private ProjectApi projectApi;
|
||||||
// 返回
|
|
||||||
return budgetHistory.getId();
|
@Resource
|
||||||
}
|
private ContractApi contractApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OutscontractApi outscontractApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BudgetService budgetService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateBudgetHistory(BudgetHistorySaveReqVO updateReqVO) {
|
public void updateBudgetHistory(Long loginUserId, BudgetHistorySaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验
|
||||||
validateBudgetHistoryExists(updateReqVO.getId());
|
Long id = updateReqVO.getId();
|
||||||
|
validateBudgetHistoryExists(id);
|
||||||
|
if (loginUserId == null) {
|
||||||
|
throw exception(USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
Long projectId = updateReqVO.getProjectId();
|
||||||
|
Long contractId = updateReqVO.getContractId();
|
||||||
|
ProjectRespDTO project = projectApi.getProject(projectId);
|
||||||
|
ContractRespDTO contract = contractApi.getContract(contractId);
|
||||||
|
if (project == null) {
|
||||||
|
throw exception(PROJECT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
if (contract == null) {
|
||||||
|
throw exception(CONTRACT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
BudgetHistoryDO updateObj = BeanUtils.toBean(updateReqVO, BudgetHistoryDO.class);
|
BudgetHistoryDO updateObj = BeanUtils.toBean(updateReqVO, BudgetHistoryDO.class);
|
||||||
|
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||||
|
updateObj.setUpdater(userName);
|
||||||
budgetHistoryMapper.updateById(updateObj);
|
budgetHistoryMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteBudgetHistory(Long id) {
|
public BudgetHistoryRespVO getBudgetHistory(Long id) {
|
||||||
// 校验存在
|
|
||||||
validateBudgetHistoryExists(id);
|
// 校验
|
||||||
// 删除
|
if (id == null) {
|
||||||
budgetHistoryMapper.deleteById(id);
|
throw exception(BUDGET_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
BudgetHistoryDO budgetHistoryDO = budgetHistoryMapper.selectById(id);
|
||||||
|
if (budgetHistoryDO == null) {
|
||||||
|
throw exception(BUDGET_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
Long budgetId = budgetHistoryDO.getBudgetId();
|
||||||
|
if (budgetId == null) {
|
||||||
|
throw exception(BUDGET_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
Long projectId = budgetHistoryDO.getProjectId();
|
||||||
|
if (projectId == null) {
|
||||||
|
throw exception(PROJECT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
Long contractId = budgetHistoryDO.getContractId();
|
||||||
|
if (contractId == null) {
|
||||||
|
throw exception(CONTRACT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
ContractRespDTO contract = contractApi.getContract(contractId);
|
||||||
|
ProjectRespDTO project = projectApi.getProject(projectId);
|
||||||
|
BudgetHistoryRespVO budgetHistoryRespVO = BeanUtils.toBean(budgetHistoryDO, BudgetHistoryRespVO.class);
|
||||||
|
|
||||||
|
/** 联表查询
|
||||||
|
* 1. 跟踪项目编号 √
|
||||||
|
* 2. 项目编号 √
|
||||||
|
* 3. 跟踪项目名称 √
|
||||||
|
* 4. 项目类型 √
|
||||||
|
* 5. 预计合同金额 √
|
||||||
|
* 6. 暂定结算数 √
|
||||||
|
* 7. 包干/审定金额 √
|
||||||
|
* 8. 外包公司金额 √
|
||||||
|
*
|
||||||
|
* 9. 有效合同金额 √
|
||||||
|
* 10. 预估利润率 √
|
||||||
|
* 11. 实际利润率 √
|
||||||
|
* 12. 利润预警 √
|
||||||
|
*/
|
||||||
|
|
||||||
|
budgetHistoryRespVO.setTrackingProjectCode(project.getTrackingCode()); // 跟踪项目编号
|
||||||
|
budgetHistoryRespVO.setProjectCode(project.getCode()); // 项目编号
|
||||||
|
budgetHistoryRespVO.setTrackingProjectName(project.getName()); // 跟踪项目名称
|
||||||
|
budgetHistoryRespVO.setProjectType(project.getType()); // 项目类型
|
||||||
|
budgetHistoryRespVO.setExpectedContractAmount(project.getContractAmount()); // 预计合同金额
|
||||||
|
|
||||||
|
String countType = contract.getCountType();
|
||||||
|
BigDecimal amount = contract.getAmount();
|
||||||
|
BigDecimal bigDecimal = new BigDecimal(String.valueOf(amount));
|
||||||
|
BigDecimal mul = new BigDecimal("0.85");
|
||||||
|
BigDecimal res = null;
|
||||||
|
if ("费率合同".equals(countType)) {
|
||||||
|
res = bigDecimal.multiply(mul);
|
||||||
|
} else if ("总价合同".equals(countType)) {
|
||||||
|
res = amount;
|
||||||
|
}
|
||||||
|
budgetHistoryRespVO.setProvisionalSettlement(res); // 暂定结算数
|
||||||
|
|
||||||
|
budgetHistoryRespVO.setApprovedAmount(contract.getApprovedAmount()); // 包干/审定金额
|
||||||
|
budgetHistoryRespVO.setOutAmount(outscontractApi.getOutsContractAmount(contractId)); // 外包公司金额
|
||||||
|
|
||||||
|
BigDecimal firstValue = new BigDecimal("0");
|
||||||
|
BigDecimal secondValue = new BigDecimal("0");
|
||||||
|
if (contract.getApprovedAmount() == null && res != null) {
|
||||||
|
firstValue = res;
|
||||||
|
} else if (contract.getApprovedAmount() != null) {
|
||||||
|
firstValue = contract.getApprovedAmount();
|
||||||
|
} else {
|
||||||
|
firstValue = project.getContractAmount();
|
||||||
|
}
|
||||||
|
if (outscontractApi.getOutsContractAmount(contractId) == null) {
|
||||||
|
if (budgetHistoryDO.getOutsourcingCosts() != null) {
|
||||||
|
secondValue = budgetHistoryDO.getOutsourcingCosts();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
secondValue = outscontractApi.getOutsContractAmount(contractId);
|
||||||
|
}
|
||||||
|
budgetHistoryRespVO.setValidContractAmount(firstValue.subtract(secondValue)); // 有效合同金额
|
||||||
|
|
||||||
|
BigDecimal estimatedBaseValue = (res == null) ? project.getContractAmount() : res;
|
||||||
|
if (estimatedBaseValue == null) {
|
||||||
|
throw exception(PROFIT_MARGIN_ERROR);
|
||||||
|
}
|
||||||
|
BigDecimal estimatedNumerator = estimatedBaseValue
|
||||||
|
.subtract(budgetHistoryDO.getOutsourcingCosts() != null ? budgetHistoryDO.getOutsourcingCosts() : BigDecimal.ZERO)
|
||||||
|
.subtract(budgetHistoryDO.getLaborCosts() != null ? budgetHistoryDO.getLaborCosts() : BigDecimal.ZERO)
|
||||||
|
.subtract(budgetHistoryDO.getProductCosts() != null ? budgetHistoryDO.getProductCosts() : BigDecimal.ZERO)
|
||||||
|
.subtract(budgetHistoryDO.getFinancialCosts() != null ? budgetHistoryDO.getFinancialCosts() : BigDecimal.ZERO);
|
||||||
|
budgetHistoryRespVO.setEstimatedProfitMargin(estimatedNumerator.divide(estimatedBaseValue, 4 , RoundingMode.HALF_UP)); // 预估利润率
|
||||||
|
|
||||||
|
BigDecimal realBaseValue = (contract.getApprovedAmount() == null) ? res : contract.getApprovedAmount();
|
||||||
|
if (realBaseValue == null) {
|
||||||
|
throw exception(PROFIT_MARGIN_ERROR);
|
||||||
|
}
|
||||||
|
BigDecimal realNumerator = realBaseValue
|
||||||
|
.subtract(outscontractApi.getOutsContractAmount(contractId) != null ? outscontractApi.getOutsContractAmount(contractId) : BigDecimal.ZERO)
|
||||||
|
.subtract(budgetHistoryDO.getAccumulatedLaborCosts() != null ? budgetHistoryDO.getAccumulatedLaborCosts() : BigDecimal.ZERO)
|
||||||
|
.subtract(budgetHistoryDO.getAccumulatedProductCosts() != null ? budgetHistoryDO.getAccumulatedProductCosts() : BigDecimal.ZERO)
|
||||||
|
.subtract(budgetHistoryDO.getAccumulatedFinancialCosts() != null ? budgetHistoryDO.getAccumulatedFinancialCosts() : BigDecimal.ZERO);
|
||||||
|
BigDecimal realProfitMargin = realNumerator.divide(realBaseValue,4, RoundingMode.HALF_UP);
|
||||||
|
budgetHistoryRespVO.setRealProfitMargin(realProfitMargin); // 实际利润率
|
||||||
|
|
||||||
|
BigDecimal threshold = new BigDecimal("0.25");
|
||||||
|
String profitWarning = (realProfitMargin.compareTo(threshold) < 0) ? "利润预警" : "";
|
||||||
|
budgetHistoryRespVO.setProfitWarning(profitWarning); // 利润预警
|
||||||
|
|
||||||
|
return budgetHistoryRespVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<BudgetHistoryRespVO> getBudgetHistoryPage(BudgetHistoryPageReqVO pageReqVO) {
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
if (pageReqVO == null) {
|
||||||
|
throw exception(PARAM_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
Long projectId = pageReqVO.getProjectId();
|
||||||
|
ProjectRespDTO project = projectApi.getProject(projectId);
|
||||||
|
if (project == null) {
|
||||||
|
throw exception(PROJECT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
Long contractId = pageReqVO.getContractId();
|
||||||
|
ContractRespDTO contract = contractApi.getContract(contractId);
|
||||||
|
if (contract == null) {
|
||||||
|
throw exception(CONTRACT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PageResult<BudgetHistoryDO> budgetHistoryDOPageResult = budgetHistoryMapper.selectPage(pageReqVO);
|
||||||
|
List<BudgetHistoryDO> pageResultList = budgetHistoryDOPageResult.getList();
|
||||||
|
List<BudgetHistoryRespVO> budgetHistoryRespVOS = new ArrayList<>();
|
||||||
|
|
||||||
|
for (BudgetHistoryDO budgetHistoryDO : pageResultList) {
|
||||||
|
Long id = budgetHistoryDO.getId();
|
||||||
|
BudgetHistoryRespVO budgetHistory = getBudgetHistory(id);
|
||||||
|
budgetHistoryRespVOS.add(budgetHistory);
|
||||||
|
}
|
||||||
|
|
||||||
|
PageResult<BudgetHistoryRespVO> pageResult = new PageResult<>();
|
||||||
|
pageResult.setList(budgetHistoryRespVOS);
|
||||||
|
|
||||||
|
return pageResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateBudgetHistoryExists(Long id) {
|
private void validateBudgetHistoryExists(Long id) {
|
||||||
@ -60,15 +239,5 @@ public class BudgetHistoryServiceImpl implements BudgetHistoryService {
|
|||||||
throw exception(BUDGET_HISTORY_NOT_EXISTS);
|
throw exception(BUDGET_HISTORY_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BudgetHistoryDO getBudgetHistory(Long id) {
|
|
||||||
return budgetHistoryMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<BudgetHistoryDO> getBudgetHistoryPage(BudgetHistoryPageReqVO pageReqVO) {
|
|
||||||
return budgetHistoryMapper.selectPage(pageReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user