新火炬后端单体项目初始化代码
lixiangyu
3 天以前 666af2a41be37f09cd6d99c8e2e338c5225f511c
src/main/java/org/jeecg/modules/pms/service/impl/PmsProcessBillMaterialsServiceImpl.java
@@ -7,16 +7,21 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.mes.entity.MesProductionOrder;
import org.jeecg.modules.pms.entity.PmsProcessBillMaterials;
import org.jeecg.modules.pms.entity.PmsProcessBillMaterialsDetail;
import org.jeecg.modules.pms.mapper.PmsProcessBillMaterialsMapper;
import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsDetailService;
import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsService;
import org.jeecg.modules.pms.vo.ProcessBillMaterialsDetailVo;
import org.jeecg.modules.sap.dto.OrderBomDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -98,4 +103,29 @@
        }
        return this.getBaseMapper().queryPageList(page, queryWrapper);
    }
    @Override
    public List<ProcessBillMaterialsDetailVo> queryMaterialsDetailByOrderIdAndMaterialNumber(String orderId, String materialNumber) {
        //根据生产订单id和物料编码查询订单BOM
        PmsProcessBillMaterials processBillMaterials = list(new LambdaQueryWrapper<PmsProcessBillMaterials>()
                        .eq(PmsProcessBillMaterials::getOrderId, orderId)
                        .eq(PmsProcessBillMaterials::getMaterialNumber, materialNumber))
                .stream().findFirst().orElse(null);
        if (processBillMaterials == null) {
            throw new JeecgBootException("未找到与该物料关联的订单BOM!");
        }
        //查询订单BOM明细
        List<PmsProcessBillMaterialsDetail> processBillMaterialsDetails = processBillMaterialsDetailService.queryByMaterialId(processBillMaterials.getId());
        List<ProcessBillMaterialsDetailVo> billMaterialsDetailList = CollectionUtil.newArrayList();
        for (PmsProcessBillMaterialsDetail processBillMaterialsDetail : processBillMaterialsDetails) {
            ProcessBillMaterialsDetailVo processBillMaterialsDetailVo = new ProcessBillMaterialsDetailVo()
                    .setMaterialNumber(processBillMaterialsDetail.getMaterialNumber())
                    .setMaterialName(processBillMaterialsDetail.getMaterialName())
                    .setProductionUnit(processBillMaterialsDetail.getProductionUnit())
                    .setPerQuantity(processBillMaterialsDetail.getUsageQuantity()
                            .divide(processBillMaterials.getProductionQuantity(), 2, RoundingMode.HALF_UP));
            billMaterialsDetailList.add(processBillMaterialsDetailVo);
        }
        return billMaterialsDetailList;
    }
}