| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.InOutCountDto; |
| | | import com.zy.asrs.entity.result.OpenOrderCompeteResult; |
| | | import com.zy.asrs.entity.result.StockVo; |
| | | import com.zy.asrs.mapper.TagMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.utils.NodeUtils; |
| | | import com.zy.common.utils.Synchro; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private TagService tagService; |
| | | @Autowired |
| | | private TagMapper tagMapper; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private NodeService nodeService; |
| | | @Autowired |
| | | private ManLocDetlService manLocDetlService; |
| | | @Autowired |
| | | private ManPakOutService manPakOutService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } else { |
| | | list.add(dto); |
| | | } |
| | | dto.setWeight(detail.getWeight()); |
| | | } |
| | | for (DetlDto detlDto : list) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | |
| | | //批号为空会出现问题,设置一个默认值 |
| | | if (detlDto.getBatch() == null) { |
| | | orderDetl.setBatch(""); |
| | | }else { |
| | | } else { |
| | | orderDetl.setBatch(detlDto.getBatch()); |
| | | |
| | | } |
| | |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | orderDetl.setWeight(detlDto.getWeight()); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成单据明细失败,请联系管理员"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | // @Transactional |
| | | // public List<OpenOrderCompeteResult> pakinOrderComplete(OpenOrderCompleteParam param) { |
| | | // List<OpenOrderCompeteResult> results = new ArrayList<>(); |
| | | // if (!Cools.isEmpty(param) && !Cools.isEmpty(param.getOrderNo())) { |
| | | // // 指定订单 |
| | | // Order order = orderService.selectByNo(param.getOrderNo()); |
| | | // if (null != order) { |
| | | // OpenOrderCompeteResult result = new OpenOrderCompeteResult(); |
| | | // results.add(result); |
| | | // result.setOrderNo(order.getOrderNo()); |
| | | // result.setOrderTime(order.getOrderTime()); |
| | | // result.setOrderType(order.getDocType$()); |
| | | // List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // for (OrderDetl orderDetl : orderDetls) { |
| | | // result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getQty())); |
| | | // } |
| | | // if (order.getSettle() == 4L) { |
| | | // // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | // if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // } |
| | | // } |
| | | // } |
| | | // } else { |
| | | // // 所有订单 |
| | | // List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L)); |
| | | // for (Order order : orders) { |
| | | // OpenOrderCompeteResult result = new OpenOrderCompeteResult(); |
| | | // results.add(result); |
| | | // result.setOrderNo(order.getOrderNo()); |
| | | // result.setOrderTime(order.getOrderTime()); |
| | | // result.setOrderType(order.getDocType$()); |
| | | // List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // for (OrderDetl orderDetl : orderDetls) { |
| | | // result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getQty())); |
| | | // } |
| | | // // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | // if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // } |
| | | // } |
| | | // } |
| | | // return results; |
| | | // } |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } else { |
| | | list.add(dto); |
| | | } |
| | | dto.setWeight(detail.getWeight()); |
| | | } |
| | | for (DetlDto detlDto : list) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | orderDetl.setWeight(detlDto.getWeight()); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成单据明细失败,请联系管理员"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | // public List<OpenOrderCompeteResult> pakoutOrderComplete(OpenOrderCompleteParam param) { |
| | | // List<OpenOrderCompeteResult> results = new ArrayList<>(); |
| | | // if (!Cools.isEmpty(param) && !Cools.isEmpty(param.getOrderNo())) { |
| | | // // 指定订单 |
| | | // Order order = orderService.selectByNo(param.getOrderNo()); |
| | | // if (null != order) { |
| | | // OpenOrderCompeteResult result = new OpenOrderCompeteResult(); |
| | | // results.add(result); |
| | | // result.setOrderNo(order.getOrderNo()); |
| | | // result.setOrderTime(order.getOrderTime()); |
| | | // result.setOrderType(order.getDocType$()); |
| | | // List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // for (OrderDetl orderDetl : orderDetls) { |
| | | // result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getQty())); |
| | | // } |
| | | // if (order.getSettle() == 4L) { |
| | | // // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | // if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // } |
| | | // } |
| | | // } |
| | | // } else { |
| | | // // 所有订单 |
| | | // List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L)); |
| | | // for (Order order : orders) { |
| | | // OpenOrderCompeteResult result = new OpenOrderCompeteResult(); |
| | | // results.add(result); |
| | | // result.setOrderNo(order.getOrderNo()); |
| | | // result.setOrderTime(order.getOrderTime()); |
| | | // result.setOrderType(order.getDocType$()); |
| | | // List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // for (OrderDetl orderDetl : orderDetls) { |
| | | // result.getOrderDetails().add(new DetlDto(orderDetl.getOrderNo(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getQty())); |
| | | // } |
| | | // // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | // if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // } |
| | | // } |
| | | // } |
| | | // return results; |
| | | // } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<StockVo> queryStock() { |
| | | return locDetlService.queryStockTotal(); |
| | | public List<StockVo> queryStock(StockVo stockVo) { |
| | | return locDetlService.queryStockTotal(stockVo); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | @Transactional |
| | | public void syncMat(MatSyncParam param) { |
| | | if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <=0 ) { |
| | | if (Cools.isEmpty(param.getMatDetails()) || param.getMatDetails().size() <= 0) { |
| | | throw new CoolException("商品数据为空"); |
| | | } |
| | | |
| | | for(MatSyncParam.MatParam matParam : param.getMatDetails()){ |
| | | if(Cools.isEmpty(matParam.getMatnr())){ |
| | | for (MatSyncParam.MatParam matParam : param.getMatDetails()) { |
| | | if (Cools.isEmpty(matParam.getMatnr())) { |
| | | throw new CoolException("商品编码不能为空"); |
| | | } |
| | | |
| | |
| | | mat.setStatus(1); |
| | | mat.setCreateTime(now); |
| | | mat.setUpdateTime(now); |
| | | if (Cools.isEmpty(matParam.getLength()) || matParam.getLength() == 0) { |
| | | mat.setLength(null); |
| | | } |
| | | if (!matService.insert(mat)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } else { |
| | |
| | | } |
| | | } else { |
| | | mat.sync(param); |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr",matParam.getMatnr()))) { |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr", matParam.getMatnr()))) { |
| | | throw new CoolException("更新已存在商品信息失败,请联系管理员"); |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public R getInOutDetl() { |
| | | List<InOutCountDto> top100 = wrkMastService.selectTop100(); |
| | | return R.ok().add(top100); |
| | | } |
| | | |
| | | } |