/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2018-09-11
 * 描述            ：检验接口表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.Pms.Settlement.impl;
import java.util.List;

import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Pms.Settlement.mapper.PurInterfaceInspectMapper;
import market.Pms.Settlement.service.PurInterfaceInspectService;
import market.Pms.Settlement.vo.PurInterfaceInspect;

import com.hnshituo.basic.service.impl.BaseServiceImpl;
import com.hnshituo.basic.spring.remoting.annotation.RemoteService;

@RemoteService(path="PurInterfaceInspectService")
public class PurInterfaceInspectServiceImpl extends BaseServiceImpl<PurInterfaceInspect,Object> implements PurInterfaceInspectService {
	/***
	 * 
	 * 检验信息查询
	 * */
	public ResultModel  doQueryWeb(CommonPage<PurInterfaceInspect> sum){
		ResultModel rm=new ResultModel();
		PurInterfaceInspect  pfb=sum.getObject();
		String  startTime=sum.getStartTime();
		String  endTime=sum.getEndTime();
		try {
			String swhere="1=1 and VALIDFLAG='00'";//查询初始数据
			if(pfb.getContract_pk()!=null&&!"".equals(pfb.getContract_pk())){
				swhere+=" and  Contract_pk  like '%"+pfb.getContract_pk()+"%'";
			}
			if(pfb.getContract_no()!=null&&!"".equals(pfb.getContract_no())){
				swhere+=" and  Contract_no  like '%"+pfb.getContract_no()+"%'";
			}//合同号
			if(pfb.getOrder_pk()!=null&&!"".equals(pfb.getOrder_pk())){
				swhere+=" and  Order_pk  like '%"+pfb.getOrder_pk()+"%'";
			}
			if(pfb.getOrder_no()!=null&&!"".equals(pfb.getOrder_no())){
				swhere+=" and  Order_no  like '%"+pfb.getOrder_no()+"%'";
			}//订单号
			if(pfb.getInspect_no()!=null&&!"".equals(pfb.getInspect_no())){
					swhere+=" and  inspect_no  like '%"+pfb.getInspect_no()+"%'";
			}//参考单号
			if(pfb.getSupp_code()!=null&&!"".equals(pfb.getSupp_code())){
				swhere+=" and  supp_code  like '%"+pfb.getSupp_code()+"%'";
		    }//供应商号
			if(pfb.getSupp_name()!=null&&!"".equals(pfb.getSupp_name())){
				swhere+=" and  supp_name  like '%"+pfb.getSupp_name()+"%'";
		    }//供应商号
			if(startTime!=null&&!"".equals(startTime)){
				swhere+=" and to_char(create_time, 'yyyy-mm-dd hh24:mi:ss') >='"+startTime+"'";			
			}
			if(endTime!=null&&!"".equals(endTime)){
				swhere+=" and to_char(create_time, 'yyyy-mm-dd hh24:mi:ss') <='"+endTime+"'";			
			}
			List<PurInterfaceInspect>  list =this.getMapper(PurInterfaceInspectMapper.class).findWithCondition(null, swhere, "CREATE_TIME desc", 0, 0);
			rm.setData(list);
			rm.setState("200");
			rm.setMsgInfo("查询成功");		
		} catch (Exception e) {
			// TODO: handle exception
			rm.setState("500");
			rm.setMsgInfo("查询失败，请联系管理员！");
			throw e;
		}
		return rm;
		
	}
	
	
	/**
	 * 
	 * @author 赵淋支
	 * @date   2018年10月13日
	 * @parameter getObject:order_pk,notice_no
	 * @return 
	 * @description 根据入库单查询检验单
	 */
	public ResultModel  doQueryInspectByInBill(CommonPage<PurInterfaceInspect> sum){
		ResultModel rm=new ResultModel();
		PurInterfaceInspect pfb=sum.getObject(); 
		try {
			String swhere="1=1 and VALIDFLAG='00'";//查询初始数据 
			//订单号
			if(pfb.getOrder_pk()!=null&&!"".equals(pfb.getOrder_pk())){
				swhere +=" and order_pk  = '"+pfb.getOrder_pk()+"'";
			}
			if(pfb.getOrder_no()!=null&&!"".equals(pfb.getOrder_no())){
				swhere+=" and order_no  = '"+pfb.getOrder_no()+"'";
			}
			//发货单号
			if(pfb.getNotice_no()!=null&&!"".equals(pfb.getNotice_no())){
					swhere+=" and notice_no  = '"+pfb.getNotice_no()+"'";
			}  
			List<PurInterfaceInspect>  list =this.getMapper(PurInterfaceInspectMapper.class).findWithCondition(null, swhere, "CREATE_TIME desc", 0, 0);
			rm.setData(list);
			rm.setState("200");
			rm.setMsgInfo("查询成功");		
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("查询失败:"+ex.getMessage()); 
		}
		return rm; 
	}
	

}
