|
@@ -26,6 +26,118 @@ def object_to_dict(obj,class_model):
|
|
|
_dict[field.name] = value
|
|
_dict[field.name] = value
|
|
|
return _dict
|
|
return _dict
|
|
|
|
|
|
|
|
|
|
+def timeAdd(_time,days):
|
|
|
|
|
+ a = time.mktime(time.strptime(_time,'%Y-%m-%d'))+86400*days
|
|
|
|
|
+ _time1 = time.strftime("%Y-%m-%d",time.localtime(a))
|
|
|
|
|
+ return _time1
|
|
|
|
|
+
|
|
|
|
|
+def getWage(user,start_time,end_time,percentPass):
|
|
|
|
|
+ import time
|
|
|
|
|
+ from django.db import connection
|
|
|
|
|
+ cursor = connection.cursor()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ current_begin = max(timeAdd(end_time,-30),start_time)
|
|
|
|
|
+
|
|
|
|
|
+ print(user,start_time,current_begin,end_time)
|
|
|
|
|
+
|
|
|
|
|
+ sql = " select count(1) from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s'"%(user,end_time,start_time)
|
|
|
|
|
+ cursor.execute(sql)
|
|
|
|
|
+ doc_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ print("doc_count",doc_count)
|
|
|
|
|
+ sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s' order by edittime desc limit 1200) and value like '%s' "%(user,end_time,current_begin,"T%")
|
|
|
|
|
+ cursor.execute(sql)
|
|
|
|
|
+ t_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ print("t_count",t_count)
|
|
|
|
|
+ sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s' order by edittime desc limit 1200) and value like '%s' "%(user,end_time,current_begin,"R%")
|
|
|
|
|
+ cursor.execute(sql)
|
|
|
|
|
+ r_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ print("r_count",r_count)
|
|
|
|
|
+ sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s') and value like '%s' "%(user,end_time,current_begin,"T%")
|
|
|
|
|
+ cursor.execute(sql)
|
|
|
|
|
+ all_t_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ print("all_t_count",all_t_count)
|
|
|
|
|
+ sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s') and value like '%s' "%(user,end_time,current_begin,"R%")
|
|
|
|
|
+ cursor.execute(sql)
|
|
|
|
|
+ all_r_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ print("all_r_count",all_r_count)
|
|
|
|
|
+
|
|
|
|
|
+ sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s') and value like '%s' "%(user,current_begin,start_time,"T%")
|
|
|
|
|
+ cursor.execute(sql)
|
|
|
|
|
+ other_t_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ print("other_t_count",other_t_count)
|
|
|
|
|
+
|
|
|
|
|
+ sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s') and value like '%s' "%(user,current_begin,start_time,"R%")
|
|
|
|
|
+ cursor.execute(sql)
|
|
|
|
|
+ other_r_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ print("other_r_count",other_r_count)
|
|
|
|
|
+
|
|
|
|
|
+ wage = round(0.015*(t_count+other_t_count)+0.025*(r_count+other_r_count)+(all_t_count-t_count)*0.02+(all_r_count-r_count)*0.03,2)
|
|
|
|
|
+
|
|
|
|
|
+ # and_sql = " and 1=1 "
|
|
|
|
|
+ # if start_time is not None:
|
|
|
|
|
+ # and_sql += " and to_char(edittime,'yyyy-mm-dd')>'%s' "%start_time
|
|
|
|
|
+ #
|
|
|
|
|
+ # if end_time is not None:
|
|
|
|
|
+ # and_sql += " and to_char(edittime,'yyyy-mm-dd')<='%s'"%end_time
|
|
|
|
|
+ #
|
|
|
|
|
+ #
|
|
|
|
|
+ # sql = " select human_identifier,to_char(edittime,'yyyy-mm-dd hh24:mi:ss') from corpus_iedocument where edituser='%s' %s order by edittime asc" %(user,and_sql)
|
|
|
|
|
+ # cursor.execute(sql)
|
|
|
|
|
+ # list_docid = []
|
|
|
|
|
+ # list_t = []
|
|
|
|
|
+ # set_docid_before = set()
|
|
|
|
|
+ # _time_split = time.mktime(time.strptime("2021-05-07 14:00:00","%Y-%m-%d %H:%M:%S"))
|
|
|
|
|
+ # for row in cursor.fetchall():
|
|
|
|
|
+ # list_docid.append(row[0])
|
|
|
|
|
+ # _et = time.mktime(time.strptime(row[1],"%Y-%m-%d %H:%M:%S"))
|
|
|
|
|
+ # if _et<_time_split:
|
|
|
|
|
+ # set_docid_before.add(row[0])
|
|
|
|
|
+ # set_first = set(list_docid[:1200])
|
|
|
|
|
+ # sql = " select document_id,value from brat_bratannotation where document_id in(select human_identifier from corpus_iedocument where edituser='%s' %s) "%(user,and_sql)
|
|
|
|
|
+ # cursor.execute(sql)
|
|
|
|
|
+ # eleCount = 0
|
|
|
|
|
+ # relCount = 0
|
|
|
|
|
+ # wage = 0
|
|
|
|
|
+ #
|
|
|
|
|
+ # for document_id,value in cursor.fetchall():
|
|
|
|
|
+ # if document_id in set_first:
|
|
|
|
|
+ # if document_id in set_docid_before:
|
|
|
|
|
+ # if len(value.strip())>0:
|
|
|
|
|
+ # if value[0]=="T":
|
|
|
|
|
+ # eleCount += 1
|
|
|
|
|
+ # wage += 0.03
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # relCount += 1
|
|
|
|
|
+ # wage += 0.05
|
|
|
|
|
+ #
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # if len(value.strip())>0:
|
|
|
|
|
+ # if value[0]=="T":
|
|
|
|
|
+ # eleCount += 1
|
|
|
|
|
+ # wage += 0.015
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # relCount += 1
|
|
|
|
|
+ # wage += 0.025
|
|
|
|
|
+ #
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # if document_id in set_docid_before:
|
|
|
|
|
+ # if len(value.strip())>0:
|
|
|
|
|
+ # if value[0]=="T":
|
|
|
|
|
+ # eleCount += 1
|
|
|
|
|
+ # wage += 0.04
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # relCount += 1
|
|
|
|
|
+ # wage += 0.06
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # if len(value.strip())>0:
|
|
|
|
|
+ # if value[0]=="T":
|
|
|
|
|
+ # eleCount += 1
|
|
|
|
|
+ # wage += 0.02
|
|
|
|
|
+ # else:
|
|
|
|
|
+ # relCount += 1
|
|
|
|
|
+ # wage += 0.03
|
|
|
|
|
+ return {"docCount":doc_count,"eleCount":other_t_count+all_t_count,"relCount":other_r_count+all_r_count,"wage":round(wage*percentPass,2)}
|
|
|
|
|
|
|
|
class Settlement():
|
|
class Settlement():
|
|
|
|
|
|
|
@@ -53,23 +165,34 @@ class Settlement():
|
|
|
else:
|
|
else:
|
|
|
time_begin = "2020-08-01"
|
|
time_begin = "2020-08-01"
|
|
|
|
|
|
|
|
- sql = " select count(1) from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s'"%(_user,time_end,time_begin)
|
|
|
|
|
- cursor.execute(sql)
|
|
|
|
|
- doc_count = cursor.fetchall()[0][0]
|
|
|
|
|
- sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s' order by edittime desc limit 1200) and value like '%s' "%(_user,time_end,time_begin,"T%")
|
|
|
|
|
- cursor.execute(sql)
|
|
|
|
|
- t_count = cursor.fetchall()[0][0]
|
|
|
|
|
- sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s' order by edittime desc limit 1200) and value like '%s' "%(_user,time_end,time_begin,"R%")
|
|
|
|
|
- cursor.execute(sql)
|
|
|
|
|
- r_count = cursor.fetchall()[0][0]
|
|
|
|
|
- sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s') and value like '%s' "%(_user,time_end,time_begin,"T%")
|
|
|
|
|
- cursor.execute(sql)
|
|
|
|
|
- all_t_count = cursor.fetchall()[0][0]
|
|
|
|
|
- sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s') and value like '%s' "%(_user,time_end,time_begin,"R%")
|
|
|
|
|
- cursor.execute(sql)
|
|
|
|
|
- all_r_count = cursor.fetchall()[0][0]
|
|
|
|
|
- wage = round(0.03*t_count+0.05*r_count+(all_t_count-t_count)*0.04+(all_r_count-r_count)*0.06,2)
|
|
|
|
|
- print(doc_count,t_count,r_count,wage)
|
|
|
|
|
|
|
+ print(_user,time_begin,time_end)
|
|
|
|
|
+ dict_wage = getWage(_user,time_begin,time_end,0.99)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ # sql = " select count(1) from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s'"%(_user,time_end,time_begin)
|
|
|
|
|
+ # cursor.execute(sql)
|
|
|
|
|
+ # doc_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ # sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s' order by edittime desc limit 1200) and value like '%s' "%(_user,time_end,time_begin,"T%")
|
|
|
|
|
+ # cursor.execute(sql)
|
|
|
|
|
+ # t_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ # sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s' order by edittime desc limit 1200) and value like '%s' "%(_user,time_end,time_begin,"R%")
|
|
|
|
|
+ # cursor.execute(sql)
|
|
|
|
|
+ # r_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ # sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s') and value like '%s' "%(_user,time_end,time_begin,"T%")
|
|
|
|
|
+ # cursor.execute(sql)
|
|
|
|
|
+ # all_t_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ # sql = " select count(1) from brat_bratannotation where document_id in (select human_identifier from corpus_iedocument where edituser='%s' and to_char(edittime,'yyyy-mm-dd')<='%s' and to_char(edittime,'yyyy-mm-dd')>'%s') and value like '%s' "%(_user,time_end,time_begin,"R%")
|
|
|
|
|
+ # cursor.execute(sql)
|
|
|
|
|
+ # all_r_count = cursor.fetchall()[0][0]
|
|
|
|
|
+ # wage = round(0.015*t_count+0.025*r_count+(all_t_count-t_count)*0.02+(all_r_count-r_count)*0.03,2)
|
|
|
|
|
+ doc_count = dict_wage["docCount"]
|
|
|
|
|
+ t_count = dict_wage['eleCount']
|
|
|
|
|
+ r_count = dict_wage["relCount"]
|
|
|
|
|
+ wage = dict_wage["wage"]
|
|
|
|
|
+ all_t_count = t_count
|
|
|
|
|
+ all_r_count = r_count
|
|
|
|
|
+
|
|
|
|
|
+ print(_user,doc_count,t_count,r_count,wage)
|
|
|
payrolls = Payroll.objects.filter(Q(user=_user)& Q(begin_time=time_begin) & Q(end_time=time_end))
|
|
payrolls = Payroll.objects.filter(Q(user=_user)& Q(begin_time=time_begin) & Q(end_time=time_end))
|
|
|
if len(payrolls)==0:
|
|
if len(payrolls)==0:
|
|
|
_payroll = Payroll.objects.create(**{"user":_user,"doc_count":doc_count,"begin_time":time_begin,"end_time":time_end,"t_count":all_t_count,"r_count":all_r_count,"wage":wage})
|
|
_payroll = Payroll.objects.create(**{"user":_user,"doc_count":doc_count,"begin_time":time_begin,"end_time":time_end,"t_count":all_t_count,"r_count":all_r_count,"wage":wage})
|
|
@@ -291,9 +414,10 @@ def makeCheck():
|
|
|
if __name__=="__main__":
|
|
if __name__=="__main__":
|
|
|
settle = Settlement()
|
|
settle = Settlement()
|
|
|
# settle.makeMigrate("test","2020-08-01","2020-08-31")
|
|
# settle.makeMigrate("test","2020-08-01","2020-08-31")
|
|
|
- settle_end = "2021-02-25"
|
|
|
|
|
- # settle.makePayroll(["test1","test7","test17","test2","test10","test11","test12","test20","test3","test19","test22"],"2020-08-01",settle_end)
|
|
|
|
|
|
|
+ settle_end = "2021-07-25"
|
|
|
|
|
+ settle.makePayroll(["test2","test9","test10","test11","test12","test16","test20","test25","test19","test22","test1","test7","test8","test17","test21","test26"],"2020-08-01",settle_end)
|
|
|
settle.exportPayroll(begin_time=None,end_time=settle_end)
|
|
settle.exportPayroll(begin_time=None,end_time=settle_end)
|
|
|
|
|
+
|
|
|
# settle.createUser_batch(batch_size=102)
|
|
# settle.createUser_batch(batch_size=102)
|
|
|
# settle.exportLabels()
|
|
# settle.exportLabels()
|
|
|
# settle.filter()
|
|
# settle.filter()
|