当前位置: 首页>>代码示例>>Python>>正文


Python MethodUtil.insertSysLog方法代码示例

本文整理汇总了Python中base.utils.MethodUtil.insertSysLog方法的典型用法代码示例。如果您正苦于以下问题:Python MethodUtil.insertSysLog方法的具体用法?Python MethodUtil.insertSysLog怎么用?Python MethodUtil.insertSysLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在base.utils.MethodUtil的用法示例。


在下文中一共展示了MethodUtil.insertSysLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: applySave

# 需要导入模块: from base.utils import MethodUtil [as 别名]
# 或者: from base.utils.MethodUtil import insertSysLog [as 别名]

#.........这里部分代码省略.........
                    costvalue = decimal.Decimal(0.0)

                unjsvalue = unbalancedCostValue(conn2,venderid,pstart)
                if not unjsvalue:
                    unjsvalue = decimal.Decimal(0.0)

                undqvalue = undueCostValue(conn2,venderid,pend)
                if not undqvalue:
                    undqvalue = decimal.Decimal(0.0)

                advance = findAdvance(conn2,venderid)
                if not advance:
                    advance = decimal.Decimal(0.0)

                payablemoney = sum([float(row["costvalue"]) for row in blist])
                if not payablemoney:
                    payablemoney = decimal.Decimal(0.0)

                params["payablemoney"]=float(payablemoney)   #应付金额
                params["advance"]=float(advance)        #预付款余额,预付款应扣金额(promoney)默认0 (写表billhead0)
                params["costvalue"]=float(costvalue)    #库存金额 (写表billhead0)
                params["undqvalue"]=float(undqvalue)    #未到期金额 (写表billhead0) 取不为空数据
                params["payableamt"]=float(payableamt)  #应付账款金额 (写表billhead0)
                params["unjsvalue"]=float(unjsvalue)    #应结未结金额 (写表billhead0) 取不为空数据

                #新增
                type=0
                typeStr = "新增"
                sheetId = getSheetId(conn2)

                conn = mtu.getMssqlConn()
                conn.autocommit(False)

                klist = findKxsum(conn,venderid,pend)
                kxmoney = sum([row["kmoney"] for row in klist])
                if not kxmoney:
                    kxmoney = decimal.Decimal(0.0)

                cashlist = filter(lambda row:row["kkflag"]==0,[row for row in klist])
                invoicelist =  filter(lambda row:row["kkflag"]==1,[row for row in klist])

                kxcash = sum([row["kmoney"] for row in cashlist])
                if not kxcash:
                    kxcash = decimal.Decimal(0.0)

                kxinvoice = sum([row["kmoney"] for row in invoicelist])
                if not kxinvoice:
                    kxinvoice = decimal.Decimal(0.0)

                #应付金额=实付金额+帐扣金额
                #应开票金额=实付金额
                params["kxmoney"]=float(kxmoney)    #扣项金额合计
                params["kxcash"]=float(kxcash)      #扣项交款金额
                params["kxinvoice"]=float(kxinvoice)  #帐扣发票金额 (帐扣金额)
                params["sheetid"] = sheetId

                #保存单据信息
                saveBillHead0(conn,params)

                #保存单据明细
                saveBillHeadItem(conn,blist,sheetId)

                #保存扣项明细
                saveKxItem(conn,klist,sheetId)

                cursor = conn.cursor()
                sqlFlow = "insert into sheetflow(sheetid,sheettype,flag,operflag,checker,checkno,checkdate,checkdatetime) " \
                          "values('{sheetId}',{shType},{flag},{operFlag},'{checker}',{chNo},convert(char(10),getdate(),120),getdate())"\
                          .format(sheetId=sheetId,shType=5203,flag=0,operFlag=0,checker=Constants.SCM_ACCOUNT_LOGINID,chNo=Constants.SCM_ACCOUNT_LOGINNO)
                cursor.execute(sqlFlow)
                conn.commit()
                cursor.close()
            except Exception as e:
                print(e)
                errors += 1
                conn.rollback()
            finally:
                conn.close()

            if errors <= 0:
                #执行保存存储过程
                sql = """declare @Result int
                       exec @Result=st_billheadsave '{sheetId}',{type},'{cname}','A001'
                       select @Result""".format(sheetId=sheetId,type=type,cname = Constants.SCM_ACCOUNT_USER_NAME)
                conn2.execute_scalar(sql)

                #保存日志记录
                note = "[SCM]操作员:[{operator}]{typeStr}单据[{sheetId}]".format(sheetId=sheetId,typeStr=typeStr,operator=s_ucode)
                mtu.insertSysLog(conn2,Constants.SCM_ACCOUNT_LOGINID,Constants.SCM_ACCOUNT_WORKSTATIONID,Constants.SCM_ACCOUNT_MODULEID,Constants.SCM_ACCOUNT_EVENTID[type],note)
                result["status"] = "0"
                result["sheetId"] = sheetId
                conn2.close()
            else:
                result["status"] = "1"
        except Exception as e:
            print(e)
    else:
        result["status"] = "2"

    return HttpResponse(json.dumps(result))
开发者ID:KGPython,项目名称:scm,代码行数:104,代码来源:views.py

示例2: saveInvioce

# 需要导入模块: from base.utils import MethodUtil [as 别名]
# 或者: from base.utils.MethodUtil import insertSysLog [as 别名]
def saveInvioce(request):
    conn = MethodUtil.getMssqlConn()
    conn2= MethodUtil.get_MssqlConn()
    suppCode = request.session.get('s_suppcode')
    suppName = request.session.get('s_suppname')

    ############接收表头相关数据(CustReceive0) ############
    planPayDate = request.POST.get('PlanPayDate')
    timeNow = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    payDate =  request.POST.get('payDate',timeNow)
    shopId = request.POST.get('shopId')
    refSheetId = request.POST.get('refSheetId','')
    beginDate = request.POST.get("begindate",'')
    endDate = request.POST.get("enddate",'')
    jsonStr = request.POST.get('jsonStr','')

    res = {}
    sql="select top 1 SheetID from CustReceive0 where VenderID='{suppCode}' and flag=0".format(suppCode=suppCode)
    row = conn2.execute_row(sql)
    if row:
        res['succ']= '2'
        res['sheetid']= row["SheetID"]
    else:
        try:
            #生成发票编号
            sqlSheetId = '''declare @i int,@SheetID char(16)
                  exec @i=TL_GetNewSheetID 5204,@SheetID out
                  select @SheetID
              '''
            sheetId = conn2.execute_scalar(sqlSheetId)

            # ############开始存储事务############
            conn.autocommit(False)
            cur = conn.cursor()
            #保存发票主要信息
            sqlCR = "insert into CustReceive0 (SheetID, BillheadSheetID, VenderID, PlanPayDate, BeginDate, EndDate,Flag, Editor, EditDate, ShopID, Operator) " \
                "values('{sheetid}','{billheadsheetid}',{venderid},'{planpaydate}','{begindate}','{enddate}',{flag},'{editor}','{editdate}','{shopid}','' )" \
            .format(sheetid=sheetId,billheadsheetid=refSheetId,venderid=suppCode,planpaydate=planPayDate,begindate=beginDate,enddate=endDate,
                    flag=0,editor=suppCode,editdate=payDate,shopid='CM01')
            cur.execute(sqlCR)

            #保存custitem0表数据res2[i][12]
            res2 = findCustItem(conn2,refSheetId,suppCode)
            for i in range(0,len(res2)):
                sqlCI = "insert into custitem0 " \
                        "values ('{SheetID}','{PayTypeSortID}','{PayableDate}','{RefSheetID}',{RefSheetType},{ManageDeptID},'{FromShopID}','{InShopID}','{CostValue}','{CostTaxValue}','{CostTaxRate}',{AgroFlag},'{SaleValue}',{BalanceBookSerialID})" \
                    .format(SheetID=sheetId,PayTypeSortID=res2[i][0],PayableDate=res2[i][11],RefSheetID=res2[i][1],RefSheetType=res2[i][2],ManageDeptID=res2[i][4],FromShopID=res2[i][13],InShopID=res2[i][5],
                            CostValue=res2[i][6],CostTaxValue=res2[i][8],CostTaxRate=res2[i][12],AgroFlag=res2[i][10],SaleValue=res2[i][9],BalanceBookSerialID=res2[i][16])
                cur.execute(sqlCI)

            #保存用户录入发票详细
            listData = json.loads(jsonStr)
            if listData:
                for data in listData:
                    #kmoney默认为0无需录入
                    sqlCRI = "insert into CustReceiveItem0 values( '"+sheetId+"','"+data['cno']+"','"+suppName+"','"+data['cdno']+"','"+data['cdate']+"',"+data['cclass']+",'"+data['cgood']+"','"+data['ctaxrate']+"','"+data['cmoney']+"','"+data['csh']+"',"+data['paytype']+",'0.0','"+shopId+"')"
                    cur.execute(sqlCRI)
            else:
                sql3 = "select a.jsdate,a.flag,a.fnotes,b.taxno,c.paytypeid from vendercard a,venderext b,vender c	where a.venderid=b.venderid and a.venderid=c.venderid and a.venderid={venderid}".format(venderid=suppCode)
                dict3 = conn2.execute_row(sql3)
                taxno = dict3["taxno"]
                sqlCRI = "insert into CustReceiveItem0 (sheetid,cno,cname,cdate,cclass,cgood,ctaxrate,cmoney,csh,cdno,PayType,kmoney,shopid) values( '"+sheetId+"','666666','"+suppName+"',getDate(),1,'货物',0.0,0.0,0.0,'"+taxno+"','1',0.0,'"+shopId+"')"
                cur.execute(sqlCRI)

            sqlFlow = "insert into sheetflow(sheetid,sheettype,flag,operflag,checker,checkno,checkdate,checkdatetime) " \
                      "values('{shid}',{shType},{flag},{operFlag},'{checker}',{chNo},convert(char(10),getdate(),120),getdate())"\
                      .format(shid=sheetId,shType=5024,flag=0,operFlag=0,checker=Constants.SCM_ACCOUNT_LOGINID,chNo=Constants.SCM_ACCOUNT_LOGINNO)
            cur.execute(sqlFlow)

            conn.commit()

            #记录发票录入状态
            try:
                if refSheetId:
                    billhead = Billhead0.objects.values("sheetid","flag","editdate","grpcode","venderid","shopid").get(sheetid=refSheetId)
                    if billhead:
                        Billhead0Status.objects.create(sheetid=refSheetId,inviocestatus=1,flag=billhead["flag"],editdate=billhead["editdate"],grpcode=billhead["grpcode"],venderid=billhead["venderid"],shopid=billhead["shopid"])
            except Exception as e:
                print(e)

            res['succ'] = '0'

            MethodUtil.insertSysLog(conn2,Constants.SCM_ACCOUNT_LOGINID,Constants.SCM_ACCOUNT_WORKSTATIONID,Constants.SCM_ACCOUNT_MODULEID,Constants.SCM_ACCOUNT_EVENTID[5],"")
            MethodUtil.insertSysLog(conn2,Constants.SCM_ACCOUNT_LOGINID,Constants.SCM_ACCOUNT_WORKSTATIONID,Constants.SCM_ACCOUNT_MODULEID,Constants.SCM_ACCOUNT_EVENTID[6],"操作员:{suppCode}保存单据[{sheetId}]".format(suppCode=suppCode,sheetId=sheetId))
        except Exception as e:
            print(e)
            res['succ'] = '1'
            conn.rollback()
        finally:
            cur.close()
            conn.close()
            conn2.close()

    return HttpResponse(json.dumps(res))
开发者ID:KGPython,项目名称:scm,代码行数:96,代码来源:views.py


注:本文中的base.utils.MethodUtil.insertSysLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。