| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- package com.ydtech.modules.protocol.controller;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.core.page.PageResult;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.base.controller.BaseController;
- import com.ydtech.modules.order.entity.po.InsUploadFiles;
- import com.ydtech.modules.order.service.InsUploadFilesService;
- import com.ydtech.modules.protocol.entity.po.PtlAgreement;
- import com.ydtech.modules.protocol.entity.po.PtlAgreementNonCarProductCosts;
- import com.ydtech.modules.protocol.entity.po.PtlAgreementProductCosts;
- import com.ydtech.modules.protocol.entity.po.PtlAgreementUndwrtRules;
- import com.ydtech.modules.protocol.entity.vo.*;
- import com.ydtech.modules.protocol.service.*;
- import com.ydtech.modules.protocol.utils.AssertionUtils;
- import com.ydtech.validation.annotation.CheckObjectNotNull;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiModelProperty;
- import io.swagger.annotations.ApiOperation;
- import org.apache.poi.ss.formula.functions.T;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Objects;
- /**
- * @author wenks
- * @description 协议管理内容
- * @createDate 2023-06-05 17:59:52
- */
- @Api(tags = "协议")
- @RequestMapping("/plt/agreement")
- @RestController
- public class PtlAgreementController extends BaseController {
- @Value("${agreement.shutdown}")
- private boolean shutdown;
- private final PtlAgreementService ptlAgreementService;
- private final PtlAgreementUndwrtRulesService ptlAgreementUndwrtRulesService;
- private final PtlAgreementProductCostsService ptlAgreementProductCostsService;
- private final PtlAgreementNonCarProductCostsService ptlAgreementNonCarProductCostsService;
- private final PtlAgreementTrajectoryService ptlAgreementTrajectoryService;
- private final InsUploadFilesService insUploadFilesService;
- public PtlAgreementController(PtlAgreementService ptlAgreementService, PtlAgreementUndwrtRulesService ptlAgreementUndwrtRulesService,
- PtlAgreementProductCostsService ptlAgreementProductCostsService,
- PtlAgreementNonCarProductCostsService ptlAgreementNonCarProductCostsService,
- PtlAgreementTrajectoryService ptlAgreementTrajectoryService,
- InsUploadFilesService insUploadFilesService) {
- this.ptlAgreementService = ptlAgreementService;
- this.ptlAgreementProductCostsService = ptlAgreementProductCostsService;
- this.ptlAgreementUndwrtRulesService = ptlAgreementUndwrtRulesService;
- this.ptlAgreementNonCarProductCostsService = ptlAgreementNonCarProductCostsService;
- this.ptlAgreementTrajectoryService = ptlAgreementTrajectoryService;
- this.insUploadFilesService = insUploadFilesService;
- }
- @PostMapping("/page")
- @ApiOperation("分页查询协议")
- public HttpResult<PageResult<PtlAgreement>> page(@RequestBody PtlAgreementPageVo ptlAgreementPageVo) {
- Page<T> page = buildPageRequest(ptlAgreementPageVo.getPageDto());
- Page<PtlAgreement> pageResultHttpResult = ptlAgreementService.pageAgreement(page, ptlAgreementPageVo);
- return HttpResult.ok(buildPageResponse(pageResultHttpResult));
- }
- @GetMapping("/getAllAgreement")
- @ApiOperation("复制费用查询同保险公司协议")
- public HttpResult<List<PtlAgreement>> getAllAgreement(@RequestParam String agreementId) {
- return HttpResult.ok(ptlAgreementService.getAllAgreement(agreementId));
- }
- @PostMapping("/list")
- @ApiOperation("根据保险公司查询协议列表")
- public HttpResult<List<PtlAgreement>> list(@RequestBody PtlAgreementPageVo ptlAgreementPageVo) {
- return ptlAgreementService.listAgreement(ptlAgreementPageVo);
- }
- @PostMapping("/listInternal")
- @ApiOperation("根据保险公司查询协议列表")
- public HttpResult<List<PtlAgreement>> listInternal(@RequestBody PtlAgreementPageVo ptlAgreementPageVo) {
- ptlAgreementPageVo.setIsExternal(0);
- ptlAgreementPageVo.setAuditStatus(0);
- ptlAgreementPageVo.setValidStatus("1");
- return ptlAgreementService.listAgreementInternal(ptlAgreementPageVo);
- }
- @PutMapping("/{agreementId}")
- @ApiOperation("修改协议")
- public HttpResult<Object> revise(@PathVariable String agreementId, @RequestBody PtlAgreementSaveVo agreement) {
- String userName = getUserName();
- return ptlAgreementService.reviseAgreement(userName, agreementId, agreement);
- }
- @PostMapping("/batch")
- @ApiOperation("批量修改协议是否启用状态")
- public HttpResult<Object> batchRevise(@RequestBody PltAgreementBatchVo pltAgreementBatchVo) {
- List<PtlAgreement> ptlAgreements = new ArrayList<>();
- for (String agreementId : pltAgreementBatchVo.getAgreementIds()) {
- PtlAgreement ptlAgreement = new PtlAgreement();
- ptlAgreement.setId(agreementId);
- ptlAgreement.setValidStatus(pltAgreementBatchVo.getValidStatus());
- ptlAgreement.setAuditType(pltAgreementBatchVo.getAuditType());
- ptlAgreements.add(ptlAgreement);
- }
- boolean b = ptlAgreementService.updateBatchById(ptlAgreements);
- AssertionUtils.isSucceed(b, "批量修改协议失败");
- return HttpResult.ok("批量修改协议成功");
- }
- @GetMapping("/{agreementId}")
- @ApiOperation("通过协议id查询所有信息")
- public HttpResult<PtlAgreementQueryVo> getByAgreementId(@PathVariable String agreementId) {
- return ptlAgreementService.getByAgreementId(agreementId);
- }
- @DeleteMapping("/{agreementId}")
- @ApiOperation("删除协议")
- public HttpResult<Object> delete(@PathVariable String agreementId) {
- return ptlAgreementService.deleteAgreement(agreementId, getUserName());
- }
- @PostMapping
- @ApiOperation("添加协议")
- public HttpResult<Object> save(@RequestBody PtlAgreementSaveVo agreement) {
- String userName = getUserName();
- return ptlAgreementService.saveAgreement(agreement, userName);
- }
- @PostMapping("/getProduct")
- @ApiOperation("查询协议产品费用")
- public PageResult getProductSav(@RequestBody PtlAgreementProductQueryVo ptlAgreementProductQueryVo) {
- Page<T> page = buildPageRequest(ptlAgreementProductQueryVo.getPageDto());
- Page<PtlAgreementProductCosts> schemeQueryDto = ptlAgreementProductCostsService.getByAgreementId(page, ptlAgreementProductQueryVo);
- return buildPageResponse(schemeQueryDto);
- }
- @PostMapping("productSave")
- @ApiOperation("添加协议产品费用")
- public HttpResult<Object> productSave(@RequestBody PtlAgreementProductCosts agreement) {
- String userName = getUserName();
- return ptlAgreementService.saveAgreementProduct(agreement, userName);
- }
- @PostMapping("productUpdate")
- @ApiOperation("修改协议产品费用")
- public HttpResult<Object> productUpdate(@RequestBody PtlAgreementProductCosts agreement) {
- String userName = getUserName();
- return ptlAgreementService.updateAgreementProduct(agreement, userName);
- }
- @GetMapping("productDelete")
- @ApiOperation("删除协议产品费用")
- public HttpResult<Object> productDelete(String id) {
- String userName = getUserName();
- return ptlAgreementService.deleteAgreementProduct(id, userName);
- }
- @GetMapping("/getNonCarProduct")
- @ApiOperation("查询非车产品费用")
- public HttpResult<Object> getNonCarProduct(@RequestParam String agreementId) {
- List<PtlAgreementNonCarProductCosts> nonCarProductCosts = ptlAgreementNonCarProductCostsService.getByAgreementId(agreementId);
- return HttpResult.ok(nonCarProductCosts);
- }
- @PostMapping("nonCarProductSave")
- @ApiOperation("添加非车产品费用")
- public HttpResult<Object> nonCarProductSave(@RequestBody PtlAgreementNonVehicleProductCostsVo agreement) {
- String userName = getUserName();
- return ptlAgreementService.saveAgreementNonCarProductCosts(agreement, userName);
- }
- @PostMapping("getUndwrtRules")
- @ApiOperation("查询承保规则")
- public PageResult getUndwrtRules(@RequestBody PtlAgreementUndwrtRulesQueryVo ptlAgreementUndwrtRulesQueryVo) {
- Page<T> page = buildPageRequest(ptlAgreementUndwrtRulesQueryVo.getPageDto());
- Page<PtlAgreementUndwrtRules> underwritingRules = ptlAgreementUndwrtRulesService.getByAgreementId(page, ptlAgreementUndwrtRulesQueryVo.getAgreementId());
- return buildPageResponse(underwritingRules);
- }
- @PostMapping("undwrtRulesSave")
- @ApiOperation("添加承保规则")
- public HttpResult<Object> underwritingRulesSave(@RequestBody PtlAgreementUndwrtRules ptlAgreementUndwrtRules) {
- String userName = getUserName();
- return ptlAgreementService.saveAgreementUndwrtRules(ptlAgreementUndwrtRules, userName);
- }
- @PostMapping("undwrtRulesUpdate")
- @ApiOperation("修改承保规则")
- public HttpResult<Object> underwritingRulesUpdate(@RequestBody PtlAgreementUndwrtRules ptlAgreementUndwrtRules) {
- String userName = getUserName();
- return ptlAgreementService.updateAgreementUndwrtRules(ptlAgreementUndwrtRules, userName);
- }
- @GetMapping("undwrtRulesDelete")
- @ApiModelProperty("删除承保规则")
- public HttpResult<Object> underwritingRulesDelete(String id) {
- String userName = getUserName();
- return ptlAgreementService.deleteAgreementUndwrtRules(id, userName);
- }
- @PostMapping("/audit/{agreementId}")
- @ApiOperation("审核协议")
- public HttpResult<Object> audit(@PathVariable String agreementId, @RequestBody PtlAgreementAuditVo ptlAgreementAuditVo) {
- return ptlAgreementService.auditAgreement(agreementId, ptlAgreementAuditVo);
- }
- @GetMapping("/shutdown")
- @ApiOperation("关闭")
- public HttpResult<Boolean> shutdown() {
- return HttpResult.ok("", shutdown);
- }
- @PostMapping("/noncarcost")
- @ApiOperation("获取非车险费用配置列表")
- public HttpResult<List<PtlAgreementNonCarProductCostsVo>> getAgreementNonCarCosts(@RequestBody PtlAgreement ptlAgreement) {
- return ptlAgreementService.getNonCarCostsInfo(ptlAgreement.getAgreementCode(), ptlAgreement.getAssociationCompaniesId());
- }
- @PostMapping("/findrelationagree")
- @ApiOperation("获取可同步协议列表")
- public HttpResult<List<PtlAgreement>> findRelationAgreement(@RequestBody PtlAgreement ptlAgreement) {
- return ptlAgreementService.findRelationAgreement(ptlAgreement.getAssociationCompaniesId());
- }
- @GetMapping("getDockingPersonList")
- @ApiOperation("获取对接人列表")
- public HttpResult getDockingPersonList() {
- List<HashMap<String, Object>> list = ptlAgreementService.getDockingPersonList();
- return HttpResult.ok(list);
- }
- @PostMapping("/agreementCopy")
- @ApiOperation("协议复制")
- public HttpResult getAgreementCopy(@RequestBody PtlAgreementVo ptlAgreementVo) {
- return ptlAgreementService.getAgreementCopy(ptlAgreementVo);
- }
- @PostMapping("/agreementTrajectory")
- @ApiOperation("协议轨迹")
- public HttpResult getAgreementTrajectory(@RequestBody PtlAgreementVo ptlAgreementVo) {
- return ptlAgreementTrajectoryService.getAgreementTrajectory(ptlAgreementVo);
- }
- @PostMapping("/updateFeeFile")
- @ApiOperation("上传费用文件")
- public HttpResult updateFeeFile(@CheckObjectNotNull(message = "上传文件不能为空") MultipartFile multipartFile, String agreementId) throws IOException {
- agreementId = agreementId.replace(",","");
- InsUploadFiles insUploadFiles = insUploadFilesService.uploadFile(multipartFile, getUserName(), "file");
- PtlAgreement byId = ptlAgreementService.getById(agreementId);
- if(Objects.isNull(byId)){
- throw new SystemException("找不到协议");
- }
- byId.setFeeFileId(insUploadFiles.getId());
- return ptlAgreementService.updateById(byId) ? HttpResult.ok("上传费用文件成功") : HttpResult.error("上传文件失败");
- }
- }
|