/***文档注释***********************************************
 * 作者               :                   易鑫
 * 创建日期      :                   2018.2.5
 * 描述               :        			试样组适用标准
 * 注意事项      :                   无
 * 遗留BUG :                   无
 * 修改日期      :                   
 * 修改人员      :                   
 * 修改内容      :                   
***********************************************************/
package market.Com.impl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import market.Com.mapper.ComBaseSampleRStdMapper;
import market.Com.service.ComBaseSampleRStdService;
import market.Com.vo.ComBaseSampleRStd;
import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;

import org.springframework.transaction.annotation.Transactional;

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

@RemoteService(path="ComBaseSampleRStdService")
public class ComBaseSampleRStdServiceImpl extends BaseServiceImpl<ComBaseSampleRStd,Object> implements ComBaseSampleRStdService  {
	
	/**
	 *  保存功能
	 * @param sum
	 * @return
	 * @throws ParseException 
	 */
	@Transactional(value="tm", rollbackFor=Exception.class)
	public ResultModel doAddStd(CommonPage<ComBaseSampleRStd> sum) throws ParseException {
		ResultModel rm =new ResultModel();
		ComBaseSampleRStd std =sum.getObject();
		//当前时间为创建时间
		SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmssSSS");
		Date time =null;
		time= sdf.parse(sdf.format(new Date()));
		std.setCreate_time(time);
		std.setValidflag("1");
		ComBaseSampleRStd Rstd =this.getMapper(ComBaseSampleRStdMapper.class).findById(std.getSmp_index());
		if (Rstd!=null) {
			this.getMapper(ComBaseSampleRStdMapper.class).delete(Rstd.getSmp_index());
		}
		this.getMapper(ComBaseSampleRStdMapper.class).insert(std);
		rm.setState("200");
		return rm;
	}

}
