| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.Synchronized; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StopWatch; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private AgvLocDetlService agvLocDetlService; |
| | | |
| | | @RequestMapping(value = "/orderDetl/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | |
| | | |
| | | @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); |
| | |
| | | |
| | | @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))); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | @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) { |
| | | EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | 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)); |
| | | List<Long> docIds = new ArrayList<>(); |
| | | for (DocType pakin : pakins) { |
| | | docIds.add(pakin.getDocId()); |
| | | } |
| | | EntityWrapper<Order> orderEntityWrapper = new EntityWrapper<>(); |
| | | 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); |
| | | 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) { |
| | | 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 { |
| | | wrapper.orderBy("create_time", false); |
| | | } |
| | | List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); |
| | | List<Long> docIds = new ArrayList<>(); |
| | | |
| | | List<Long> unDocIds = new ArrayList<>(); |
| | | unDocIds.add(18L); |
| | | unDocIds.add(31L); |
| | | unDocIds.add(33L); |
| | | unDocIds.add(34L); |
| | | unDocIds.add(35L); |
| | | unDocIds.add(37L); |
| | | for (DocType pakin : pakins) { |
| | | if (!unDocIds.contains(pakin.getDocId())) { |
| | | docIds.add(pakin.getDocId()); |
| | | } |
| | | } |
| | | |
| | | if (docIds.size() > 0) { |
| | | if (docType > 0) { |
| | | wrapper.in("source", docType); |
| | | } else { |
| | | wrapper.in("source", docIds); |
| | | } |
| | | |
| | | } else { |
| | | wrapper.in("source", 0); |
| | | } |
| | | Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); |
| | | for (OrderDetl record : page.getRecords()) { |
| | | Double sumAnfme = agvLocDetlService.getSumAnfme(record.getMatnr(), record.getThreeCode()); |
| | | record.setStock(sumAnfme == null ? 0 : sumAnfme); |
| | | } |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @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) { |
| | | //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 { |
| | | wrapper.orderBy("create_time", false); |
| | | } |
| | | // List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); |
| | | // List<Long> docIds = new ArrayList<>(); |
| | | // for (DocType pakin : pakins) { |
| | | // if (pakin.getDocId() != 17 && pakin.getDocId() != 33 && pakin.getDocId() != 34 && pakin.getDocId() != 35) { |
| | | // docIds.add(pakin.getDocId()); |
| | | // } |
| | | // } |
| | | Object o = param.get("orderType"); |
| | | if (o != null) { |
| | | wrapper.in("source", o); |
| | | } |
| | | Page<OrderDetl> page = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); |
| | | for (OrderDetl record : page.getRecords()) { |
| | | Double sumAnfme = agvLocDetlService.getSumAnfme(record.getMatnr(), record.getThreeCode()); |
| | | record.setStock(sumAnfme == null ? 0 : sumAnfme); |
| | | } |
| | | //stopWatch.stop(); |
| | | //System.out.println(stopWatch.getTotalTimeSeconds()); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderDetl/pakout/list/authV7") |
| | | @ManagerAuth |
| | | public R pakoutList7(@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 { |
| | | wrapper.orderBy("create_time", false); |
| | | } |
| | | List<DocType> pakins = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakout", 1)); |
| | | List<Long> docIds = new ArrayList<>(); |
| | | for (DocType pakin : pakins) { |
| | | if (pakin.getDocId() != 17 && pakin.getDocId() != 33 && pakin.getDocId() != 34 && pakin.getDocId() != 35) { |
| | | docIds.add(pakin.getDocId()); |
| | | } |
| | | } |
| | | 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()); |
| | | record.setStock(sumAnfme == null ? 0 : sumAnfme); |
| | | } |
| | | //stopWatch.stop(); |
| | | //System.out.println(stopWatch.getTotalTimeSeconds()); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | /* |
| | | * 半成品加工单据 |
| | | * */ |
| | | @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) { |
| | | EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convertLike(param, wrapper); |
| | | 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)); |
| | | List<Long> docIds = new ArrayList<>(); |
| | | for (DocType pakin : pakins) { |
| | | if (pakin.getDocId() == 35) { |
| | | docIds.add(pakin.getDocId()); |
| | | } |
| | | } |
| | | 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()); |
| | | record.setStock(sumAnfme == null ? 0 : sumAnfme); |
| | | } |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @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) { |
| | | EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convertLike(param, wrapper); |
| | | 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)); |
| | | List<Long> docIds = new ArrayList<>(); |
| | | for (DocType pakin : pakins) { |
| | | if (pakin.getDocId() == 34) { |
| | | docIds.add(pakin.getDocId()); |
| | | } |
| | | } |
| | | |
| | | 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()); |
| | | record.setStock(sumAnfme == null ? 0 : sumAnfme); |
| | | } |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | @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) { |
| | | EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convertLike(param, wrapper); |
| | | 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)); |
| | | List<Long> docIds = new ArrayList<>(); |
| | | for (DocType pakin : pakins) { |
| | | if (pakin.getDocId() == 37 || pakin.getDocId() == 43) { |
| | | docIds.add(pakin.getDocId()); |
| | | } |
| | | } |
| | | |
| | | 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()); |
| | | record.setStock(sumAnfme == null ? 0 : sumAnfme); |
| | | } |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | 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); |
| | | if (entry.getKey().equals("order_id")) { |
| | | wrapper.eq(entry.getKey(), val); |
| | | } else { |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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)) { |
| | | 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.like(entry.getKey(), val); |
| | | } |
| | | } |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderDetl/update/auth") |
| | | @ManagerAuth |
| | | public R update(OrderDetl orderDetl){ |
| | | if (Cools.isEmpty(orderDetl) || null==orderDetl.getId()){ |
| | | return R.error(); |
| | | @RequestMapping(value = "/orderDetl/update/auth") |
| | | @ManagerAuth |
| | | public R update(OrderDetl orderDetl) { |
| | | if (Cools.isEmpty(orderDetl) || null == orderDetl.getId()) { |
| | | return R.error("参数缺失"); |
| | | } |
| | | orderDetlService.updateById(orderDetl); |
| | | return R.ok(); |
| | |
| | | |
| | | @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(); |
| | |
| | | |
| | | @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")); |
| | |
| | | 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()); |
| | |
| | | @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(); |