|  |  |  | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.DateUtils; | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.zy.asrs.entity.Order; | 
|---|
|  |  |  | import com.zy.asrs.entity.OrderDetl; | 
|---|
|  |  |  | import com.zy.asrs.service.OrderDetlService; | 
|---|
|  |  |  | import com.zy.asrs.service.OrderService; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderDetlService orderDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/orderDetl/{id}/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | 
|---|
|  |  |  | wrapper.eq("status", 1); | 
|---|
|  |  |  | return R.ok(orderDetlService.selectPage(new Page<>(curr, limit), wrapper)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @RequestMapping(value = "/orderDetl/out/list") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R out(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByField, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByType, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param){ | 
|---|
|  |  |  | EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | excludeTrash(param); | 
|---|
|  |  |  | convert(param, wrapper); | 
|---|
|  |  |  | List<Order> orders = orderService.selectInOrOutOrders(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { | 
|---|
|  |  |  | wrapper.orderBy("create_time", false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(orders)) { | 
|---|
|  |  |  | return R.ok(new  Page<OrderDetl>()); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | for (Order order : orders) { | 
|---|
|  |  |  | wrapper.or(); | 
|---|
|  |  |  | wrapper.eq("order_no",order.getOrderNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | wrapper.eq("status", 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(orderDetlService.selectPage(new Page<>(curr, limit), wrapper)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/orderDetl/in/list") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R in(@RequestParam(defaultValue = "1")Integer curr, | 
|---|
|  |  |  | @RequestParam(defaultValue = "10")Integer limit, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByField, | 
|---|
|  |  |  | @RequestParam(required = false)String orderByType, | 
|---|
|  |  |  | @RequestParam Map<String, Object> param){ | 
|---|
|  |  |  | EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | excludeTrash(param); | 
|---|
|  |  |  | convert(param, wrapper); | 
|---|
|  |  |  | List<Order> orders = orderService.selectInOrOutOrders(true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { | 
|---|
|  |  |  | wrapper.orderBy("create_time", false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(orders)) { | 
|---|
|  |  |  | return R.ok(new  Page<OrderDetl>()); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | for (Order order : orders) { | 
|---|
|  |  |  | wrapper.or(); | 
|---|
|  |  |  | wrapper.eq("order_no",order.getOrderNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | wrapper.eq("status", 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Page<OrderDetl> orderDetlPage = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); | 
|---|
|  |  |  | return R.ok(orderDetlPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/orderDetl/pakout/list/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | 
|---|
|  |  |  | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); | 
|---|
|  |  |  | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | wrapper.like(entry.getKey(), val); | 
|---|
|  |  |  | wrapper.eq(entry.getKey(), val); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/orderDetlQuery/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R query(String condition) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(condition.split(",").length < 2){ | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String maktxCondition = condition.split(",")[0]; | 
|---|
|  |  |  | Long orderId = Long.parseLong(condition.split(",")[1]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.like("id", condition); | 
|---|
|  |  |  | wrapper.eq("order_id",orderId); | 
|---|
|  |  |  | wrapper.like("maktx", maktxCondition); | 
|---|
|  |  |  | Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(0, 10), wrapper); | 
|---|
|  |  |  | List<Map<String, Object>> result = new ArrayList<>(); | 
|---|
|  |  |  | for (OrderDetl orderDetl : page.getRecords()){ | 
|---|
|  |  |  | Map<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("id", orderDetl.getId()); | 
|---|
|  |  |  | map.put("value", orderDetl.getId()); | 
|---|
|  |  |  | map.put("value", orderDetl.getMaktx()); | 
|---|
|  |  |  | map.put("weight",orderDetl.getAnfme() - orderDetl.getWorkQty()); | 
|---|
|  |  |  | map.put("type","orderDetl"); | 
|---|
|  |  |  | result.add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(result); | 
|---|