PtlAgreementController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. package com.ydtech.modules.protocol.controller;
  2. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  3. import com.ydtech.core.page.HttpResult;
  4. import com.ydtech.core.page.PageResult;
  5. import com.ydtech.modules.base.controller.BaseController;
  6. import com.ydtech.modules.protocol.entity.po.PtlAgreement;
  7. import com.ydtech.modules.protocol.entity.po.PtlAgreementNonCarProductCosts;
  8. import com.ydtech.modules.protocol.entity.po.PtlAgreementProductCosts;
  9. import com.ydtech.modules.protocol.entity.po.PtlAgreementUndwrtRules;
  10. import com.ydtech.modules.protocol.entity.vo.*;
  11. import com.ydtech.modules.protocol.service.*;
  12. import com.ydtech.modules.protocol.utils.AssertionUtils;
  13. import io.swagger.annotations.Api;
  14. import io.swagger.annotations.ApiModelProperty;
  15. import io.swagger.annotations.ApiOperation;
  16. import org.apache.poi.ss.formula.functions.T;
  17. import org.springframework.beans.factory.annotation.Value;
  18. import org.springframework.web.bind.annotation.*;
  19. import java.util.ArrayList;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. /**
  23. * @author wenks
  24. * @description 协议管理内容
  25. * @createDate 2023-06-05 17:59:52
  26. */
  27. @Api(tags = "协议")
  28. @RequestMapping("/plt/agreement")
  29. @RestController
  30. public class PtlAgreementController extends BaseController {
  31. @Value("${agreement.shutdown}")
  32. private boolean shutdown;
  33. private final PtlAgreementService ptlAgreementService;
  34. private final PtlAgreementUndwrtRulesService ptlAgreementUndwrtRulesService;
  35. private final PtlAgreementProductCostsService ptlAgreementProductCostsService;
  36. private final PtlAgreementNonCarProductCostsService ptlAgreementNonCarProductCostsService;
  37. private final PtlAgreementTrajectoryService ptlAgreementTrajectoryService;
  38. public PtlAgreementController(PtlAgreementService ptlAgreementService, PtlAgreementUndwrtRulesService ptlAgreementUndwrtRulesService,
  39. PtlAgreementProductCostsService ptlAgreementProductCostsService,
  40. PtlAgreementNonCarProductCostsService ptlAgreementNonCarProductCostsService,
  41. PtlAgreementTrajectoryService ptlAgreementTrajectoryService) {
  42. this.ptlAgreementService = ptlAgreementService;
  43. this.ptlAgreementProductCostsService = ptlAgreementProductCostsService;
  44. this.ptlAgreementUndwrtRulesService = ptlAgreementUndwrtRulesService;
  45. this.ptlAgreementNonCarProductCostsService = ptlAgreementNonCarProductCostsService;
  46. this.ptlAgreementTrajectoryService = ptlAgreementTrajectoryService;
  47. }
  48. @PostMapping("/page")
  49. @ApiOperation("分页查询协议")
  50. public HttpResult<PageResult<PtlAgreement>> page(@RequestBody PtlAgreementPageVo ptlAgreementPageVo) {
  51. Page<T> page = buildPageRequest(ptlAgreementPageVo.getPageDto());
  52. Page<PtlAgreement> pageResultHttpResult = ptlAgreementService.pageAgreement(page, ptlAgreementPageVo);
  53. return HttpResult.ok(buildPageResponse(pageResultHttpResult));
  54. }
  55. @GetMapping("/getAllAgreement")
  56. @ApiOperation("复制费用查询同保险公司协议")
  57. public HttpResult<List<PtlAgreement>> getAllAgreement(@RequestParam String agreementId) {
  58. return HttpResult.ok(ptlAgreementService.getAllAgreement(agreementId));
  59. }
  60. @PostMapping("/list")
  61. @ApiOperation("根据保险公司查询协议列表")
  62. public HttpResult<List<PtlAgreement>> list(@RequestBody PtlAgreementPageVo ptlAgreementPageVo) {
  63. return ptlAgreementService.listAgreement(ptlAgreementPageVo);
  64. }
  65. @PostMapping("/listInternal")
  66. @ApiOperation("根据保险公司查询协议列表")
  67. public HttpResult<List<PtlAgreement>> listInternal(@RequestBody PtlAgreementPageVo ptlAgreementPageVo) {
  68. ptlAgreementPageVo.setIsExternal(0);
  69. ptlAgreementPageVo.setAuditStatus(0);
  70. ptlAgreementPageVo.setValidStatus("1");
  71. return ptlAgreementService.listAgreementInternal(ptlAgreementPageVo);
  72. }
  73. @PutMapping("/{agreementId}")
  74. @ApiOperation("修改协议")
  75. public HttpResult<Object> revise(@PathVariable String agreementId, @RequestBody PtlAgreementSaveVo agreement) {
  76. String userName = getUserName();
  77. return ptlAgreementService.reviseAgreement(userName, agreementId, agreement);
  78. }
  79. @PostMapping("/batch")
  80. @ApiOperation("批量修改协议是否启用状态")
  81. public HttpResult<Object> batchRevise(@RequestBody PltAgreementBatchVo pltAgreementBatchVo) {
  82. List<PtlAgreement> ptlAgreements = new ArrayList<>();
  83. for (String agreementId : pltAgreementBatchVo.getAgreementIds()) {
  84. PtlAgreement ptlAgreement = new PtlAgreement();
  85. ptlAgreement.setId(agreementId);
  86. ptlAgreement.setValidStatus(pltAgreementBatchVo.getValidStatus());
  87. ptlAgreement.setAuditType(pltAgreementBatchVo.getAuditType());
  88. ptlAgreements.add(ptlAgreement);
  89. }
  90. boolean b = ptlAgreementService.updateBatchById(ptlAgreements);
  91. AssertionUtils.isSucceed(b, "批量修改协议失败");
  92. return HttpResult.ok("批量修改协议成功");
  93. }
  94. @GetMapping("/{agreementId}")
  95. @ApiOperation("通过协议id查询所有信息")
  96. public HttpResult<PtlAgreementQueryVo> getByAgreementId(@PathVariable String agreementId) {
  97. return ptlAgreementService.getByAgreementId(agreementId);
  98. }
  99. @DeleteMapping("/{agreementId}")
  100. @ApiOperation("删除协议")
  101. public HttpResult<Object> delete(@PathVariable String agreementId) {
  102. return ptlAgreementService.deleteAgreement(agreementId, getUserName());
  103. }
  104. @PostMapping
  105. @ApiOperation("添加协议")
  106. public HttpResult<Object> save(@RequestBody PtlAgreementSaveVo agreement) {
  107. String userName = getUserName();
  108. return ptlAgreementService.saveAgreement(agreement, userName);
  109. }
  110. @PostMapping("/getProduct")
  111. @ApiOperation("查询协议产品费用")
  112. public PageResult getProductSav(@RequestBody PtlAgreementProductQueryVo ptlAgreementProductQueryVo) {
  113. Page<T> page = buildPageRequest(ptlAgreementProductQueryVo.getPageDto());
  114. Page<PtlAgreementProductCosts> schemeQueryDto = ptlAgreementProductCostsService.getByAgreementId(page, ptlAgreementProductQueryVo);
  115. return buildPageResponse(schemeQueryDto);
  116. }
  117. @PostMapping("productSave")
  118. @ApiOperation("添加协议产品费用")
  119. public HttpResult<Object> productSave(@RequestBody PtlAgreementProductCosts agreement) {
  120. String userName = getUserName();
  121. return ptlAgreementService.saveAgreementProduct(agreement, userName);
  122. }
  123. @PostMapping("productUpdate")
  124. @ApiOperation("修改协议产品费用")
  125. public HttpResult<Object> productUpdate(@RequestBody PtlAgreementProductCosts agreement) {
  126. String userName = getUserName();
  127. return ptlAgreementService.updateAgreementProduct(agreement, userName);
  128. }
  129. @GetMapping("productDelete")
  130. @ApiOperation("删除协议产品费用")
  131. public HttpResult<Object> productDelete(String id) {
  132. String userName = getUserName();
  133. return ptlAgreementService.deleteAgreementProduct(id, userName);
  134. }
  135. @GetMapping("/getNonCarProduct")
  136. @ApiOperation("查询非车产品费用")
  137. public HttpResult<Object> getNonCarProduct(@RequestParam String agreementId) {
  138. List<PtlAgreementNonCarProductCosts> nonCarProductCosts = ptlAgreementNonCarProductCostsService.getByAgreementId(agreementId);
  139. return HttpResult.ok(nonCarProductCosts);
  140. }
  141. @PostMapping("nonCarProductSave")
  142. @ApiOperation("添加非车产品费用")
  143. public HttpResult<Object> nonCarProductSave(@RequestBody PtlAgreementNonVehicleProductCostsVo agreement) {
  144. String userName = getUserName();
  145. return ptlAgreementService.saveAgreementNonCarProductCosts(agreement, userName);
  146. }
  147. @PostMapping("getUndwrtRules")
  148. @ApiOperation("查询承保规则")
  149. public PageResult getUndwrtRules(@RequestBody PtlAgreementUndwrtRulesQueryVo ptlAgreementUndwrtRulesQueryVo) {
  150. Page<T> page = buildPageRequest(ptlAgreementUndwrtRulesQueryVo.getPageDto());
  151. Page<PtlAgreementUndwrtRules> underwritingRules = ptlAgreementUndwrtRulesService.getByAgreementId(page, ptlAgreementUndwrtRulesQueryVo.getAgreementId());
  152. return buildPageResponse(underwritingRules);
  153. }
  154. @PostMapping("undwrtRulesSave")
  155. @ApiOperation("添加承保规则")
  156. public HttpResult<Object> underwritingRulesSave(@RequestBody PtlAgreementUndwrtRules ptlAgreementUndwrtRules) {
  157. String userName = getUserName();
  158. return ptlAgreementService.saveAgreementUndwrtRules(ptlAgreementUndwrtRules, userName);
  159. }
  160. @PostMapping("undwrtRulesUpdate")
  161. @ApiOperation("修改承保规则")
  162. public HttpResult<Object> underwritingRulesUpdate(@RequestBody PtlAgreementUndwrtRules ptlAgreementUndwrtRules) {
  163. String userName = getUserName();
  164. return ptlAgreementService.updateAgreementUndwrtRules(ptlAgreementUndwrtRules, userName);
  165. }
  166. @GetMapping("undwrtRulesDelete")
  167. @ApiModelProperty("删除承保规则")
  168. public HttpResult<Object> underwritingRulesDelete(String id) {
  169. String userName = getUserName();
  170. return ptlAgreementService.deleteAgreementUndwrtRules(id, userName);
  171. }
  172. @PostMapping("/audit/{agreementId}")
  173. @ApiOperation("审核协议")
  174. public HttpResult<Object> audit(@PathVariable String agreementId, @RequestBody PtlAgreementAuditVo ptlAgreementAuditVo) {
  175. return ptlAgreementService.auditAgreement(agreementId, ptlAgreementAuditVo);
  176. }
  177. @GetMapping("/shutdown")
  178. @ApiOperation("关闭")
  179. public HttpResult<Boolean> shutdown() {
  180. return HttpResult.ok("", shutdown);
  181. }
  182. @PostMapping("/noncarcost")
  183. @ApiOperation("获取非车险费用配置列表")
  184. public HttpResult<List<PtlAgreementNonCarProductCostsVo>> getAgreementNonCarCosts(@RequestBody PtlAgreement ptlAgreement) {
  185. return ptlAgreementService.getNonCarCostsInfo(ptlAgreement.getAgreementCode(), ptlAgreement.getAssociationCompaniesId());
  186. }
  187. @PostMapping("/findrelationagree")
  188. @ApiOperation("获取可同步协议列表")
  189. public HttpResult<List<PtlAgreement>> findRelationAgreement(@RequestBody PtlAgreement ptlAgreement) {
  190. return ptlAgreementService.findRelationAgreement(ptlAgreement.getAssociationCompaniesId());
  191. }
  192. @GetMapping("getDockingPersonList")
  193. @ApiOperation("获取对接人列表")
  194. public HttpResult getDockingPersonList() {
  195. List<HashMap<String, Object>> list = ptlAgreementService.getDockingPersonList();
  196. return HttpResult.ok(list);
  197. }
  198. @PostMapping("/agreementCopy")
  199. @ApiOperation("协议复制")
  200. public HttpResult getAgreementCopy(@RequestBody PtlAgreementVo ptlAgreementVo) {
  201. return ptlAgreementService.getAgreementCopy(ptlAgreementVo);
  202. }
  203. @PostMapping("/agreementTrajectory")
  204. @ApiOperation("协议轨迹")
  205. public HttpResult getAgreementTrajectory(@RequestBody PtlAgreementVo ptlAgreementVo) {
  206. return ptlAgreementTrajectoryService.getAgreementTrajectory(ptlAgreementVo);
  207. }
  208. }