新火炬后端单体项目初始化代码
zhangherong
5 天以前 383cee5937b1f10e800ca30743a78a96c34d5123
src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialServiceImpl.java
@@ -13,16 +13,17 @@
import org.jeecg.modules.lsw.mapper.LswMaterialInventoryMapper;
import org.jeecg.modules.lsw.mapper.LswMaterialMapper;
import org.jeecg.modules.lsw.service.ILswMaterialService;
import org.jeecg.modules.mes.entity.MesProductionOrder;
import org.jeecg.modules.pms.entity.PmsProcessBillMaterials;
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 javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @Description: 线边库物料信息
@@ -84,4 +85,41 @@
        return list.get(0);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdateMaterial(Map<String, MesProductionOrder> orderMap, List<OrderBomDTO> orderBomDTOList) {
        List<LswMaterial> addList = new ArrayList<>();
        for (Map.Entry<String, MesProductionOrder> entry : orderMap.entrySet()) {
            MesProductionOrder order = entry.getValue();
            LswMaterial material = queryByMaterialNumber(order.getMaterialNumber());
            if (material == null) {
                //新增物料
                material = new LswMaterial();
                material.setMaterialStatus(CommonConstant.STATUS_1);
                material.setMaterialNumber(order.getMaterialNumber());
                material.setMaterialName(order.getMaterialName());
                material.setMaterialUnit(order.getProductionUnit());
                material.setDelFlag(CommonConstant.DEL_FLAG_0);
                addList.add(material);
            }
        }
        for (OrderBomDTO bomDTO : orderBomDTOList) {
            LswMaterial material = queryByMaterialNumber(bomDTO.getMATNR());
            if (material == null) {
                //新增物料
                material = new LswMaterial();
                material.setMaterialStatus(CommonConstant.STATUS_1);
                material.setMaterialNumber(bomDTO.getMATNR());
                material.setMaterialName(bomDTO.getMAKTX());
                material.setMaterialUnit(bomDTO.getMEINS());
                material.setDelFlag(CommonConstant.DEL_FLAG_0);
                addList.add(material);
            }
        }
        if (CollectionUtil.isEmpty(addList)) {
            super.saveBatch(addList);
        }
        return true;
    }
}