通话记录保存 三

来源:互联网 发布:剑网三苍云男捏脸数据 编辑:程序博客网 时间:2024/06/11 01:09

服务器端:

 

由于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 blocke.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 numberDBUtil.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 ) isTID      NUMBER;CT NUMBER;Cursor myCursor is select ID,CALL_TIME from EDJ_SERVICE where customer_id=CUSTOMER_ID1 and order_time=CREATE_TIME1;beginTID := -1;OPEN  myCursor;LOOP   fetch  myCursor  into  TID,CT;   if TID>0 then    if CALL_TIME1>CT or CT is null thenupdate edj_service t set t.call_time= CALL_TIME1 where ID=TID;end if;elseinsert 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;


 

 

 

 

原创粉丝点击