RmsWarehouseController.java 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.RmsWarehouse;
  5. import com.steerinfo.dil.service.impl.RmsWarehouseServiceImpl;
  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.util.HashMap;
  18. import java.util.List;
  19. import java.util.Map;
  20. /**
  21. * @Description:
  22. * @Author:ZhouZhou
  23. * @CreateTime:2021/11/10 14:12
  24. * @Version:V1.0
  25. */
  26. @RestController
  27. @RequestMapping("/${api.version}/rmswarehouse")
  28. public class RmsWarehouseController extends BaseRESTfulController {
  29. @Autowired
  30. RmsWarehouseServiceImpl rmsWarehouseService;
  31. @Autowired
  32. ColumnDataUtil columnDataUtil;
  33. @Autowired
  34. ESFeign esFeign;
  35. /**
  36. *增加原料工厂
  37. * @param rmsWarehouse
  38. * @return
  39. */
  40. @ApiOperation(value="创建", notes="根据RmsWarehouse对象创建")
  41. @ApiImplicitParam(name = "rmsWarehouse", value = "详细实体rmsWarehouse", required = true, dataType = "RmsWarehouse")
  42. @PostMapping(value = "/insertWarehouse")
  43. public RESTfulResult insertWarehouse(@RequestBody(required = false) RmsWarehouse rmsWarehouse){
  44. int result = rmsWarehouseService.insertWarehouse(rmsWarehouse);
  45. if (result==-1){
  46. return failed();
  47. }
  48. return success(result);
  49. }
  50. /**
  51. *更新原料工厂
  52. * @param rmsWarehouse
  53. * @return
  54. */
  55. @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的rmsCarDriver信息来更新详细信息")
  56. @ApiImplicitParams({
  57. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal"),
  58. @ApiImplicitParam(name = "rmsWarehouse", value = "详细实体rmsWarehouse", required = true, dataType = "RmsWarehouse")
  59. })
  60. @PostMapping(value = "/updateWarehouse", produces = "application/json;charset=UTF-8")
  61. public RESTfulResult updateWarehouse( @RequestBody RmsWarehouse rmsWarehouse){
  62. int result = rmsWarehouseService.updateWarehouse(rmsWarehouse);
  63. return success(result);
  64. }
  65. /**
  66. *删除原料工厂
  67. * @param id
  68. * @return
  69. */
  70. @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
  71. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal")
  72. @PostMapping(value = "/deleteWarehouse/{id}")//BigDecimal
  73. public RESTfulResult deleteWarehouse(@PathVariable("id") BigDecimal id){
  74. return success(rmsWarehouseService.deleteWarehouse(id));
  75. }
  76. /**
  77. * 根据id获取原料仓库信息
  78. * @param id
  79. * @return
  80. */
  81. @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息")
  82. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal")
  83. @PostMapping(value = "/getWarehouseById/{id}")
  84. public RESTfulResult getWarehouseById(@PathVariable("id") BigDecimal id){
  85. // List<Map<String,Object>> list= rmsWarehouseService.getWarehouseById(id);
  86. Map<String,Object> list= rmsWarehouseService.getWarehouseById(id);
  87. return success(list);
  88. }
  89. /*
  90. * 获取原料仓库类型下拉
  91. * */
  92. @GetMapping(value = "getWarehouseTypeId")
  93. public RESTfulResult getWarehouseTypeId(){
  94. return success(rmsWarehouseService.getWarehouseTypeId());
  95. }
  96. /*
  97. *
  98. * 获取港存库所属港口下拉
  99. * */
  100. @GetMapping(value = "getPortId")
  101. public RESTfulResult getPortId(){
  102. return success(rmsWarehouseService.getPortId());
  103. }
  104. @ApiOperation(value = "模糊查询原料仓库", notes = "分页查询")
  105. @ApiImplicitParams({
  106. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  107. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  108. @ApiImplicitParam(name = "apiId", value = "196", required = false, dataType = "BigDecimal"),
  109. })
  110. @PostMapping(value = "/getWarehouseList")
  111. public RESTfulResult getWarehouseList(@RequestBody(required = false) Map<String, Object> mapValue,
  112. Integer pageNum,
  113. Integer pageSize,
  114. Integer apiId,
  115. String con) {
  116. if (mapValue==null){
  117. mapValue=new HashMap<>();
  118. }
  119. //框计算
  120. if (con != null) {
  121. if (!"undefined".equals(con)) {
  122. //设置要查询的索引名称
  123. String index = "get_warehouse_list";
  124. //获取查询结果
  125. return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
  126. }
  127. }
  128. //初始化过滤
  129. List<Map<String, Object>> listTotal = null;
  130. //如果有条件查询则跳过初始化,和创建索引
  131. if (mapValue.size() == 0) {
  132. //将查询结果存入索引中
  133. listTotal = rmsWarehouseService.getWarehouseList(null);
  134. Map<String, Object> map = new HashMap<>();
  135. //添加索引
  136. map.put("index", "get_warehouse_list");
  137. //添加id
  138. map.put("indexId", "warehouseId");
  139. listTotal.add(map);
  140. //新建索引
  141. String s = JSON.toJSONString(listTotal);
  142. esFeign.insertIndex(listTotal);
  143. //删除
  144. listTotal.remove(listTotal.size() - 1);
  145. }
  146. if (listTotal == null) {
  147. listTotal = rmsWarehouseService.getWarehouseList(mapValue);
  148. }
  149. PageHelper.startPage(pageNum, pageSize);
  150. //分页查询数据
  151. List<Map<String, Object>> columnList = rmsWarehouseService.getWarehouseList(mapValue);
  152. PageListAdd data = columnDataUtil.tableColumnData(apiId, listTotal, columnList);
  153. return success(data);
  154. }
  155. }