通话记录保存 三

服务器端:

 

由于action 同步锁造成的等待对多用户保存记录造成影响 决定 使用存储过程

加入的通话时间是为了更新数据

	public HashMap saveservice(Long driverid, String userkey, Long mlon,
			Long mlat, String telephone, Long coopid,Long calltime,String clientcreatetime,int distime ) {
		HashMap map = new HashMap();
		
		String sql1 = "select * from edj_customer where user_key =?";

		List<EdjCustomer> list = DBUtil.getHgjDao().findBySQL(sql1,
				new Object[] { userkey }, 0, 1, new EdjCustomer());

		Long customerId = null;

		if (list == null || list.size() < 1) {
			// 设置用户名
			// 创建用户 userKey creatTime city
			// userName=userKey;
			EdjCustomer c = new EdjCustomer();
			c.setUserKey(userkey);
			c.setMobile(telephone);
			c.setServiceType((short)9);
			c.setCreateTime(new Date());
			DBUtil.getHgjDao().save(c);
			customerId = c.getId();
		} else {
			EdjCustomer cc = list.get(0);
			if (cc != null) {

				customerId = cc.getId();
			}
		}
		
		
		Date orderTime = null;
		//--保存创建时间
		DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
		if(clientcreatetime!=null&&!"".equals(clientcreatetime)){
		try {
			orderTime=format.parse(clientcreatetime);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}
		
		Date createtime=null;
		EdjTools edj=new EdjTools();
		if(distime!=0){
			createtime=edj.MakeTime(distime);
		}else{
			createtime=new Date();
		}
		String sql="call dj_call_save(?,?,?,?,?,?,?,?,?)";
		
		try{
//			 CREATE_TIME1       in DATE,
//			 CUSTOMER_ID1       in NUMBER,
//			 CALL_TIME1        in NUMBER,
//			 driver_id1        in number,
//			 coop_id1         in number,
//			 create_time2       in date,
//			  LON1               in number,
//			 LAT1               in number
			DBUtil.getDao().updateBySQL(sql, new Object[] {orderTime,customerId,calltime,driverid,coopid,createtime,mlon,mlat,telephone});
			map.put("code",1);
			map.put("msg","添加成功");
			
			}catch(Exception ex){
				map.put("code",0);
				map.put("msg","添加失败");
			  }
		return map;
	}


 

数据库存储过程:

create or replace procedure dj_call_save(
 CREATE_TIME1       in DATE,
 CUSTOMER_ID1       in NUMBER,
 CALL_TIME1        in NUMBER,
 driver_id1        in number,
 coop_id1         in number,
 create_time2       in date,
  LON1               in number,
 LAT1               in number,
 CUSTOMER_MOBILE1     in varchar2
 
) is
TID      NUMBER;
CT NUMBER;
Cursor myCursor is select ID,CALL_TIME from EDJ_SERVICE where customer_id=CUSTOMER_ID1 and order_time=CREATE_TIME1;
begin

TID := -1;
OPEN  myCursor;
LOOP 
  fetch  myCursor  into  TID,CT; 

  if TID>0 then
    if CALL_TIME1>CT or CT is null then
update edj_service t set t.call_time= CALL_TIME1 where ID=TID;
end if;
else
insert into edj_service (ID,Customer_Id,driver_id,coop_id,create_time,order_time,order_source,longitude,LATITUDE,call_time,customer_mobile) values (
edj_service_seq.nextval,CUSTOMER_ID1,driver_id1,coop_id1,create_time2,CREATE_TIME1,2,LON1,LAT1,CALL_TIME1,CUSTOMER_MOBILE1
);
end if;
  Exit  when  myCursor%NOTFOUND or TID>0; 
end loop;

  commit;
end dj_call_save;


 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值