/***文档注释***********************************************
 * 作者               :                   易鑫
 * 创建日期      :                   2016.03.12
 * 描述               :                  公示范围信息
 * 注意事项      :                   无
 * 遗留BUG :                      无
 * 修改日期      :                   
 * 修改人员      :                   
 * 修改内容      :                   
 ***********************************************************/

package market.Slm.Notice.impl;

import java.util.ArrayList;
import java.util.List;

import market.Slm.CustomerInformation.mapper.SlmCustomerPersonInfoMapper;
import market.Slm.CustomerInformation.vo.SlmCustomerPersonInfo;
import market.Slm.Notice.mapper.SlmNoticeScaleMapper;
import market.Slm.Notice.service.SlmNoticeScaleService;
import market.Slm.Notice.vo.SlmNoticeScale;

import org.springframework.transaction.annotation.Transactional;

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

@RemoteService(path="SlmNoticeScaleService")
public class SlmNoticeScaleServiceImpl extends BaseServiceImpl<SlmNoticeScale,Object> implements SlmNoticeScaleService {
	
	//通知公告选择范围
	@Transactional(value="tm", rollbackFor=Exception.class)
	public List<SlmCustomerPersonInfo> doAdd(List<SlmNoticeScale> lons) {
		List<SlmCustomerPersonInfo> lsp=new ArrayList<SlmCustomerPersonInfo>();
		
		String strCompany="";
		for(SlmNoticeScale ons:lons){
			//获取公司
			strCompany+="'"+ons.getType_no()+"',";
			this.getMapper(SlmNoticeScaleMapper.class).doAdd(ons);
		}
		
		ArrayList<String> ls=new ArrayList<String>();
		if(!"".equals(strCompany)){//根据公司获取人员编号用于发送推送消息
			SlmCustomerPersonInfo scpi=new SlmCustomerPersonInfo();
			scpi.setValid_flag("1");
			lsp=this.getMapper(SlmCustomerPersonInfoMapper.class).findWithCondition(scpi, "customer_no in ("+strCompany.substring(0,strCompany.length()-1)+")", "", 0, 0);
		}
		return lsp;
	}
	
	public List<SlmNoticeScale> doQuery(SlmNoticeScale cs){
		List<SlmNoticeScale> list=this.getMapper(SlmNoticeScaleMapper.class).find(cs, 0, 0);
		return list;
	}
}
