/***文档注释***********************************************
 * 作者               :                   易鑫
 * 创建日期      :                   2017.10.24
 * 描述               :        			合同附件信息
 * 注意事项      :                   无
 * 遗留BUG :                   无
 * 修改日期      :                   
 * 修改人员      :                   
 * 修改内容      :                   
***********************************************************/
package market.Slm.ContractManagement.impl;

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

import market.Com.pb.PbMethod;
import market.Com.vo.ResultModel;
import market.Slm.ContractManagement.mapper.SlmContractAnnexMapper;
import market.Slm.ContractManagement.service.SlmContractAnnexService;
import market.Slm.ContractManagement.vo.SlmContractAnnex;

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

@RemoteService(path="SlmContractAnnexService")
public class SlmContractAnnexServiceImpl extends BaseServiceImpl<SlmContractAnnex,Object> implements SlmContractAnnexService {

	/**
	 * 新增
	 * */
	public ResultModel doAddWeb(SlmContractAnnex annex){
		ResultModel rm=new ResultModel();
		try{
			String date=new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
			String annex_no=date+PbMethod.RandomCreate(3);
			annex.setAnnex_no(annex_no);
			if(annex.getContract_no()==null||"".equals(annex.getContract_no())){
				annex.setContract_no(new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+PbMethod.RandomCreate(3));
			}
			this.getMapper(SlmContractAnnexMapper.class).insert(annex);
			rm.setState("200");
			rm.setData(annex);
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
		}
		return rm;
	}
	
	/**
	 * 删除
	 * */
	public ResultModel doDeleteWeb(SlmContractAnnex annex){
		ResultModel rm=new ResultModel();
		try{
			this.getMapper(SlmContractAnnexMapper.class).delete(annex.getAnnex_no());
			rm.setState("200");
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
		}
		return rm;
	}
	
	/**
	 * 查询
	 * */
	public ResultModel doQueryWeb(SlmContractAnnex annex){
		ResultModel rm=new ResultModel();
		try{
			List<SlmContractAnnex> list=this.getMapper(SlmContractAnnexMapper.class).findWithCondition(annex, null, " annex_no desc", 0, 0);
			rm.setData(list);
			rm.setState("200");
		}catch(Exception e){
			rm.setState("500");
			rm.setMsgInfo(e.getMessage());
		}
		return rm;
	}
}