package doumeemes.service.business.impl; 
 | 
  
 | 
import doumeemes.core.model.PageData; 
 | 
import doumeemes.core.model.PageWrap; 
 | 
import doumeemes.core.utils.Utils; 
 | 
import doumeemes.dao.business.AdjustmentRecordMapper; 
 | 
import doumeemes.dao.business.model.AdjustmentRecord; 
 | 
import doumeemes.service.business.AdjustmentRecordService; 
 | 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 
 | 
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; 
 | 
import com.baomidou.mybatisplus.core.metadata.IPage; 
 | 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
 | 
import org.springframework.beans.factory.annotation.Autowired; 
 | 
import org.springframework.stereotype.Service; 
 | 
import org.springframework.util.CollectionUtils; 
 | 
  
 | 
import java.util.List; 
 | 
  
 | 
/** 
 | 
 * 调整入库单 - 明细记录表Service实现 
 | 
 * @author 江蹄蹄 
 | 
 * @date 2022/08/08 09:38 
 | 
 */ 
 | 
@Service 
 | 
public class AdjustmentRecordServiceImpl implements AdjustmentRecordService { 
 | 
  
 | 
    @Autowired 
 | 
    private AdjustmentRecordMapper adjustmentRecordMapper; 
 | 
  
 | 
    @Override 
 | 
    public Integer create(AdjustmentRecord adjustmentRecord) { 
 | 
        adjustmentRecordMapper.insert(adjustmentRecord); 
 | 
        return adjustmentRecord.getId(); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void deleteById(Integer id) { 
 | 
        adjustmentRecordMapper.deleteById(id); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void delete(AdjustmentRecord adjustmentRecord) { 
 | 
        UpdateWrapper<AdjustmentRecord> deleteWrapper = new UpdateWrapper<>(adjustmentRecord); 
 | 
        adjustmentRecordMapper.delete(deleteWrapper); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void deleteByIdInBatch(List<Integer> ids) { 
 | 
        if (CollectionUtils.isEmpty(ids)) { 
 | 
            return; 
 | 
        } 
 | 
        adjustmentRecordMapper.deleteBatchIds(ids); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void updateById(AdjustmentRecord adjustmentRecord) { 
 | 
        adjustmentRecordMapper.updateById(adjustmentRecord); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void updateByIdInBatch(List<AdjustmentRecord> adjustmentRecords) { 
 | 
        if (CollectionUtils.isEmpty(adjustmentRecords)) { 
 | 
            return; 
 | 
        } 
 | 
        for (AdjustmentRecord adjustmentRecord: adjustmentRecords) { 
 | 
            this.updateById(adjustmentRecord); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public AdjustmentRecord findById(Integer id) { 
 | 
        return adjustmentRecordMapper.selectById(id); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public AdjustmentRecord findOne(AdjustmentRecord adjustmentRecord) { 
 | 
        QueryWrapper<AdjustmentRecord> wrapper = new QueryWrapper<>(adjustmentRecord); 
 | 
        return adjustmentRecordMapper.selectOne(wrapper); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public List<AdjustmentRecord> findList(AdjustmentRecord adjustmentRecord) { 
 | 
        QueryWrapper<AdjustmentRecord> wrapper = new QueryWrapper<>(adjustmentRecord); 
 | 
        return adjustmentRecordMapper.selectList(wrapper); 
 | 
    } 
 | 
   
 | 
    @Override 
 | 
    public PageData<AdjustmentRecord> findPage(PageWrap<AdjustmentRecord> pageWrap) { 
 | 
        IPage<AdjustmentRecord> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); 
 | 
        QueryWrapper<AdjustmentRecord> queryWrapper = new QueryWrapper<>(); 
 | 
        Utils.MP.blankToNull(pageWrap.getModel()); 
 | 
        if (pageWrap.getModel().getId() != null) { 
 | 
            queryWrapper.lambda().eq(AdjustmentRecord::getId, pageWrap.getModel().getId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getDeleted() != null) { 
 | 
            queryWrapper.lambda().eq(AdjustmentRecord::getDeleted, pageWrap.getModel().getDeleted()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCreateUser() != null) { 
 | 
            queryWrapper.lambda().eq(AdjustmentRecord::getCreateUser, pageWrap.getModel().getCreateUser()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCreateTime() != null) { 
 | 
            queryWrapper.lambda().ge(AdjustmentRecord::getCreateTime, Utils.Date.getStart(pageWrap.getModel().getCreateTime())); 
 | 
            queryWrapper.lambda().le(AdjustmentRecord::getCreateTime, Utils.Date.getEnd(pageWrap.getModel().getCreateTime())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getUpdateUser() != null) { 
 | 
            queryWrapper.lambda().eq(AdjustmentRecord::getUpdateUser, pageWrap.getModel().getUpdateUser()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getUpdateTime() != null) { 
 | 
            queryWrapper.lambda().ge(AdjustmentRecord::getUpdateTime, Utils.Date.getStart(pageWrap.getModel().getUpdateTime())); 
 | 
            queryWrapper.lambda().le(AdjustmentRecord::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getRemark() != null) { 
 | 
            queryWrapper.lambda().eq(AdjustmentRecord::getRemark, pageWrap.getModel().getRemark()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getRootDepartId() != null) { 
 | 
            queryWrapper.lambda().eq(AdjustmentRecord::getRootDepartId, pageWrap.getModel().getRootDepartId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getOutboundId() != null) { 
 | 
            queryWrapper.lambda().eq(AdjustmentRecord::getOutboundId, pageWrap.getModel().getOutboundId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getAppliancesId() != null) { 
 | 
            queryWrapper.lambda().eq(AdjustmentRecord::getAppliancesId, pageWrap.getModel().getAppliancesId()); 
 | 
        } 
 | 
        for(PageWrap.SortData sortData: pageWrap.getSorts()) { 
 | 
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { 
 | 
                queryWrapper.orderByDesc(sortData.getProperty()); 
 | 
            } else { 
 | 
                queryWrapper.orderByAsc(sortData.getProperty()); 
 | 
            } 
 | 
        } 
 | 
        return PageData.from(adjustmentRecordMapper.selectPage(page, queryWrapper)); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public long count(AdjustmentRecord adjustmentRecord) { 
 | 
        QueryWrapper<AdjustmentRecord> wrapper = new QueryWrapper<>(adjustmentRecord); 
 | 
        return adjustmentRecordMapper.selectCount(wrapper); 
 | 
    } 
 | 
} 
 |