Exemple #1
0
def funcmodel(request):
    log = public.logger

    try:

        cur = connection.cursor()  # 创建游标

        cur.close()

    except Exception as ex:
        log.error("获取数据表信息失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100100", "获取数据表信息失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {},
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #2
0
def get_crud_list(request):
    log = public.logger
    try:
        cur = connection.cursor()  # 创建游标
        sql = "select app_id, app_name from sys_crud_cfg_head order by upd_time desc"
        cur.execute(sql)
        rows = cur.fetchall()
        crud_list = []
        for item in rows:
            tableitem = {}
            tableitem["value"] = str(item[0])
            tableitem["lable"] = str(item[0]) + '  ' + str(item[1])
            crud_list.append(tableitem)
        cur.close()
    except Exception as ex:
        log.error("获取增删改查配置信息失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100103", "获取增删改查配置信息失败!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "crud_list": crud_list
        }
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #3
0
def attend_schedule_save(request):
    log = public.logger
    body = public.req_body
    form_var = body['form_var']
    try:
        cur = connection.cursor()  # 创建游标

        month_id = form_var.get('month_id')
        group_list = form_var.get('group_list')
        # 插入休息日字段
        day_list_option = form_var.get('day_list_option')
        day_list = form_var.get('day_list')
        month_day_list = []
        for item in day_list_option:
            month_day_list.append(item.get('key'))
        res_day_list = set(month_day_list).difference(set(day_list))
        res_day_list = list(res_day_list)
        sql_value = (str(day_list), str(res_day_list), form_var.get('work_time'), form_var.get('closing_time'),
                     form_var.get('am_closing'), form_var.get('pm_start'),
                     form_var.get('group_list'), form_var.get('month_id'))
        log.info("============STR_LIST===========")
        log.info(str(form_var.get('day_list')))
        if month_id and group_list:
            sql = 'select 1 from yw_workflow_attend_group_cfg where group_id = %s and month_id = %s'
            cur.execute(sql, (form_var.get('group_list'), form_var.get('month_id')))

            row = cur.fetchone()
            if row:  # 有数据, 更新
                sql = "update yw_workflow_attend_group_cfg set work_day=%s, rest_day=%s,work_time=%s," \
                      "closing_time=%s,am_closing_time=%s,pm_start_time=%s where group_id = %s and month_id = %s"
            else:  # 无数据,插入
                sql = "insert into yw_workflow_attend_group_cfg (work_day,rest_day,work_time,closing_time," \
                      "am_closing_time,pm_start_time, group_id, month_id) values (%s, %s, %s, %s, %s, %s, %s, %s)"
        else:
            pass
        log.info(sql, sql_value)

        cur.execute(sql, sql_value)
    except Exception as ex:
        log.error("更新数据失败!" + str(ex), exc_info=True, extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info()
        public.respcode, public.respmsg = "100010", "更新数据失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())

    else:
        public.respcode, public.respmsg = "000000", "交易成功!"
        json_data = {
            "HEAD": public.resphead_setvalue(),
            "BODY": {
                "form_var": form_var
            }
        }
        s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
        public.respinfo = HttpResponse(s)
    finally:
        cur.close()  # 关闭游标

    return public.respinfo
Exemple #4
0
def boxing_begin_set(request):
    log = public.logger
    body = public.req_body
    try:
        form_var = body.get('form_var')
        orderid = form_var.get('order_id')
        modelid = form_var.get('model_id')

        cur = connection.cursor()  # 创建游标

        sql = "select box_code, tray_code, model_box_seq, model_tray_seq, state from yw_project_boxing_info " \
              "where order_id=%s and model_id=%s "
        cur.execute(sql, (orderid, modelid))
        row = cur.fetchone()
        if not row:
            cur.close()
            public.respcode, public.respmsg = "554901", "此工单没有待装箱的模块!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        now_box_code = row[0]
        now_tray_code = row[1]
        model_box_seq = row[2]
        model_tray_seq = row[3]
        db_state = row[4]
        if db_state == '1':
            cur.close()
            public.respcode, public.respmsg = "554903", "此模块ID已装箱!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        fix_out = True
        sql = "insert into yw_project_boxing_info_lasttray(order_id, box_code,tray_code,model_id, fix_out,errinfo ) " \
              "values( '%s', '%s', '%s', '%s', '%s', '%s')" \
              % (orderid, now_box_code, now_tray_code, modelid, fix_out, '管理台设置装箱数据')
        cur.execute(sql)

        cur.close()

        form_var['box_code'] = now_box_code
        form_var['tray_code'] = now_tray_code
        form_var['model_box_seq'] = model_box_seq
        form_var['model_tray_seq'] = model_tray_seq
    except Exception as ex:
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        cur.close()
        public.respcode, public.respmsg = "300010", "交易失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {"HEAD": public.resphead_setvalue(), "BODY": body}
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #5
0
def docment_manage_fileauth_cfg(request):
    log = public.logger
    form_var = public.req_body['form_var']

    try:
        cur = connection.cursor()  # 创建游标

        file_type = form_var.get('file_type')
        if not file_type:
            public.respcode, public.respmsg = "310310", "请先选择文件类型!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        form_var['read_cfginfo'] = str(form_var.get('read_cfginfo'))
        form_var['write_cfginfo'] = str(form_var.get('write_cfginfo'))

        flag, msg = public_db.insert_or_update_table(
            cur, 'yw_workflow_document_manage_cfg', **form_var)
        if not flag:
            public.respcode, public.respmsg = "310310", msg
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        # sql = "select 1 from yw_workflow_document_manage_cfg where file_type=%s"
        # cur.execute(sql, file_type)
        # row = cur.fetchone()
        # if row:  # 有数据, 更新
        #     sql = "update yw_workflow_document_manage_cfg set read_cfgtype=%s,read_cfginfo=%s, write_cfgtype=%s,write_cfginfo=%s  " \
        #           "where file_type=%s"
        # else:  # 无数据,插入
        #     sql = "insert into yw_workflow_document_manage_cfg(read_cfgtype,read_cfginfo,write_cfgtype,write_cfginfo, file_type) " \
        #           "values(%s, %s, %s, %s, %s)"
        # cur.execute(sql,
        #             (form_var.get('read_cfgtype'), str(form_var.get('read_cfginfo')), form_var.get('write_cfgtype'),
        #              str(form_var.get('write_cfginfo')), file_type))
    except Exception as ex:
        log.error("更新数据失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100010", "更新数据失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())

    else:
        public.respcode, public.respmsg = "000000", "交易成功!"
        json_data = {
            "HEAD": public.resphead_setvalue(),
            "BODY": {
                "form_var": form_var
            }
        }
        s = json.dumps(json_data,
                       cls=public.JsonCustomEncoder,
                       ensure_ascii=False)
        public.respinfo = HttpResponse(s)
    finally:
        cur.close()  # 关闭游标

    return public.respinfo
Exemple #6
0
def get_menu_info(request):
    log = public.logger
    body = public.req_body
    menuid = body.get('menu_id')
    if not menuid:
        public.respcode, public.respmsg = "100112", "menu_id不可为空!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        cur = connection.cursor()  # 创建游标
        sql = "select a.menu_id, a.menu_name, a.is_run_menu, a.menu_desc, a.order_id, a.app_id, a.menu_type, a.menu_path, " \
              "a.menu_icon, a.is_enable, a.above_menu_id " \
              "from sys_menu a  where a.menu_id =%s "
        log.info("查询菜单详情:" + sql % menuid, extra={'ptlsh': public.req_seq})
        cur.execute(sql, (menuid))
        row = cur.fetchone()
        if not row:
            cur.close()
            log.info("对应的MENUID不存在!", extra={'ptlsh': public.req_seq})
            public.respcode, public.respmsg = "100111", "对应的MENUID不存在!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        menuinfo = {}
        menuinfo['menu_id'] = str(row[0])
        menuinfo['menu_name'] = row[1]
        menuinfo['menu_desc'] = row[3]
        menuinfo['menu_seq'] = row[4]  #排序号
        menuinfo['menu_appid'] = row[5]
        menuinfo['menu_type'] = row[6]  #菜单类型 目录,自定义等。。
        menuinfo['menu_path'] = row[7]  # 菜单路径(自定义路径)
        menuinfo['menu_icon'] = row[8]  # 菜单图标
        menuinfo['is_active'] = public.Y2True(row[9])
        menuinfo['above_menu_id'] = row[10]  # 上级菜单ID

        cur.close()

    except Exception as ex:
        log.error("菜单信息查询失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100200", "菜单信息查询失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "menuinfo": menuinfo,
        },
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #7
0
def transfer_attend_manage_groupcfg(request):
    log = public.logger
    body = public.req_body
    select_key = body.get('select_key')
    form_var = body.get('form_var')
    group_list = form_var.get('group_list')
    try:
        transfer = []  # 全部数据, 数据变量
        transfer_data = []  # 已选中数据,绑定变量

        if not group_list:
            public.respcode, public.respmsg = "310310", "请先选择考勤組!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        cur = connection.cursor()  # 创建游标
        # sql = "SELECT user_id,user_name FROM sys_user  WHERE state='1'"
        sql = "SELECT job_num,name from yw_workflow_attend_mx GROUP BY job_num"
        cur.execute(sql)
        rows = cur.fetchall()
        for item in rows:
            transfer.append({
                "key": item[0],
                "label": str(item[1]),
                "disabled": False
            })
        sql = "SELECT user_id from yw_workflow_attend_group_user where group_id = %s"
        log.info("group_list: [%s]" % group_list)
        cur.execute(sql, group_list)
        row = cur.fetchone()
        if row:
            for subitem in eval(row[0]):
                transfer_data.append(subitem)
        cur.close()

        form_var['userinfo_option'] = transfer
        form_var['userinfo'] = transfer_data
    except Exception as ex:
        log.error("生成穿梭框数据失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "303010", "生成穿梭框数据失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return '' ''

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "form_var": form_var,
        }
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #8
0
def export_abnormal_detail_excel(request):
    """导出考勤异常详单"""
    log = public.logger
    body = public.req_body
    form_var = body['form_var']
    month_id = form_var.get('month_id')
    if not month_id:
        public.respcode, public.respmsg = "310310", "请先选择考勤月份!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        sql = "select id,state from yw_workflow_attend_report_mx where substr(natural_day,1,7) = '%s'" % month_id
        cur = connection.cursor()
        cur.execute(sql)
        rows = cur.fetchall()
        if not rows:
            public.respcode, public.respmsg = "310314", "该月尚未生成报表!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        else:
            id_list = []
            abnormal_list = ['迟到', '早退', '事假', '病假', '丧假', '产假', '陪产假', '待处理']
            for row in rows:
                attend_state = eval(row[1])
                if set(attend_state).intersection(set(abnormal_list)):
                    id_list.append(row[0])
            abnormal_sql = "select department,job_num,user_name,natural_day,in_time,out_time,state " \
                           "from yw_workflow_attend_report_mx " \
                           "where id in %s" % str(tuple(id_list))

            file_name = month_id + '_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S") + '考勤异常记录.xlsx'
            full_file_name = public.localhome + '/static/filedown/' + file_name
            # 导出Excel
            pubfunc.export_excel(full_file_name, abnormal_sql)
            form_var['file_download_path'] = '/static/filedown/' + file_name

    except Exception as ex:
        log.error(ex)
        # tr.close()
        log.error('导出数据到excel文件错误', exc_info=True)
        data = {
            "respcode": "000000",
            "respmsg": "导出数据到excel文件错误",
            "trantype": public.req_head.get('trantype', None)
        }
    else:
        public.respcode, public.respmsg = "000000", "交易成功!"
        json_data = {
            "HEAD": public.resphead_setvalue(),
            "BODY": {
                "form_var": form_var
            }
        }
        s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
        public.respinfo = HttpResponse(s)
        return public.respinfo
Exemple #9
0
def erp_check_everyday_getdata(request):
    log = public.logger
    body = public.req_body
    form_data = body.get('form_data')
    if not form_data:  #未上传数据,估计是新增
        selectd_data = {}
        form_data = {}
    else:
        selectd_data = form_data.get('selectd_data')

    try:
        cur = connection.cursor()  # 创建游标

        # 赋值返回数据
        data = {}
        if selectd_data:
            selectd = selectd_data[0]
            data['id'] = selectd.get('id')
            data['check_name'] = selectd.get('check_name')
            data['check_date'] = selectd.get('check_date')
            data['check_sql'] = selectd.get('check_sql')
            data['check_state'] = selectd.get('check_state')
            data['check_msg'] = selectd.get('check_msg')
        cur.close()

        data["check_state_options"] = [{
            "key": "0",
            "value": "停用"
        }, {
            "key": "1",
            "value": "启用"
        }]
        # submit_power = {"show": True, "disabled": False} #放开提交按钮

    except Exception as ex:
        log.error("生成数据失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "300010", "生成数据失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "form_var": data,
        }
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #10
0
def docment_copy_by_seclass(request):
    """文档三级目录复制"""
    log = public.logger
    body = public.req_body
    form_var = body['form_var']
    try:
        company = form_var.get('company')
        seclasstype = form_var.get('seclasstype')
        if not company:
            public.respcode, public.respmsg = "310314", "公司不可为空!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        if not seclasstype:
            public.respcode, public.respmsg = "310314", "二级文档类别不可为空!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        cur = connection.cursor()  # 创建游标
        # 查询该公司下属二级目录
        sql = "select class_name,class_spell from yw_workflow_document_classtype where class_top = %s and class_rank=3 "
        cur.execute(sql, seclasstype)
        rows = cur.fetchall()
        if not rows:
            public.respcode, public.respmsg = "310318", "该文档类别下没有可供复制的三级目录!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        dict_list = [{'class_name': k, 'class_spell': v} for k, v in rows]
        form_var['trdclasslist'] = dict_list
    except Exception as ex:
        log.error("更新数据失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100010", "查询数据失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())

    else:
        public.respcode, public.respmsg = "000000", "交易成功!"
        json_data = {
            "HEAD": public.resphead_setvalue(),
            "BODY": {
                "form_var": form_var
            }
        }
        s = json.dumps(json_data,
                       cls=public.JsonCustomEncoder,
                       ensure_ascii=False)
        public.respinfo = HttpResponse(s)
    finally:
        cur.close()  # 关闭游标

    return public.respinfo
Exemple #11
0
def workflow_get_user_list(request):
    log = public.logger
    body = public.req_body
    # formid=body.get("form_id")
    #
    # if not formid:
    #     public.respcode, public.respmsg = "110221", "表单ID不可为空!"
    #     public.respinfo = HttpResponse(public.setrespinfo())
    #     return public.respinfo

    try:
        cur = connection.cursor()  # 创建游标
        sql = "select user_id, user_name from sys_user where state='1' "
        cur.execute(sql)
        rows = cur.fetchall()
        user_list = []

        # 先初始化几个特殊的用户
        user_list.append({
            "key": "org_leader",
            "value": 'org_leader' + '-' + '部门负责人'
        })

        for item in rows:
            user_list.append({
                "key": item[0],
                "value": str(item[0]) + '-' + item[1]
            })

        cur.close()

    except Exception as ex:
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "user_list": user_list,
        },
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #12
0
def get_table_info(request):
    log = public.logger
    body = public.req_body  # 请求报文体
    tablename = body.get('tablename')
    if not tablename:
        public.respcode, public.respmsg = "100101", "表名必输!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    cur = connection.cursor()
    # 根据表名获取表信息
    tablename = tablename.upper()
    try:
        sql = "SELECT LOWER(column_name), column_comment FROM information_schema.columns " \
              "WHERE UPPER(table_name) = UPPER(%s) order by ordinal_position asc"
        # log.info(sql % tablename)
        cur.execute(sql, tablename)
        rows = cur.fetchall()

        table_field = []

        loopid = 0
        for item in rows:
            tableitem = {}
            loopid = loopid + 1
            tableitem["field_id"] = item[0]
            tableitem["field_name"] = item[1]
            table_field.append(tableitem)
        cur.close()
    except Exception as ex:
        log.error("获取数据表信息失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100102", "获取数据表信息失败!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "table_field": table_field
        }
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #13
0
def erp_check_everyday_getlist(request):
    log = public.logger
    body = public.req_body
    form_var = body.get('form_var')
    form_data = body.get('form_data')
    try:
        cur = connection.cursor()  # 创建游标
        # 获取线别字典
        tableData = []
        sql = "select id,check_name,check_date,check_sql,check_state,check_msg from yw_lqerp_check_everyday order by id desc"
        cur.execute(sql)
        rows = cur.fetchall()
        for item in rows:
            dataitem = {}
            dataitem['id'] = item[0]
            dataitem['check_name'] = item[1]
            dataitem['check_date'] = item[2]
            dataitem['check_sql'] = item[3]
            dataitem['check_state'] = item[4]
            dataitem['check_msg'] = item[5]
            tableData.append(dataitem)
        cur.close()

        submit_power = {"show": True, "disabled": False}  #放开提交按钮

    except Exception as ex:
        log.error("生成数据失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "300010", "生成数据失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "form_var": {
                "tableData": tableData,
                "submit_power": submit_power,
            },
        }
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #14
0
def get_workflow_cfg_info(request):
    log = public.logger
    body = public.req_body
    formid = body.get("form_id")

    if not formid:
        public.respcode, public.respmsg = "110221", "表单ID不可为空!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        workflow_info = []
        cur = connection.cursor()  # 创建游标
        sql = "select wf_id, wf_notes, wf_prev,wf_type,wf_cfg from sys_workflow_node_cfg where form_id=%s "
        cur.execute(sql, formid)
        rows = cur.fetchall()
        for item in rows:
            wfinfo = {}
            wfinfo['wf_id'] = item[0]
            wfinfo['wf_notes'] = item[1]
            wfinfo['wf_prev'] = item[2]
            wfinfo['wf_type'] = item[3]
            if item[4]:
                wfinfo['wf_cfg'] = eval(item[4])
            else:
                wfinfo['wf_cfg'] = {}
            workflow_info.append(wfinfo)
        cur.close()  # 关闭游标

    except Exception as ex:
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "workflow_info": workflow_info,
        },
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #15
0
def export_report_excel(request):
    """导出考勤报表"""
    log = public.logger
    body = public.req_body
    form_var = body['form_var']
    month_id = form_var.get('month_id')
    if not month_id:
        public.respcode, public.respmsg = "310310", "请先选择考勤月份!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        sql = "select month_id,department,user_name,job_num,chid,zaot,gonx,tx,shij,bingj,chuc,sangj,cj,pcj,attend_days," \
              "work_days from yw_workflow_attend_report where month_id = '%s'" % month_id
        cur = connection.cursor()
        cur.execute(sql)
        row = cur.fetchone()
        if not row:
            public.respcode, public.respmsg = "310314", "该月尚未生成报表!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        file_name = month_id + '_' + datetime.datetime.now().strftime("%Y%m%d%H%M%S") + '考勤报表.xlsx'
        full_file_name = public.localhome + '/static/filedown/' + file_name
        # 导出Excel
        pubfunc.export_excel(full_file_name, sql)
        form_var['file_download_path'] = '/static/filedown/' + file_name

    except Exception as ex:
        log.error(ex)
        # tr.close()
        log.error('导出数据到excel文件错误', exc_info=True)
        data = {
            "respcode": "000000",
            "respmsg": "导出数据到excel文件错误",
            "trantype": public.req_head.get('trantype', None)
        }
    else:
        public.respcode, public.respmsg = "000000", "交易成功!"
        json_data = {
            "HEAD": public.resphead_setvalue(),
            "BODY": {
                "form_var": form_var
            }
        }
        s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
        public.respinfo = HttpResponse(s)
        return public.respinfo
Exemple #16
0
def order_detail_add(request):
    log = public.logger
    body = public.req_body
    form_var = body.get('form_var')
    if not form_var:
        public.respcode, public.respmsg = "387711", "上送数据异常!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        cur = connection.cursor()  # 创建游标

        sql = "insert into yw_workflow_work_order(start_time,sponsor,  order_type, receiver, order_urgent_type, " \
              "receiving_department, require_completion_time, requirments, requirements_ziliao, remarks, state) " \
              "values(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, '0')"
        cur.execute(sql, (form_var.get('start_time'), public.user_id,
                          form_var.get('order_type'), form_var.get('receiver'),
                          form_var.get('order_urgent_type'),
                          form_var.get('receiving_department'),
                          form_var.get('require_completion_time'),
                          form_var.get('requirments'),
                          str(form_var.get('requirements_ziliao')),
                          form_var.get('remarks')))
        form_var['state_info'] = '0'

        cur.close()

    except Exception as ex:
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.respcode, public.respmsg = "999999", str(ex)
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": body,
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #17
0
def delete_menu_info(request):
    log = public.logger
    body = public.req_body
    menuid = body.get('menu_id')
    if not menuid:
        public.respcode, public.respmsg = "100312", "menu_id不可为空!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        cur = connection.cursor()  # 创建游标
        sql = "select menu_id,menu_name from sys_menu where above_menu_id = %s "  #查看是否有下级菜单
        log.info("查看是否有下级菜单:" + sql % menuid, extra={'ptlsh': public.req_seq})
        cur.execute(sql, (menuid))
        row = cur.fetchone()
        if row:
            cur.close()
            public.respcode, public.respmsg = "100316", "请先删除下级菜单!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        sql = "delete from sys_menu where menu_id=%s "  # 查看是否有下级菜单
        log.info("删除菜单:" + sql % menuid, extra={'ptlsh': public.req_seq})
        cur.execute(sql, (menuid))

        cur.close()

    except Exception as ex:
        log.error("菜单信息删除失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100300", "菜单信息删除失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {},
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #18
0
def erp_check_everyday_savedata(request):
    log = public.logger
    body = public.req_body
    form_var = body.get('form_var')

    try:
        cur = connection.cursor()  # 创建游标

        if form_var.get('id'):
            sql = "update yw_lqerp_check_everyday set check_name=%s,check_date=%s,check_sql=%s,check_state=%s," \
                  "check_msg=%s where id=%s "
            cur.execute(
                sql, (form_var.get('check_name'), form_var.get('check_date'),
                      form_var.get('check_sql'), form_var.get('check_state'),
                      form_var.get('check_msg'), form_var.get('id')))
        else:
            sql = "insert into yw_lqerp_check_everyday(check_name,check_date,check_sql,check_state,check_msg) " \
                  "values(%s, %s, %s, %s, %s)"
            cur.execute(
                sql, (form_var.get('check_name'), form_var.get('check_date'),
                      form_var.get('check_sql'), form_var.get('check_state'),
                      form_var.get('check_msg')))

        cur.close()
    except Exception as ex:
        log.error("保存数据失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "300010", "保存数据失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "form_var": form_var,
        }
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #19
0
def workflow_get_formfield_info(request):
    log = public.logger
    body = public.req_body
    formid = body.get("form_id")

    if not formid:
        public.respcode, public.respmsg = "110221", "表单ID不可为空!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        cur = connection.cursor()  # 创建游标
        sql = "select field_id, field_name from sys_form_cfg_fieldlist where form_id=%s " \
              "and comp_type in ('textarea', 'input', 'datetime', 'select', 'radio', 'date')"
        cur.execute(sql, formid)
        rows = cur.fetchall()
        field_list = []
        for item in rows:
            field_list.append({"key": item[0], "value": item[1]})

        cur.close()

    except Exception as ex:
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "field_list": field_list,
        },
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #20
0
def workflow_cfg_create(request):
    log = public.logger
    body = public.req_body
    formid = body.get("form_id")

    if not formid:
        public.respcode, public.respmsg = "110221", "表单ID不可为空!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    wf_id = int(public.getintrandom(6))
    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "wf_id": wf_id,
        },
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #21
0
def attend_manage_group_cfg(request):
    log = public.logger
    form_var = public.req_body['form_var']
    try:
        cur = connection.cursor()  # 创建游标
        group_list = form_var.get('group_list')
        if not group_list:
            public.respcode, public.respmsg = "310310", "请先选择考勤組!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        sql = "select 1 from yw_workflow_attend_group_user where group_id=%s"
        cur.execute(sql, group_list)
        row = cur.fetchone()
        if row:  # 有数据, 更新
            sql = "update yw_workflow_attend_group_user set user_id=%s where group_id=%s"
        else:  # 无数据,插入
            sql = "insert into yw_workflow_attend_group_user (user_id, group_id) values (%s, %s)"
        log.info(sql, (str(form_var.get('userinfo')), group_list))
        cur.execute(sql, (str(form_var.get('userinfo')), group_list))
    except Exception as ex:
        log.error("更新数据失败!" + str(ex), exc_info=True, extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info()
        public.respcode, public.respmsg = "100010", "更新数据失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())

    else:
        public.respcode, public.respmsg = "000000", "交易成功!"
        json_data = {
            "HEAD": public.resphead_setvalue(),
            "BODY": {
                "form_var": form_var
            }
        }
        s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
        public.respinfo = HttpResponse(s)
    finally:
        cur.close()  # 关闭游标

    return public.respinfo
Exemple #22
0
def test_boxdata_clear(request):
    log = public.logger
    body = public.req_body
    try:
        cur = connection.cursor()  # 创建游标
        orderid = 'MO2012A129'
        sql = "update yw_project_boxing_info set state='0' where order_id = '%s' " % orderid
        cur.execute(sql)

        sql = "delete from yw_project_meterread_test_info where Batch_Num = '%s' " % orderid
        cur.execute(sql)

        sql = "delete from yw_project_snid_detail where order_id = '%s' " % orderid
        cur.execute(sql)

        sql = "delete from yw_project_boxing_info_autoput_detail where order_id = '%s' " % orderid
        cur.execute(sql)

        sql = "delete from yw_project_boxing_info_lasttray where order_id = '%s' " % orderid
        cur.execute(sql)

        cur.close()

        body['form_var']['result'] = '清理数据完成!'
    except Exception as ex:
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        cur.close()
        public.respcode, public.respmsg = "300010", "交易失败!" + str(ex)
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {"HEAD": public.resphead_setvalue(), "BODY": body}
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #23
0
def workflow_get_org_list(request):
    log = public.logger
    body = public.req_body
    org_list = []
    try:
        cur = connection.cursor()

        sql = " select org_id, org_name from sys_org where org_state='1' "
        log.info(sql)
        cur.execute(sql)
        rows = cur.fetchall()
        for item in rows:
            org_list.append({
                "key": item[0],
                "value": str(item[0]) + '-' + item[1]
            })
        cur.close()

    except Exception as ex:
        cur.close()
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "org_list": org_list,
        },
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #24
0
def get_table_list(request):
    log = public.logger
    try:
        cur = connection.cursor()  # 创建游标
        sql="select table_name, table_comment from information_schema.tables " \
            "where table_schema not in ('sys', 'mysql','performance_schema','information_schema') " \
            "order by table_name asc"
        cur.execute(sql)
        rows = cur.fetchall()
        table_list = []
        for item in rows:
            tableitem = {}
            tableitem["value"] = item[0]
            tableitem["lable"] = item[0] + '  ' + item[1]
            table_list.append(tableitem)
        cur.close()
    except Exception as ex:
        log.error("获取数据表信息失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100100", "获取数据表信息失败!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "table_list": table_list
        }
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #25
0
def get_crud_data(request):
    log = public.logger
    body = public.req_body

    if not public.menu_id:
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100103", "配置交易上送信息有误!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    #开始处理
    try:
        # 翻页查询请求
        pagesize = int(body.get('pagesize', "10"))
        pagenum = int(body.get('pagenum', "1"))

        cur = connection.cursor()  # 创建游标
        # 根据menuid获取增删改查配置的appid
        sql = "select app_id from sys_menu where menu_id='%s' " % (
            public.menu_id)
        cur.execute(sql)
        row = cur.fetchone()
        if row:
            appid = row[0]
        else:
            public.respcode, public.respmsg = "100105", "查询菜单对应的APPID异常!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        if not appid:
            public.respcode, public.respmsg = "100105", "查询菜单对应的APPID异常!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        # 查询增删改查配置HEAD信息
        sql = "select where_ctrl, order_ctrl, table_name" \
              " from sys_crud_cfg_head where app_id=%s "
        # log.info("查询增删改查配置HEAD信息:"+sql % appid, extra={'ptlsh':public.req_seq})
        cur.execute(sql, appid)
        crud_head_row = cur.fetchone()
        if crud_head_row:
            where_ctrl = crud_head_row[0]
            order_ctrl = crud_head_row[1]
            table_name = crud_head_row[2]
        else:
            public.respcode, public.respmsg = "100115", "查询APPID异常,数据不存在!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        searchinfo = body.get('searchinfo', None)
        whereinfo = ""
        # print( type(searchinfo), searchinfo )
        if searchinfo:
            # 有查询条件
            for item in searchinfo:
                selectid = item.get('selectid', None)
                selecttype = item.get('selecttype', None)
                selectvalue = item.get('selectvalue', None)

                if selectid == None or selectid == "":
                    continue
                if selecttype == None or selecttype == "":
                    continue

                # if item['uitype'] == 'datetime' and selectvalue:
                #     selectvalue = datetime.datetime.strptime(selectvalue, "%Y-%m-%d %H:%M:%S")
                if selecttype == 'like' and selectvalue:
                    selectvalue = "%" + selectvalue + "%"
                wheretemp = " and " + selectid + " " + selecttype + " '" + selectvalue + "'"
                # print(wheretemp)
                if whereinfo == "":
                    whereinfo = wheretemp
                else:
                    whereinfo = whereinfo + ' ' + wheretemp

        if where_ctrl == None:
            where_ctrl = ""
        if order_ctrl == None:
            order_ctrl = ""

        cur = connection.cursor()
        # sql = "select field_id,ui_type,search_exts from sys_crud_cfg_body " \
        #       "where state='y' and app_id=%s order by order_id asc"
        #为了使隐藏ID的也好用,所以状态不再做为条件。。
        sql = "select field_id,ui_type,search_exts from sys_crud_cfg_body " \
              "where  app_id=%s order by order_id asc"
        log.info(sql % appid, extra={'ptlsh': public.req_seq})
        cur.execute(sql, appid)
        rows = cur.fetchall()
        fieldlist = ""
        field_uitype_list = []
        field_search_list = []  # 查询配置,用于枚举转换
        for item in rows:
            if fieldlist.__len__() == 0:
                fieldlist = item[0]
            else:
                fieldlist = fieldlist + ',' + item[0]
            # 获取uitype,对multipleimage要使用list返回结果
            field_uitype_list.append(item[1])
            field_search_list.append(item[2])
            # 根据查询配置获取反回结果
        fieldlist = fieldlist.replace('data_seq_no', '1 as data_sql_no')

        if where_ctrl == None or where_ctrl == "":
            if whereinfo.__len__() > 0:
                where_ctrl = "where 1=1"
        else:
            if 'WHERE' not in where_ctrl.upper():
                where_ctrl = 'where ' + where_ctrl
            if '${USER_ID}' in where_ctrl:
                where_ctrl = where_ctrl.replace('${USER_ID}',
                                                str(public.user_id))
            if '${ORGID}' in where_ctrl:
                orgidsql = "(SELECT org_id FROM sys_user_org WHERE user_id='%s')" % public.user_id
                where_ctrl = where_ctrl.replace('${ORGID}', orgidsql)
            if '${ORG_ID}' in where_ctrl:
                orgidsql = "(SELECT org_id FROM sys_user_org WHERE user_id='%s')" % public.user_id
                where_ctrl = where_ctrl.replace('${ORG_ID}', orgidsql)

        # 获取总笔数,分页使用
        selsql = "select count(1) from " + table_name + " " + where_ctrl + " " + whereinfo + " " + order_ctrl
        log.info(selsql, extra={'ptlsh': public.req_seq})
        cur.execute(selsql)
        row = cur.fetchone()
        totalnum = row[0]

        # 分页查询
        if pagesize == 0 or not pagesize:
            pagesize = 10
        if pagenum == 0 or not pagenum:
            pagenum = 1
        startno = (pagenum - 1) * pagesize
        # endno = (pagenum) * pagesize

        selsql = "select " + fieldlist + " from " + table_name + " " + where_ctrl + " " + whereinfo + " " + order_ctrl
        selsql = selsql + " limit %s, %s" % (startno, pagesize)
        log.info(selsql, extra={'ptlsh': public.req_seq})
        cur.execute(selsql)
        rows = cur.fetchall()

        fieldlist = fieldlist.split(',')
        # print("查询时获取的表头字段:",fieldlist)
        data = {"totalnum": "0", "tabledata": []}

        data_seq_no = totalnum - (pagenum - 1) * pagesize  # 增加当前数据的序号(倒序)
        for item in rows:
            dataitem = {}
            loopid = 0
            for subitem in item:
                if subitem == None or len(str(subitem)) == 0:
                    subitem = ""
                # log.info('=mytest=='+str(fieldlist[loopid])+'-----'+str(data_seq_no)  )
                #增加一个data_sql_no序号, add by litz, 2020-10-30
                if fieldlist[loopid] == '1 as data_sql_no':  #序号列,为虚列不控制
                    dataitem['data_seq_no'] = data_seq_no
                    data_seq_no = data_seq_no - 1
                    loopid = loopid + 1
                    continue

                dataitem[fieldlist[loopid]] = subitem

                if field_search_list[
                        loopid] and field_uitype_list[loopid] != 'transfer':
                    if '${THIS}' in (
                            field_search_list[loopid]):  # 有查询配置,获取值对应的描述信息
                        if len(str(subitem)) > 0:
                            descsql = field_search_list[loopid].replace(
                                '${THIS}', '%s')
                            desccur = connection.cursor()
                            # log.info(descsql % str(subitem))
                            desccur.execute(descsql % str(subitem))
                            descrow = desccur.fetchone()
                            if descrow != None:
                                dataitem[fieldlist[loopid]] = str(
                                    subitem) + ' - ' + str(descrow[0])
                            desccur.close()

                # log.info('fieldname='+fieldlist[loopid]+',uitype='+field_uitype_list[loopid]+',value='+str(subitem) )
                if field_uitype_list[loopid] == 'multipleimage':
                    dataitem[fieldlist[loopid]] = []
                    for itemlist in str(subitem).split(';'):
                        if len(itemlist) > 0:
                            dataitem[fieldlist[loopid]].append(itemlist)
                            # 图片不存在时,显示图片不存在的默认图片
                            # if len(dataitem[fieldlist[loopid]])==0:
                            #     dataitem[fieldlist[loopid]].append(public.localurl+'static/images/irs_noimg_exists.png')

                # 循环数+1
                loopid = loopid + 1

            data['tabledata'].append(dataitem)
        cur.close()
        data['totalnum'] = totalnum
        cur.close()

    except Exception as ex:
        log.error("获取增删改查配置信息失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        cur.close()
        public.respcode, public.respmsg = "100103", "数据查询失败!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {"HEAD": public.resphead_setvalue(), "BODY": data}

    log.info("json_data:" + str(json_data), extra={'ptlsh': public.req_seq})

    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #26
0
def crud_cfg_show(request):
    log = public.logger
    body = public.req_body  # 请求报文体

    if not public.menu_id:
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100103", "配置交易上送信息有误!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    #获取用户对应的增删改查权限
    def get_data_able(insert_able, delete_able, update_able, import_able,
                      export_able):

        #如果是超级用户,返回所有权限
        sql = "select 1 from sys_user_role where role_id = 'root' and user_id='%s' " % (
            public.user_id)
        cur.execute(sql)
        row = cur.fetchall()
        if row:
            return public.Y2True(insert_able), public.Y2True(
                delete_able), public.Y2True(update_able), public.Y2True(
                    import_able), public.Y2True(export_able)

        # 0 - "查询数据"
        # 1 - "添加数据"
        # 2 - "删除数据"
        # 3 - "更新数据"
        # 4 - "导入数据"
        # 5 - "导出数据"
        insert_flag = False
        update_flag = False
        delete_flag = False
        export_flag = False
        import_flag = False

        sql="select a.auth_type from sys_role_purv_head a, sys_user_role b  " \
            "where a.role_id=b.role_id and a.menu_id='%s' and b.user_id='%s' " % ( public.menu_id, public.user_id )
        cur.execute(sql)
        rows = cur.fetchall()
        for item in rows:
            if item[0] == '1' and insert_able == 'Y':
                insert_flag = True
            elif item[0] == '2' and delete_able == 'Y':
                delete_flag = True
            elif item[0] == '3' and update_able == 'Y':
                update_flag = True
            elif item[0] == '4' and import_able == 'Y':
                import_flag = True
            elif item[0] == '5' and export_able == 'Y':
                export_flag = True

        return insert_flag, delete_flag, update_flag, import_flag, export_flag

    try:
        cur = connection.cursor()  # 创建游标
        #根据menuid获取增删改查配置的appid
        sql = "select app_id from sys_menu where menu_id='%s' " % (
            public.menu_id)
        cur.execute(sql)
        row = cur.fetchone()
        if row:
            appid = row[0]
        else:
            public.respcode, public.respmsg = "100105", "查询菜单对应的APPID异常!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        if not appid:
            public.respcode, public.respmsg = "100105", "查询菜单对应的APPID异常!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        # 获取字段权限
        role_purv_body = []
        sql = "select distinct upper(a.field_id), a.show_able, a.dis_able from sys_role_purv_body a, sys_user_role b " \
              "where a.ROLE_ID=b.ROLE_ID and a.app_id='%s' and b.USER_ID='%s' " % (appid, public.user_id)
        log.info("获取字段权限SQL:" + sql, extra={'ptlsh': public.req_seq})
        cur.execute(sql)
        rows = cur.fetchall()
        for item in rows:
            if item[0] in ['', 'FORMTRAN_EXESQL']:
                continue
            role_purv_body.append(item[0] + '-show_able-' + item[1])
            role_purv_body.append(item[0] + '-dis_able-' + item[2])
        log.info("获取字段权限结果:" + str(role_purv_body),
                 extra={'ptlsh': public.req_seq})

        #查询增删改查配置HEAD信息
        sql = "select app_id, app_name,tran_id,where_ctrl,order_ctrl,table_name,data_source," \
              "main_control,select_able,insert_able,update_able,delete_able,export_able,import_able, snote," \
              "insert_formid,update_formid,delete_formid,export_formid,import_formid " \
              " from sys_crud_cfg_head where app_id='%s' " % appid
        # log.info("查询增删改查配置HEAD信息:"+sql, extra={'ptlsh':public.req_seq})
        cur.execute(sql)
        crud_head_row = cur.fetchone()
        tran_id = crud_head_row[2]
        table_name = crud_head_row[5]

        insert_able = crud_head_row[9]
        update_able = crud_head_row[10]
        delete_able = crud_head_row[11]
        export_able = crud_head_row[12]
        import_able = crud_head_row[13]

        #同步判断角色权限
        insert_able, delete_able, update_able, import_able, export_able = get_data_able(
            insert_able, delete_able, update_able, import_able, export_able)

        insert_formid = crud_head_row[15]
        update_formid = crud_head_row[16]
        delete_formid = crud_head_row[17]
        export_formid = crud_head_row[18]
        import_formid = crud_head_row[19]

        #查询增删改查配置BODY信息
        sql = "select distinct a.field_id, a.field_name, a.field_length, a.search_type, a.ui_type, " \
              "a.max_length, upper(a.edit_able), upper(a.allow_blank), upper(a.is_key), a.data_type, " \
              "a.def_value, a.search_exts " \
              "from sys_crud_cfg_body a  where a.state='Y' and a.app_id='%s' order by a.order_id asc " % appid
        log.info("查询增删改查配置BODY信息:" + sql, extra={'ptlsh': public.req_seq})
        cur.execute(sql)
        crud_body_rows = cur.fetchall()

        data = {
            "tableHead": [],
            "ButtonInfo": [],
            "searchinfo": [{
                "SearchInfo": {
                    "selectoptions": [],
                    "selecttypes": [],
                    "selectoption": {
                        "label": '',
                        "value": '',
                        "uitype": ''
                    },
                    "selecttype": "",
                    "selectvalue": "",
                }
            }],
            "tableAble": {
                "INSERT_ABLE": insert_able,
                "UPDATE_ABLE": update_able,
                "DELETE_ABLE": delete_able,
                "EXPORT_ABLE": export_able,
                "IMPORT_ABLE": import_able,
            },
            "form_cfg": {
                "INSERT_FORMID": insert_formid,
                "UPDATE_FORMID": update_formid,
                "DELETE_FORMID": delete_formid,
                "EXPORT_FORMID": export_formid,
                "IMPORT_FORMID": import_formid,
            },
            "listinfo": {},  #下接列表的配置
        }

        data['searchinfo'][0]['SearchInfo']['selecttypes'] = public.selecttypes
        tableHead = []
        selectoptions = []
        for item in crud_body_rows:
            # print(item)
            tableitem = {}
            tableitem["label"] = item[1]
            tableitem["property"] = item[0]  #字段ID

            # log.info(str(tableitem["property"].upper() + '-show_able-Y'))
            if len(role_purv_body) > 0 and tableitem["property"].upper(
            ) + '-show_able-Y' not in role_purv_body:
                continue  #此字段权限配置中不显示给此用户

            # 页面显示的列宽度width
            fieldlength = item[2]
            # print(type(fieldlength), fieldlength)
            if fieldlength == None or not fieldlength:
                fieldlength = len(item[1])

            fieldlength = int(fieldlength)
            if fieldlength > 30:
                tableitem["width"] = 30 * 14
            elif fieldlength <= len(item[1]):
                tableitem["width"] = len(item[1]) * 14
            else:
                tableitem["width"] = fieldlength * 14

            tableitem["width"] = fieldlength * 14
            tableitem["uitype"] = item[4]
            tableitem["MAX_LENGTH"] = item[5]

            if item[6] == 'Y':
                log.info(tableitem["property"].upper() + '-dis_able-N')
                if len(role_purv_body) > 0 and tableitem["property"].upper(
                ) + '-dis_able-N' in role_purv_body:
                    tableitem["EDIT_ABLE"] = True
                elif len(role_purv_body) > 0:
                    tableitem["EDIT_ABLE"] = False
                else:
                    tableitem["EDIT_ABLE"] = True
            else:
                tableitem["EDIT_ABLE"] = False

            # 是否为空属性
            if item[7] == 'Y' or item[7] == 'y':
                tableitem["ALLOW_BLANK"] = True
            else:
                tableitem["ALLOW_BLANK"] = False
            # 主键不允许为空
            if item[8] == 'Y' or item[8] == 'y':
                tableitem["ALLOW_BLANK"] = False

            # 数据类型
            tableitem["DATA_TYPE"] = item[9]

            tableitem["DEF_VALUE"] = item[10]  # 默认值

            tableHead.append(tableitem)

            # 查询条件配置
            if item[3] == None or item[3] == "":
                pass
            else:
                searchitem = {}
                searchitem["label"] = item[1]
                searchitem["value"] = item[0]
                searchitem["uitype"] = item[4]
                selectoptions.append(searchitem)

            #获取下拉列表
            search_exts = item[11]  #下拉查询类型
            if tableitem["uitype"] in ['list']:
                # 自定义配置
                if search_exts:
                    sql = search_exts
                    if '${ORGID}' in sql:
                        orgidsql = "(SELECT org_id FROM irsadmin_user_org WHERE user_id='%s')" % request.session.get(
                            'user_id', None)
                        sql = sql.replace('${ORGID}', orgidsql)
                    log.info('自定义下拉数据:' + sql)
                    cur.execute(sql)
                    rows = cur.fetchall()
                    listinfo = []
                    for item in rows:
                        listtemp = {}
                        listtemp['value'] = str(item[0])
                        listtemp['label'] = str(item[1])
                        listinfo.append(listtemp)
                    data["listinfo"][tableitem["property"]] = listinfo
                else:  # 默认配置
                    listkey = table_name + "." + tableitem["property"]
                    sql = "select dict_code,dict_target from irs_ywty_dict where dict_name='%s' " % listkey
                    cur.execute(sql)
                    rows = cur.fetchall()
                    listinfo = []
                    for item in rows:
                        listtemp = {}
                        listtemp['value'] = item[0]
                        listtemp['label'] = item[1]
                        listinfo.append(listtemp)
                    data["listinfo"][tableitem["property"]] = listinfo

        data['tableHead'] = tableHead
        if selectoptions.__len__() > 0:
            data['searchinfo'][0]['SearchInfo'][
                'selectoptions'] = selectoptions
        else:
            # 没有查询条件
            data.pop('searchinfo')

        if len(tran_id) > 0 and str(tran_id) != '0':
            # 获取按钮配置信息
            sql="select id,button_name,button_type,button_color,button_trantype,button_length " \
                "from irsadmin_tran_cfg where id in %s" % str( tuple( str(tran_id).split(',') ) )
            log.info("获取按钮配置信息:" + sql)
            cur.execute(sql)
            rows = cur.fetchall()
            if rows:
                buttonlength = 30
                for item in rows:
                    buttonitem = {}
                    buttonitem['BUTTON_NAME'] = item[1]
                    buttonitem['BUTTON_TYPE'] = item[2]
                    buttonitem['BUTTON_COLOR'] = item[3]
                    buttonitem['BUTTON_TRANTYPE'] = item[4]
                    data['ButtonInfo'].append(buttonitem)
                    buttonlength = buttonlength + 30 + item[5]
                data['ButtonLength'] = buttonlength

        # 关闭游标
        cur.close()

    except Exception as ex:
        log.error("配置信息转换失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        cur.close()
        public.respcode, public.respmsg = "100103", "配置信息转换失败!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": data,
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #27
0
def crud_cfg_create(request):
    log = public.logger
    body = public.req_body  # 请求报文体
    crud_info = body.get('crud_info')
    crud_field = body.get('crud_field')

    if not crud_info or not crud_field:
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100103", "配置交易上送信息有误!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    appid = crud_info.get('APP_ID')
    try:
        cur = connection.cursor()  # 创建游标
        if appid:  #先把原来的配置删除掉
            appid = int(appid)
            sql = "delete from sys_crud_cfg_head where app_id=%s"
            cur.execute(sql, appid)
            sql = "delete from sys_crud_cfg_body where app_id=%s"
            cur.execute(sql, appid)
        else:
            appid = None

        #登记增删改查配置HEAD表
        sql = "insert into sys_crud_cfg_head(app_id, app_name,tran_id,where_ctrl,order_ctrl,table_name,data_source," \
              "main_control,select_able,insert_able,update_able,delete_able,export_able,import_able, snote," \
              "insert_formid,update_formid,delete_formid,export_formid,import_formid ) " \
              "values(%s,%s,%s,%s,%s,  %s,%s,%s,%s,%s,   %s,%s,%s,%s,%s,   %s,%s,%s,%s,%s )"
        log.info(
            sql %
            (appid, crud_info.get('APP_NAME'), crud_info.get('TRAN_ID'),
             crud_info.get('WHERE_CTRL'), crud_info.get('ORDER_CTRL'),
             crud_info.get('TABLE_NAME'), crud_info.get('DATA_SOURCE'),
             crud_info.get('MAIN_CONTROL'),
             public.True2y(crud_info.get('SELECT_ABLE')),
             public.True2y(crud_info.get('INSERT_ABLE')),
             public.True2y(crud_info.get('UPDATE_ABLE')),
             public.True2y(crud_info.get('DELETE_ABLE')),
             public.True2y(crud_info.get('EXPORT_ABLE')),
             public.True2y(crud_info.get('IMPORT_ABLE')),
             crud_info.get('SNOTE'), crud_info.get('INSERT_FORMID'),
             crud_info.get('UPDATE_FORMID'), crud_info.get('DELETE_FORMID'),
             crud_info.get('EXPORT_FORMID'), crud_info.get('IMPORT_FORMID')),
            extra={'ptlsh': public.req_seq})

        sql = "insert into sys_crud_cfg_head(app_id, app_name,tran_id,where_ctrl,order_ctrl,table_name,data_source," \
              "main_control,select_able,insert_able,update_able,delete_able,export_able,import_able, snote," \
              "insert_formid,update_formid,delete_formid,export_formid,import_formid ) " \
              "values(%s,%s,%s,%s,%s,  %s,%s,%s,%s,%s,   %s,%s,%s,%s,%s,   %s,%s,%s,%s,%s )"
        cur.execute(
            sql,
            (appid, crud_info.get('APP_NAME'), crud_info.get('TRAN_ID'),
             crud_info.get('WHERE_CTRL'), crud_info.get('ORDER_CTRL'),
             crud_info.get('TABLE_NAME'), crud_info.get('DATA_SOURCE'),
             crud_info.get('MAIN_CONTROL'),
             public.True2y(crud_info.get('SELECT_ABLE')),
             public.True2y(crud_info.get('INSERT_ABLE')),
             public.True2y(crud_info.get('UPDATE_ABLE')),
             public.True2y(crud_info.get('DELETE_ABLE')),
             public.True2y(crud_info.get('EXPORT_ABLE')),
             public.True2y(crud_info.get('IMPORT_ABLE')),
             crud_info.get('SNOTE'), crud_info.get('INSERT_FORMID'),
             crud_info.get('UPDATE_FORMID'), crud_info.get('DELETE_FORMID'),
             crud_info.get('EXPORT_FORMID'), crud_info.get('IMPORT_FORMID')))
        if not appid:  #如果没有appid,获取本线程最后插入的appid
            cur.execute("SELECT LAST_INSERT_ID()")  # 获取自增字段刚刚插入的ID
            row = cur.fetchone()
            if row:
                appid = row[0]
                log.info('APP_ID生成,自增字段ID:%s' % str(appid),
                         extra={'ptlsh': public.req_seq})
            else:
                public.respcode, public.respmsg = "100104", "登记配置信息表异常!"
                public.respinfo = HttpResponse(public.setrespinfo())
                return public.respinfo
        for item in crud_field:
            # 登记增删改查配置BODY表
            sql = "insert into sys_crud_cfg_body(app_id, tran_id, field_id, field_name, state, data_type, ui_type," \
                  "allow_blank, is_key, search_type, search_exts, edit_able, def_value, order_id, snote, field_length, max_length) " \
                  "values( %s,%s,%s,%s,%s, %s,%s,%s,%s,%s ,%s,%s,%s,%s,%s, %s,%s)"
            cur.execute(
                sql,
                (appid, item.get('TRAN_ID'), item.get('FIELD_ID').lower(),
                 item.get('FIELD_NAME'), public.True2y(
                     item.get('STATE')), item.get('DATA_TYPE'),
                 item.get('UI_TYPE'), public.True2y(item.get('ALLOW_BLANK')),
                 public.True2y(item.get('IS_KEY')), item.get('SEARCH_TYPE'),
                 item.get('SEARCH_EXTS'), public.True2y(
                     item.get('EDIT_ABLE')), item.get('DEF_VALUE'),
                 item.get('ORDER_ID'), item.get('SNOTE'),
                 item.get('FIELD_LENGTH'), item.get('MAX_LENGTH')))
            # log.info('登记增删改查配置BODY表成功', extra={'ptlsh': public.req_seq})
        cur.close()
    except Exception as ex:
        log.error("登记配置信息表失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respcode, public.respmsg = "100103", "登记配置信息表失败!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {"HEAD": public.resphead_setvalue(), "BODY": {"app_id": appid}}
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #28
0
def get_crud_info(request):
    log = public.logger
    body = public.req_body  # 请求报文体
    appid = body.get('app_id')
    tablename = body.get('table_name')
    if (tablename == None or tablename == '') and (appid == None
                                                   or appid == ''):
        public.respcode, public.respmsg = "100101", "配置应用ID或者表名必输!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    cur = connection.cursor()
    if tablename:  # 根据表名获取表信息
        tablename = tablename.upper()
        try:
            sql = "SELECT column_name, column_comment, data_type, is_nullable,  " \
                  "column_key, column_default, character_maximum_length,  numeric_precision, " \
                  "extra "
            sql = sql + "FROM information_schema.columns WHERE UPPER(table_name) = UPPER(%s) "
            sql = sql + "order by ordinal_position"
            # log.info(sql % tablename)
            cur.execute(sql, tablename)
            rows = cur.fetchall()
            table_info = {}
            table_field = []

            table_info["APP_ID"] = ""  #获取表信息时还没有appid
            table_info["TRAN_ID"] = ""
            table_info["APP_NAME"] = ""
            table_info["WHERE_CTRL"] = ""
            table_info["ORDER_CTRL"] = ""
            table_info["TABLE_NAME"] = tablename
            table_info["DATA_SOURCE"] = ""
            table_info["MAIN_CONTROL"] = ""
            table_info["SELECT_ABLE"] = True
            table_info["INSERT_ABLE"] = False
            table_info["UPDATE_ABLE"] = False
            table_info["DELETE_ABLE"] = False
            table_info["EXPORT_ABLE"] = False
            table_info["IMPORT_ABLE"] = False
            table_info["INSERT_FORMID"] = ""
            table_info["UPDATE_FORMID"] = ""
            table_info["DELETE_FORMID"] = ""
            table_info["EXPORT_FORMID"] = ""
            table_info["IMPORT_FORMID"] = ""
            table_info["SNOTE"] = "SNOTE"

            loopid = 0
            for item in rows:
                tableitem = {}
                loopid = loopid + 1
                tableitem["APP_ID"] = ""
                tableitem["TRAN_ID"] = ""
                tableitem["FIELD_ID"] = item[0]
                tableitem["FIELD_NAME"] = item[1]
                tableitem["STATE"] = True
                tableitem["DATA_TYPE"] = item[2]
                tableitem["UI_TYPE"] = "text"  # 先默认是文本
                if item[3] == "YES" or item[3] == "yes":
                    tableitem["ALLOW_BLANK"] = True
                else:
                    tableitem["ALLOW_BLANK"] = False
                if item[4] == "PRI":
                    tableitem["IS_KEY"] = True
                else:
                    tableitem["IS_KEY"] = False
                tableitem["SEARCH_TYPE"] = ""
                tableitem["SEARCH_EXTS"] = ""
                tableitem["EDIT_ABLE"] = False
                tableitem["DEF_VALUE"] = item[5]
                tableitem["ORDER_ID"] = str(loopid)
                tableitem["SNOTE"] = ""

                if item[6] and len(str(item[6])) > 0:
                    maxlength = item[6]
                else:
                    maxlength = item[7]
                if maxlength == None or maxlength == '':
                    if tableitem["DATA_TYPE"] in ['date', 'DATE']:
                        maxlength = 10
                        tableitem["UI_TYPE"] = 'date'
                    elif tableitem["DATA_TYPE"] in ['time', 'TIME']:
                        maxlength = 8
                        tableitem["UI_TYPE"] = 'time'
                    elif tableitem["DATA_TYPE"] in ['datetime', 'DATETIME']:
                        maxlength = 19
                        tableitem["UI_TYPE"] = 'datetime'
                    elif tableitem["DATA_TYPE"] in ['timestamp', 'TIMESTAMP']:
                        maxlength = 23
                        tableitem["UI_TYPE"] = 'datetime'
                    else:
                        maxlength = 23

                showlength = None
                if item[8] == 'auto_increment':  # 自增变量
                    tableitem["UI_TYPE"] = 'auto_increment'
                    showlength = 4

                # 显示长度初始值
                if showlength == 0 or showlength == None:
                    showlength = len(tableitem["FIELD_NAME"])
                if showlength == 0:
                    showlength = 8
                # print('maxlength=',maxlength)
                maxlength = int(maxlength)
                if maxlength > 30:
                    tableitem["FIELD_LENGTH"] = 30
                elif maxlength < 4:
                    tableitem["FIELD_LENGTH"] = 4
                else:
                    tableitem["FIELD_LENGTH"] = showlength
                tableitem["MAX_LENGTH"] = maxlength

                table_field.append(tableitem)
            cur.close()
        except Exception as ex:
            log.error("获取数据表信息失败!" + str(ex),
                      exc_info=True,
                      extra={'ptlsh': public.req_seq})
            public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
            )
            public.respcode, public.respmsg = "100102", "获取数据表信息失败!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
    else:  #根据配置应用ID获取配置信息
        try:

            sql = "select app_id, app_name,tran_id,where_ctrl,order_ctrl,table_name,data_source, " \
                  " main_control,select_able,insert_able,update_able,delete_able,export_able,import_able,snote," \
                  "insert_formid,update_formid,delete_formid,export_formid,import_formid" \
                  " from sys_crud_cfg_head where app_id=%s "
            # log.info(sql % appid)
            cur.execute(sql, appid)
            row = cur.fetchone()
            table_info = {}
            table_field = []

            table_info["APP_ID"] = row[0]
            table_info["APP_NAME"] = row[1]
            table_info["TRAN_ID"] = row[2]
            table_info["WHERE_CTRL"] = row[3]
            table_info["ORDER_CTRL"] = row[4]
            table_info["TABLE_NAME"] = row[5]
            table_info["DATA_SOURCE"] = row[6]
            table_info["MAIN_CONTROL"] = row[7]
            table_info["SELECT_ABLE"] = public.Y2True(row[8])
            table_info["INSERT_ABLE"] = public.Y2True(row[9])
            table_info["UPDATE_ABLE"] = public.Y2True(row[10])
            table_info["DELETE_ABLE"] = public.Y2True(row[11])
            table_info["EXPORT_ABLE"] = public.Y2True(row[12])
            table_info["IMPORT_ABLE"] = public.Y2True(row[13])
            table_info["SNOTE"] = row[14]
            table_info["INSERT_FORMID"] = row[15]
            table_info["UPDATE_FORMID"] = row[16]
            table_info["DELETE_FORMID"] = row[17]
            table_info["EXPORT_FORMID"] = row[18]
            table_info["IMPORT_FORMID"] = row[19]

            sql = "select app_id, tran_id, field_id, field_name, state, data_type, ui_type," \
                  " allow_blank, is_key, search_type, search_exts, edit_able, def_value, order_id, snote, field_length," \
                  " max_length" \
                  " from sys_crud_cfg_body where app_id=%s order by order_id asc "
            log.info(sql % appid)
            cur.execute(sql, appid)
            rows = cur.fetchall()
            loopid = 0
            for item in rows:
                tableitem = {}
                loopid = loopid + 1
                tableitem["APP_ID"] = item[0]
                tableitem["TRAN_ID"] = item[1]
                tableitem["FIELD_ID"] = item[2]
                tableitem["FIELD_NAME"] = item[3]
                tableitem["STATE"] = public.Y2True(item[4])
                tableitem["DATA_TYPE"] = item[5]
                tableitem["UI_TYPE"] = item[6]
                tableitem["ALLOW_BLANK"] = public.Y2True(item[7])
                tableitem["IS_KEY"] = public.Y2True(item[8])
                tableitem["SEARCH_TYPE"] = item[9]
                tableitem["SEARCH_EXTS"] = item[10]
                tableitem["EDIT_ABLE"] = public.Y2True(item[11])
                tableitem["DEF_VALUE"] = item[12]
                tableitem["ORDER_ID"] = item[13]
                tableitem["SNOTE"] = item[14]
                tableitem["FIELD_LENGTH"] = item[15]
                tableitem["MAX_LENGTH"] = item[16]
                table_field.append(tableitem)
            cur.close()
        except Exception as ex:
            log.error("获取数据表信息失败!" + str(ex),
                      exc_info=True,
                      extra={'ptlsh': public.req_seq})
            public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
            )
            public.respcode, public.respmsg = "100102", "获取数据表信息失败!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "crud_info": table_info,
            "crud_field": table_field
        }
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #29
0
def get_workflow_info(request):
    log = public.logger
    body = public.req_body
    nodeid = body.get("node_id")

    if not nodeid:
        public.respcode, public.respmsg = "100221", "节点ID不可为空!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        cur = connection.cursor()  # 创建游标
        flow_info = {
            "node_id":
            "1111",
            "node_name":
            "审批流程",
            "tabledata": [
                {
                    "label": "申请类型",
                    "value": "用章申请"
                },
                {
                    "label": "申请人",
                    "value": "张三"
                },
                {
                    "label": "申请时间",
                    "value": "2020-04-29 13:39:22"
                },
                {
                    "label": "申请用途",
                    "value": "网站备案"
                },
                {
                    "label": "使用时间",
                    "value": "2020-04-30 至 2020-05-01 "
                },
                {
                    "label": "附件",
                    "value": [234, 233]
                },
                {
                    "label": "当前状态",
                    "value": "申请中"
                },
            ],
            "node_flow": [
                {
                    "name": " 提交(张三)"
                },
                {
                    "name": " 审批(李四)"
                },
                {
                    "name": " 审批(王五)"
                },
                {
                    "name": " 归档(赵六)"
                },
            ],
            "node_status":
            False,  # False-未处理,True-已处理
            "node_active":
            2,
            "node_act":
            "",  # 处理动作 1-同意 2-不同意
            "snote":
            "",  # 说明
            "file": [222, 333],
        }
        # 模拟返回
        cur.close()

    except Exception as ex:
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": {
            "flow_info": flow_info,
        },
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo
Exemple #30
0
def order_detail_update(request):
    log = public.logger
    body = public.req_body
    form_var = body.get('form_var')
    if not form_var:
        public.respcode, public.respmsg = "387711", "上送数据异常!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    id = form_var.get('id')
    if not id:
        public.respcode, public.respmsg = "387712", "无查询条件!"
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    try:
        cur = connection.cursor()  # 创建游标
        sql = "select sponsor, receiver, state from yw_workflow_work_order where id=%s"
        cur.execute(sql, id)
        row = cur.fetchone()
        if not row:
            cur.close()
            public.respcode, public.respmsg = "387713", "数据不存在!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        db_sponsor = row[0]
        db_receiver = row[1]
        db_state = row[2]

        if db_state != '0':
            cur.close()
            public.respcode, public.respmsg = "387715", "非初始发布状态,无法修改信息!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo
        # log.info(str(public.user_id)+'=='+str(db_sponsor)+'=='+str(db_receiver), extra={'ptlsh': public.req_seq})
        # log.info(str(type(public.user_id)) + '==' + str(type(db_sponsor)) + '==' + str(type(db_receiver)), extra={'ptlsh': public.req_seq})
        # print(type(public.user_id), public.user_id, type(db_sponsor), db_sponsor, type(db_receiver), db_receiver)

        if int(public.user_id) == db_sponsor:
            sql = "UPDATE yw_workflow_work_order SET start_time=%s, order_type=%s, receiver=%s, order_urgent_type=%s, " \
                  "receiving_department=%s, require_completion_time=%s, requirments=%s,requirements_ziliao=%s," \
                  "remarks=%s, state='0' where id=%s"
            cur.execute(
                sql,
                (form_var.get('start_time'), form_var.get('order_type'),
                 form_var.get('receiver'), form_var.get('order_urgent_type'),
                 form_var.get('receiving_department'),
                 form_var.get('require_completion_time'),
                 form_var.get('requirments'),
                 str(form_var.get('requirements_ziliao')),
                 form_var.get('remarks'), form_var.get('id')))
            form_var['state_info'] = '0'
        elif int(public.user_id) == db_receiver:
            if form_var.get('except_completion_time') and form_var.get(
                    'actual_time'):
                sql = "UPDATE yw_workflow_work_order SET except_completion_time=%s, actual_time=%s, task_completion_info=%s, " \
                      "task_completion_ziliao=%s, remarks=%s, state= '1' where id=%s"
                cur.execute(sql, (form_var.get('except_completion_time'),
                                  form_var.get('actual_time'),
                                  form_var.get('task_completion_info'),
                                  str(form_var.get('task_completion_ziliao')),
                                  form_var.get('remarks'), form_var.get('id')))
            elif not form_var.get('except_completion_time') and form_var.get(
                    'actual_time'):
                sql = "UPDATE yw_workflow_work_order SET actual_time=%s, task_completion_info=%s, " \
                      "task_completion_ziliao=%s, remarks=%s, state= '1' where id=%s"
                cur.execute(sql, (form_var.get('actual_time'),
                                  form_var.get('task_completion_info'),
                                  str(form_var.get('task_completion_ziliao')),
                                  form_var.get('remarks'), form_var.get('id')))
            elif form_var.get('except_completion_time'
                              ) and not form_var.get('actual_time'):
                sql = "UPDATE yw_workflow_work_order SET except_completion_time=%s, task_completion_info=%s, " \
                      "task_completion_ziliao=%s, remarks=%s, state= '1' where id=%s"
                cur.execute(sql, (form_var.get('except_completion_time'),
                                  form_var.get('task_completion_info'),
                                  str(form_var.get('task_completion_ziliao')),
                                  form_var.get('remarks'), form_var.get('id')))
            else:
                sql = "UPDATE yw_workflow_work_order SET  task_completion_info=%s, task_completion_ziliao=%s, remarks=%s where id=%s"
                cur.execute(sql, (form_var.get('task_completion_info'),
                                  str(form_var.get('task_completion_ziliao')),
                                  form_var.get('remarks'), form_var.get('id')))
                form_var['state_info'] = '1'
        else:
            cur.close()
            public.respcode, public.respmsg = "387714", "无操作权限!"
            public.respinfo = HttpResponse(public.setrespinfo())
            return public.respinfo

        cur.close()

    except Exception as ex:
        log.error("交易失败!" + str(ex),
                  exc_info=True,
                  extra={'ptlsh': public.req_seq})
        public.respcode, public.respmsg = "387888", str(ex)
        public.exc_type, public.exc_value, public.exc_traceback = sys.exc_info(
        )
        public.respinfo = HttpResponse(public.setrespinfo())
        return public.respinfo

    public.respcode, public.respmsg = "000000", "交易成功!"
    json_data = {
        "HEAD": public.resphead_setvalue(),
        "BODY": body,
    }
    s = json.dumps(json_data, cls=public.JsonCustomEncoder, ensure_ascii=False)
    public.respinfo = HttpResponse(s)
    return public.respinfo