| | |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.manager.controller.params.PakinItem; |
| | | import com.vincent.rsf.server.manager.controller.params.WaitPakinParam; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrder; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderItem; |
| | | import com.vincent.rsf.server.manager.entity.WaitPakinItem; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.PakinIOStatus; |
| | | import com.vincent.rsf.server.manager.mapper.WaitPakinMapper; |
| | | import com.vincent.rsf.server.manager.entity.WaitPakin; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderItemService; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderService; |
| | | import com.vincent.rsf.server.manager.service.WaitPakinItemService; |
| | | import com.vincent.rsf.server.manager.service.WaitPakinService; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.parameters.P; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | @Service("waitPakinService") |
| | | public class WaitPakinServiceImpl extends ServiceImpl<WaitPakinMapper, WaitPakin> implements WaitPakinService { |
| | | |
| | | @Autowired |
| | | private AsnOrderItemService asnOrderItemService; |
| | | |
| | | @Autowired |
| | | private AsnOrderService asnOrderService; |
| | | @Autowired |
| | | private AsnOrderItemService asnOrderItemService; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private WaitPakinItemService waitPakinItemService; |
| | | @Autowired |
| | | private LocService locService; |
| | | |
| | | /** |
| | | * 单据组拖 |
| | | * @param waitPakin |
| | | * @author Ryan |
| | | * @description 组拖 |
| | | * @param |
| | | * @return |
| | | * @time 2025/3/29 14:42 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | throw new CoolException("参数错误:托盘码为空!!"); |
| | | } |
| | | |
| | | double sum = waitPakin.getItems().stream().mapToDouble(PakinItem::getQty).sum(); |
| | | List<WaitPakin> list = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, waitPakin.getBarcode())); |
| | | if (!list.isEmpty()) { |
| | | List<String> stringList = list.stream().map(WaitPakin::getCode).collect(Collectors.toList()); |
| | | String join = StringUtils.join(stringList, ","); |
| | | throw new CoolException("拖盘码:" + waitPakin.getBarcode() + "已被组拖单:" + join + "使用!!"); |
| | | } |
| | | |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode())); |
| | | if (!locs.isEmpty()) { |
| | | List<String> locCodes = locs.stream().map(Loc::getCode).collect(Collectors.toList()); |
| | | String join = StringUtils.join(locCodes, ","); |
| | | throw new CoolException("拖盘码:" + waitPakin.getBarcode() + "已被库位:" + join + "使用!!"); |
| | | } |
| | | |
| | | double sum = waitPakin.getItems().stream().mapToDouble(PakinItem::getReceiptQty).sum(); |
| | | |
| | | WaitPakin pakin = new WaitPakin(); |
| | | |
| | |
| | | } |
| | | pakin.setCode(ruleCode) |
| | | //状态修改为入库中 |
| | | .setIoStatus(Short.parseShort("1")) |
| | | .setIoStatus(Short.parseShort(PakinIOStatus.QLY_ISPT_STAS_DONE.val)) |
| | | .setAnfme(sum) |
| | | .setBarcode(waitPakin.getBarcode()); |
| | | if (!this.save(pakin)) { |
| | |
| | | .setUnit(item.getStockUnit()) |
| | | .setFieldsIndex(item.getFieldsIndex()) |
| | | .setUnit(item.getStockUnit()) |
| | | .setMatnrId(StringUtils.isNotBlank(item.getMatnrId()) ? Long.parseLong(item.getMatnrId()) : null) |
| | | .setMatnrId(item.getMatnrId()) |
| | | .setMaktx(item.getMaktx()) |
| | | .setMatnrCode(item.getMatnrCode()); |
| | | for (PakinItem waitPakinItem : waitPakin.getItems()) { |
| | | if (waitPakinItem.getTrackCode().equals(item.getTrackCode())) { |
| | | Double v = item.getWorkQty() + waitPakinItem.getQty(); |
| | | Double v = item.getWorkQty() + waitPakinItem.getReceiptQty(); |
| | | pakinItem.setWorkQty(v) |
| | | .setAnfme(waitPakinItem.getQty()) |
| | | .setAnfme(waitPakinItem.getReceiptQty()) |
| | | .setTrackCode(waitPakinItem.getTrackCode()); |
| | | /**更新单据执行中库存*/ |
| | | if (v.compareTo(item.getAnfme()) > 0) {throw new CoolException("执行中数量大于收货数量!!");} |
| | |
| | | } |
| | | return pakin; |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 组拖解绑 |
| | | * @param |
| | | * @return |
| | | * @time 2025/3/29 14:42 |
| | | */ |
| | | @Override |
| | | public WaitPakin unBind(WaitPakinParam param) { |
| | | String barcode = param.getBarcode(); |
| | | if (StringUtils.isNotBlank(barcode)) { |
| | | WaitPakin waitPakins = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, barcode), false); |
| | | if (Objects.isNull(waitPakins)) { |
| | | throw new CoolException("组拖不存在!!"); |
| | | } |
| | | List<PakinItem> paramItems = param.getItems(); |
| | | if (Objects.isNull(paramItems) || paramItems.isEmpty()) { |
| | | throw new CoolException("解绑物料不能为空!!"); |
| | | } |
| | | List<Long> list = paramItems.stream().map(PakinItem::getMatnrId).collect(Collectors.toList()); |
| | | List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>() |
| | | .eq(WaitPakinItem::getPakinId, waitPakins.getId()) |
| | | .in(WaitPakinItem::getMatnrId, list)); |
| | | if (pakinItems.isEmpty()) { |
| | | throw new CoolException("数据错误:组拖明细不存在!!"); |
| | | } |
| | | List<Long> ids = pakinItems.stream().map(WaitPakinItem::getId).collect(Collectors.toList()); |
| | | if (!waitPakinItemService.removeByIds(ids)) { |
| | | throw new CoolException("组拖明细解绑失败!!"); |
| | | } |
| | | return waitPakins; |
| | | } |
| | | return new WaitPakin(); |
| | | } |
| | | } |