CargoTallyAction.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. package com.fuzamei.web;
  2. import java.util.Map;
  3. import javax.servlet.http.HttpServletRequest;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.web.bind.annotation.RequestBody;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RequestMethod;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import com.fuzamei.constant.HintMSG;
  10. import com.fuzamei.constant.Role;
  11. import com.fuzamei.constant.Status;
  12. import com.fuzamei.entity.Orders;
  13. import com.fuzamei.entity.Params;
  14. import com.fuzamei.entity.TallyOrder;
  15. import com.fuzamei.service.CargoTallyService;
  16. import com.fuzamei.service.OrderService;
  17. import com.fuzamei.service.UserAuthoricationService;
  18. import com.fuzamei.util.JSONUtil;
  19. import com.fuzamei.util.PageDTO;
  20. import com.fuzamei.util.ReadConfUtil;
  21. import com.fuzamei.util.ValidationUtil;
  22. @RestController
  23. @RequestMapping(path="/cargoTally")
  24. public class CargoTallyAction {
  25. @Autowired
  26. private CargoTallyService cargoTallyService;
  27. @Autowired
  28. private UserAuthoricationService userAuthoricationService;
  29. @Autowired
  30. private HttpServletRequest req;
  31. @Autowired
  32. private OrderService orderService;
  33. /**
  34. *
  35. * @Title: queryOrdersByReceiver
  36. * @Description: TODO(收货员查询订单信息)
  37. {
  38. "tokenId":"xxx",
  39. "page":"1",
  40. "orderId":"",
  41. "carNo":"",
  42. "startTime":"",
  43. "endTime":""
  44. }
  45. * @params @return 设定文件
  46. * @return Map<String,Object> 返回类型
  47. * @author ylx
  48. * @date 2018年1月26日 下午2:12:02
  49. * @throws
  50. */
  51. @RequestMapping(value="/queryOrdersByReceiver",method=RequestMethod.POST)
  52. public Map<String, Object> queryOrdersByReceiver(@RequestBody Params params){
  53. try {
  54. String userId = req.getHeader("Authorization").split("&")[1];
  55. userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(userId), Role.STOCKER);
  56. int page = ValidationUtil.checkMinAndAssignInt(params.getPage(), 1);
  57. int rowNum = ValidationUtil.checkMinAndAssignInt(params.getRowNum(), 1);
  58. Long startTime=ValidationUtil.checkAndAssignDefaultLong(params.getStartTime(), 0L);
  59. Long endTime=ValidationUtil.checkAndAssignDefaultLong(params.getEndTime(), Long.MAX_VALUE);
  60. params.setStartTime(startTime);
  61. if(startTime<=endTime) params.setEndTime(endTime);
  62. else params.setEndTime(Long.MAX_VALUE);
  63. params.setStartPage((page - 1) * rowNum);
  64. params.setRowNum(rowNum);
  65. PageDTO pageDto = cargoTallyService.queryOrdersByReceiver(params);
  66. return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, pageDto);
  67. } catch (Exception e) {
  68. return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
  69. }
  70. }
  71. /**
  72. *
  73. * @Title: searchNewOrderByOrderId
  74. * @Description: TODO(售货员根据订单号点击下一步查询最新的点货订单)
  75. {
  76. "tokenId":"",
  77. "orderId":""
  78. }
  79. * @params @return 设定文件
  80. * @return Map<String,Object> 返回类型
  81. * @author ylx
  82. * @date 2018年1月26日 下午2:24:02
  83. * @throws
  84. */
  85. @RequestMapping(value="/searchNewOrderByOrderId",method=RequestMethod.POST)
  86. public Map<String, Object> searchNewOrderByOrderId(@RequestBody Params params){
  87. try {
  88. String userId = req.getHeader("Authorization").split("&")[1];
  89. userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(userId), Role.STOCKER);
  90. Orders order = orderService.queryFullOrderByOrderId(ValidationUtil.checkAndAssignInt(params.getOrderId()));
  91. if(order==null) throw new RuntimeException("订单不存在");
  92. if(!Status.DELIVERING.equals(order.getStatusId())) throw new RuntimeException("非法操作");
  93. params.setOrder(order);
  94. TallyOrder tallyOrder=cargoTallyService.searchNewOrderByOrderId(params);
  95. return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, tallyOrder);
  96. } catch (Exception e) {
  97. return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
  98. }
  99. }
  100. /**
  101. *
  102. * @Title: confirmOrReject
  103. * @Description: TODO(收货员点击确认点货或拒收操作)
  104. {
  105. "tokenId":"",
  106. "orderId":"",
  107. "confirmId":""
  108. }
  109. * @params @return 设定文件
  110. * @return Map<String,Object> 返回类型
  111. * @author ylx
  112. * @date 2018年1月26日 下午2:35:06
  113. * @throws
  114. */
  115. @RequestMapping(value="/confirmOrReject",method=RequestMethod.POST)
  116. public Map<String, Object> confirmOrReject(@RequestBody Params params){
  117. try {
  118. String userId = req.getHeader("Authorization").split("&")[1];
  119. userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(userId), Role.STOCKER);
  120. ValidationUtil.checkRangeAndAssignInt(params.getConfirmId(), 0, 1);//确认id只能是0和1
  121. Orders order = orderService.queryFullOrderByOrderId(ValidationUtil.checkAndAssignInt(params.getOrderId()));
  122. if(order==null) throw new RuntimeException("订单不存在");
  123. if(!Status.DELIVERING.equals(order.getStatusId())) throw new RuntimeException("非法操作");
  124. cargoTallyService.confirmOrReject(params);
  125. return JSONUtil.getJsonMap(200, true, HintMSG.OPERATION_SUCCESS, null);
  126. } catch (Exception e) {
  127. return JSONUtil.getJsonMap(500, false, HintMSG.OPERATION_FAIL+":"+e.getMessage(), null);
  128. }
  129. }
  130. /**
  131. *
  132. * @Title: orderTracking
  133. * @Description: TODO(收货员查询订单跟踪信息)
  134. {
  135. "tokenId":"",
  136. "orderId":""
  137. }
  138. * @params @return 设定文件
  139. * @return Map<String,Object> 返回类型
  140. * @author ylx
  141. * @date 2018年1月26日 下午2:48:12
  142. * @throws
  143. */
  144. @RequestMapping(value="/orderTracking",method=RequestMethod.POST)
  145. public Map<String, Object> orderTracking(@RequestBody Params params){
  146. try {
  147. String userId = req.getHeader("Authorization").split("&")[1];
  148. userAuthoricationService.queryUserAuthority(ValidationUtil.checkAndAssignInt(userId),Role.STOCKER);//检测当前操作用户权限
  149. Orders order = orderService.queryFullOrderByOrderId(ValidationUtil.checkAndAssignInt(params.getOrderId()));
  150. if(!params.getUserId().equals(order.getReceiverId())) throw new RuntimeException("无权查看");
  151. params.setOrder(order);
  152. Map<String, Object> map = cargoTallyService.orderTracking(params);
  153. return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, map);
  154. } catch (Exception e) {
  155. return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
  156. }
  157. }
  158. }