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

        return mobiledevices
Beispiel #2
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
Beispiel #3
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
Beispiel #4
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
Beispiel #5
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"])