RmsCapacityController.java 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. package com.steerinfo.dil.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.steerinfo.dil.component.ImageFileUtils;
  4. import com.steerinfo.dil.feign.ESFeign;
  5. import com.steerinfo.dil.model.RmsCapacity;
  6. import com.steerinfo.dil.service.impl.RmsCapacityServiceImpl;
  7. import com.steerinfo.dil.util.BaseRESTfulController;
  8. import com.steerinfo.dil.util.ColumnDataUtil;
  9. import com.steerinfo.dil.util.DataChange;
  10. import com.steerinfo.dil.util.PageListAdd;
  11. import com.steerinfo.framework.controller.RESTfulResult;
  12. import com.steerinfo.framework.service.pagehelper.PageHelper;
  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 java.math.BigDecimal;
  19. import java.util.ArrayList;
  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/9 14:28
  27. * @Version:V1.0
  28. */
  29. @RestController
  30. @RequestMapping("/${api.version}/rmscapacity")
  31. public class RmsCapacityController extends BaseRESTfulController {
  32. @Autowired
  33. RmsCapacityServiceImpl rmsCapacityService;
  34. @Autowired
  35. ColumnDataUtil columnDataUtil;
  36. @Autowired
  37. ESFeign esFeign;
  38. @Autowired
  39. private ImageFileUtils imageFileUtils;
  40. /**
  41. * 创建运力信息
  42. * @param
  43. * @return
  44. */
  45. @ApiOperation(value="创建", notes="根据RmsCapacity对象创建")
  46. @ApiImplicitParam(name = "rmsCapacity", value = "详细实体rmsCapacity", required = true, dataType = "RmsCapacity")
  47. @PostMapping(value = "/insertCapacity")
  48. public RESTfulResult insertCapacity(@RequestBody(required = false) Map<String,Object> mapValue){
  49. int result = rmsCapacityService.insertCapacity(mapValue);
  50. if (result == 0){
  51. return success(0);
  52. }
  53. if (result == -1) {
  54. return failed(-1);
  55. }
  56. return success(result);
  57. }
  58. /**
  59. * 根据id更新运力信息
  60. * @param map
  61. * @return
  62. */
  63. @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的rmsCapacity信息来更新详细信息")
  64. @ApiImplicitParams({
  65. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "Short"),
  66. @ApiImplicitParam(name = "rmsCapacity", value = "详细实体rmsCapacity", required = true, dataType = "RmsCapacity")
  67. })
  68. @PostMapping(value = "/updateCapacity", produces = "application/json;charset=UTF-8")
  69. public RESTfulResult updateCapacity( @RequestBody Map<String,Object> map){
  70. int result = rmsCapacityService.updateCapacity(map);
  71. return success(result);
  72. }
  73. /**
  74. * 根据id删除运力信息
  75. * @param id
  76. * @return
  77. */
  78. @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
  79. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "Short")
  80. @PostMapping(value = "/deleteCapacity/{id}")
  81. public RESTfulResult deleteCapacity(@PathVariable("id") BigDecimal id){
  82. int s = rmsCapacityService.deleteCapacity(id);
  83. return success(s);
  84. }
  85. /**
  86. * 根据id获取运力信息
  87. * @param id
  88. * @return
  89. */
  90. @ApiOperation(value="获取运力详细信息", notes="根据url的id来获取详细信息")
  91. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal")
  92. @PostMapping(value = "/getCapacityById/{id}")
  93. public RESTfulResult getCapacityById(@PathVariable("id") BigDecimal id) throws Exception {
  94. List<Map<String,Object>> list= rmsCapacityService.getCapacityById(id);
  95. List<Map<String,Object>> resultList= new ArrayList<>();
  96. for (Map<String,Object> item :list){
  97. if(item.containsKey("driverLicenceUrl")&&item.get("driverLicenceUrl")!=null){
  98. String driverLicenceUrl = imageFileUtils.downloadFile(item.get("driverLicenceUrl").toString()).toString();
  99. item.put("driverLicenceUrl",driverLicenceUrl);
  100. }
  101. resultList.add(item);
  102. }
  103. return success(resultList);
  104. }
  105. @ApiOperation(value="获取运力详细信息", notes="根据url的id来获取详细信息")
  106. @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "BigDecimal")
  107. @PostMapping(value = "/getCapacityInfoById/{id}")
  108. public RESTfulResult getCapacityInfoById(@PathVariable("id") Integer id) throws Exception {
  109. List<Map<String,Object>> list= rmsCapacityService.getCapacityByCapacityId(id);
  110. return success(list);
  111. }
  112. /*
  113. * 运力类型下拉框
  114. * */
  115. @GetMapping("/getCapacityTypeId")
  116. public RESTfulResult getCapacityTypeId(){
  117. return success(rmsCapacityService.getCapacityTypeId());
  118. }
  119. /*
  120. * 承运单位下拉框
  121. * */
  122. @GetMapping("/getCarrierId")
  123. public RESTfulResult getCarrierId(){
  124. return success(rmsCapacityService.getCarrierId());
  125. }
  126. /*
  127. *模糊查询运力表
  128. * */
  129. @ApiOperation(value = "模糊查询展示运力表", notes = "分页查询")
  130. @ApiImplicitParams({
  131. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  132. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  133. @ApiImplicitParam(name = "apiId", value = "397", required = false, dataType = "BigDecimal"),
  134. })
  135. @PostMapping(value = "/getCapacityList")
  136. public RESTfulResult getCapacityList(@RequestBody(required = false) Map<String, Object> mapValue,
  137. Integer apiId,
  138. Integer pageNum,
  139. Integer pageSize,
  140. String con,
  141. String carrierSSOId) {
  142. if(carrierSSOId != null){
  143. if(!"null".equals(carrierSSOId)) {
  144. mapValue.put("carrierSSOId", carrierSSOId);
  145. }
  146. }
  147. if(con != null){
  148. if(!"".equals(con)){
  149. mapValue.put("index", con);
  150. }
  151. }
  152. PageHelper.startPage(pageNum, pageSize);
  153. //分页查询数据
  154. List<Map<String, Object>> columnList = rmsCapacityService.getCapacityList(mapValue);
  155. PageListAdd data = columnDataUtil.tableColumnData(apiId, null, columnList);
  156. return success(data);
  157. }
  158. //根据carrierSSOId查询承运商
  159. @PostMapping("/getCarrierNameBySSOId")
  160. public RESTfulResult getCarrierNameBySSOId(@RequestParam("carrierSSOId") String carrierSSOId){
  161. Map<String,Object> map=rmsCapacityService.getCarrierNameBySSOId(carrierSSOId);
  162. return success(map);
  163. }
  164. @ApiOperation("解除承运商和车辆的绑定关系")
  165. @PostMapping("/deleteCapacityCarrier")
  166. public RESTfulResult deleteCapacityCarrier(@RequestBody() Map<String,Object> map){
  167. if(map.containsKey("capacityId")&&map.get("capacityId")!=null&&map.containsKey("carrierSSOId")&&map.get("carrierSSOId")!=null){
  168. int i =rmsCapacityService.deleteCapacityCarrier(DataChange.dataToBigDecimal(map.get("capacityCarrierId")),map.get("carrierSSOId").toString());
  169. return success(i);
  170. }
  171. return failed();
  172. }
  173. }