|
|
|
|
@ -1,17 +1,22 @@ |
|
|
|
|
package org.springblade.wms.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.desk.dashboard.feign.IPartClient; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.DsPartEntity; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.DsPartRelationEntity; |
|
|
|
|
import org.springblade.desk.order.pojo.entity.YieldOrder; |
|
|
|
|
import org.springblade.desk.produce.pojo.entity.WorkOrder; |
|
|
|
|
import org.springblade.wms.excel.StOtherReceiptRecordExcel; |
|
|
|
|
import org.springblade.wms.mapper.StOtherReceiptRecordMapper; |
|
|
|
|
import org.springblade.wms.mapper.StStockInoutRecordMapper; |
|
|
|
|
import org.springblade.wms.pojo.dto.InitStockDTO; |
|
|
|
|
import org.springblade.wms.pojo.entity.*; |
|
|
|
|
import org.springblade.wms.pojo.vo.StOtherReceiptRecordVO; |
|
|
|
|
@ -22,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
@ -49,6 +53,15 @@ public class StOtherReceiptRecordServiceImpl extends BaseServiceImpl<StOtherRece |
|
|
|
|
IStRealtimeStockService stRealtimeStockService; |
|
|
|
|
@Resource |
|
|
|
|
IStStockInoutRecordService stStockInoutRecordService; |
|
|
|
|
@Resource |
|
|
|
|
IPartClient partClient; |
|
|
|
|
|
|
|
|
|
// private static IPartClient getPartClient() {
|
|
|
|
|
// if (partClient == null) {
|
|
|
|
|
// partClient = SpringUtil.getBean(IPartClient.class);
|
|
|
|
|
// }
|
|
|
|
|
// return partClient;
|
|
|
|
|
// }
|
|
|
|
|
@Override |
|
|
|
|
public IPage<StOtherReceiptRecordVO> selectStOtherReceiptRecordPage(IPage<StOtherReceiptRecordVO> page, StOtherReceiptRecordVO stOtherReceiptRecord) { |
|
|
|
|
return page.setRecords(baseMapper.selectStOtherReceiptRecordPage(page, stOtherReceiptRecord)); |
|
|
|
|
@ -275,12 +288,55 @@ public class StOtherReceiptRecordServiceImpl extends BaseServiceImpl<StOtherRece |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<StOtherReceiptRecordVO> getGlassCakeByWoCode(String woCode) { |
|
|
|
|
public StStockInoutRecord getGlassCakeByWoCode(String woCode, String goodsCode) { |
|
|
|
|
List<StOtherReceiptRecord> list = baseMapper.selectByWoCode(woCode); |
|
|
|
|
if (CollUtil.isEmpty(list)) { |
|
|
|
|
|
|
|
|
|
WorkOrder workOrder = baseMapper.getByWoCode(woCode); |
|
|
|
|
YieldOrder yieldOrder = baseMapper.getByYoId(workOrder.getYoId()); |
|
|
|
|
|
|
|
|
|
DsPartEntity partOne = partClient.getPart(workOrder.getPartCode(),yieldOrder.getPartVersion()); |
|
|
|
|
List<DsPartRelationEntity> partRelationEntityList = partClient.getSubPart(partOne.getId()); |
|
|
|
|
|
|
|
|
|
List<DsPartEntity> glassCakePartList = new ArrayList<>(); |
|
|
|
|
if (!CollectionUtils.isEmpty(partRelationEntityList)) { |
|
|
|
|
// 步骤1:提取所有非空的childPartId并去重(避免null和重复ID,减少查询压力)
|
|
|
|
|
List<Long> childPartIdList = partRelationEntityList.stream() |
|
|
|
|
.map(DsPartRelationEntity::getChildPartId) // 提取子件ID
|
|
|
|
|
.filter(Objects::nonNull) // 过滤null的ID
|
|
|
|
|
.distinct() // 去重,避免重复查询
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
// 步骤2:批量查询DS_PART表(一次SQL,性能最优)
|
|
|
|
|
if (!CollectionUtils.isEmpty(childPartIdList)) { |
|
|
|
|
// 调用dsPartService的批量查询方法(根据ID列表查DS_PART)
|
|
|
|
|
List<DsPartEntity> allChildPartList = partClient.batchParts(childPartIdList); |
|
|
|
|
|
|
|
|
|
// 步骤3:筛选出IS_CLASS_CAKE为"玻璃饼"的记录(核心过滤)
|
|
|
|
|
if (!CollectionUtils.isEmpty(allChildPartList)) { |
|
|
|
|
glassCakePartList = allChildPartList.stream() |
|
|
|
|
.filter(part -> Boolean.TRUE.equals(part.getIsGlassCake())) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
StStockInoutRecord inoutRecord = new StStockInoutRecord(); |
|
|
|
|
if (!CollectionUtils.isEmpty(glassCakePartList)) { |
|
|
|
|
DsPartEntity targetPart = glassCakePartList.stream() |
|
|
|
|
.filter(part -> goodsCode.equals(part.getPartCode())) |
|
|
|
|
.findFirst() |
|
|
|
|
.orElse(null); |
|
|
|
|
|
|
|
|
|
inoutRecord.setPrintMark(Boolean.valueOf(targetPart.getIsPrint())); |
|
|
|
|
inoutRecord.setPowderWeight(String.valueOf(targetPart.getPowderWeight())); |
|
|
|
|
inoutRecord.setMaterialNo(targetPart.getMaterial()); |
|
|
|
|
inoutRecord.setThickness(String.valueOf(targetPart.getFormingThickness())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(inoutRecord)) { |
|
|
|
|
throw new ServiceException("未找到对应的玻璃饼信息"); |
|
|
|
|
} |
|
|
|
|
return StOtherReceiptRecordWrapper.build().listVO(list); |
|
|
|
|
return inoutRecord; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|