设置业务锁

  //设置业务锁
         boolean lockPeriod  = false;
         lockPeriod = nc.bs.uap.lock.PKLock.getInstance().acquireLock(psndocWadocs[0].getPk_wa_grd(), PubEnv.getPk_user(), null);
         if (!lockPeriod) {
      throw new nc.vo.pub.BusinessException(NCLangResOnserver.getInstance().getStrByID("60131004", "UPP60131004-000303")/*
                         * @res
                         * "有人正在处理该数据,请稍候再试!"
                         */);
         }
         try {
            Hashtable<String, String> ht = new Hashtable<String, String>();
            for (int i = 0; i < psndocWadocs.length; i++) {
                if (psndocWadocs[i].getRecordnum() == null) {
                    psndocWadocs[i].setRecordnum(new Integer(0));
                }
                if (psndocWadocs[i].getLastflag() == null) {
                    psndocWadocs[i].setLastflag(new nc.vo.pub.lang.UFBoolean(true));
                }
                if (!psndocWadocs[i].getPk_wa_item().equals(ht.get(psndocWadocs[i].getPk_psndoc()))) {// 保证同一批插入的数据,同一人同一项目的记录号只更新一次
                    dmo.updatePrePsnWadocFlag(psndocWadocs[i].getPk_psndoc(), psndocWadocs[i].getPk_wa_item(), "insertarray", psndocWadocs[i].getRecordnum(), new Boolean(true));
                    ht.put(psndocWadocs[i].getPk_psndoc(), psndocWadocs[i].getPk_wa_item());
                }
            }
            String[] keys = dmo.insertArray(psndocWadocs);
            return keys;
        } catch (Exception e) {
            Logger.error(e);
            return null;
        }finally{
      //打开业务锁
      if(lockPeriod)
       PKLock.getInstance().releaseLock(psndocWadocs[0].getPk_wa_grd(),  PubEnv.getPk_user(), null);
      
     }

你可能感兴趣的:(设置)