From f111076ba746238c20472121993495ac5df4b54b Mon Sep 17 00:00:00 2001 From: zhangc <zc@123> Date: 星期三, 15 一月 2025 14:38:26 +0800 Subject: [PATCH] 添加订单视图及控制器,优化订单详情展示 --- src/main/java/com/zy/asrs/controller/OrderDetlController.java | 163 +++++++++++++++++++++++++++++------------------------- 1 files changed, 88 insertions(+), 75 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/OrderDetlController.java b/src/main/java/com/zy/asrs/controller/OrderDetlController.java index 47ca17f..2490c12 100644 --- a/src/main/java/com/zy/asrs/controller/OrderDetlController.java +++ b/src/main/java/com/zy/asrs/controller/OrderDetlController.java @@ -1,6 +1,5 @@ package com.zy.asrs.controller; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; @@ -49,15 +48,17 @@ @RequestMapping(value = "/orderDetl/list/auth") @ManagerAuth - public R list(@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){ + public R list(@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); - if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { + if (!Cools.isEmpty(orderByField)) { + wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); + } else { wrapper.orderBy("create_time", false); } wrapper.eq("status", 1); @@ -66,23 +67,25 @@ @RequestMapping(value = "/orderDetl/pakout/list/auth") @ManagerAuth - public R pakoutList(@RequestParam(defaultValue = "1")Integer curr, - @RequestParam(defaultValue = "10")Integer limit, - @RequestParam Map<String, Object> param){ + public R pakoutList(@RequestParam(defaultValue = "1") Integer curr, + @RequestParam(defaultValue = "10") Integer limit, + @RequestParam Map<String, Object> param) { return R.ok(orderDetlService.getPakoutPage(toPage(curr, limit, param, OrderDetl.class))); } @RequestMapping(value = "/orderDetl/pakout/list/authV2") @ManagerAuth - public R pakoutList2(@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){ + public R pakoutList2(@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); - if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { + if (!Cools.isEmpty(orderByField)) { + wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); + } else { wrapper.orderBy("create_time", false); } List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); @@ -91,28 +94,30 @@ docIds.add(pakin.getDocId()); } EntityWrapper<Order> orderEntityWrapper = new EntityWrapper<>(); - List<Order> orders = orderService.selectList(orderEntityWrapper.in("doc_type",docIds)); + List<Order> orders = orderService.selectList(orderEntityWrapper.in("doc_type", docIds)); List<String> orderNos = new ArrayList<>(); for (Order order : orders) { orderNos.add(order.getOrderNo()); } - wrapper.in("order_no",orderNos); + wrapper.in("order_no", orderNos); return R.ok(orderDetlService.selectPage(new Page<>(curr, limit), wrapper)); } @RequestMapping(value = "/orderDetl/pakout/list/authV193") @ManagerAuth - public R pakoutList193(@RequestParam(defaultValue = "1")Integer curr, - @RequestParam(defaultValue = "10")Integer limit, - @RequestParam(required = false)String orderByField, - @RequestParam(required = false)String orderByType, - @RequestParam(required = false)Long docType, - @RequestParam Map<String, Object> param){ + public R pakoutList193(@RequestParam(defaultValue = "1") Integer curr, + @RequestParam(defaultValue = "10") Integer limit, + @RequestParam(required = false) String orderByField, + @RequestParam(required = false) String orderByType, + @RequestParam(required = false) Long docType, + @RequestParam Map<String, Object> param) { EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); param.remove("docType"); excludeTrash(param); convertLike(param, wrapper); - if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { + if (!Cools.isEmpty(orderByField)) { + wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); + } else { wrapper.orderBy("create_time", false); } List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); @@ -133,13 +138,13 @@ if (docIds.size() > 0) { if (docType > 0) { - wrapper.in("source",docType); + wrapper.in("source", docType); } else { - wrapper.in("source",docIds); + wrapper.in("source", docIds); } } else { - wrapper.in("source",0); + wrapper.in("source", 0); } Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); for (OrderDetl record : page.getRecords()) { @@ -153,17 +158,19 @@ @RequestMapping(value = "/orderDetl/pakout/list/authV3") @Synchronized @ManagerAuth - public R pakoutList3(@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){ + public R pakoutList3(@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) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); excludeTrash(param); convertLike(param, wrapper); - if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { + if (!Cools.isEmpty(orderByField)) { + wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); + } else { wrapper.orderBy("create_time", false); } List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); @@ -173,7 +180,7 @@ docIds.add(pakin.getDocId()); } } - wrapper.in("source",docIds); + wrapper.in("source", docIds); Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); for (OrderDetl record : page.getRecords()) { Double sumAnfme = agvLocDetlService.getSumAnfme(record.getMatnr(), record.getThreeCode()); @@ -185,19 +192,21 @@ } /* - * 鍗婃垚鍝佸姞宸ュ崟鎹� - * */ + * 鍗婃垚鍝佸姞宸ュ崟鎹� + * */ @RequestMapping(value = "/orderDetl/pakout/list/authV5") @ManagerAuth - public R pakoutList5(@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){ + public R pakoutList5(@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); convertLike(param, wrapper); - if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { + if (!Cools.isEmpty(orderByField)) { + wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); + } else { wrapper.orderBy("create_time", false); } List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); @@ -207,8 +216,8 @@ docIds.add(pakin.getDocId()); } } - wrapper.eq("process_sts",1); - wrapper.in("source",docIds); + wrapper.eq("process_sts", 1); + wrapper.in("source", docIds); Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); for (OrderDetl record : page.getRecords()) { Double sumAnfme = agvLocDetlService.getSumAnfmeProcess(record.getMatnr(), record.getThreeCode()); @@ -220,15 +229,17 @@ @RequestMapping(value = "/orderDetl/pakout/list/authV4") @ManagerAuth - public R pakoutList4(@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){ + public R pakoutList4(@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); convertLike(param, wrapper); - if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { + if (!Cools.isEmpty(orderByField)) { + wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); + } else { wrapper.orderBy("create_time", false); } List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); @@ -239,7 +250,7 @@ } } - wrapper.in("source",docIds); + wrapper.in("source", docIds); Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); for (OrderDetl record : page.getRecords()) { Double sumAnfme = agvLocDetlService.getSumAnfmeProcessed(record.getMatnr(), record.getThreeCode()); @@ -251,15 +262,17 @@ @RequestMapping(value = "/orderDetl/pakout/list/authV6") @ManagerAuth - public R pakoutList6(@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){ + public R pakoutList6(@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); convertLike(param, wrapper); - if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { + if (!Cools.isEmpty(orderByField)) { + wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); + } else { wrapper.orderBy("create_time", false); } List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); @@ -270,7 +283,7 @@ } } - wrapper.in("source",docIds); + wrapper.in("source", docIds); Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); for (OrderDetl record : page.getRecords()) { Double sumAnfme = agvLocDetlService.getSumAnfme(record.getMatnr(), record.getThreeCode()); @@ -280,23 +293,23 @@ return R.ok(page); } - private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ - for (Map.Entry<String, Object> entry : map.entrySet()){ + private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) { + for (Map.Entry<String, Object> entry : map.entrySet()) { String val = String.valueOf(entry.getValue()); - if (val.contains(RANGE_TIME_LINK)){ + if (val.contains(RANGE_TIME_LINK)) { String[] dates = val.split(RANGE_TIME_LINK); wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); } else { - wrapper.eq(entry.getKey(), val); + wrapper.like(entry.getKey(), val); } } } - private <T> void convertLike(Map<String, Object> map, EntityWrapper<T> wrapper){ - for (Map.Entry<String, Object> entry : map.entrySet()){ + private <T> void convertLike(Map<String, Object> map, EntityWrapper<T> wrapper) { + for (Map.Entry<String, Object> entry : map.entrySet()) { String val = String.valueOf(entry.getValue()); - if (val.contains(RANGE_TIME_LINK)){ + if (val.contains(RANGE_TIME_LINK)) { String[] dates = val.split(RANGE_TIME_LINK); wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); @@ -313,10 +326,10 @@ return R.ok(); } - @RequestMapping(value = "/orderDetl/update/auth") - @ManagerAuth - public R update(OrderDetl orderDetl){ - if (Cools.isEmpty(orderDetl) || null==orderDetl.getId()){ + @RequestMapping(value = "/orderDetl/update/auth") + @ManagerAuth + public R update(OrderDetl orderDetl) { + if (Cools.isEmpty(orderDetl) || null == orderDetl.getId()) { return R.error("鍙傛暟缂哄け"); } orderDetlService.updateById(orderDetl); @@ -325,8 +338,8 @@ @RequestMapping(value = "/orderDetl/delete/auth") @ManagerAuth - public R delete(@RequestParam(value="ids[]") Long[] ids){ - for (Long id : ids){ + public R delete(@RequestParam(value = "ids[]") Long[] ids) { + for (Long id : ids) { orderDetlService.deleteById(id); } return R.ok(); @@ -334,7 +347,7 @@ @RequestMapping(value = "/orderDetl/export/auth") @ManagerAuth - public R export(@RequestBody JSONObject param){ + public R export(@RequestBody JSONObject param) { EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); Map<String, Object> map = excludeTrash(param.getJSONObject("orderDetl")); @@ -350,7 +363,7 @@ wrapper.like("id", condition); Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(0, 10), wrapper); List<Map<String, Object>> result = new ArrayList<>(); - for (OrderDetl orderDetl : page.getRecords()){ + for (OrderDetl orderDetl : page.getRecords()) { Map<String, Object> map = new HashMap<>(); map.put("id", orderDetl.getId()); map.put("value", orderDetl.getId()); @@ -363,7 +376,7 @@ @ManagerAuth public R query(@RequestBody JSONObject param) { Wrapper<OrderDetl> wrapper = new EntityWrapper<OrderDetl>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); - if (null != orderDetlService.selectOne(wrapper)){ + if (null != orderDetlService.selectOne(wrapper)) { return R.parse(BaseRes.REPEAT).add(getComment(OrderDetl.class, String.valueOf(param.get("key")))); } return R.ok(); -- Gitblit v1.9.1