• spring jdbctemplate调用procedure(返回游标)


    package cn.com.git.htsc.uac.core.repository.report;
    
    import cn.com.git.htsc.uac.core.api.dto.report.ReportCampaignDayOutDTO;
    import oracle.jdbc.OracleTypes;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.jdbc.core.JdbcTemplate;
    import org.springframework.jdbc.core.RowMapper;
    import org.springframework.jdbc.core.SqlOutParameter;
    import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
    import org.springframework.jdbc.core.simple.SimpleJdbcCall;
    import org.springframework.stereotype.Repository;
    
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.List;
    import java.util.Map;
    
    /**
     * Created by wangyang on 2016/10/28.
     */
    @Repository
    public class ReportCampaignTotalRepository {
        @Autowired
        private JdbcTemplate primaryJdbcTemplate;
    
        public List<ReportCampaignDayOutDTO> getCampaignTotal(String start_date,String end_date,String campId,String deptId,String statu){
            SimpleJdbcCall jdbcCall = new SimpleJdbcCall(primaryJdbcTemplate).withProcedureName("pro_credit_total").declareParameters(
                    new SqlOutParameter("results_out", OracleTypes.CURSOR, new QueryExchangeOrderDTOTypeMapper())
            );
            MapSqlParameterSource mapSqlParameterSource = new MapSqlParameterSource();
            mapSqlParameterSource.addValue("startd", start_date);
            mapSqlParameterSource.addValue("endd", end_date);
            mapSqlParameterSource.addValue("actiid", campId);
            mapSqlParameterSource.addValue("deptid", deptId);
            mapSqlParameterSource.addValue("stat", statu);
            Map<String, Object> results = jdbcCall.execute(mapSqlParameterSource);
            List<ReportCampaignDayOutDTO> results_out = (List<ReportCampaignDayOutDTO>) results.get("results_out");
            return results_out;
        }
    
        private class QueryExchangeOrderDTOTypeMapper implements RowMapper {
            public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                ReportCampaignDayOutDTO dayOutDTO=new ReportCampaignDayOutDTO();
                dayOutDTO.setCampaignId(rs.getString("campaign_id"));
                dayOutDTO.setDayJoinPersonNum(rs.getLong("day_join_person_num"));
                dayOutDTO.setDayJoinCountNum(rs.getLong("day_join_count_num"));
                dayOutDTO.setDayCreditEarnNum(rs.getLong("day_credit_earn_num"));
                dayOutDTO.setDayCreditExpendNum(rs.getLong("day_credit_expend_num"));
                return dayOutDTO;
            }
        }
    }
  • 相关阅读:
    springmvc介绍
    mybatis中的动态sql应用
    mybatis中表的关联
    mybatis分页
    聚类评估指标系列(二):准确率和F值
    混淆矩阵,准确率,召回率,F-score,PR曲线,ROC曲线,AUC
    聚类评估指标系列(一):标准化互信息NMI计算步骤及其Python实现
    numpy.where() 用法详解
    互信息Mutual Information
    转:Prewitt算子、Sobel算子、canny算子、Lapacian算子
  • 原文地址:https://www.cnblogs.com/wangyang108/p/6007069.html
Copyright © 2020-2023  润新知