RmsCarDriverController.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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.RmsCarDriver;
  5. import com.steerinfo.dil.service.impl.RmsCarDriverServiceImpl;
  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 com.steerinfo.framework.utils.misc.IdGenerator;
  12. import com.steerinfo.framework.utils.upload.UploadUtils;
  13. import io.swagger.annotations.ApiImplicitParam;
  14. import io.swagger.annotations.ApiImplicitParams;
  15. import io.swagger.annotations.ApiOperation;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.*;
  18. import org.springframework.web.multipart.MultipartFile;
  19. import java.math.BigDecimal;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. /**
  24. * @Description:
  25. * @Author:ZhouZhou
  26. * @CreateTime:2021/11/6 9:47
  27. * @Version:V1.0
  28. */
  29. @RestController
  30. @RequestMapping("/${api.version}/rmscardriver")
  31. public class RmsCarDriverController extends BaseRESTfulController {
  32. @Autowired
  33. RmsCarDriverServiceImpl rmsCarDriverService;
  34. @Autowired
  35. ColumnDataUtil columnDataUtil;
  36. @Autowired
  37. ESFeign esFeign;
  38. /**
  39. *增加司机
  40. * @param
  41. * @return
  42. */
  43. @ApiOperation(value="创建", notes="根据RmsCarDriver对象创建")
  44. @ApiImplicitParam(name = "rmsCarDriver", value = "详细实体rmsCarDriver", required = true, dataType = "RmsCarDriver")
  45. @PostMapping(value = "/insertCarDriver")
  46. public RESTfulResult insertCarDriver(@RequestBody(required = false) Map<String,Object> mapValue){
  47. int result = rmsCarDriverService.insertCarDriver(mapValue);
  48. if (result <= 0){
  49. return failed();
  50. }
  51. return success(result);
  52. }
  53. /**
  54. *更新司机
  55. * @param rmsCarDriver
  56. * @return
  57. */
  58. @PostMapping(value = "/updateCarDriver", produces = "application/json;charset=UTF-8")
  59. public RESTfulResult updateCarDriver(@RequestBody RmsCarDriver rmsCarDriver){
  60. int result = rmsCarDriverService.updateCarDriver(rmsCarDriver);
  61. return success(result);
  62. }
  63. /**
  64. *删除司机
  65. * @param id
  66. * @return
  67. */
  68. @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
  69. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal")
  70. @PostMapping(value = "/deleteCarDriver/{id}")//BigDecimal
  71. public RESTfulResult deleteCarDriver(@PathVariable("id") BigDecimal id){
  72. return success(rmsCarDriverService.deleteCarDriver(id));
  73. }
  74. /**
  75. * 根据id获取司机
  76. * @param id
  77. * @return
  78. */
  79. @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息")
  80. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal")
  81. @PostMapping(value = "/getCarDriverById/{id}")
  82. public RESTfulResult getCarDriverById(@PathVariable("id") BigDecimal id){
  83. List<Map<String,Object>> map= rmsCarDriverService.getCarDriverById(id);
  84. return success(map);
  85. }
  86. @ApiOperation(value = "司机模糊查询", notes = "分页查询")
  87. @ApiImplicitParams({
  88. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  89. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  90. @ApiImplicitParam(name = "apiId", value = "196", required = false, dataType = "BigDecimal"),
  91. })
  92. @PostMapping(value = "/getCarDriverList")
  93. public RESTfulResult getCarDriverList(@RequestBody(required = false) Map<String, Object> mapValue,
  94. Integer pageNum,
  95. Integer pageSize,
  96. Integer apiId,
  97. String con) {
  98. if (mapValue==null){
  99. mapValue=new HashMap<>();
  100. }
  101. //框计算
  102. if (con != null) {
  103. if (!"undefined".equals(con)) {
  104. //设置要查询的索引名称
  105. String index = "get_car_driver_list";
  106. //获取查询结果
  107. return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));
  108. }
  109. }
  110. //初始化过滤
  111. List<Map<String, Object>> listTotal = null;
  112. //如果有条件查询则跳过初始化,和创建索引
  113. if (mapValue.size() == 0) {
  114. //将查询结果存入索引中
  115. listTotal = rmsCarDriverService.getCarDriverList(null);
  116. Map<String, Object> map = new HashMap<>();
  117. //添加索引
  118. map.put("index", "get_car_driver_list");
  119. //添加id
  120. map.put("indexId", "driverId");
  121. listTotal.add(map);
  122. //新建索引
  123. String s = JSON.toJSONString(listTotal);
  124. esFeign.insertIndex(listTotal);
  125. //删除
  126. listTotal.remove(listTotal.size() - 1);
  127. }
  128. if (listTotal == null) {
  129. listTotal = rmsCarDriverService.getCarDriverList(mapValue);
  130. }
  131. PageHelper.startPage(pageNum, pageSize);
  132. //分页查询数据
  133. List<Map<String, Object>> columnList = rmsCarDriverService.getCarDriverList(mapValue);
  134. PageListAdd data = columnDataUtil.tableColumnData(apiId, listTotal, columnList);
  135. return success(data);
  136. }
  137. /*
  138. * 运输类型下拉框
  139. * */
  140. @GetMapping("/getTransportTypeId")
  141. public RESTfulResult getTransportTypeId(){
  142. return success(rmsCarDriverService.getTransportTypeId());
  143. }
  144. /*
  145. *边写边搜索承运商
  146. * */
  147. @ApiOperation(value="根据用户输入输出承运商", notes="模糊查询")
  148. @ApiImplicitParams({
  149. @ApiImplicitParam(name = "con",value = "用户输入的承运商名", required = false, dataType = "String")
  150. })
  151. @PostMapping("/getCarrierName")
  152. public RESTfulResult getCarrierName(@RequestParam(value ="state") String state){
  153. List<Map<String, Object>> carrierName = rmsCarDriverService.getCarrierName(state);
  154. return success(carrierName);
  155. }
  156. //根据司机id查询承运商
  157. @PostMapping(value = "/getCarrierNameByDriverId/{id}")
  158. public RESTfulResult getCarrierNameByDriverId(@PathVariable("id") BigDecimal id){
  159. Map<String,Object> map = rmsCarDriverService.getCarrierNameByDriverId(id);
  160. return success(map);
  161. }
  162. }