mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-15 18:51:54 +08:00
[fix] 优化历史预算管理功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.budgethistory;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDetailDO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -24,6 +25,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
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.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDO;
|
||||
@@ -38,27 +40,11 @@ public class BudgetHistoryController {
|
||||
@Resource
|
||||
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")
|
||||
@Operation(summary = "更新历史预算管理")
|
||||
@PreAuthorize("@ss.hasPermission('pms:budget-history:update')")
|
||||
public CommonResult<Boolean> updateBudgetHistory(@Valid @RequestBody BudgetHistorySaveReqVO updateReqVO) {
|
||||
budgetHistoryService.updateBudgetHistory(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);
|
||||
budgetHistoryService.updateBudgetHistory(getLoginUserId(), updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@@ -67,16 +53,18 @@ public class BudgetHistoryController {
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('pms:budget-history:query')")
|
||||
public CommonResult<BudgetHistoryRespVO> getBudgetHistory(@RequestParam("id") Long id) {
|
||||
BudgetHistoryDO budgetHistory = budgetHistoryService.getBudgetHistory(id);
|
||||
return success(BeanUtils.toBean(budgetHistory, BudgetHistoryRespVO.class));
|
||||
BudgetHistoryDetailDO budgetHistoryDetailDO = budgetHistoryService.getBudgetHistoryDetail(id);
|
||||
BudgetHistoryRespVO budgetHistoryRespVO = new BudgetHistoryRespVO();
|
||||
org.springframework.beans.BeanUtils.copyProperties(budgetHistoryDetailDO, budgetHistoryRespVO);
|
||||
return success(budgetHistoryRespVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得历史预算管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('pms:budget-history:query')")
|
||||
public CommonResult<PageResult<BudgetHistoryRespVO>> getBudgetHistoryPage(@Valid BudgetHistoryPageReqVO pageReqVO) {
|
||||
PageResult<BudgetHistoryDO> pageResult = budgetHistoryService.getBudgetHistoryPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, BudgetHistoryRespVO.class));
|
||||
PageResult<BudgetHistoryRespVO> pageResult = budgetHistoryService.getBudgetHistoryPage(pageReqVO);
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@@ -86,7 +74,7 @@ public class BudgetHistoryController {
|
||||
public void exportBudgetHistoryExcel(@Valid BudgetHistoryPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<BudgetHistoryDO> list = budgetHistoryService.getBudgetHistoryPage(pageReqVO).getList();
|
||||
List<BudgetHistoryRespVO> list = budgetHistoryService.getBudgetHistoryPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "历史预算管理.xls", "数据", BudgetHistoryRespVO.class,
|
||||
BeanUtils.toBean(list, BudgetHistoryRespVO.class));
|
||||
|
@@ -16,53 +16,10 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@ToString(callSuper = true)
|
||||
public class BudgetHistoryPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "项目id", example = "15123")
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long projectId;
|
||||
|
||||
@Schema(description = "合同管理", example = "23971")
|
||||
@Schema(description = "合同编号", example = "47")
|
||||
private Long contractId;
|
||||
|
||||
@Schema(description = "预算文件url", example = "https://www.iocoder.cn")
|
||||
private String budgetFileUrl;
|
||||
|
||||
@Schema(description = "预算外包成本")
|
||||
private BigDecimal outsourcingCosts;
|
||||
|
||||
@Schema(description = "人力成本")
|
||||
private BigDecimal laborCosts;
|
||||
|
||||
@Schema(description = "累计人力成本")
|
||||
private BigDecimal accumulatedLaborCosts;
|
||||
|
||||
@Schema(description = "生产成本")
|
||||
private BigDecimal productCosts;
|
||||
|
||||
@Schema(description = "累计生产成本")
|
||||
private BigDecimal accumulatedProductCosts;
|
||||
|
||||
@Schema(description = "财务成本")
|
||||
private BigDecimal financialCosts;
|
||||
|
||||
@Schema(description = "累计财务成本")
|
||||
private BigDecimal accumulatedFinancialCosts;
|
||||
|
||||
@Schema(description = "回款情况")
|
||||
private String collectionSituation;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "流程实体id", example = "30893")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "流程状态", example = "2")
|
||||
private String processStatus;
|
||||
|
||||
@Schema(description = "预算id", example = "24627")
|
||||
private Long budgetId;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private String version;
|
||||
|
||||
}
|
@@ -13,6 +13,40 @@ import com.alibaba.excel.annotation.*;
|
||||
@ExcelIgnoreUnannotated
|
||||
public class BudgetHistoryRespVO {
|
||||
|
||||
@Schema(description = "自动编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("自动编号")
|
||||
private Long autoId;
|
||||
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("项目编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "跟踪项目名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("跟踪项目名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "项目类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("项目类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("预计合同金额")
|
||||
private BigDecimal expectedContractAmount;
|
||||
|
||||
@Schema(description = "暂定结算数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("暂定结算数")
|
||||
private BigDecimal provisionalSettlement;
|
||||
|
||||
@Schema(description = "包干/审定金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("包干/审定金额")
|
||||
private BigDecimal approvedAmount;
|
||||
|
||||
@Schema(description = "外包合同金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("外包合同金额")
|
||||
private BigDecimal outsContractAmount;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2972")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
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 lombok.*;
|
||||
import java.util.*;
|
||||
@@ -10,6 +11,40 @@ import java.math.BigDecimal;
|
||||
@Data
|
||||
public class BudgetHistorySaveReqVO {
|
||||
|
||||
@Schema(description = "自动编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("自动编号")
|
||||
private Long autoId;
|
||||
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("项目编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "跟踪项目名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("跟踪项目名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "项目类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("项目类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("预计合同金额")
|
||||
private BigDecimal expectedContractAmount;
|
||||
|
||||
@Schema(description = "暂定结算数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("暂定结算数")
|
||||
private BigDecimal provisionalSettlement;
|
||||
|
||||
@Schema(description = "包干/审定金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("包干/审定金额")
|
||||
private BigDecimal approvedAmount;
|
||||
|
||||
@Schema(description = "外包合同金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("外包合同金额")
|
||||
private BigDecimal outsContractAmount;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2972")
|
||||
private Long id;
|
||||
|
||||
|
@@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class BudgetHistoryDetailDO extends BudgetHistoryDO {
|
||||
|
||||
/**
|
||||
* 自动编号
|
||||
*/
|
||||
private Long autoId;
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 跟踪项目名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 项目类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 预计合同金额
|
||||
*/
|
||||
private BigDecimal expectedContractAmount;
|
||||
|
||||
/**
|
||||
* 暂定结算数
|
||||
*/
|
||||
private BigDecimal provisionalSettlement;
|
||||
|
||||
/**
|
||||
* 包干/审定金额
|
||||
*/
|
||||
private BigDecimal approvedAmount;
|
||||
|
||||
/**
|
||||
* 外包合同金额
|
||||
*/
|
||||
private BigDecimal outsContractAmount;
|
||||
}
|
@@ -21,16 +21,6 @@ public interface BudgetMapper extends BaseMapperX<BudgetDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BudgetDO>()
|
||||
.eqIfPresent(BudgetDO::getProjectId, reqVO.getProjectId())
|
||||
.eqIfPresent(BudgetDO::getContractId, reqVO.getContractId())
|
||||
// .eqIfPresent(BudgetDO::getBudgetFileUrl, reqVO.getBudgetFileUrl())
|
||||
// .eqIfPresent(BudgetDO::getOutsourcingCosts, reqVO.getOutsourcingCosts())
|
||||
// .eqIfPresent(BudgetDO::getLaborCosts, reqVO.getLaborCosts())
|
||||
// .eqIfPresent(BudgetDO::getAccumulatedLaborCosts, reqVO.getAccumulatedLaborCosts())
|
||||
// .eqIfPresent(BudgetDO::getProductCosts, reqVO.getProductCosts())
|
||||
// .eqIfPresent(BudgetDO::getAccumulatedProductCosts, reqVO.getAccumulatedProductCosts())
|
||||
// .eqIfPresent(BudgetDO::getFinancialCosts, reqVO.getFinancialCosts())
|
||||
// .eqIfPresent(BudgetDO::getAccumulatedFinancialCosts, reqVO.getAccumulatedFinancialCosts())
|
||||
// .eqIfPresent(BudgetDO::getCollectionSituation, reqVO.getCollectionSituation())
|
||||
// .betweenIfPresent(BudgetDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(BudgetDO::getId));
|
||||
}
|
||||
|
||||
|
@@ -21,20 +21,20 @@ public interface BudgetHistoryMapper extends BaseMapperX<BudgetHistoryDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BudgetHistoryDO>()
|
||||
.eqIfPresent(BudgetHistoryDO::getProjectId, reqVO.getProjectId())
|
||||
.eqIfPresent(BudgetHistoryDO::getContractId, reqVO.getContractId())
|
||||
.eqIfPresent(BudgetHistoryDO::getBudgetFileUrl, reqVO.getBudgetFileUrl())
|
||||
.eqIfPresent(BudgetHistoryDO::getOutsourcingCosts, reqVO.getOutsourcingCosts())
|
||||
.eqIfPresent(BudgetHistoryDO::getLaborCosts, reqVO.getLaborCosts())
|
||||
.eqIfPresent(BudgetHistoryDO::getAccumulatedLaborCosts, reqVO.getAccumulatedLaborCosts())
|
||||
.eqIfPresent(BudgetHistoryDO::getProductCosts, reqVO.getProductCosts())
|
||||
.eqIfPresent(BudgetHistoryDO::getAccumulatedProductCosts, reqVO.getAccumulatedProductCosts())
|
||||
.eqIfPresent(BudgetHistoryDO::getFinancialCosts, reqVO.getFinancialCosts())
|
||||
.eqIfPresent(BudgetHistoryDO::getAccumulatedFinancialCosts, reqVO.getAccumulatedFinancialCosts())
|
||||
.eqIfPresent(BudgetHistoryDO::getCollectionSituation, reqVO.getCollectionSituation())
|
||||
.betweenIfPresent(BudgetHistoryDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(BudgetHistoryDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.eqIfPresent(BudgetHistoryDO::getProcessStatus, reqVO.getProcessStatus())
|
||||
.eqIfPresent(BudgetHistoryDO::getBudgetId, reqVO.getBudgetId())
|
||||
.eqIfPresent(BudgetHistoryDO::getVersion, reqVO.getVersion())
|
||||
// .eqIfPresent(BudgetHistoryDO::getBudgetFileUrl, reqVO.getBudgetFileUrl())
|
||||
// .eqIfPresent(BudgetHistoryDO::getOutsourcingCosts, reqVO.getOutsourcingCosts())
|
||||
// .eqIfPresent(BudgetHistoryDO::getLaborCosts, reqVO.getLaborCosts())
|
||||
// .eqIfPresent(BudgetHistoryDO::getAccumulatedLaborCosts, reqVO.getAccumulatedLaborCosts())
|
||||
// .eqIfPresent(BudgetHistoryDO::getProductCosts, reqVO.getProductCosts())
|
||||
// .eqIfPresent(BudgetHistoryDO::getAccumulatedProductCosts, reqVO.getAccumulatedProductCosts())
|
||||
// .eqIfPresent(BudgetHistoryDO::getFinancialCosts, reqVO.getFinancialCosts())
|
||||
// .eqIfPresent(BudgetHistoryDO::getAccumulatedFinancialCosts, reqVO.getAccumulatedFinancialCosts())
|
||||
// .eqIfPresent(BudgetHistoryDO::getCollectionSituation, reqVO.getCollectionSituation())
|
||||
// .betweenIfPresent(BudgetHistoryDO::getCreateTime, reqVO.getCreateTime())
|
||||
// .eqIfPresent(BudgetHistoryDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
// .eqIfPresent(BudgetHistoryDO::getProcessStatus, reqVO.getProcessStatus())
|
||||
// .eqIfPresent(BudgetHistoryDO::getBudgetId, reqVO.getBudgetId())
|
||||
// .eqIfPresent(BudgetHistoryDO::getVersion, reqVO.getVersion())
|
||||
.orderByDesc(BudgetHistoryDO::getId));
|
||||
}
|
||||
|
||||
|
@@ -108,8 +108,6 @@ public class BudgetServiceImpl implements BudgetService {
|
||||
.setBusinessKey(String.valueOf(budgetId)));
|
||||
|
||||
// 写入工作流编号
|
||||
// budgetHistory.setProcessInstanceId(processInstanceId);
|
||||
// budgetHistory.setBudgetId(budgetId);
|
||||
budgetHistoryMapper.updateById(budgetHistory.setBudgetId(budgetId).setProcessInstanceId(processInstanceId));
|
||||
|
||||
Long count = budgetHistoryMapper.selectCount("project_id", projectId);
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.pms.service.budgethistory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDetailDO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDO;
|
||||
@@ -14,27 +16,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
*/
|
||||
public interface BudgetHistoryService {
|
||||
|
||||
/**
|
||||
* 创建预算管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createBudgetHistory(@Valid BudgetHistorySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新预算管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateBudgetHistory(@Valid BudgetHistorySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除预算管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteBudgetHistory(Long id);
|
||||
void updateBudgetHistory(Long loginUserId, @Valid BudgetHistorySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 获得预算管理
|
||||
@@ -42,7 +29,7 @@ public interface BudgetHistoryService {
|
||||
* @param id 编号
|
||||
* @return 预算管理
|
||||
*/
|
||||
BudgetHistoryDO getBudgetHistory(Long id);
|
||||
BudgetHistoryDetailDO getBudgetHistoryDetail(Long id);
|
||||
|
||||
/**
|
||||
* 获得预算管理分页
|
||||
@@ -50,6 +37,6 @@ public interface BudgetHistoryService {
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 预算管理分页
|
||||
*/
|
||||
PageResult<BudgetHistoryDO> getBudgetHistoryPage(BudgetHistoryPageReqVO pageReqVO);
|
||||
PageResult<BudgetHistoryRespVO> getBudgetHistoryPage(BudgetHistoryPageReqVO pageReqVO);
|
||||
|
||||
}
|
@@ -1,10 +1,20 @@
|
||||
package cn.iocoder.yudao.module.pms.service.budgethistory;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.iocoder.yudao.module.cms.api.contract.ContractApi;
|
||||
import cn.iocoder.yudao.module.cms.api.contract.dto.ContractDTO;
|
||||
import cn.iocoder.yudao.module.cms.api.outscontract.OutsContractApi;
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.budget.vo.BudgetRespVO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDetailDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.projecttracking.ProjectTrackingDO;
|
||||
import cn.iocoder.yudao.module.pms.service.projecttracking.ProjectTrackingService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.budgethistory.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budgethistory.BudgetHistoryDO;
|
||||
@@ -15,13 +25,16 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.module.cms.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.PARAM_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 预算管理 Service 实现类
|
||||
*
|
||||
* @author zqc
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class BudgetHistoryServiceImpl implements BudgetHistoryService {
|
||||
@@ -29,32 +42,34 @@ public class BudgetHistoryServiceImpl implements BudgetHistoryService {
|
||||
@Resource
|
||||
private BudgetHistoryMapper budgetHistoryMapper;
|
||||
|
||||
@Override
|
||||
public Long createBudgetHistory(BudgetHistorySaveReqVO createReqVO) {
|
||||
// 插入
|
||||
BudgetHistoryDO budgetHistory = BeanUtils.toBean(createReqVO, BudgetHistoryDO.class);
|
||||
budgetHistoryMapper.insert(budgetHistory);
|
||||
// 返回
|
||||
return budgetHistory.getId();
|
||||
}
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private ProjectTrackingService projectTrackingService;
|
||||
|
||||
@Resource
|
||||
private ContractApi contractApi;
|
||||
|
||||
@Resource
|
||||
private OutsContractApi outsContractApi;
|
||||
|
||||
@Override
|
||||
public void updateBudgetHistory(BudgetHistorySaveReqVO updateReqVO) {
|
||||
public void updateBudgetHistory(Long loginUserId, BudgetHistorySaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateBudgetHistoryExists(updateReqVO.getId());
|
||||
projectTrackingService.validateProjectExists(updateReqVO.getProjectId());
|
||||
contractApi.validContractExists(updateReqVO.getContractId());
|
||||
// 更新
|
||||
BudgetHistoryDO updateObj = BeanUtils.toBean(updateReqVO, BudgetHistoryDO.class);
|
||||
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||
if (userName == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
updateObj.setUpdater(userName);
|
||||
budgetHistoryMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBudgetHistory(Long id) {
|
||||
// 校验存在
|
||||
validateBudgetHistoryExists(id);
|
||||
// 删除
|
||||
budgetHistoryMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateBudgetHistoryExists(Long id) {
|
||||
if (budgetHistoryMapper.selectById(id) == null) {
|
||||
throw exception(BUDGET_HISTORY_NOT_EXISTS);
|
||||
@@ -62,13 +77,55 @@ public class BudgetHistoryServiceImpl implements BudgetHistoryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BudgetHistoryDO getBudgetHistory(Long id) {
|
||||
return budgetHistoryMapper.selectById(id);
|
||||
public BudgetHistoryDetailDO getBudgetHistoryDetail(Long id) {
|
||||
// 校验
|
||||
if (id == null) {
|
||||
throw exception(BUDGET_NOT_EXISTS);
|
||||
}
|
||||
BudgetHistoryDO budgetHistoryDO = budgetHistoryMapper.selectById(id);
|
||||
if (budgetHistoryDO == null) {
|
||||
throw exception(BUDGET_NOT_EXISTS);
|
||||
}
|
||||
|
||||
Long projectId = budgetHistoryDO.getProjectId();
|
||||
Long contractId = budgetHistoryDO.getContractId();
|
||||
contractApi.validContractExists(contractId);
|
||||
projectTrackingService.validateProjectExists(projectId);
|
||||
|
||||
BudgetHistoryDetailDO budgetHistoryDetailDO = new BudgetHistoryDetailDO();
|
||||
|
||||
ProjectTrackingDO projectTracking = projectTrackingService.getProjectTracking(projectId);
|
||||
ContractDTO contractDTO = contractApi.getContractDTO(contractId);
|
||||
BigDecimal outsContractAmount = outsContractApi.getOutsContractAmount(contractId);
|
||||
budgetHistoryDetailDO.setOutsContractAmount(outsContractAmount);
|
||||
budgetHistoryDetailDO.setAutoId(projectTracking.getId());
|
||||
|
||||
BeanUtil.copyProperties(budgetHistoryDO, budgetHistoryDetailDO);
|
||||
BeanUtil.copyProperties(projectTracking, budgetHistoryDetailDO);
|
||||
BeanUtil.copyProperties(contractDTO, budgetHistoryDetailDO);
|
||||
|
||||
return budgetHistoryDetailDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BudgetHistoryDO> getBudgetHistoryPage(BudgetHistoryPageReqVO pageReqVO) {
|
||||
return budgetHistoryMapper.selectPage(pageReqVO);
|
||||
public PageResult<BudgetHistoryRespVO> getBudgetHistoryPage(BudgetHistoryPageReqVO pageReqVO) {
|
||||
// 校验
|
||||
if (pageReqVO == null) {
|
||||
throw exception(PARAM_NOT_EXISTS);
|
||||
}
|
||||
PageResult<BudgetHistoryDO> budgetHistoryDOPageResult = budgetHistoryMapper.selectPage(pageReqVO);
|
||||
List<BudgetHistoryDO> budgetHistoryDOList = budgetHistoryDOPageResult.getList();
|
||||
List<BudgetHistoryDetailDO> budgetHistoryDetailDOList = new ArrayList<>();
|
||||
|
||||
for (BudgetHistoryDO budgetHistoryDO : budgetHistoryDOList) {
|
||||
Long id = budgetHistoryDO.getId();
|
||||
BudgetHistoryDetailDO budgetHistoryDetailDO = getBudgetHistoryDetail(id);
|
||||
budgetHistoryDetailDOList.add(budgetHistoryDetailDO);
|
||||
}
|
||||
List<BudgetHistoryRespVO> respVOList = BeanUtils.toBean(budgetHistoryDetailDOList, BudgetHistoryRespVO.class);
|
||||
PageResult<BudgetHistoryRespVO> pageResult = new PageResult<>();
|
||||
pageResult.setList(respVOList);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user