| | |
| | | package com.zy.asrs.wms.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.*; |
| | | import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType; |
| | | import com.zy.asrs.wms.asrs.mapper.WaitPakinMapper; |
| | | import com.zy.asrs.wms.asrs.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service("waitPakinService") |
| | | public class WaitPakinServiceImpl extends ServiceImpl<WaitPakinMapper, WaitPakin> implements WaitPakinService { |
| | | |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private WaitPakinRuleService waitPakinRuleService; |
| | | |
| | | @Override |
| | | public List<WaitPakin> getByOrderDetlId(Long orderDetlId) { |
| | | return this.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getDetlId, orderDetlId)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean comb(WaitPakin waitPakin) { |
| | | //组托规则校验 |
| | | waitPakinRuleService.rule(waitPakin); |
| | | |
| | | if (waitPakin.getAnfme() <= 0) { |
| | | throw new CoolException("组托数量错误"); |
| | | } |
| | | |
| | | List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode())); |
| | | if (!locList.isEmpty()) { |
| | | throw new CoolException("托盘已在库"); |
| | | } |
| | | |
| | | List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, waitPakin.getBarcode())); |
| | | if (!taskList.isEmpty()) { |
| | | throw new CoolException("托盘正在入库中"); |
| | | } |
| | | |
| | | OrderDetl orderDetl = orderDetlService.getById(waitPakin.getDetlId()); |
| | | if (orderDetl == null) { |
| | | throw new CoolException("订单明细不存在"); |
| | | } |
| | | |
| | | //可用数量 |
| | | Double count = orderDetl.getAnfme() - orderDetl.getQty() - orderDetl.getWorkQty() - orderDetl.getWaitQty(); |
| | | if (waitPakin.getAnfme() > count) { |
| | | throw new CoolException("组托数量超过剩余可用数量"); |
| | | } |
| | | |
| | | //查询是否存在相同明细和托盘码的组托通知档 |
| | | WaitPakin waitPakin1 = this.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, waitPakin.getBarcode()).eq(WaitPakin::getDetlId, waitPakin.getDetlId())); |
| | | if (waitPakin1 == null) { |
| | | //不存在组托通知档,创建 |
| | | waitPakin.setMatnr(orderDetl.getMat$().getMatnr()); |
| | | waitPakin.setBatch(orderDetl.getBatch()); |
| | | if (!this.save(waitPakin)) { |
| | | throw new CoolException("添加失败"); |
| | | } |
| | | }else { |
| | | //存在组托通知档,更新 |
| | | waitPakin1.setAnfme(waitPakin1.getAnfme() + waitPakin.getAnfme()); |
| | | waitPakin1.setUpdateTime(new Date()); |
| | | if (!this.updateById(waitPakin1)) { |
| | | throw new CoolException("添加失败"); |
| | | } |
| | | } |
| | | |
| | | //获取订单 |
| | | Order order = orderService.getById(orderDetl.getOrderId()); |
| | | if(order == null){ |
| | | throw new CoolException("订单不存在"); |
| | | } |
| | | |
| | | //更新订单状态 |
| | | if (order.getOrderSettle().equals(OrderSettleType.INIT.val())) { |
| | | order.setOrderSettle(OrderSettleType.WAIT.val()); |
| | | order.setUpdateTime(new Date()); |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("订单数据更新失败"); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | package com.zy.asrs.wms.asrs.service.impl;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.zy.asrs.framework.exception.CoolException;
|
| | | import com.zy.asrs.wms.asrs.entity.*;
|
| | | import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType;
|
| | | import com.zy.asrs.wms.asrs.mapper.WaitPakinMapper;
|
| | | import com.zy.asrs.wms.asrs.service.*;
|
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | @Service("waitPakinService")
|
| | | public class WaitPakinServiceImpl extends ServiceImpl<WaitPakinMapper, WaitPakin> implements WaitPakinService {
|
| | |
|
| | | @Autowired
|
| | | private OrderService orderService;
|
| | | @Autowired
|
| | | private OrderDetlService orderDetlService;
|
| | | @Autowired
|
| | | private LocService locService;
|
| | | @Autowired
|
| | | private TaskService taskService;
|
| | | @Autowired
|
| | | private WaitPakinRuleService waitPakinRuleService;
|
| | |
|
| | | @Override
|
| | | public List<WaitPakin> getByOrderDetlId(Long orderDetlId) {
|
| | | return this.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getDetlId, orderDetlId));
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public boolean comb(WaitPakin waitPakin) {
|
| | | //组托规则校验
|
| | | waitPakinRuleService.rule(waitPakin);
|
| | |
|
| | | if (waitPakin.getAnfme() <= 0) {
|
| | | throw new CoolException("组托数量错误");
|
| | | }
|
| | |
|
| | | List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode()));
|
| | | if (!locList.isEmpty()) {
|
| | | throw new CoolException("托盘已在库");
|
| | | }
|
| | |
|
| | | List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, waitPakin.getBarcode()));
|
| | | if (!taskList.isEmpty()) {
|
| | | throw new CoolException("托盘正在入库中");
|
| | | }
|
| | |
|
| | | OrderDetl orderDetl = orderDetlService.getById(waitPakin.getDetlId());
|
| | | if (orderDetl == null) {
|
| | | throw new CoolException("订单明细不存在");
|
| | | }
|
| | |
|
| | | //可用数量
|
| | | Double count = orderDetl.getAnfme() - orderDetl.getQty() - orderDetl.getWorkQty() - orderDetl.getWaitQty();
|
| | | if (waitPakin.getAnfme() > count) {
|
| | | throw new CoolException("组托数量超过剩余可用数量");
|
| | | }
|
| | |
|
| | | //查询是否存在相同明细和托盘码的组托通知档
|
| | | WaitPakin waitPakin1 = this.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, waitPakin.getBarcode()).eq(WaitPakin::getDetlId, waitPakin.getDetlId()));
|
| | | if (waitPakin1 == null) {
|
| | | //不存在组托通知档,创建
|
| | | waitPakin.setMatnr(orderDetl.getMat$().getMatnr());
|
| | | waitPakin.setBatch(orderDetl.getBatch());
|
| | | if (!this.save(waitPakin)) {
|
| | | throw new CoolException("添加失败");
|
| | | }
|
| | | }else {
|
| | | //存在组托通知档,更新
|
| | | waitPakin1.setAnfme(waitPakin1.getAnfme() + waitPakin.getAnfme());
|
| | | waitPakin1.setUpdateTime(new Date());
|
| | | if (!this.updateById(waitPakin1)) {
|
| | | throw new CoolException("添加失败");
|
| | | }
|
| | | }
|
| | |
|
| | | //获取订单
|
| | | Order order = orderService.getById(orderDetl.getOrderId());
|
| | | if(order == null){
|
| | | throw new CoolException("订单不存在");
|
| | | }
|
| | |
|
| | | //更新订单状态
|
| | | if (order.getOrderSettle().equals(OrderSettleType.INIT.val())) {
|
| | | order.setOrderSettle(OrderSettleType.WAIT.val());
|
| | | order.setUpdateTime(new Date());
|
| | | if (!orderService.updateById(order)) {
|
| | | throw new CoolException("订单数据更新失败");
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | | }
|