PtlAgreementController.java 12 KB

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