示例#1
0
def updateToNullify(oracle, distri_id, oper_staff_id):
    '''更新in为nullify'''
    update_dic = {'state': 'nullify', 'state_date': '/sysdate'}
    where_dic = {'distri_id': distri_id, 'staff_id': oper_staff_id}
    and_the = "and state in('in','hold')"

    update(oracle, 'distri', update_dic, where_dic, and_the=and_the)
示例#2
0
def unbondStaff(oracle, **args):
    '''工号取消绑定 staff_id out_staff_id sys_type '''
    for k, v in args.items():
        exec "%s = '%s'"%(k,v)
    update_dic = {'state':'0'}
    where_dic = args
    update(oracle, 'staff_map', update_dic, where_dic)
示例#3
0
    def setDistriOut(self):
        checkBeginEndNbr(self.tax_begin_nbr, self.tax_end_nbr, 
        self.hold_tax_begin_nbr, self.hold_tax_end_nbr)
        update_dic = {'state':'out','state_date':'/sysdate'}
        where_dic = {'distri_id':self.distri_id}
        update(self.oracle, 'distri', update_dic, where_dic)

        insertDistriLog(self.oracle, distri_id = self.distri_id, oper_staff_id =
        self.oper_staff_id, oper = 'part be collect',state = 'out')
示例#4
0
    def updatePool(s):
        update_dic = {'state':s.state, 'state_date':'/sysdate', 'payment_id':s.payment_id, 'sys_type':s.sys_type, 'reprint_flag':s.reprint_flag}
        where_dic = {'staff_id':s.staff_id, 'tax_code':s.tax_code, 'tax_nbr':s.tax_nbr, 'state':'instance'}
        table_name = 'pool'
        update(s.oracle, table_name, update_dic, where_dic, need_lock = True)

        where_dic['state'] = s.state
        add_info = {'oper_staff_id':s.staff_id, 'oper':s.state, 'oper_date':'/sysdate'}
        insertLog(s.oracle, table_name, where_dic, add_info)
示例#5
0
        def updatePool(self):
            update_dic = {'state': 'abstract', 'state_date': '/sysdate'}
            self.where_dic['state'] = 'instance'

            update(oracle=oracle,
                   table_name='pool',
                   update_dic=update_dic,
                   where_dic=self.where_dic,
                   and_the=self.and_the,
                   count=self.reverse_count)
示例#6
0
    def changeBssOrg(self):
        update_dic = self.args
        del update_dic['bss_org_id']
        update(self.oracle,
               'bss_org',
               update_dic,
               where_dic={'bss_org_id': self.bss_org_id})

        add_infos = {
            'oper': 'change',
            'oper_staff_id': self.oper_staff_id,
            'oper_date': '/sysdate'
        }
        insertLog(self.oracle, 'bss_org', {'bss_org_id': self.bss_org_id},
                  add_infos)
示例#7
0
def updateToNullify(oracle, pool_id):
    '''更新instance为nullify'''
    update_dic = {'state': 'nullify', 'state_date': '/sysdate'}
    where_dic = {'pool_id': pool_id}

    #row_count = updatePool(oracle, update_dic, where_dic)
    #if(row_count!= 1):
    #    raise Exception, '作废录数有%s条,pool_id = %s'%(row_count, pool_id)
    and_the = "and state in('instance', 'pre-use')"

    update(oracle=oracle,
           table_name='pool',
           update_dic=update_dic,
           where_dic=where_dic,
           and_the=and_the)
示例#8
0
def delStaff(oracle, **args):
    '''删除工号 staff_id, oper_staff_id, [remark]'''
    for k, v in args.items():
        exec "%s = '%s'"%(k,v)
    is_upper = upperLevel(oracle, oper_staff_id, staff_id)
    if(not is_upper):
        raise Exception,'工号%s没有权限删除工号%s'%(oper_staff_id, staff_id)
    #sql = 'delete from staff where staff_id = %s'%staff_id
    update(oracle, 'staff', update_dic = {'state':'0'}, where_dic = {'staff_id':staff_id})
    #row_count = oracle.execute(sql)
    #if(row_count ==  0):
    #    raise Exception, '未能正确删除staff表;staff_id = %s'%staff_id

    add_infos = {'oper':'del', 'oper_staff_id':oper_staff_id, 'oper_date':'/sysdate'}
    insertLog(oracle, 'staff', {'staff_id':staff_id}, add_infos)
示例#9
0
def modifyRole(oracle, **args):
    '''role_id, oper_staff_id '''
    update_dic = args
    role_id = update_dic['role_id']
    oper_staff_id = update_dic['oper_staff_id']
    del update_dic['role_id']
    del update_dic['oper_staff_id']
    update(oracle, 'role', update_dic, where_dic={'role_id': role_id})

    add_infos = {
        'oper': 'modify',
        'oper_staff_id': oper_staff_id,
        'oper_date': '/sysdate'
    }
    insertLog(oracle, 'role', {'role_id': role_id}, add_infos)
示例#10
0
def allCollect(oracle, distri_id, oper_staff_id):
    '''全部回收'''
    update_dic = {'state':'out','state_date':'/sysdate'}
    where_dic = {'distri_id':distri_id}
    update(oracle, 'distri', update_dic, where_dic)
    
    insertDistriLog(oracle = oracle, distri_id = distri_id, oper_staff_id =
    oper_staff_id, oper = 'be collect',state = 'out')
    
    new_distri_id = getNextVal(oracle)
    insertDistriAsSplit(oracle, new_distri_id = new_distri_id, distri_id =
    distri_id, staff_id = oper_staff_id)

    insertDistriLog(oracle = oracle, distri_id = new_distri_id, oper_staff_id =
    oper_staff_id, oper = 'collect',state = 'hold')
示例#11
0
def changeStaff(oracle, **args):
    '''staff_id, oper_staff_id '''
    update_dic = args
    passwd = update_dic.get('passwd')
    if( passwd!= None):
        m = hashlib.md5()
        m.update(passwd)
        passwd = m.hexdigest()
        update_dic['passwd'] = passwd
    staff_id = update_dic['staff_id']
    oper_staff_id = update_dic['oper_staff_id']
    del update_dic['staff_id']
    del update_dic['oper_staff_id']
    update(oracle, 'staff', update_dic, where_dic = {'staff_id':staff_id})

    add_infos = {'oper':'modify', 'oper_staff_id':oper_staff_id, 'oper_date':'/sysdate'}
    insertLog(oracle, 'staff', {'staff_id':staff_id}, add_infos)
示例#12
0
def poolToAbstract(oracle, **args):
    for k, v in args.items():
        exec "%s = '%s'" % (k, v)
    update_dic = {'state': 'abstract', 'state_date': '/sysdate'}
    must_reverse_count = int(tax_end_nbr) - int(tax_begin_nbr) + 1

    where_dic = {
        'distri_id': distri_id,
        'state': 'instance',
        'tax_code': tax_code,
        'staff_id': oper_staff_id
    }

    and_the = "and to_number(tax_nbr)> = to_number('%s') and \
    to_number(tax_nbr)< = to_number('%s')" % (tax_begin_nbr, tax_end_nbr)

    update(oracle=oracle,
           table_name='pool',
           update_dic=update_dic,
           where_dic=where_dic,
           and_the=and_the,
           count=must_reverse_count)

    where_dic = {
        'tax_code': tax_code,
        'distri_id': distri_id,
        'state': 'abstract',
        'staff_id': oper_staff_id
    }
    add_infos = {'oper': 'abstract'}
    add_infos['oper_staff_id'] = oper_staff_id
    add_infos['oper_date'] = '/sysdate'

    insertLog(oracle, 'pool', where_dic, add_infos, and_the,
              must_reverse_count)
    #删掉
    delete(oracle=oracle,
           table_name='pool',
           where_dic=where_dic,
           count=must_reverse_count)
示例#13
0
    def updatePool(self):
        table_name = 'pool'
        #将要调的发票先置-1
        update_dic = {'tax_nbr': '-1', 'tax_code': '-1'}
        where_dic = {
            'pool_id': self.pool_id,
            'tax_code': self.tax_code,
            'tax_nbr': self.tax_nbr
        }
        update(oracle=self.oracle,
               table_name=table_name,
               update_dic=update_dic,
               where_dic=where_dic,
               and_the=self.and_the)

        #将被影响的发票置之
        update_dic = {'tax_nbr': self.tax_nbr, 'tax_code': self.tax_code}
        where_dic = {
            'pool_id': self.be_pool_id,
            'tax_code': self.new_tax_code,
            'tax_nbr': self.new_tax_nbr
        }
        update(oracle=self.oracle,
               table_name=table_name,
               update_dic=update_dic,
               where_dic=where_dic,
               and_the=self.and_the)

        where_dic = {'pool_id': self.be_pool_id}
        add_infos = {
            'oper': 'adjust',
            'oper_staff_id': self.oper_staff_id,
            'oper_date': '/sysdate'
        }
        insertLog(self.oracle, table_name, where_dic, add_infos)

        #将-1的置之
        update_dic = {
            'tax_nbr': self.new_tax_nbr,
            'tax_code': self.new_tax_code
        }
        where_dic = {
            'pool_id': self.pool_id,
            'tax_code': '-1',
            'tax_nbr': '-1'
        }
        update(oracle=self.oracle,
               table_name=table_name,
               update_dic=update_dic,
               where_dic=where_dic,
               and_the=self.and_the)

        where_dic = {'pool_id': self.pool_id}
        add_infos = {
            'oper': 'adjust',
            'oper_staff_id': self.oper_staff_id,
            'oper_date': '/sysdate'
        }
        insertLog(self.oracle, table_name, where_dic, add_infos)
示例#14
0
def changeRetail(oracle, dic):
    ''' id, flex_id, name, score, value, num'''
    for k, v in dic.items():
        exec "%s = '%s'" % (k, v)
    where_dic = {'id': id, 'flex_id': flex_id}
    update_dic = {
        'num': num,
        'name': name,
        'score': score,
        'value': value,
        'state_date': '/sysdate'
    }
    count = update(oracle=oracle,
                   table_name='retail_detail',
                   update_dic=update_dic,
                   where_dic=where_dic,
                   count=0)
    if (count == 0):
        dic['state_date'] = '/sysdate'
        insert(oracle, 'retail_detail', dic)
示例#15
0
def allInstance(oracle, **args):
    '''全部上架'''
    for k, v in args.items():
        exec "%s = '%s'" % (k, v)

    state = 'instance'
    update_dic = {'state': state, 'state_date': '/sysdate'}
    where_dic = {'distri_id': distri_id}
    update(oracle, 'distri', update_dic, where_dic,
           "and state in('in','hold')")
    insertDistriLog(oracle=oracle,
                    distri_id=distri_id,
                    oper_staff_id=oper_staff_id,
                    oper='instance',
                    state=state)

    #先插入一条
    dic = {}
    pool_id = pool.getNextVal(oracle)
    dic['pool_id'] = pool_id
    dic['distri_id'] = distri_id
    dic['tax_code'] = tax_code
    dic['tax_nbr'] = tax_begin_nbr
    #dic['sys_type'] = 'B'
    dic['state'] = 'instance'
    dic['state_date'] = '/sysdate'
    dic['staff_id'] = oper_staff_id
    insert(oracle, 'pool', dic)

    must_instance_count = int(tax_end_nbr) - int(tax_begin_nbr) + 1
    if (hold_tax_begin_nbr != hold_tax_end_nbr):

        length = len(hold_tax_begin_nbr)
        tax_nbr_list = []
        sql = '''	 insert into pool             
            		   (pool_id,                    
            		    distri_id,                  
            		    tax_code,                   
            		    tax_nbr,                    
            		    state,                      
            		    state_date,                 
            		    staff_id,                   
            		    sys_type)                
            		   (select pool_seq.nextval,        
            		           distri_id,           
            		           tax_code,            
            		           :tax_nbr,             
            		           state,               
            		           state_date,          
            		           staff_id,            
            		           sys_type            
            		      from  pool    
            		     where pool_id = %s)   ''' % pool_id
        if (int(hold_tax_end_nbr) - int(hold_tax_begin_nbr) > 100000):
            raise Warning_, '一次上架记录数有%s条,业务不允许,请下发拆分小于10W再上架' % (
                int(hold_tax_end_nbr) - int(hold_tax_begin_nbr))

        for i in range(int(hold_tax_begin_nbr) + 1, int(hold_tax_end_nbr) + 1):
            tax_nbr = addZero(length, i)
            dic = {'tax_nbr': tax_nbr}
            tax_nbr_list.append(dic)
        if (len(tax_nbr_list) > 100000):
            raise Warning_, '一次上架记录数有%s条,业务不允许,请下发拆分小于10W再上架'
        if (len(tax_nbr_list) > 50000):
            row_count = oracle.executemany(sql, tax_nbr_list[:50000])
            row_count += oracle.executemany(sql, tax_nbr_list[50000:])
        else:
            row_count = oracle.executemany(sql, tax_nbr_list)
        if (row_count != must_instance_count - 1):
            raise Exception, '未能正确上架 distri_id = %s,应上架%s,实际只上了%s,数据发生变动,请重新查' % (
                distri_id, must_instance_count, row_count + 1)

    where_dic = {
        'tax_code': tax_code,
        'distri_id': distri_id,
        'state': 'instance',
        'staff_id': oper_staff_id
    }
    and_the = "and to_number(tax_nbr)> = to_number('%s') and to_number(tax_nbr)< = to_number('%s')" % (
        tax_begin_nbr, tax_end_nbr)
    add_infos = {'oper': 'instance'}
    add_infos['oper_staff_id'] = oper_staff_id
    add_infos['oper_date'] = '/sysdate'
    insertLog(oracle, 'pool', where_dic, add_infos, and_the,
              must_instance_count)
示例#16
0
def partDistri(oracle, **args):
    '''部分下发
    in: tax_type, distri_id, staff_id, oper_staff_id, hold_staff_id, 
                tax_begin_nbr, tax_end_nbr, 
                hold_tax_begin_nbr, hold_tax_end_nbr
    '''
    for k, v in args.items():
        log.msg("%s type is %s" % (k, type(v)))
        if (type(v) is StringType or type(v) is UnicodeType):
            exec "%s = '%s'" % (k, v)
            print "%s = '%s'" % (k, v)
        else:
            exec "%s = %s" % (k, v)
            print "%s = %s" % (k, v)
    log.msg(type(tax_end_nbr))
    checkBeginEndNbr(tax_begin_nbr, tax_end_nbr, hold_tax_begin_nbr,
                     hold_tax_end_nbr)
    update_dic = {'state': 'out', 'state_date': '/sysdate'}
    where_dic = {'distri_id': distri_id}
    update(oracle, 'distri', update_dic, where_dic)
    insertDistriLog(oracle,
                    distri_id=distri_id,
                    oper_staff_id=oper_staff_id,
                    oper='part be distri',
                    state='out')

    #下发
    new_distri_id = getNextVal(oracle)
    insertDistriAsSplit(oracle,
                        new_distri_id=new_distri_id,
                        distri_id=distri_id,
                        staff_id=staff_id,
                        tax_begin_nbr=tax_begin_nbr,
                        tax_end_nbr=tax_end_nbr)
    insertDistriLog(oracle=oracle,
                    distri_id=new_distri_id,
                    oper_staff_id=oper_staff_id,
                    oper='distri',
                    state='hold')

    if (tax_type == 'r'):
        '''左下发拆分'''
        #拆分生成原持有右边剩下的
        new_distri_id = getNextVal(oracle)
        split_tax_begin_nbr = addZero(len(tax_end_nbr), int(tax_end_nbr) + 1)
        insertDistriAsSplit(oracle,
                            new_distri_id=new_distri_id,
                            distri_id=distri_id,
                            staff_id=hold_staff_id,
                            tax_begin_nbr=split_tax_begin_nbr,
                            tax_end_nbr=hold_tax_end_nbr)
        insertDistriLog(oracle=oracle,
                        distri_id=new_distri_id,
                        oper_staff_id=oper_staff_id,
                        oper='split distri',
                        state='hold')
    elif (tax_type == 'l'):
        '''右下发'''
        #拆分生成原持有左边剩下的
        new_distri_id = getNextVal(oracle)
        split_tax_end_nbr = addZero(len(tax_begin_nbr), int(tax_begin_nbr) - 1)
        insertDistriAsSplit(oracle,
                            new_distri_id=new_distri_id,
                            distri_id=distri_id,
                            staff_id=hold_staff_id,
                            tax_begin_nbr=hold_tax_begin_nbr,
                            tax_end_nbr=split_tax_end_nbr)
        insertDistriLog(oracle=oracle,
                        distri_id=new_distri_id,
                        oper_staff_id=oper_staff_id,
                        oper='split distri',
                        state='hold')
    elif (tax_type == 'm'):
        '''中间下发'''
        #左边
        new_distri_id = getNextVal(oracle)
        split_tax_end_nbr = addZero(len(tax_begin_nbr), int(tax_begin_nbr) - 1)
        insertDistriAsSplit(oracle,
                            new_distri_id=new_distri_id,
                            distri_id=distri_id,
                            staff_id=hold_staff_id,
                            tax_begin_nbr=hold_tax_begin_nbr,
                            tax_end_nbr=split_tax_end_nbr)
        insertDistriLog(oracle=oracle,
                        distri_id=new_distri_id,
                        oper_staff_id=oper_staff_id,
                        oper='split distri',
                        state='hold')
        #右边
        new_distri_id = getNextVal(oracle)
        split_tax_begin_nbr = addZero(len(tax_end_nbr), int(tax_end_nbr) + 1)
        insertDistriAsSplit(oracle,
                            new_distri_id=new_distri_id,
                            distri_id=distri_id,
                            staff_id=hold_staff_id,
                            tax_begin_nbr=split_tax_begin_nbr,
                            tax_end_nbr=hold_tax_end_nbr)
        insertDistriLog(oracle=oracle,
                        distri_id=new_distri_id,
                        oper_staff_id=oper_staff_id,
                        oper='split distri',
                        state='hold')
    else:
        raise Exception, '类型错误:%s' % tax_type
示例#17
0
def updateNeedUpdate(oracle, id, need_update):
    '''更新应查询的数目'''
    update(oracle = oracle, table_name = 'invoice.update_acct_id', update_dic = {'need_update':need_update}, where_dic = {'id':id})
    oracle.commit();
示例#18
0
def updateUpdateCount(oracle, id, update_count):
    '''更实际更新的数目'''
    update(oracle = oracle, table_name = 'invoice.update_acct_id', update_dic = {'update_count':update_count}, where_dic = {'id':id})
示例#19
0
    def updateInvoice(self):
        table_name = 'e_invoice'
        be_table_name = 'e_invoice'
        if (self.sys_type == 'C'):
            table_name = 'e_invoice_crm'
        elif (self.sys_type == 'B'):
            table_name = 'e_invoice_bill'
        else:
            raise Exception('取到的系统类型为%s,不正确' % self.sys_type)

        if (self.be_state == 'use' or self.be_state == 'reverse'
                or self.be_state == 'abdicate'):
            if (self.be_sys_type == 'C'):
                be_table_name = 'e_invoice_crm'
            elif (self.sys_type == 'B'):
                be_table_name = 'e_invoice_bill'
            else:
                raise Exception('取到的系统类型为%s,不正确' % self.be_sys_type)

            update_dic = {'tax_nbr': '-1', 'tax_code': '-1'}
            where_dic = {'tax_code': self.tax_code, 'tax_nbr': self.tax_nbr}
            update(oracle=self.oracle,
                   table_name=table_name,
                   update_dic=update_dic,
                   where_dic=where_dic)

            update_dic = {'tax_nbr': self.tax_nbr, 'tax_code': self.tax_code}
            where_dic = {
                'tax_code': self.new_tax_code,
                'tax_nbr': self.new_tax_nbr
            }
            update(oracle=self.oracle,
                   table_name=be_table_name,
                   update_dic=update_dic,
                   where_dic=where_dic)

            dic = {
                'pool_id': self.be_pool_id,
                'new_tax_code': self.tax_code,
                'new_tax_nbr': self.tax_nbr,
                'tax_code': self.new_tax_code,
                'tax_nbr': self.new_tax_nbr,
                'oper_staff_id': self.oper_staff_id
            }
            adjustLog(self.oracle, dic)

            update_dic = {
                'tax_nbr': self.new_tax_nbr,
                'tax_code': self.new_tax_code
            }
            where_dic = {'tax_code': '-1', 'tax_nbr': '-1'}
            update(oracle=self.oracle,
                   table_name=table_name,
                   update_dic=update_dic,
                   where_dic=where_dic)

            self.args['pool_id'] = self.pool_id
            adjustLog(self.oracle, self.args)
        else:
            sql = "update %s p set p.tax_code = '%s', p.tax_nbr = '%s' where \
            tax_code = '%s' and tax_nbr = '%s'" % (
                table_name, self.new_tax_code, self.new_tax_nbr, self.tax_code,
                self.tax_nbr)
            row_count = self.oracle.execute(sql)
            if (row_count != 1):
                raise Exception('update %s表记录数%s' % (table_name, row_count))
            self.args['pool_id'] = self.pool_id
            adjustLog(self.oracle, self.args)