[fix] 优化外包合同管理功能

This commit is contained in:
wyw 2024-07-26 16:43:48 +08:00
parent 0a52eddbc6
commit 027a5d1e1c
7 changed files with 72 additions and 26 deletions

View File

@ -62,10 +62,10 @@ public class OutsContractController {
@GetMapping("/get") @GetMapping("/get")
@Operation(summary = "获得外包合同") @Operation(summary = "获得外包合同")
@Parameter(name = "contractId", description = "主合同编号", required = true, example = "1") @Parameter(name = "id", description = "主合同编号", required = true, example = "1")
@PreAuthorize("@ss.hasPermission('cms:outs-contract:query')") @PreAuthorize("@ss.hasPermission('cms:outs-contract:query')")
public CommonResult<OutsContractRespVO> getOutsContract(@RequestParam("contractId") Long contractId) { public CommonResult<OutsContractRespVO> getOutsContract(@RequestParam("id") Long id) {
OutsContractRespVO outsContractRespVO = outsContractService.getOutsContract(contractId); OutsContractRespVO outsContractRespVO = outsContractService.getOutsContract(id);
return success(outsContractRespVO); return success(outsContractRespVO);
} }
@ -89,5 +89,4 @@ public class OutsContractController {
ExcelUtils.write(response, "外包合同.xls", "数据", OutsContractRespVO.class, ExcelUtils.write(response, "外包合同.xls", "数据", OutsContractRespVO.class,
BeanUtils.toBean(list, OutsContractRespVO.class)); BeanUtils.toBean(list, OutsContractRespVO.class));
} }
} }

View File

@ -29,7 +29,8 @@ public class OutsContractRespVO {
@Schema(description = "签订合同总额") @Schema(description = "签订合同总额")
@ExcelProperty("签订合同总额") @ExcelProperty("签订合同总额")
private BigDecimal amount; private BigDecimal outsAmount;
@Schema(description = "外包合同编号") @Schema(description = "外包合同编号")
@ExcelProperty("编号") @ExcelProperty("编号")
@ -49,11 +50,9 @@ public class OutsContractRespVO {
@DictFormat("contract_billing_type") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中 @DictFormat("contract_billing_type") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private String countType; private String countType;
@Schema(description = "外包合同总额")
@Schema(description = "外包合同金额") @ExcelProperty("外包合同总额")
@ExcelProperty("外包合同金额") private BigDecimal amount;
private BigDecimal outsAmount;
@Schema(description = "专业") @Schema(description = "专业")
@ExcelProperty(value = "专业", converter = DictConvert.class) @ExcelProperty(value = "专业", converter = DictConvert.class)

View File

@ -44,11 +44,11 @@ public class OutsContractDO extends BaseDO {
/** /**
* 类型 * 类型
* *
* 枚举 * 枚举 //// TODO 搞成枚举
*/ */
private String countType; private String countType;
/** /**
* 合同金额 * 外包合同金额
*/ */
private BigDecimal amount; private BigDecimal amount;
/** /**
@ -58,7 +58,7 @@ public class OutsContractDO extends BaseDO {
/** /**
* 专业 * 专业
* *
* 枚举 * 枚举 // TODO 搞成枚举
*/ */
private String major; private String major;
/** /**

View File

@ -118,8 +118,8 @@ public class ContractServiceImpl implements ContractService {
contractRespVO.setProjectManager(projectDetail.getProjectManagerName()); contractRespVO.setProjectManager(projectDetail.getProjectManagerName());
//分包合同商议提示 TODO 待优化 //分包合同商议提示 TODO 待优化
ExtContractDO extContractDO = extContractMapper.selectOne("project_id", projectId); // ExtContractDO extContractDO = extContractMapper.selectOne("project_id", projectId);
LocalDateTime reminderTime = extContractDO.getReminderTime(); // LocalDateTime reminderTime = extContractDO.getReminderTime();
contractRespVO.setReminderTime(LocalDateTime.now()); contractRespVO.setReminderTime(LocalDateTime.now());
//暂定结算数 //暂定结算数

View File

@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.cms.service.extContract;
import cn.iocoder.yudao.module.cms.controller.admin.extContract.vo.ExtContractPageReqVO; import cn.iocoder.yudao.module.cms.controller.admin.extContract.vo.ExtContractPageReqVO;
import cn.iocoder.yudao.module.cms.controller.admin.extContract.vo.ExtContractRespVO; import cn.iocoder.yudao.module.cms.controller.admin.extContract.vo.ExtContractRespVO;
import cn.iocoder.yudao.module.cms.controller.admin.extContract.vo.ExtContractSaveReqVO; import cn.iocoder.yudao.module.cms.controller.admin.extContract.vo.ExtContractSaveReqVO;
import cn.iocoder.yudao.module.cms.dal.dataobject.contract.ContractDO;
import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO; import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO;
import cn.iocoder.yudao.module.cms.dal.dataobject.extContract.ExtContractDO; import cn.iocoder.yudao.module.cms.dal.dataobject.extContract.ExtContractDO;
import cn.iocoder.yudao.module.cms.dal.mysql.customerCompany.CustomerCompanyMapper; import cn.iocoder.yudao.module.cms.dal.mysql.customerCompany.CustomerCompanyMapper;
@ -93,7 +92,7 @@ public class ExtContractServiceImpl implements ExtContractService {
// 3.项目经理 pms_project找到的是id 需要联表 // 3.项目经理 pms_project找到的是id 需要联表
// 4.客户公司名称 pms_project 联表 // 4.客户公司名称 pms_project 联表
// 5.合同总金额 // 5.合同总金额
// 6.合同商议提示和分包提示不一样 // 6.合同商议提示和分包提示不一样
@Override @Override
public ExtContractRespVO getExtContract(Long id) { public ExtContractRespVO getExtContract(Long id) {
//校验 //校验

View File

@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.cms.controller.admin.outscontract.vo.OutsContract
import cn.iocoder.yudao.module.cms.dal.dataobject.outscontract.OutsContractDO; import cn.iocoder.yudao.module.cms.dal.dataobject.outscontract.OutsContractDO;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.List;
/** /**
* 外包合同 Service 接口 * 外包合同 Service 接口
* *

View File

@ -2,19 +2,24 @@ package cn.iocoder.yudao.module.cms.service.outscontract;
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 cn.iocoder.yudao.module.cms.controller.admin.contract.vo.ContractRespVO;
import cn.iocoder.yudao.module.cms.controller.admin.outscontract.vo.OutsContractPageReqVO; import cn.iocoder.yudao.module.cms.controller.admin.outscontract.vo.OutsContractPageReqVO;
import cn.iocoder.yudao.module.cms.controller.admin.outscontract.vo.OutsContractRespVO; import cn.iocoder.yudao.module.cms.controller.admin.outscontract.vo.OutsContractRespVO;
import cn.iocoder.yudao.module.cms.controller.admin.outscontract.vo.OutsContractSaveReqVO; import cn.iocoder.yudao.module.cms.controller.admin.outscontract.vo.OutsContractSaveReqVO;
import cn.iocoder.yudao.module.cms.dal.dataobject.outscontract.OutsContractDO; 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.dal.mysql.outscontract.OutsContractMapper;
import cn.iocoder.yudao.module.cms.service.contract.ContractService; import cn.iocoder.yudao.module.cms.service.contract.ContractService;
import cn.iocoder.yudao.module.pms.api.ProjectApi;
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.List;
import java.util.Objects;
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_NOT_EXISTS; import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.OUTS_CONTRACT_NOT_EXISTS;
/** /**
* 外包合同 Service 实现类 * 外包合同 Service 实现类
@ -31,9 +36,26 @@ public class OutsContractServiceImpl implements OutsContractService {
@Resource @Resource
private ContractService contractService; private ContractService contractService;
@Resource
private ProjectApi projectApi;
@Override @Override
public Long createOutsContract(OutsContractSaveReqVO createReqVO) { public Long createOutsContract(OutsContractSaveReqVO createReqVO) {
OutsContractDO outsContract = BeanUtils.toBean(createReqVO, OutsContractDO.class); OutsContractDO outsContract = BeanUtils.toBean(createReqVO, OutsContractDO.class);
//TODO 待优化 把校验逻辑提取
Long contractId = outsContract.getContractId();
ContractRespVO contract = contractService.getContract(contractId);
if (contract == null) {
throw exception(CONTRACT_NOT_EXISTS);
}
Long projectId = outsContract.getProjectId();
ProjectRespDTO project = projectApi.getProject(projectId);
if (project == null) {
throw exception(PROJECT_NOT_EXISTS);
}
outsContractMapper.insert(outsContract); outsContractMapper.insert(outsContract);
return outsContract.getId(); return outsContract.getId();
} }
@ -42,6 +64,16 @@ public class OutsContractServiceImpl implements OutsContractService {
public void updateOutsContract(OutsContractSaveReqVO updateReqVO) { public void updateOutsContract(OutsContractSaveReqVO updateReqVO) {
// 校验 // 校验
validateOutsContractExists(updateReqVO.getId()); validateOutsContractExists(updateReqVO.getId());
//TODO 待优化 把校验逻辑提取
Long contractId = updateReqVO.getContractId();
ContractRespVO contract = contractService.getContract(contractId);
if (contract == null) {
throw exception(CONTRACT_NOT_EXISTS);
}
OutsContractDO outsContractDO = outsContractMapper.selectById(updateReqVO.getId());
if (!Objects.equals(updateReqVO.getProjectId(), outsContractDO.getProjectId())) {
throw exception(PROJECT_NOT_EXISTS);
}
// 更新 // 更新
OutsContractDO updateObj = BeanUtils.toBean(updateReqVO, OutsContractDO.class); OutsContractDO updateObj = BeanUtils.toBean(updateReqVO, OutsContractDO.class);
outsContractMapper.updateById(updateObj); outsContractMapper.updateById(updateObj);
@ -55,14 +87,29 @@ public class OutsContractServiceImpl implements OutsContractService {
outsContractMapper.deleteById(id); outsContractMapper.deleteById(id);
} }
@Override // 需要联表查询
public OutsContractRespVO getOutsContract(Long contractId) { // 1.合同名称
//校验 // 2.主控部门(跟踪部门)
if (contractId == null){ // 3.项目经理
throw exception(CONTRACT_NOT_EXISTS); // 4.签订合同总额
}
return null; @Override
public OutsContractRespVO getOutsContract(Long id) {
//校验
if (id == null) {
throw exception(OUTS_CONTRACT_NOT_EXISTS);
}
OutsContractDO outsContractDO = outsContractMapper.selectById(id);
OutsContractRespVO outsContractRespVO = BeanUtils.toBean(outsContractDO, OutsContractRespVO.class);
Long contractId = outsContractDO.getContractId();
ContractRespVO contract = contractService.getContract(contractId);
outsContractRespVO.setName(contract.getName());
outsContractRespVO.setTrackingDep(contract.getTrackingDep());
outsContractRespVO.setProjectManager(contract.getProjectManager());
outsContractRespVO.setOutsAmount(contract.getAmount());
return outsContractRespVO;
} }
@Override @Override