prepareStatement

package com.yundaex.wms.basicdata.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.stereotype.Repository;

import com.yundaex.common.dao.impl.BaseDaoImpl;
import com.yundaex.wms.basicdata.constant.RivPrintHistoryLSqlConstant;
import com.yundaex.wms.basicdata.dao.RivPrintHistoryLDao;
import com.yundaex.wms.basicdata.po.RivPrintHistoryL;
import com.yundaex.wms.basicdata.vo.DifferentUserQtyVO;


@Repository("printHistoryLDao")
public class RivPrintHistoryLDaoImpl extends BaseDaoImpl<RivPrintHistoryL> implements RivPrintHistoryLDao {

    
    @Override
    public Integer getAlreadyPrintCount(Integer oplHeaderId, String printType) {
        List<Object> params = new ArrayList<Object>();
        StringBuilder sb = new StringBuilder(" SELECT count(1) ");
        sb.append(" FROM ");
        sb.append(" riv_print_history_l phl");
        sb.append(" WHERE ");
        sb.append(" phl.PHL_HEADER_ID = ? ");
        params.add(oplHeaderId);
        sb.append(" AND ");
        sb.append(" phl.PHL_PRINT_TYPE = ? ");
        params.add(printType);
        
        Integer joinShipCnt = this.jdbcTemplate.getJdbcOperations().queryForObject(sb.toString(), params.toArray(), Integer.class);
        return joinShipCnt;
    }

    @Override
    public List<DifferentUserQtyVO> queryTopQtyUser(final String beginDate,final String endDate,final Integer orgId) {
        
         List<DifferentUserQtyVO> results = jdbcTemplate.getJdbcOperations().query(new PreparedStatementCreator() {
            public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
                PreparedStatement ps = con.prepareStatement(RivPrintHistoryLSqlConstant.PRINT_HISTORY_TOP_QTY_USER_SQL);
                ps.setString(1, beginDate);
                ps.setString(2, endDate);
                ps.setInt(3, orgId);
                ps.setInt(4, orgId);
                return ps;
            }
        }, new BeanPropertyRowMapper<DifferentUserQtyVO>(DifferentUserQtyVO.class));
        
        return results;
    }
}
public KeyHolder saveOutboundNotice(final RivOutboundNoticeH onh) {
        CommonMethodHelper.showDebugLogger(logger, OmsSqlConstants.SAVE_OUTBOUND_NOTICE);
        KeyHolder keyHolder = new GeneratedKeyHolder();
        jdbcTemplate.getJdbcOperations().update(new PreparedStatementCreator() {
            public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
                return buildOutNotceHeaderPS(onh, con);
            }
        }, keyHolder);
        return keyHolder;
    }
    
    private PreparedStatement buildOutNotceHeaderPS(final RivOutboundNoticeH onh, Connection con) throws SQLException {
        PreparedStatement ps = con.prepareStatement(OmsSqlConstants.SAVE_OUTBOUND_NOTICE, new String[] {"onh_id"});
        ps.setInt(1, onh.getOnhStatus());
        ps.setInt(2, onh.getOnhOrgId());
        ps.setString(3, onh.getOnhNoticeNo());
        ps.setInt(4, onh.getOnhOwnerId());
        ps.setString(5, onh.getOnhOwnerNo());
        ps.setString(6, onh.getOnhTxType());
        if (null != onh.getOnhCarrierId()) {
            ps.setInt(7, onh.getOnhCarrierId());
        } else {
            ps.setString(7, null);
        }
        ps.setTimestamp(8, new Timestamp(onh.getOnhOrderDatetime().getTime()));
        ps.setTimestamp(9, new Timestamp(onh.getOnhExpectDatetime().getTime()));
        ps.setString(10, onh.getOnhConsignee());
        ps.setString(11, onh.getOnhConsigneeMobile());
        ps.setString(12, onh.getOnhConsigneeTel());
        ps.setString(13, onh.getOnhConsigneeAddress());
        ps.setString(14, onh.getOnhConsigneePostCode());
        ps.setInt(15, onh.getOnhIsOneItem());
        ps.setString(16, onh.getOnhLineSignature());
        ps.setTimestamp(17, new Timestamp(onh.getOnhInputDatetime().getTime()));
        ps.setInt(18, SecurityContextHelper.getCurrentUserId());
        ps.setTimestamp(19, new Timestamp(onh.getOnhApproveDatetime().getTime()));
        ps.setInt(20, SecurityContextHelper.getCurrentUserId());
        ps.setString(21, onh.getGenMethod());
        ps.setInt(22, SecurityContextHelper.getCurrentUserId());
        ps.setTimestamp(23, new Timestamp(System.currentTimeMillis()));
        ps.setInt(24, SecurityContextHelper.getCurrentUserId());
        ps.setString(25, onh.getOnhConsAddressProvince());
        ps.setString(26, onh.getOnhConsAddressCity());
        ps.setString(27, onh.getOnhConsAddressDistrict());
        ps.setString(28, onh.getOnhShopName());
        ps.setString(29, onh.getOnhTransactionNo());
        ps.setString(30, onh.getOnhRemarks());
        ps.setString(31, onh.getOnhPlatformName());
        ps.setString(32, onh.getOnhBuyerNickname());
        ps.setString(33, onh.getOnhPlatformCode());
        ps.setString(34, onh.getOnhSender());
        ps.setString(35, onh.getOnhSenderTel());
        ps.setString(36, onh.getOnhSenderMobile());
        ps.setString(37, onh.getOnhSenderAddress());
        ps.setString(38, onh.getOnhSenderPostCode());
        ps.setString(39, onh.getOnhBuyerMessage());
        ps.setString(40, onh.getOnhSellerMessage());
        ps.setInt(41, null == onh.getOnhIsCod() ? 0 : onh.getOnhIsCod());
        ps.setBigDecimal(42, null == onh.getOnhCodAmount() ? BigDecimal.ZERO : onh.getOnhCodAmount());
        ps.setInt(43, onh.getOnhParcelInsurance()==null?0:onh.getOnhParcelInsurance());
        ps.setBigDecimal(44, null == onh.getOnhActualTotalAmount() ? BigDecimal.ZERO : onh.getOnhActualTotalAmount());
        ps.setBigDecimal(45, null == onh.getOnhItemAmount() ? BigDecimal.ZERO : onh.getOnhItemAmount());
        ps.setBigDecimal(46, null == onh.getOnhFreightAmount() ? BigDecimal.ZERO : onh.getOnhFreightAmount());
        ps.setBigDecimal(47, null == onh.getOnhOffAmount() ? BigDecimal.ZERO : onh.getOnhOffAmount());
        ps.setBigDecimal(48, null == onh.getOnhPaidAmount() ? BigDecimal.ZERO : onh.getOnhPaidAmount());
        ps.setInt(49, null == onh.getOnhItemsCount() ? 0 : onh.getOnhItemsCount());
        ps.setString(50, onh.getOnhSetPackageDestination());
        ps.setBigDecimal(51, null == onh.getOnhInsuranceAmount() ? BigDecimal.ZERO : onh.getOnhInsuranceAmount());
        ps.setString(52, onh.getOnhExpressType());
        ps.setString(53, onh.getOnhLogisticsOrderNo());
        ps.setString(54, onh.getOnhCnOrdercode());
        ps.setString(55, onh.getOnhOrderStruType());
        ps.setInt(56, null == onh.getOnhIsInternationalOrder()? 0 : onh.getOnhIsInternationalOrder());
        return ps;
    }
    
    /** 出库通知单单头表信息保存 **/
    public final static String SAVE_OUTBOUND_NOTICE = "insert into riv_outbound_notice_h \n" +
            "    (onh_status, onh_org_id, onh_notice_no, onh_owner_id, onh_owner_no,  \n" +
            "    onh_tx_type, onh_carrier_id, onh_order_datetime, onh_expect_datetime, onh_consignee,  \n" +
            "    onh_consignee_mobile, onh_consignee_tel, onh_consignee_address, onh_consignee_post_code,  \n" +
            "    onh_is_one_item, onh_line_signature, onh_input_datetime, onh_input_user_id, onh_approve_datetime,  \n" +
            "    onh_approve_user_id, gen_method, create_user_id, create_time, update_user_id, \n" +
            "    onh_cons_address_province, onh_cons_address_city, onh_cons_address_district, \n" +
            "    onh_shop_name, onh_transaction_no, onh_remarks, onh_platform_name, onh_buyer_nickname, onh_platform_code,  \n" +
            "    onh_sender, onh_sender_tel, onh_sender_mobile, onh_sender_address, onh_sender_post_code,  \n" +
            "    onh_buyer_message, onh_seller_message, onh_is_cod, onh_cod_amount, onh_parcel_insurance,  \n" +
            "   onh_actual_total_amount ,onh_item_amount, onh_freight_amount, onh_off_amount, onh_paid_amount,onh_items_count, \n" +
            "    onh_set_package_destination, onh_insurance_amount, onh_express_type, onh_logistics_order_no,onh_cn_ordercode,onh_order_stru_type,onh_is_international_order )  \n" +
            "    values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,  \n" +
            "           ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
    

 

转载于:https://www.cnblogs.com/tonggc1668/p/7602793.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值