TmstruckSmsRusultController.java 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package com.steerinfo.dil.controller;
  2. import com.steerinfo.dil.feign.ESFeign;
  3. import com.steerinfo.dil.service.ITmstruckSmsRusultService;
  4. import com.steerinfo.dil.util.BaseRESTfulController;
  5. import com.steerinfo.dil.util.ColumnDataUtil;
  6. import com.steerinfo.dil.util.PageListAdd;
  7. import com.steerinfo.framework.controller.RESTfulResult;
  8. import com.steerinfo.framework.service.pagehelper.PageHelper;
  9. import io.swagger.annotations.ApiImplicitParam;
  10. import io.swagger.annotations.ApiImplicitParams;
  11. import io.swagger.annotations.ApiOperation;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.Map;
  17. /**
  18. * TmstruckSmsRusult RESTful接口:
  19. * @author generator
  20. * @version 1.0-SNAPSHORT 2021-10-18 09:19
  21. * 类描述
  22. * 修订历史:
  23. * 日期:2021-10-18
  24. * 作者:generator
  25. * 参考:
  26. * 描述:TmstruckSmsRusult RESTful接口
  27. * @see null
  28. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  29. */
  30. @RestController
  31. @RequestMapping("/${api.version}/tmstrucksmsrusults")
  32. public class TmstruckSmsRusultController extends BaseRESTfulController{
  33. @Autowired
  34. ITmstruckSmsRusultService tmstruckSmsRusultService;
  35. @Autowired
  36. ESFeign esFeign;
  37. @Autowired
  38. ColumnDataUtil columnDataUtil;
  39. @ApiOperation(value = "新增短信实绩", notes = "通过人工稽核判断点击新增短信实绩")
  40. @PostMapping(value = "/insertSmsResult")//BigDecimal
  41. public RESTfulResult insertSmsResult(@RequestBody(required = false) Map<String, Object> map) {
  42. int i = tmstruckSmsRusultService.addSmsResult(map);
  43. return success(i);
  44. }
  45. //查询短信实绩
  46. @ApiOperation(value="查询短信实绩")
  47. @ApiImplicitParams({
  48. @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  49. @ApiImplicitParam(name = "apiId(175)", value = "动态表头", required = false, dataType = "Integer"),
  50. @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  51. @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"),
  52. })
  53. @PostMapping("/getSmsResult")
  54. public RESTfulResult getSmsResult(@RequestBody(required=false) Map<String,Object> mapValue,
  55. Integer apiId,
  56. Integer pageNum,
  57. Integer pageSize,
  58. String con
  59. ){
  60. //框计算
  61. if(con != null){
  62. if(!"undefined".equals(con)){
  63. String index="get_sms_list";//设置要查询的索引名称
  64. return success(esFeign.getConResult(mapValue,index,apiId,pageNum,pageSize,con));//获取查询结果
  65. }
  66. }
  67. List<Map<String, Object>> allSmsResult = null;
  68. //如果有条件查询则跳过初始化,和创建索引
  69. if(mapValue.size() == 0){
  70. //将查询结果存入索引中
  71. allSmsResult = tmstruckSmsRusultService.getSmsResult(mapValue);
  72. Map<String, Object> map = new HashMap<>();
  73. //添加索引
  74. map.put("index","get_sms_list");
  75. //添加id
  76. map.put("indexId","smsId");
  77. allSmsResult.add(map);
  78. //新建索引
  79. esFeign.insertIndex(allSmsResult);
  80. //删除
  81. allSmsResult.remove(allSmsResult.size()-1);
  82. }
  83. if(allSmsResult == null){
  84. allSmsResult = tmstruckSmsRusultService.getSmsResult(mapValue);
  85. }
  86. PageHelper.startPage(pageNum,pageSize);
  87. //分页数据
  88. List<Map<String, Object>> smsResult = tmstruckSmsRusultService.getSmsResult(mapValue);
  89. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, allSmsResult,smsResult);
  90. return success(pageList);
  91. }
  92. }