| | |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.MatCode; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.WaitPakin; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.model.DetlDto; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | * 移动端服务核心类 |
| | | * Created by vincent on 2020/6/28 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class MobileServiceImpl implements MobileService { |
| | | |
| | | @Autowired |
| | | private MatCodeService matCodeService; |
| | | private MatService matService; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException("条码数据已存在"); |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | } |
| | | Date now = new Date(); |
| | | |
| | |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | DetlDto detlDto = new DetlDto(elem.getMatNo(), elem.getBatch(), elem.getCount()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert one != null; |
| | |
| | | }); |
| | | |
| | | for (DetlDto detlDto : detlDtos) { |
| | | MatCode matCode = matCodeService.selectById(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(matCode)) { |
| | | throw new CoolException("物料数据错误"); |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setBatch(detlDto.getBatch()); |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(detlDto.getAnfme()); // 数量 |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | VersionUtils.setWaitPakIn(waitPakin, matCode); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存数据失败"); |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | // 关联组托 |
| | |
| | | param.getCombMats().forEach(elem -> { |
| | | |
| | | // 订单明细数量校验 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatNo(), elem.getBatch()); |
| | | if (elem.getCount() > orderDetl.getEnableQty()) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); |
| | | if (elem.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改订单明细数量 |
| | | if (!orderDetlService.increase(order.getId(), elem.getMatNo(), elem.getBatch(), elem.getCount())) { |
| | | if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { |
| | | throw new CoolException("修改单据明细数量失败"); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(elem.getMatNo(), elem.getBatch(), elem.getCount()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert one != null; |
| | |
| | | } |
| | | }); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | MatCode matCode = matCodeService.selectById(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(matCode)) { |
| | | throw new CoolException("物料数据错误"); |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setOrderNo(order.getOrderNo()); // 单据编号 |
| | | waitPakin.setBatch(detlDto.getBatch()); // 批号 |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | VersionUtils.setWaitPakIn(waitPakin, matCode); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存数据失败"); |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | |