TmsshipShipLocationController.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. package com.steerinfo.dil.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.steerinfo.dil.feign.ESFeign;
  4. import com.steerinfo.dil.model.TmsshipShipLocation;
  5. import com.steerinfo.dil.service.ITmsshipShipLocationService;
  6. import com.steerinfo.dil.service.impl.TmsshipShipLocationServiceImpl;
  7. import com.steerinfo.dil.service.impl.TmsshipTotalResultServiceImpl;
  8. import com.steerinfo.dil.util.BaseRESTfulController;
  9. import com.steerinfo.dil.util.ColumnDataUtil;
  10. import com.steerinfo.dil.util.PageListAdd;
  11. import com.steerinfo.framework.controller.RESTfulResult;
  12. import com.steerinfo.framework.service.pagehelper.PageHelper;
  13. import com.steerinfo.framework.service.pagehelper.PageList;
  14. import com.steerinfo.framework.utils.collection.ListUtils;
  15. import io.swagger.annotations.ApiImplicitParam;
  16. import io.swagger.annotations.ApiImplicitParams;
  17. import io.swagger.annotations.ApiOperation;
  18. import org.apache.commons.lang3.StringUtils;
  19. import org.apache.shiro.authz.annotation.RequiresPermissions;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.web.bind.annotation.*;
  22. import java.util.*;
  23. import java.math.BigDecimal;
  24. /**
  25. * TmsshipShipLocation RESTful接口:
  26. * @author generator
  27. * @version 1.0-SNAPSHORT 2021-08-19 08:52
  28. * 类描述
  29. * 修订历史:
  30. * 日期:2021-08-19
  31. * 作者:generator
  32. * 参考:
  33. * 描述:TmsshipShipLocation RESTful接口
  34. * @see null
  35. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  36. */
  37. @RestController
  38. @RequestMapping("/${api.version}/tmsshipshiplocations")
  39. public class TmsshipShipLocationController extends BaseRESTfulController {
  40. @Autowired
  41. TmsshipShipLocationServiceImpl tmsshipShipLocationService;
  42. @Autowired
  43. TmsshipTotalResultServiceImpl tmsshipTotalResultService;
  44. @Autowired
  45. ColumnDataUtil columnDataUtil;
  46. @Autowired
  47. ESFeign esFeign;
  48. /**
  49. * 新增位置作业
  50. * @param map
  51. * @return
  52. */
  53. @ApiOperation(value="新增位置作业", notes="根据TmsshipShipLocation对象创建")
  54. @ApiImplicitParams({
  55. @ApiImplicitParam(name = "map",value = "位置作业字段",required = true,paramType = "java.util.Map")
  56. })
  57. @PostMapping("/addShipLocation")
  58. public RESTfulResult addShipLocation(@RequestBody Map<String,Object> map) {
  59. int code = tmsshipShipLocationService.addShipLocation(map);
  60. return success(code);
  61. }
  62. /**
  63. * 修改位置作业信息
  64. * @param tmsshipShipLocation
  65. * @return
  66. */
  67. @ApiOperation(value="修改位置作业信息", notes="根据TmsshipShipLocation对象修改")
  68. @ApiImplicitParams({
  69. @ApiImplicitParam(name = "tmsshipShipLocation",value = "位置作业字段",required = true,paramType = "TmsshipShipLocation")
  70. })
  71. @PostMapping("/updateShipLocation")
  72. public RESTfulResult updateShipLocation(@RequestBody TmsshipShipLocation tmsshipShipLocation) {
  73. int code = tmsshipShipLocationService.updateShipLocation(tmsshipShipLocation);
  74. return success(code);
  75. }
  76. /**
  77. * 删除位置作业信息
  78. * @param locationId
  79. * @return
  80. */
  81. @ApiOperation(value="删除位置作业信息")
  82. @ApiImplicitParams({
  83. @ApiImplicitParam(name = "locationId",value = "位置作业字段",required = true,paramType = "BigDecimal")
  84. })
  85. @PostMapping("/deleteShipLocation/{locationId}")
  86. public RESTfulResult deleteShipLocation(@PathVariable("locationId") BigDecimal locationId) {
  87. int code = tmsshipShipLocationService.deleteShipLocation(locationId);
  88. return success(code);
  89. }
  90. /**
  91. * 查询位置作业信息
  92. * @param locationId
  93. * @return
  94. */
  95. @ApiOperation(value="查询位置作业信息")
  96. @ApiImplicitParams({
  97. @ApiImplicitParam(name = "mapVal",value = "位置作业字段",required = true,paramType = "java.util.Map")
  98. })
  99. @PostMapping("/selectShipLocation/{locationId}")
  100. public RESTfulResult selectShipLocation(@PathVariable("locationId") BigDecimal locationId) {
  101. TmsshipShipLocation tmsshipShipLocation = tmsshipShipLocationService.selectShipLocation(locationId);
  102. return success(tmsshipShipLocation);
  103. }
  104. /**
  105. * 查询位置作业信息
  106. * @param locationId
  107. * @return
  108. */
  109. @ApiOperation(value="查询位置作业信息")
  110. @ApiImplicitParams({
  111. @ApiImplicitParam(name = "mapVal",value = "位置作业字段",required = true,paramType = "java.util.Map")
  112. })
  113. @PostMapping("/getShipLocation/{locationId}")
  114. public RESTfulResult getShipLocation(@PathVariable("locationId") BigDecimal locationId) {
  115. List<Map<String,Object>> map = tmsshipShipLocationService.getShipLocation(locationId);
  116. return success(map);
  117. }
  118. /**
  119. * 展示位置作业信息列表
  120. * @param mapVal
  121. * @param pageNum
  122. * @param pageSize
  123. * @param apiId
  124. * @return
  125. */
  126. @ApiOperation(value="展示位置作业信息列表", notes="分页查询")
  127. @ApiImplicitParams({
  128. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  129. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  130. @ApiImplicitParam(name = "apiId", value = "59", required = false, dataType = "BigDecimal"),
  131. })
  132. @PostMapping(value = "/getShipLocationList")
  133. public RESTfulResult getShipLocationList(@RequestBody(required = false) Map<String,Object> mapVal,
  134. Integer pageNum,
  135. Integer pageSize,
  136. Integer apiId,
  137. String con){
  138. //框计算
  139. if(con != null){
  140. if(!"undefined".equals(con)){
  141. //设置要查询的索引名称
  142. String index="get_ship_location_list";
  143. //获取查询结果
  144. return success(esFeign.getConResult(mapVal,index,apiId,pageNum,pageSize,con));
  145. }
  146. }
  147. //初始化过滤
  148. List<Map<String, Object>> detailListTotal = null;
  149. //如果有条件查询则跳过初始化,和创建索引
  150. if (mapVal == null) {
  151. //将查询结果存入索引中
  152. detailListTotal = tmsshipShipLocationService.selectShipLocationList(null);
  153. Map<String, Object> map = new HashMap<>();
  154. //添加索引
  155. map.put("index", "get_ship_location_list");
  156. //添加id
  157. map.put("indexId", "locationId");
  158. detailListTotal.add(map);
  159. //新建索引
  160. String s = JSON.toJSONString(detailListTotal);
  161. esFeign.insertIndex(detailListTotal);
  162. //删除
  163. detailListTotal.remove(detailListTotal.size() - 1);
  164. }
  165. if (detailListTotal == null) {
  166. detailListTotal = tmsshipShipLocationService.selectShipLocationList(mapVal);
  167. }
  168. PageHelper.startPage(pageNum, pageSize);
  169. //分页查询数据
  170. List<Map<String, Object>> columnList = tmsshipShipLocationService.selectShipLocationList(mapVal);
  171. PageListAdd data = columnDataUtil.tableColumnData(apiId, detailListTotal, columnList);
  172. return success(data);
  173. }
  174. }