package com.gkhy.safePlatform.equipment.service.baseService.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.utils.StringUtils; import com.gkhy.safePlatform.equipment.entity.*; import com.gkhy.safePlatform.equipment.excepiton.EquipmentException; import com.gkhy.safePlatform.equipment.model.dto.req.SafeMaterialQuery; import com.gkhy.safePlatform.equipment.repository.SafeMaterialInfoRepository; import com.gkhy.safePlatform.equipment.service.baseService.SafeMaterialInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; @Service("SafeMaterialInfoService") public class SafeMaterialInfoServiceImpl extends ServiceImpl implements SafeMaterialInfoService { @Autowired private SafeMaterialInfoRepository repository; /** * 获取所有数据,包括被删除的 * @return */ @Override public int getTotalCount() { return repository.getTotalCount(); } @Override public SafeMaterialDO queryById(Long id) { if(null == id){ throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL); } return repository.queryById(id); } @Override public int deleteBatch(List ids) { if(null == ids || ids.size() == 0){ throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL); } repository.deleteBatch(ids); return 0; } @Override public List list(){ List safeMaterialInfos = repository.selectList(new LambdaQueryWrapper() .eq(SafeMaterialInfo::getDelFlag, 0)); return safeMaterialInfos; } @Override public List listByPage(Page page, SafeMaterialQuery query) { List materialInfoList = repository.listByConditions(page, query); return materialInfoList; } @Override public int getCountBySmallClassifyId(Long smallClassifyId) { if(null == smallClassifyId){ throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL); } return repository.getCountBySmallClassifyId(smallClassifyId); } @Override public boolean checkMaterial(Long smallClassifyId, Long depId, Long id) { if(null == depId || null == smallClassifyId){ throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL); } boolean flag = false; int i = repository.checkMatrial(smallClassifyId,depId,id); if (i>0){ flag = true; } return flag; } @Override public void updateCountById(SafeMaterialBO safeMaterialBO) { if(null == safeMaterialBO){ throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL); } repository.updateCountById(safeMaterialBO); } @Override public List listByDepId(Long depId) { if(null == depId){ throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL); } List safeMaterialInfoList = repository.selectList(new LambdaQueryWrapper() .eq(SafeMaterialInfo::getDelFlag, 0) .eq(SafeMaterialInfo::getDepId, depId)); return safeMaterialInfoList; } @Override public void updateStockCount(List safeMaterialBOList) { if(CollectionUtils.isEmpty(safeMaterialBOList)){ throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL); } repository.updateStockCount(safeMaterialBOList); } }