springboot+mybatis3.4 调用存储过程 执行多条SQL

1.创建Mapper接口类

public interface TCustomerOrgTempMapper {
    /**
     * 存储过程更新
     *
     * @param map
     * @return
     */
    Map callProceUpdate(Map map);
}

 

2.mybatis sql文件




      

3.调存储过程,存储过程返回的值在传入的map里可以获取

CustomerOrgExtendVo customerOrgExtendVo = custCnVo.getCustOrgExtendVo();
String customerOrgExtendJson = JSON.toJSONString(customerOrgExtendVo);
String id = StringUtil.UUID32();
TCustomerOrgTemp tCustomerOrgTemp = ClassToolUtil.arrayJsonToObj(new String[]
         {customerOrgExtendJson,custVoJson},TCustomerOrgTemp.class);
            tCustomerOrgTemp.setId(id);
            tCustomerOrgTempMapper.insert(tCustomerOrgTemp);
            Map params = new HashMap(5);
            params.put("id", id);
            params.put("custNo", custNo);
            tCustomerOrgTempMapper.callProceUpdate(params);
            if("false".equals(params.get("status"))){
            	ResultVo resultVo = new ResultVo();
                resultVo.setStatus(false);
                resultVo.setMessage("E10000009");
                return resultVo;
            }

4.mybatis执行多条sql


  		begin
  		insert into tableA(join_serial, cust_no, old_cust_no, status, join_time, join_user)
		values(#{params.join_id}, #{params.custNo}, #{params.suspectedCustNo}, '0', sysdate, #{params.createUser});
		insert into tableB (join_id, join_cust_no, cust_no, cust_name, en_name, customer_type, id_type, id_number, contact_way, country_code, 
			select #{params.join_id},#{params.custNo},cust_no, cust_name, en_name, customer_type, id_type, id_number, contact_way, country_code, 
			from tableC where cust_no=#{params.suspectedCustNo};
		delete from e_basic_info where cust_no = #{params.suspectedCustNo};
		 	           
		end;
  

 

 

 

你可能感兴趣的:(开发)