zoukankan      html  css  js  c++  java
  • 报表查询——自动刷新数据,双击明细打开关联作业

     

     

    这次的范例是(cxmq100);

    目的:实现报表数据自动刷新,双击明细数据打开相关的查询作业;

    1)在MAIN前进行客制变量定义:

    #add-point:自定義模組變數-客製(Module Variable) name="global.variable_customerization"
    
    TYPE type_g_input RECORD
        refresh        LIKE type_t.num10,
        autoRefresh     LIKE type_t.chr1
    END RECORD
    
    DEFINE    g_input          type_g_input  #INPUT條件
    
    DEFINE    g_seconds        LIKE type_t.num10
    DEFINE    g_time1          DATETIME YEAR TO SECOND
    DEFINE    g_time2          STRING
    DEFINE    g_time3          STRING
    DEFINE    l_hhmmss         STRING 
    DEFINE    g_total          LIKE type_t.num10
    #end add-point
    

      

    2)在cxmq100_init()中将客制变量进行初始化赋值:

       #add-point:畫面資料初始化 name="init.init"
       LET g_input.refresh = 1
       LET g_input.autoRefresh = 'Y'
       LET g_total = g_input.refresh * 60 
       LET g_seconds = 0
       #end add-point

      

    3)在 cxmq100_ui_dialog() 中DIALOG ATTRIBUTES(UNBUFFERED,FIELD ORDER FORM)下置入INPUT指令,让用户输入数据,并在此实现自动刷新数据的功能:

          DIALOG ATTRIBUTES(UNBUFFERED,FIELD ORDER FORM)
             #add-point:input段落 name="ui_dialog.input"
    
             INPUT g_input.refresh,g_input.autoRefresh FROM refresh,autoRefresh ATTRIBUTE(WITHOUT DEFAULTS)
             BEFORE INPUT
                ON idle  5
                   if g_input.autoRefresh = "Y" then
                       IF g_time1 IS NULL THEN
                          LET g_time1 = cl_get_current()
                       END IF
                       #去掉“-”,“:”和空格,得到2个数字做大小比较,不要求得到准确的秒数差
                       LET g_time2 = g_time1
                       LET g_time2 = s_chr_minus(g_time2,'-',0)
                       LET g_time2 = s_chr_minus(g_time2,':',0)
                       LET g_time2 = s_chr_atrim(g_time2)
                       LET l_hhmmss = g_time2.substring(9,10)*3600+g_time2.substring(11,12)*60+g_time2.substring(13,14)
                       LET g_time2 = g_time2.substring(1,8),l_hhmmss
                       LET g_time3 = cl_get_current()
                       LET g_time3 = s_chr_minus(g_time3,'-',0)
                       LET g_time3 = s_chr_minus(g_time3,':',0)
                       LET g_time3 = s_chr_atrim(g_time3)
                       LET l_hhmmss = g_time3.substring(9,10)*3600+g_time3.substring(11,12)*60+g_time3.substring(13,14)
                       LET g_time3 = g_time3.substring(1,8),l_hhmmss
                       #DISPLAY 'g_time2 =',g_time2         #预埋调试用,可放开看时间调试
                       #DISPLAY 'g_time3 =',g_time3
                       #display '3-2 =',g_time3 - g_time2    
                       #这个2是容许误差2秒,2秒内的误差都不会触发重计倒计时,这是因为服务器有时候会很卡、停顿,尤其是网络的延迟,这些都会造成误差,如果特别卡,可以适当放大秒数误差,但是会造成必须操作X秒以上才会触发重计的现象
                       IF g_time3 - g_time2 < 2 THEN
                          IF g_seconds >= g_total THEN    #自动刷新设为60秒
                             CALL cxmq100_b_fill()
                             LET g_seconds = 0
                          END IF
                          LET g_time1 = cl_get_current()
                          LET g_seconds = g_seconds + 1
                          #DISPLAY g_seconds 
                       ELSE 
                       #DISPLAY 'cl_get_current()           =',cl_get_current()    预埋调试用,可放开看时间调试
                       #DISPLAY 'g_time1                    =',g_time1
                       #DISPLAY 'cl_get_current() - g_time1 =',cl_get_current() - g_time1         
                       #LET g_seconds = 0
                          LET g_time1 = cl_get_current()            
                       END IF
                   end if
                   
                AFTER FIELD refresh
                   IF NOT cl_null(g_input.refresh) THEN
                      Let g_total = g_input.refresh * 60 
                   END IF    
             END INPUT
             #end add-point
    

    ON IDLE 5 表示空闲时间5秒执行;

    AFTER FIELD refresh 表示用户在输入完指定的字段动作完毕后,计算机会处理AFTER FIELD下的程序段;

     

    4)实现双击明细数据打开相关查询作业的功能:

    ①依然在cxmq100_ui_dialog() 下先把doubleClick的action事件【modify_detail】客制好:

             #主選單用ACTION
             &include "main_menu_exit_dialog.4gl"
             &include "relating_action.4gl"
             #交談指令共用ACTION
             &include "common_action.4gl"
     
             #add-point:查詢方案相關ACTION設定前 name="ui_dialog.set_qbe_action_before"
             ON ACTION modify_detail
                LET g_action_choice="modify_detail"
                IF cl_auth_chk_act("modify_detail") THEN
                   IF g_detail_idx>=1 THEN
                      CALL cxmq100_qrystr(g_xmabuc_d[g_detail_idx].xmabucdocno) 
                   END IF
                END IF
             #end add-point
    

      明细单号xmabucdocno作为PK传入cxmq100_qrystr函数;

     

    5) cxmq100_qrystr(p_docno)函数:

    PRIVATE FUNCTION cxmq100_qrystr(p_docno)
       DEFINE p_docno LIKE xmdk_t.xmdkdocno
       #DEFINE l_slip     LIKE oobal_t.oobal002
       #DEFINE l_prog     LIKE oobx_t.oobx004
       #DEFINE l_success  LIKE type_t.num5
       DEFINE ls_js      STRING
       DEFINE la_param   RECORD
              prog       STRING,
              actionid   STRING,
              background LIKE type_t.chr1,
              param      DYNAMIC ARRAY OF STRING
              END RECORD
       #抓取單據別
       {
       LET l_slip = ''
       LET l_prog = ''
       IF NOT cl_null(p_docno) THEN
          CALL s_aooi200_get_slip(p_docno) RETURNING l_success,l_slip
          IF NOT cl_null(l_slip) THEN
             #抓取程式名稱
             SELECT oobx004 INTO l_prog
               FROM oobx_t
              WHERE oobxent = g_enterprise
                AND oobx001 = l_slip
          END IF
          IF NOT cl_null(l_prog) THEN
             INITIALIZE la_param.* TO NULL
             LET la_param.prog     = l_prog
             LET la_param.param[1] = p_docno
             LET ls_js = util.JSON.stringify(la_param)
             CALL cl_cmdrun(ls_js)
          END IF
       END IF
       }
       IF NOT cl_null(p_docno) THEN
             INITIALIZE la_param.* TO NULL
             LET la_param.prog     = "cxmt631"
             LET la_param.param[1] = p_docno
             LET ls_js = util.JSON.stringify(la_param)
             CALL cl_cmdrun(ls_js)
       END IF
    END FUNCTION

    注意上面使用了{}注释的内容在这个范例中不适用;

     

    下方代码,双击单身明细,打开cxmt631作业:

    IF NOT cl_null(p_docno) THEN
             INITIALIZE la_param.* TO NULL
             LET la_param.prog     = "cxmt631"
             LET la_param.param[1] = p_docno
             LET ls_js = util.JSON.stringify(la_param)
             CALL cl_cmdrun(ls_js)
       END IF





    
    
    
    INPUT g_input.refresh FROM refresh ATTRIBUTE(WITHOUT DEFAULTS)
                 BEFORE INPUT
                     ON IDLE 10 
                         IF g_input.refresh > 0 THEN
                             LET g_hh = g_refresh_time[7]||g_refresh_time[8]
                             LET g_mm = g_refresh_time[9]||g_refresh_time[10]
                             LET g_ss = g_refresh_time[11]||g_refresh_time[12]
                             LET g_second = g_hh*60*60 + g_mm*60 + g_ss
                             
                             SELECT to_char(SYSTIMESTAMP, 'yymmddhh24miss') INTO l_time FROM dual 
                             LET l_hh = l_time[7]||l_time[8]
                             LET l_mm = l_time[9]||l_time[10]
                             LET l_ss = l_time[11]||l_time[12]
                             LET l_second = l_hh*60*60 + l_mm*60 + l_ss
                             
                             LET l_seconds = l_second - g_second
                             IF l_seconds >= g_refresh THEN
                                 CALL cxmq245_b_fill()
                                 LET l_seconds = 0
                                 LET g_refresh_time = l_time
                                 
                                 LET g_input.refresh_desc = l_hh||":"||l_mm||":"||l_ss||"已自动刷新"
                                 DISPLAY BY NAME g_input.refresh_desc
                             END IF
                         END IF                     
                    
                 AFTER FIELD refresh
                     IF NOT cl_null(g_input.refresh) THEN
                         LET g_refresh = g_input.refresh * 60 
                     ELSE
                         LET g_input.refresh = 1 
                         DISPLAY BY NAME g_input.refresh
                         LET g_refresh = g_input.refresh * 60 
                     END IF              
             END INPUT
     
  • 相关阅读:
    深度分析:java8的新特性lambda和stream流,看完你学会了吗?
    花了三天整理,Spring Cloud微服务如何设计异常处理机制?还看不懂算我输
    做了两年java,这些高性能高可用高并发的技术架构你都知道吗?
    面试阿里,字节跳动90%会被问到的微服务,你确定不进来看看吗?
    阿里面试官:小伙子,你给我说一下前后端分离的接口规范是什么?
    深度分析:面试阿里,字节跳动,美团几乎都会被问到的阻塞队列
    1. 线性DP 1143. 最长公共子序列
    1. 线性DP 300. 最长上升子序列 (LIS)
    GC 的认识(转) https://github.com/qcrao/Go-Questions/blob/master/GC/GC.md#1-什么是-gc有什么作用
    缓存淘汰算法--LRU算法
  • 原文地址:https://www.cnblogs.com/xiaoli9627/p/6836734.html
Copyright © 2011-2022 走看看