package cn.com.qmth.stmms.ms.marking.assembler;

import java.math.BigDecimal;
import java.math.BigInteger;

import cn.com.qmth.stmms.ms.marking.dto.LevelStatDTO;
import org.springframework.stereotype.Component;


/**
 * Created by zhengmin on 2016/10/14.
 */
@Component
public class LevelStatAssembler {

    public LevelStatDTO toDTO(Object[] levelStats){
        LevelStatDTO levelStatDTO = null;
        if(levelStats != null){
            levelStatDTO = new LevelStatDTO();
            levelStatDTO.setId(levelStats[0]);
            BigInteger count = new BigInteger(String.valueOf(levelStats[1]));
            levelStatDTO.setCount(count.intValue());
            if(levelStats.length>2){
            	BigDecimal rejected =(BigDecimal) levelStats[2];
            	levelStatDTO.setRejected(rejected.intValue());
            }
            if(levelStats.length>3){
            	BigDecimal arbitrated =(BigDecimal) levelStats[3];
            	levelStatDTO.setArbitrated(arbitrated.intValue());
            }
            if(levelStats.length>4){
                BigDecimal shift =(BigDecimal) levelStats[4];
                levelStatDTO.setShift(shift.intValue());
            }
            if(levelStats.length>5){
                BigDecimal shiftScore =(BigDecimal) levelStats[5];
                levelStatDTO.setShiftScore(shiftScore.intValue());
            }
        }
        return levelStatDTO;
    }

    public LevelStatDTO toScoreDTO(Object[] levelStats){
        LevelStatDTO levelStatDTO = null;
        if(levelStats != null){
            levelStatDTO = new LevelStatDTO();
            BigInteger count = new BigInteger(String.valueOf(levelStats[0]));
            levelStatDTO.setCount(count.intValue());
            if(levelStats.length>1){
                BigDecimal rejected =(BigDecimal) levelStats[1];
                levelStatDTO.setRejected(rejected.intValue());
            }
            if(levelStats.length>2){
                BigDecimal arbitrated =(BigDecimal) levelStats[2];
                levelStatDTO.setArbitrated(arbitrated.intValue());
            }
            if(levelStats.length>3){
                BigDecimal shift =(BigDecimal) levelStats[3];
                levelStatDTO.setShift(shift.intValue());
            }
            if(levelStats.length>4){
                BigDecimal shiftScore =(BigDecimal) levelStats[4];
                levelStatDTO.setShiftScore(shiftScore.intValue());
            }
        }
        return levelStatDTO;
    }
}
