|
@@ -1,21 +1,28 @@
|
|
|
package cn.iocoder.yudao.module.contract.controller.admin.customercontract;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.enums.GeneralStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
-import cn.iocoder.yudao.module.contract.controller.admin.customercontract.vo.CustomerContractPageReqVO;
|
|
|
-import cn.iocoder.yudao.module.contract.controller.admin.customercontract.vo.CustomerContractRespVO;
|
|
|
-import cn.iocoder.yudao.module.contract.controller.admin.customercontract.vo.CustomerContractSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.contract.controller.admin.customercontract.vo.*;
|
|
|
import cn.iocoder.yudao.module.contract.dal.dataobject.customercontract.CustomerContractDO;
|
|
|
import cn.iocoder.yudao.module.contract.dal.dataobject.customercontract.CustomerContractHistoryDO;
|
|
|
+import cn.iocoder.yudao.module.contract.enums.ContractStatusEnum;
|
|
|
import cn.iocoder.yudao.module.contract.service.customercontract.CustomerContractService;
|
|
|
+import cn.iocoder.yudao.module.employee.api.EmployeeApi;
|
|
|
+import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
|
+import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
|
+import cn.iocoder.yudao.module.infra.api.file.dto.FileDTO;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springdoc.api.annotations.ParameterObject;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -23,7 +30,11 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@@ -37,16 +48,37 @@ public class CustomerContractController {
|
|
|
@Resource
|
|
|
private CustomerContractService customerContractService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private EmployeeApi employeeApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private FileApi fileApi;
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/getCustomerContractCode")
|
|
|
+ @Operation(summary = "获取销售合同编号")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:create')")
|
|
|
+ public CommonResult<String> getCustomerContractCode() {
|
|
|
+ return success(customerContractService.getCustomerContractCode());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建销售合同信息")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:create')")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:create')")
|
|
|
public CommonResult<Long> createCustomerContract(@Valid @RequestBody CustomerContractSaveReqVO createReqVO) {
|
|
|
return success(customerContractService.createCustomerContract(createReqVO));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "更新销售合同信息")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
public CommonResult<Boolean> updateCustomerContract(@Valid @RequestBody CustomerContractSaveReqVO updateReqVO) {
|
|
|
customerContractService.updateCustomerContract(updateReqVO);
|
|
|
return success(true);
|
|
@@ -54,8 +86,9 @@ public class CustomerContractController {
|
|
|
|
|
|
@DeleteMapping("/delete")
|
|
|
@Operation(summary = "删除销售合同信息")
|
|
|
- @Parameter(name = "id", description = "编号", required = true)
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:delete')")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @Parameter(name = "id", description = "主键id", required = true)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:delete')")
|
|
|
public CommonResult<Boolean> deleteCustomerContract(@RequestParam("id") Long id) {
|
|
|
customerContractService.deleteCustomerContract(id);
|
|
|
return success(true);
|
|
@@ -63,75 +96,194 @@ public class CustomerContractController {
|
|
|
|
|
|
@GetMapping("/get")
|
|
|
@Operation(summary = "获得销售合同信息")
|
|
|
- @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:query')")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @Parameter(name = "id", description = "主键id", required = true, example = "1")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:query')")
|
|
|
public CommonResult<CustomerContractRespVO> getCustomerContract(@RequestParam("id") Long id) {
|
|
|
CustomerContractDO customerContract = customerContractService.getCustomerContract(id);
|
|
|
- return success(BeanUtils.toBean(customerContract, CustomerContractRespVO.class));
|
|
|
+ if (Objects.isNull(customerContract)) {
|
|
|
+ return success(null);
|
|
|
+ }
|
|
|
+ CustomerContractRespVO customerContractRespVO = BeanUtils.toBean(customerContract, CustomerContractRespVO.class);
|
|
|
+ // 是否描述集合
|
|
|
+ Map<Integer, String> generalStatusMap = Arrays.stream(GeneralStatusEnum.values())
|
|
|
+ .collect(Collectors.toMap(GeneralStatusEnum::getStatus, GeneralStatusEnum::getName));
|
|
|
+ // 是否框架合同
|
|
|
+ customerContractRespVO.setIsFrameContractDesc(generalStatusMap.getOrDefault(customerContract.getIsFrameContract(), "未知"));
|
|
|
+ // 负责人名称
|
|
|
+ EmployeeRespDTO ownerEmployee = employeeApi.getEmployeeById(customerContract.getOwnerEmployeeId());
|
|
|
+ if (Objects.nonNull(ownerEmployee)) {
|
|
|
+ customerContractRespVO.setOwnerEmployeeName(ownerEmployee.getName());
|
|
|
+ }
|
|
|
+ // 部门名称
|
|
|
+ DeptRespDTO ownerDept = deptApi.getDept(customerContract.getDeptId());
|
|
|
+ if (Objects.nonNull(ownerDept)) {
|
|
|
+ customerContractRespVO.setDeptName(ownerDept.getName());
|
|
|
+ }
|
|
|
+ // 合同状态描述
|
|
|
+ Map<String, String> contractStatusMap = Arrays.stream(ContractStatusEnum.values())
|
|
|
+ .collect(Collectors.toMap(ContractStatusEnum::getStatus, ContractStatusEnum::getDesc));
|
|
|
+ customerContractRespVO.setContractStatusDesc(contractStatusMap.getOrDefault(customerContract.getContractStatus(), "未知"));
|
|
|
+ // 是否关闭
|
|
|
+ customerContractRespVO.setClosedDesc(generalStatusMap.getOrDefault(customerContract.getClosed(), "未知"));
|
|
|
+ // 是否终止
|
|
|
+ customerContractRespVO.setTerminateDesc(generalStatusMap.getOrDefault(customerContract.getTerminate(), "未知"));
|
|
|
+
|
|
|
+ // 附件
|
|
|
+ List<FileDTO> fileDTOList = fileApi.getFileDTOListByBiz(customerContract.getCustomerContractUuid());
|
|
|
+ customerContractRespVO.setFileList(fileDTOList);
|
|
|
+
|
|
|
+ return success(customerContractRespVO);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
@Operation(summary = "获得销售合同信息分页")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:query')")
|
|
|
- public CommonResult<PageResult<CustomerContractRespVO>> getCustomerContractPage(@Valid CustomerContractPageReqVO pageReqVO) {
|
|
|
- PageResult<CustomerContractDO> pageResult = customerContractService.getCustomerContractPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, CustomerContractRespVO.class));
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:query')")
|
|
|
+ public CommonResult<PageResult<CustomerContractRespVO>> getCustomerContractPage(@Valid @ParameterObject CustomerContractPageReqVO pageReqVO) {
|
|
|
+ PageResult<CustomerContractRespVO> pageResult = customerContractService.getCustomerContractPage(pageReqVO);
|
|
|
+
|
|
|
+ return success(pageResult);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
|
@Operation(summary = "导出销售合同信息 Excel")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:export')")
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:export')")
|
|
|
@ApiAccessLog(operateType = EXPORT)
|
|
|
- public void exportCustomerContractExcel(@Valid CustomerContractPageReqVO pageReqVO,
|
|
|
- HttpServletResponse response) throws IOException {
|
|
|
+ public void exportCustomerContractExcel(@ParameterObject CustomerContractPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
- List<CustomerContractDO> list = customerContractService.getCustomerContractPage(pageReqVO).getList();
|
|
|
+ List<CustomerContractRespVO> list = customerContractService.getCustomerContractPage(pageReqVO).getList();
|
|
|
// 导出 Excel
|
|
|
ExcelUtils.write(response, "销售合同信息.xls", "数据", CustomerContractRespVO.class,
|
|
|
- BeanUtils.toBean(list, CustomerContractRespVO.class));
|
|
|
+ list);
|
|
|
}
|
|
|
|
|
|
- // ==================== 子表(销售合同历史信息) ====================
|
|
|
+ @PutMapping("/open")
|
|
|
+ @Operation(summary = "开启销售合同")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @Parameter(name = "id", description = "主键id", required = true, example = "1")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
+ public CommonResult<Boolean> openCustomerContract(@RequestParam("id") Long id) {
|
|
|
+ customerContractService.openCustomerContract(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
|
|
|
- @GetMapping("/customer-contract-history/page")
|
|
|
- @Operation(summary = "获得销售合同历史信息分页")
|
|
|
- @Parameter(name = "customerContractCode", description = "合同编号,年月日+uuid")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:query')")
|
|
|
- public CommonResult<PageResult<CustomerContractHistoryDO>> getCustomerContractHistoryPage(PageParam pageReqVO,
|
|
|
- @RequestParam("customerContractCode") String customerContractCode) {
|
|
|
- return success(customerContractService.getCustomerContractHistoryPage(pageReqVO, customerContractCode));
|
|
|
+ @PutMapping("/close")
|
|
|
+ @Operation(summary = "关闭销售合同")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
+ public CommonResult<Boolean> closeCustomerContract(@Valid @RequestBody CustomerContractCloseReqVO closeReqVO) {
|
|
|
+ customerContractService.closeCustomerContract(closeReqVO);
|
|
|
+ return success(true);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/customer-contract-history/create")
|
|
|
- @Operation(summary = "创建销售合同历史信息")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:create')")
|
|
|
- public CommonResult<Long> createCustomerContractHistory(@Valid @RequestBody CustomerContractHistoryDO customerContractHistory) {
|
|
|
- return success(customerContractService.createCustomerContractHistory(customerContractHistory));
|
|
|
+ @PutMapping("/terminate")
|
|
|
+ @Operation(summary = "终止销售合同")
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
+ public CommonResult<Boolean> terminateCustomerContract(@Valid @RequestBody CustomerContractTerminatedReqVO terminatedReqVO) {
|
|
|
+ customerContractService.terminateCustomerContract(terminatedReqVO);
|
|
|
+ return success(true);
|
|
|
}
|
|
|
|
|
|
- @PutMapping("/customer-contract-history/update")
|
|
|
- @Operation(summary = "更新销售合同历史信息")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
- public CommonResult<Boolean> updateCustomerContractHistory(@Valid @RequestBody CustomerContractHistoryDO customerContractHistory) {
|
|
|
- customerContractService.updateCustomerContractHistory(customerContractHistory);
|
|
|
+ @PutMapping("/editCustomerStatus")
|
|
|
+ @Operation(summary = "修改销售合同状态")
|
|
|
+ @ApiOperationSupport(order = 11)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
+ public CommonResult<Boolean> editCustomerStatus(@Valid @RequestBody CustomerContractStatusReqVO statusReqVO) {
|
|
|
+ customerContractService.editCustomerStatus(statusReqVO);
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
|
- @DeleteMapping("/customer-contract-history/delete")
|
|
|
- @Parameter(name = "id", description = "编号", required = true)
|
|
|
- @Operation(summary = "删除销售合同历史信息")
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:delete')")
|
|
|
- public CommonResult<Boolean> deleteCustomerContractHistory(@RequestParam("id") Long id) {
|
|
|
- customerContractService.deleteCustomerContractHistory(id);
|
|
|
+ @PutMapping("/alter")
|
|
|
+ @Operation(summary = "变更销售合同信息")
|
|
|
+ @ApiOperationSupport(order = 12)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
+ public CommonResult<Boolean> alterCustomerContract(@Valid @RequestBody CustomerContractSaveReqVO updateReqVO) {
|
|
|
+ customerContractService.alterCustomerContract(updateReqVO);
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/customer-contract-history/get")
|
|
|
- @Operation(summary = "获得销售合同历史信息")
|
|
|
- @Parameter(name = "id", description = "编号", required = true)
|
|
|
- @PreAuthorize("@ss.hasPermission('contract:customer-contract:query')")
|
|
|
- public CommonResult<CustomerContractHistoryDO> getCustomerContractHistory(@RequestParam("id") Long id) {
|
|
|
- return success(customerContractService.getCustomerContractHistory(id));
|
|
|
- }
|
|
|
+
|
|
|
+ // ==================== 子表(销售合同历史信息) ====================
|
|
|
+
|
|
|
+ @GetMapping("/customer-contract-history/page")
|
|
|
+ @Operation(summary = "获得销售合同历史信息分页")
|
|
|
+ @ApiOperationSupport(order = 13)
|
|
|
+ @Parameter(name = "code", description = "合同编号,年月日+uuid")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:query')")
|
|
|
+ public CommonResult<PageResult<CustomerContractHistoryDO>> getCustomerContractHistoryPage(PageParam pageReqVO,
|
|
|
+ @RequestParam("code") String code) {
|
|
|
+ return success(customerContractService.getCustomerContractHistoryPage(pageReqVO, code));
|
|
|
+ }
|
|
|
+
|
|
|
+ // @PostMapping("/customer-contract-history/create")
|
|
|
+ // @Operation(summary = "创建销售合同历史信息")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:create')")
|
|
|
+ // public CommonResult<Long> createCustomerContractHistory(@Valid @RequestBody CustomerContractHistoryDO customerContractHistory) {
|
|
|
+ // return success(customerContractService.createCustomerContractHistory(customerContractHistory));
|
|
|
+ // }
|
|
|
+
|
|
|
+ // @PutMapping("/customer-contract-history/update")
|
|
|
+ // @Operation(summary = "更新销售合同历史信息")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:update')")
|
|
|
+ // public CommonResult<Boolean> updateCustomerContractHistory(@Valid @RequestBody CustomerContractHistoryDO customerContractHistory) {
|
|
|
+ // customerContractService.updateCustomerContractHistory(customerContractHistory);
|
|
|
+ // return success(true);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // @DeleteMapping("/customer-contract-history/delete")
|
|
|
+ // @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ // @Operation(summary = "删除销售合同历史信息")
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:delete')")
|
|
|
+ // public CommonResult<Boolean> deleteCustomerContractHistory(@RequestParam("id") Long id) {
|
|
|
+ // customerContractService.deleteCustomerContractHistory(id);
|
|
|
+ // return success(true);
|
|
|
+ // }
|
|
|
+
|
|
|
+ @GetMapping("/customer-contract-history/get")
|
|
|
+ @Operation(summary = "获得销售合同历史信息")
|
|
|
+ @ApiOperationSupport(order = 14)
|
|
|
+ @Parameter(name = "id", description = "主键id", required = true)
|
|
|
+ // @PreAuthorize("@ss.hasPermission('contract:customer-contract:query')")
|
|
|
+ public CommonResult<CustomerContractRespVO> getCustomerContractHistory(@RequestParam("id") Long id) {
|
|
|
+ CustomerContractHistoryDO customerContractHistory = customerContractService.getCustomerContractHistory(id);
|
|
|
+ if (Objects.isNull(customerContractHistory)) {
|
|
|
+ return success(null);
|
|
|
+ }
|
|
|
+ CustomerContractRespVO customerContractRespVO = BeanUtils.toBean(customerContractHistory, CustomerContractRespVO.class);
|
|
|
+
|
|
|
+ // 是否描述集合
|
|
|
+ Map<Integer, String> generalStatusMap = Arrays.stream(GeneralStatusEnum.values())
|
|
|
+ .collect(Collectors.toMap(GeneralStatusEnum::getStatus, GeneralStatusEnum::getName));
|
|
|
+ // 是否框架合同
|
|
|
+ customerContractRespVO.setIsFrameContractDesc(generalStatusMap.getOrDefault(customerContractHistory.getIsFrameContract(), "未知"));
|
|
|
+ // 负责人名称
|
|
|
+ EmployeeRespDTO ownerEmployee = employeeApi.getEmployeeById(customerContractHistory.getOwnerEmployeeId());
|
|
|
+ if (Objects.nonNull(ownerEmployee)) {
|
|
|
+ customerContractRespVO.setOwnerEmployeeName(ownerEmployee.getName());
|
|
|
+ }
|
|
|
+ // 部门名称
|
|
|
+ DeptRespDTO ownerDept = deptApi.getDept(customerContractHistory.getDeptId());
|
|
|
+ if (Objects.nonNull(ownerDept)) {
|
|
|
+ customerContractRespVO.setDeptName(ownerDept.getName());
|
|
|
+ }
|
|
|
+ // 合同状态描述
|
|
|
+ Map<String, String> contractStatusMap = Arrays.stream(ContractStatusEnum.values())
|
|
|
+ .collect(Collectors.toMap(ContractStatusEnum::getStatus, ContractStatusEnum::getDesc));
|
|
|
+ customerContractRespVO.setContractStatusDesc(contractStatusMap.getOrDefault(customerContractHistory.getContractStatus(), "未知"));
|
|
|
+ // 是否关闭
|
|
|
+ customerContractRespVO.setClosedDesc(generalStatusMap.getOrDefault(customerContractHistory.getClosed(), "未知"));
|
|
|
+ // 是否终止
|
|
|
+ customerContractRespVO.setTerminateDesc(generalStatusMap.getOrDefault(customerContractHistory.getTerminate(), "未知"));
|
|
|
+
|
|
|
+ // 附件
|
|
|
+ List<FileDTO> fileDTOList = fileApi.getFileDTOListByBiz(customerContractHistory.getCustomerContractUuid());
|
|
|
+ customerContractRespVO.setFileList(fileDTOList);
|
|
|
+
|
|
|
+ return success(customerContractRespVO);
|
|
|
+ }
|
|
|
|
|
|
}
|