# EquipmentConstrainRowMapper.java

    package com.mycim.server.constrain.dao.mapper;

    import com.mycim.framework.jdbc.mapper.RowMapper;
    import com.mycim.framework.utils.lang.StringUtils;
    import com.mycim.framework.utils.lang.time.DateUtils;
    import com.mycim.valueobject.prp.EquipmentConstrainInfo;

    import java.sql.ResultSet;
    import java.sql.SQLException;

    /**
     * @author andy
     */
    public final class EquipmentConstrainRowMapper implements RowMapper<EquipmentConstrainInfo> {

        @Override
        public EquipmentConstrainInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
            EquipmentConstrainInfo equipmentConstrainInfo = new EquipmentConstrainInfo();
            equipmentConstrainInfo.setFacilityRrn(new Long(rs.getLong("FACILITY_RRN")));
            equipmentConstrainInfo.setConstrainRrn(rs.getLong("CONSTRAIN_RRN"));
            equipmentConstrainInfo.setProductId(
                    StringUtils.equals(rs.getString("PRODUCT_ID"), EquipmentConstrainInfo.SPECIAL) ? "" : rs
                            .getString("PRODUCT_ID"));
            equipmentConstrainInfo.setProcessId(
                    StringUtils.equals(rs.getString("PROCESS_ID"), EquipmentConstrainInfo.SPECIAL) ? "" : rs
                            .getString("PROCESS_ID"));
            equipmentConstrainInfo.setOperationId(
                    StringUtils.equals(rs.getString("OPERATION_ID"), EquipmentConstrainInfo.SPECIAL) ? "" : rs
                            .getString("OPERATION_ID"));
            equipmentConstrainInfo.setRecipeId(
                    StringUtils.equals(rs.getString("RECIPE_ID"), EquipmentConstrainInfo.SPECIAL) ? "" : rs
                            .getString("RECIPE_ID"));
            equipmentConstrainInfo.setLotId(
                    StringUtils.equals(rs.getString("LOT_ID"), EquipmentConstrainInfo.SPECIAL) ? "" : rs
                            .getString("LOT_ID"));
            equipmentConstrainInfo.setEquipmentId(rs.getString("EQUIPMENT_ID"));
            equipmentConstrainInfo.setConstrainAction(rs.getString("CONSTRAIN_ACTION"));
            equipmentConstrainInfo.setConstrainType(rs.getString("CONSTRAIN_TYPE"));
            equipmentConstrainInfo.setConstrainStatus(rs.getString("CONSTRAIN_STATUS"));
            equipmentConstrainInfo.setRemark(rs.getString("REMARK"));
            equipmentConstrainInfo.setCreateBy(rs.getString("CREATE_BY"));
            equipmentConstrainInfo.setModifyBy(rs.getString("MODIFY_BY"));
            equipmentConstrainInfo.setCreateTime(rs.getTimestamp("CREATE_TIME"));
            equipmentConstrainInfo.setModifyTime(rs.getTimestamp("MODIFY_TIME"));
            equipmentConstrainInfo.setATTRIBUTE_DATA1(rs.getString("ATTRIBUTE_DATA1"));
            equipmentConstrainInfo.setATTRIBUTE_DATA2(rs.getString("ATTRIBUTE_DATA2"));
            equipmentConstrainInfo.setATTRIBUTE_DATA3(rs.getString("ATTRIBUTE_DATA3"));
            equipmentConstrainInfo.setATTRIBUTE_DATA4(rs.getString("ATTRIBUTE_DATA4"));
            equipmentConstrainInfo.setATTRIBUTE_DATA5(rs.getString("ATTRIBUTE_DATA5"));
            equipmentConstrainInfo.setConstrainSeq(rs.getString("CONSTRAIN_SEQ"));
            equipmentConstrainInfo.setRouteId(rs.getString("ROUTE_ID"));
            equipmentConstrainInfo.setStageId(rs.getString("STAGE_ID"));
            equipmentConstrainInfo.setDailyWaferCount(rs.getInt("DAILY_WAFER_COUNT"));
            equipmentConstrainInfo.setTotalWaferCount(rs.getInt("TOTAL_WAFER_COUNT"));
            equipmentConstrainInfo.setCustomerId(rs.getString("CUSTOMER_ID"));

            String expireDate = rs.getString("EXPIRE_DATE");
            if (StringUtils.isNotBlank(expireDate)) {
                if (expireDate.indexOf(".") > -1) {
                    expireDate = expireDate.substring(0, expireDate.indexOf("."));
                }
                equipmentConstrainInfo.setExpireDate(expireDate);
                String[] dates = expireDate.split(" ");

                if (dates != null && dates.length == 2) {
                    equipmentConstrainInfo.setExpireDates(dates[0]);
                    equipmentConstrainInfo.setExpireTime(dates[1]);
                }
            }
            String effectiveDate = rs.getString("EFFECTIVE_DATE");
            if (StringUtils.isNotBlank(effectiveDate)) {
                if (effectiveDate.indexOf(".") > -1) {
                    effectiveDate = effectiveDate.substring(0, effectiveDate.indexOf("."));
                }
                equipmentConstrainInfo.setEffectiveDate(effectiveDate);
            }

            equipmentConstrainInfo.setParentEquipmentId(rs.getString("PARENT_EQUIPMENT_ID"));
            equipmentConstrainInfo.setParentEquipmentRrn(rs.getLong("PARENT_EQUIPMENT_RRN"));
            equipmentConstrainInfo.setLotType(rs.getString("LOT_TYPE"));
            equipmentConstrainInfo.setEqpGroupId(rs.getString("EQPGROUP_ID"));
            equipmentConstrainInfo.setLotPriority(rs.getString("LOT_PRIORITY"));
            equipmentConstrainInfo.setInternalPriority(rs.getString("INTERNAL_PRIORITY"));
            equipmentConstrainInfo.setDailyLotCount(rs.getInt("DAILY_LOT_COUNT"));
            equipmentConstrainInfo.setTotalLotCount(rs.getInt("TOTAL_LOT_COUNT"));
            equipmentConstrainInfo
                    .setAutoSwitchTimeInterval(DateUtils.formatDateForSeconds(rs.getLong("AUTO_SWITCH_TIME_INTERVAL")));

            equipmentConstrainInfo.setExceptProductId(rs.getString("EXCEPT_PRODUCT_ID"));
            equipmentConstrainInfo.setExceptProcessId(rs.getString("EXCEPT_PROCESS_ID"));
            equipmentConstrainInfo.setExceptLotId(rs.getString("EXCEPT_LOT_ID"));
            equipmentConstrainInfo.setExceptOperationId(rs.getString("EXCEPT_OPERATION_ID"));
            equipmentConstrainInfo.setExceptStageId(rs.getString("EXCEPT_STAGE_ID"));
            equipmentConstrainInfo.setExceptRecipeId(rs.getString("EXCEPT_RECIPE_ID"));
            equipmentConstrainInfo.setExceptCustomerId(rs.getString("EXCEPT_CUSTOMER_ID"));
            equipmentConstrainInfo.setExceptLotType(rs.getString("EXCEPT_LOT_TYPE"));
            equipmentConstrainInfo.setExceptLotPriority(rs.getString("EXCEPT_LOT_PRIORITY"));
            equipmentConstrainInfo.setExceptInternalPriority(rs.getString("EXCEPT_INTERNAL_PRIORITY"));
            equipmentConstrainInfo.setExceptEqpGroupId(rs.getString("EXCEPT_EQPGROUP_ID"));
            equipmentConstrainInfo.setQeFlag(rs.getString("QE_FLAG"));
            return equipmentConstrainInfo;
        }

    }