|  |  |  | 
|---|
|  |  |  | package com.vincent.rsf.server.manager.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 
|---|
|  |  |  | import com.vincent.rsf.framework.common.R; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.vincent.rsf.framework.exception.CoolException; | 
|---|
|  |  |  | 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.controller.params.QlyInspectAndItem; | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.entity.AsnOrderItem; | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.entity.QlyInspect; | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.entity.*; | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.enums.QlyIsptResult; | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.enums.QlyIsptStatus; | 
|---|
|  |  |  | 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.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Service("qlyIsptItemService") | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private AsnOrderItemService asnOrderItemService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private QlyInspectResultService qlyInspectResultService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private QlyIsptItemService qlyIsptItemService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WarehouseAreasItemServiceImpl warehouseAreasItemService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanysServiceImpl companysService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @param | 
|---|
|  |  |  | * @param loginUserId | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @author Ryan | 
|---|
|  |  |  | * @description 批量修改 | 
|---|
|  |  |  | * @param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @time 2025/4/1 09:40 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public boolean batchUpdate(IsptItemsParams params) { | 
|---|
|  |  |  | public boolean batchUpdate(IsptItemsParams params, Long loginUserId) { | 
|---|
|  |  |  | if (Objects.isNull(params.getIsptItem()) || params.getIsptItem().isEmpty()) { | 
|---|
|  |  |  | throw new CoolException("ID不能为空!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<QlyIsptItem> isptItem =  params.getIsptItem(); | 
|---|
|  |  |  | List<QlyIsptItem> isptItem = params.getIsptItem(); | 
|---|
|  |  |  | List<Long> list = isptItem.stream().map(QlyIsptItem::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | if (Short.parseShort(params.getType()) == QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val || Short.parseShort(params.getType()) == QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val) { | 
|---|
|  |  |  | //1:合格, 2:不合格, 0: 其它(默认) | 
|---|
|  |  |  | isptItem.forEach(item -> { | 
|---|
|  |  |  | if (Short.parseShort(params.getType()) == QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val) { | 
|---|
|  |  |  | //TODO 先捡后收为送货数量,先收后捡为收货数量 | 
|---|
|  |  |  | item.setSafeQty(item.getDlyQty()); | 
|---|
|  |  |  | item.setDisQty(0.0); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | item.setSafeQty(0.0); | 
|---|
|  |  |  | item.setDisQty(item.getDlyQty()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!this.update(new LambdaUpdateWrapper<QlyIsptItem>() | 
|---|
|  |  |  | .set(QlyIsptItem::getSafeQty, item.getSafeQty()) | 
|---|
|  |  |  | .set(QlyIsptItem::getIsptResult, Short.parseShort(params.getType())) | 
|---|
|  |  |  | .set(QlyIsptItem::getDisQty, item.getDisQty()) | 
|---|
|  |  |  | .in(QlyIsptItem::getId, item.getId()))) { | 
|---|
|  |  |  | throw new CoolException("修改失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (!this.updateBatchById(isptItem)) { | 
|---|
|  |  |  | throw new CoolException("明细修改失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<QlyIsptItem> isptItems = this.list(new LambdaQueryWrapper<QlyIsptItem>().in(QlyIsptItem::getId, list)); | 
|---|
|  |  |  | if (isptItems.isEmpty()) { | 
|---|
|  |  |  | throw new CoolException("数据错误:明细不存在!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<Long, List<QlyIsptItem>> listMap = isptItems.stream().collect(Collectors.groupingBy(QlyIsptItem::getIspectId)); | 
|---|
|  |  |  | for (Long key : listMap.keySet()) { | 
|---|
|  |  |  | QlyInspect inspect = qlyInspectService.getById(key); | 
|---|
|  |  |  | List<QlyIsptItem> items = listMap.get(key); | 
|---|
|  |  |  | items.forEach(qlyIsptItem -> { | 
|---|
|  |  |  | AsnOrderItem orderItem = asnOrderItemService.getById(qlyIsptItem.getAsnItemId()); | 
|---|
|  |  |  | if (qlyIsptItem.getSafeQty().compareTo(orderItem.getAnfme()) >= 0.00) { | 
|---|
|  |  |  | orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val) | 
|---|
|  |  |  | .setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val); | 
|---|
|  |  |  | } else if (qlyIsptItem.getSafeQty().compareTo(0.00) > 0.00 && qlyIsptItem.getSafeQty().compareTo(orderItem.getAnfme()) < 0.00) { | 
|---|
|  |  |  | orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_SECTION.val); | 
|---|
|  |  |  | if (Double.compare(qlyIsptItem.getSafeQty() + qlyIsptItem.getDisQty(), orderItem.getAnfme()) >= 0.00 ) { | 
|---|
|  |  |  | orderItem.setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | orderItem.setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_ING.val); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val) | 
|---|
|  |  |  | .setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!asnOrderItemService.updateById(orderItem)) { | 
|---|
|  |  |  | throw new CoolException("收货单明细修改失败!!"); | 
|---|
|  |  |  | for (QlyIsptItem item : isptItem) { | 
|---|
|  |  |  | List<QlyInspectResult> results = qlyInspectResultService.list(new LambdaQueryWrapper<QlyInspectResult>() | 
|---|
|  |  |  | .eq(QlyInspectResult::getIsptId, item.getIspectId()) | 
|---|
|  |  |  | .eq(QlyInspectResult::getIsptItemId, item.getId())); | 
|---|
|  |  |  | if (!results.isEmpty()) { | 
|---|
|  |  |  | if (!qlyInspectResultService.remove(new LambdaUpdateWrapper<QlyInspectResult>() | 
|---|
|  |  |  | .eq(QlyInspectResult::getIsptItemId, item.getId()))) { | 
|---|
|  |  |  | throw new CoolException("历史质检结果移出失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | Double safeQty = items.stream().mapToDouble(QlyIsptItem::getSafeQty).sum(); | 
|---|
|  |  |  | Double disQty = items.stream().mapToDouble(QlyIsptItem::getDisQty).sum(); | 
|---|
|  |  |  | Double qlyQty = safeQty + disQty; | 
|---|
|  |  |  | //安全数量,质检数量 | 
|---|
|  |  |  | inspect.setSafeQty(safeQty) | 
|---|
|  |  |  | .setIsptQty(qlyQty); | 
|---|
|  |  |  | if (Double.compare(disQty, 0) > 0) { | 
|---|
|  |  |  | inspect.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_SECTION.val); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Double.compare(safeQty, inspect.getDlyQty()) == 0) { | 
|---|
|  |  |  | //                inspect.setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val); | 
|---|
|  |  |  | inspect.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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()) | 
|---|
|  |  |  | .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val); | 
|---|
|  |  |  | qlyInspectResultService.saveOrUpdate(result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!qlyInspectService.updateById(inspect)) { | 
|---|
|  |  |  | throw new CoolException("质检数量修改失败!!"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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()) | 
|---|
|  |  |  | .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val); | 
|---|
|  |  |  | qlyInspectResultService.saveOrUpdate(result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<QlyInspectResult> isptRelt = qlyInspectResultService.list(new LambdaQueryWrapper<QlyInspectResult>() | 
|---|
|  |  |  | .eq(QlyInspectResult::getIsptId, item.getIspectId()) | 
|---|
|  |  |  | .eq(QlyInspectResult::getIsptItemId, item.getId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Double isptQty = isptRelt.stream().mapToDouble(QlyInspectResult::getAnfme).sum(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!qlyIsptItemService.update(new LambdaUpdateWrapper<QlyIsptItem>() | 
|---|
|  |  |  | .set(QlyIsptItem::getUpdateBy, loginUserId) | 
|---|
|  |  |  | .set(QlyIsptItem::getAnfme, isptQty) | 
|---|
|  |  |  | .eq(QlyIsptItem::getId, item.getId()))) { | 
|---|
|  |  |  | throw new CoolException("单据明细数量修改失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //            WarehouseAreasItem orderItem = warehouseAreasItemService.getById(item.getRcptId()); | 
|---|
|  |  |  | //            if (Objects.isNull(orderItem)) { | 
|---|
|  |  |  | //                throw new CoolException("收货单据不存在!!"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //            Double disQty = Objects.isNull(item.getDisQty()) ? 0 : item.getDisQty(); | 
|---|
|  |  |  | //            Double safeQty = Objects.isNull(item.getSafeQty()) ? 0 : item.getSafeQty(); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            Double sum = disQty + safeQty; | 
|---|
|  |  |  | //            orderItem.setIsptQty(sum); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            if (sum.compareTo(0.0) > 0) { | 
|---|
|  |  |  | //                if (!warehouseAreasItemService.updateById(orderItem)) { | 
|---|
|  |  |  | //                    throw new CoolException("收货区库存信息更新失败!!"); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                //新建质检单,不会有质检结果 | 
|---|
|  |  |  | //                confirmReceipt(item, orderItem); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////                if (Objects.isNull(orderItem.getIsptResult())) { | 
|---|
|  |  |  | ////                    operateReceipt(item, orderItem); | 
|---|
|  |  |  | ////                } | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<Long> isptIds = isptItem.stream().map(QlyIsptItem::getIspectId).collect(Collectors.toSet()); | 
|---|
|  |  |  | 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>() | 
|---|
|  |  |  | .set(QlyInspect::getIsptQty, sum) | 
|---|
|  |  |  | .set(QlyInspect::getUpdateBy, loginUserId) | 
|---|
|  |  |  | .eq(QlyInspect::getId, isptItem.stream().findFirst().get().getIspectId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author Ryan | 
|---|
|  |  |  | * @date 2025/5/12 | 
|---|
|  |  |  | * @description: 质检后修改收货区存信息 | 
|---|
|  |  |  | * @version 1.0 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public void confirmReceipt(QlyIsptItem item, WarehouseAreasItem orderItem) { | 
|---|
|  |  |  | Double disQty = Objects.isNull(item.getDisQty()) ? 0 : item.getDisQty(); | 
|---|
|  |  |  | Double safeQty = Objects.isNull(item.getSafeQty()) ? 0 : item.getSafeQty(); | 
|---|
|  |  |  | Double sum = disQty + safeQty; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | AsnOrderItem asnOrderItem = asnOrderItemService.getById(item.getAsnItemId()); | 
|---|
|  |  |  | if (Objects.isNull(asnOrderItem)) { | 
|---|
|  |  |  | if (StringUtils.isNoneBlank(asnOrderItem.getSplrCode())) { | 
|---|
|  |  |  | Companys companys = companysService.getOne(new LambdaQueryWrapper<Companys>().eq(Companys::getCode, asnOrderItem.getSplrCode())); | 
|---|
|  |  |  | orderItem.setSplrId(companys.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (sum.compareTo(orderItem.getAnfme()) >= 0) { | 
|---|
|  |  |  | //完成质检,做更新操作 | 
|---|
|  |  |  | if (safeQty.compareTo(0.0) > 0) { | 
|---|
|  |  |  | orderItem.setIsptQty(safeQty).setAnfme(safeQty); | 
|---|
|  |  |  | orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val); | 
|---|
|  |  |  | if (!warehouseAreasItemService.updateById(orderItem)) { | 
|---|
|  |  |  | throw new CoolException("收货区库存明细更新失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WarehouseAreasItem areasItem = new WarehouseAreasItem(); | 
|---|
|  |  |  | BeanUtils.copyProperties(orderItem, areasItem); | 
|---|
|  |  |  | if (disQty.compareTo(0.0) > 0) { | 
|---|
|  |  |  | areasItem.setIsptQty(disQty) | 
|---|
|  |  |  | .setAnfme(disQty) | 
|---|
|  |  |  | .setId(null) | 
|---|
|  |  |  | .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val); | 
|---|
|  |  |  | if (!warehouseAreasItemService.saveOrUpdate(areasItem)) { | 
|---|
|  |  |  | throw new CoolException("收货区库存明细更新失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Double anfme = Math.round((orderItem.getAnfme() - sum) * 10000) / 10000.0; | 
|---|
|  |  |  | orderItem.setAnfme(anfme); | 
|---|
|  |  |  | if (!warehouseAreasItemService.updateById(orderItem)) { | 
|---|
|  |  |  | throw new CoolException("收货区库存明细更新失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WarehouseAreasItem areasItem = new WarehouseAreasItem(); | 
|---|
|  |  |  | BeanUtils.copyProperties(orderItem, areasItem); | 
|---|
|  |  |  | //未完成做添加操作 | 
|---|
|  |  |  | if (safeQty.compareTo(0.0) > 0) { | 
|---|
|  |  |  | areasItem.setIsptQty(safeQty) | 
|---|
|  |  |  | .setAnfme(safeQty) | 
|---|
|  |  |  | .setId(null) | 
|---|
|  |  |  | .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val); | 
|---|
|  |  |  | if (!warehouseAreasItemService.saveOrUpdate(areasItem)) { | 
|---|
|  |  |  | throw new CoolException("收货区库存明细更新失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WarehouseAreasItem items = new WarehouseAreasItem(); | 
|---|
|  |  |  | BeanUtils.copyProperties(orderItem, items); | 
|---|
|  |  |  | if (disQty.compareTo(0.0) > 0) { | 
|---|
|  |  |  | items.setIsptQty(disQty) | 
|---|
|  |  |  | .setAnfme(disQty) | 
|---|
|  |  |  | .setId(null) | 
|---|
|  |  |  | .setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val); | 
|---|
|  |  |  | if (!warehouseAreasItemService.saveOrUpdate(items)) { | 
|---|
|  |  |  | throw new CoolException("收货区库存明细更新失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<QlyIsptItem> selectIsptResult(LambdaQueryWrapper<QlyIsptItem> eq) { | 
|---|
|  |  |  | return this.baseMapper.selectIsptResult(eq); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author Ryan | 
|---|
|  |  |  | * @date 2025/5/12 | 
|---|
|  |  |  | * @description: 获取自定义Page | 
|---|
|  |  |  | * @version 1.0 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<QlyIsptItem> pageByWrapper(PageParam<QlyIsptItem, BaseParam> pageParam, QueryWrapper<QlyIsptItem> queryWrapper) { | 
|---|
|  |  |  | IPage<QlyIsptItem> page = this.page(pageParam, queryWrapper); | 
|---|
|  |  |  | if (!page.getRecords().isEmpty()) { | 
|---|
|  |  |  | 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, rcpt_id") | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .eq(QlyInspectResult::getIsptItemId, records.get(i).getId()).groupBy(QlyInspectResult::getIsptResult)); | 
|---|
|  |  |  | if (!results.isEmpty()) { | 
|---|
|  |  |  | for (QlyInspectResult result : results) { | 
|---|
|  |  |  | if (result.getIsptResult() == QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val) { | 
|---|
|  |  |  | records.get(i).setSafeQty(result.getAnfme()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | records.get(i).setDisQty(result.getAnfme()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | page.setRecords(records); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return page; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<QlyIsptItem> pageByIsptResult(PageParam<QlyIsptItem, BaseParam> pageParam, QueryWrapper<QlyIsptItem> queryWrapper) { | 
|---|
|  |  |  | if (Objects.isNull(pageParam)) { | 
|---|
|  |  |  | PageParam<QlyIsptItem, BaseParam> param = new PageParam<>(); | 
|---|
|  |  |  | return this.baseMapper.selectPage(param, queryWrapper); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return this.baseMapper.pageByWrapper(pageParam, queryWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|