/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2018-01-30
 * 描述            ：质量设计-附加要求表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.Qms.slmord.impl;
import java.util.ArrayList;
import java.util.List;

import market.Com.vo.CommonPage;
import market.Com.vo.ResultModel;
import market.Qms.common.DataHelper;
import market.Qms.metallurgy.mapper.ComBaseAskRStationMapper;
import market.Qms.metallurgy.vo.ComBaseAskRStation;
import market.Qms.slmord.mapper.SlmOrdDesignAdditionalMapper;
import market.Qms.slmord.service.SlmOrdDesignAdditionalService;
import market.Qms.slmord.vo.SlmOrdDesignAdditional;
import market.Qms.slmord.vo.SlmOrdDesignMscPlSti;

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

@RemoteService(path="SlmOrdDesignAdditionalService")
public class SlmOrdDesignAdditionalServiceImpl extends BaseServiceImpl<SlmOrdDesignAdditional,Object> implements SlmOrdDesignAdditionalService {
	
	/**
	 * 获取附加要求设计结果
	 * @param designKey
	 * @return
	 */
	public ResultModel GetSlmOrdDesignAddAsk(String designKey){
		ResultModel rm=new ResultModel("200", "获取数据成功");
		try{
			SlmOrdDesignAdditional _add=new SlmOrdDesignAdditional();
			_add.setDesign_key(designKey);
			List<SlmOrdDesignAdditional> listAdd=this.getMapper(SlmOrdDesignAdditionalMapper.class).GetSlmOrdDesignAddAsk(_add.getDesign_key());
			rm.setData(listAdd);
			rm.setState("200");
			rm.setMsgInfo("获取数据成功");
		}catch(Exception ex){
			rm.setMsgInfo("获取附加要求设计结果失败");
			rm.setErrorInfo(ex.getMessage());
			rm.setState("500");
		}
		return rm;
	}
	
	
	/**
	 * 获取工序点关联附加要求项
	 * @param com
	 * @return
	 */
	public ResultModel GetAllByPlan(CommonPage<SlmOrdDesignMscPlSti> com){
		ResultModel rm=new ResultModel();
		try{
			SlmOrdDesignMscPlSti sti=com.getObject();
			List<SlmOrdDesignAdditional> listAdd=new ArrayList<>();
			if(DataHelper.IsNullOrSpace(sti.getProcess_point_code())){
				rm.setState("404");
				rm.setMsgInfo("工序点不能为空");
				return rm;
			}
			ComBaseAskRStation _station=new ComBaseAskRStation();
			_station.setProcess_point_code(sti.getProcess_point_code());
			List<ComBaseAskRStation> listStation=this.getMapper(ComBaseAskRStationMapper.class).find(_station, 0, 0);
			List<String> addS=new ArrayList<>();
			for (ComBaseAskRStation comBaseAskRStation : listStation) {
				addS.add(comBaseAskRStation.getAsk_sub_itme());
			}
			if(addS.size()<1){
				rm.setState("404");
				rm.setMsgInfo("没有与该工序点关联的附加要求项");
				return rm;
			}
			String condition=DataHelper.CreateSqlCondition(addS, "ASK_ITEM");
			listAdd=this.getMapper(SlmOrdDesignAdditionalMapper.class).findWithCondition(null, condition, null, 0, 0);
			rm.setData(listAdd);
			rm.setState("200");
		}catch(Exception ex){
			rm.setState("500");
			rm.setMsgInfo("获取附加要求项出错："+ex.getMessage());
		}
		return rm;
	}
}
