/***文档注释***********************************************
 * 作者               :                   易鑫
 * 创建日期      :                   2017.10.24
 * 描述               :        			探伤要求表
 * 注意事项      :                   无
 * 遗留BUG :                   无
 * 修改日期      :                   
 * 修改人员      :                   
 * 修改内容      :                   
***********************************************************/
package market.Slm.ContractManagement.impl;

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

import market.Com.pb.PbMethod;
import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Slm.ContractManagement.mapper.SlmCustAlphaDetectionMapper;
import market.Slm.ContractManagement.service.SlmCustAlphaDetectionService;
import market.Slm.ContractManagement.vo.SlmCustAlphaDetection;

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

@RemoteService(path="SlmCustAlphaDetectionService")
public class SlmCustAlphaDetectionServiceImpl extends BaseServiceImpl<SlmCustAlphaDetection,Object> implements SlmCustAlphaDetectionService {
	
//	/**
//	 * 通过alpha码查询具体的探伤要求
//	 * cust_alpha_no
//	 * */
//	public ResultModel doQueryWeb(CommonPage<SlmCustAlphaDetection> sum){
//		ResultModel rm=new ResultModel();
//		SlmCustAlphaDetection chem=sum.getObject();
//		try{
//			List<SlmCustAlphaDetection> list=this.getMapper(SlmCustAlphaDetectionMapper.class).find(chem, 0, 0);
//			rm.setState("200");
//			rm.setData(list);
//		}catch(Exception ex){
//			rm.setState("500");
//			rm.setMsgInfo("查询失败!");
//			ex.printStackTrace();
//		}
//		return rm;
//	}
	
	/**
	 * 探伤要求 - 新增
	 * */
	public ResultModel doAddWeb(CommonPage<SlmCustAlphaDetection> sum){
		ResultModel rm=new ResultModel();
		SlmCustAlphaDetection detection=sum.getObject();
		String userId=(String) this.getSession().getAttribute(HomeService.SESSION_USER_ID);
		String userName=(String) this.getSession().getAttribute(HomeService.SESSION_USER_NAME);
		try{
			String seq=new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+PbMethod.RandomCreate(3);
			detection.setDetection_seq(seq);
			detection.setCreate_no(userId);
			detection.setCreate_name(userName);
			detection.setCreate_time(new Date());
			if(detection.getValidflag()==null)
				detection.setValidflag("1");
			this.getMapper(SlmCustAlphaDetectionMapper.class).insert(detection);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("新增失败!");
			ex.printStackTrace();
		}
		return rm;
	}
	
	/**
	 * 探伤要求 - 编辑
	 * */
	public ResultModel doUpdateWeb(CommonPage<SlmCustAlphaDetection> sum){
		ResultModel rm=new ResultModel();
		SlmCustAlphaDetection detection=sum.getObject();
		String userId=(String) this.getSession().getAttribute(HomeService.SESSION_USER_ID);
		String userName=(String) this.getSession().getAttribute(HomeService.SESSION_USER_NAME);
		try{
			detection.setUpdate_no(userId);
			detection.setUpdate_name(userName);
			detection.setUpdate_time(new Date());
			this.getMapper(SlmCustAlphaDetectionMapper.class).update(detection);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("编辑失败!");
			ex.printStackTrace();
		}
		return rm;
	}
	
	/**
	 * 探伤要求 - 详情
	 * */
	public ResultModel doQueryDetailWeb(CommonPage<SlmCustAlphaDetection> sum){
		ResultModel rm=new ResultModel();
		SlmCustAlphaDetection detection=sum.getObject();
		try{
			detection=this.getMapper(SlmCustAlphaDetectionMapper.class).findById(detection.getDetection_seq());
			rm.setState("200");
			rm.setData(detection);
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("查询失败!");
			ex.printStackTrace();
		}
		return rm;
	}
}
