RmsGatepostController.java 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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.RmsGatepost;
  5. import com.steerinfo.dil.service.impl.RmsGatepostServiceImpl;
  6. import com.steerinfo.dil.util.BaseRESTfulController;
  7. import com.steerinfo.dil.util.ColumnDataUtil;
  8. import com.steerinfo.dil.util.PageListAdd;
  9. import com.steerinfo.framework.controller.RESTfulResult;
  10. import com.steerinfo.framework.service.pagehelper.PageHelper;
  11. import io.swagger.annotations.ApiImplicitParam;
  12. import io.swagger.annotations.ApiImplicitParams;
  13. import io.swagger.annotations.ApiOperation;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.*;
  16. import java.math.BigDecimal;
  17. import java.text.ParseException;
  18. import java.text.SimpleDateFormat;
  19. import java.util.*;
  20. /**
  21. * RmsGatepost RESTful接口:
  22. * @author generator
  23. * @version 1.0-SNAPSHORT 2021-11-12 11:51
  24. * 类描述
  25. * 修订历史:
  26. * 日期:2021-11-12
  27. * 作者:generator
  28. * 参考:
  29. * 描述:RmsGatepost RESTful接口
  30. * @see null
  31. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  32. */
  33. @RestController
  34. @RequestMapping("/${api.version}/rmsgatepost")
  35. public class RmsGatepostController extends BaseRESTfulController {
  36. @Autowired
  37. RmsGatepostServiceImpl rmsGatepostService;
  38. @Autowired
  39. RmsGatepostServiceImpl rmsGatepostRulesService;
  40. @Autowired
  41. ColumnDataUtil columnDataUtil;
  42. @Autowired
  43. ESFeign esFeign;
  44. /**
  45. * 获得门岗列表
  46. * @param mapValue
  47. * @param pageNum
  48. * @param pageSize
  49. * @param apiId
  50. * @return
  51. */
  52. @ApiOperation(value="获取列表", notes="分页查询")
  53. @ApiImplicitParams({
  54. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  55. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  56. @ApiImplicitParam(name = "apiId", value = "347", required = false, dataType = "BigDecimal"),
  57. })
  58. //@RequiresPermissions("rmsgatepost:view")
  59. @PostMapping(value = "/getGatepostList")
  60. public RESTfulResult getGatepostList(@RequestBody(required = false) Map<String,Object> mapValue,
  61. Integer apiId,
  62. Integer pageNum,
  63. Integer pageSize,
  64. String con) throws ParseException {
  65. //框计算
  66. if (con != null) {
  67. if (!"undefined".equals(con)) {
  68. //设置要查询的索引名称
  69. String index = "get_gatepost_list";
  70. //获取查询结果
  71. return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
  72. }
  73. }
  74. //初始化过滤
  75. List<Map<String, Object>> listTotal = null;
  76. //如果有条件查询则跳过初始化,和创建索引
  77. if (mapValue.size() == 0) {
  78. //将查询结果存入索引中
  79. listTotal = rmsGatepostService.getGatepostList(null);
  80. Map<String, Object> map = new HashMap<>();
  81. //添加索引
  82. map.put("index", "get_gatepost_list");
  83. //添加id
  84. map.put("indexId", "gatepostId");
  85. listTotal.add(map);
  86. //新建索引
  87. String s = JSON.toJSONString(listTotal);
  88. esFeign.insertIndex(listTotal);
  89. //删除
  90. listTotal.remove(listTotal.size() - 1);
  91. }
  92. if (listTotal == null) {
  93. listTotal = rmsGatepostService.getGatepostList(mapValue);
  94. }
  95. PageHelper.startPage(pageNum, pageSize);
  96. //分页查询数据
  97. List<Map<String, Object>> columnList = rmsGatepostService.getGatepostList(mapValue);
  98. PageListAdd data = columnDataUtil.tableColumnData(apiId, listTotal, columnList);
  99. return success(data);
  100. }
  101. /**
  102. * 添加门岗信息
  103. * @param rmsGatepost
  104. * @return
  105. */
  106. @ApiOperation(value="创建", notes="根据RmsGatepost对象创建")
  107. @ApiImplicitParam(name = "rmsGatepost", value = "详细实体rmsGatepost", required = true, dataType = "RmsGatepost")
  108. //@RequiresPermissions("rmsgatepost:create")
  109. @PostMapping(value = "/insertGatepost")
  110. public RESTfulResult insertGatepost(@RequestBody RmsGatepost rmsGatepost) {
  111. int result= rmsGatepostService.insertGatepost(rmsGatepost);
  112. if (result==-1){
  113. return failed();
  114. }
  115. return success(result);
  116. }
  117. /**
  118. * 根据id值更新门岗信息
  119. * @param mapValue
  120. * @return
  121. */
  122. @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的rmsGatepost信息来更新详细信息")
  123. @ApiImplicitParams({
  124. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal"),
  125. @ApiImplicitParam(name = "rmsGatepost", value = "详细实体rmsGatepost", required = true, dataType = "RmsGatepost")
  126. })
  127. //@RequiresPermissions("rmsgatepost:update")
  128. @PostMapping(value = "updateGatepost", produces = "application/json;charset=UTF-8")
  129. public RESTfulResult updateGatepost(LinkedHashMap<String, Object> mapValue) throws Exception{
  130. int result= rmsGatepostService.updateGatepost(mapValue);
  131. return success(result);
  132. }
  133. /**
  134. * 根据id删除对应的门岗信息
  135. * @param gatepostId
  136. * @return
  137. */
  138. @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
  139. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "Short")
  140. //@RequiresPermissions("rmsgatepost:delete")
  141. @PostMapping(value = "/deleteGatepost/{gatepostId}")
  142. public RESTfulResult deleteGatepost(@PathVariable("gatepostId") BigDecimal gatepostId){
  143. int result=rmsGatepostService.deleteGatepost(gatepostId);
  144. return success(result);
  145. }
  146. /**
  147. * 根据id获取门岗规则详细信息
  148. */
  149. @ApiOperation(value="获取列表", notes="分页查询")
  150. @ApiImplicitParams({
  151. @ApiImplicitParam(name = "apiId", value = "349", required = false, dataType = "BigDecimal"),
  152. })
  153. //@RequiresPermissions("rmsgatepost:view")
  154. @PostMapping(value = "/getGatepostRulesById/{gatepostId}")
  155. public RESTfulResult getGatepostRulesById(@PathVariable("gatepostId") BigDecimal gatepostId,
  156. Integer apiId) {
  157. List<Map<String, Object>> list= rmsGatepostService.getGatepostRulesById(gatepostId);
  158. // 将数据库中的进出类型进行格式转换输出
  159. for (Map<String, Object> map1:list){
  160. // 将数据库中的进出类型从整型转换为字符串
  161. if (map1.get("rulesGatepostEntityOutType")!=null){
  162. BigDecimal rule= (BigDecimal) map1.get("rulesGatepostEntityOutType");
  163. if (rule.intValue()==0){
  164. map1.put("rulesGatepostEntityOutTypeStr","进");
  165. }
  166. if (rule.intValue()==1){
  167. map1.put("rulesGatepostEntityOutTypeStr","出");
  168. }
  169. }
  170. }
  171. List<Map<String, Object>> columnList = list;
  172. System.out.println(columnList);
  173. PageListAdd data = columnDataUtil.tableColumnData(apiId, list, columnList);
  174. System.out.println(data);
  175. return success(data);
  176. }
  177. /**
  178. * 获取车辆类型Id
  179. */
  180. @GetMapping("/getVehicleTypeId")
  181. public RESTfulResult getVehicleTypeId(){
  182. return success(rmsGatepostService.getVehicleTypeId());
  183. }
  184. /**
  185. * 根据规则id删除对应的规则信息
  186. * @param rulesId
  187. * @return
  188. */
  189. @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
  190. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "Short")
  191. //@RequiresPermissions("rmsgatepost:delete")
  192. @PostMapping(value = "/deleteGatepostRules/{rulesId}")
  193. public RESTfulResult deleteGatepostRules(@PathVariable("rulesId") BigDecimal rulesId){
  194. int result=rmsGatepostRulesService.deleteGatepostRules(rulesId);
  195. return success(result);
  196. }
  197. /**
  198. * 添加相对应的规则信息
  199. */
  200. @ApiOperation(value="创建", notes="根据mapValue对象创建")
  201. @ApiImplicitParam(name = "rmsGatepostRules", value = "详细mapValue", required = true, dataType = "mapValue")
  202. @PostMapping(value = "/insertGatepostRule")
  203. public RESTfulResult insertGatepostRule(@RequestBody(required = false) Map<String,Object> mapValue) {
  204. int result= rmsGatepostRulesService.insertGatepostRule(mapValue);
  205. return success(result);
  206. }
  207. /**
  208. * 根据门岗id获取门岗名
  209. */
  210. @ApiOperation(value="查询", notes="根据url的id来指定查询")
  211. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "Short")
  212. //@RequiresPermissions("rmsgatepost:delete")
  213. @PostMapping(value = "/getGatepostName/{gatepostId}")
  214. public RESTfulResult getGatepostName(@PathVariable("gatepostId") BigDecimal gatepostId){
  215. return success(rmsGatepostService.getGatepostName(gatepostId));
  216. }
  217. }