mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-27 01:15:10 +08:00
[fix] 优化应收款管理功能
This commit is contained in:
@ -16,4 +16,20 @@ public class ContractDTO {
|
|||||||
* 包干审定金额
|
* 包干审定金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal approvedAmount;
|
private BigDecimal approvedAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目编号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合同名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签订合同总额
|
||||||
|
*/
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,12 @@ public class ContractDetailDO extends ContractDO {
|
|||||||
* 出图公司
|
* 出图公司
|
||||||
*/
|
*/
|
||||||
private String drawingCompany;
|
private String drawingCompany;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预计公司合同总金额
|
* 预计公司合同总金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal expectedContractAmount;
|
private BigDecimal expectedContractAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目负责人
|
* 项目负责人
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,10 @@ public interface ErrorCodeConstants {
|
|||||||
// ========== 项目追踪信息不存在 1_026_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 ==========
|
// ========== 项目追踪信息已存在 1_027_000_000 ==========
|
||||||
ErrorCode BUDGET_ALREADY_EXISTS = new ErrorCode(1_027_000_000, "预算管理已存在");
|
ErrorCode BUDGET_ALREADY_EXISTS = new ErrorCode(1_027_000_000, "预算管理已存在");
|
||||||
|
|
||||||
|
// ========== 项目追踪信息已存在 1_027_000_000 ==========
|
||||||
|
ErrorCode RECEIVABLES_ALREADY_EXISTS = new ErrorCode(1_028_000_000, "应收款管理已存在");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.pms.controller.admin.receivables;
|
package cn.iocoder.yudao.module.pms.controller.admin.receivables;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.dataobject.receivables.ReceivablesDetailDO;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
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 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.receivables.vo.*;
|
import cn.iocoder.yudao.module.pms.controller.admin.receivables.vo.*;
|
||||||
import cn.iocoder.yudao.module.pms.dal.dataobject.receivables.ReceivablesDO;
|
import cn.iocoder.yudao.module.pms.dal.dataobject.receivables.ReceivablesDO;
|
||||||
@ -42,14 +44,14 @@ public class ReceivablesController {
|
|||||||
@Operation(summary = "创建应收款管理")
|
@Operation(summary = "创建应收款管理")
|
||||||
@PreAuthorize("@ss.hasPermission('pms:receivables:create')")
|
@PreAuthorize("@ss.hasPermission('pms:receivables:create')")
|
||||||
public CommonResult<Long> createReceivables(@Valid @RequestBody ReceivablesSaveReqVO createReqVO) {
|
public CommonResult<Long> createReceivables(@Valid @RequestBody ReceivablesSaveReqVO createReqVO) {
|
||||||
return success(receivablesService.createReceivables(createReqVO));
|
return success(receivablesService.createReceivables(getLoginUserId(), createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新应收款管理")
|
@Operation(summary = "更新应收款管理")
|
||||||
@PreAuthorize("@ss.hasPermission('pms:receivables:update')")
|
@PreAuthorize("@ss.hasPermission('pms:receivables:update')")
|
||||||
public CommonResult<Boolean> updateReceivables(@Valid @RequestBody ReceivablesSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateReceivables(@Valid @RequestBody ReceivablesSaveReqVO updateReqVO) {
|
||||||
receivablesService.updateReceivables(updateReqVO);
|
receivablesService.updateReceivables(getLoginUserId(), updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,16 +69,18 @@ public class ReceivablesController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('pms:receivables:query')")
|
@PreAuthorize("@ss.hasPermission('pms:receivables:query')")
|
||||||
public CommonResult<ReceivablesRespVO> getReceivables(@RequestParam("id") Long id) {
|
public CommonResult<ReceivablesRespVO> getReceivables(@RequestParam("id") Long id) {
|
||||||
ReceivablesDO receivables = receivablesService.getReceivables(id);
|
ReceivablesDetailDO receivablesDetail = receivablesService.getReceivablesDetail(id);
|
||||||
return success(BeanUtils.toBean(receivables, ReceivablesRespVO.class));
|
ReceivablesRespVO receivablesRespVO = new ReceivablesRespVO();
|
||||||
|
org.springframework.beans.BeanUtils.copyProperties(receivablesDetail, receivablesRespVO);
|
||||||
|
return success(receivablesRespVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得应收款管理分页")
|
@Operation(summary = "获得应收款管理分页")
|
||||||
@PreAuthorize("@ss.hasPermission('pms:receivables:query')")
|
@PreAuthorize("@ss.hasPermission('pms:receivables:query')")
|
||||||
public CommonResult<PageResult<ReceivablesRespVO>> getReceivablesPage(@Valid ReceivablesPageReqVO pageReqVO) {
|
public CommonResult<PageResult<ReceivablesRespVO>> getReceivablesPage(@Valid ReceivablesPageReqVO pageReqVO) {
|
||||||
PageResult<ReceivablesDO> pageResult = receivablesService.getReceivablesPage(pageReqVO);
|
PageResult<ReceivablesRespVO> pageResult = receivablesService.getReceivablesPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, ReceivablesRespVO.class));
|
return success(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@ -86,7 +90,7 @@ public class ReceivablesController {
|
|||||||
public void exportReceivablesExcel(@Valid ReceivablesPageReqVO pageReqVO,
|
public void exportReceivablesExcel(@Valid ReceivablesPageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<ReceivablesDO> list = receivablesService.getReceivablesPage(pageReqVO).getList();
|
List<ReceivablesRespVO> list = receivablesService.getReceivablesPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "应收款管理.xls", "数据", ReceivablesRespVO.class,
|
ExcelUtils.write(response, "应收款管理.xls", "数据", ReceivablesRespVO.class,
|
||||||
BeanUtils.toBean(list, ReceivablesRespVO.class));
|
BeanUtils.toBean(list, ReceivablesRespVO.class));
|
||||||
|
@ -18,29 +18,7 @@ public class ReceivablesPageReqVO extends PageParam {
|
|||||||
@Schema(description = "项目id")
|
@Schema(description = "项目id")
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
@Schema(description = "主合同id ")
|
@Schema(description = "主合同id")
|
||||||
private Long contractId;
|
private Long contractId;
|
||||||
|
|
||||||
@Schema(description = "方案阶段比例")
|
|
||||||
private String planStage;
|
|
||||||
|
|
||||||
@Schema(description = "初设阶段比例")
|
|
||||||
private String initialDesignStage;
|
|
||||||
|
|
||||||
@Schema(description = "施工图阶段比例")
|
|
||||||
private String constructionDrawingStage;
|
|
||||||
|
|
||||||
@Schema(description = "施工配合阶段")
|
|
||||||
private String constructionStage;
|
|
||||||
|
|
||||||
@Schema(description = "审定阶段")
|
|
||||||
private String approveStage;
|
|
||||||
|
|
||||||
@Schema(description = "回款情况")
|
|
||||||
private String collectionSituation;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] createTime;
|
|
||||||
|
|
||||||
}
|
}
|
@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.pms.controller.admin.receivables.vo;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -12,6 +14,28 @@ import com.alibaba.excel.annotation.*;
|
|||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class ReceivablesRespVO {
|
public class ReceivablesRespVO {
|
||||||
|
|
||||||
|
@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 BigDecimal amount;
|
||||||
|
|
||||||
|
@Schema(description = "审定金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("审定金额")
|
||||||
|
private BigDecimal approvedAmount;
|
||||||
|
|
||||||
|
@Schema(description = "已完成的项目阶段", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("已完成的项目阶段")
|
||||||
|
private String preStage;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("主键")
|
@ExcelProperty("主键")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.pms.controller.admin.receivables.vo;
|
package cn.iocoder.yudao.module.pms.controller.admin.receivables.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.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
@ -9,6 +12,28 @@ import jakarta.validation.constraints.*;
|
|||||||
@Data
|
@Data
|
||||||
public class ReceivablesSaveReqVO {
|
public class ReceivablesSaveReqVO {
|
||||||
|
|
||||||
|
@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 BigDecimal amount;
|
||||||
|
|
||||||
|
@Schema(description = "审定金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("审定金额")
|
||||||
|
private BigDecimal approvedAmount;
|
||||||
|
|
||||||
|
@Schema(description = "已完成的项目阶段", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("已完成的项目阶段")
|
||||||
|
private String preStage;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ -5,12 +5,6 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author wyw
|
|
||||||
* @description
|
|
||||||
* @date 2024/8/14
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
public class ProjectScheduleDetailDO extends ProjectDO {
|
public class ProjectScheduleDetailDO extends ProjectDO {
|
||||||
|
|
||||||
@ -23,4 +17,5 @@ public class ProjectScheduleDetailDO extends ProjectDO {
|
|||||||
* 外部合同商议时间
|
* 外部合同商议时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime exReminderTime;
|
private LocalDateTime exReminderTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,6 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 应收款管理 DO
|
* 应收款管理 DO
|
||||||
*
|
|
||||||
* @author zqc
|
|
||||||
*/
|
*/
|
||||||
@TableName("pms_receivables")
|
@TableName("pms_receivables")
|
||||||
@KeySequence("pms_receivables_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
@KeySequence("pms_receivables_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.pms.dal.dataobject.receivables;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ReceivablesDetailDO extends ReceivablesDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目编号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合同名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签订合同总额
|
||||||
|
*/
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审定金额
|
||||||
|
*/
|
||||||
|
private BigDecimal approvedAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已完成的项目阶段
|
||||||
|
*/
|
||||||
|
private String preStage;
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.pms.dal.dataobject.receivableshistory;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.dataobject.receivables.ReceivablesDO;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ReceivablesHistoryDetailDO extends ReceivablesHistoryDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目编号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合同名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签订合同总额
|
||||||
|
*/
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审定金额
|
||||||
|
*/
|
||||||
|
private BigDecimal approvedAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已完成的项目阶段
|
||||||
|
*/
|
||||||
|
private String preStage;
|
||||||
|
}
|
@ -21,13 +21,13 @@ public interface ReceivablesMapper extends BaseMapperX<ReceivablesDO> {
|
|||||||
return selectPage(reqVO, new LambdaQueryWrapperX<ReceivablesDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<ReceivablesDO>()
|
||||||
.eqIfPresent(ReceivablesDO::getProjectId, reqVO.getProjectId())
|
.eqIfPresent(ReceivablesDO::getProjectId, reqVO.getProjectId())
|
||||||
.eqIfPresent(ReceivablesDO::getContractId, reqVO.getContractId())
|
.eqIfPresent(ReceivablesDO::getContractId, reqVO.getContractId())
|
||||||
.eqIfPresent(ReceivablesDO::getPlanStage, reqVO.getPlanStage())
|
// .eqIfPresent(ReceivablesDO::getPlanStage, reqVO.getPlanStage())
|
||||||
.eqIfPresent(ReceivablesDO::getInitialDesignStage, reqVO.getInitialDesignStage())
|
// .eqIfPresent(ReceivablesDO::getInitialDesignStage, reqVO.getInitialDesignStage())
|
||||||
.eqIfPresent(ReceivablesDO::getConstructionDrawingStage, reqVO.getConstructionDrawingStage())
|
// .eqIfPresent(ReceivablesDO::getConstructionDrawingStage, reqVO.getConstructionDrawingStage())
|
||||||
.eqIfPresent(ReceivablesDO::getConstructionStage, reqVO.getConstructionStage())
|
// .eqIfPresent(ReceivablesDO::getConstructionStage, reqVO.getConstructionStage())
|
||||||
.eqIfPresent(ReceivablesDO::getApproveStage, reqVO.getApproveStage())
|
// .eqIfPresent(ReceivablesDO::getApproveStage, reqVO.getApproveStage())
|
||||||
.eqIfPresent(ReceivablesDO::getCollectionSituation, reqVO.getCollectionSituation())
|
// .eqIfPresent(ReceivablesDO::getCollectionSituation, reqVO.getCollectionSituation())
|
||||||
.betweenIfPresent(ReceivablesDO::getCreateTime, reqVO.getCreateTime())
|
// .betweenIfPresent(ReceivablesDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(ReceivablesDO::getId));
|
.orderByDesc(ReceivablesDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,12 @@ public interface ProjectScheduleService {
|
|||||||
*/
|
*/
|
||||||
ProjectScheduleDO getProjectScheduleDetail(Long projectId);
|
ProjectScheduleDO getProjectScheduleDetail(Long projectId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断项目是否存在
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void validateProjectExists(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -80,6 +80,12 @@ public class ProjectScheduleServiceImpl implements ProjectScheduleService {
|
|||||||
return projectScheduleDOS.get(0);
|
return projectScheduleDOS.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validateProjectExists(Long id) {
|
||||||
|
if (projectScheduleMapper.selectById(id) == null) {
|
||||||
|
throw exception(PROJECT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package cn.iocoder.yudao.module.pms.service.receivables;
|
package cn.iocoder.yudao.module.pms.service.receivables;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.dataobject.receivables.ReceivablesDetailDO;
|
||||||
import jakarta.validation.*;
|
import jakarta.validation.*;
|
||||||
import cn.iocoder.yudao.module.pms.controller.admin.receivables.vo.*;
|
import cn.iocoder.yudao.module.pms.controller.admin.receivables.vo.*;
|
||||||
import cn.iocoder.yudao.module.pms.dal.dataobject.receivables.ReceivablesDO;
|
import cn.iocoder.yudao.module.pms.dal.dataobject.receivables.ReceivablesDO;
|
||||||
@ -14,42 +16,16 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|||||||
*/
|
*/
|
||||||
public interface ReceivablesService {
|
public interface ReceivablesService {
|
||||||
|
|
||||||
/**
|
Long createReceivables(Long loginUserId, @Valid ReceivablesSaveReqVO createReqVO);
|
||||||
* 创建应收款管理
|
|
||||||
*
|
|
||||||
* @param createReqVO 创建信息
|
|
||||||
* @return 编号
|
|
||||||
*/
|
|
||||||
Long createReceivables(@Valid ReceivablesSaveReqVO createReqVO);
|
|
||||||
|
|
||||||
/**
|
void updateReceivables(Long loginUserId, @Valid ReceivablesSaveReqVO updateReqVO);
|
||||||
* 更新应收款管理
|
|
||||||
*
|
|
||||||
* @param updateReqVO 更新信息
|
|
||||||
*/
|
|
||||||
void updateReceivables(@Valid ReceivablesSaveReqVO updateReqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除应收款管理
|
|
||||||
*
|
|
||||||
* @param id 编号
|
|
||||||
*/
|
|
||||||
void deleteReceivables(Long id);
|
void deleteReceivables(Long id);
|
||||||
|
|
||||||
/**
|
ReceivablesDetailDO getReceivablesDetail(Long id);
|
||||||
* 获得应收款管理
|
|
||||||
*
|
|
||||||
* @param id 编号
|
|
||||||
* @return 应收款管理
|
|
||||||
*/
|
|
||||||
ReceivablesDO getReceivables(Long id);
|
|
||||||
|
|
||||||
/**
|
PageResult<ReceivablesRespVO> getReceivablesPage(ReceivablesPageReqVO pageReqVO);
|
||||||
* 获得应收款管理分页
|
|
||||||
*
|
void validReceivablesExists(Long id);
|
||||||
* @param pageReqVO 分页查询
|
|
||||||
* @return 应收款管理分页
|
|
||||||
*/
|
|
||||||
PageResult<ReceivablesDO> getReceivablesPage(ReceivablesPageReqVO pageReqVO);
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,18 @@
|
|||||||
package cn.iocoder.yudao.module.pms.service.receivables;
|
package cn.iocoder.yudao.module.pms.service.receivables;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.cms.api.contract.ContractApi;
|
||||||
|
import cn.iocoder.yudao.module.cms.api.contract.dto.ContractDTO;
|
||||||
|
import cn.iocoder.yudao.module.pms.controller.admin.budget.vo.BudgetRespVO;
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.dataobject.budget.BudgetDetailDO;
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.dataobject.projectschedule.ProjectScheduleDO;
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.dataobject.receivables.ReceivablesDetailDO;
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.dataobject.receivableshistory.ReceivablesHistoryDO;
|
||||||
|
import cn.iocoder.yudao.module.pms.dal.mysql.receivableshistory.ReceivablesHistoryMapper;
|
||||||
|
import cn.iocoder.yudao.module.pms.service.projectschedule.ProjectScheduleService;
|
||||||
|
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;
|
||||||
@ -16,59 +29,178 @@ import cn.iocoder.yudao.module.pms.dal.mysql.receivables.ReceivablesMapper;
|
|||||||
|
|
||||||
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.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 实现类
|
||||||
*
|
|
||||||
* @author zqc
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
public class ReceivablesServiceImpl implements ReceivablesService {
|
public class ReceivablesServiceImpl implements ReceivablesService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收款管理流程定义
|
||||||
|
*/
|
||||||
|
public static final String PROCESS_KEY = "receivables_init";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本
|
||||||
|
*/
|
||||||
|
public static String VERSION = "1";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ReceivablesMapper receivablesMapper;
|
private ReceivablesMapper receivablesMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ContractApi contractApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProjectScheduleService projectScheduleService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmProcessInstanceApi processInstanceApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ReceivablesHistoryMapper receivablesHistoryMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createReceivables(ReceivablesSaveReqVO createReqVO) {
|
public Long createReceivables(Long loginUserId, ReceivablesSaveReqVO createReqVO) {
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||||
|
if (userName == null) {
|
||||||
|
throw exception(USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
Long contractId = createReqVO.getContractId();
|
||||||
|
Long projectId = createReqVO.getProjectId();
|
||||||
|
contractApi.validContractExists(contractId);
|
||||||
|
projectScheduleService.validateProjectExists(projectId);
|
||||||
|
|
||||||
|
Long id = createReqVO.getId();
|
||||||
|
List<ReceivablesDO> receivablesList = receivablesMapper.selectList("project_id", projectId);
|
||||||
|
for (ReceivablesDO receivablesDO : receivablesList) {
|
||||||
|
if (Objects.equals(receivablesDO.getId(), id)) {
|
||||||
|
throw exception(RECEIVABLES_ALREADY_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 插入
|
// 插入
|
||||||
ReceivablesDO receivables = BeanUtils.toBean(createReqVO, ReceivablesDO.class);
|
ReceivablesDO receivables = BeanUtils.toBean(createReqVO, ReceivablesDO.class);
|
||||||
|
receivables.setCreator(userName);
|
||||||
|
receivables.setUpdater(userName);
|
||||||
receivablesMapper.insert(receivables);
|
receivablesMapper.insert(receivables);
|
||||||
|
|
||||||
|
Long receivablesId = receivables.getId();
|
||||||
|
ReceivablesHistoryDO receivablesHistory = BeanUtils.toBean(receivables, ReceivablesHistoryDO.class);
|
||||||
|
|
||||||
|
// 启动流程,写入历史应收款
|
||||||
|
if (id == null) {
|
||||||
|
String processInstanceId = processInstanceApi.createProcessInstance(loginUserId,
|
||||||
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||||
|
.setBusinessKey(String.valueOf(receivablesId)));
|
||||||
|
|
||||||
|
// 写入工作流编号
|
||||||
|
receivablesHistoryMapper.updateById(receivablesHistory.setReceivableId(receivablesId)
|
||||||
|
.setProcessInstanceId(processInstanceId));
|
||||||
|
|
||||||
|
// 写入版本号
|
||||||
|
Long count = receivablesHistoryMapper.selectCount("project_id", projectId);
|
||||||
|
if (count < 1) {
|
||||||
|
receivablesHistory.setVersion(VERSION);
|
||||||
|
} else {
|
||||||
|
receivablesHistory.setVersion(String.valueOf(count + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 写入流程状态
|
||||||
|
receivablesHistory.setProcessStatus("0");
|
||||||
|
// 插入历史应收款
|
||||||
|
receivablesHistoryMapper.insert(receivablesHistory);
|
||||||
|
}
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
return receivables.getId();
|
return receivables.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateReceivables(ReceivablesSaveReqVO updateReqVO) {
|
public void updateReceivables(Long loginUserId, ReceivablesSaveReqVO updateReqVO) {
|
||||||
|
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateReceivablesExists(updateReqVO.getId());
|
validReceivablesExists(updateReqVO.getId());
|
||||||
|
projectScheduleService.validateProjectExists(updateReqVO.getProjectId());
|
||||||
|
contractApi.validContractExists(updateReqVO.getContractId());
|
||||||
// 更新
|
// 更新
|
||||||
ReceivablesDO updateObj = BeanUtils.toBean(updateReqVO, ReceivablesDO.class);
|
ReceivablesDO updateObj = BeanUtils.toBean(updateReqVO, ReceivablesDO.class);
|
||||||
|
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||||
|
if (userName == null) {
|
||||||
|
throw exception(USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
updateObj.setUpdater(userName);
|
||||||
receivablesMapper.updateById(updateObj);
|
receivablesMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteReceivables(Long id) {
|
public void deleteReceivables(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateReceivablesExists(id);
|
validReceivablesExists(id);
|
||||||
// 删除
|
// 删除
|
||||||
receivablesMapper.deleteById(id);
|
receivablesMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateReceivablesExists(Long id) {
|
@Override
|
||||||
|
public ReceivablesDetailDO getReceivablesDetail(Long id) {
|
||||||
|
|
||||||
|
ReceivablesDetailDO receivablesDetailDO = new ReceivablesDetailDO();
|
||||||
|
ReceivablesDO receivablesDO = receivablesMapper.selectById(id);
|
||||||
|
|
||||||
|
if (receivablesDO == null) {
|
||||||
|
throw exception(RECEIVABLES_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
Long contractId = receivablesDO.getContractId();
|
||||||
|
Long projectId = receivablesDO.getProjectId();
|
||||||
|
contractApi.validContractExists(contractId);
|
||||||
|
projectScheduleService.validateProjectExists(projectId);
|
||||||
|
|
||||||
|
ProjectScheduleDO projectSchedule = projectScheduleService.getProjectSchedule(projectId);
|
||||||
|
ContractDTO contractDTO = contractApi.getContractDTO(contractId);
|
||||||
|
|
||||||
|
receivablesDetailDO.setPreStage(projectSchedule.getPreStage());
|
||||||
|
|
||||||
|
BeanUtil.copyProperties(receivablesDO, receivablesDetailDO);
|
||||||
|
BeanUtil.copyProperties(projectSchedule, receivablesDetailDO);
|
||||||
|
BeanUtil.copyProperties(contractDTO, receivablesDetailDO);
|
||||||
|
|
||||||
|
return receivablesDetailDO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<ReceivablesRespVO> getReceivablesPage(ReceivablesPageReqVO pageReqVO) {
|
||||||
|
|
||||||
|
PageResult<ReceivablesDO> receivablesDOPageResult = receivablesMapper.selectPage(pageReqVO);
|
||||||
|
List<ReceivablesDO> receivablesDOList = receivablesDOPageResult.getList();
|
||||||
|
List<ReceivablesDetailDO> receivablesDetailDOList =new ArrayList<>();
|
||||||
|
|
||||||
|
for (ReceivablesDO receivablesDO : receivablesDOList) {
|
||||||
|
Long id = receivablesDO.getId();
|
||||||
|
ReceivablesDetailDO receivablesDetail = getReceivablesDetail(id);
|
||||||
|
receivablesDetailDOList.add(receivablesDetail);
|
||||||
|
}
|
||||||
|
List<ReceivablesRespVO> respVOList = BeanUtils.toBean(receivablesDetailDOList, ReceivablesRespVO.class);
|
||||||
|
PageResult<ReceivablesRespVO> pageResult = new PageResult<>();
|
||||||
|
pageResult.setList(respVOList);
|
||||||
|
|
||||||
|
return pageResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validReceivablesExists(Long id) {
|
||||||
if (receivablesMapper.selectById(id) == null) {
|
if (receivablesMapper.selectById(id) == null) {
|
||||||
throw exception(RECEIVABLES_NOT_EXISTS);
|
throw exception(RECEIVABLES_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ReceivablesDO getReceivables(Long id) {
|
|
||||||
return receivablesMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<ReceivablesDO> getReceivablesPage(ReceivablesPageReqVO pageReqVO) {
|
|
||||||
return receivablesMapper.selectPage(pageReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user