|
@@ -424,6 +424,10 @@ class CBDThread(QtCore.QThread):
|
|
|
|
|
|
|
|
def get_position(self, device_id):
|
|
def get_position(self, device_id):
|
|
|
device = self.device_collection.find_one({"device_id": device_id})
|
|
device = self.device_collection.find_one({"device_id": device_id})
|
|
|
|
|
+ province, city, district = device.get("province"), device.get("city"), device.get("district")
|
|
|
|
|
+ position_device = f"{province}{city}{district}"
|
|
|
|
|
+ if position_device:
|
|
|
|
|
+ return position_device
|
|
|
lng, lat = device.get("lng"), device.get("lat")
|
|
lng, lat = device.get("lng"), device.get("lat")
|
|
|
if lng and lat:
|
|
if lng and lat:
|
|
|
try:
|
|
try:
|
|
@@ -468,20 +472,17 @@ class CBDThread(QtCore.QThread):
|
|
|
data = {"iccids":[iccid]}
|
|
data = {"iccids":[iccid]}
|
|
|
data = json.dumps(data)
|
|
data = json.dumps(data)
|
|
|
ret = requests.post(url,data=data,timeout=(10,30))
|
|
ret = requests.post(url,data=data,timeout=(10,30))
|
|
|
- print(ret.text)
|
|
|
|
|
status = 3
|
|
status = 3
|
|
|
except:
|
|
except:
|
|
|
status = 0
|
|
status = 0
|
|
|
ret = 0
|
|
ret = 0
|
|
|
day = 0
|
|
day = 0
|
|
|
- print(ret)
|
|
|
|
|
if ret:
|
|
if ret:
|
|
|
try:
|
|
try:
|
|
|
result = json.loads(ret.text)
|
|
result = json.loads(ret.text)
|
|
|
expiry_date = result.get("data", {}).get("expiry_date")
|
|
expiry_date = result.get("data", {}).get("expiry_date")
|
|
|
now_date = int(time.time())
|
|
now_date = int(time.time())
|
|
|
time_difference = int((expiry_date - now_date) / 3600 / 24)
|
|
time_difference = int((expiry_date - now_date) / 3600 / 24)
|
|
|
- print(time_difference)
|
|
|
|
|
if time_difference < 30:
|
|
if time_difference < 30:
|
|
|
return [1,"有效期剩余{}天".format(time_difference)]
|
|
return [1,"有效期剩余{}天".format(time_difference)]
|
|
|
elif time_difference >= 181:
|
|
elif time_difference >= 181:
|
|
@@ -586,7 +587,6 @@ class CBDThread(QtCore.QThread):
|
|
|
scores_time = {}
|
|
scores_time = {}
|
|
|
photo_obj = self.cbd_photo.find({"device_id":str(device_id), 'addtime': {"$gte": int(self.start_time) - 3600 * 24,"$lte":self.start_time}})
|
|
photo_obj = self.cbd_photo.find({"device_id":str(device_id), 'addtime': {"$gte": int(self.start_time) - 3600 * 24,"$lte":self.start_time}})
|
|
|
# photo_obj = self.cbd_photo.find({"device_id":str(device_id), 'addtime': {"$lte":self.start_time}})
|
|
# photo_obj = self.cbd_photo.find({"device_id":str(device_id), 'addtime': {"$lte":self.start_time}})
|
|
|
- print("图片数量:", photo_obj.count())
|
|
|
|
|
for p in photo_obj:
|
|
for p in photo_obj:
|
|
|
photo_addr = p.get("addr")
|
|
photo_addr = p.get("addr")
|
|
|
addtime = p.get("addtime")
|
|
addtime = p.get("addtime")
|
|
@@ -602,8 +602,6 @@ class CBDThread(QtCore.QThread):
|
|
|
result_score = self.predict(os.path.join(local_dir, file_name))
|
|
result_score = self.predict(os.path.join(local_dir, file_name))
|
|
|
if result_score:
|
|
if result_score:
|
|
|
avg_score = sum(result_score)/len(result_score)
|
|
avg_score = sum(result_score)/len(result_score)
|
|
|
- if avg_score > 60:
|
|
|
|
|
- print(f"score {avg_score}")
|
|
|
|
|
scores_time[str(addtime)] = avg_score
|
|
scores_time[str(addtime)] = avg_score
|
|
|
try:
|
|
try:
|
|
|
os.remove(os.path.join(local_dir, file_name))
|
|
os.remove(os.path.join(local_dir, file_name))
|
|
@@ -792,7 +790,6 @@ class CBDThread(QtCore.QThread):
|
|
|
device_c = ast.literal_eval(device_c)
|
|
device_c = ast.literal_eval(device_c)
|
|
|
tp = device_c.get("tps", "")
|
|
tp = device_c.get("tps", "")
|
|
|
if tp == "1":
|
|
if tp == "1":
|
|
|
- print(device_c)
|
|
|
|
|
tr_k_jg_lst.append(tp)
|
|
tr_k_jg_lst.append(tp)
|
|
|
|
|
|
|
|
for index, cur in enumerate(data_cursor):
|
|
for index, cur in enumerate(data_cursor):
|
|
@@ -801,7 +798,6 @@ class CBDThread(QtCore.QThread):
|
|
|
if device_data:
|
|
if device_data:
|
|
|
device_data = ast.literal_eval(device_data)
|
|
device_data = ast.literal_eval(device_data)
|
|
|
iccid = device_data.get("iccid", "")
|
|
iccid = device_data.get("iccid", "")
|
|
|
- print(device_data, self.set_power, "--------------")
|
|
|
|
|
lamp = device_data.get("lamp")
|
|
lamp = device_data.get("lamp")
|
|
|
if lamp == "0":
|
|
if lamp == "0":
|
|
|
infor_lamp[str(start_time)] = lamp
|
|
infor_lamp[str(start_time)] = lamp
|
|
@@ -854,7 +850,6 @@ class CBDThread(QtCore.QThread):
|
|
|
lat_jg = [1, f"{str(min(lat_lst))}~{str(max(lat_lst))}"]
|
|
lat_jg = [1, f"{str(min(lat_lst))}~{str(max(lat_lst))}"]
|
|
|
# 工作状态切换
|
|
# 工作状态切换
|
|
|
work_status_str = "".join(work_status)
|
|
work_status_str = "".join(work_status)
|
|
|
- print(work_status_str, "工作状态切换")
|
|
|
|
|
result = self.eliminate_adjacent_duplicates(work_status_str)
|
|
result = self.eliminate_adjacent_duplicates(work_status_str)
|
|
|
count_01 = result.count("01")
|
|
count_01 = result.count("01")
|
|
|
count_10 = result.count("10")
|
|
count_10 = result.count("10")
|
|
@@ -919,7 +914,6 @@ class CBDThread(QtCore.QThread):
|
|
|
else:
|
|
else:
|
|
|
img_jg = [1, ""]
|
|
img_jg = [1, ""]
|
|
|
# 上报信息条数
|
|
# 上报信息条数
|
|
|
- print("上报信息条数", infor_lamp, information_count)
|
|
|
|
|
interval = [abs(information_count[i+1] - information_count[i]) for i in range(len(information_count) - 1)]
|
|
interval = [abs(information_count[i+1] - information_count[i]) for i in range(len(information_count) - 1)]
|
|
|
k = 0
|
|
k = 0
|
|
|
for i in interval:
|
|
for i in interval:
|
|
@@ -959,21 +953,23 @@ class CBDThread(QtCore.QThread):
|
|
|
rtu_num = [0, ",".join(rtus)]
|
|
rtu_num = [0, ",".join(rtus)]
|
|
|
# 工作时长 判定
|
|
# 工作时长 判定
|
|
|
if self.set_power == "DC":
|
|
if self.set_power == "DC":
|
|
|
- print(tt, "+++++++++++++++++++++++++")
|
|
|
|
|
- if tt == "4":
|
|
|
|
|
|
|
+ # total_time 去重
|
|
|
|
|
+ total_time = list(set(total_time))
|
|
|
|
|
+ if len(total_time) == 1 and total_time[0] == 4:
|
|
|
|
|
+ # if tt == "4":
|
|
|
time_jg = [1, "4"]
|
|
time_jg = [1, "4"]
|
|
|
else:
|
|
else:
|
|
|
time_jg = [0, "不合格"]
|
|
time_jg = [0, "不合格"]
|
|
|
else:
|
|
else:
|
|
|
time_jg = [0, "不合格"]
|
|
time_jg = [0, "不合格"]
|
|
|
- # power_pass = []
|
|
|
|
|
- # for i in total_time:
|
|
|
|
|
- # if i not in power_pass:
|
|
|
|
|
- # power_pass.append(i)
|
|
|
|
|
- # if len(power_pass) == 1 and power_pass[0] == 4:
|
|
|
|
|
- # time_jg = [1, "4"]
|
|
|
|
|
- # else:
|
|
|
|
|
- # time_jg = [0, ",".join([str(i) for i in power_pass])]
|
|
|
|
|
|
|
+ # power_pass = []
|
|
|
|
|
+ # for i in total_time:
|
|
|
|
|
+ # if i not in power_pass:
|
|
|
|
|
+ # power_pass.append(i)
|
|
|
|
|
+ # if len(power_pass) == 1 and power_pass[0] == 4:
|
|
|
|
|
+ # time_jg = [1, "4"]
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # time_jg = [0, ",".join([str(i) for i in power_pass])]
|
|
|
# if self.set_power == "AC":
|
|
# if self.set_power == "AC":
|
|
|
# power_pass = []
|
|
# power_pass = []
|
|
|
# for i in total_time:
|
|
# for i in total_time:
|
|
@@ -1076,7 +1072,6 @@ class CBDThread(QtCore.QThread):
|
|
|
device_data = cur.get("cbd_data", "")
|
|
device_data = cur.get("cbd_data", "")
|
|
|
if device_data:
|
|
if device_data:
|
|
|
device_data = ast.literal_eval(device_data)
|
|
device_data = ast.literal_eval(device_data)
|
|
|
- print(device_data, "-------------------")
|
|
|
|
|
lng = device_data.get("lng", "")
|
|
lng = device_data.get("lng", "")
|
|
|
lng_lst.append(float(lng))
|
|
lng_lst.append(float(lng))
|
|
|
lat = device_data.get("lat", "")
|
|
lat = device_data.get("lat", "")
|
|
@@ -1089,13 +1084,11 @@ class CBDThread(QtCore.QThread):
|
|
|
temp_hum.append({"at": device_data.get("at", ""), "ah": device_data.get("ah", "")})
|
|
temp_hum.append({"at": device_data.get("at", ""), "ah": device_data.get("ah", "")})
|
|
|
if self.set_power == "AC":
|
|
if self.set_power == "AC":
|
|
|
total_time.append(device_data.get("tt"))
|
|
total_time.append(device_data.get("tt"))
|
|
|
- print(device_data, "-------------------")
|
|
|
|
|
elif self.set_power == "DC":
|
|
elif self.set_power == "DC":
|
|
|
st = device_data.get("st", "00:00")
|
|
st = device_data.get("st", "00:00")
|
|
|
et = device_data.get("et", "00:00")
|
|
et = device_data.get("et", "00:00")
|
|
|
st = int(st.split(":")[0])
|
|
st = int(st.split(":")[0])
|
|
|
et = int(et.split(":")[0])
|
|
et = int(et.split(":")[0])
|
|
|
- print(device_data, "-------------------")
|
|
|
|
|
if st > et:
|
|
if st > et:
|
|
|
total = 24 - st + et
|
|
total = 24 - st + et
|
|
|
else:
|
|
else:
|
|
@@ -1343,14 +1336,12 @@ class CBDThread(QtCore.QThread):
|
|
|
verify_list = []
|
|
verify_list = []
|
|
|
for index, short_id in enumerate(self.device_list):
|
|
for index, short_id in enumerate(self.device_list):
|
|
|
short_id = str(int(short_id)).strip() # 把device_id转换成字符串并去除空格
|
|
short_id = str(int(short_id)).strip() # 把device_id转换成字符串并去除空格
|
|
|
- print(short_id, "short_id")
|
|
|
|
|
d_id,deviceId,platform = self.device_their_platform(short_id)
|
|
d_id,deviceId,platform = self.device_their_platform(short_id)
|
|
|
# if short_id != deviceId:
|
|
# if short_id != deviceId:
|
|
|
# device_id_info = [0, "不合格"]
|
|
# device_id_info = [0, "不合格"]
|
|
|
# else:
|
|
# else:
|
|
|
device_id_info = [1, deviceId]
|
|
device_id_info = [1, deviceId]
|
|
|
worksheet.write(index+4,0,short_id,formal_style)
|
|
worksheet.write(index+4,0,short_id,formal_style)
|
|
|
- print("ping success", platform)
|
|
|
|
|
if platform == "大数据平台":
|
|
if platform == "大数据平台":
|
|
|
try:
|
|
try:
|
|
|
worksheet.write(index+4,1,deviceId,formal_style)
|
|
worksheet.write(index+4,1,deviceId,formal_style)
|
|
@@ -1359,13 +1350,11 @@ class CBDThread(QtCore.QThread):
|
|
|
|
|
|
|
|
data_status = self.cbd_alerm.find({"equip_id": deviceId, "alarm_time": {"$gte":self.start_time ,"$lte":self.end_time}}).sort([('alarm_time', pymongo.DESCENDING)])
|
|
data_status = self.cbd_alerm.find({"equip_id": deviceId, "alarm_time": {"$gte":self.start_time ,"$lte":self.end_time}}).sort([('alarm_time', pymongo.DESCENDING)])
|
|
|
data_cursor = self.cbd_collection.find({"device_id":d_id,'addtime': {"$gte":self.start_time ,"$lte":self.end_time}}).sort([('addtime', pymongo.DESCENDING)])
|
|
data_cursor = self.cbd_collection.find({"device_id":d_id,'addtime': {"$gte":self.start_time ,"$lte":self.end_time}}).sort([('addtime', pymongo.DESCENDING)])
|
|
|
- data_temps = self.cbd_collection.find({"device_id":d_id,'addtime': {"$gte":self.end_time ,"$lte":self.end_time + 3600 * 24}}).sort([('addtime', pymongo.DESCENDING)])
|
|
|
|
|
|
|
+ data_temps = self.cbd_collection.find({"device_id":d_id,'addtime': {"$gte":self.start_time - 3600 * 24 ,"$lte":self.start_time}}).sort([('addtime', pymongo.DESCENDING)])
|
|
|
data_counts = data_cursor.count()
|
|
data_counts = data_cursor.count()
|
|
|
# 配置
|
|
# 配置
|
|
|
de = self.device_collection.find_one({"device_id":deviceId})
|
|
de = self.device_collection.find_one({"device_id":deviceId})
|
|
|
- print(de, "__________1_________")
|
|
|
|
|
device_config = self.device_config.find_one({"d_id":de.get("id")})
|
|
device_config = self.device_config.find_one({"d_id":de.get("id")})
|
|
|
- print(device_config, "___________2__________")
|
|
|
|
|
tt = 0
|
|
tt = 0
|
|
|
if device_config:
|
|
if device_config:
|
|
|
device_config_temp = device_config.get("device_config")
|
|
device_config_temp = device_config.get("device_config")
|