/***文档注释***********************************************
 * 作者               :                   易鑫
 * 创建日期      :                   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.SlmCustAlphaPhyMapper;
import market.Slm.ContractManagement.service.SlmCustAlphaPhyService;
import market.Slm.ContractManagement.vo.SlmCustAlphaPhy;

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

@RemoteService(path="SlmCustAlphaPhyService")
public class SlmCustAlphaPhyServiceImpl extends BaseServiceImpl<SlmCustAlphaPhy,Object> implements SlmCustAlphaPhyService {
//	/**
//	 * 通过alpha码查询具体的材质要求
//	 * cust_alpha_no
//	 * */
//	public ResultModel doQueryWeb(CommonPage<SlmCustAlphaPhy> sum){
//		ResultModel rm=new ResultModel();
//		SlmCustAlphaPhy chem=sum.getObject();
//		try{
//			List<SlmCustAlphaPhy> list=this.getMapper(SlmCustAlphaPhyMapper.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<SlmCustAlphaPhy> sum){
		ResultModel rm=new ResultModel();
		SlmCustAlphaPhy phy=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);
			phy.setPhy_seq(seq);
			phy.setCreate_no(userId);
			phy.setCreate_name(userName);
			phy.setCreate_time(new Date());
			if(phy.getValidflag()==null)
				phy.setValidflag("1");
			this.getMapper(SlmCustAlphaPhyMapper.class).insert(phy);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("新增失败!"+ex.getMessage());
			ex.printStackTrace();
		}
		return rm;
	}
	
	/**
	 * 材质要求 - 编辑
	 * */
	public ResultModel doUpdateWeb(CommonPage<SlmCustAlphaPhy> sum){
		ResultModel rm=new ResultModel();
		SlmCustAlphaPhy phy=sum.getObject();
		String userId=(String) this.getSession().getAttribute(HomeService.SESSION_USER_ID);
		String userName=(String) this.getSession().getAttribute(HomeService.SESSION_USER_NAME);
		try{
			phy.setUpdate_no(userId);
			phy.setUpdate_name(userName);
			phy.setUpdate_time(new Date());
			this.getMapper(SlmCustAlphaPhyMapper.class).update(phy);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("编辑失败!");
			ex.printStackTrace();
		}
		return rm;
	}
	
	/**
	 * 材质要求 - 详情
	 * */
	public ResultModel doQueryDetailWeb(CommonPage<SlmCustAlphaPhy> sum){
		ResultModel rm=new ResultModel();
		SlmCustAlphaPhy phy=sum.getObject();
		try{
			phy=this.getMapper(SlmCustAlphaPhyMapper.class).findById(phy.getPhy_seq());
			rm.setState("200");
			rm.setData(phy);
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("查询失败!");
			ex.printStackTrace();
		}
		return rm;
	}
}
