[fix] 优化合同管理功能

This commit is contained in:
wyw 2024-07-24 11:02:40 +08:00
parent c44b48ec3f
commit 57b1000fc5
5 changed files with 65 additions and 27 deletions

View File

@ -16,6 +16,7 @@ import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.*; import jakarta.validation.*;
import jakarta.servlet.http.*; import jakarta.servlet.http.*;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@ -51,7 +52,7 @@ public class ContractController {
@DeleteMapping("/delete") @DeleteMapping("/delete")
@Operation(summary = "删除合同") @Operation(summary = "删除合同")
@Parameter(name = "id", description = "项目id", required = true) @Parameter(name = "id", description = "合同id", required = true)
@PreAuthorize("@ss.hasPermission('cms:contract:delete')") @PreAuthorize("@ss.hasPermission('cms:contract:delete')")
public CommonResult<Boolean> deleteContract(@RequestParam("id") Long id) { public CommonResult<Boolean> deleteContract(@RequestParam("id") Long id) {
contractService.deleteContract(id); contractService.deleteContract(id);
@ -60,19 +61,19 @@ public class ContractController {
@GetMapping("/get") @GetMapping("/get")
@Operation(summary = "获得合同") @Operation(summary = "获得合同")
@Parameter(name = "projectId", description = "项目id", required = true) @Parameter(name = "id", description = "合同id", required = true)
@PreAuthorize("@ss.hasPermission('cms:contract:query')") @PreAuthorize("@ss.hasPermission('cms:contract:query')")
public CommonResult<ContractRespVO> getContract(@RequestParam("projectId") Long projectId) { public CommonResult<ContractRespVO> getContract(@RequestParam("id") Long id) {
ContractRespVO contractRespVO = contractService.getContract(projectId); ContractRespVO contractRespVO = contractService.getContract(id);
return success(contractRespVO); return success(contractRespVO);
} }
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得合同分页") @Operation(summary = "获得合同分页")
@PreAuthorize("@ss.hasPermission('cms:contract:query')") @PreAuthorize("@ss.hasPermission('cms:contract:query')")
public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid ContractPageReqVO pageReqVO) { public CommonResult<PageResult<ContractDO>> getContractPage(@Valid ContractPageReqVO pageReqVO) {
PageResult<ContractDO> pageResult = contractService.getContractPage(pageReqVO); PageResult<ContractDO> pageResult = contractService.getContractPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ContractRespVO.class)); return success(pageResult);
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ -88,6 +89,4 @@ public class ContractController {
BeanUtils.toBean(list, ContractRespVO.class)); BeanUtils.toBean(list, ContractRespVO.class));
} }
} }

View File

@ -97,19 +97,4 @@ public class ContractSaveReqVO {
@Schema(description = "其他费") @Schema(description = "其他费")
private BigDecimal otherFee; private BigDecimal otherFee;
@Schema(description = "创建者")
private String creator;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "创建时间不能为空")
private LocalDateTime createTime;
@Schema(description = "更新者")
private String updater;
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "更新时间不能为空")
private LocalDateTime updateTime;
} }

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.cms.dal.dataobject.contract; package cn.iocoder.yudao.module.cms.dal.dataobject.contract;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -144,4 +146,25 @@ public class ContractDO extends BaseDO {
*/ */
private BigDecimal otherFee; private BigDecimal otherFee;
/**
* 创建者
*/
private String creator;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新者
*/
private String updater;
/**
* 更新时间
*/
private LocalDateTime updateTime;
} }

View File

@ -5,6 +5,8 @@ import cn.iocoder.yudao.module.cms.controller.admin.contract.vo.*;
import cn.iocoder.yudao.module.cms.dal.dataobject.contract.ContractDO; import cn.iocoder.yudao.module.cms.dal.dataobject.contract.ContractDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import java.math.BigDecimal;
/** /**
* 合同 Service 接口 * 合同 Service 接口
* *
@ -50,4 +52,10 @@ public interface ContractService {
*/ */
PageResult<ContractDO> getContractPage(ContractPageReqVO pageReqVO); PageResult<ContractDO> getContractPage(ContractPageReqVO pageReqVO);
/**
* 获得暂定结算金额
* @param id 合同编号
* @return
*/
BigDecimal getProvisionalSettlement(Long id);
} }

View File

@ -15,6 +15,8 @@ import cn.iocoder.yudao.module.cms.dal.dataobject.contract.ContractDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import java.math.BigDecimal;
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.*; import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*;
@ -66,8 +68,10 @@ public class ContractServiceImpl implements ContractService {
} }
@Override @Override
public ContractRespVO getContract(Long projectId) { public ContractRespVO getContract(Long id) {
ContractDO contractDO = contractMapper.selectOne("project_id",projectId);
ContractDO contractDO = contractMapper.selectById(id);
Long projectId = contractDO.getProjectId();
ContractRespVO contractRespVO = BeanUtils.toBean(contractDO, ContractRespVO.class); ContractRespVO contractRespVO = BeanUtils.toBean(contractDO, ContractRespVO.class);
// 需要联表查询 // 需要联表查询
@ -77,7 +81,7 @@ public class ContractServiceImpl implements ContractService {
// 4.出图公司 pms_project 直接 // 4.出图公司 pms_project 直接
// 5.预计合同金额 pms_project 直接 // 5.预计合同金额 pms_project 直接
// 6.分包合同商议提示 pms_project_schedule // 6.分包合同商议提示 pms_project_schedule
// 7.暂定结算数 // 7.暂定结算数
ProjectRespDTO project = projectApi.getProject(projectId); ProjectRespDTO project = projectApi.getProject(projectId);
contractRespVO.setCode(project.getCode()); contractRespVO.setCode(project.getCode());
contractRespVO.setDrawingCompany(project.getDrawingCompany()); contractRespVO.setDrawingCompany(project.getDrawingCompany());
@ -87,7 +91,9 @@ public class ContractServiceImpl implements ContractService {
contractRespVO.setTrackingDep(projectDetail.getTrackingDepName()); contractRespVO.setTrackingDep(projectDetail.getTrackingDepName());
contractRespVO.setProjectManager(projectDetail.getProjectManagerName()); contractRespVO.setProjectManager(projectDetail.getProjectManagerName());
//暂定结算数
BigDecimal provisionalSettlement = getProvisionalSettlement(id);
contractRespVO.setProvisionalSettlement(provisionalSettlement);
return contractRespVO; return contractRespVO;
@ -98,4 +104,21 @@ public class ContractServiceImpl implements ContractService {
return contractMapper.selectPage(pageReqVO); return contractMapper.selectPage(pageReqVO);
} }
@Override
public BigDecimal getProvisionalSettlement(Long id) {
ContractDO contractDO = contractMapper.selectById(id);
String type = contractDO.getType();
BigDecimal amount = contractDO.getAmount();
BigDecimal bigDecimal = new BigDecimal(String.valueOf(amount));
BigDecimal mul = new BigDecimal("0.85");
BigDecimal res = null;
if ("费率合同".equals(type)) {
res = bigDecimal.multiply(mul);
} else if ("总价合同".equals(type)) {
res = amount;
}
return res;
}
} }