/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2018-11-22
 * 描述            ：结算单主表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.Pms.Settlement.impl;
import java.util.Date;
import java.util.List;

import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Pms.Order.mapper.PurOrderMMapper;
import market.Pms.Order.vo.PurOrderM;
import market.Pms.Settlement.mapper.PurBalanceCMapper;
import market.Pms.Settlement.mapper.PurBalanceDMapper;
import market.Pms.Settlement.mapper.PurBalanceEMapper;
import market.Pms.Settlement.mapper.PurBalanceGMapper;
import market.Pms.Settlement.mapper.PurBalanceMMapper;
import market.Pms.Settlement.mapper.PurInterfaceInbillMapper;
import market.Pms.Settlement.service.PurBalanceMService;
import market.Pms.Settlement.vo.PurBalanceC;
import market.Pms.Settlement.vo.PurBalanceD;
import market.Pms.Settlement.vo.PurBalanceE;
import market.Pms.Settlement.vo.PurBalanceG;
import market.Pms.Settlement.vo.PurBalanceM;
import market.Pms.Settlement.vo.PurInterfaceInbill;
import market.Pms.Supp.mapper.PurSuppBankMapper;
import market.Pms.Supp.vo.PurSuppBank;

import org.springframework.transaction.annotation.Transactional;

import com.hnshituo.basic.service.impl.BaseServiceImpl;
import com.hnshituo.basic.spring.remoting.annotation.RemoteService;
import com.hnshituo.core.auth.service.HomeService;
import com.ibm.icu.text.SimpleDateFormat;

@RemoteService(path="PurBalanceMService")
public class PurBalanceMServiceImpl extends BaseServiceImpl<PurBalanceM,Object> implements PurBalanceMService {

	/**
	 * @author 赵淋支
	 * @date   2018年11月22日
	 * @description 结算单编制：查询结算单主表信息
	 */
	public ResultModel doQueryPurBalanceM(CommonPage<PurBalanceM> cp){
		ResultModel rm=new ResultModel();
		PurBalanceM  pbm=cp.getObject();
		String startTime = cp.getStartTime();
		String endTime = cp.getEndTime();
		try {
			String swhere="";
			//结算单号
			if(pbm.getBalance_no()!=null&&!"".equals(pbm.getBalance_no())){
				swhere+=" and T.BALANCE_NO like  '%"+pbm.getBalance_no()+"%'";
			}
			//供应商名称
			if(pbm.getSupp_name()!=null&&!"".equals(pbm.getSupp_name())){
				swhere+=" and T.SUPP_NAME like '%"+pbm.getSupp_name()+"%'";
			}
			//合同号
			if (pbm.getContract_no()!=null && !"".equals(pbm.getContract_no())) {
				swhere+=" and T.CONTRACT_NO like '%"+pbm.getContract_no()+"%'";
			}
			//数据状态
			if(pbm.getValidflag()!=null&&!"".equals(pbm.getValidflag())){
				swhere+=" and T.VALIDFLAG  = '"+pbm.getValidflag()+"'";
			}
			//评审状态
			if(pbm.getStatus()!=null&&!"".equals(pbm.getStatus())){
				swhere+=" and T.STATUS  = '"+pbm.getStatus()+"'";
			}
			if (startTime != null && !"".equals(startTime)) {
				swhere += " and to_char(T.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') >='"
						+ startTime +" 00:00:00"+ "'";
			}
			if (endTime != null && !"".equals(endTime)) {
				swhere += " and to_char(T.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') <= '"
						+ endTime +" 23:59:59"+ "'";
			}
			//默认不显示无效的数据
			if(!swhere.contains("VALIDFLAG")){
				swhere+=" and T.VALIDFLAG > '00'";
			}
			// 新增报支单主信息时，查询结算单主信息
			if ("balanceG".equals(cp.getMemo4())) {
				swhere += " and T.VALIDFLAG = '25' and not exists "
						+ "(select g.balance_no from pur_balance_g g "
						+ "where g.balance_no = T.balance_no)";
			}
			// 新增冲减单信息时，查询冲减单信息
			if ("balanceD".equals(cp.getMemo4())) {
				swhere += " and T.VALIDFLAG = '25' and not exists "
						+ "(select d.balance_no from pur_balance_d d "
						+ "where d.balance_no = T.balance_no and d.validflag  > '00')";
			}
			List<PurBalanceM> list = this.getMapper(PurBalanceMMapper.class).doQueryPurBalanceM(swhere);
			rm.setData(list);
			rm.setState("200");
			rm.setMsgInfo("查询成功");		
		} catch (Exception e) {
			rm.setState("500");
			rm.setMsgInfo("查询失败，请联系管理员！");
			throw e;
		}
		return rm;
	}
	
	
	/**
	 * 
	 * @author 赵淋支
	 * @date   2018年11月22日
	 * @parameter [{"object":{"bal_year_month":"会计年月YYYYMM",
	 * "balance_type_code":"结算类别编码","balance_type_name":"结算类别名称",
	 * "balance_date":"结算日期","balance_desc":"结算说明"},"memo1":"合同号"}]
	 * @description 结算单编制界面：创建结算单头信息
	 */
	public  ResultModel addPurBalanceM(CommonPage<PurBalanceM> cp) throws Exception{
		String userId = (String) this.getSession().getAttribute(HomeService.SESSION_USER_ID);
		String userName = (String) this.getSession().getAttribute(HomeService.SESSION_USER_NAME);
		ResultModel rm=new ResultModel();
		PurBalanceM  PBM=cp.getObject();
		String contractno = cp.getMemo1(); // 合同号
		 
		if (contractno==null || "".equals(contractno)) {
			rm.setState("500");
			rm.setMsgInfo("请选择合同数据！");
			return rm;
		}
		try 
		{
			// 获取合同信息
			PurOrderM pom = new PurOrderM();
			pom.setContract_no(contractno);
			pom.setValidflag("20");
			List<PurOrderM> pomList = this.getMapper(PurOrderMMapper.class).find(pom, 0, 0);
			if (pomList!=null && pomList.size() > 0) {
				pom = pomList.get(0);
				Date now = new Date();
				PurBalanceM pbm = new PurBalanceM();
				//1、生成结算单号
				String BALANCE_NO = "JS"+ new SimpleDateFormat("yyyyMMdd").format(now);
				String maxD = this.getMapper(PurBalanceMMapper.class).findBalanceNO(BALANCE_NO);
				if (maxD != null && maxD.length() > 4) {
					String seq = maxD.substring(maxD.length() - 4);
					int iseq = Integer.parseInt(seq) + 1;
					BALANCE_NO += String.format("%04d", iseq);
				} else {
					BALANCE_NO += "0001";
				}
				pbm.setBalance_no(BALANCE_NO);//结算单号
				pbm.setContract_no(pom.getContract_no());//合同号
				pbm.setContract_pk(pom.getContract_pk());//合同主键
				pbm.setContract_ver(pom.getContract_ver());//合同版本
				pbm.setSupp_code(pom.getSupp_code());
				pbm.setSupp_name(pom.getSupp_name());//供应商
				pbm.setDept_code(pom.getBuyer_dept_code());//管理部门
				pbm.setDept_desc(pom.getBuyer_dept_desc());
				pbm.setUnit_code(pom.getBuyer_unit_code());//管理科室
				pbm.setUnit_desc(pom.getBuyer_unit_desc());
				pbm.setBal_year_month(PBM.getBal_year_month());//业务年月(会计年月)
				pbm.setBalance_type_code(PBM.getBalance_type_code());//结算类别
				pbm.setBalance_type_name(PBM.getBalance_type_name());
				pbm.setBalance_date(PBM.getBalance_date());//结算日期
				pbm.setBalance_desc(PBM.getBalance_desc());//结算说明
		        pbm.setValidflag("10");//默认草稿
		        pbm.setStatus("00");//默认待提报
		        pbm.setCreate_name(userName);
		        pbm.setCreate_userid(userId);
		        pbm.setCreate_time(now); 
		        this.getMapper(PurBalanceMMapper.class).insert(pbm);
			}
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("创建结算单头失败:"+ex.getMessage());
			throw ex;
		}
		rm.setState("200");
		return rm; 
	}
	
	/**
	 * @author 赵淋支
	 * @date   2018年11月22日
	 * @description 结算单编制界面：自动审批功能
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel doExamPurBalanceM(CommonPage<PurBalanceM> cp)
			throws Exception {
		String userId = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_ID);
		String userName = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_NAME);
		ResultModel rm = new ResultModel();
		if (cp.getObjectList() == null || cp.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择结算单数据！");
			return rm;
		}
		Date now = new Date();
		for (PurBalanceM pdm : cp.getObjectList()) {
			PurBalanceM pdm2=this.getMapper(PurBalanceMMapper.class).findById(pdm.getBalance_no());				
			if (pdm2!=null && "10".equals(pdm2.getValidflag())
					&& ("00".equals(pdm2.getStatus()) || "40".equals(pdm2
							.getStatus()))) {//草稿+ 待提报/审批退回
				//主表PurBalanceM
				PurBalanceM newPdm = new PurBalanceM();
				newPdm.setBalance_no(pdm2.getBalance_no());
				newPdm.setBalance_type_code(pdm.getBalance_type_code());//结算类别
				newPdm.setBalance_type_name(pdm.getBalance_type_name());
				newPdm.setBalance_desc(pdm.getBalance_desc());//结算说明
				newPdm.setValidflag("20");//生效
				newPdm.setStatus("50");//审批通过
				newPdm.setUpdate_userid(userId);
				newPdm.setUpdate_name(userName);
				newPdm.setUpdate_time(now);
				this.getMapper(PurBalanceMMapper.class).update(newPdm);
				//从表PurBalanceC
				PurBalanceC pdc = new PurBalanceC();
				pdc.setBalance_no(pdm.getBalance_no());
				pdc.setValidflag("10");//草稿
				List<PurBalanceC> pdcList = this.getMapper(PurBalanceCMapper.class).find(pdc, 0, 0);
				if (pdcList!=null && pdcList.size() > 0) {
					for (PurBalanceC pDc : pdcList) {
						pdc = new PurBalanceC();
						pdc.setBalance_sqe(pDc.getBalance_sqe());
						pdc.setValidflag("20"); //生效
						pdc.setStatus("50"); //审批通过
						pdc.setUpdate_userid(userId);
						pdc.setUpdate_name(userName);
						pdc.setUpdate_time(now);
						this.getMapper(PurBalanceCMapper.class).update(pdc);
					}
				}
			} else {
				throw new Exception("当前数据状态不能进行自动审批");
			}
		}
		rm.setState("200");
		rm.setMsgInfo("自动审批成功！"); 
		return rm;
	}
	
	/**
	 * @author 赵淋支
	 * @date   2018年11月22日
	 * @description 结算单编制界面：撤销审批功能
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel doCancelExamPurBalanceM(CommonPage<PurBalanceM> cp)
			throws Exception {
		String userId = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_ID);
		String userName = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_NAME);
		ResultModel rm = new ResultModel();
		if (cp.getObjectList() == null || cp.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择结算单数据！");
			return rm;
		}
		try {
			Date now = new Date();
			for (PurBalanceM pdm : cp.getObjectList()) {
				PurBalanceM pdm2=this.getMapper(PurBalanceMMapper.class).findById(pdm.getBalance_no());				
				if (pdm2!=null && "20".equals(pdm2.getValidflag())
						&& "50".equals(pdm2.getStatus())) {//生效+ 审批通过
					//主表PurBalanceM
					pdm = new PurBalanceM();
					pdm.setBalance_no(pdm2.getBalance_no());
					pdm.setValidflag("10");//草稿
					pdm.setStatus("00");//待提报
					pdm.setUpdate_userid(userId);
					pdm.setUpdate_name(userName);
					pdm.setUpdate_time(now);
					this.getMapper(PurBalanceMMapper.class).update(pdm);
					//从表PurBalanceC
					PurBalanceC pdc = new PurBalanceC();
					pdc.setBalance_no(pdm.getBalance_no());
					pdc.setValidflag("20");//生效
					pdc.setStatus("50");//审批通过
					List<PurBalanceC> pdcList = this.getMapper(PurBalanceCMapper.class).find(pdc, 0, 0);
					if (pdcList!=null && pdcList.size() > 0) {
						for (PurBalanceC pDc : pdcList) {
							pdc = new PurBalanceC();
							pdc.setBalance_sqe(pDc.getBalance_sqe());
							pdc.setValidflag("10"); //草稿
							pdc.setStatus("00"); //待提报
							pdc.setUpdate_userid(userId);
							pdc.setUpdate_name(userName);
							pdc.setUpdate_time(now);
							this.getMapper(PurBalanceCMapper.class).update(pdc);
						}
					}
				} else {
					throw new Exception("当前数据状态不能进行撤销审批");
				}
			}
			rm.setState("200");
			rm.setMsgInfo("撤销审批成功！");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("撤销审批失败，请联系管理员");
			throw ex;
		}
		return rm;
	}
	
	/**
	 * @author 赵淋支
	 * @date   2018年11月22日
	 * @description 结算单编制界面：删除结算单主信息
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel doDeletePurBalanceM(CommonPage<PurBalanceM> cp)
			throws Exception {
		String userId = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_ID);
		String userName = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_NAME);
		ResultModel rm = new ResultModel();
		if (cp.getObjectList() == null || cp.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择结算单数据！");
			return rm;
		}

		Date now = new Date();
		for (PurBalanceM pdm : cp.getObjectList()) {
			PurBalanceM pdm2=this.getMapper(PurBalanceMMapper.class).findById(pdm.getBalance_no());				
			if (pdm2!=null && "10".equals(pdm2.getValidflag())
					&& ("00".equals(pdm2.getStatus()) || "40".equals(pdm2
							.getStatus()))) {//草稿+ 待提报/审批退回
				//主表PurBalanceM
				pdm = new PurBalanceM();
				pdm.setBalance_no(pdm2.getBalance_no());
				pdm.setValidflag("00");//无效
				pdm.setUpdate_userid(userId);
				pdm.setUpdate_name(userName);
				pdm.setUpdate_time(now);
				this.getMapper(PurBalanceMMapper.class).update(pdm);
				//从表PurBalanceC
				PurBalanceC pdc = new PurBalanceC();
				pdc.setBalance_no(pdm.getBalance_no());
				pdc.setValidflag("10");//草稿
				List<PurBalanceC> pdcList = this.getMapper(PurBalanceCMapper.class).find(pdc, 0, 0);
				if (pdcList!=null && pdcList.size() > 0) {
					for (PurBalanceC pDc : pdcList) {
						pdc = new PurBalanceC();
						pdc.setBalance_sqe(pDc.getBalance_sqe());
						pdc.setValidflag("00"); //无效
						pdc.setUpdate_userid(userId);
						pdc.setUpdate_name(userName);
						pdc.setUpdate_time(now);
						this.getMapper(PurBalanceCMapper.class).update(pdc);
						//修改待结入库单的数据的状态为初始状态
						PurInterfaceInbill pii = new PurInterfaceInbill();
						pii.setInstock_no(pDc.getRefe_no());
						pii.setValidflag("00");
						this.getMapper(PurInterfaceInbillMapper.class).update(pii);
					}
				}
			} else {
				throw new Exception("当前数据状态不能删除");
			}
		}
		rm.setState("200");
		rm.setMsgInfo("删除成功！");
		return rm;
	}
	
	/**
	 * 
	 * @author 赵淋支
	 * @date   2018年11月22日
	 * @description 结算单编制界面：修改保存结算单主信息
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel doSavePurBalanceM(CommonPage<PurBalanceM> cp)
			throws Exception {
		String userId = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_ID);
		String userName = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_NAME);
		ResultModel rm = new ResultModel();
		if (cp.getObjectList() == null || cp.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择结算单数据！");
			return rm;
		}
		Date now = new Date();
		for (PurBalanceM pdm : cp.getObjectList()) {
			PurBalanceM pdm2=this.getMapper(PurBalanceMMapper.class).findById(pdm.getBalance_no());				
			if (pdm2!=null) {
				//主表PurBalanceM
				PurBalanceM newPdm = new PurBalanceM();
				newPdm.setBalance_no(pdm2.getBalance_no());
				newPdm.setBalance_type_code(pdm.getBalance_type_code());//结算类别
				newPdm.setBalance_type_name(pdm.getBalance_type_name());
				newPdm.setBalance_desc(pdm.getBalance_desc());//结算说明
				newPdm.setUpdate_userid(userId);
				newPdm.setUpdate_name(userName);
				newPdm.setUpdate_time(now);
				//生效后才能保存发票号码和发票代码				
				if ("20".equals(pdm2.getValidflag())) {
					if ((pdm.getBills_nos()!=null && !"".equals(pdm.getBills_nos())) ||
							(pdm.getBills_codes()!=null && !"".equals(pdm.getBills_codes()))) {
						//存在发票号码或者发票代码将数据状态改成发票
						newPdm.setValidflag("25");
					}
					newPdm.setBills_nos(pdm.getBills_nos());//发票号码
					newPdm.setBills_codes(pdm.getBills_codes());//发票代码
				}
				//发票状态
				if ("25".equals(pdm2.getValidflag())) {
					// 判断是否报支
					String condition = "balance_no = '"+pdm2.getBalance_no()+"' and validflag > '00'";
					List<PurBalanceG> pbgList = this.getMapper(PurBalanceGMapper.class).findWithCondition(null, condition, null, 0, 0);
					if (pbgList!=null && pbgList.size()>0) {
						throw new Exception("结算单号["+pdm2.getBalance_no()+"]已经报支，无法进行保存操作");
					}
					// 判断是否冲减
					List<PurBalanceD> pbdList = this.getMapper(PurBalanceDMapper.class).findWithCondition(null, condition, null, 0, 0);
					if (pbdList!=null && pbdList.size()>0) {
						throw new Exception("结算单号["+pdm2.getBalance_no()+"]已经冲减，无法进行保存操作");
					}
					List<PurBalanceE> pbeList = this.getMapper(PurBalanceEMapper.class).findWithCondition(null, condition, null, 0, 0);
					if (pbeList!=null && pbeList.size()>0) {
						throw new Exception("结算单号["+pdm2.getBalance_no()+"]的结算单行已经冲减，无法进行保存操作");
					}
					
					//清除发票号码或者发票代码，将状态改为生效
					if ((pdm.getBills_nos()==null || "".equals(pdm.getBills_nos())) && 
						(pdm.getBills_codes()==null || "".equals(pdm.getBills_codes()))) {
						newPdm.setValidflag("20");
					}
					newPdm.setBills_nos(pdm.getBills_nos());//发票号码
					newPdm.setBills_codes(pdm.getBills_codes());//发票代码
				}
				this.getMapper(PurBalanceMMapper.class).update(newPdm);
			} else {
				throw new Exception("结算单["+pdm.getBalance_no()+"]数据未找到");
			}
		}
		rm.setState("200");
		rm.setMsgInfo("保存成功！");
		return rm;
	}
	 
	/**
	 * 
	 * @author 赵淋支
	 * @date   2018年11月30日
	 * @description 报支单新增:查询结算单
	 */
	public ResultModel doQueryPurBalanceM_G(CommonPage<PurBalanceM> cp){
		ResultModel rm=new ResultModel();
		PurBalanceM  pbm=cp.getObject();
		String startTime = cp.getStartTime();
		try {
			String swhere="";
			//结算单号
			if(pbm.getBalance_no()!=null&&!"".equals(pbm.getBalance_no())){
				swhere+=" and T.BALANCE_NO like  '%"+pbm.getBalance_no()+"%'";
			}
			//供应商名称
			if(pbm.getSupp_name()!=null&&!"".equals(pbm.getSupp_name())){
				swhere+=" and T.SUPP_NAME like '%"+pbm.getSupp_name()+"%'";
			}
			//合同号
			if (pbm.getContract_no()!=null && !"".equals(pbm.getContract_no())) {
				swhere+=" and T.CONTRACT_NO like '%"+pbm.getContract_no()+"%'";
			}
			if (startTime != null && !"".equals(startTime)) {
				swhere += " and to_char(T.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') >='"
						+ startTime +" 00:00:00"+ "'";
			}			
			List<PurBalanceM> list = this.getMapper(PurBalanceMMapper.class).doQueryPurBalanceM_G(swhere);
			rm.setData(list);
			rm.setState("200");
			rm.setMsgInfo("查询成功");		
		} catch (Exception e) {
			rm.setState("500");
			rm.setMsgInfo("查询失败，请联系管理员！");
			throw e;
		}
		return rm;
	}
	
	/**
	 * 
	 * @author 赵淋支
	 * @date   2018年11月30日
	 * @description 报支单新增；通过供应商获取银行信息
	 */
	public ResultModel doQueryPurSupBank(CommonPage<PurSuppBank> cp){
		ResultModel rm=new ResultModel();
		PurSuppBank  psb=cp.getObject();
		try {
			String swhere="";
			//供应商编码
			if(psb.getSupp_code()!=null&&!"".equals(psb.getSupp_code())){
				swhere+=" and SUPP_CODE like  '%"+psb.getSupp_code()+"%'";
			}
			//供应商名称
			if(psb.getSupp_name()!=null&&!"".equals(psb.getSupp_name())){
				swhere+=" and SUPP_NAME like '%"+psb.getSupp_name()+"%'";
			}
			//银行账号
			if(psb.getBank_account()!=null&&!"".equals(psb.getBank_account())){
				swhere+=" and BANK_ACCOUNT like '%"+psb.getBank_account()+"%'";
			}
			swhere += " and VALIDFLAG = '1' ";
			List<PurSuppBank> list = this.getMapper(PurSuppBankMapper.class).findWithCondition(null, swhere, null, 0, 0);
			rm.setData(list);
			rm.setState("200");
			rm.setMsgInfo("查询成功");		
		} catch (Exception e) {
			rm.setState("500");
			rm.setMsgInfo("查询失败，请联系管理员！");
			throw e;
		}
		return rm;
	}
	
	/**
	 * 
	 * @author 赵淋支
	 * @date   2018年12月11日
	 * @description 结算单新增：查询合同信息
	 */
	public ResultModel doQuaryPurOrderM(CommonPage<PurOrderM> oci) {
		ResultModel rm = new ResultModel();
		PurOrderM  pom=oci.getObject();
		String startTime = oci.getStartTime();
		try {
			String swhere=" and t.VALIDFLAG='20'";
			//供应商
			if(pom.getSupp_name()!=null&&!"".equals(pom.getSupp_name())){
				swhere+=" and t.supp_name  like  '%"+pom.getSupp_name()+"%'";
			}
			//合同号
			if(pom.getContract_no()!=null&&!"".equals(pom.getContract_no())){
				swhere+=" and t.Contract_no  like '%"+pom.getContract_no()+"%'";
			}
			//开始时间
			if (startTime!=null&&!"".equals(startTime)) {
				swhere+=" and to_char(t.create_time, 'yyyy-mm-dd hh24:mi:ss') >= '"+startTime+"' ";
			}
			List<PurOrderM> list=this.getMapper(PurBalanceMMapper.class).doQuaryPurOrderM(swhere);
			rm.setData(list);
			rm.setState("200");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("错误：" + ex.getMessage());
		}
		return rm;
	}
	
	
}
