# EenActionQueryDAOImpl.java

    package com.mycim.server.wip.dao.impl;

    import com.mycim.framework.jdbc.JdbcTemplate;
    import com.mycim.server.wip.dao.EenActionQueryDAO;
    import com.mycim.server.wip.dao.mapper.EenActionMapper;
    import com.mycim.valueobject.alm.EenAction;
    import com.mycim.valueobject.consts.DataBaseNames;
    import org.springframework.stereotype.Repository;

    import java.util.ArrayList;
    import java.util.List;

    /**
     * @author Johnson.Wang
     * @version 6.0.0
     * @date 2019/10/8
     **/
    @Repository
    public class EenActionQueryDAOImpl implements EenActionQueryDAO {

        private final JdbcTemplate jdbcTemplate;

        public EenActionQueryDAOImpl(JdbcTemplate jdbcTemplate) {
            this.jdbcTemplate = jdbcTemplate;
        }

        @Override
        public List<EenAction> getEenActions(long actionRrn) {
            String sql = "SELECT ACTION_RRN,ACTION_SEQ,ACTION_TYPE,PARAMETER_VALUE_1," + "PARAMETER_VALUE_2," +
                    "PARAMETER_VALUE_3,PARAMETER_VALUE_4," + "PARAMETER_VALUE_5,PARAMETER_VALUE_6,PARAMETER_VALUE_7," +
                    "PARAMETER_VALUE_8,PARAMETER_VALUE_9,PARAMETER_VALUE_10" + " FROM " + DataBaseNames.EEN_ACTION + " " +
                    "WHERE ACTION_RRN = ?";

            return jdbcTemplate.query(sql, new Object[]{actionRrn}, new EenActionMapper(actionRrn));
        }

        @Override
        public EenAction getEenAction(EenAction eenAction) {
            int actionSeq = eenAction.getActionSeq() == null || eenAction.getActionSeq().intValue() <= 0 ? 1 : eenAction
                    .getActionSeq();
            String sql = "SELECT count(*) FROM " + DataBaseNames.EEN_ACTION + " WHERE ACTION_RRN = ? AND ACTION_TYPE = ? " +
                    "AND ACTION_SEQ = ?" + " AND PARAMETER_VALUE_1 = ? AND PARAMETER_VALUE_2=?" + " AND PARAMETER_VALUE_3" +
                    " = ? AND PARAMETER_VALUE_4 = ?" + " AND PARAMETER_VALUE_5 = ? AND PARAMETER_VALUE_6 = ?" + " AND " +
                    "PARAMETER_VALUE_7 = ? AND PARAMETER_VALUE_8 = ?" + " AND PARAMETER_VALUE_9 = ? AND " +
                    "PARAMETER_VALUE_10 = ?";

            List args = new ArrayList();
            args.add(eenAction.getActionRrn());
            args.add(eenAction.getActionType());
            args.add(actionSeq);
            args.add(eenAction.getParameterValue1());
            args.add(eenAction.getParameterValue2());
            args.add(eenAction.getParameterValue3());
            args.add(eenAction.getParameterValue4());
            args.add(eenAction.getParameterValue5());
            args.add(eenAction.getParameterValue6());
            args.add(eenAction.getParameterValue7());
            args.add(eenAction.getParameterValue8());
            args.add(eenAction.getParameterValue9());
            args.add(eenAction.getParameterValue10());

            int count = jdbcTemplate.queryForObjectWithNull(sql, args.toArray(), int.class);

            if (count > 0) {
                return eenAction;
            }
            return null;
        }

        @Override
        public List<EenAction> getEenActionsWithMerged(long actionRrn) {
            String sql = "SELECT ACTION_RRN,ACTION_SEQ,ACTION_TYPE,PARAMETER_VALUE_1," + "PARAMETER_VALUE_2," +
                    "PARAMETER_VALUE_3,PARAMETER_VALUE_4," + "PARAMETER_VALUE_5,PARAMETER_VALUE_6,PARAMETER_VALUE_7," +
                    "PARAMETER_VALUE_8,PARAMETER_VALUE_9,PARAMETER_VALUE_10" + " FROM " + DataBaseNames.EEN_ACTION + " " +
                    "WHERE ACTION_RRN = ? AND PARAMETER_VALUE_10 != 'MERGED'";

            return jdbcTemplate.query(sql, new Object[]{actionRrn}, new EenActionMapper(actionRrn));
        }

    }