package org.jeecg.modules.pms.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang.StringUtils; import org.jeecg.modules.pms.entity.PmsProcessBillMaterialsDetail; import org.jeecg.modules.pms.mapper.PmsProcessBillMaterialsDetailMapper; import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsDetailService; import org.jeecg.modules.sap.dto.OrderBomDTO; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @Description: 物料清单 * @Author: jeecg-boot * @Date: 2025-07-01 * @Version: V1.0 */ @Service public class PmsProcessBillMaterialsDetailServiceImpl extends ServiceImpl implements IPmsProcessBillMaterialsDetailService { @Override public PmsProcessBillMaterialsDetail queryByMaterialId(String materialId) { return baseMapper.queryByMaterialId(materialId); } @Override public IPage> getpmsProcessBillMaterialsDetailListData(Integer pageNo, Integer pageSize, HttpServletRequest req) { IPage pageData = new Page(pageNo, pageSize); Map paramMap = new HashMap(); Map parameterMap = req.getParameterMap(); if (null != parameterMap) { if (parameterMap.containsKey("materialNumber") && StringUtils.isNotBlank(parameterMap.get("materialNumber")[0])) { paramMap.put("materialNumber", parameterMap.get("materialNumber")[0]); } if (parameterMap.containsKey("materialName") && StringUtils.isNotBlank(parameterMap.get("materialName")[0])) { paramMap.put("materialName", parameterMap.get("materialName")[0].trim()); } if (parameterMap.containsKey("batchNumber") && StringUtils.isNotBlank(parameterMap.get("batchNumber")[0])) { paramMap.put("batchNumber", parameterMap.get("batchNumber")[0].trim()); } } return super.getBaseMapper().getpmsProcessBillMaterialsDetailListData(pageData, paramMap); } @Override @Transactional(rollbackFor = Exception.class) public void removeByMaterialsId(String materialsId) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(PmsProcessBillMaterialsDetail::getMaterialId, materialsId); this.getBaseMapper().delete(queryWrapper); } @Override @Transactional(rollbackFor = Exception.class) public void saveBatchDetail(String materialsId, List collect) { if (CollectionUtil.isEmpty(collect)) { return; } List list = collect.stream().map(orderBomDTO -> new PmsProcessBillMaterialsDetail(materialsId, orderBomDTO)).collect(Collectors.toList()); super.saveBatch(list); } }