存储过程和函数是有区别的!!!
创建函数,只是演示,以下函数不完整!!!(只是看P_xxx参数)
CREATE OR REPLACE PROCEDURE SP_TICKET_CHECKE_ONLINE_TEST (p_transcode IN OUT VARCHAR2,
p_ip IN OUT VARCHAR2,
p_barcode VARCHAR2,
p_managercard VARCHAR2,
p_checkdatetime VARCHAR2,
p_haspic OUT VARCHAR2,
p_rescode OUT VARCHAR2,
p_resmsg OUT VARCHAR2,
p_transdata OUT VARCHAR2,
p_orderno OUT VARCHAR2,
p_pricename OUT VARCHAR2) AS
v_transcode VARCHAR2(4);
v_ip VARCHAR2(15);
v_terminalnum VARCHAR2(30);
v_barcode VARCHAR2(25);
--v_visitorbar VARCHAR2(25);
v_managercard VARCHAR2(30);
v_checkdatetime VARCHAR2(20);
v_syscheckdatetime VARCHAR2(14);
v_syscheckdate VARCHAR2(8);
v_syschecktime VARCHAR2(6);
v_bardate VARCHAR2(8);
v_barprice VARCHAR2(6);
v_priceid VARCHAR2(16);
v_pricenum NUMBER;
v_haspic VARCHAR2(1);
v_barnum NUMBER;
v_managernum NUMBER;
v_status VARCHAR2(1);
v_munitid1 VARCHAR2(15);
v_merid VARCHAR2(15);
v_pacid VARCHAR2(7);
v_scenicid VARCHAR2(15);
v_scenicids VARCHAR2(1000);
v_scenicids_temp VARCHAR2(1000);
v_scen_has NUMBER;
v_ischeck NUMBER;
v_barmunitid VARCHAR2(15);
v_pricename VARCHAR2(100);
v_hasterminal NUMBER;
v_operUser VARCHAR2(20); -- 操作员编码;
v_userID VARCHAR2(20);
v_tag VARCHAR2(12);
v_checkDoor VARCHAR2(8);
v_date VARCHAR2(10);
v_time VARCHAR2(8);
v_id_card VARCHAR2(20); -- 证件号码
v_barEndDate VARCHAR2(8); --2预售票时间段 票结束日期
v_ticketType VARCHAR2(1); --票类型1日历票2预售票3普通票 默认3
v_createData VARCHAR2(8); --票类型1日历票2预售票3普通票 默认3
v_recsn VARCHAR2(50); --票类型1日历票2预售票3普通票 默认3
v_orderno VARCHAR2(50); --票类型1日历票2预售票3普通票 默认3
BEGIN
v_haspic:='0';
v_date := TO_CHAR(SYSDATE, 'YYYYMMDD');
v_time := TO_CHAR(SYSDATE, 'HH24MISS');
v_transcode := TRIM(p_transcode);
v_barcode := TRIM(p_barcode);
v_ip := TRIM(p_ip);
v_managercard := TRIM(p_managercard);
v_barnum := 0;
v_checkdatetime := TRIM(p_checkdatetime);
v_syscheckdatetime := TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS');
v_syscheckdate := SUBSTR(v_syscheckdatetime,0,8);
v_syschecktime := SUBSTR(v_syscheckdatetime,9,6);
v_pricename := '';
v_checkDoor := '';
v_createData := '';
v_recsn := '';
v_orderno := '';
mapper层,不需要返回实体对象。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.jiewen.pgw.dao.CheckDoorMapper">
<select id="checkTicket" statementType="CALLABLE">
{call SP_TICKET_CHECKE_ONLINE_TEST(
#{p_transcode, mode=INOUT, jdbcType=VARCHAR},
#{p_ip, mode=INOUT, jdbcType=VARCHAR},
#{p_barcode, mode=IN, jdbcType=VARCHAR},
#{p_managercard, mode=IN, jdbcType=VARCHAR},
#{p_checkdatetime, mode=IN, jdbcType=VARCHAR},
#{p_haspic, mode=OUT, jdbcType=VARCHAR},
#{p_rescode, mode=OUT, jdbcType=VARCHAR},
#{p_resmsg, mode=OUT, jdbcType=VARCHAR},
#{p_transdata, mode=OUT, jdbcType=VARCHAR},
#{p_orderno, mode=OUT, jdbcType=VARCHAR},
#{p_pricename, mode=OUT, jdbcType=VARCHAR}
)}
</select>
</mapper>
dao层
@Mapper
public interface CheckDoorMapper {
void checkTicket(Map<String, Object> params);
}
server层
public interface CheckDoorService {
void checkTicket(Map<String, Object> params);
}
serverimpl层
@Service
public class CheckDoorServiceImpl implements CheckDoorService {
@Autowired
private CheckDoorMapper checkDoorMapper;
@Override
public void checkTicket(Map<String, Object> params) {
checkDoorMapper.checkTicket(params);
}
}
controller层
Map<String, Object> params = new HashMap<>();
params.put("p_transcode", request.getTransCode());
params.put("p_ip", request.getAddr());
params.put("p_barcode", request.getBarCode());
params.put("p_managercard", null);
params.put("p_checkdatetime", DateTimeUtil.getSystemDate());
//调用函数 通过map来传参数
checkDoorService.checkTicket(params);
//接收函数返回的信息
String p_haspic = (String) params.get("p_haspic");
String p_rescode = (String) params.get("p_rescode");
String p_resmsg = (String) params.get("p_resmsg");
String p_pricename = (String) params.get("p_pricename");
String p_transcode = (String) params.get("p_transcode");
String p_ip = (String) params.get("p_ip");
String p_barcode = (String) params.get("p_barcode");
System.out.println("p_haspic: " + p_haspic);
System.out.println("p_rescode: " + p_rescode);
System.out.println("p_resmsg: " + p_resmsg);
System.out.println("p_pricename: " + p_pricename);
System.out.println("p_transcode: " + p_transcode);
System.out.println("p_ip: " + p_ip);
System.out.println("p_barcode: " + p_barcode);
System.out.println("oper: " + request.getOper());
最后输出结果: