/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2019-09-04
 * 描述            ：判定原因汇总表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.Qms.qcm.service.impl;
import java.util.ArrayList;
import java.util.List;

import market.Com.vo.ResultModel;
import market.Qms.common.DataHelper;
import market.Qms.qcm.mapper.QcmJudgeUltimateReasonMapper;
import market.Qms.qcm.service.QcmJudgeUltimateReasonService;
import market.Qms.qcm.vo.QcmJudgeUltimateReason;

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

@RemoteService(path="QcmJudgeUltimateReasonService")
public class QcmJudgeUltimateReasonServiceImpl extends BaseServiceImpl<QcmJudgeUltimateReason,Object> implements QcmJudgeUltimateReasonService {
	public ResultModel createUltimateReason (List<QcmJudgeUltimateReason> qjuList) {
		ResultModel rm = new ResultModel();
		rm.setState("200");
		for(QcmJudgeUltimateReason qju:qjuList) {
			if(DataHelper.IsNullOrSpace(qju.getMaterial_no())) {
				rm.setMsgInfo("请传入虚拟产品序号");
				rm.setState("403");
				return rm;
			}
			if(DataHelper.IsNullOrSpace(qju.getType_code())) {
				rm.setMsgInfo("请传入类型代码");
				rm.setState("403");
				return rm;
			}
			if(DataHelper.IsNullOrSpace(qju.getRecord_id())) {
				rm.setMsgInfo("请传入记录ID");
				rm.setState("403");
				return rm;
			}
			if(DataHelper.IsNullOrSpace(qju.getPhy_code_s())) {
				rm.setMsgInfo("请传入检验项代码");
				rm.setState("403");
				return rm;
			}
			if(DataHelper.IsNullOrSpace(qju.getPhy_name_s())) {
				rm.setMsgInfo("请传入检验项名称");
				rm.setState("403");
				return rm;
			}
		}
		this.getMapper(QcmJudgeUltimateReasonMapper.class).insertBatch(qjuList);
		return rm;
	}
	public List<String> getAllreson(String material_no){
		List<String> strList = new ArrayList<String>();
		String strG= "钢制缺陷";
		String strZ= "轧制缺陷";
		List<QcmJudgeUltimateReason> qjurList= this.getMapper(QcmJudgeUltimateReasonMapper.class).getAllReson(material_no);
		for(QcmJudgeUltimateReason qjur: qjurList) {
			if("408301".equals(qjur.getDefect_type_code())) {
				strG += qjur.getPhy_name_s();
			}else if("408302".equals(qjur.getDefect_type_code())) {
				strZ += qjur.getPhy_name_s();
			}
		}
		strList.add(strG);
		strList.add(strZ);
		return strList;
	}
}
