コード例 #1
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def trainning(self, request, pk=None, *args, **kwargs):
        """
        培训
        :param request:
        :param pk:
        :return:
        """
        verify = self.verify_teacher(request, pk)
        if verify == 0 and request.user.is_superuser is False:
            return Response({"error": "该问题的培训老师不是您,无权操作!"}, status=status.HTTP_400_BAD_REQUEST)
        data = self.request.data

        training_model = data.get("training_model")
        start_time = data.get("start_time")
        end_time = data.get("end_time")
        # 是否有遗留问题
        legacy_issue = data.get("legacy_issue")
        enclosure = data.get("enclosure")
        # 改动记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        matter_log = MatterLog()
        matter_log.status_change(pk, log_id, 8)
        matter_log.date_change(pk, log_id, start_time, end_time)

        matter = Matter.objects.get(pk=pk)
        matter.training_model = training_model
        matter.start_time = start_time
        matter.end_time = end_time
        matter.legacy_issue = legacy_issue
        matter.matter_status = 8
        matter.save()
        if enclosure != []:
            SimpleMatterViewsets.create_attachment(enclosure, "培训", 1, pk)
        return Response({"info": "培训完成"}, status=status.HTTP_200_OK)
コード例 #2
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def distribution_lecturer(self, request, pk=None, *args, **kwargs):
        """
        分配讲师
        :param request:
        :param pk:
        :return:
        """
        data = self.request.data

        instructors = data.get("training_instructors")
        enclosure = data.get("enclosure")

        training_instructors = self.get_user(instructors)
        # 变更记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        mat_log = MatterLog()
        # 记录老师变更
        mat_log.teacher_change(pk, log_id, instructors)
        # 记录状态变更
        mat_log.status_change(pk, log_id, 2)

        matter = Matter.objects.get(pk=pk)
        matter.training_instructors = training_instructors
        matter.matter_status = 2

        matter.save()
        if enclosure != []:
            SimpleMatterViewsets.create_attachment(enclosure,"分配讲师", 1, pk)
        return Response({"info": "讲师分配成功"}, status=status.HTTP_200_OK)
コード例 #3
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def determine_scheduling(self, request, pk=None, *args, **kwargs):
        """
        确定排期
        :param request:
        :param pk:
        :return:
        """
        verify = self.verify_teacher(request, pk)
        if verify == 0 and request.user.is_superuser is False:
            return Response({"error": "该问题的培训老师不是您,无权操作!"}, status=status.HTTP_400_BAD_REQUEST)
        data = self.request.data

        start_time = data.get("start_time")
        end_time = data.get("end_time")
        # 改动记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        matter_log = MatterLog()
        matter_log.status_change(pk, log_id, 4)
        matter_log.date_change(pk, log_id, start_time, end_time)

        matter = Matter.objects.get(pk=pk)
        matter.start_time = start_time
        matter.end_time = end_time
        matter.matter_status = 4
        matter.save()
        return Response({"info": "确定排期成功"}, status=status.HTTP_200_OK)
コード例 #4
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def termination_training(self, request, pk=None, *args, **kwargs):
        """
        终止培训
        :param request:
        :param pk:
        :param args:
        :param kwargs:
        :return:
        """
        data = self.request.data
        verify = self.verify_teacher(request, pk)
        if verify == 0 and request.user.is_superuser is False:
            return Response({"error": "该问题的培训老师不是您,无权操作!"}, status=status.HTTP_400_BAD_REQUEST)
        # 终止原因
        termination_reason = data.get("termination_reason")
        # 上传附件返回的数据
        enclosure = data.get("enclosure")
        # 改动记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        mat_log = MatterLog()
        mat_log.status_change(pk, log_id, 7)

        matter = Matter.objects.get(pk=pk)
        matter.termination_reason = termination_reason
        matter.matter_status = 7
        matter.save()
        if enclosure != []:
            SimpleMatterViewsets.create_attachment(enclosure, "客户终止培训", 1, pk)
        return Response({"info": "客户终止培训成功"}, status=status.HTTP_200_OK)
コード例 #5
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def satisfaction_survey(self, request, pk=None, *args, **kwargs):
        """
        满意度调查
        :param request:
        :param pk:
        :return:
        """
        data = self.request.data

        satisfaction_level = data.get("satisfaction_level")
        customer_feedback = data.get("customer_feedback")
        invest_start = data.get("invest_start")
        invest_end = data.get("invest_end")
        enclosure = data.get("enclosure")

        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        matter_log = MatterLog()
        matter_log.status_change(pk, log_id, 12)

        matter = Matter.objects.get(pk=pk)
        matter.satisfaction_level = satisfaction_level
        matter.customer_feedback = customer_feedback
        matter.invest_start = invest_start
        matter.invest_end = invest_end
        matter.matter_status = 12
        matter.save()
        if enclosure != []:
            # 新增附件
            SimpleMatterViewsets.create_attachment(enclosure, "满意度调查", 1, pk)

        return Response({"info": "满意度调查添加成功"}, status=status.HTTP_200_OK)
コード例 #6
0
ファイル: views_product.py プロジェクト: z991/neng_backend
    def reject(self, request, pk=None, *args, **kwargs):
        data = request.data
        # 驳回原因
        dismiss_reason = data.get("dismiss_reason")
        # 附件
        enclosure = data.get("enclosure")
        # 产品配置记录
        product_log = ProConfigLog()

        try:
            with transaction.atomic():
                # 驳回操作
                ret = Reject.objects.create(dismiss_reason=dismiss_reason,
                                            correlation_id=pk,
                                            reject_type=2)
                log_id = OpenStationViewSet.create_base_log(
                    request, pk, '产品配置管理', 3)
                # 新增附件
                if enclosure != [] or enclosure != '[]':
                    SimpleMatterViewsets.create_attachment(
                        enclosure, "产品配置驳回", 2, pk)
                # 记录产品配置状态变更
                product_log.status_change(pk, log_id, 12)
                status_ret = ProductConfig.objects.filter(pk=pk).update(
                    product_stautus=12)
        except Exception as e:
            raise TypeError(e)
        return Response({"info": "驳回成功"}, status=status.HTTP_200_OK)
コード例 #7
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def handover_issues(self, request, pk=None, *args, **kwargs):
        """
        遗留问题交接
        :param request:
        :param pk:
        :return:
        """
        verify = self.verify_teacher(request, pk)
        if verify == 0 and request.user.is_superuser is False:
            return Response({"error": "该问题的培训老师不是您,无权操作!"}, status=status.HTTP_400_BAD_REQUEST)
        data = self.request.data
        dealing_person = data.get("dealing_person")
        problem_description = data.get("problem_description")
        enclosure = data.get("enclosure")

        dealing_person = self.get_user(dealing_person)
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        matter_log = MatterLog()
        matter_log.status_change(pk, log_id, 9)

        matter = Matter.objects.get(pk=pk)
        matter.dealing_person = dealing_person
        matter.problem_description = problem_description
        matter.matter_status = 9
        matter.save()
        if enclosure != []:
            SimpleMatterViewsets.create_attachment(enclosure, "遗留问题交接", 1, pk)

        return Response({"info": "遗留问题交接完成"}, status=status.HTTP_200_OK)
コード例 #8
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def identification_issues(self, request, pk=None, *args, **kwargs):
        """
        遗留问题确认
        :param request:
        :param pk:
        :return:
        """
        dealing_person = Matter.objects.get(pk=pk).dealing_person
        if dealing_person != request.user and request.user.is_superuser is False:
            return Response({"error": "您不是该问题的处理人,无权操作!"}, status=status.HTTP_400_BAD_REQUEST)
        data = self.request.data
        problem_description = data.get("problem_description")
        enclosure = data.get("enclosure")
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        matter_log = MatterLog()
        matter_log.status_change(pk, log_id, 10)
        matter_log.matter_describe(pk, log_id, problem_description)

        matter = Matter.objects.get(pk=pk)
        matter.problem_description = problem_description
        matter.matter_status = 10
        matter.save()
        if enclosure != []:
            atta = Attachment.objects.create(enclosure=enclosure, step_atta="遗留问题确认", atta_matter=matter)

        return Response({"info": "遗留问题确认成功"}, status=status.HTTP_200_OK)
コード例 #9
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def communication_requirements(self, request, pk=None, *args, **kwargs):
        """
        创建沟通需求
        :param request:
        :param pk:
        :return:
        """
        verify = self.verify_teacher(request, pk)
        if verify == 0 and request.user.is_superuser is False:
            return Response({"error": "该问题的培训老师不是您,无权操作!"}, status=status.HTTP_400_BAD_REQUEST)

        data = self.request.data
        instructors = data.get("training_instructors")
        # 培训联系人
        training_contact = data.get("training_contact")
        # 培训联系人电话
        training_contactnum = data.get("training_contactnum")
        # 培训联系人QQ
        training_contactqq = data.get("training_contactqq")
        # 培训联系人职位
        training_position = data.get("training_position")
        # 客户培训需求
        customer_training_needs = data.get("customer_training_needs")
        # 沟通方式
        communication_way = data.get("communication_way")
        # 最终培训方式
        final_training_method = data.get("final_training_method")
        # 培训预计开始时间
        start_time = data.get("start_time")
        # 培训预计结束时间
        end_time = data.get("end_time")
        # 未培训原因
        untrained_cause = data.get("untrained_cause")

        training_instructors = self.get_user(instructors)
        # 改动记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        mat_log = MatterLog()
        mat_log.train_contact(pk, data, log_id)
        mat_log.status_change(pk, log_id, 4)

        matter = Matter.objects.get(pk=pk)
        matter.training_instructors = training_instructors
        matter.training_contact = training_contact
        matter.training_contactnum = training_contactnum
        matter.training_contactqq = training_contactqq
        matter.training_position = training_position
        matter.customer_training_needs = customer_training_needs
        matter.communication_way = communication_way
        matter.final_training_method = final_training_method
        if start_time != '':
            matter.start_time = str_to_date(start_time)
        if end_time != '':
            matter.end_time = str_to_date(end_time)
        matter.untrained_cause = untrained_cause
        matter.matter_status = 4
        matter.save()

        return Response({"info": "沟通培训需求创建成功"}, status=status.HTTP_200_OK)
コード例 #10
0
ファイル: views_product.py プロジェクト: z991/neng_backend
    def verification_pass(self, request, pk=None, *args, **kwargs):
        """
        验证通过,任务关闭,根据当前产品配置的状态执行对应的操作
        :param request:
        :param pk:
        :param args:
        :param kwargs:
        :return:
        """
        data = request.data
        # 备注
        content = data.get("content")
        # 附件
        enclosure = data.get("enclosure")
        # 产品配置记录
        product_log = ProConfigLog()
        product_config = ProductConfig.objects.get(pk=pk)
        try:
            with transaction.atomic():
                log_id = OpenStationViewSet.create_base_log(
                    request, pk, '产品配置管理', 3)

                product_status = product_config.product_stautus
                # 操作方验证通过
                if product_status == 8:
                    product_log.status_change(pk, log_id, 9)
                    product_config.product_stautus = 9
                    if enclosure != [] or enclosure != '[]':
                        SimpleMatterViewsets.create_attachment(
                            enclosure, "操作方验证通过", 2, pk)
                # 需求方验证通过
                elif product_status == 9:
                    product_log.status_change(pk, log_id, 10)
                    product_config.product_stautus = 10
                    # 新增附件
                    if enclosure != [] or enclosure != '[]':
                        SimpleMatterViewsets.create_attachment(
                            enclosure, "需求方验证通过", 2, pk)
                # 任务关闭
                elif product_status == 10:
                    product_log.status_change(pk, log_id, 11)
                    product_config.product_stautus = 11
                    # 新增附件
                    if enclosure != [] or enclosure != '[]':
                        SimpleMatterViewsets.create_attachment(
                            enclosure, "任务关闭", 2, pk)
                product_config.save()

                # 新增备注
                matter = SimpleMatterViewsets()
                matter.create_remark(request, content, 4, pk)
        except Exception as e:
            raise TypeError(e)
        return Response(status=status.HTTP_200_OK)
コード例 #11
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def create_train(self, request):
        data = request.data
        # 企业id
        company_pk = data.get("company_pk")
        # 问题类型
        matter_type = data.get("matter_type")
        # 经办人
        # responsible = data.get("responsible")
        # 问题名称
        matter_name = data.get("matter_name")
        # 培训方式
        training_method = data.get("training_method")
        # 客户状态描述
        description_customer = data.get("description_customer")
        # 已上线模块
        online_module = data.get("online_module")
        # 未上线模块
        unonline_module = data.get("unonline_module")
        # 培训联系人
        training_contact = data.get("training_contact")
        # 培训联系人电话
        training_contactnum = data.get("training_contactnum")
        # 培训联系人QQ
        training_contactqq = data.get("training_contactqq")
        # 培训联系人职位
        training_position = data.get("training_position")

        # company_matter = CompanyInfo.objects.get(pk=company_pk)
        # 获取当前登录用户
        responsibler = request.user

        train_dict = {
            "matter_type": matter_type,
            "responsible": responsibler,
            "matter_name": matter_name,
            "training_method": training_method,
            "description_customer": description_customer,
            "online_module": online_module,
            "unonline_module": unonline_module,
            "training_contact": training_contact,
            "training_contactnum": training_contactnum,
            "training_contactqq": training_contactqq,
            "training_position": training_position,
            "matter_status": 1,
            "company_matter": company_pk
        }
        ret = Matter.objects.create(**train_dict)
        # 改动记录
        ret = str(ret)
        log_id = OpenStationViewSet.create_base_log(request, ret, "培训管理", 3)
        ma_log = MatterLog()
        ma_log.create_log(log_id,'创建问题', '创建问题')
        return Response(data={"info": "问题创建成功"}, status=status.HTTP_200_OK)
コード例 #12
0
ファイル: views_product.py プロジェクト: z991/neng_backend
    def put_proconfig(self, request, pk=None, *args, **kwargs):
        """
        再次申请
        :param request:
        :param pk:
        :param args:
        :param kwargs:
        :return:
        """
        data = request.data
        # 子站点
        children_station = data.get("children_station")
        # 工单主题
        workorder_theme = data.get("workorder_theme")
        # 所属模块
        subordinatemodule = data.get("subordinatemodule")
        # 功能名称
        func_name = data.get("func_name")
        # 功能选项值
        func_value = data.get("func_value")
        # 描述
        describe = data.get("describe")
        # 附件
        enclosure = data.get("enclosure")

        product_config = ProductConfig.objects.get(pk=pk)
        # 产品配置记录
        product_log = ProConfigLog()
        try:
            with transaction.atomic():
                log_id = OpenStationViewSet.create_base_log(
                    request, pk, '产品配置管理', 3)
                product_config.children_station = children_station
                product_config.workorder_theme = workorder_theme
                product_config.subordinatemodule = subordinatemodule
                product_config.func_name = func_name
                product_config.func_value = func_value
                product_config.describe = describe
                # 记录产品配置状态变更
                product_log.status_change(pk, log_id, 3)
                product_config.product_stautus = 3
                product_config.save()
                if enclosure != [] or enclosure != '[]':
                    # 删除该产品配置的原有附件
                    ret = Attachment.objects.filter(
                        atta_type=2, correlation_id=pk).delete()
                    # 新增附件
                    SimpleMatterViewsets.create_attachment(
                        enclosure, "重新申请", 2, pk)
        except Exception as e:
            raise TypeError(e)
        return Response({"info": "产品配置修改成功"}, status=status.HTTP_200_OK)
コード例 #13
0
ファイル: views_product.py プロジェクト: z991/neng_backend
    def create(self, request, *args, **kwargs):
        """
        产品配置创建
        :param request:
        :return:
        """
        data = request.data
        # 子站点
        children_station = data.get("children_station")
        # 客户库id
        khk_id = data.get("khk_id")
        # 工单主题
        workorder_theme = data.get("workorder_theme")
        # 所属模块
        subordinatemodule = data.get("subordinatemodule")
        # 功能名称
        func_name = data.get("func_name")
        # 功能选项值
        func_value = data.get("func_value")
        # 描述
        describe = data.get("describe")
        # 附件
        enclosure = data.get("enclosure")

        # 获取开站id
        open_id = OpenStationManage.objects.get(company_info=khk_id).id

        product_dict = {
            "children_station": children_station,
            "open_id": open_id,
            "workorder_theme": workorder_theme,
            "subordinatemodule": subordinatemodule,
            "func_name": func_name,
            "func_value": func_value,
            "describe": describe,
            "product_stautus": 3,
            "khk_id": khk_id
        }

        ret = ProductConfig.objects.create(**product_dict)
        # 改动记录
        log_id = OpenStationViewSet.create_base_log(request, ret.id, "产品配置管理",
                                                    3)
        ma_log = MatterLog()
        ma_log.create_log(log_id, '创建产品配置', '创建产品配置')
        if enclosure != [] or enclosure != '[]':
            SimpleMatterViewsets.create_attachment(enclosure, "新增产品配置", 2,
                                                   ret.id)
        return Response({"info": "产品配置创建成功"}, status=status.HTTP_200_OK)
コード例 #14
0
ファイル: views_product.py プロジェクト: z991/neng_backend
    def problem_solver(self, request, pk=None, *args, **kwargs):
        """
        分配处理人
        :param request:
        :param pk:
        :param args:
        :param kwargs:
        :return:
        """
        log_id = OpenStationViewSet.create_base_log(request, pk, '产品配置管理', 3)
        product_log = ProConfigLog()

        data = request.data
        # 处理人id
        dealing_person = data.get("dealing_person")
        task_type = self.get_task_type(dealing_person)
        # 备注
        content = data.get("content")
        # 分配人
        allocation_people = request.user

        # 处理人
        dealing_person = User.objects.get(pk=dealing_person)
        product_config = ProductConfig.objects.get(pk=pk)
        try:
            with transaction.atomic():
                product_config.dealing_person = dealing_person
                product_config.allocation_people = allocation_people.last_name
                product_config.allocate_time = datetime.datetime.now()

                # 平台组
                if task_type == 1:
                    # 记录产品配置状态变更
                    product_log.status_change(pk, log_id, 4)
                    product_config.product_stautus = 4

                else:
                    # 记录产品配置状态变更
                    product_log.status_change(pk, log_id, 6)
                    product_config.product_stautus = 6
                product_config.save()
                # 备注
                matter = SimpleMatterViewsets()
                # 新增备注
                matter.create_remark(request, content, 4, pk)
        except Exception as e:
            raise TypeError(e)
        return Response({"info": "分配完成"}, status=status.HTTP_200_OK)
コード例 #15
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def set_pending(self, request, pk=None, *args, **kwargs):
        """
        状态挂起
        :param request:
        :param pk:
        :return:
        """
        verify = self.verify_teacher(request, pk)
        # 改动记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        mat_log = MatterLog()
        mat_log.status_change(pk, log_id, 6)
        if verify == 0 and request.user.is_superuser is False:
            return Response({"error": "该问题的培训老师不是您,无权操作!"}, status=status.HTTP_400_BAD_REQUEST)
        ret = Matter.objects.filter(pk=pk).update(matter_status=6)

        return Response({"info": "培训已挂起"}, status=status.HTTP_200_OK)
コード例 #16
0
ファイル: views_product.py プロジェクト: z991/neng_backend
    def fail_verification(self, request, pk=None, *args, **kwargs):
        """
        验证不通过
        :param request:
        :param pk:
        :param args:
        :param kwargs:
        :return:
        """
        data = request.data
        # 不通过原因
        dismiss_reason = data.get("dismiss_reason")
        # 附件
        enclosure = data.get("enclosure")

        product_status = ProductConfig.objects.get(pk=pk).product_stautus
        # 产品配置记录
        product_log = ProConfigLog()
        # try:
        #     with transaction.atomic():
        log_id = OpenStationViewSet.create_base_log(request, pk, '产品配置管理', 3)
        # 操作方验证通过
        if product_status == 8:
            ret = Reject.objects.create(dismiss_reason=dismiss_reason,
                                        correlation_id=pk,
                                        reject_type=3)
            if enclosure != [] or enclosure != '[]':
                # 新增附件
                SimpleMatterViewsets.create_attachment(enclosure, "操作方验证不通过",
                                                       2, pk)
        # 需求方验证通过
        elif product_status == 9:
            ret = Reject.objects.create(dismiss_reason=dismiss_reason,
                                        correlation_id=pk,
                                        reject_type=4)
            if enclosure != [] or enclosure != '[]':
                # 新增附件
                SimpleMatterViewsets.create_attachment(enclosure, "需求方验证不通过",
                                                       2, pk)
        product_log.status_change(pk, log_id, 3)
        # 验证不通过
        ret = ProductConfig.objects.filter(pk=pk).update(product_stautus=3)
        # except Exception as e:
        #     raise TypeError(e)
        return Response(status=status.HTTP_200_OK)
コード例 #17
0
ファイル: views_product.py プロジェクト: z991/neng_backend
 def operator_verification(self, request, pk=None, *args, **kwargs):
     """
     操作方验证
     :param request:
     :param pk:
     :param args:
     :param kwargs:
     :return:
     """
     # 产品配置记录
     product_log = ProConfigLog()
     try:
         with transaction.atomic():
             log_id = OpenStationViewSet.create_base_log(
                 request, pk, '产品配置管理', 3)
             product_log.status_change(pk, log_id, 8)
             ret = ProductConfig.objects.filter(pk=pk).update(
                 product_stautus=8)
     except Exception as e:
         raise TypeError(e)
     return Response(status=status.HTTP_200_OK)
コード例 #18
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def personnel_allocation(self, request, pk=None, *args, **kwargs):
        """
        调查人员分配
        :param request:
        :param pk:
        :return:
        """
        data = self.request.data
        investigador = data.get("investigador")
        # 获取用户实例
        investigador = self.get_user(investigador)
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        matter_log = MatterLog()
        matter_log.status_change(pk, log_id, 11)

        matter = Matter.objects.get(pk=pk)
        matter.investigador = investigador
        matter.matter_status = 11
        matter.save()

        return Response({"info": "调查人员分配成功"}, status=status.HTTP_200_OK)
コード例 #19
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def reject(self, request, pk=None, *args, **kwargs):
        """
        驳回
        :param request:
        :param pk:
        :param args:
        :param kwargs:
        :return:
        """
        data = self.request.data
        dismiss_reason = data.get("dismiss_reason")
        # 状态变更记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        matter_log = MatterLog()
        matter_log.status_change(pk, log_id, 3)
        matter_log.reject_change(pk, dismiss_reason, log_id)

        matter = Matter.objects.get(pk=pk)
        matter.matter_status = 3
        matter.save()
        reject = Reject.objects.create(dismiss_reason=dismiss_reason, correlation_id=pk, reject_type=1)

        return Response({"info": "驳回成功"}, status=status.HTTP_200_OK)
コード例 #20
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def training_prepare(self, request, pk=None, *args, **kwargs):
        """
        培训准备
        :param request:
        :param pk:
        :return:
        """
        verify = self.verify_teacher(request, pk)
        if verify == 0 and request.user.is_superuser is False:
            return Response({"error": "该问题的培训老师不是您,无权操作!"}, status=status.HTTP_400_BAD_REQUEST)
        data = self.request.data

        instructors = data.get("training_instructors")
        enclosure = data.get("enclosure")
        start_time = data.get("start_time")
        end_time = data.get("end_time")

        training_instructors = self.get_user(instructors)
        # 改动记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        matter_log = MatterLog()
        matter_log.status_change(pk, log_id, 5)
        matter_log.date_change(pk, log_id, start_time, end_time)

        matter = Matter.objects.get(pk=pk)
        matter.training_instructors = training_instructors
        matter.start_time = start_time
        matter.end_time = end_time
        matter.matter_status = 5
        matter.save()

        if enclosure != []:
            # 保存附件
            SimpleMatterViewsets.create_attachment(enclosure, "培训准备", 1, pk)

        return Response({"info": "培训准备完成"}, status=status.HTTP_200_OK)
コード例 #21
0
ファイル: views_matter.py プロジェクト: z991/neng_backend
    def put_train(self, request, pk=None, *args, **kwargs):
        """
        问题修改成功
        :param request:
        :param pk:
        :return:
        """
        matter_responsible = Matter.objects.get(pk=pk).responsible
        if request.user != matter_responsible and request.user.is_superuser is False:
            return Response({"error": "您不是该问题的经办人,无法操作"}, status=status.HTTP_400_BAD_REQUEST)
        data = self.request.data

        # 改动记录
        log_id = OpenStationViewSet.create_base_log(request, pk, "培训管理", 3)
        ma_log = MatterLog()
        ma_log.apply_again(pk, data, log_id)
        ma_log.status_change(pk, log_id, 1)

        # 问题类型key-value 位置交换
        type_dict = dict(MATTER_TYPE)
        type_dict = {v: k for k, v in type_dict.items()}

        # 问题类型
        matter_type = data.get("matter_type")
        # 问题名称
        matter_name = data.get("matter_name")
        # 培训方式
        training_method = data.get("training_method")
        # 客户状态描述
        description_customer = data.get("description_customer")
        # 已上线模块
        online_module = data.get("online_module")
        # 未上线模块
        unonline_module = data.get("unonline_module")
        # 培训联系人
        training_contact = data.get("training_contact")
        # 培训联系人电话
        training_contactnum = data.get("training_contactnum")
        # 培训联系人QQ
        training_contactqq = data.get("training_contactqq")
        # 培训联系人职位
        training_position = data.get("training_position")
        # 培训方式key-value 位置交换
        method_dict = dict(TRAINING_METTART_METHOD)
        method_dict = {v: k for k, v in method_dict.items()}

        matter = Matter.objects.get(pk=pk)
        matter.matter_type = type_dict.get(matter_type)
        matter.matter_name = matter_name
        matter.training_method = method_dict.get(training_method)
        matter.description_customer = description_customer
        matter.online_module = online_module
        matter.unonline_module = unonline_module
        matter.training_contact = training_contact
        matter.training_contactnum = training_contactnum
        matter.training_contactqq = training_contactqq
        matter.training_position = training_position
        matter.matter_status = 1
        matter.save()

        return Response({"info": "信息修改成功"}, status=status.HTTP_200_OK)
コード例 #22
0
ファイル: views_product.py プロジェクト: z991/neng_backend
    def product_open(self, request, pk=None, *args, **kwargs):
        """
        开站2,3步
        :param request:
        :param pk:
        :param args:
        :param kwargs:
        :return:
        """
        data = request.data
        common_open = CommonOpenSet()
        # 产品配置记录
        product_log = ProConfigLog()

        # 开站id
        open_id = data.get("open_id")

        children_id = data.get("children_id")

        sta_data = data.get("station_info")
        func_list = data.get("func_list")

        # 获取  要修改的站点的open_id
        #要得目的  如果childre_id 不为None,要修改的是子站,对open_id = children_id
        # childre_id 为 None  表达式为True  执行
        # 1. childeren =None 2. children_di=34534

        if children_id != None:
            # 修改子站
            parents = 1
            open_id = int(children_id)
        elif children_id == None:
            open_id = int(open_id)
            parents = 0

        open = OpenStationManage.objects.get(pk=open_id)

        station_info = open.station_info
        company_id = station_info.company_id
        online_status = open.online_status
        input_pact_products = sta_data["pact_products"]
        """
        开站管理2、3步
        """
        try:
            with transaction.atomic():
                log_id = OpenStationViewSet.create_base_log(
                    request, pk, '产品配置管理', 3)

                # 更新站点信息
                common_open.open_update_station(open, station_info, sta_data,
                                                parents)
                # 更新站点的功能开关信息
                common_open.open_funclist(open, func_list)
                # 判断该open_id的站点是经典版1还是重构版2
                classify = common_open.get_classify(open_id)
                if classify == 1 and parents == 0:
                    common_open.open_servergrouup(station_info, sta_data,
                                                  classify)
                # 如果站点状态是开站
                if online_status is True:
                    # 开站
                    common_open.open_manage(company_id, online_status,
                                            classify)
                # 获取修改前的站点到期时间和产品名称列表
                pre_station_info = StationInfo.objects.filter(
                    open_station__id=open_id).select_related(
                        'pact_products__product').values_list(
                            'pact_products__product', 'close_station_time')
                common_open.new_product(company_id, pre_station_info,
                                        input_pact_products)
                common_open.open_renewal(pre_station_info, company_id,
                                         sta_data)
                """
                产品配置
                """
                product_config = ProductConfig.objects.get(pk=pk)
                current_state = product_config.product_stautus
                # 实际开始时间
                actual_start_time = data.get("actual_start_time")
                # 实际完成时间
                actual_completion_time = datetime.datetime.now()
                product_config.actual_start_time = actual_start_time
                product_config.actual_completion_time = actual_completion_time
                if current_state == 4:
                    # 记录产品配置状态变更
                    product_log.status_change(pk, log_id, 5)
                    product_config.product_stautus = 5
                elif current_state == 6:
                    # 记录产品配置状态变更
                    product_log.status_change(pk, log_id, 7)
                    product_config.product_stautus = 7
                product_config.save()
        except Exception as e:
            raise TypeError(e)
        return Response({"info": "操作完成"}, status=status.HTTP_200_OK)