|
@@ -168,42 +168,35 @@ class EquipmentInfo(View):
|
|
|
res.append(p)
|
|
|
return response.json(0, {'datas': res, 'count': count})
|
|
|
|
|
|
- def update_info(self, request_dict, userID, response):
|
|
|
- is_update_all = request_dict.get('is_update_all', 0)
|
|
|
- eventType = request_dict.get('eventType', None)
|
|
|
- if int(is_update_all) == 1:
|
|
|
+ @staticmethod
|
|
|
+ def update_info(request_dict, userID, response):
|
|
|
+ is_update_all = int(request_dict.get('is_update_all', 0))
|
|
|
+ event_type = request_dict.get('eventType', None)
|
|
|
+ if is_update_all == 1:
|
|
|
+ kwargs = {
|
|
|
+ 'device_user_id': userID
|
|
|
+ }
|
|
|
+ if event_type:
|
|
|
+ kwargs['event_type'] = int(event_type)
|
|
|
try:
|
|
|
- is_update = 0
|
|
|
- for i in range(1, 8):
|
|
|
- eq_qs = EquipmentInfoService.get_equipment_info_model('', i)
|
|
|
- eq_qs = eq_qs.filter(device_user_id=userID)
|
|
|
- if eventType:
|
|
|
- eq_qs = eq_qs.filter(event_type=int(eventType))
|
|
|
- is_update += eq_qs.update(status=1)
|
|
|
- return response.json(0, {'update_count': is_update})
|
|
|
+ EquipmentInfoService.all_read_equipment_info(**kwargs)
|
|
|
except Exception as e:
|
|
|
print(repr(e))
|
|
|
- return response.json(0, {'update_success': 'all'})
|
|
|
else:
|
|
|
id_list = request_dict.getlist('id[]', None)
|
|
|
if id_list is None or len(id_list) < 1:
|
|
|
id_list = request_dict.getlist('id', None)
|
|
|
param_flag = CommonService.get_param_flag(data=[id_list])
|
|
|
- if param_flag is True:
|
|
|
- count = 0
|
|
|
- for ei_id in id_list:
|
|
|
- try:
|
|
|
- tab_val = int(ei_id[0:1])
|
|
|
- ei_id = int(ei_id[1:])
|
|
|
- eq = EquipmentInfoService.get_equipment_info_model('', tab_val)
|
|
|
- eq.filter(id=ei_id).update(status=1)
|
|
|
- count += 1
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- print(repr(e))
|
|
|
- return response.json(0, {'update_success': count})
|
|
|
- else:
|
|
|
+ if not param_flag:
|
|
|
return response.json(444)
|
|
|
+ for full_id in id_list:
|
|
|
+ try:
|
|
|
+ ei_id = int(full_id[2:])
|
|
|
+ equipment_info_model = EquipmentInfoService.get_equipment_info_model_with_full_id(full_id)
|
|
|
+ equipment_info_model.filter(id=ei_id).update(status=1)
|
|
|
+ except Exception as e:
|
|
|
+ print(repr(e))
|
|
|
+ return response.json(0)
|
|
|
|
|
|
@staticmethod
|
|
|
def update_answer_status(request_dict, user_id, response):
|