| | |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractAuditReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractImportExcelVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractImportReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractImportRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得合同") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | | public CommonResult<CrmContractRespVO> getContract(@RequestParam("id") Long id) { |
| | | CrmContractDO contract = contractService.getContract(id); |
| | | return success(buildContractDetail(contract)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得合同分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | | public CommonResult<PageResult<CrmContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) { |
| | | PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId()); |
| | | return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetailList(pageResult.getList()))); |
| | |
| | | ExcelUtils.write(response, "合同.xls", "数据", CrmContractRespVO.class, list); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入合同模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<CrmContractImportExcelVO> list = Arrays.asList( |
| | | CrmContractImportExcelVO.builder().name("示例合同").customerName("示例客户") |
| | | .orderDate(null).startTime(null).endTime(null).discountPercent(null) |
| | | .totalPrice(null).depositPrice(null).contractType(null).voltageLevel(null) |
| | | .electricityType(null).contractCapacity(null).tariffMode(null).meterMode(null) |
| | | .payCycle(null).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "合同导入模板.xls", "合同列表", CrmContractImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入合同") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:import')") |
| | | public CommonResult<CrmContractImportRespVO> importExcel(@Valid CrmContractImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<CrmContractImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), CrmContractImportExcelVO.class); |
| | | return success(contractService.importContractList(list, importReqVO)); |
| | | } |
| | | |
| | | @PutMapping("/transfer") |
| | | @Operation(summary = "合同转移") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:update')") |
| | |
| | | |
| | | @GetMapping("/approver-ids") |
| | | @Operation(summary = "获得合同的审批人编号集合,供前端判断是否展示审核按钮") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | | public CommonResult<Set<Long>> getApproverUserIds() { |
| | | return success(contractService.getContractApproverUserIds()); |
| | | } |
| | |
| | | |
| | | @GetMapping("/audit-count") |
| | | @Operation(summary = "获得待审核合同数量") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | | public CommonResult<Long> getAuditContractCount() { |
| | | return success(contractService.getAuditContractCount(getLoginUserId())); |
| | | } |
| | | |
| | | @GetMapping("/remind-count") |
| | | @Operation(summary = "获得即将到期(提醒)的合同数量") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | | public CommonResult<Long> getRemindContractCount() { |
| | | return success(contractService.getRemindContractCount(getLoginUserId())); |
| | | } |
| | |
| | | @GetMapping("/simple-list") |
| | | @Operation(summary = "获得合同精简列表", description = "只包含的合同,主要用于前端的下拉选项") |
| | | @Parameter(name = "customerId", description = "客户编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | | public CommonResult<List<CrmContractRespVO>> getContractSimpleList(@RequestParam("customerId") Long customerId) { |
| | | CrmContractPageReqVO pageReqVO = new CrmContractPageReqVO().setCustomerId(customerId); |
| | | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); // 不分页 |