mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-01 21:01:59 +08:00
[fix] 优化预算管理功能
This commit is contained in:
parent
4ee64cce49
commit
98f295be74
@ -0,0 +1,11 @@
|
||||
package cn.iocoder.yudao.module.cms.api.contract;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.cms.api.contract.dto.ContractDTO;
|
||||
|
||||
public interface ContractApi {
|
||||
|
||||
ContractDTO getContractDTO(Long ContractId);
|
||||
|
||||
void validContractExists(Long Id);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.cms.api.contract.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class ContractDTO {
|
||||
|
||||
/**
|
||||
* 暂定结算数
|
||||
*/
|
||||
private BigDecimal provisionalSettlement;
|
||||
|
||||
/**
|
||||
* 包干审定金额
|
||||
*/
|
||||
private BigDecimal approvedAmount;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.module.cms.api.outscontract;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public interface OutsContractApi {
|
||||
|
||||
BigDecimal getOutsContractAmount(Long contractId);
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.cms.api.outscontract.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class OutsContractDTO {
|
||||
|
||||
/**
|
||||
* 外包合同金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.cms.api.contract;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.cms.api.contract.dto.ContractDTO;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.contract.ContractDetailDO;
|
||||
import cn.iocoder.yudao.module.cms.service.contract.ContractService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class ContractImpl implements ContractApi{
|
||||
|
||||
@Resource
|
||||
private ContractService contractService;
|
||||
|
||||
@Override
|
||||
public ContractDTO getContractDTO(Long ContractId) {
|
||||
ContractDetailDO contractDetail = contractService.getContractDetail(ContractId);
|
||||
return BeanUtils.toBean(contractDetail, ContractDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validContractExists(Long Id) {
|
||||
contractService.validateContractExists(Id);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.cms.api.outscontract;
|
||||
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.outscontract.OutsContractDO;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.outscontract.OutsContractMapper;
|
||||
import cn.iocoder.yudao.module.cms.service.outscontract.OutsContractService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class OutsContractImpl implements OutsContractApi{
|
||||
|
||||
@Resource
|
||||
private OutsContractMapper outsContractMapper;
|
||||
|
||||
@Override
|
||||
public BigDecimal getOutsContractAmount(Long contractId) {
|
||||
|
||||
List<OutsContractDO> outsContractDOList = outsContractMapper.selectList("contract_id", contractId);
|
||||
BigDecimal res = BigDecimal.ZERO;
|
||||
for (OutsContractDO outsContractDO : outsContractDOList) {
|
||||
res = res.add(outsContractDO.getOutsAmount());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -61,11 +61,11 @@ public class OutsContractDO extends BaseDO {
|
||||
/**
|
||||
* 外包合同金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
private BigDecimal outsAmount;
|
||||
/**
|
||||
* 外包合同编号
|
||||
*/
|
||||
private Integer code;
|
||||
private Integer outsCode;
|
||||
/**
|
||||
* 最终外包金额
|
||||
*/
|
||||
|
@ -20,8 +20,8 @@ public interface OutsContractMapper extends BaseMapperX<OutsContractDO> {
|
||||
.eqIfPresent(OutsContractDO::getProjectId, reqVO.getProjectId())
|
||||
.eqIfPresent(OutsContractDO::getContractId, reqVO.getContractId())
|
||||
.eqIfPresent(OutsContractDO::getCountType, reqVO.getCountType())
|
||||
.eqIfPresent(OutsContractDO::getAmount, reqVO.getAmount())
|
||||
.eqIfPresent(OutsContractDO::getCode, reqVO.getCode())
|
||||
.eqIfPresent(OutsContractDO::getOutsAmount, reqVO.getAmount())
|
||||
.eqIfPresent(OutsContractDO::getOutsCode, reqVO.getCode())
|
||||
.eqIfPresent(OutsContractDO::getMajor, reqVO.getMajor())
|
||||
.betweenIfPresent(OutsContractDO::getSigningTime, reqVO.getSigningTime())
|
||||
.eqIfPresent(OutsContractDO::getContractFileUrl, reqVO.getContractFileUrl())
|
||||
|
@ -22,6 +22,7 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 应收款管理 1_024_000_000 ==========
|
||||
ErrorCode RECEIVABLES_NOT_EXISTS = new ErrorCode(1_024_000_000, "应收款管理不存在");
|
||||
|
||||
// ========== 应收款管理历史记录 1_024_000_000 ==========
|
||||
ErrorCode RECEIVABLES_HISTORY_NOT_EXISTS = new ErrorCode(1_024_000_000, "应收款管理历史记录不存在");
|
||||
|
||||
@ -29,7 +30,9 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode PROJECT_SCHEDULE_NOT_EXISTS = new ErrorCode(1_025_000_000, "项目进度管理不存在");
|
||||
|
||||
// ========== 项目追踪信息不存在 1_026_000_000 ==========
|
||||
ErrorCode PROJECT_TRACKING_NOT_EXISTS = new ErrorCode(1_026_000_000, "项目进度管理不存在");
|
||||
ErrorCode PROJECT_TRACKING_NOT_EXISTS = new ErrorCode(1_026_000_000, "项目跟踪管理不存在");
|
||||
|
||||
// ========== 项目追踪信息不存在 1_027_000_000 ==========
|
||||
ErrorCode BUDGET_ALREADY_EXISTS = new ErrorCode(1_027_000_000, "预算管理已存在");
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,13 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-cms-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<!-- 流程相关 -->
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.budget;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budget.BudgetDetailDO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -8,7 +9,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
@ -24,6 +24,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.budget.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budget.BudgetDO;
|
||||
@ -42,14 +43,14 @@ public class BudgetController {
|
||||
@Operation(summary = "创建预算管理")
|
||||
@PreAuthorize("@ss.hasPermission('pms:budget:create')")
|
||||
public CommonResult<Long> createBudget(@Valid @RequestBody BudgetSaveReqVO createReqVO) {
|
||||
return success(budgetService.createBudget(createReqVO));
|
||||
return success(budgetService.createBudget(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新预算管理")
|
||||
@PreAuthorize("@ss.hasPermission('pms:budget:update')")
|
||||
public CommonResult<Boolean> updateBudget(@Valid @RequestBody BudgetSaveReqVO updateReqVO) {
|
||||
budgetService.updateBudget(updateReqVO);
|
||||
budgetService.updateBudget(getLoginUserId(), updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -67,16 +68,19 @@ public class BudgetController {
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('pms:budget:query')")
|
||||
public CommonResult<BudgetRespVO> getBudget(@RequestParam("id") Long id) {
|
||||
BudgetDO budget = budgetService.getBudget(id);
|
||||
return success(BeanUtils.toBean(budget, BudgetRespVO.class));
|
||||
BudgetDetailDO budgetDetailDO = budgetService.getBudgetDetail(id);
|
||||
BudgetRespVO budgetRespVO = new BudgetRespVO();
|
||||
org.springframework.beans.BeanUtils.copyProperties(budgetDetailDO, budgetRespVO);
|
||||
|
||||
return success(budgetRespVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得预算管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('pms:budget:query')")
|
||||
public CommonResult<PageResult<BudgetRespVO>> getBudgetPage(@Valid BudgetPageReqVO pageReqVO) {
|
||||
PageResult<BudgetDO> pageResult = budgetService.getBudgetPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, BudgetRespVO.class));
|
||||
PageResult<BudgetRespVO> pageResult = budgetService.getBudgetPage(pageReqVO);
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ -86,7 +90,7 @@ public class BudgetController {
|
||||
public void exportBudgetExcel(@Valid BudgetPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<BudgetDO> list = budgetService.getBudgetPage(pageReqVO).getList();
|
||||
List<BudgetRespVO> list = budgetService.getBudgetPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "预算管理.xls", "数据", BudgetRespVO.class,
|
||||
BeanUtils.toBean(list, BudgetRespVO.class));
|
||||
|
@ -16,41 +16,11 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@ToString(callSuper = true)
|
||||
public class BudgetPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "项目id", example = "13470")
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long projectId;
|
||||
|
||||
@Schema(description = "合同管理", example = "20248")
|
||||
@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;
|
||||
|
||||
}
|
@ -13,6 +13,39 @@ import com.alibaba.excel.annotation.*;
|
||||
@ExcelIgnoreUnannotated
|
||||
public class BudgetRespVO {
|
||||
|
||||
@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 = "25375")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.budget.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 BudgetSaveReqVO {
|
||||
|
||||
@Schema(description = "自动编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("自动编号")
|
||||
private String 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 = "25375")
|
||||
private Long id;
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.pms.dal.dataobject.budget;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author shl
|
||||
* @description
|
||||
* @date 2024/8/16
|
||||
*/
|
||||
@Data
|
||||
public class BudgetDetailDO extends BudgetDO {
|
||||
|
||||
/**
|
||||
* 自动编号
|
||||
*/
|
||||
private Long autoId;
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 跟踪项目名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 项目类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 预计合同金额
|
||||
*/
|
||||
private BigDecimal expectedContractAmount;
|
||||
|
||||
/**
|
||||
* 暂定结算数
|
||||
*/
|
||||
private BigDecimal provisionalSettlement;
|
||||
|
||||
/**
|
||||
* 包干/审定金额
|
||||
*/
|
||||
private BigDecimal approvedAmount;
|
||||
|
||||
/**
|
||||
* 外包合同金额
|
||||
*/
|
||||
private BigDecimal outsContractAmount;
|
||||
|
||||
}
|
@ -13,8 +13,6 @@ import java.math.BigDecimal;
|
||||
@Data
|
||||
public class ProjectTrackingDetailDO extends ProjectDO {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
@ -25,7 +23,6 @@ public class ProjectTrackingDetailDO extends ProjectDO {
|
||||
*/
|
||||
private String trackingDep;
|
||||
|
||||
|
||||
/**
|
||||
* 出图公司
|
||||
*/
|
||||
@ -41,4 +38,5 @@ public class ProjectTrackingDetailDO extends ProjectDO {
|
||||
*/
|
||||
private String constructionSide;
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,16 +21,16 @@ 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())
|
||||
// .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));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.pms.service.budget;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budget.BudgetDetailDO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.budget.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budget.BudgetDO;
|
||||
@ -14,42 +16,15 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
*/
|
||||
public interface BudgetService {
|
||||
|
||||
/**
|
||||
* 创建预算管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createBudget(@Valid BudgetSaveReqVO createReqVO);
|
||||
Long createBudget(Long loginUserId, @Valid BudgetSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新预算管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateBudget(@Valid BudgetSaveReqVO updateReqVO);
|
||||
void updateBudget(Long loginUserId, @Valid BudgetSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除预算管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteBudget(Long id);
|
||||
|
||||
/**
|
||||
* 获得预算管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 预算管理
|
||||
*/
|
||||
BudgetDO getBudget(Long id);
|
||||
PageResult<BudgetRespVO> getBudgetPage(BudgetPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得预算管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 预算管理分页
|
||||
*/
|
||||
PageResult<BudgetDO> getBudgetPage(BudgetPageReqVO pageReqVO);
|
||||
BudgetDetailDO getBudgetDetail(Long id);
|
||||
|
||||
void validateBudgetExists(Long id);
|
||||
}
|
@ -1,10 +1,19 @@
|
||||
package cn.iocoder.yudao.module.pms.service.budget;
|
||||
|
||||
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.dal.dataobject.budget.BudgetDetailDO;
|
||||
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.budget.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.budget.BudgetDO;
|
||||
@ -16,6 +25,7 @@ import cn.iocoder.yudao.module.pms.dal.mysql.budget.BudgetMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 预算管理 Service 实现类
|
||||
@ -29,21 +39,60 @@ public class BudgetServiceImpl implements BudgetService {
|
||||
@Resource
|
||||
private BudgetMapper budgetMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private ContractApi contractApi;
|
||||
|
||||
@Resource
|
||||
private OutsContractApi outsContractApi;
|
||||
|
||||
@Resource
|
||||
private ProjectTrackingService projectTrackingService;
|
||||
|
||||
@Override
|
||||
public Long createBudget(BudgetSaveReqVO createReqVO) {
|
||||
public Long createBudget(Long loginUserId, BudgetSaveReqVO createReqVO) {
|
||||
|
||||
// 校验
|
||||
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||
if (userName == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
Long projectId = createReqVO.getProjectId();
|
||||
Long contractId = createReqVO.getContractId();
|
||||
projectTrackingService.validateProjectExists(projectId);
|
||||
contractApi.validContractExists(contractId);
|
||||
|
||||
Long id = createReqVO.getId();
|
||||
List<BudgetDO> projectList = budgetMapper.selectList("project_id", projectId);
|
||||
for (BudgetDO budgetDO : projectList) {
|
||||
if (Objects.equals(budgetDO.getId(), id)) {
|
||||
throw exception(BUDGET_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
// 插入
|
||||
BudgetDO budget = BeanUtils.toBean(createReqVO, BudgetDO.class);
|
||||
budget.setCreator(userName);
|
||||
budget.setUpdater(userName);
|
||||
budgetMapper.insert(budget);
|
||||
// 返回
|
||||
return budget.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBudget(BudgetSaveReqVO updateReqVO) {
|
||||
public void updateBudget(Long loginUserId, BudgetSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateBudgetExists(updateReqVO.getId());
|
||||
projectTrackingService.validateProjectExists(updateReqVO.getProjectId());
|
||||
contractApi.validContractExists(updateReqVO.getContractId());
|
||||
// 更新
|
||||
BudgetDO updateObj = BeanUtils.toBean(updateReqVO, BudgetDO.class);
|
||||
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||
if (userName == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
updateObj.setUpdater(userName);
|
||||
budgetMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@ -55,20 +104,57 @@ public class BudgetServiceImpl implements BudgetService {
|
||||
budgetMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateBudgetExists(Long id) {
|
||||
@Override
|
||||
public void validateBudgetExists(Long id) {
|
||||
if (budgetMapper.selectById(id) == null) {
|
||||
throw exception(BUDGET_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BudgetDO getBudget(Long id) {
|
||||
return budgetMapper.selectById(id);
|
||||
public PageResult<BudgetRespVO> getBudgetPage(BudgetPageReqVO pageReqVO) {
|
||||
|
||||
PageResult<BudgetDO> budgetDOPageResult = budgetMapper.selectPage(pageReqVO);
|
||||
List<BudgetDO> budgetDOList = budgetDOPageResult.getList();
|
||||
List<BudgetDetailDO> budgetRespVOList = new ArrayList<>();
|
||||
|
||||
for (BudgetDO budgetDO : budgetDOList) {
|
||||
Long id = budgetDO.getId();
|
||||
BudgetDetailDO budgetDetail = getBudgetDetail(id);
|
||||
budgetRespVOList.add(budgetDetail);
|
||||
}
|
||||
List<BudgetRespVO> respVOList = BeanUtils.toBean(budgetRespVOList, BudgetRespVO.class);
|
||||
PageResult<BudgetRespVO> pageResult = new PageResult<>();
|
||||
pageResult.setList(respVOList);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BudgetDO> getBudgetPage(BudgetPageReqVO pageReqVO) {
|
||||
return budgetMapper.selectPage(pageReqVO);
|
||||
public BudgetDetailDO getBudgetDetail(Long id) {
|
||||
|
||||
BudgetDetailDO budgetDetailDO = new BudgetDetailDO();
|
||||
BudgetDO budgetDO = budgetMapper.selectById(id);
|
||||
|
||||
if (budgetDO == null) {
|
||||
throw exception(BUDGET_NOT_EXISTS);
|
||||
}
|
||||
|
||||
Long contractId = budgetDO.getContractId();
|
||||
Long projectId = budgetDO.getProjectId();
|
||||
contractApi.validContractExists(contractId);
|
||||
projectTrackingService.validateProjectExists(projectId);
|
||||
|
||||
ProjectTrackingDO projectTracking = projectTrackingService.getProjectTracking(projectId);
|
||||
ContractDTO contractDTO = contractApi.getContractDTO(contractId);
|
||||
BigDecimal outsContractAmount = outsContractApi.getOutsContractAmount(contractId);
|
||||
budgetDetailDO.setOutsContractAmount(outsContractAmount);
|
||||
budgetDetailDO.setAutoId(projectTracking.getId());
|
||||
|
||||
BeanUtil.copyProperties(budgetDO, budgetDetailDO);
|
||||
BeanUtil.copyProperties(projectTracking, budgetDetailDO);
|
||||
BeanUtil.copyProperties(contractDTO, budgetDetailDO);
|
||||
|
||||
return budgetDetailDO;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user