| | |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.manager.controller.params.IsptItemsParams; |
| | | import com.vincent.rsf.server.manager.entity.QlyInspect; |
| | | import com.vincent.rsf.server.manager.entity.QlyInspectResult; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.QlyIsptResult; |
| | | import com.vincent.rsf.server.manager.mapper.QlyIsptItemMapper; |
| | | import com.vincent.rsf.server.manager.entity.QlyIsptItem; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderItemService; |
| | | import com.vincent.rsf.server.manager.service.QlyInspectResultService; |
| | | import com.vincent.rsf.server.manager.service.QlyInspectService; |
| | | import com.vincent.rsf.server.manager.service.QlyIsptItemService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private QlyInspectResultService qlyInspectResultService; |
| | | @Autowired |
| | | private QlyIsptItemService qlyIsptItemService; |
| | | @Autowired |
| | | private WarehouseAreasItemServiceImpl warehouseAreasItemService; |
| | | |
| | | /** |
| | | * @param |
| | |
| | | |
| | | QlyInspectResult result = new QlyInspectResult(); |
| | | result.setIsptId(item.getIspectId()) |
| | | .setRcptId(item.getRcptId()) |
| | | .setIsptItemId(item.getId()); |
| | | if (!Objects.isNull(item.getDisQty()) && item.getDisQty().compareTo(0.00) > 0) { |
| | | result.setAnfme(item.getDisQty()) |
| | |
| | | |
| | | result = new QlyInspectResult(); |
| | | result.setIsptId(item.getIspectId()) |
| | | .setRcptId(item.getRcptId()) |
| | | .setIsptItemId(item.getId()); |
| | | if (!Objects.isNull(item.getSafeQty()) && item.getSafeQty().compareTo(0.00) > 0) { |
| | | result.setAnfme(item.getSafeQty()) |
| | |
| | | .eq(QlyIsptItem::getId, item.getId()))) { |
| | | throw new CoolException("单据明细数量修改失败!!"); |
| | | } |
| | | |
| | | WarehouseAreasItem orderItem = warehouseAreasItemService.getById(item.getRcptId()); |
| | | if (Objects.isNull(orderItem)) { |
| | | throw new CoolException("收货单据不存在!!"); |
| | | } |
| | | Double sum = item.getDisQty() + item.getSafeQty(); |
| | | orderItem.setIsptQty(sum); |
| | | |
| | | if (!warehouseAreasItemService.updateById(orderItem)) { |
| | | throw new CoolException("收货区库存信息更新失败!!"); |
| | | } |
| | | |
| | | if (Objects.isNull(orderItem.getIsptResult())) { |
| | | operateReceipt(item, orderItem); |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | |
| | | Set<Long> isptIds = isptItem.stream().map(QlyIsptItem::getIspectId).collect(Collectors.toSet()); |
| | | List<QlyInspectResult> items = qlyInspectResultService.list(new LambdaQueryWrapper<QlyInspectResult>().in(QlyInspectResult::getIsptId, isptIds)); |
| | | List<QlyInspectResult> items = qlyInspectResultService.list(new LambdaQueryWrapper<QlyInspectResult>() |
| | | .in(QlyInspectResult::getIsptId, isptIds)); |
| | | Double sum = items.stream().mapToDouble(QlyInspectResult::getAnfme).sum(); |
| | | if (sum.compareTo(0.00) > 0) { |
| | | qlyInspectService.update(new LambdaUpdateWrapper<QlyInspect>() |
| | |
| | | .eq(QlyInspect::getId, isptItem.stream().findFirst().get().getIspectId())); |
| | | } |
| | | |
| | | // qlyIsptItemService.pageByIsptResult(null, new QueryWrapper<QlyIsptItem>()) |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/5/12 |
| | | * @description: 质检后修改收货区存信息 |
| | | * @version 1.0 |
| | | */ |
| | | private void operateReceipt(QlyIsptItem item, WarehouseAreasItem orderItem) { |
| | | Double sum = item.getDisQty() + item.getSafeQty(); |
| | | if (sum.compareTo(orderItem.getAnfme()) >= 0) { |
| | | //完成质检,做更新操作 |
| | | if (item.getSafeQty().compareTo(0.0) > 0) { |
| | | orderItem.setIsptQty(item.getSafeQty()); |
| | | orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val); |
| | | if (!warehouseAreasItemService.updateById(orderItem)) { |
| | | throw new CoolException("收货区库存明细更新失败!!"); |
| | | } |
| | | } |
| | | |
| | | if (item.getDisQty().compareTo(0.0) > 0) { |
| | | orderItem.setIsptQty(item.getDisQty()) |
| | | .setId(null) |
| | | .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val); |
| | | if (!warehouseAreasItemService.saveOrUpdate(orderItem)) { |
| | | throw new CoolException("收货区库存明细更新失败!!"); |
| | | } |
| | | } |
| | | } else { |
| | | //未完成做添加操作 |
| | | if (item.getSafeQty().compareTo(0.0) > 0) { |
| | | orderItem.setIsptQty(item.getSafeQty()) |
| | | .setId(null) |
| | | .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val); |
| | | if (!warehouseAreasItemService.saveOrUpdate(orderItem)) { |
| | | throw new CoolException("收货区库存明细更新失败!!"); |
| | | } |
| | | } |
| | | |
| | | if (item.getDisQty().compareTo(0.0) > 0) { |
| | | orderItem.setIsptQty(item.getDisQty()) |
| | | .setId(null) |
| | | .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val); |
| | | if (!warehouseAreasItemService.saveOrUpdate(orderItem)) { |
| | | throw new CoolException("收货区库存明细更新失败!!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | List<QlyIsptItem> records = page.getRecords(); |
| | | for (int i = 0; i < records.size(); i++) { |
| | | List<QlyInspectResult> results = qlyInspectResultService.list(new QueryWrapper<QlyInspectResult>() |
| | | .select("id, ispt_result, SUM(anfme) anfme, ispt_item_id, ispt_id") |
| | | .select("id, ispt_result, SUM(anfme) anfme, ispt_item_id, ispt_id, rcpt_id") |
| | | .lambda() |
| | | .eq(QlyInspectResult::getIsptItemId, records.get(i).getId()).groupBy(QlyInspectResult::getIsptResult)); |
| | | if (!results.isEmpty()) { |
| | |
| | | |
| | | @Override |
| | | public IPage<QlyIsptItem> pageByIsptResult(PageParam<QlyIsptItem, BaseParam> pageParam, QueryWrapper<QlyIsptItem> queryWrapper) { |
| | | return this.baseMapper.pageByWrapper(pageParam, queryWrapper); |
| | | if (Objects.isNull(pageParam)) { |
| | | PageParam<QlyIsptItem, BaseParam> param = new PageParam<>(); |
| | | return this.baseMapper.selectPage(param, queryWrapper); |
| | | } else { |
| | | return this.baseMapper.pageByWrapper(pageParam, queryWrapper); |
| | | } |
| | | } |
| | | } |