|
|
|
@ -346,23 +346,64 @@ client_id: 1c39cb24-07f8-11ed-abd4-f47b094925e1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
dic = {"bar_code":"789654","by_user_date":"","by_user_id":"","by_user_name":"","cas_number":"106-24-7","cell_position_code":"","client_code":"","client_id":"1c39cb24-07f8-11ed-abd4-f47b094925e1","customer_id":"","distributor":"","english_name":"","expiration_date":"","flow_position_code":"","inventory_warning_value":10,"is_add":0,"is_supervise":0,"is_weigh":0,"manufacturer":"国药","medicament_id":"12dec478-186b-11ed-b2c3-9adf5e32e162","name":"乙酸酐","net_weight":"","net_weight_unit":"","place":"","price":"0","production_date":"2022-03-01","purity":"AR","put_in_date":"2022-08-10 13:12:47","put_in_user_id":"4cea74ee-0d8b-11ed-943e-f47b094925e1","put_in_user_name":"12334","remain":"749","remark1":"","remark10":"","remark11":"","remark12":"","remark13":"","remark14":"","remark15":"","remark16":"","remark17":"","remark18":"","remark19":"","remark2":"","remark20":"","remark21":"","remark22":"","remark23":"","remark24":"","remark25":"","remark26":"","remark27":"","remark28":"","remark29":"","remark3":"危化品","remark30":"","remark4":"","remark5":"","remark6":"瓶","remark7":"","remark8":"","remark9":"烷基汞","shelf_life":0,"shelf_life_warning_value":10,"speci":"500","total":"","tp":"","use_days_warning_value":10,"user_auditing":"","variety_id":"f37c5780-1869-11ed-8ac1-9adf5e32e162","weigh_flag":0,"num":12}
|
|
|
|
|
|
|
|
|
|
# for k,v in dic.items():
|
|
|
|
|
# if v == "":
|
|
|
|
|
# dic.pop(k)
|
|
|
|
|
# print(dic)
|
|
|
|
|
data_list = [{"t1":0, "t2":2, "t3": 1}, {"t1":None, "t2":1, "t3": 1}]
|
|
|
|
|
new_data_list = []
|
|
|
|
|
for i in data_list:
|
|
|
|
|
new_dic = {}
|
|
|
|
|
for k, v in i.items():
|
|
|
|
|
if not v:
|
|
|
|
|
v = 0
|
|
|
|
|
new_dic[k] = v
|
|
|
|
|
new_li = list(new_dic.values())
|
|
|
|
|
new_dic.update(**{
|
|
|
|
|
"t4": int(new_li[1]) - int(new_li[2])
|
|
|
|
|
})
|
|
|
|
|
new_data_list.append(new_dic)
|
|
|
|
|
print(new_data_list)
|
|
|
|
|
# dic = {"bar_code":"789654","by_user_date":"","by_user_id":"","by_user_name":"","cas_number":"106-24-7","cell_position_code":"","client_code":"","client_id":"1c39cb24-07f8-11ed-abd4-f47b094925e1","customer_id":"","distributor":"","english_name":"","expiration_date":"","flow_position_code":"","inventory_warning_value":10,"is_add":0,"is_supervise":0,"is_weigh":0,"manufacturer":"国药","medicament_id":"12dec478-186b-11ed-b2c3-9adf5e32e162","name":"乙酸酐","net_weight":"","net_weight_unit":"","place":"","price":"0","production_date":"2022-03-01","purity":"AR","put_in_date":"2022-08-10 13:12:47","put_in_user_id":"4cea74ee-0d8b-11ed-943e-f47b094925e1","put_in_user_name":"12334","remain":"749","remark1":"","remark10":"","remark11":"","remark12":"","remark13":"","remark14":"","remark15":"","remark16":"","remark17":"","remark18":"","remark19":"","remark2":"","remark20":"","remark21":"","remark22":"","remark23":"","remark24":"","remark25":"","remark26":"","remark27":"","remark28":"","remark29":"","remark3":"危化品","remark30":"","remark4":"","remark5":"","remark6":"瓶","remark7":"","remark8":"","remark9":"烷基汞","shelf_life":0,"shelf_life_warning_value":10,"speci":"500","total":"","tp":"","use_days_warning_value":10,"user_auditing":"","variety_id":"f37c5780-1869-11ed-8ac1-9adf5e32e162","weigh_flag":0,"num":12}
|
|
|
|
|
|
|
|
|
|
# # for k,v in dic.items():
|
|
|
|
|
# # if v == "":
|
|
|
|
|
# # dic.pop(k)
|
|
|
|
|
# # print(dic)
|
|
|
|
|
# data_list = [{"t1":0, "t2":2, "t3": 1}, {"t1":None, "t2":1, "t3": 1}]
|
|
|
|
|
# new_data_list = []
|
|
|
|
|
# for i in data_list:
|
|
|
|
|
# new_dic = {}
|
|
|
|
|
# for k, v in i.items():
|
|
|
|
|
# if not v:
|
|
|
|
|
# v = 0
|
|
|
|
|
# new_dic[k] = v
|
|
|
|
|
# new_li = list(new_dic.values())
|
|
|
|
|
# new_dic.update(**{
|
|
|
|
|
# "t4": int(new_li[1]) - int(new_li[2])
|
|
|
|
|
# })
|
|
|
|
|
# new_data_list.append(new_dic)
|
|
|
|
|
# print(new_data_list)
|
|
|
|
|
|
|
|
|
|
a = 0
|
|
|
|
|
|
|
|
|
|
class BaseStatus(object):
|
|
|
|
|
|
|
|
|
|
status = None
|
|
|
|
|
def __init__(self, status=0) -> None:
|
|
|
|
|
self.status = status
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import threading
|
|
|
|
|
class WriteTxt(object):
|
|
|
|
|
|
|
|
|
|
status_obj = None
|
|
|
|
|
|
|
|
|
|
def __init__(self) -> None:
|
|
|
|
|
self.status_obj = BaseStatus()
|
|
|
|
|
|
|
|
|
|
def write1(self):
|
|
|
|
|
self.status_obj.status = 1
|
|
|
|
|
fileName = 'note.txt'
|
|
|
|
|
for i in range(100):
|
|
|
|
|
with open(fileName, 'a', encoding='utf-8')as file:
|
|
|
|
|
file.write(str(self.status_obj.status)+"\n")
|
|
|
|
|
|
|
|
|
|
def write2(self):
|
|
|
|
|
self.status_obj.status = 2
|
|
|
|
|
fileName = 'note1.txt'
|
|
|
|
|
for i in range(100):
|
|
|
|
|
with open(fileName, 'a', encoding='utf-8')as file:
|
|
|
|
|
file.write(str(self.status_obj.status) + "\n")
|
|
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
|
p = threading.Thread(target=self.write1)
|
|
|
|
|
p.start()
|
|
|
|
|
p1 = threading.Thread(target=self.write2)
|
|
|
|
|
p1.start()
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
aaa = WriteTxt()
|
|
|
|
|
aaa.start()
|