package com.cim.idm.mwmsextend.materialpackingoqaresult.service;
import java.util.List;
import com.cim.idm.framework.IDMFrameServiceProxy;
import com.cim.idm.wmspackage.materialpacking.MaterialPackingServiceProxy;
import com.cim.idm.wmspackage.materialpacking.management.data.MaterialPacking;

public class OQAResultUtil {

	public List<MaterialPacking> GetOQAPackingList(String mpgroupName){
		
		String condition = "WHERE MATERIALPROCESSGROUPNAME = ? AND (NPFLAG='N' or NPFLAG IS NULL) ";
		Object[] bindSet = {mpgroupName};		
		List<MaterialPacking> oqaList = MaterialPackingServiceProxy.getMaterialPackingService().select(condition, bindSet); 
		return oqaList;
	}
	
	public List<MaterialPacking> GetNoPOOQAPackingList(String mpgroupName){
		
		String condition = "WHERE MATERIALPROCESSGROUPNAME = ? AND (NPFLAG='Y' or NPFLAG IS NULL) ";
		Object[] bindSet = {mpgroupName};		
		List<MaterialPacking> oqaList = MaterialPackingServiceProxy.getMaterialPackingService().select(condition, bindSet); 
		return oqaList;
	}
	
	public List<MaterialPacking> GetNPOQAPackingList(String mpgroupName){
		
		String condition = "WHERE MATERIALPROCESSGROUPNAME = ? AND NPFLAG='Y'";
		Object[] bindSet = {mpgroupName};		
		List<MaterialPacking> oqaList = MaterialPackingServiceProxy.getMaterialPackingService().select(condition, bindSet); 
		return oqaList;
	}
	
	public double GetOQAOKResult(String siteName,String mpgroupName){
		
		String strsql = "SELECT SUM(MATERIALQUANTITY) FROM MATERIALPACKING t where t.OQARESULT='OK'\n"+
				" and ERPFACTORYNAME= ?\n"+
				" and MATERIALPROCESSGROUPNAME = ?";
		Object[] bindSet = new Object[] {siteName, mpgroupName };
		double	result= IDMFrameServiceProxy.getSqlTemplate().queryForObject(strsql,double.class, bindSet);
		return result;
	}
	
	public double GetOQANGResult(String siteName,String mpgroupName){
		
		String strsql = "SELECT SUM(MATERIALQUANTITY) FROM MATERIALPACKING t where t.OQARESULT='NG'\n"+
				" and ERPFACTORYNAME= ?\n"+
				" and MATERIALPROCESSGROUPNAME = ?";
		Object[] bindSet = new Object[] {siteName, mpgroupName };
		double	result= IDMFrameServiceProxy.getSqlTemplate().queryForObject(strsql, Double.class, bindSet);
		return result;
	}
}
