OmstruckOrderSeparateController.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. package com.steerinfo.dil.controller;
  2. import com.steerinfo.dil.feign.ESFeign;
  3. import com.steerinfo.dil.feign.TmsTruckFeign;
  4. import com.steerinfo.dil.mapper.OmstruckOrderSeparateMapper;
  5. import com.steerinfo.dil.model.OmstruckOrder;
  6. import com.steerinfo.dil.service.impl.OmstruckOrderSeparateServiceImpl;
  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.*;
  20. /**
  21. * @ author :TXF
  22. * @ time :2021/12/3 15:07
  23. */
  24. @RestController
  25. @RequestMapping("/${api.version}/omstruckorderseparates")
  26. public class OmstruckOrderSeparateController extends BaseRESTfulController {
  27. @Autowired
  28. OmstruckOrderSeparateMapper omstruckOrderSeparateMapper;
  29. @Autowired
  30. OmstruckOrderSeparateServiceImpl omstruckOrderSeparateService;
  31. @Autowired
  32. private TmsTruckFeign tmsTruckFeign;
  33. @Autowired
  34. ColumnDataUtil columnDataUtil;
  35. @Autowired
  36. ESFeign esFeign;
  37. @PostMapping("/getOrderMes")
  38. public RESTfulResult getMes(@RequestBody(required = false) Map<String, Object> map){
  39. Integer integer = tmsTruckFeign.addTotalResult(map);
  40. return success(integer);
  41. }
  42. /**
  43. * 添加退货实绩关闭当前订单
  44. * @param map
  45. * @return
  46. */
  47. @PostMapping("/returnOrderCloseOrder")
  48. public RESTfulResult returnOrderCloseOrder(@RequestBody(required = false) Map<String, Object> map){
  49. Integer result = omstruckOrderSeparateService.returnOrderCloseOrder(map);
  50. return success(result);
  51. }
  52. /**
  53. * 根据运单id查询实绩位置
  54. * @param map
  55. * @return
  56. */
  57. @PostMapping("/getOrderResult")
  58. public List<Map<String,Object>> getOrderResult(@RequestBody Map<String,Object> map){
  59. BigDecimal orderId = DataChange.dataToBigDecimal(map.get("orderId"));
  60. String orderNumber = (String) map.get("orderNumber");
  61. List<Map<String, Object>> result = null;
  62. if (orderId.intValue() != 0) {
  63. result = omstruckOrderSeparateService.getOrderResult(orderId);
  64. }
  65. else {
  66. result = omstruckOrderSeparateService.getOrderNumberResult(orderNumber);
  67. }
  68. return result;
  69. }
  70. /**
  71. * 发送消息到 websocket 推送消息
  72. * @param map
  73. */
  74. @PostMapping("/pushMesToWebsocket")
  75. public RESTfulResult pushMesToWebsocket(@RequestBody Map<String,Object> map) {
  76. String s = omstruckOrderSeparateService.pushMesToWebsocket(map);
  77. return success(s);
  78. }
  79. @ApiOperation(value = "查看承运商所属的订单")
  80. @ApiImplicitParams({
  81. @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  82. @ApiImplicitParam(name = "apiId(86)", value = "动态表头", required = false, dataType = "Integer"),
  83. @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  84. @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"),
  85. @ApiImplicitParam(name = "status", value = "状态码", required = false, dataType = "Integer"),
  86. })
  87. @PostMapping("/getInputOrderList")
  88. public RESTfulResult getInputOrderList(@RequestBody(required = false) Map<String, Object> mapValue,
  89. Integer apiId,
  90. Integer pageNum,
  91. Integer pageSize,
  92. Integer carrierId,
  93. Integer orderType,
  94. Integer orderStatus,
  95. String con) {
  96. int count = 0;
  97. if (orderStatus != null) {
  98. mapValue.put("orderStatus", orderStatus);
  99. count++;
  100. }
  101. if (orderType != null) {
  102. mapValue.put("orderType", orderType);
  103. count++;
  104. }
  105. if (carrierId != null) {
  106. mapValue.put("carrierId", carrierId);
  107. count++;
  108. }
  109. //框计算
  110. if (con != null) {
  111. if (!"undefined".equals(con)) {
  112. String index = "get_input_order_list";//设置要查询的索引名称
  113. return success(esFeign.getConResult(mapValue, index, apiId, pageNum, pageSize, con));//获取查询结果
  114. }
  115. }
  116. //不分页筛选数据
  117. List<Map<String, Object>> allTruckOrder = null;
  118. //如果有条件查询则跳过初始化,和创建索引
  119. if (mapValue.size() == count) {
  120. //将查询结果存入索引中
  121. allTruckOrder = omstruckOrderSeparateService.getInputOrderList(mapValue);
  122. Map<String, Object> map = new HashMap<>();
  123. //添加索引
  124. map.put("index", "get_input_order_list");
  125. //添加id
  126. map.put("indexId", "truckOrderId");
  127. allTruckOrder.add(map);
  128. //新建索引
  129. esFeign.insertIndex(allTruckOrder);
  130. //删除
  131. allTruckOrder.remove(allTruckOrder.size() - 1);
  132. allTruckOrder.remove(allTruckOrder.size() - 1);
  133. }
  134. if (allTruckOrder == null)
  135. allTruckOrder = omstruckOrderSeparateService.getInputOrderList(mapValue);
  136. PageHelper.startPage(pageNum, pageSize);
  137. //分页数据
  138. List<Map<String, Object>> truckOrder = omstruckOrderSeparateService.getInputOrderList(mapValue);
  139. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, allTruckOrder, truckOrder);
  140. return success(pageList);
  141. }
  142. @ApiOperation(value = "查询所有的零星物资订单")
  143. @ApiImplicitParams({
  144. @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  145. @ApiImplicitParam(name = "apiId(86)", value = "动态表头", required = false, dataType = "Integer"),
  146. @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  147. @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"),
  148. @ApiImplicitParam(name = "orderStatus", value = "状态码", required = false, dataType = "Integer"),
  149. })
  150. @PostMapping("/getOthersOrderMesToSend")
  151. public RESTfulResult getOthersOrderMesToSend(@RequestBody(required = false) Map<String, Object> mapValue,
  152. Integer apiId,
  153. Integer pageNum,
  154. Integer pageSize,
  155. Integer type,
  156. Integer orderStatus,
  157. String carrierId,
  158. String con,
  159. String userId,
  160. String usersId,
  161. Integer type1
  162. ) {
  163. int count = 0;
  164. if (orderStatus != null) {
  165. mapValue.put("status", orderStatus);
  166. }
  167. if (type != null) {
  168. mapValue.put("type", type);
  169. }
  170. if (type1!=null){
  171. mapValue.put("type1",type1);
  172. }
  173. if (carrierId != null && !"undefined".equals(carrierId)) {
  174. mapValue.put("carrierId", carrierId);
  175. }
  176. if (userId!=null){
  177. mapValue.put("userId",userId);
  178. }
  179. if (usersId!=null){
  180. mapValue.put("usersId",usersId);
  181. }
  182. //框计算
  183. List<Map<String, Object>> allMes = omstruckOrderSeparateService.getOthersOrderMesToSend(mapValue);
  184. PageHelper.startPage(pageNum, pageSize);
  185. //分页数据
  186. List<Map<String, Object>> mes = omstruckOrderSeparateService.getOthersOrderMesToSend(mapValue);
  187. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, allMes, mes);
  188. return success(pageList);
  189. }
  190. /**
  191. * 根据运输订单id修改运力id
  192. * @param omstruckOrder
  193. */
  194. @PostMapping("/updateOmstruckOrder")
  195. public RESTfulResult updateOmstruckOrder(@RequestBody(required = false) OmstruckOrder omstruckOrder){
  196. int i = omstruckOrderSeparateService.updateOmstruckOrder(omstruckOrder);
  197. return success(i);
  198. }
  199. @PostMapping("getUnloadOrderMaterial")
  200. public RESTfulResult getUnloadOrderMaterial(@RequestBody(required = false) Map<String,Object>map) {
  201. return success(omstruckOrderSeparateService.getUnloadOrderMaterial(map));
  202. }
  203. /**
  204. * 承运商销售分派运输订单给司机
  205. * @param mapValue
  206. * @return
  207. */
  208. @PostMapping("/addSaleTruckOrder")
  209. public RESTfulResult addSaleTruckOrder(@RequestBody Map<String, Object> mapValue){
  210. Integer result = omstruckOrderSeparateService.addSaleTruckOrder(mapValue);
  211. return success(result);
  212. }
  213. @ApiOperation(value = "该车牌号下的所有订单号 以及 订单ID")
  214. @PostMapping("/getCapacityAllOrder")
  215. public RESTfulResult getCapacityAllOrder(String capacityNumber){
  216. List<Map<String, Object>> capacityAllOrderList = omstruckOrderSeparateService.getCapacityAllOrder(capacityNumber);
  217. return success(capacityAllOrderList);
  218. }
  219. @ApiOperation(value = "根据运单id关闭运输订单")
  220. @PostMapping("/closeOrder")
  221. public RESTfulResult closeOrder(@RequestParam Integer orderId){
  222. int result = omstruckOrderSeparateService.closeOrder(orderId);
  223. return success(result);
  224. }
  225. @ApiOperation(value = "根据运单id查询出所有销售数据")
  226. @PostMapping("/getSaleAllMessages")
  227. public Map<String,Object> getSaleAllMessages(@RequestParam Integer orderId){
  228. Map<String, Object> mapValue = omstruckOrderSeparateService.getSaleAllMessages(new BigDecimal(orderId));
  229. return mapValue;
  230. }
  231. @ApiOperation(value = "新增一个新的采购运输订单(一车多趟)")
  232. @PostMapping("/addNewTransportOrder")
  233. public RESTfulResult addNewTransportOrder(@RequestParam Integer orderId){
  234. int i = omstruckOrderSeparateService.addNewTransportOrder(new BigDecimal(orderId));
  235. return success(i);
  236. }
  237. @ApiOperation(value = "一键删除多个订单")
  238. @PostMapping("/deleteOrders")
  239. public RESTfulResult deleteOrders(@RequestBody (required = false) Map<String, Object> map){
  240. int i = omstruckOrderSeparateService.deleteOrders(map);
  241. return success(i);
  242. }
  243. @ApiOperation(value = "装卸工查询自己所有装了货的订单信息")
  244. @PostMapping("/getAllLoadUnloadResult")
  245. public RESTfulResult getAllLoadUnloadResult(@RequestBody (required = false) Map<String, Object> map){
  246. return success(omstruckOrderSeparateService.getAllLoadUnloadResult(map));
  247. }
  248. @ApiOperation(value = "批量关闭运输订单")
  249. @PostMapping("/batchCloseOrder")
  250. public RESTfulResult batchCloseOrder(@RequestBody List<Map<String,Object>> mapList){
  251. return success(omstruckOrderSeparateService.batchCloseOrder(mapList));
  252. }
  253. @ApiOperation(value = "根据订单ID查询订单子表物资信息")
  254. @PostMapping("/getOrderMaterial/{orderId}")
  255. public RESTfulResult getOrderMaterial(@PathVariable("orderId")Integer orderId) {
  256. return success(omstruckOrderSeparateService.getOrderMaterial(orderId));
  257. }
  258. @ApiOperation(value = "查看所有实绩点")
  259. @PostMapping("/getAllResultLineMes")
  260. public RESTfulResult getAllResultLineMes(Integer orderId, String orderNumber){
  261. Map<String, Object> map = new HashMap<>();
  262. if(orderId != null){
  263. map.put("orderId", orderId);
  264. }
  265. if(orderNumber != null){
  266. map.put("orderNumber", orderNumber);
  267. }
  268. List<Map<String, Object>> allOrderResult = null;
  269. try {
  270. allOrderResult = omstruckOrderSeparateService.getAllOrderResult(map);
  271. } catch (Exception e) {
  272. System.out.println(e.getMessage());
  273. return failed("查询失败");
  274. }
  275. return success(allOrderResult);
  276. }
  277. @ApiOperation(value = "正常关闭运输订单")
  278. @PostMapping("/closeInwardOrder")
  279. public RESTfulResult closeInwardOrder(Integer orderId){
  280. return success(omstruckOrderSeparateService.closeInwardOrder(orderId));
  281. }
  282. }