| | |
| | | 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.param.CombParam; |
| | | import com.zy.asrs.service.MatCodeService; |
| | | import com.zy.asrs.service.MobileService; |
| | | import com.zy.asrs.service.WaitPakinService; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private MatCodeService matCodeService; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | if (Cools.isEmpty(param.getBarcode()) || param.getCombMats().isEmpty()) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | int count = waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("barcode", param.getBarcode()).eq("status", "N")); |
| | | if (count > 0) { |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException("条码数据已存在"); |
| | | } |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | MatCode matCode = matCodeService.selectById(combMat.getMatNo()); |
| | | if (Cools.isEmpty(matCode)) { |
| | | throw new CoolException("物料数据错误"); |
| | | Date now = new Date(); |
| | | // 无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | MatCode matCode = matCodeService.selectById(combMat.getMatNo()); |
| | | if (Cools.isEmpty(matCode)) { |
| | | throw new CoolException("物料数据错误"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAnfme(combMat.getCount()); // 数量 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | VersionUtils.setWaitPakIn(waitPakin, matCode); |
| | | |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin( |
| | | param.getBarcode(), // 托盘码 |
| | | matCode.getMatNo(), // 物料编码 |
| | | matCode.getMatName(), // 物料描述 |
| | | combMat.getCount(), // 数量 |
| | | matCode.getStr1(), // 单位 |
| | | "N", // 状态 |
| | | null, // 备注 |
| | | new Date(), // 修改时间 |
| | | userId, // 修改人员 |
| | | new Date(), // 添加时间 |
| | | userId // 创建者 |
| | | ); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存数据失败"); |
| | | // 关联组托 |
| | | } else { |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | for (CombParam.CombMat comb : param.getCombMats()) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), comb.getMatNo(), comb.getBatch()); |
| | | if (comb.getCount() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改单细数量 |
| | | if (!orderDetlService.increase(order.getId(), comb.getMatNo(), comb.getBatch(), comb.getCount())) { |
| | | throw new CoolException("修改单据明细数量失败"); |
| | | } |
| | | // 添加入库通知档 |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAnfme(comb.getCount()); // 数量 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | VersionUtils.setWaitPakIn(waitPakin, orderDetl); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("添加入库通知档失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |