3 Komitmen 08c4ce05bc ... 9a297811dd

Pembuat SHA1 Pesan Tanggal
  997842115 9a297811dd batch_task 8 jam lalu
  997842115 1212af48d0 Merge branch 'master' of http://47.101.198.30:3000/xiaopzhang/celery 1 hari lalu
  997842115 5e4f2a65a5 fix 1 hari lalu
2 mengubah file dengan 119 tambahan dan 4 penghapusan
  1. 2 2
      tasks.py
  2. 117 2
      tasks2.py

+ 2 - 2
tasks.py

@@ -40,8 +40,8 @@ model = FlagModel('/mnt/d/Develop/bge/test2_encoder_only_base_bge-large-zh-v1.5'
 cuoshi_model = FlagModel('cuoshi_encoder_only_base_bge-large-zh-v1.5/cuoshi_encoder_only_base_bge-large-zh-v1.5')
 from sentence_transformers import CrossEncoder
 azce = CrossEncoder('/mnt/d/Develop/az/models/reranker-chinese-macbert-large-gooaq-bce-4/final')
-ce = CrossEncoder('/mnt/d/Develop/celery/final/final')
-cuoshi_ce = CrossEncoder('cuoshi_reranker/cuoshi_reranker/final')
+ce = CrossEncoder('/mnt/d/Develop/celery/final')
+cuoshi_ce = CrossEncoder('cuoshi_reranker/final')
 with open("hunningtu_rule", "r") as f:
     content = f.read()
 obj = json.loads(content)

+ 117 - 2
tasks2.py

@@ -1,15 +1,130 @@
 import time
+from bson.objectid import ObjectId
 from celery_app2 import celery_app2
 from pymongo import MongoClient
+import requests
+import json
 uri="mongodb://owner:Pheecian1@47.101.198.30:27017/baojia"
 mongoclient=MongoClient(uri)
 db = mongoclient['baojia']
 dbcollection=db['Dwgc']
+qdcollection=db['qdxm']
+biaocollection=db['jingjibiao']
+djcollection=db['Djcs']
 from redis.exceptions import TimeoutError
 @celery_app2.task(autoretry_for=(TimeoutError,))
 def process_data(data:dict)-> dict:
     print(data['name'])
     print(data['detail'])##dwgcbh
-    result = dbcollection.update_one({'biao_id': data['name'], 'Dwgcbh': data['detail']}, {'$set': {'status': '开始'}})
-    print(result)
+    biao = biaocollection.find_one({'_id': ObjectId(data['name'])})
+    Dxgcxx = biao['Dxgcxx']
+    label=""
+    city = biao['city']
+    for dxgc in Dxgcxx:
+        Dwgc = dxgc['Dwgc']
+        for child in Dwgc:
+            if child['Dwgcbh'] == data['detail']:
+                label = child['Dwgcmc']
+    qd = qdcollection.find({'biao_id': data['name'], 'Dwgcbh': data['detail']})
+    qds = {}
+    qds2 = {}
+    djs = {}
+    djs2 = {}
+    for entry in qd:
+        qds[entry['清单编码']]= 0
+        qds2[entry['清单编码']]= 0
+    dj = djcollection.find({'biao_id': data['name'], 'Dwgcbh': data['detail']})
+    for entry in dj:
+        djs[entry['清单编码']]= 0
+        djs2[entry['清单编码']]= 0
+    result = dbcollection.update_one({'biao_id': data['name'], 'Dwgcbh': data['detail']},
+            {'$set': {'status': '开始', 'qd_detail': qds, 'dj_detail': djs}})
+    maxN = 0
+    for entry in qds:
+        maxN = maxN + 1
+        url = 'http://0.0.0.0:8000/submit/'
+        qd_ = qdcollection.find_one({'biao_id': data['name'], 'Dwgcbh': data['detail'], '清单编码': entry})
+        response = requests.post(url, json={
+          'bianma': entry,
+          'mc': qd_['名称'],
+          'tz': qd_['项目特征'],
+          'dw': qd_['单位'],
+          'sl': qd_['数量'],
+          'n': maxN,
+          'label': label,
+          'name': data['name'],
+          'bh': data['detail'],
+          'city': city
+            })
+        text = response.text
+        id_ = json.loads(text)['id']
+        elapse = 0
+        result = None
+        while elapse < 300:
+            time.sleep(10)
+            elapse = elapse + 10
+            response = requests.get('http://0.0.0.0:8000/check/'+id_)
+            text = json.loads(response.text)
+            result = text['result']
+            if text['status'] in ['SUCCESS', 'FAILURE']:
+                break
+        if result is not None and text['status'] == 'SUCCESS':
+            qds2[entry]=1
+            result['result'][0]['biao_id'] = qd_['biao_id']
+            result['result'][0]['Dwgcbh'] = qd_['Dwgcbh']
+            result['result'][0]['bt'] = qd_['bt']
+            response = requests.post('http://www.xiaozaotongxue.com/api/save2/', json={
+              'name': json.dumps(result['result']),
+            })
+            print(response.text)
+        else:
+            qds2[entry]=-1
+        result = dbcollection.update_one({'biao_id': data['name'], 'Dwgcbh': data['detail']},
+            {'$set': {'qd_detail': qds2}})
+
+        break
+    maxN = 0
+    for entry in djs:
+        maxN = maxN + 1
+        url = 'http://0.0.0.0:8000/submit/'
+        qd_ = djcollection.find_one({'biao_id': data['name'], 'Dwgcbh': data['detail'], '清单编码': entry})
+        response = requests.post(url, json={
+          'bianma': entry,
+          'mc': qd_['名称'],
+          'tz': qd_['项目特征'],
+          'dw': qd_['单位'],
+          'sl': qd_['数量'],
+          'n': maxN,
+          'label': label,
+          'name': data['name'],
+          'bh': data['detail'],
+          'city' : city
+            })
+        text = response.text
+        id_ = json.loads(text)['id']
+        elapse = 0
+        result = None
+        while elapse < 300:
+            time.sleep(10)
+            elapse = elapse + 10
+            response = requests.get('http://0.0.0.0:8000/check/'+id_)
+            text = json.loads(response.text)
+            result = text['result']
+            if text['status'] in ['SUCCESS', 'FAILURE']:
+                break
+        if result is not None and text['status'] == 'SUCCESS':
+            djs2[entry]=1
+            result['result'][0]['biao_id'] = qd_['biao_id']
+            result['result'][0]['Dwgcbh'] = qd_['Dwgcbh']
+            response = requests.post('http://www.xiaozaotongxue.com/api/savedjcs2/', json={
+              'name': json.dumps(result['result']),
+            })
+            print(response.text)
+        else:
+            djs2[entry]=-1
+        result = dbcollection.update_one({'biao_id': data['name'], 'Dwgcbh': data['detail']},
+            {'$set': {'dj_detail': djs2}})
+
+        break
+
     return {"result": []}