ContextTempImportRowMapper.java

package com.mycim.server.spec.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 java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author shijie.deng
 * @version 6.0.0
 * @date 2019/9/8
 **/
public class ContextTempImportRowMapper implements RowMapper<Map<String, Object>> {

    @Override
    public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
        Map<String, Object> m = new HashMap<String, Object>();

        m.put("productId", rs.getString("PRODUCT_ID"));
        m.put("productRrn", rs.getLong("PRODUCT_RRN"));
        m.put("processId", rs.getString("PROCESS_ID"));
        m.put("processRrn", rs.getLong("PROCESS_RRN"));
        m.put("processVersion", rs.getInt("PROCESS_VERSION"));
        m.put("processStatus", rs.getString("PROCESS_STATUS"));
        m.put("routeSeq", rs.getString("ROUTE_SEQ") == null ? StringUtils.EMPTY : rs.getString("ROUTE_SEQ"));
        m.put("routeId", rs.getString("ROUTE_ID"));
        m.put("routeRrn", rs.getLong("ROUTE_RRN"));
        m.put("operationSeq",
              rs.getString("OPERATION_SEQ") == null ? StringUtils.EMPTY : rs.getString("OPERATION_SEQ"));
        m.put("operationId", rs.getString("OPERATION_ID"));
        m.put("operationType", rs.getString("OPERATION_TYPE"));
        m.put("workArea", rs.getString("WORK_AREA") == null ? StringUtils.EMPTY : rs.getString("WORK_AREA"));
        m.put("orderOperationSeq", rs.getString("FLOW_SEQ") == null ? StringUtils.EMPTY : rs.getString("FLOW_SEQ"));
        m.put("operationDesc", rs.getString("OPERATION_DESCRIPTION") == null ? StringUtils.EMPTY : rs
                .getString("OPERATION_DESCRIPTION"));
        m.put("operationRrn", rs.getLong("OPERATION_RRN"));
        m.put("stepPath", rs.getString("STEP_PATH") == null ? StringUtils.EMPTY : rs.getString("STEP_PATH"));
        m.put("recipeId", rs.getString("RECIPE_ID") == null ? StringUtils.EMPTY : rs.getString("RECIPE_ID"));
        m.put("stageId", rs.getString("STAGE_ID") == null ? StringUtils.EMPTY : rs.getString("STAGE_ID"));
        boolean isRework = false;
        if (StringUtils.isNotBlank(rs.getString("IS_REWORK"))) {
            isRework = Boolean.parseBoolean(rs.getString("IS_REWORK"));
        }
        m.put("isRework", isRework);
        m.put("reticleFamilyId",
              rs.getString("RETICLE_GROUP_ID") == null ? StringUtils.EMPTY : rs.getString("RETICLE_GROUP_ID"));
        m.put("parameterSetId",
              rs.getString("parameter_set_id") == null ? StringUtils.EMPTY : rs.getString("parameter_set_id"));
        m.put("processLocation",
              rs.getString("process_location") == null ? StringUtils.EMPTY : rs.getString("process_location"));
        m.put("contaimnation",
              rs.getString("contaimnation") == null ? StringUtils.EMPTY : rs.getString("contaimnation"));
        m.put("flowSeqStatus", rs.getString("FLOWSEQ_STATUS"));
        m.put("entityGroupId", rs.getString("ENTITY_GROUP_ID"));
        m.put("queueTime", rs.getString("QUEUE_TIME") == null ? StringUtils.EMPTY : rs.getString("QUEUE_TIME"));
        m.put("reworkRouteId",
              rs.getString("REWORK_ROUTE_ID") == null ? StringUtils.EMPTY : rs.getString("REWORK_ROUTE_ID"));
        m.put("maxReworkTimes",
              rs.getString("MAX_REWORK_TIMES") == null ? StringUtils.EMPTY : rs.getString("MAX_REWORK_TIMES"));
        m.put("maxProcessingTime",
              rs.getString("MAX_PROCESSING_TIME") == null ? StringUtils.EMPTY : rs.getString("MAX_PROCESSING_TIME"));
        m.put("status", rs.getString("STATUS") == null ? StringUtils.EMPTY : rs.getString("STATUS"));
        m.put("ecnIds", rs.getString("ECN_IDS") == null ? StringUtils.EMPTY : rs.getString("ECN_IDS"));
        if (rs.getTimestamp("ECN_CREATE_DATE") != null) {
            m.put("ecnCreateDate", DateUtils.formatDate(rs.getTimestamp("ECN_CREATE_DATE")));
        }
        if (rs.getTimestamp("EFFECTIVE_DATE_FROM") != null) {
            m.put("effectiveDateFrom", DateUtils.formatDate(rs.getTimestamp("EFFECTIVE_DATE_FROM")));
        }
        if (rs.getTimestamp("EFFECTIVE_DATE_TO") != null) {
            m.put("effectiveDateTo", DateUtils.formatDate(rs.getTimestamp("EFFECTIVE_DATE_TO")));
        }
        m.put("ecnId", rs.getString("ECN_ID") == null ? StringUtils.EMPTY : rs.getString("ECN_ID"));
        m.put("hasActiveFlag",
              rs.getString("HAS_ACTIVE_FLAG") == null ? StringUtils.EMPTY : rs.getString("HAS_ACTIVE_FLAG"));
        m.put("isMain", rs.getString("IS_MAIN") == null ? StringUtils.EMPTY : rs.getString("IS_MAIN"));
        m.put("ecnRrn", rs.getLong("ECN_RRN"));
        m.put("bomId", rs.getString("BOM_ID") == null ? StringUtils.EMPTY : rs.getString("BOM_ID"));
        m.put("samplingRate", rs.getString("SAMPLINGRATE") == null ? StringUtils.EMPTY : rs.getString("SAMPLINGRATE"));
        m.put("tailCode", rs.getString("TAILCODE") == null ? StringUtils.EMPTY : rs.getString("TAILCODE"));
        m.put("recipeParameter",
              rs.getString("RECIPE_PARAMETER") == null ? StringUtils.EMPTY : rs.getString("RECIPE_PARAMETER"));
        return m;
    }

}