# AsmServiceImpl.java

    package com.mycim.server.asm.service;

    import com.alipay.sofa.runtime.api.annotation.SofaService;
    import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding;
    import com.fa.sesa.exception.Assert;
    import com.fa.sesa.exception.Errors;
    import com.mycim.framework.utils.lang.StringUtils;
    import com.mycim.server.asm.manager.LotInventoryManager;
    import com.mycim.server.asm.manager.MaterialManager;
    import com.mycim.server.base.manager.NamedObjectManager;
    import com.mycim.valueobject.ObjectList;
    import com.mycim.valueobject.inv.MaterialDO;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

    import java.util.List;
    import java.util.Map;

    @Service
    @SofaService(interfaceType = AsmService.class, bindings = {@SofaServiceBinding(bindingType = "bolt")})
    public class AsmServiceImpl implements AsmService {

        @Autowired
        MaterialManager materialManager;

        @Autowired
        NamedObjectManager namedObjectManager;

        @Autowired
        LotInventoryManager lotInventoryManager;

        @Override
        public long insertMaterial(MaterialDO material) {
            return materialManager.insertMaterial(material);
        }

        @Override
        public void deleteMaterial(MaterialDO material) {
            materialManager.deleteMaterial(material);
        }

        @Override
        public void updateMaterial(MaterialDO material) {
            materialManager.updateMaterial(material);
        }

        @Override
        public MaterialDO getMaterial(Long facilityRrn, String materialId) {
            return getMaterial(
                    new MaterialDO(materialId, namedObjectManager.getNamedSpace(facilityRrn, ObjectList.ITEM_KEY),
                                   ObjectList.ITEM_KEY));
        }

        @Override
        public MaterialDO getMaterial(MaterialDO material) {
            return materialManager.getMaterial(material);
        }

        @Override
        public boolean isMaterialInUsed(Long materialRrn) {
            return materialManager.isMaterialInUsed(materialRrn);
        }

        @Override
        public boolean hasMaterialExtNumber(Long materialRrn, String itemExtendNumber) {
            if (StringUtils.isEmpty(itemExtendNumber)) {
                return false;
            } else {
                return materialManager.hasMaterialExtNumber(materialRrn, itemExtendNumber);
            }
        }

        @Override
        public MaterialDO getAndCheckMaterial(Long facilityRrn, String materialId) {
            Assert.isFalse(StringUtils.isEmpty(materialId),
                           Errors.create().content("Material Id can not be empty!").build());

            MaterialDO material = Assert.nonNull(getMaterial(facilityRrn, materialId),
                                                 Errors.create().content("Material Id not " + "exist!").build());
            return material;
        }

        @Override
        public String getMaterials4lot(Long warehouseRrn, Long productRrn) {
            return materialManager.getMaterials4lot(warehouseRrn, productRrn);
        }

        @Override
        public List<Map<String, Object>> getLotInventoryTransHistory(Long transRrn) {
            return lotInventoryManager.getLotInventoryTransHistory(transRrn);
        }

        @Override
        public int getMaterialTotalQuantity(long materialRrn) {
            return materialManager.getMaterialTotalQuantity(materialRrn);
        }

    }