| 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.model.ApiResponse; | 
| import com.doumee.core.model.PageWrap; | 
| import com.doumee.core.model.PageData; | 
| import com.doumee.core.utils.Constants; | 
| import com.doumee.dao.business.dto.ApplyDetailPageDTO; | 
| import com.doumee.dao.business.model.ApplyDetail; | 
| import com.doumee.service.business.ApplyDetailService; | 
| 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.web.bind.annotation.*; | 
| import javax.servlet.http.HttpServletResponse; | 
|   | 
| import java.math.BigDecimal; | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| /** | 
|  * @author 江蹄蹄 | 
|  * @date 2024/01/16 10:03 | 
|  */ | 
| @Api(tags = "投保申请明细信息表") | 
| @RestController | 
| @RequestMapping("/business/applyDetail") | 
| public class ApplyDetailController extends BaseController { | 
|   | 
|     @Autowired | 
|     private ApplyDetailService applyDetailService; | 
|   | 
|     @PreventRepeat | 
|     @ApiOperation("新建") | 
|     @PostMapping("/create") | 
|     @RequiresPermissions("business:applydetail:create") | 
|     public ApiResponse create(@RequestBody ApplyDetail applyDetail) { | 
|         return ApiResponse.success(applyDetailService.create(applyDetail)); | 
|     } | 
|   | 
|     @ApiOperation("根据ID删除") | 
|     @GetMapping("/delete/{id}") | 
|     @RequiresPermissions("business:applydetail:delete") | 
|     public ApiResponse deleteById(@PathVariable Integer id) { | 
|         applyDetailService.deleteById(id); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("批量删除") | 
|     @GetMapping("/delete/batch") | 
|     @RequiresPermissions("business:applydetail:delete") | 
|     public ApiResponse deleteByIdInBatch(@RequestParam String ids) { | 
|         String [] idArray = ids.split(","); | 
|         List<Integer> idList = new ArrayList<>(); | 
|         for (String id : idArray) { | 
|             idList.add(Integer.valueOf(id)); | 
|         } | 
|         applyDetailService.deleteByIdInBatch(idList); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("根据ID修改") | 
|     @PostMapping("/updateById") | 
|     @RequiresPermissions("business:applydetail:update") | 
|     public ApiResponse updateById(@RequestBody ApplyDetail applyDetail) { | 
|         applyDetailService.updateById(applyDetail); | 
|         return ApiResponse.success(null); | 
|     } | 
|   | 
|     @ApiOperation("分页查询") | 
|     @PostMapping("/page") | 
|     @RequiresPermissions("business:applydetail:query") | 
|     public ApiResponse<PageData<ApplyDetail>> findPage (@RequestBody PageWrap<ApplyDetailPageDTO> pageWrap) { | 
|         PageData<ApplyDetail> pageData = applyDetailService.findPageForCompany(pageWrap); | 
|         pageData.getRecords().forEach(i->{ | 
|             if(i.getSolutionType().equals(Constants.ONE)&&!i.getStatus().equals(Constants.InsuranceApplyStatus.WTB_DONE.getKey())){ | 
|                 i.setFee(null); | 
|             } | 
|         }); | 
|         return ApiResponse.success(pageData); | 
|     } | 
|   | 
|     @ApiOperation("列表查询") | 
|     @PostMapping("/findList") | 
|     @RequiresPermissions("business:applydetail:query") | 
|     public ApiResponse<List<ApplyDetail>> findList (@RequestBody ApplyDetailPageDTO applyDetailPageDTO) { | 
|         return ApiResponse.success(applyDetailService.findListForCompany(applyDetailPageDTO)); | 
|     } | 
|   | 
|     @ApiOperation("查询全部") | 
|     @PostMapping("/list") | 
|     @RequiresPermissions("business:applydetail:query") | 
|     public ApiResponse<List<ApplyDetail>> list (@RequestBody  ApplyDetail pageWrap) { | 
|         return ApiResponse.success(applyDetailService.findList(pageWrap)); | 
|     } | 
|   | 
|     @ApiOperation("导出在保人员详单Excel") | 
|     @PostMapping("/exportExcel") | 
|     @RequiresPermissions("business:applydetail:exportExcel") | 
|     public void exportExcel (@RequestBody PageWrap<ApplyDetailPageDTO> pageWrap, HttpServletResponse response) { | 
|         pageWrap.getModel().setIsExcel(Constants.ONE); | 
|         PageData<ApplyDetail> pageData = applyDetailService.findPageForCompany(pageWrap); | 
|         pageData.getRecords().forEach(i->{ | 
|             if(i.getSolutionType().equals(Constants.ONE)&&!i.getStatus().equals(Constants.InsuranceApplyStatus.WTB_DONE.getKey())){ | 
|                 i.setFee(BigDecimal.ZERO); | 
|             } | 
|         }); | 
|         ExcelExporter.build(ApplyDetail.class).exportWithSheetAndFirstAndEnd(pageData.getRecords(), pageWrap.getModel().getSolutionName()+".xlsx","《"+pageWrap.getModel().getSolutionName()+"》"+"保单人员信息",null, "保单人员",response); | 
|     } | 
|   | 
|     @ApiOperation("根据ID查询") | 
|     @GetMapping("/{id}") | 
|     @RequiresPermissions("business:applydetail:query") | 
|     public ApiResponse findById(@PathVariable Integer id) { | 
|         return ApiResponse.success(applyDetailService.findById(id)); | 
|     } | 
|   | 
|   | 
|     @ApiOperation("查询员工投保记录") | 
|     @GetMapping("/getMemberApplyList") | 
|     public ApiResponse<List<ApplyDetail>> getMemberApplyList(@RequestParam Integer memberId) { | 
|         return ApiResponse.success(applyDetailService.getMemberApplyList(memberId)); | 
|     } | 
|   | 
|   | 
|     @ApiOperation("查询人员可报案数据") | 
|     @GetMapping("/getMemberSettleClaimsList") | 
|     public ApiResponse<List<ApplyDetail>> getMemberSettleClaimsList(@RequestParam Integer memberId) { | 
|         return ApiResponse.success(applyDetailService.getMemberSettleClaimsList(memberId)); | 
|     } | 
|   | 
|   | 
|   | 
|   | 
| } |