package com.jwipc.order.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwipc.order.entity.PurchaseOrderDevPlan;
import com.jwipc.order.mapper.PurchaseOrderDevPlanMapper;
import com.jwipc.order.model.po.PurchaseOrderPlanPO;
import com.jwipc.order.model.query.PurchaseOrderPlanQuery;
import com.jwipc.order.service.IPurchaseOrderDevPlanService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhangjie
 * @since 2024-03-18
 */
@Service
public class PurchaseOrderDevPlanServiceImpl extends ServiceImpl<PurchaseOrderDevPlanMapper, PurchaseOrderDevPlan> implements IPurchaseOrderDevPlanService {
    @Override
    public List<PurchaseOrderPlanPO> findList(Page<PurchaseOrderPlanPO> page, PurchaseOrderPlanQuery query) {
        //先去掉空格
        if (StringUtils.isNotEmpty(query.getMaterialCode())) {
            query.setMaterialCode(query.getMaterialCode().trim());
        }
        if (StringUtils.isNotEmpty(query.getMaterialCode()) && query.getMaterialCode().indexOf(" ") > 0) {
            query.setMaterialCode(query.getMaterialCode().replaceAll(" ", "|"));
        }
        if (StringUtils.isNotEmpty(query.getMaterialCode()) && query.getMaterialCode().indexOf(",") > 0) {
            query.setMaterialCode(query.getMaterialCode().replace(",", "|"));
        }
        return this.baseMapper.findList(page,query);
    }

}
