/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2018-01-30
 * 描述            ：质量设计-制程-工序适用产线
 * 注意事项     ：
 * 遗留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.SlmOrdDesignMscPlGxPrlMapper;
import market.Qms.slmord.mapper.SlmOrdDesignMscPlStiMcMapper;
import market.Qms.slmord.mapper.SlmOrdDesignMscTicMapper;
import market.Qms.slmord.service.SlmOrdDesignMscPlGxPrlService;
import market.Qms.slmord.vo.SlmOrdDesignMscPlGxPrl;

import org.springframework.transaction.annotation.Transactional;

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

@RemoteService(path="SlmOrdDesignMscPlGxPrlService")
public class SlmOrdDesignMscPlGxPrlServiceImpl extends BaseServiceImpl<SlmOrdDesignMscPlGxPrl,Object> implements SlmOrdDesignMscPlGxPrlService {
	
	@Transactional(value="tm",rollbackFor=Exception.class)
	public ResultModel DelOrdDesignPrl(List<SlmOrdDesignMscPlGxPrl> listPrl){
		ResultModel rm=new ResultModel("200","删除成功");
		SlmOrdDesignMscPlGxPrlMapper prlMapper=this.getMapper(SlmOrdDesignMscPlGxPrlMapper.class);
		SlmOrdDesignMscPlGxPrl _prl=new SlmOrdDesignMscPlGxPrl();
		_prl.setDesign_key(listPrl.get(0).getDesign_key());
		_prl.setMsc_pline(listPrl.get(0).getMsc_pline());
		_prl.setProcess_code(listPrl.get(0).getProcess_code());
		List<SlmOrdDesignMscPlGxPrl> list=prlMapper.find(_prl, 0, 0);
		if(listPrl.size()>=list.size()){
			rm.setState("500");
			rm.setMsgInfo("不能删除全部适用产线");
			return rm;
		}
		for (SlmOrdDesignMscPlGxPrl prl : listPrl) {
			this.getMapper(SlmOrdDesignMscPlGxPrlMapper.class).DelOrdDesignMscPrl(prl.getDesign_key(), prl.getMsc_pline(), prl.getProcess_code(), prl.getPline_code());
			this.getMapper(SlmOrdDesignMscPlStiMcMapper.class).DePlineStiMc(prl.getDesign_key(), prl.getMsc_pline(), prl.getProcess_code(), prl.getPline_code());
			this.getMapper(SlmOrdDesignMscTicMapper.class).DelOrdDesignPlineTic(prl.getDesign_key(), prl.getMsc_pline(), prl.getProcess_code(), prl.getPline_code());
			//下面表设计有问题，不能删除
			//this.getMapper(SlmOrdDesignMscTicItemMapper.class)
		}	
		return rm;
	}
	
	
	public ResultModel GetOrdDesignPrl(CommonPage<SlmOrdDesignMscPlGxPrl> com){
		ResultModel rm=new ResultModel();
		try{
			List<SlmOrdDesignMscPlGxPrl> listPrl =this.getMapper(SlmOrdDesignMscPlGxPrlMapper.class).find(com.getObject(), 0, 0);
			rm.setData(listPrl);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("获取工序适用产线失败："+ex.getMessage());
		}
		return rm;
	}
	
}
