/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2018-09-04
 * 描述            ：采购单主表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.Pms.Quote.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Pms.Quote.mapper.PurInquiryMMapper;
import market.Pms.Quote.mapper.PurPurchaseCMapper;
import market.Pms.Quote.mapper.PurPurchaseDMapper;
import market.Pms.Quote.mapper.PurPurchaseEMapper;
import market.Pms.Quote.mapper.PurPurchaseFMapper;
import market.Pms.Quote.mapper.PurPurchaseMMapper;
import market.Pms.Quote.service.PurPurchaseMService;
import market.Pms.Quote.vo.PurPurchaseC;
import market.Pms.Quote.vo.PurPurchaseD;
import market.Pms.Quote.vo.PurPurchaseE;
import market.Pms.Quote.vo.PurPurchaseF;
import market.Pms.Quote.vo.PurPurchaseM;

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.mapper.UserMapper;
import com.hnshituo.core.auth.service.HomeService;
import com.hnshituo.core.auth.vo.User;

@RemoteService(path="PurPurchaseMService")
public class PurPurchaseMServiceImpl extends BaseServiceImpl<PurPurchaseM,Object> implements PurPurchaseMService {
	/**
	 *采购信息查询
	 * 
	 * @param oci
	 * @return
	 */
	public ResultModel doQueryWeb(CommonPage<PurPurchaseM> oci) {
		ResultModel rm = new ResultModel();
		PurPurchaseM ppm = oci.getObject();
//		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
		String startTime = oci.getStartTime();
		String endTime = oci.getEndTime();
		String userId = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_ID);
//		String userName = (String) this.getSession().getAttribute(
//				HomeService.SESSION_USER_NAME);
		
		try {
			User user2=this.getMapper(UserMapper.class).findById(userId);
			if("资材备件科".equals(user2.getDept_name())||"原料科".equals(user2.getDept_name())){
				ppm.setBuyer_unit_desc(user2.getDept_name());
			}  
			ppm.setPurchase_nocopy(ppm.getPurchase_no());
			List<PurPurchaseM> list = this.getMapper(PurPurchaseMMapper.class)
					.findPurPurchaseM(ppm, startTime, endTime);
			rm.setData(list);
			rm.setState("200");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("查询失败，请联系管理员");
			throw ex;
		}
		return rm;
	}
	/**
	 *报价单——采购信息查询
	 * 
	 * @param oci
	 * @return
	 */
	public ResultModel doQueryQuote(CommonPage<PurPurchaseM> oci) {
		ResultModel rm = new ResultModel();
		PurPurchaseM ppm = oci.getObject();
		String userId = (String) this.getSession().getAttribute(
				HomeService.SESSION_USER_ID);
//		String userName = (String) this.getSession().getAttribute(
//				HomeService.SESSION_USER_NAME);
//		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
		try {
			String sWhere = " 1=1 and  VALIDFLAG>'10' and status='50'";
			User user2=this.getMapper(UserMapper.class).findById(userId);
			if("资材备件科".equals(user2.getDept_name())||"原料科".equals(user2.getDept_name())){
				sWhere += "and buyer_unit_desc like '%" + user2.getDept_name() + "%'";
			} 		
			if(ppm.getPurchase_no()!=null&&!"".equals(ppm.getPurchase_no())){
				sWhere += "and purchase_no like '%" + ppm.getPurchase_no() + "%'";
			}
			if(ppm.getPurchase_desc()!=null&&!"".equals(ppm.getPurchase_desc())){
				sWhere += "and purchase_desc like '%" + ppm.getPurchase_desc() + "%'";
			}
			List<PurPurchaseM> list = this.getMapper(PurPurchaseMMapper.class)
					.findWithCondition(null, sWhere, "create_time desc", 0, 0);
			rm.setData(list);
			rm.setState("200");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("查询失败，请联系管理员");
			throw ex;
		}
		return rm;
	}	
	/**
	 * 采购单信息新增
	 * 
	 * @param oci
	 * @return
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel doAddWeb(CommonPage<PurPurchaseM> oci) 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 (oci.getObjectList() == null || oci.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请传入需新增的数据！");
			return rm;
		}*/
		User user2=this.getMapper(UserMapper.class).findById(userId);
		PurPurchaseM ppm=oci.getObject();
		try {
				String purchase_no = "YG"
						+ new SimpleDateFormat("yyyyMMdd").format(new Date());
				String maxD = this.getMapper(PurPurchaseMMapper.class)
						.findMaxPurchaseNo(purchase_no);
				if (maxD != null && maxD.length() > 4) {
					String seq = maxD.substring(maxD.length() - 4);
					int iseq = Integer.parseInt(seq) + 1;
					purchase_no += String.format("%04d", iseq);
				} else {
					purchase_no += "0001";
				}
				ppm.setBuyer_dept_code(user2.getDept_id());//加入部门
				ppm.setBuyer_dept_desc(user2.getDept_name());
				ppm.setBuyer_unit_code(user2.getDept_id());//资材备件科
				ppm.setBuyer_unit_desc(user2.getDept_name());
				ppm.setPurchase_no(purchase_no);
				ppm.setValidflag("10");// 默认10草稿
				ppm.setStatus("00"); // 默认00代提报
				ppm.setNquiry_status("10");//默认10准备
				ppm.setArchive_flag("0");//默认0未归档
				ppm.setCreate_userid(userId);
				ppm.setCreate_name(userName);
				ppm.setCreate_time(new Date());
				if (ppm.getPurchase_desc()==null && "".equals(ppm.getPurchase_desc())) {
					ppm.setPurchase_desc(purchase_no.substring(2)+ppm.getBpo_mode_name());
				} 
				this.getMapper(PurPurchaseMMapper.class).insert(ppm);
			

			rm.setState("200");
			rm.setMsgInfo("新增成功！");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("新增失败，请联系管理员");
			throw ex;
		}
		return rm;
	}
	/**
	 * 采购单信息提报
	 * 
	 * @param oci
	 * @return
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel upPurDemandM(CommonPage<PurPurchaseM> oci)
			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 (oci.getObjectList() == null || oci.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择数据！");
			return rm;
		}
		try {
			for (PurPurchaseM pdm : oci.getObjectList()) {
				PurPurchaseM pdm2=this.getMapper(PurPurchaseMMapper.class).findById(pdm.getPurchase_no());
				pdm.setRemark(pdm2.getRemark());
				if ("10".equals(pdm2.getValidflag())
						&& ("00".equals(pdm2.getStatus()) || "40".equals(pdm2
								.getStatus()))) {
					// 主表
					pdm2.setStatus("10"); // 暂时提报即审批通过并且生效
					pdm2.setValidflag("20"); // 暂时生效
					pdm2.setUpdate_userid(userId);
					pdm2.setUpdate_name(userName);
					pdm2.setUpdate_time(new Date());
					this.getMapper(PurPurchaseMMapper.class).update(pdm2);
					// 从表
					PurPurchaseC pdc = new PurPurchaseC();
					pdc.setPurchase_no(pdm.getPurchase_no());
					List<PurPurchaseC> pdcList = this.getMapper(
							PurPurchaseCMapper.class).find(pdc, 0, 0);
					if (pdcList.size() > 0) {
						for (PurPurchaseC pDc : pdcList) {
							pDc.setStatus("10"); // 暂时提报即审批通过并且生效
							pDc.setValidflag("20"); // 暂时生效
							pDc.setUpdate_userid(userId);
							pDc.setUpdate_name(userName);
							pDc.setUpdate_time(new Date());
							this.getMapper(PurPurchaseCMapper.class).update(pDc);
						}
					}
				} else {
					rm.setState("500");
					rm.setMsgInfo("提报失败，请联系管理员");
					return rm;
				}
			}

			rm.setState("200");
			rm.setMsgInfo("提报成功！");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("提报失败，请联系管理员");
			throw ex;
		}
		return rm;
	}
	
	/**
	 * 采购单信息提报撤销
	 * 
	 * @param oci
	 * @return
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel disPurPurchaseM(CommonPage<PurPurchaseM> oci)
			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 (oci.getObjectList() == null || oci.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择数据！");
			return rm;
		}
		try {
			for (PurPurchaseM ppm : oci.getObjectList()) {
				PurPurchaseM ppm2=this.getMapper(PurPurchaseMMapper.class).findById(ppm.getPurchase_no());
				ppm.setRemark(ppm2.getRemark());
				if ("20".equals(ppm2.getValidflag())
						&& ("10".equals(ppm2.getStatus()) || "40".equals(ppm2
								.getStatus()))) {
					// 主表
					ppm2.setStatus("00"); // 置为待提报
					ppm2.setValidflag("10"); // 置为草稿状态
					ppm2.setUpdate_userid(userId);
					ppm2.setUpdate_name(userName);
					ppm2.setUpdate_time(new Date());
					this.getMapper(PurPurchaseMMapper.class).update(ppm2);
					// 从表
					PurPurchaseC ppc = new PurPurchaseC();
					ppc.setPurchase_no(ppm.getPurchase_no());
					List<PurPurchaseC> ppcList = this.getMapper(
							PurPurchaseCMapper.class).find(ppc, 0, 0);
					if (ppcList.size() > 0) {
						for (PurPurchaseC ppc2: ppcList) {
							ppc2.setStatus("00"); //  置为待提报
							ppc2.setValidflag("10"); // 置为草稿状态
							ppc2.setUpdate_userid(userId);
							ppc2.setUpdate_name(userName);
							ppc2.setUpdate_time(new Date());
							this.getMapper(PurPurchaseCMapper.class).update(ppc2);
						}
					}
				} else {
					rm.setState("500");
					rm.setMsgInfo("当前数据不能提报撤销！");
					return rm;
				}
			}

			rm.setState("200");
			rm.setMsgInfo("提报撤销成功！");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("提报撤销失败，请联系管理员");
			throw ex;
		}
		return rm;
	}
	
	/**
	 * 采购单信息删除
	 * 
	 * @param oci
	 * @return
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel doDelete(CommonPage<PurPurchaseM> oci) throws Exception {
		ResultModel rm = new ResultModel();
		if (oci.getObjectList() == null || oci.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择数据！");
			return rm;
		}
		try {
			for (PurPurchaseM pdc : oci.getObjectList()) {
				//数据状态无效或草稿状态。审批状态待提报、拒绝、退回。可进行删除操作。
				if (("00".equals(pdc.getValidflag())||"10".equals(pdc.getValidflag()))
						&& ("00".equals(pdc.getStatus()) || "30".equals(pdc
								.getStatus())|| "40".equals(pdc
								.getStatus()))) {
				//采购单信息主表
				this.getMapper(PurPurchaseMMapper.class).delete(pdc.getPurchase_no());	
				//采购单信息从表
				this.getMapper(PurPurchaseCMapper.class).deleteByPurchaseNo(pdc.getPurchase_no());	
				//评标规则表
				PurPurchaseD ppd=new PurPurchaseD();
				ppd.setPurchase_no(pdc.getPurchase_no());
				this.getMapper(PurPurchaseDMapper.class).deleteBidNo(ppd);
				//供应商表
				PurPurchaseE ppe=new PurPurchaseE();
				ppe.setPurchase_no(pdc.getPurchase_no());
				this.getMapper(PurPurchaseEMapper.class).deleteBidNo(ppe);
				//评标人表
				PurPurchaseF  ppf=new  PurPurchaseF();
				ppf.setPurchase_no(pdc.getPurchase_no());
				this.getMapper(PurPurchaseFMapper.class).deletePurPurchaseF(ppf);
				}else{
					rm.setState("500");
					rm.setMsgInfo(pdc.getPurchase_no()+"该数据不能删除！");
					return rm;
				}		
			}
			rm.setState("200");
			rm.setMsgInfo("删除成功！");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("删除失败，请联系管理员");
			throw ex;
		}
		return rm;
	}
	/**
	 * 计划信息审批
	 * 
	 * @param oci
	 * @return
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel appPurPlanM(CommonPage<PurPurchaseM> oci)
			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 (oci.getObjectList() == null || oci.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择数据！");
			return rm;
		}
		String memo1=oci.getMemo1();
		if(memo1==null&&"".equals(memo1)){
			rm.setState("500");
			rm.setMsgInfo("请选择操作！");
			return rm;
		}
		try {
			for (PurPurchaseM ppm2 : oci.getObjectList()) {
				PurPurchaseM pdm=this.getMapper(PurPurchaseMMapper.class).findById(ppm2.getPurchase_no());
				pdm.setRemark(ppm2.getRemark());
				if ("10".equals(pdm.getStatus()) ) {
					if("1".equals(memo1)){
					// 主表
					pdm.setStatus("50"); //审批通过
					pdm.setUpdate_userid(userId);
					pdm.setUpdate_name(userName);
					pdm.setUpdate_time(new Date());
					this.getMapper(PurPurchaseMMapper.class).update(pdm);
					// 从表
					PurPurchaseC pdc = new PurPurchaseC();
					pdc.setPurchase_no(pdm.getPurchase_no());
					List<PurPurchaseC> pdcList = this.getMapper(
							PurPurchaseCMapper.class).find(pdc, 0, 0);
					if (pdcList.size() > 0) {
						for (PurPurchaseC pDc : pdcList) {
							if ("10".equals(pDc.getStatus())) {
							pDc.setStatus("50"); // 审批通过
							pDc.setUpdate_userid(userId);
							pDc.setUpdate_name(userName);
							pDc.setUpdate_time(new Date());
							this.getMapper(PurPurchaseCMapper.class).update(pDc);
							}
						}
					}
					}
					if("2".equals(memo1)){
						// 主表
						pdm.setStatus("40"); //审批退回
						pdm.setUpdate_userid(userId);
						pdm.setUpdate_name(userName);
						pdm.setUpdate_time(new Date());
						this.getMapper(PurPurchaseMMapper.class).update(pdm);
						// 从表
						PurPurchaseC pdc = new PurPurchaseC();
						pdc.setPurchase_no(pdm.getPurchase_no());
						List<PurPurchaseC> pdcList = this.getMapper(
								PurPurchaseCMapper.class).find(pdc, 0, 0);
						if (pdcList.size() > 0) {
							for (PurPurchaseC pDc : pdcList) {
								pDc.setStatus("40"); // 审批退回
								pDc.setUpdate_userid(userId);
								pDc.setUpdate_name(userName);
								pDc.setUpdate_time(new Date());
								this.getMapper(PurPurchaseCMapper.class).update(pDc);
							}
						}
						}
					 if("3".equals(memo1)){
						// 主表
						pdm.setStatus("30"); //审批拒绝
						pdm.setValidflag("00");//数据状态变为无效
						pdm.setUpdate_userid(userId);
						pdm.setUpdate_name(userName);
						pdm.setUpdate_time(new Date());
						this.getMapper(PurPurchaseMMapper.class).update(pdm);
						// 从表
						PurPurchaseC pdc = new PurPurchaseC();
						pdc.setPurchase_no(pdm.getPurchase_no());
						List<PurPurchaseC> pdcList = this.getMapper(
								PurPurchaseCMapper.class).find(pdc, 0, 0);
						if (pdcList.size() > 0) {
							for (PurPurchaseC pDc : pdcList) {
								pDc.setStatus("30"); // 审批拒绝
								pDc.setValidflag("00");//数据状态变为无效
								pDc.setUpdate_userid(userId);
								pDc.setUpdate_name(userName);
								pDc.setUpdate_time(new Date());
								this.getMapper(PurPurchaseCMapper.class).update(pDc);
							}
						}
						}
				} else {
					rm.setState("500");
					rm.setMsgInfo("数据状态不为待审批，请刷新界面！");
					return rm;
				}
			}

			rm.setState("200");
			rm.setMsgInfo("审批成功！");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("审批失败，请联系管理员");
			throw ex;
		}
		return rm;
	}
	
	/**
	 * @author 赵淋支
	 * @date   2018年11月1日
	 * @parameter 
	 * @return 
	 * @description 采购单编制：自动审批
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel doAutoExamPurchaseM(CommonPage<PurPurchaseM> oci)
			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 (oci.getObjectList() == null || oci.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择数据！");
			return rm;
		}
		try {
			Date now = new Date();
			for (PurPurchaseM pdm : oci.getObjectList()) {
				PurPurchaseM pdm2=this.getMapper(PurPurchaseMMapper.class).findById(pdm.getPurchase_no());
				if (pdm2==null) {
					rm.setState("500");
					rm.setMsgInfo("采购单号["+pdm.getPurchase_no()+"]的数据不存在，请重新查询！");
					return rm;
				}
				if ("10".equals(pdm2.getValidflag())
						&& ("00".equals(pdm2.getStatus()))) {
					//草稿+待提报
					// 主表
					PurPurchaseM newPPM = new PurPurchaseM();
					newPPM.setPurchase_no(pdm2.getPurchase_no());//ID
					newPPM.setValidflag("20"); //生效
					newPPM.setStatus("50"); //审批通过
					newPPM.setUpdate_userid(userId);
					newPPM.setUpdate_name(userName);
					newPPM.setUpdate_time(now);
					this.getMapper(PurPurchaseMMapper.class).update(newPPM);
					// 从表
					PurPurchaseC pdc = new PurPurchaseC();
					pdc.setPurchase_no(pdm.getPurchase_no());
					pdc.setValidflag("10");
					pdc.setStatus("00");
					List<PurPurchaseC> pdcList = this.getMapper(
							PurPurchaseCMapper.class).find(pdc, 0, 0);
					if (pdcList!=null && pdcList.size() > 0) {
						for (PurPurchaseC pDc : pdcList) {
							PurPurchaseC newPPC = new PurPurchaseC();
							newPPC.setPurchase_sqe(pDc.getPurchase_sqe());//ID
							newPPC.setValidflag("20"); //生效
							newPPC.setStatus("50"); //审批通过
							newPPC.setUpdate_userid(userId);
							newPPC.setUpdate_name(userName);
							newPPC.setUpdate_time(now);
							this.getMapper(PurPurchaseCMapper.class).update(newPPC);
						}
					}
				} else {
					rm.setState("500");
					rm.setMsgInfo("状态不是待提报，无法自动审批！");
					return rm;
				}
			} 
			rm.setState("200");
			rm.setMsgInfo("自动审批成功！");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("自动审批失败，请联系管理员");
			throw ex;
		}
		return rm;
	}
	
	/**
	 * @author 赵淋支
	 * @date   2018年11月1日
	 * @parameter TODO
	 * @return TODO
	 * @description 采购单编制：撤销审批
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel doAutoCancelExamPurchasenM(CommonPage<PurPurchaseM> oci)
			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 (oci.getObjectList() == null || oci.getObjectList().size() == 0) {
			rm.setState("500");
			rm.setMsgInfo("请选择数据！");
			return rm;
		}
		try {
			Date now = new Date();
			for (PurPurchaseM ppm : oci.getObjectList()) {
				PurPurchaseM ppm2=this.getMapper(PurPurchaseMMapper.class).findById(ppm.getPurchase_no());
				if (ppm2==null) {
					rm.setState("500");
					rm.setMsgInfo("采购单号["+ppm.getPurchase_no()+"]的数据不存在，请重新查询！");
					return rm;
				}				
				if ("20".equals(ppm2.getValidflag())
						&& ("50".equals(ppm2.getStatus()))) {
					int count = this.getMapper(PurInquiryMMapper.class).findIsPurInquiryM(ppm2.getPurchase_no());
					if (count > 0) {
						rm.setState("500");
						rm.setMsgInfo("采购单号["+ppm.getPurchase_no()+"]已经生成报价单数据,无法撤销审批！");
						return rm;
					}
					//生效+审批通过
					// 主表
					PurPurchaseM newPPM = new PurPurchaseM();
					newPPM.setPurchase_no(ppm2.getPurchase_no());//ID
					newPPM.setValidflag("10"); //草稿
					newPPM.setStatus("00"); //待提报
					newPPM.setUpdate_userid(userId);
					newPPM.setUpdate_name(userName);
					newPPM.setUpdate_time(now);
					this.getMapper(PurPurchaseMMapper.class).update(newPPM);
					// 从表
					PurPurchaseC ppc = new PurPurchaseC();
					ppc.setPurchase_no(ppm.getPurchase_no());
					ppc.setValidflag("20");//生效
					ppc.setStatus("50");//审批通过
					List<PurPurchaseC> ppcList = this.getMapper(
							PurPurchaseCMapper.class).find(ppc, 0, 0);
					if (ppcList!=null && ppcList.size() > 0) {
						for (PurPurchaseC ppc2: ppcList) {
							PurPurchaseC newPPC = new PurPurchaseC();
							newPPC.setPurchase_sqe(ppc2.getPurchase_sqe());//ID
							newPPC.setValidflag("10"); //草稿
							newPPC.setStatus("00"); //待提报
							newPPC.setUpdate_userid(userId);
							newPPC.setUpdate_name(userName);
							newPPC.setUpdate_time(now);
							this.getMapper(PurPurchaseCMapper.class).update(newPPC);
						}
					}
				} else {
					rm.setState("500");
					rm.setMsgInfo("状态不是审批通过，无法撤销审批！");
					return rm;
				}
			} 
			rm.setState("200");
			rm.setMsgInfo("撤销审批成功！");
		} catch (Exception ex) {
			rm.setState("500");
			rm.setMsgInfo("撤销审批失败，请联系管理员:"+ex.getMessage());
			throw ex;
		}
		return rm;
	}
	
}
