/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2019-01-02
 * 描述            ：质量设计-制程设定信息表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.Qms.slmord.impl;
import java.util.List;

import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Qms.slmord.mapper.SlmOrdDesignMscSetProcMapper;
import market.Qms.slmord.service.SlmOrdDesignMscSetProcService;
import market.Qms.slmord.vo.SlmOrdDesignMscSetProc;

import org.springframework.transaction.annotation.Transactional;

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

@RemoteService(path="SlmOrdDesignMscSetProcService")
public class SlmOrdDesignMscSetProcServiceImpl extends BaseServiceImpl<SlmOrdDesignMscSetProc,Object> implements SlmOrdDesignMscSetProcService {




	/**
	 * 指定制程
	 * @throws Exception 
	 */
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel surePline(CommonPage<SlmOrdDesignMscSetProc> com) throws Exception {
		ResultModel rm=new ResultModel();
		try {
			List<SlmOrdDesignMscSetProc> sns=com.getObjectList();
			if (sns==null || sns.size()<1) {
				rm.setState("500");
				rm.setMsgInfo("请传入参数");
				return rm;
				
			}
			SlmOrdDesignMscSetProcMapper mapper=this.getMapper(SlmOrdDesignMscSetProcMapper.class);
			if (sns.get(0).getContract_line_no()==null || "".equals(sns.get(0).getContract_line_no())) {
				rm.setState("500");
				rm.setMsgInfo("请传入合同行主键");
				return rm;
			}
			
			mapper.deleteByContract(sns.get(0).getContract_line_no());
			
			for (SlmOrdDesignMscSetProc sn : sns) {
				
				if (sn.getContract_line_no()==null || "".equals(sn.getContract_line_no())) {
					rm.setState("500");
					rm.setMsgInfo("请传入合同行主键");
					return rm;
				}
					
				this.getMapper(SlmOrdDesignMscSetProcMapper.class).insert(sn);
					
			}
			rm.setMsgInfo("制程指定成功");
			rm.setState("200");
		} catch (Exception e) {
			rm.setState("500");
			rm.setMsgInfo("指定制程失败");
			throw new Exception(rm.getMsgInfo());
		}
		
		
		
		return rm;
		
		
		
		
		
	}



	
	@Transactional(value = "tm", rollbackFor = Exception.class)
	public ResultModel deleteSurePline(CommonPage<SlmOrdDesignMscSetProc> com) throws Exception {
		ResultModel rm=new ResultModel();
		try {
			SlmOrdDesignMscSetProc sn=com.getObject();
			if (sn==null) {
				rm.setState("500");
				rm.setMsgInfo("请传入参数");
				return rm;
				
			}
			
			if (sn.getContract_line_no()==null || "".equals(sn.getContract_line_no())) {
				rm.setState("500");
				rm.setMsgInfo("请传入合同行主键");
				return rm;
			}
			
			this.getMapper(SlmOrdDesignMscSetProcMapper.class).deleteByContract(sn.getContract_line_no());
			
			rm.setMsgInfo("制程指定删除成功");
			rm.setState("200");
		} catch (Exception e) {
			rm.setState("500");
			rm.setMsgInfo("指定制程删除失败");
			throw new Exception(rm.getMsgInfo());
		}
		
		
		
		return rm;
		
		
		
		
		
	}
	




}
