/***文档注释***********************************************
 * 作者               :                   易鑫
 * 创建日期      :                   2017.11.02
 * 描述               :        			客户附加要求附件表
 * 注意事项      :                   无
 * 遗留BUG :                   无
 * 修改日期      :                   
 * 修改人员      :                   
 * 修改内容      :                   
 ***********************************************************/
package market.Com.impl;

import java.util.List;

import market.Com.mapper.ComPscMapper;
import market.Com.service.ComPscService;
import market.Com.vo.ComPsc;
import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;

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

@RemoteService(path="ComPscService")
public class ComPscServiceImpl extends BaseServiceImpl<ComPsc,Object> implements ComPscService {
	/**
	 * 合同行-新增 ，产品规范码下拉框
	 * */
	public ResultModel findProdWeb(CommonPage<ComPsc> sum){
		ResultModel rm=new ResultModel();
		ComPsc psc=sum.getObject();
		int pageIndex=sum.getPageIndex();
		int pageSize=sum.getPageSize();
		PageModel<ComPsc> pm=new PageModel<ComPsc>(pageIndex, pageSize);
		try{
			String sWhere=" validflag='1' ";
			if(psc.getProd_name()!=null&&!"".equals(psc.getProd_name())){
				sWhere+=" and prod_name like concat('%','"+psc.getProd_name()+"','%')";
				psc.setProd_name(null);
			}
			if(psc.getSteel_name()!=null&&!"".equals(psc.getSteel_name())){
				sWhere+=" and steel_name like concat('%','"+psc.getSteel_name()+"','%')";
				psc.setSteel_name(null);
			}
			List<ComPsc> list=this.getMapper(ComPscMapper.class).findWithCondition(psc, sWhere," create_time desc",(pageIndex-1)*pageSize,pageSize);
			int count=this.getMapper(ComPscMapper.class).countWithCondition(psc, sWhere);
			pm.setTotal(count);
			pm.setRows(list);
			rm.setState("200");
			rm.setData(pm);
		}catch(Exception e){
			rm.setState("500");
			rm.setData("查询失败");
			e.printStackTrace();
		}	
		return rm;
	}
}
