/***文档注释***********************************************
 * 作者            ：
 * 创建日期     ：2018-06-04
 * 描述            ：炼钢牌号适用生产产线表
 * 注意事项     ：
 * 遗留BUG   ：
 * 修改日期     ：
 * 修改人员     ：
 * 修改内容     ：
***********************************************************/
package market.Qms.metallurgy.impl;
import java.util.Date;
import java.util.List;

import market.Qms.metallurgy.mapper.ComBaseGradeRPlineMapper;
import market.Qms.metallurgy.service.ComBaseGradeRPlineService;
import market.Qms.metallurgy.vo.ComBaseGradeRPline;

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

@RemoteService(path = "ComBaseGradeRPlineService")
public class ComBaseGradeRPlineServiceImpl extends BaseServiceImpl<ComBaseGradeRPline,Object> implements ComBaseGradeRPlineService {
	
	public boolean doSaveGradeRPlinexz(List<ComBaseGradeRPline> Plines,String grade_code){
		boolean count=false;
		String userName=(String) this.getSession().getAttribute(HomeService.SESSION_USER_NAME);
		try {
			this.getMapper(ComBaseGradeRPlineMapper.class).doDelete(grade_code);
			if (Plines != null) {
				for (ComBaseGradeRPline comBaseGradeRPline : Plines) {
					if (comBaseGradeRPline.getCreate_time() != null) {
						comBaseGradeRPline.setUpdate_name(userName);
						comBaseGradeRPline.setUpdate_time(new Date());
						comBaseGradeRPline.setGrade_code(grade_code);
						this.getMapper(ComBaseGradeRPlineMapper.class).insert(comBaseGradeRPline);
						count=true;
					}else {
						comBaseGradeRPline.setCreate_name(userName);
						comBaseGradeRPline.setCreate_time(new Date());
						comBaseGradeRPline.setValidflag("1");
						comBaseGradeRPline.setGrade_code(grade_code);
						this.getMapper(ComBaseGradeRPlineMapper.class).insert(comBaseGradeRPline);
						count=true;
					}
				}
			}
		} catch (Exception e) {
			count=false;
			e.printStackTrace();
		}
		return count;
	}
}
