package com.doumee.api.business; import com.doumee.api.BaseController; import com.doumee.core.annotation.excel.ExcelExporter; import com.doumee.core.annotation.pr.PreventRepeat; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.model.ApiResponse; import com.doumee.core.model.PageWrap; import com.doumee.core.model.PageData; import com.doumee.core.utils.Constants; import com.doumee.core.utils.DateUtil; import com.doumee.dao.business.dto.ApplyChangeCyclePriceDTO; import com.doumee.dao.business.model.ApplyChange; import com.doumee.dao.business.model.InsuranceApply; import com.doumee.dao.business.vo.CountCyclePriceVO; import com.doumee.service.business.ApplyChangeService; import com.doumee.service.business.InsuranceApplyService; import com.doumee.service.business.impl.UnionChangeServiceImpl; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Objects; /** * @author 江蹄蹄 * @date 2024/01/16 10:03 */ @Api(tags = "加减保换厂申请信息表") @RestController @RequestMapping("/business/applyChange") public class ApplyChangeController extends BaseController { @Autowired private ApplyChangeService applyChangeService; @Autowired private InsuranceApplyService insuranceApplyService; @Autowired private UnionChangeServiceImpl unionChangeServiceImpl; @PreventRepeat @ApiOperation("新建") @PostMapping("/create") @RequiresPermissions("business:applychange:create") public ApiResponse create(@RequestBody ApplyChange applyChange) { return ApiResponse.success(applyChangeService.create(applyChange)); } @PreventRepeat @ApiOperation("平台退回申请") @PostMapping("/back") @RequiresPermissions("business:applychange:back") public ApiResponse back(@RequestBody ApplyChange applyChange) { return ApiResponse.success(applyChangeService.back(applyChange)); } @PreventRepeat @ApiOperation("平台处理退回申请") @PostMapping("/dealBackApply") @RequiresPermissions("business:applychange:dealBackApply") public ApiResponse dealBackApply(@RequestBody ApplyChange applyChange) { return ApiResponse.success(applyChangeService.dealBackApply(applyChange)); } @PreventRepeat @ApiOperation("平台上传批单") @PostMapping("/uploadPidan") @RequiresPermissions("business:applychange:uploadPidan") public ApiResponse uploadPidan(@RequestBody ApplyChange applyChange) { Integer applyId = applyChangeService.uploadPidan(applyChange); insuranceApplyService.updateApplyCurrentFee(applyId,null); return ApiResponse.success(null); } @PreventRepeat @ApiOperation("平台修改批单") @PostMapping("/editPidan") @RequiresPermissions("business:applychange:uploadPidan") public ApiResponse editPidan(@RequestBody ApplyChange applyChange) { return ApiResponse.success(applyChangeService.editPidan(applyChange)); } @ApiOperation("获取加减保签章地址") @PostMapping("/getJiajianBaoSignLink") @RequiresPermissions("business:applychange:sign") public ApiResponse getSignLinkJiajiabao (@RequestBody ApplyChange model, HttpServletResponse response) { return ApiResponse.success( applyChangeService.getSignLinkJiajiabao(model)); } @ApiOperation("获取缓存申请签章地址") @PostMapping("/getChangeUnitSignLink") @RequiresPermissions("business:applychange:sign") public ApiResponse getChangeUnitSignLink (@RequestBody ApplyChange model, HttpServletResponse response) { return ApiResponse.success( applyChangeService.getSignLinkChangeUnit(model)); } @ApiOperation("列表查询") @PostMapping("/list") @RequiresPermissions("business:applychange:query") public ApiResponse> list (@RequestBody ApplyChange applyChange) { return ApiResponse.success(applyChangeService.findListForCompany(applyChange)); } @ApiOperation("根据ID删除") @GetMapping("/delete/{id}") @RequiresPermissions("business:applychange:delete") public ApiResponse deleteById(@PathVariable Integer id) { applyChangeService.deleteById(id); return ApiResponse.success(null); } @ApiOperation("批量删除") @GetMapping("/delete/batch") @RequiresPermissions("business:applychange:delete") public ApiResponse deleteByIdInBatch(@RequestParam String ids) { String [] idArray = ids.split(","); List idList = new ArrayList<>(); for (String id : idArray) { idList.add(Integer.valueOf(id)); } applyChangeService.deleteByIdInBatch(idList); return ApiResponse.success(null); } @ApiOperation("根据ID修改") @PostMapping("/updateById") @RequiresPermissions("business:applychange:update") public ApiResponse updateById(@RequestBody ApplyChange applyChange) { applyChangeService.updateById(applyChange); return ApiResponse.success(null); } @ApiOperation("分页查询") @PostMapping("/page") @RequiresPermissions("business:applychange:query") public ApiResponse> findPage (@RequestBody PageWrap pageWrap) { return ApiResponse.success(applyChangeService.findPageForCompany(pageWrap)); } @ApiOperation("导出Excel") @PostMapping("/exportExcel") @RequiresPermissions("business:applychange:exportExcel") public void exportExcel (@RequestBody PageWrap pageWrap, HttpServletResponse response) { ExcelExporter.build(ApplyChange.class).export(applyChangeService.findPageForCompany(pageWrap).getRecords(), "加减保换厂申请信息表", response); } @ApiOperation("导出加减保详情单") @PostMapping("/exportJiajianBaoExcel") @RequiresPermissions("business:applychange:exportExcel") public void exportJiajianBaoExcel (@RequestBody ApplyChange model, HttpServletResponse response) { ExcelExporter.build(ApplyChange.class).exportJiajianBaoExcel(applyChangeService.exportJiajianBaoExcel(model), response); } @ApiOperation("导出换厂申请详情单") @PostMapping("/exportChangeUnitExcel") @RequiresPermissions("business:applychange:exportExcel") public void exportChangeUnitExcel (@RequestBody ApplyChange model, HttpServletResponse response) { ExcelExporter.build(ApplyChange.class).exportChangeUnitExcel(applyChangeService.exportChangeUnitExcel(model), response); } @ApiOperation("根据ID查询") @GetMapping("/{id}") @RequiresPermissions("business:applychange:query") public ApiResponse findById(@PathVariable Integer id) { return ApiResponse.success(applyChangeService.findDetail(id)); } @ApiOperation("查询月度统计数据") @PostMapping("/monthList") @RequiresPermissions("business:applychange:query") public ApiResponse> findPage (@RequestBody ApplyChange pageWrap) { return ApiResponse.success(applyChangeService.monthTotalList(pageWrap)); } @ApiOperation("加减保业务补充金额") @PostMapping("/getChangeCountCyclePriceVO") public ApiResponse getChangeCountCyclePriceVO (@RequestBody ApplyChangeCyclePriceDTO applyChangeCyclePriceDTO) { applyChangeCyclePriceDTO.setValidTime(DateUtil.getMontageDate(new Date(),1)); return ApiResponse.success("操作成功",applyChangeService.getChangeCountCyclePriceVO(applyChangeCyclePriceDTO)); } @ApiOperation("商户审核 - 委托保业务") @PostMapping("/check") @RequiresPermissions("business:applychange:check") public ApiResponse check(@RequestBody ApplyChange model) { return ApiResponse.success(applyChangeService.check(model,unionChangeServiceImpl)); } @ApiOperation("导出保单下所有加减保详情单") @PostMapping("/exportApplyJiajianBaoExcel") @RequiresPermissions("business:applychange:exportExcel") public void exportApplyJiajianBaoExcel (@RequestBody InsuranceApply insuranceApply, HttpServletResponse response) { insuranceApply = insuranceApplyService.findDetail(insuranceApply.getId()); if(Objects.isNull(insuranceApply)){ throw new BusinessException(com.doumee.core.constants.ResponseStatus.DATA_EMPTY); } List applyChangeList = applyChangeService.findListByApplyId(insuranceApply.getId(), Constants.ZERO); List excelList = new ArrayList<>(); if(CollectionUtils.isEmpty(applyChangeList)){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"无可导出的加减保记录"); }else{ for (ApplyChange applyChange:applyChangeList) { excelList.add(applyChangeService.exportJiajianBaoExcel(applyChange)); } } ExcelExporter.build(ApplyChange.class).exportApplyJiajianBaoExcel(insuranceApply,excelList, response); } }