コード例 #1
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def show_lc_xz_page(request):
    context = dict()
    xm_id = request.POST.get("xm_id")
    wj_id = request.POST.get("wj_id")

    status, xm_list, reason = api.project_get(xm_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        xm_name = xm_list.name

    status, project_list, reason = api.project_switch_to_ready_status(
        xm_id)  # 更改项目状态-就绪状态
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)

    status, project_list, reason = api.flow_run(xm_id, wj_id)  # 执行项目
    if status != api.OK:
        reason = {"错误原因": reason, "项目名": xm_name}
        context['reason'] = reason
        return render(request,
                      '12-执行失败提示页面/execution_failure.html',
                      context=context)
    else:
        return render(request, '08-流程显示页面/article_show.html', context=context)
コード例 #2
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def stop_item_successful_page(request):
    context = dict()
    xm_id = request.POST.get("xm_id")
    zzyy = request.POST.get("zzyy")
    status, xm_list, reason = api.project_get(xm_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        xm_name = xm_list.name
    #中止:先暂停,后中止
    status1, project_list, reason1 = api.project_services_start()  # 暂停项目
    #status1 = "簇ok"
    if status1 != api.OK:
        ID = {"项目名": xm_name, "错误原因": reason1}
        context['ID'] = ID
        return render(request,
                      '10-项目页面/25-中止项目失败页面/stop_project_failed.html',
                      context=context)
    else:
        #中止项目
        status2, project_list, reason2 = api.project_services_start()  # 暂停项目
        #status2 = "传ok"
        if status2 != api.OK:
            ID = {"项目名": xm_name, "错误原因": reason2}
            context['ID'] = ID
            return render(request,
                          '10-项目页面/25-中止项目失败页面/stop_project_failed.html',
                          context=context)
        else:
            ID = {"项目名": xm_name}
            context['ID'] = ID
            return render(request,
                          '10-项目页面/24-中止项目成功页面/stop_item_successful.html',
                          context=context)
コード例 #3
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def successful_suspension_project_page(request):
    context = dict()
    xm_id = request.POST.get("xm_id")
    ztyy = request.POST.get("ztyy")
    status, xm_list, reason = api.project_get(xm_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        xm_name = xm_list.name

    status1, project_list, reason1 = api.project_service_stop()  # 暂停项目
    #status1 = "是ok"
    if status1 != api.OK:
        ID = {"项目名": xm_name, "错误原因": reason1}
        context['ID'] = ID
        return render(request,
                      '10-项目页面/21-暂停项目失败页面/project_suspension_failed.html',
                      context=context)
    else:
        ID = {"项目名": xm_name}
        context['ID'] = ID
        return render(request,
                      '10-项目页面/20-暂停项目成功页面/successful_suspension_project.html',
                      context=context)
コード例 #4
0
ファイル: prjd.py プロジェクト: bedreamer/plane-ui
def dump_all_project(prj_id):
    """显示项目状态"""
    status, prj, reason = api.project_get(prj_id)
    if status != api.OK:
        print(reason)
        return

    print(prj.id)
    print("=" * 40)
    for field in prj._meta.fields:
        if field.attname == 'id':
            continue
        value = str(prj.__getattribute__(field.attname))
        if len(value) > 40:
            print(field.attname, ":")
            print(" " * 4, value)
        else:
            print(field.attname, ":", value)

    for bind in ProjectWithDevice.objects.filter(project=prj):
        print(bind.device.type.name, ':', bind.device.id)
        print("-" * 10)
        print("  vendor:", bind.device.vendor)
        print("  model:", bind.device.model)
        print("  version:", bind.device.version)
        print("  driver:", bind.device.driver)

    statement_change_log = ProjectStateLog.objects.filter(project=prj).order_by('-change_datetime')
    if len(statement_change_log):
        print("状态更改历史")
        print('-' * 10)

    for s in statement_change_log:
        print(str(s.change_datetime), s.old_status, '===>', s.new_status, s.comment)
コード例 #5
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def cease_project_cause_page(request, prj_id):
    context = dict()
    status, xm_list, reason = api.project_get(prj_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        # 拿到绑定的充放电机设备ID信息
        xm_name = xm_list.name

    ID = {"项目ID": prj_id, "项目名": xm_name}
    context['ID'] = ID
    return render(request,
                  '10-项目页面/11-中止项目确认页面/cease_project_cause.html',
                  context=context)
コード例 #6
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def execute_confirmation_page(request):
    context = dict()
    xm_id = request.POST.get("xm_id")

    status, wj_list, reason = api.project_list_flow_file(xm_id)  # 获取对应项目ID信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        #把项目的上传文件信息带下去
        context['wj_list'] = wj_list
    status, xm_list, reason = api.project_get(xm_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        xm_name = xm_list.name

    ID = {"项目ID": xm_id, "项目名": xm_name, "进入状态": "修改项目"}
    context['ID'] = ID
    return render(request,
                  '10-项目页面/34-新建执行项目确认页面/execute_confirmation_page.html',
                  context=context)
コード例 #7
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def upload_project_flow_page(request):
    context = dict()
    xm_id = request.POST.get("xm_id")

    status, xm_list, reason = api.project_get(xm_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        xm_name = xm_list.name

    status, wj_list, reason = api.project_list_flow_file(xm_id)  #读取项目流程文件信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        # 拿到项目中的流程文件信息
        context['wj_list'] = wj_list
        ID = {"项目ID": xm_id, "项目名": xm_name, "进入状态": "修改项目"}
        context['ID'] = ID
        return render(request,
                      '10-项目页面/19-项目流程文件上传页面/upload_project_flow.html',
                      context=context)
コード例 #8
0
ファイル: prjd.py プロジェクト: bedreamer/plane-ui
def force_update_project_status(prj_id, status, without_confirm):
    """强制更改项目状态"""
    prj_status, project, reason = api.project_get(prj_id)
    if prj_status != api.OK:
        print(reason)
        return

    if status not in profile.PROJECT_STATUS_LIST:
        print("无法支持的状态:", status)
        return

    if status == project.status:
        return

    if without_confirm is None:
        confirm = input("确定强制更改项目状态({}==>{}):(N/y)>".format(project.status, status)).rstrip().lstrip()
        if confirm.lower() != 'y':
            return

    status, _, reason = api.project_modify_status(prj_id, status, "强制手工切换状态!")
    if status != api.OK:
        print(reason)
        return
コード例 #9
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def execute_item_successful_page(request):
    context = dict()
    xm_id = request.POST.get("xm_id")
    status, xm_list, reason = api.project_get(xm_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        xm_name = xm_list.name
    #执行项目
    status1, project_list, reason1 = api.project_services_start()  # 暂停项目
    #status1 = "NOok"
    if status1 != api.OK:
        ID = {"项目名": xm_name, "错误原因": reason1}
        context['ID'] = ID
        return render(request,
                      '10-项目页面/27-执行项目失败页面/execute_project_failed.html',
                      context=context)
    else:
        ID = {"项目名": xm_name}
        context['ID'] = ID
        return render(request,
                      '10-项目页面/26-执行项目成功页面/execute_item_successful.html',
                      context=context)
コード例 #10
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def bms_parameter_issue_failure_page(request):
    xm_id = request.POST.get("xm_id")
    bms_id = request.POST.get("bms_id")
    cm_id = request.POST.get("cm_id")
    ec_id = request.POST.get("ec_id")
    cd_id = request.POST.get("cd_id")
    #bz_name = request.POST.get("bz_name")
    context = dict()
    if len(xm_id) < 7:
        if len(bms_id) < 7 and len(bms_id) > 0:
            status, project_list, reason = api.project_register_device(
                xm_id, bms_id)  # 下发BMS参数
            #status, project_list, reason = api.project_list()  # 下发BMS参数
            if status != api.OK:
                ID = {"项目ID": xm_id}
                context['ID'] = ID
                reason = {"错误原因": reason.subscript}
                context['reason'] = reason
                return render(
                    request,
                    '10-项目页面/29-BMS参数下发失败页面/bms_parameter_issue_failure.html',
                    context=context)

        if len(cm_id) < 7 and len(cm_id) > 0:
            status, project_list, reason = api.project_register_device(
                xm_id, cm_id)  # 下发水冷机参数
            #status, project_list, reason = api.project_list()  # 下发BMS参数
            context = dict()
            if status != api.OK:
                ID = {"项目ID": xm_id}
                context['ID'] = ID
                reason = {"错误原因": reason.subscript}
                context['reason'] = reason
                return render(
                    request,
                    '10-项目页面/29-BMS参数下发失败页面/bms_parameter_issue_failure.html',
                    context=context)

        if len(ec_id) < 7 and len(ec_id) > 0:
            status, project_list, reason = api.project_register_device(
                xm_id, ec_id)  # 下发环境箱参数
            #status, project_list, reason = api.project_list()  # 下发BMS参数
            context = dict()
            if status != api.OK:
                ID = {"项目ID": xm_id}
                context['ID'] = ID
                reason = {"错误原因": reason.subscript}
                context['reason'] = reason
                return render(
                    request,
                    '10-项目页面/29-BMS参数下发失败页面/bms_parameter_issue_failure.html',
                    context=context)

        if len(cd_id) < 7 and len(cd_id) > 0:
            status, project_list, reason = api.project_register_device(
                xm_id, cd_id)  # 下发充放电机参数
            #status, project_list, reason = api.project_list()  # 下发BMS参数
            context = dict()
            if status != api.OK:
                ID = {"项目ID": xm_id}
                context['ID'] = ID
                reason = {"错误原因": reason.subscript}
                context['reason'] = reason
                return render(
                    request,
                    '10-项目页面/29-BMS参数下发失败页面/bms_parameter_issue_failure.html',
                    context=context)
    else:
        reason = {"错误原因": "项目ID不对"}
        context['reason'] = reason
        return render(
            request,
            '10-项目页面/29-BMS参数下发失败页面/bms_parameter_issue_failure.html',
            context=context)

    status, xm_list, reason = api.project_get(xm_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        xm_name = xm_list.name

    #读取项目流程文件信息
    status, wj_list, reason = api.project_list_flow_file(xm_id)
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        # 拿到绑定的设备ID信息
        context['wj_list'] = wj_list
        ID = {"项目ID": xm_id, "项目名": xm_name, "进入状态": "新建项目"}
        context['ID'] = ID
        return render(request,
                      '10-项目页面/19-项目流程文件上传页面/upload_project_flow.html',
                      context=context)
コード例 #11
0
ファイル: views.py プロジェクト: bedreamer/plane-ui
def show_begin_index_page(request):  #从项目页面进入,把项目名下发,成功进入BMS参数设置,失败报错
    context = dict()
    xm_id = request.POST.get("xm_id")
    status, bms_list, reason = api.device_get_list_by_type(
        "bms")  # 获取注册BMS设备列表
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        context['bms_list'] = bms_list

    status, cm_list, reason = api.device_get_list_by_type("cm")  # 获取注册水冷机设备列表
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        context['cm_list'] = cm_list

    status, ec_list, reason = api.device_get_list_by_type("ec")  # 获取注册环境箱设备列表
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        context['ec_list'] = ec_list

    status, cd_list, reason = api.device_get_list_by_type("cd")  # 获取注册充放电机设备列表
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        context['cd_list'] = cd_list

    status, bd_bms_list, reason = api.project_get_device_by_type(
        xm_id, "bms")  # 获取项目绑定BMS设备信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        #拿到绑定的BMS设备ID信息
        bd_bms_id = bd_bms_list.id

    status, bd_cm_list, reason = api.project_get_device_by_type(
        xm_id, "cm")  # 获取项目绑定水冷机设备信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        # 拿到绑定的水冷机设备ID信息
        bd_cm_id = bd_cm_list.id

    status, bd_ec_list, reason = api.project_get_device_by_type(
        xm_id, "ec")  # 获取项目绑定环境箱设备信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        # 拿到绑定的环境箱设备ID信息
        bd_ec_id = bd_ec_list.id

    status, bd_cd_list, reason = api.project_get_device_by_type(
        xm_id, "cd")  # 获取项目绑定充放电机设备信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        # 拿到绑定的充放电机设备ID信息
        bd_cd_id = bd_cd_list.id

    status, xm_list, reason = api.project_get(xm_id)  # 获取项目信息
    if status != api.OK:
        context['reason'] = reason
        return render(request, "07-告警提示页面/alarm_prompt.html", context=context)
    else:
        # 拿到绑定的充放电机设备ID信息
        xm_name = xm_list.name

    ID = {
        "BMS_id": bd_bms_id,
        "cm_id": bd_cm_id,
        "ec_id": bd_ec_id,
        "cd_id": bd_cd_id,
        "zt": "xg",
        "项目ID": xm_id,
        "项目名": xm_name
    }
    context['ID'] = ID
    return render(request, '06-BMS参数设置页面/aisle_choose.html', context=context)