package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base;

import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesOrgService;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesOrg;
import cn.estsh.i3plus.pojo.mes.repository.MesOrgRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Description: 责任人区域关系
 * @Author: gsz
 * @Date: 2024/6/5 10:16
 * @Modify:
 */
@Service
@Slf4j
public class MesOrgServiceImpl implements IMesOrgService {

    @Autowired
    private MesOrgRepository mesOrgRDao;

    @Override
    public List<MesOrg> queryMesOrg(MesOrg bean) {
        DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
        DdlPreparedPack.getStringEqualPack(bean.getInventoryLocationCode(), "inventoryLocationCode", packBean);
        if(StringUtil.isEmpty(bean.getResponsibleParty())){
            DdlPreparedPack.getIsNotNull( "responsibleParty", packBean);
        }else {
            DdlPreparedPack.getStringEqualPack(bean.getResponsibleParty(), "responsibleParty", packBean);
        }
        packBean.setOrderByStr(bean.orderBy());

        return mesOrgRDao.findByHqlWhere(packBean);
    }
}
