mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
[feat] 新增合同历史管理
This commit is contained in:
@ -14,14 +14,19 @@ import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
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;
|
||||
|
||||
@ -38,14 +43,14 @@ public class ContractController {
|
||||
@Operation(summary = "创建合同")
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract:create')")
|
||||
public CommonResult<Long> createContract(@Valid @RequestBody ContractSaveReqVO createReqVO) {
|
||||
return success(contractService.createContract(getLoginUserId(),createReqVO));
|
||||
return success(contractService.createContract(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新合同")
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract:update')")
|
||||
public CommonResult<Boolean> updateContract(@Valid @RequestBody ContractSaveReqVO updateReqVO) {
|
||||
contractService.updateContract(getLoginUserId(),updateReqVO);
|
||||
contractService.updateContract(getLoginUserId(), updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -80,12 +85,11 @@ public class ContractController {
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportContractExcel(@Valid ContractPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ContractRespVO> list = contractService.getContractPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "合同.xls", "数据", ContractRespVO.class,
|
||||
BeanUtils.toBean(list, ContractRespVO.class));
|
||||
BeanUtils.toBean(list, ContractRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,8 @@
|
||||
package cn.iocoder.yudao.module.cms.controller.admin.contract.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 合同分页 Request VO")
|
||||
@Data
|
||||
@ -29,75 +23,9 @@ public class ContractPageReqVO extends PageParam {
|
||||
@Schema(description = "合同进展")
|
||||
private String progress;
|
||||
|
||||
@Schema(description = "合同拟定时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] expectedTime;
|
||||
|
||||
@Schema(description = "合同用印时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] printingTime;
|
||||
|
||||
@Schema(description = "签订时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] signingTime;
|
||||
|
||||
@Schema(description = "归档时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] archiveTime;
|
||||
|
||||
@Schema(description = "合同状态", example = "1")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "计费方式", example = "1")
|
||||
private String countType;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "合同url", example = "https://www.iocoder.cn")
|
||||
private String contractFileUrl;
|
||||
|
||||
@Schema(description = "建安费")
|
||||
private BigDecimal constructionCost;
|
||||
|
||||
@Schema(description = "资金来源")
|
||||
private String source;
|
||||
|
||||
@Schema(description = "优惠", example = "17910")
|
||||
private String discount;
|
||||
|
||||
@Schema(description = "是否联合体")
|
||||
private Boolean consortium;
|
||||
|
||||
@Schema(description = "联合体单位")
|
||||
private String consortiumCompany;
|
||||
|
||||
@Schema(description = "占主合同比例")
|
||||
private String extProportion;
|
||||
|
||||
@Schema(description = "审定金额")
|
||||
private BigDecimal approvedAmount;
|
||||
|
||||
@Schema(description = "审核文件url", example = "https://www.iocoder.cn")
|
||||
private String reviewFileUrl;
|
||||
|
||||
|
||||
@Schema(description = "签订合同总额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "前期费")
|
||||
private BigDecimal preAmount;
|
||||
|
||||
@Schema(description = "设计费")
|
||||
private BigDecimal designAmount;
|
||||
|
||||
@Schema(description = "勘测费")
|
||||
private BigDecimal surveyFees;
|
||||
|
||||
@Schema(description = "测量费")
|
||||
private BigDecimal measurementFee;
|
||||
|
||||
@Schema(description = "其他费")
|
||||
private BigDecimal otherFee;
|
||||
|
||||
}
|
@ -11,6 +11,7 @@ import com.alibaba.excel.annotation.*;
|
||||
@Schema(description = "管理后台 - 合同 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@EqualsAndHashCode
|
||||
public class ContractRespVO {
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 合同新增/修改 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
public class ContractSaveReqVO {
|
||||
|
||||
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ -30,7 +31,7 @@ public class ContractSaveReqVO {
|
||||
|
||||
@Schema(description = "分包合同提示时间")
|
||||
@ExcelProperty("分包合同提示时间")
|
||||
private LocalDateTime ReminderTime;
|
||||
private LocalDateTime reminderTime;
|
||||
|
||||
@Schema(description = "暂定结算数")
|
||||
@ExcelProperty("暂定结算数")
|
||||
@ -44,6 +45,8 @@ public class ContractSaveReqVO {
|
||||
@ExcelProperty("预计合同金额")
|
||||
private BigDecimal expectedContractAmount;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "合同名称不能为空")
|
||||
private String name;
|
||||
|
@ -1,7 +1,4 @@
|
||||
package cn.iocoder.yudao.module.cms.controller.admin.contractHistory;
|
||||
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.contractHistory.ContractHistoryDO;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.contract.ContractMapper;
|
||||
import cn.iocoder.yudao.module.cms.service.contractHistory.ContractHistoryService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -14,7 +11,6 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
|
||||
import java.beans.Beans;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@ -28,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.cms.controller.admin.contractHistory.vo.*;
|
||||
|
||||
@ -40,33 +37,12 @@ public class ContractHistoryController {
|
||||
@Resource
|
||||
private ContractHistoryService contractHistoryService;
|
||||
|
||||
@Resource
|
||||
private ContractMapper contractMapper;
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建历史合同")
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract-history:create')")
|
||||
public CommonResult<Long> createContractHistory(@Valid @RequestBody ContractHistorySaveReqVO createReqVO) {
|
||||
return success(contractHistoryService.createContractHistory(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新历史合同")
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract-history:update')")
|
||||
public CommonResult<Boolean> updateContractHistory(@Valid @RequestBody ContractHistorySaveReqVO updateReqVO) {
|
||||
contractHistoryService.updateContractHistory(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除历史合同")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract-history:delete')")
|
||||
public CommonResult<Boolean> deleteContractHistory(@RequestParam("id") Long id) {
|
||||
contractHistoryService.deleteContractHistory(id);
|
||||
contractHistoryService.updateContractHistory(getLoginUserId(),updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -74,17 +50,17 @@ public class ContractHistoryController {
|
||||
@Operation(summary = "获得历史合同")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract-history:query')")
|
||||
public CommonResult<ContractHistoryDO> getContractHistory(@RequestParam("id") Long id) {
|
||||
ContractHistoryDO contractHistory = contractHistoryService.getContractHistory(id);
|
||||
return success(BeanUtils.toBean(contractHistory, ContractHistoryDO.class));
|
||||
public CommonResult<ContractHistoryRespVO> getContractHistory(@RequestParam("id") Long id) {
|
||||
ContractHistoryRespVO contractHistory = contractHistoryService.getContractHistory(id);
|
||||
return success(contractHistory);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得历史合同分页")
|
||||
@PreAuthorize("@ss.hasPermission('cms:contract-history:query')")
|
||||
public CommonResult<PageResult<ContractHistoryRespVO>> getContractHistoryPage(@Valid ContractHistoryPageReqVO pageReqVO) {
|
||||
PageResult<ContractHistoryDO> pageResult = contractHistoryService.getContractHistoryPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ContractHistoryRespVO.class));
|
||||
PageResult<ContractHistoryRespVO> pageResult = contractHistoryService.getContractHistoryPage(pageReqVO);
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ -94,10 +70,9 @@ public class ContractHistoryController {
|
||||
public void exportContractHistoryExcel(@Valid ContractHistoryPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ContractHistoryDO> list = contractHistoryService.getContractHistoryPage(pageReqVO).getList();
|
||||
List<ContractHistoryRespVO> list = contractHistoryService.getContractHistoryPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "历史合同.xls", "数据", ContractHistoryRespVO.class,
|
||||
BeanUtils.toBean(list, ContractHistoryRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -3,18 +3,18 @@ package cn.iocoder.yudao.module.cms.controller.admin.contractHistory.vo;
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 历史合同分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ContractHistoryPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "合同编号")
|
||||
private Long contractId;
|
||||
|
||||
@Schema(description = "项目id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long projectId;
|
||||
|
||||
@Schema(description = "流程实体id", example = "12536")
|
||||
private String processInstanceId;
|
||||
|
||||
@ -27,103 +27,13 @@ public class ContractHistoryPageReqVO extends PageParam {
|
||||
@Schema(description = "合同进展")
|
||||
private String progress;
|
||||
|
||||
@Schema(description = "合同拟定时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] expectedTime;
|
||||
|
||||
@Schema(description = "合同用印时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] printingTime;
|
||||
|
||||
@Schema(description = "签订时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] signingTime;
|
||||
|
||||
@Schema(description = "归档时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] archiveTime;
|
||||
|
||||
@Schema(description = "合同状态", example = "1")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "计费方式", example = "2")
|
||||
@Schema(description = "计费方式")
|
||||
private String countType;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "合同url", example = "https://www.iocoder.cn")
|
||||
private String contractFileUrl;
|
||||
|
||||
@Schema(description = "建安费")
|
||||
private BigDecimal constructionCost;
|
||||
|
||||
@Schema(description = "资金来源")
|
||||
private String source;
|
||||
|
||||
@Schema(description = "优惠", example = "18154")
|
||||
private String discount;
|
||||
|
||||
@Schema(description = "是否联合体")
|
||||
private Boolean consortium;
|
||||
|
||||
@Schema(description = "联合体单位")
|
||||
private String consortiumCompany;
|
||||
|
||||
@Schema(description = "占主合同比例")
|
||||
private String extProportion;
|
||||
|
||||
@Schema(description = "审定金额")
|
||||
private BigDecimal approvedAmount;
|
||||
|
||||
@Schema(description = "审核文件url", example = "https://www.iocoder.cn")
|
||||
private String reviewFileUrl;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "更新者")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] updateTime;
|
||||
|
||||
@Schema(description = "是否删除")
|
||||
private Boolean deleted;
|
||||
|
||||
@Schema(description = "租户编号", example = "23584")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "签订合同总额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "前期费")
|
||||
private BigDecimal preAmount;
|
||||
|
||||
@Schema(description = "设计费")
|
||||
private BigDecimal designAmount;
|
||||
|
||||
@Schema(description = "勘测费")
|
||||
private BigDecimal surveyFees;
|
||||
|
||||
@Schema(description = "测量费")
|
||||
private BigDecimal measurementFee;
|
||||
|
||||
@Schema(description = "其他费")
|
||||
private BigDecimal otherFee;
|
||||
|
||||
@Schema(description = "流程状态", example = "2")
|
||||
private String processStatus;
|
||||
|
||||
@Schema(description = "合同", example = "20704")
|
||||
private Long contractId;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private String version;
|
||||
|
||||
}
|
@ -46,7 +46,6 @@ public class ContractHistoryRespVO {
|
||||
@ExcelProperty("流程实体id")
|
||||
private String processInstanceId;
|
||||
|
||||
|
||||
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("合同名称")
|
||||
private String name;
|
||||
@ -123,29 +122,6 @@ public class ContractHistoryRespVO {
|
||||
@ExcelProperty("审核文件url")
|
||||
private String reviewFileUrl;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
@ExcelProperty("创建者")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新者")
|
||||
@ExcelProperty("更新者")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "是否删除", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("是否删除")
|
||||
private Boolean deleted;
|
||||
|
||||
@Schema(description = "租户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23584")
|
||||
@ExcelProperty("租户编号")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "签订合同总额")
|
||||
@ExcelProperty("签订合同总额")
|
||||
@ -171,14 +147,14 @@ public class ContractHistoryRespVO {
|
||||
@ExcelProperty("其他费")
|
||||
private BigDecimal otherFee;
|
||||
|
||||
@Schema(description = "流程状态", example = "2")
|
||||
@ExcelProperty("流程状态")
|
||||
private String processStatus;
|
||||
|
||||
@Schema(description = "合同", example = "20704")
|
||||
@ExcelProperty("合同")
|
||||
private Long contractId;
|
||||
|
||||
@Schema(description = "流程状态", example = "2")
|
||||
@ExcelProperty("流程状态")
|
||||
private String processStatus;
|
||||
|
||||
@Schema(description = "版本")
|
||||
@ExcelProperty("版本")
|
||||
private String version;
|
||||
|
@ -1,8 +1,10 @@
|
||||
package cn.iocoder.yudao.module.cms.controller.admin.contractHistory.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ -13,12 +15,40 @@ public class ContractHistorySaveReqVO {
|
||||
@Schema(description = "历史合同编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
@Schema(description = "项目id", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
private Long projectId;
|
||||
|
||||
@Schema(description = "流程实体id", example = "12536")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SJ24001")
|
||||
@ExcelProperty("项目编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "主控部门", requiredMode = Schema.RequiredMode.REQUIRED, example = "生产一部")
|
||||
@ExcelProperty("主控部门")
|
||||
private String trackingDep;
|
||||
|
||||
@Schema(description = "项目经理", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("项目经理")
|
||||
private String projectManager;
|
||||
|
||||
@Schema(description = "分包合同提示时间")
|
||||
@ExcelProperty("分包合同提示时间")
|
||||
private LocalDateTime ReminderTime;
|
||||
|
||||
@Schema(description = "暂定结算数")
|
||||
@ExcelProperty("暂定结算数")
|
||||
private BigDecimal provisionalSettlement;
|
||||
|
||||
@Schema(description = "出图公司", requiredMode = Schema.RequiredMode.REQUIRED, example = "***设计院")
|
||||
@ExcelProperty("出图公司")
|
||||
private String drawingCompany;
|
||||
|
||||
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "200.0000")
|
||||
@ExcelProperty("预计合同金额")
|
||||
private BigDecimal expectedContractAmount;
|
||||
|
||||
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "合同名称不能为空")
|
||||
private String name;
|
||||
@ -83,28 +113,6 @@ public class ContractHistorySaveReqVO {
|
||||
@Schema(description = "审核文件url", example = "https://www.iocoder.cn")
|
||||
private String reviewFileUrl;
|
||||
|
||||
@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;
|
||||
|
||||
@Schema(description = "是否删除", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否删除不能为空")
|
||||
private Boolean deleted;
|
||||
|
||||
@Schema(description = "租户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23584")
|
||||
@NotNull(message = "租户编号不能为空")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "签订合同总额")
|
||||
private BigDecimal amount;
|
||||
|
||||
|
@ -148,5 +148,4 @@ public class ContractHistoryDO extends BaseDO {
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
}
|
@ -19,29 +19,10 @@ public interface ContractMapper extends BaseMapperX<ContractDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ContractDO>()
|
||||
.likeIfPresent(ContractDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ContractDO::getType, reqVO.getType())
|
||||
.eqIfPresent(ContractDO::getProjectId, reqVO.getProjectId())
|
||||
.eqIfPresent(ContractDO::getProgress, reqVO.getProgress())
|
||||
.betweenIfPresent(ContractDO::getExpectedTime, reqVO.getExpectedTime())
|
||||
.betweenIfPresent(ContractDO::getPrintingTime, reqVO.getPrintingTime())
|
||||
.betweenIfPresent(ContractDO::getSigningTime, reqVO.getSigningTime())
|
||||
.betweenIfPresent(ContractDO::getArchiveTime, reqVO.getArchiveTime())
|
||||
.eqIfPresent(ContractDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ContractDO::getCountType, reqVO.getCountType())
|
||||
.eqIfPresent(ContractDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(ContractDO::getContractFileUrl, reqVO.getContractFileUrl())
|
||||
.eqIfPresent(ContractDO::getConstructionCost, reqVO.getConstructionCost())
|
||||
.eqIfPresent(ContractDO::getSource, reqVO.getSource())
|
||||
.eqIfPresent(ContractDO::getDiscount, reqVO.getDiscount())
|
||||
.eqIfPresent(ContractDO::getConsortium, reqVO.getConsortium())
|
||||
.eqIfPresent(ContractDO::getConsortiumCompany, reqVO.getConsortiumCompany())
|
||||
.eqIfPresent(ContractDO::getExtProportion, reqVO.getExtProportion())
|
||||
.eqIfPresent(ContractDO::getApprovedAmount, reqVO.getApprovedAmount())
|
||||
.eqIfPresent(ContractDO::getReviewFileUrl, reqVO.getReviewFileUrl())
|
||||
.eqIfPresent(ContractDO::getAmount, reqVO.getAmount())
|
||||
.eqIfPresent(ContractDO::getPreAmount, reqVO.getPreAmount())
|
||||
.eqIfPresent(ContractDO::getDesignAmount, reqVO.getDesignAmount())
|
||||
.eqIfPresent(ContractDO::getSurveyFees, reqVO.getSurveyFees())
|
||||
.eqIfPresent(ContractDO::getMeasurementFee, reqVO.getMeasurementFee())
|
||||
.eqIfPresent(ContractDO::getOtherFee, reqVO.getOtherFee())
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -19,39 +19,13 @@ public interface ContractHistoryMapper extends BaseMapperX<ContractHistoryDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ContractHistoryDO>()
|
||||
.eqIfPresent(ContractHistoryDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.likeIfPresent(ContractHistoryDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ContractHistoryDO::getProjectId,reqVO.getProjectId())
|
||||
.eqIfPresent(ContractHistoryDO::getType, reqVO.getType())
|
||||
.eqIfPresent(ContractHistoryDO::getProgress, reqVO.getProgress())
|
||||
.betweenIfPresent(ContractHistoryDO::getExpectedTime, reqVO.getExpectedTime())
|
||||
.betweenIfPresent(ContractHistoryDO::getPrintingTime, reqVO.getPrintingTime())
|
||||
.betweenIfPresent(ContractHistoryDO::getSigningTime, reqVO.getSigningTime())
|
||||
.betweenIfPresent(ContractHistoryDO::getArchiveTime, reqVO.getArchiveTime())
|
||||
.eqIfPresent(ContractHistoryDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ContractHistoryDO::getCountType, reqVO.getCountType())
|
||||
.eqIfPresent(ContractHistoryDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(ContractHistoryDO::getContractFileUrl, reqVO.getContractFileUrl())
|
||||
.eqIfPresent(ContractHistoryDO::getConstructionCost, reqVO.getConstructionCost())
|
||||
.eqIfPresent(ContractHistoryDO::getSource, reqVO.getSource())
|
||||
.eqIfPresent(ContractHistoryDO::getDiscount, reqVO.getDiscount())
|
||||
.eqIfPresent(ContractHistoryDO::getConsortium, reqVO.getConsortium())
|
||||
.eqIfPresent(ContractHistoryDO::getConsortiumCompany, reqVO.getConsortiumCompany())
|
||||
.eqIfPresent(ContractHistoryDO::getExtProportion, reqVO.getExtProportion())
|
||||
.eqIfPresent(ContractHistoryDO::getApprovedAmount, reqVO.getApprovedAmount())
|
||||
.eqIfPresent(ContractHistoryDO::getReviewFileUrl, reqVO.getReviewFileUrl())
|
||||
.eqIfPresent(ContractHistoryDO::getCreator, reqVO.getCreator())
|
||||
.betweenIfPresent(ContractHistoryDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(ContractHistoryDO::getUpdater, reqVO.getUpdater())
|
||||
.betweenIfPresent(ContractHistoryDO::getUpdateTime, reqVO.getUpdateTime())
|
||||
.eqIfPresent(ContractHistoryDO::getDeleted, reqVO.getDeleted())
|
||||
.eqIfPresent(ContractHistoryDO::getAmount, reqVO.getAmount())
|
||||
.eqIfPresent(ContractHistoryDO::getPreAmount, reqVO.getPreAmount())
|
||||
.eqIfPresent(ContractHistoryDO::getDesignAmount, reqVO.getDesignAmount())
|
||||
.eqIfPresent(ContractHistoryDO::getSurveyFees, reqVO.getSurveyFees())
|
||||
.eqIfPresent(ContractHistoryDO::getMeasurementFee, reqVO.getMeasurementFee())
|
||||
.eqIfPresent(ContractHistoryDO::getOtherFee, reqVO.getOtherFee())
|
||||
.eqIfPresent(ContractHistoryDO::getProcessStatus, reqVO.getProcessStatus())
|
||||
.eqIfPresent(ContractHistoryDO::getContractId, reqVO.getContractId())
|
||||
.eqIfPresent(ContractHistoryDO::getVersion, reqVO.getVersion())
|
||||
.orderByDesc(ContractHistoryDO::getId));
|
||||
.eqIfPresent(ContractHistoryDO::getContractId, reqVO.getContractId()));
|
||||
}
|
||||
|
||||
}
|
@ -53,11 +53,18 @@ public interface ContractService {
|
||||
PageResult<ContractRespVO> getContractPage(ContractPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得暂定结算金额
|
||||
* 通过id获得暂定结算金额
|
||||
* @param id 合同编号
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getProvisionalSettlement(Long id);
|
||||
BigDecimal getProvisionalSettlementById(Long id);
|
||||
|
||||
/**
|
||||
* 通过输入的合同获得暂定结算金额
|
||||
* @param contractSaveReqVO
|
||||
* @return
|
||||
*/
|
||||
BigDecimal getProvisionalSettlement(ContractSaveReqVO contractSaveReqVO);
|
||||
|
||||
/**
|
||||
* 判断合同是否存在
|
||||
|
@ -1,14 +1,14 @@
|
||||
package cn.iocoder.yudao.module.cms.service.contract;
|
||||
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.extContract.ExtContractDO;
|
||||
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.dal.dataobject.contractHistory.ContractHistoryDO;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.contract.ContractMapper;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.extcontract.ExtContractMapper;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.contractHistory.ContractHistoryMapper;
|
||||
import cn.iocoder.yudao.module.pms.api.ProjectApi;
|
||||
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -19,9 +19,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.cms.enums.ErrorCodeConstants.*;
|
||||
@ -36,7 +36,16 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_E
|
||||
@Validated
|
||||
public class ContractServiceImpl implements ContractService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ContractServiceImpl.class);
|
||||
/**
|
||||
* 合同立项审批流程定义
|
||||
*/
|
||||
public static final String PROCESS_KEY = "contract_init";
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
public static String VERSION = "1";
|
||||
|
||||
@Resource
|
||||
private ContractMapper contractMapper;
|
||||
|
||||
@ -46,42 +55,124 @@ public class ContractServiceImpl implements ContractService {
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
|
||||
@Resource
|
||||
private ContractHistoryMapper contractHistoryMapper;
|
||||
|
||||
@Override
|
||||
public Long createContract(Long loginUserId,ContractSaveReqVO createReqVO) {
|
||||
if (createReqVO == null){
|
||||
throw exception(PARAM_NOT_EXISTS);
|
||||
}
|
||||
if (loginUserId == null){
|
||||
public Long createContract(Long loginUserId, ContractSaveReqVO createReqVO) {
|
||||
|
||||
if (loginUserId == null) {
|
||||
throw exception(PARAM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||
if (userName == null){
|
||||
if (userName == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
ContractDO contract = BeanUtils.toBean(createReqVO, ContractDO.class);
|
||||
//校验,项目是否存在
|
||||
projectApi.validProjectExist(contract.getProjectId());
|
||||
|
||||
//校验,项目是否存在
|
||||
Long projectId = createReqVO.getProjectId();
|
||||
projectApi.validProjectExist(projectId);
|
||||
|
||||
//校验联表的字段是否和所联系的表内容相同
|
||||
ProjectRespDTO project = projectApi.getProject(projectId);
|
||||
ProjectDetailRespDTO projectDetail = projectApi.getProjectDetailById(projectId);
|
||||
|
||||
|
||||
//todo 待提取
|
||||
String code = createReqVO.getCode();
|
||||
String trackingDep = createReqVO.getTrackingDep();
|
||||
String projectManager = createReqVO.getProjectManager();
|
||||
String drawingCompany = createReqVO.getDrawingCompany();
|
||||
BigDecimal expectedContractAmount = createReqVO.getExpectedContractAmount();
|
||||
BigDecimal provisionalSettlement = createReqVO.getProvisionalSettlement();
|
||||
|
||||
//LocalDateTime reminderTime = createReqVO.getReminderTime();
|
||||
|
||||
if (!project.getCode().equals(code)) {
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
if (!projectDetail.getTrackingDepName().equals(trackingDep)) {
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
if (!projectDetail.getProjectManagerName().equals(projectManager)) {
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
if (!project.getDrawingCompany().equals(drawingCompany)) {
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
if (!Objects.equals(project.getContractAmount(), expectedContractAmount)) {
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
if (!Objects.equals(provisionalSettlement, getProvisionalSettlement(createReqVO))) {
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
|
||||
|
||||
ContractDO contract = BeanUtils.toBean(createReqVO, ContractDO.class);
|
||||
ContractRespVO contractResp = BeanUtils.toBean(contract, ContractRespVO.class);
|
||||
contract.setCreator(userName);
|
||||
contract.setUpdater(userName);
|
||||
|
||||
|
||||
//判断该合同是否已经存在,比较各个字段值是否完全一样
|
||||
//得到所有的合同?逐个比较?
|
||||
|
||||
|
||||
List<ContractDO> contractList = contractMapper.selectList("project_id", projectId);
|
||||
List<ContractRespVO> respVOList = BeanUtils.toBean(contractList, ContractRespVO.class);
|
||||
|
||||
for (ContractRespVO respVO : respVOList) {
|
||||
if (respVO.equals(contractResp)) {
|
||||
throw exception(CONTRACT_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
contractMapper.insert(contract);
|
||||
|
||||
|
||||
Long contractId = contract.getId();
|
||||
ContractHistoryDO contractHistory = BeanUtils.toBean(contract, ContractHistoryDO.class);
|
||||
|
||||
|
||||
// 启动流程,同时写入历史合同
|
||||
if (createReqVO.getId() == null) {
|
||||
String processInstanceId = processInstanceApi.createProcessInstance(loginUserId,
|
||||
new BpmProcessInstanceCreateReqDTO()
|
||||
.setProcessDefinitionKey(PROCESS_KEY).setBusinessKey(String.valueOf(contractId)));
|
||||
|
||||
// 写入工作流编号
|
||||
contractHistory.setProcessInstanceId(processInstanceId);
|
||||
contractHistory.setContractId(contractId);
|
||||
|
||||
Long count = contractHistoryMapper.selectCount("project_id", projectId);
|
||||
if (count < 1) {
|
||||
contractHistory.setVersion(VERSION);
|
||||
} else {
|
||||
contractHistory.setVersion(String.valueOf(count + 1));
|
||||
}
|
||||
|
||||
contractHistory.setProcessStatus("0");
|
||||
contractHistoryMapper.insert(contractHistory);
|
||||
}
|
||||
|
||||
|
||||
//返回
|
||||
return contract.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateContract(Long loginUserId,ContractSaveReqVO updateReqVO) {
|
||||
public void updateContract(Long loginUserId, ContractSaveReqVO updateReqVO) {
|
||||
//校验
|
||||
validateContractExists(updateReqVO.getId());
|
||||
projectApi.validProjectExist(updateReqVO.getProjectId());
|
||||
// 更新
|
||||
ContractDO updateObj = BeanUtils.toBean(updateReqVO, ContractDO.class);
|
||||
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||
if (userName == null){
|
||||
if (userName == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
updateObj.setUpdater(userName);
|
||||
@ -129,7 +220,6 @@ public class ContractServiceImpl implements ContractService {
|
||||
contractRespVO.setCode(project.getCode());
|
||||
contractRespVO.setDrawingCompany(project.getDrawingCompany());
|
||||
contractRespVO.setExpectedContractAmount(project.getContractAmount());
|
||||
|
||||
ProjectDetailRespDTO projectDetail = projectApi.getProjectDetailById(projectId);
|
||||
contractRespVO.setTrackingDep(projectDetail.getTrackingDepName());
|
||||
contractRespVO.setProjectManager(projectDetail.getProjectManagerName());
|
||||
@ -137,10 +227,10 @@ public class ContractServiceImpl implements ContractService {
|
||||
//分包合同商议提示 TODO 待优化
|
||||
// ExtContractDO extContractDO = extContractMapper.selectOne("project_id", projectId);
|
||||
// LocalDateTime reminderTime = extContractDO.getReminderTime();
|
||||
contractRespVO.setReminderTime(LocalDateTime.now());
|
||||
contractRespVO.setReminderTime(null);
|
||||
|
||||
//暂定结算数
|
||||
BigDecimal provisionalSettlement = getProvisionalSettlement(id);
|
||||
BigDecimal provisionalSettlement = getProvisionalSettlementById(id);
|
||||
contractRespVO.setProvisionalSettlement(provisionalSettlement);
|
||||
|
||||
|
||||
@ -150,7 +240,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
@Override
|
||||
public PageResult<ContractRespVO> getContractPage(ContractPageReqVO pageReqVO) {
|
||||
//校验
|
||||
if (pageReqVO == null){
|
||||
if (pageReqVO == null) {
|
||||
throw exception(PARAM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@ -176,7 +266,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getProvisionalSettlement(Long id) {
|
||||
public BigDecimal getProvisionalSettlementById(Long id) {
|
||||
ContractDO contractDO = contractMapper.selectById(id);
|
||||
String type = contractDO.getCountType();
|
||||
BigDecimal amount = contractDO.getAmount();
|
||||
@ -191,6 +281,21 @@ public class ContractServiceImpl implements ContractService {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getProvisionalSettlement(ContractSaveReqVO contractSaveReqVO) {
|
||||
String type = contractSaveReqVO.getCountType();
|
||||
BigDecimal amount = contractSaveReqVO.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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validateContractExists(Long id) {
|
||||
@ -200,5 +305,4 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -12,27 +12,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
*/
|
||||
public interface ContractHistoryService {
|
||||
|
||||
/**
|
||||
* 创建历史合同
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createContractHistory(@Valid ContractHistorySaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新历史合同
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateContractHistory(@Valid ContractHistorySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除历史合同
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteContractHistory(Long id);
|
||||
void updateContractHistory(Long loginUserId,@Valid ContractHistorySaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 获得历史合同
|
||||
@ -40,7 +25,7 @@ public interface ContractHistoryService {
|
||||
* @param contractId 现有合同编号
|
||||
* @return 历史合同
|
||||
*/
|
||||
ContractHistoryDO getContractHistory(Long contractId);
|
||||
ContractHistoryRespVO getContractHistory(Long contractId);
|
||||
|
||||
/**
|
||||
* 获得历史合同分页
|
||||
@ -48,6 +33,6 @@ public interface ContractHistoryService {
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 历史合同分页
|
||||
*/
|
||||
PageResult<ContractHistoryDO> getContractHistoryPage(ContractHistoryPageReqVO pageReqVO);
|
||||
PageResult<ContractHistoryRespVO> getContractHistoryPage(ContractHistoryPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -1,19 +1,27 @@
|
||||
package cn.iocoder.yudao.module.cms.service.contractHistory;
|
||||
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.contract.ContractMapper;
|
||||
import cn.iocoder.yudao.module.cms.controller.admin.contract.vo.ContractRespVO;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.contract.ContractDO;
|
||||
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.ProjectDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.pms.api.project.dto.ProjectRespDTO;
|
||||
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 cn.iocoder.yudao.module.cms.controller.admin.contractHistory.vo.*;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.contractHistory.ContractHistoryDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.contractHistory.ContractHistoryMapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 历史合同 Service 实现类
|
||||
@ -27,47 +35,124 @@ public class ContractHistoryServiceImpl implements cn.iocoder.yudao.module.cms.s
|
||||
@Resource
|
||||
private ContractHistoryMapper contractHistoryMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private ProjectApi projectApi;
|
||||
|
||||
@Resource
|
||||
private ContractService contractService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long createContractHistory(ContractHistorySaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ContractHistoryDO contractHistory = BeanUtils.toBean(createReqVO, ContractHistoryDO.class);
|
||||
contractHistoryMapper.insert(contractHistory);
|
||||
// 返回
|
||||
return contractHistory.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateContractHistory(ContractHistorySaveReqVO updateReqVO) {
|
||||
public void updateContractHistory(Long loginUserId,ContractHistorySaveReqVO updateReqVO) {
|
||||
//校验
|
||||
Long id = updateReqVO.getId();
|
||||
validateContractHistoryExists(id);
|
||||
if (loginUserId == null){
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
Long projectId = updateReqVO.getProjectId();
|
||||
ProjectRespDTO project = projectApi.getProject(projectId);
|
||||
if (project == null){
|
||||
throw exception(PROJECT_NOT_EXISTS);
|
||||
}
|
||||
// 更新
|
||||
ContractHistoryDO updateObj = BeanUtils.toBean(updateReqVO, ContractHistoryDO.class);
|
||||
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||
updateObj.setUpdater(userName);
|
||||
contractHistoryMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteContractHistory(Long id) {
|
||||
// 校验存在
|
||||
validateContractHistoryExists(id);
|
||||
// 删除
|
||||
contractHistoryMapper.deleteById(id);
|
||||
public ContractHistoryRespVO getContractHistory(Long id) {
|
||||
//校验
|
||||
if (id == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
ContractHistoryDO contractHistoryDO = contractHistoryMapper.selectById(id);
|
||||
if (contractHistoryDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
Long projectId = contractHistoryDO.getProjectId();
|
||||
|
||||
if (projectId == null) {
|
||||
throw exception(PROJECT_NOT_EXISTS);
|
||||
}
|
||||
ContractHistoryRespVO contractHistoryRespVO = BeanUtils.toBean(contractHistoryDO, ContractHistoryRespVO.class);
|
||||
|
||||
// 需要联表查询
|
||||
// 1.项目编号 pms_project 直接 √
|
||||
// 2.主控部门(跟踪部门) pms_project找到的是id 需要联表 √
|
||||
// 3.项目经理 pms_project找到的是id 需要联表 √
|
||||
// 4.出图公司 pms_project 直接 √
|
||||
// 5.预计合同金额 pms_project 直接 √
|
||||
// 6.分包合同商议提示 √
|
||||
// 7.暂定结算数 √
|
||||
|
||||
ProjectRespDTO project = projectApi.getProject(projectId);
|
||||
contractHistoryRespVO.setCode(project.getCode());
|
||||
contractHistoryRespVO.setDrawingCompany(project.getDrawingCompany());
|
||||
contractHistoryRespVO.setExpectedContractAmount(project.getContractAmount());
|
||||
ProjectDetailRespDTO projectDetail = projectApi.getProjectDetailById(projectId);
|
||||
contractHistoryRespVO.setTrackingDep(projectDetail.getTrackingDepName());
|
||||
contractHistoryRespVO.setProjectManager(projectDetail.getProjectManagerName());
|
||||
|
||||
//分包合同商议提示 TODO 待优化
|
||||
// ExtContractDO extContractDO = extContractMapper.selectOne("project_id", projectId);
|
||||
// LocalDateTime reminderTime = extContractDO.getReminderTime();
|
||||
contractHistoryRespVO.setReminderTime(null);
|
||||
|
||||
//暂定结算数
|
||||
BigDecimal provisionalSettlement =contractService.getProvisionalSettlementById(id);
|
||||
contractHistoryRespVO.setProvisionalSettlement(provisionalSettlement);
|
||||
|
||||
|
||||
return contractHistoryRespVO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<ContractHistoryRespVO> getContractHistoryPage(ContractHistoryPageReqVO pageReqVO) {
|
||||
//校验
|
||||
if (pageReqVO == null) {
|
||||
throw exception(PARAM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
Long projectId = pageReqVO.getProjectId();
|
||||
ProjectRespDTO project = projectApi.getProject(projectId);
|
||||
if (project == null) {
|
||||
throw exception(PROJECT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
PageResult<ContractHistoryDO> contractHistoryDOPageResult = contractHistoryMapper.selectPage(pageReqVO);
|
||||
List<ContractHistoryDO> pageResultList = contractHistoryDOPageResult.getList();
|
||||
List<ContractHistoryRespVO> contractHistoryRespVOS = new ArrayList<>();
|
||||
|
||||
|
||||
for (ContractHistoryDO contractHistoryDO : pageResultList) {
|
||||
Long id = contractHistoryDO.getId();
|
||||
ContractHistoryRespVO contractHistory = getContractHistory(id);
|
||||
contractHistoryRespVOS.add(contractHistory);
|
||||
}
|
||||
|
||||
PageResult<ContractHistoryRespVO> pageResult = new PageResult<>();
|
||||
pageResult.setList(contractHistoryRespVOS);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
|
||||
private void validateContractHistoryExists(Long id) {
|
||||
if (contractHistoryMapper.selectById(id) == null) {
|
||||
throw exception(CONTRACT_HISTORY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractHistoryDO getContractHistory(Long id) {
|
||||
return contractHistoryMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<ContractHistoryDO> getContractHistoryPage(ContractHistoryPageReqVO pageReqVO) {
|
||||
return contractHistoryMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -2,12 +2,16 @@ package cn.iocoder.yudao.module.cms.service.outscontract;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.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.OutsContractRespVO;
|
||||
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.outscontracthistory.OutsContractHistoryDO;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.outscontract.OutsContractMapper;
|
||||
import cn.iocoder.yudao.module.cms.dal.mysql.outscontracthistory.OutsContractHistoryMapper;
|
||||
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;
|
||||
@ -16,6 +20,7 @@ import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -33,6 +38,15 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_E
|
||||
@Validated
|
||||
public class OutsContractServiceImpl implements OutsContractService {
|
||||
|
||||
/**
|
||||
* 外包合同立项审批流程定义
|
||||
*/
|
||||
public static final String PROCESS_KEY = "outs_contract_init";
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
public static String VERSION = "1";
|
||||
@Resource
|
||||
private OutsContractMapper outsContractMapper;
|
||||
|
||||
@ -45,44 +59,110 @@ public class OutsContractServiceImpl implements OutsContractService {
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
|
||||
@Resource
|
||||
private OutsContractHistoryMapper outsContractHistoryMapper;
|
||||
|
||||
@Override
|
||||
public Long createOutsContract(Long loginUserId,OutsContractSaveReqVO createReqVO) {
|
||||
|
||||
|
||||
if (createReqVO == null) {
|
||||
throw exception(PARAM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
OutsContractDO outsContract = BeanUtils.toBean(createReqVO, OutsContractDO.class);
|
||||
|
||||
Long contractId = outsContract.getContractId();
|
||||
|
||||
ContractRespVO contract = contractService.getContract(contractId);
|
||||
if (contract == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
if (loginUserId == null) {
|
||||
throw exception(PARAM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
Long projectId = outsContract.getProjectId();
|
||||
ProjectRespDTO project = projectApi.getProject(projectId);
|
||||
if (project == null) {
|
||||
throw exception(PROJECT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
//合同名称错误
|
||||
if (!Objects.equals(createReqVO.getName(), contract.getName())) {
|
||||
throw exception(CONTRACT_NAME_NOT_EXISTS);
|
||||
}
|
||||
//TODO 待优化
|
||||
String userName = adminUserApi.getUser(loginUserId).getNickname();
|
||||
if (userName == null){
|
||||
if (userName == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
outsContract.setCreator(userName);
|
||||
outsContract.setUpdater(userName);
|
||||
|
||||
OutsContractDO outsContractDO = BeanUtils.toBean(createReqVO, OutsContractDO.class);
|
||||
//校验
|
||||
Long projectId = outsContractDO.getProjectId();
|
||||
projectApi.validProjectExist(projectId);
|
||||
|
||||
|
||||
//校验联表的字段是否和所联系的表内容相同
|
||||
ContractRespVO contract = contractService.getContract(createReqVO.getContractId());
|
||||
// 需要联表查询
|
||||
// 1.合同名称 √
|
||||
// 2.主控部门(跟踪部门) √
|
||||
// 3.项目经理 √
|
||||
// 4.签订合同总额 √
|
||||
|
||||
//todo 待提取
|
||||
String name = createReqVO.getName();
|
||||
String trackingDep = createReqVO.getTrackingDep();
|
||||
String projectManager = createReqVO.getProjectManager();
|
||||
BigDecimal outsAmount = createReqVO.getOutsAmount();
|
||||
|
||||
|
||||
if (!contract.getName().equals(name)){
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
if (!contract.getTrackingDep().equals(trackingDep)){
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
if (!contract.getProjectManager().equals(projectManager)){
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
if (contract.getAmount().compareTo(outsAmount) != 0){
|
||||
throw exception(PARAM_ERROR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
outsContractMapper.insert(outsContract);
|
||||
return outsContract.getId();
|
||||
OutsContractRespVO outsContractRespVO = BeanUtils.toBean(outsContractDO, OutsContractRespVO.class);
|
||||
outsContractDO.setCreator(userName);
|
||||
outsContractDO.setUpdater(userName);
|
||||
|
||||
|
||||
|
||||
//判断该合同是否已经存在,比较各个字段值是否完全一样
|
||||
//得到所有的合同?逐个比较?
|
||||
|
||||
|
||||
List<OutsContractDO> outsContractDOList = outsContractMapper.selectList("project_id", projectId);
|
||||
List<OutsContractRespVO> outsContractRespList = BeanUtils.toBean(outsContractDOList, OutsContractRespVO.class);
|
||||
|
||||
for (OutsContractRespVO respVO : outsContractRespList) {
|
||||
if (respVO.equals(outsContractRespVO)){
|
||||
throw exception(CONTRACT_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
outsContractMapper.insert(outsContractDO);
|
||||
|
||||
|
||||
Long outsContractDOId = outsContractDO.getId();
|
||||
OutsContractHistoryDO outsContractHistoryDO = BeanUtils.toBean(outsContractDO, OutsContractHistoryDO.class);
|
||||
|
||||
|
||||
// 启动流程,同时写入历史合同
|
||||
if (createReqVO.getId() == null) {
|
||||
String processInstanceId = processInstanceApi.createProcessInstance(loginUserId,
|
||||
new BpmProcessInstanceCreateReqDTO()
|
||||
.setProcessDefinitionKey(PROCESS_KEY).setBusinessKey(String.valueOf(outsContractDOId)));
|
||||
|
||||
// 写入工作流编号
|
||||
outsContractHistoryDO.setProcessInstanceId(processInstanceId);
|
||||
outsContractHistoryDO.setOutsContractId(outsContractDOId);
|
||||
|
||||
Long count = outsContractHistoryMapper.selectCount("project_id", projectId);
|
||||
if (count < 1) {
|
||||
outsContractHistoryDO.setVersion(VERSION);
|
||||
} else {
|
||||
outsContractHistoryDO.setVersion(String.valueOf(count+1));
|
||||
}
|
||||
|
||||
outsContractHistoryDO.setProcessStatus("0");
|
||||
outsContractHistoryMapper.insert(outsContractHistoryDO);
|
||||
}
|
||||
|
||||
return outsContractDO.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user