Exemple #1
0
 def create(self, mobiledevices_info, result_mapping):
     mobiledevices_qs = MobileDevices.query().filter(
         code=mobiledevices_info.code)
     if mobiledevices_qs.count():
         mobiledevices = mobiledevices_qs[0]
     else:
         mobiledevices = MobileDevices.create(**mobiledevices_info)
     return mobiledevices
Exemple #2
0
    def get_mobile_devices(self, code):
        mobile_devices = None
        if code:
            mobile_devices_qs = MobileDevices.search(code = code)
            if mobile_devices_qs.count() > 0:
                mobile_devices = mobile_devices_qs[0]
            else:
                mobile_devices = MobileDevices.create(code = code, update_time = self._modify_date, create_time = self._create_date)

        return mobile_devices
Exemple #3
0
    def generate(cls, **attrs):
        """添加手机设备"""
        mobiledevices = MobileDevices.create(**attrs)
        if mobiledevices is None:
            raise BusinessError("添加手机设备失败")

        return mobiledevices
Exemple #4
0
    def skip_mobile_devices(self, mobile_code):
        if not mobile_code:
            self._error_msg = "缺少手机编号"
            return False

        mobile_devices_qs = MobileDevices.search(code=mobile_code)
        if mobile_devices_qs.count() > 0:
            self._error_msg = "重复数据"
            return False

        return True
Exemple #5
0
    def is_code_exist(cls, code, mobile_devices=None):
        """判断手机设备编号是否存在"""

        mobile_devices_qs = MobileDevices.search(code=code)
        if mobile_devices is not None:
            mobile_devices_qs = mobile_devices_qs.filter(~Q(
                id=mobile_devices.id))

        if mobile_devices_qs.count() > 0:
            raise BusinessError("该手机设备编号已存在")

        return True
Exemple #6
0
    def convet_mobiledevices(self, mobile_code):
        mobile_devices_qs = MobileDevices.query().filter(code=mobile_code)
        if mobile_devices_qs.count() > 0:
            self._mobiledevices = mobile_devices_qs[0]
            mobile_maintain_qs = MobileMaintain.search(
                devices=self._mobiledevices)
            if mobile_maintain_qs.count() > 0:
                self._server_staff = mobile_maintain_qs[0].staff
        else:
            self._error_msg = "备注手机编码系统不存在"
            return False

        return True
Exemple #7
0
    def exec_convet(self, mobile_devices):
        check_mobile_devices = self.skip_mobile_devices(
            mobile_devices.mobile_code)
        if check_mobile_devices:
            devices = MobileDevices.create(code = mobile_devices.mobile_code, brand = mobile_devices.brand, \
                                                  model = mobile_devices.model, price = mobile_devices.price, \
                                                  status = self.get_devices_status(mobile_devices.mobile_status), \
                                                  remark = self.get_mobile_devices_remark(mobile_devices.mobile_remark, mobile_devices.department), \
                                                  imei = mobile_devices.imei, \
                                                  )
            mobile_phone_staff = self.get_staff(mobile_devices.real_name)

            mobile_phone = self.get_mobile_phone(mobile_devices.phone_number)
            if mobile_phone is None:
                Mobilephone.create(devices = devices, staff = mobile_phone_staff, name = mobile_devices.real_name, \
                                   identity = mobile_phone_staff.identity if mobile_phone_staff else "", wechat_nick = mobile_devices.wechat_nick, \
                                   wechat_number = mobile_devices.wechat_number, wechat_password = mobile_devices.wechat_password, \
                                   pay_password = mobile_devices.pay_password, wechat_remark = mobile_devices.wechat_remark, \
                                   phone_number = mobile_devices.phone_number, operator = mobile_devices.operator, \
                                   phone_remark = mobile_devices.phone_remark, flow_card_number = mobile_devices.flow_card_number, \
                                   )
            else:
                mobile_phone.update(devices = devices, staff = mobile_phone_staff, name = mobile_devices.real_name, \
                                   identity = mobile_phone_staff.identity if mobile_phone_staff else "", wechat_nick = mobile_devices.wechat_nick, \
                                   wechat_number = mobile_devices.wechat_number, wechat_password = mobile_devices.wechat_password, \
                                   pay_password = mobile_devices.pay_password, wechat_remark = mobile_devices.wechat_remark, \
                                   phone_number = mobile_devices.phone_number, operator = mobile_devices.operator, \
                                   phone_remark = mobile_devices.phone_remark, flow_card_number = mobile_devices.flow_card_number, \
                                   )

            mobile_maintain_staff = self.get_staff(mobile_devices.group_member)
            if mobile_maintain_staff is not None:
                MobileMaintain.create(devices = devices, staff = mobile_maintain_staff, \
                                      remark = self.get_mobile_maintain_remark(mobile_devices.group_leader))
            return True, ""

        return False, self._error_msg
Exemple #8
0
    def get_mobile_devices(self, code):
        mobile_devices_qs = MobileDevices.search(code=code)
        if mobile_devices_qs.count() > 0:
            return mobile_devices_qs[0]

        return None
Exemple #9
0
    def skip_mobile_devices(self, code):
        mobile_devices_qs = MobileDevices.search(code=code)
        if mobile_devices_qs.count() == 0:
            return True

        return False
Exemple #10
0
 def generate_date(self, data_list):
     for dic_data in data_list:
         if self.skip_mobile_devices(dic_data["code"]):
             MobileDevices.create(code = dic_data["code"], remark = dic_data["remark"], \
                           update_time = dic_data["modify_date"], create_time = dic_data["create_date"])
Exemple #11
0
 def get(cls, mobile_devices_id):
     """获取手机设备详情"""
     mobile_devices = MobileDevices.get_byid(mobile_devices_id)
     if mobile_devices is None:
         raise BusinessError("此手机设备不存在")
     return mobile_devices
Exemple #12
0
 def searchall(cls, **search_info):
     """查询所有的手机设备列表"""
     mobile_devices_qs = MobileDevices.query(**search_info)
     mobile_devices_qs = mobile_devices_qs.order_by("-create_time")
     return mobile_devices_qs