imperituroard 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/imperituroard/projects/iot.rb +16 -16
- data/lib/imperituroard/version.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5264f8d3d00a73980d4de22a91b93c49ccd65904
|
4
|
+
data.tar.gz: a165a821f4ea118ca20916f6ca512aa4d1f4b173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8d44ca288a3ebadc98ebd0ad7844e781c1ca3085c4df144113f9cd61a349915f71565daeeaa460437d4b6da545a40f7577c488bc7f4f6ca09230dafacc535b1
|
7
|
+
data.tar.gz: 1161e315402988d67d08cb63d0c7660412a24d2826172e5d23c38f81d1fa876c84cfef2f56b83754a7f8ff3cbc1d45e2cdd1415b6cc96abb8c8a9a8a5c15739f
|
@@ -980,24 +980,33 @@ class IotFunctions_2
|
|
980
980
|
#step1 checking permission for writing for imei list
|
981
981
|
prof_name1 = mongo_client.get_profile_name_from_imei(curr_dev["imei"].to_i)
|
982
982
|
if prof_name1[:code] == 200
|
983
|
-
|
983
|
+
|
984
|
+
if curr_dev["new_profile"] != "nil" && curr_dev["new_profile"] != "null" && curr_dev["new_profile"] != "empty"
|
985
|
+
prof_new_id = mongo_client.get_profile_universal(curr_dev["new_profile"])["profile_id"]
|
986
|
+
else
|
987
|
+
prof_new_id = prof_name1[:body]["profile_id"]
|
988
|
+
end
|
989
|
+
|
990
|
+
|
991
|
+
if curr_dev["new_type"] != "nil" && curr_dev["new_type"] != "null" && curr_dev["new_type"] != "empty"
|
992
|
+
type_new_pr = curr_dev["new_type"]
|
993
|
+
else
|
994
|
+
type_new_pr = prof_name1[:imei_info][:body][0]["device_type"]
|
995
|
+
end
|
996
|
+
|
984
997
|
|
985
998
|
get_login_info = mongo_client.check_login_prof_perm_id_one(inp_login, prof_name1[:body]["profile_id"])
|
986
999
|
if get_login_info[:code] == 200
|
987
1000
|
get_login_info_new = mongo_client.check_login_prof_perm_id_one(inp_login, prof_new_id)
|
988
1001
|
if get_login_info_new[:code] == 200
|
989
|
-
|
990
1002
|
cur_comp1 = mongo_client.compare_profiles(prof_name1[:body]["profile_id"], prof_new_id)
|
991
|
-
cur_comp2 = mongo_client.compare_device_types(prof_name1[:imei_info][:body][0]["device_type"],
|
1003
|
+
cur_comp2 = mongo_client.compare_device_types(prof_name1[:imei_info][:body][0]["device_type"], type_new_pr)
|
992
1004
|
|
993
|
-
p cur_comp1
|
994
|
-
p cur_comp2
|
995
1005
|
if cur_comp1[:is_the_same] && cur_comp2[:is_the_same]
|
996
1006
|
#the same. Nothing to do
|
997
1007
|
processed_list.append(curr_dev)
|
998
1008
|
########
|
999
1009
|
else
|
1000
|
-
|
1001
1010
|
credentials_old = mongo_client.get_iot_oceanconn_credent_2(prof_name1[:body]["profile"])
|
1002
1011
|
credentials_new = mongo_client.get_iot_oceanconn_credent_2(prof_new_id)
|
1003
1012
|
#########
|
@@ -1006,9 +1015,7 @@ class IotFunctions_2
|
|
1006
1015
|
if imei_data[:body] != []
|
1007
1016
|
ans = {}
|
1008
1017
|
if imei_data[:body][0]["huadata"]["body"]["deviceId"] != nil
|
1009
|
-
|
1010
|
-
model_data = mongo_client.get_device_type_info_universal(curr_dev["new_type"])
|
1011
|
-
|
1018
|
+
model_data = mongo_client.get_device_type_info_universal(type_new_pr)
|
1012
1019
|
#####all checks completed. then process data#####
|
1013
1020
|
ans_old = hua_aceanconnect_connector.remove_one_device_from_iot(credentials_old[:body][:app_id], credentials_old[:body][:secret], imei_data[:body][0]["huadata"]["body"]["deviceId"])
|
1014
1021
|
|
@@ -1025,9 +1032,7 @@ class IotFunctions_2
|
|
1025
1032
|
model_data[:body]["ManufacturerNAME"],
|
1026
1033
|
model_data[:body]["model"]
|
1027
1034
|
)
|
1028
|
-
|
1029
1035
|
if resss[:code]=="200"
|
1030
|
-
|
1031
1036
|
if resss[:body].key?("error_code") && resss[:body]["error_code"] != 200
|
1032
1037
|
not_processed_list.append({:imei => curr_dev["imei"], :error => resss})
|
1033
1038
|
else
|
@@ -1036,18 +1041,14 @@ class IotFunctions_2
|
|
1036
1041
|
now_date = DateTime.now
|
1037
1042
|
#finished success. update database
|
1038
1043
|
attribute = {profile: new_profile_id, device_type: model_data[:body]["model"], huadata: {body: new_id_iot}, updated: now_date}
|
1039
|
-
|
1040
1044
|
answ_mongo = mongo_client.modify_attr_mongo_universal(curr_dev["imei"].to_i, attribute)
|
1041
|
-
|
1042
1045
|
if answ_mongo[:code] != 200
|
1043
1046
|
not_processed_list.append({:imei => curr_dev["imei"], :error => "Critical error. Mongo not updated", :mongo_err => answ_mongo})
|
1044
1047
|
else
|
1045
1048
|
processed_list.append(curr_dev)
|
1046
1049
|
end
|
1047
|
-
|
1048
1050
|
#added_on_iot_platf.append(s1)
|
1049
1051
|
end
|
1050
|
-
|
1051
1052
|
else
|
1052
1053
|
not_processed_list.append({:imei => curr_dev["imei"], :error => resss})
|
1053
1054
|
end
|
@@ -1102,7 +1103,6 @@ class IotFunctions_2
|
|
1102
1103
|
output_answ = {:code => 200, :result => "Success", :body => {:to_soap_gw => soap_answ, :not_processed_list => not_processed_list, :processed_list => processed_list}}
|
1103
1104
|
mongo_client.audit_logger("set_data_replace_2", remote_ip, input_params, output_answ, real_ip)
|
1104
1105
|
output_answ
|
1105
|
-
|
1106
1106
|
end
|
1107
1107
|
|
1108
1108
|
|