123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- $PBExportHeader$f_outware_savelock.srf
- global type f_outware_savelock from function_object
- end type
- forward prototypes
- global function integer f_outware_savelock (long arg_scid, ref string arg_msg)
- global function integer f_outware_savelock (long arg_storageid, string arg_lockemp, ref string arg_msg)
- end prototypes
- global function integer f_outware_savelock (long arg_scid, ref string arg_msg);Int rslt = 1
- Int li_iflock
- DateTime ldt_lastlocktime,ldt_locktime
- Long ll_h,ll_m
- IF sys_option_mrp_locktype = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- SELECT iflock,
- lastlocktime,
- locktime,
- DATEDIFF(hh,lastlocktime,getdate()),
- DATEDIFF(mi,locktime,getdate())
- INTO :li_iflock,
- :ldt_lastlocktime,
- :ldt_locktime,
- :ll_h,
- :ll_m
- FROM aps_mrp_lock
- Where scid = :arg_scid;
- IF sqlca.SQLCode = -1 THEN
- arg_msg = '查询MRP运算锁定标记失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- ELSEIF sqlca.SQLCode = 100 THEN
- rslt = 1
- GOTO ext
- END IF
- IF li_iflock = 0 THEN
- rslt = 1
- GOTO ext
- ELSE
- IF ll_h >= 12 THEN
- rslt = 1
- GOTO ext
- ELSE
- IF ll_m <= 20 THEN
- rslt = 0
- arg_msg = 'MRP运算当中,请稍后操作'
- GOTO ext
- ELSE
- rslt = 1
- GOTO ext
- END IF
- END IF
- END IF
- ext:
- RETURN rslt
- end function
- global function integer f_outware_savelock (long arg_storageid, string arg_lockemp, ref string arg_msg);Int rslt = 1
- Int li_iflock
- Long ll_s
- IF sys_option_outware_save_lock = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- SELECT iflock,
- DATEDIFF(ss,locktime,getdate())
- INTO :li_iflock,
- :ll_s
- FROM u_outware_save_lock
- Where storageid = :arg_storageid;
- IF sqlca.SQLCode = -1 THEN
- arg_msg = '查询出仓单保存锁定标记失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- ELSEIF sqlca.SQLCode = 100 THEN
- //上锁
- INSERT INTO u_outware_save_lock(storageid,iflock,locktime,lockemp)
- Values(:arg_storageid,1,getdate(),:arg_lockemp);
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '新增出仓单仓库保存锁定标记失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- COMMIT;
- rslt = 1
- GOTO ext
- END IF
- IF li_iflock = 0 THEN
- //上锁
- UPDATE u_outware_save_lock
- SET iflock = 1,
- locktime = getdate(),
- lockemp = :arg_lockemp
- Where storageid = :arg_storageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新出仓单仓库保存锁定标记失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- COMMIT;
- rslt = 1
- GOTO ext
- ELSE
- //重新上锁
- IF ll_s >= 30 THEN
- UPDATE u_outware_save_lock
- SET iflock = 1,
- locktime = getdate(),
- lockemp = :arg_lockemp
- Where storageid = :arg_storageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新出仓单仓库保存锁定标记失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- COMMIT;
- rslt = 1
- GOTO ext
- ELSE
- rslt = 0
- arg_msg = '该仓库有出仓单正在保存,请稍后操作'
- GOTO ext
- END IF
- END IF
- ext:
- RETURN rslt
- end function
|