jialuyao 1 hete
szülő
commit
073559c7c6
2 módosított fájl, 75 hozzáadás és 14 törlés
  1. 36 13
      app.py
  2. 39 1
      tables/fields/bidamount.py

+ 36 - 13
app.py

@@ -3,6 +3,7 @@ import inspect
 import csv
 from pymongo import MongoClient
 from docs.config import abnormal_config
+from tables.fields import bidamount
 from tables.fields.winner import WinnerChecker
 from tables.fields.buyer import BuyerChecker
 from tables.fields.bidamount import BidAmountChecker
@@ -211,7 +212,7 @@ def check(obj: any, rules) -> any:
 
 if __name__ == '__main__':
     row={
-    "comeintime" : int(1698739748), 
+    "comeintime" : int(1698739748),
     "area" : "内蒙古",
     "purchasingsource" : "[{\"start\": 13, \"verify\": \"确定\", \"direction\": \"h\", \"type\": \"识别\", \"header\": {\"itemname\": \"产品名称\", \"model\": \"技术规格\", \"number\": \"数量\", \"unitprice\": \"单价(元)\", \"totalprice\": \"金额(元)\"}, \"file_name\": \"公告\"}]",
     "toptype" : "结果",
@@ -258,9 +259,9 @@ if __name__ == '__main__':
     "basicClass" : "货物", 
     "rate" : "97%", 
     "autoid" : int(249351001), 
-    # "bidamount" : 1034.1111,
+    "bidamount" :5000,
     "bidway" : "电子投标", 
-    # "budget" : None,
+    "budget" : 800,
     "supervisorrate": 0.03,
     "buyer" : "哈密市伊州区花园乡人民政府",
     "buyerclass" : "医疗", 
@@ -276,7 +277,7 @@ if __name__ == '__main__':
     "projectname" : "二连浩特市人民医院台式计算机(等)直接订购", 
     "purchasing_tag" : "台式计算机,计算机,摄像头,液晶显示器,DR,M9,液晶,4G", 
     "s_subscopeclass" : "信息技术_其他,行政办公_通用办公设备", 
-    "s_topscopeclass" : "行政办公,信息技术", 
+    "s_topscopeclass" : "行政办公,信息技术,建筑工程",
     "s_winner" : "二连浩特市智慧真彩文体办公院院",
     "subscopeclass" : [
         "信息技术_其他", 
@@ -325,6 +326,9 @@ if __name__ == '__main__':
     ],
     "pici" : int(1698740066)
 }
+    # result = BidAmountChecker.check0701(100, 800, "建筑工程")
+    # if result:
+    #     print("警告:中标金额低于预算70%!")
     # result=check(row,rules={
     #     "bidamount": {
     #         "0101": {
@@ -557,12 +561,19 @@ if __name__ == '__main__':
     # #     }
     # })
     result = check(row, rules={
-        "entname": {
-            },
-        "price": {
-        },
-        "sort": {
-        },
+        # "budget": {
+        #     "0401": {
+        #         "name": "预算金额 < 中标金额",
+        #         "parent_name": "金额错误",
+        #         "parent_code": "01"
+        #        }
+        #     },
+        # "entname": {
+        #     },
+        # "price": {
+        # },
+        # "sort": {
+        # },
         # "city": {
         #     "0302": {
         #         "name": "城市不在[3,11]个字之间",
@@ -582,7 +593,7 @@ if __name__ == '__main__':
         #                 "parent_code": "02"
         #             }
         # },
-        # "bidamount": {
+        "bidamount": {
         #             "0101": {
         #                 "name": "互相校验(预算和中标金额的比例)",
         #                 "parent_name": "金额错误",
@@ -603,7 +614,19 @@ if __name__ == '__main__':
         #                 "name": "中标金额存在费率,折扣率",
         #                 "parent_name": "金额错误",
         #                 "parent_code": "01"
-        #             }
-        #         },
+        #             },
+        #               "0601": {
+        #                   "name": "中标金额 > 预算金额",
+        #                   "parent_name": "金额错误",
+        #                   "parent_code": "01"
+        #               },
+                      "0701": {
+                          "name": "建筑行业中标金额不在预算的 70%-130%范围",
+                          "parent_name": "金额错误",
+                          "parent_code": "01"
+                      }
+
+                },
     })
     print(result)
+

+ 39 - 1
tables/fields/bidamount.py

@@ -39,6 +39,18 @@ class BidAmountChecker(object):
                 "parent_name": "金额错误",
                 "parent_code": "01",
                 "checkFn": self.check0301
+            },
+            "0601": {
+                "name": "中标金额 > 预算金额",
+                "parent_name": "金额错误",
+                "parent_code": "01",
+                "checkFn": self.check0601
+            },
+            "0701": {
+                "name": "建筑行业中标金额不在预算的 70%-130%范围",
+                "parent_name": "金额错误",
+                "parent_code": "01",
+                "checkFn": self.check0701
             }
         }
 
@@ -109,4 +121,30 @@ class BidAmountChecker(object):
         """
         if  bidamount < 0:
             return True
-        return False
+        return False
+
+    @staticmethod
+    def check0601(bidamount: float,budget:float) -> bool:
+        """
+        中标金额>预算,视为异常
+        :return: 返回true 代表异常
+        """
+        if bidamount > budget:
+            return True
+        return False
+
+    @staticmethod
+    def check0701(bidamount: float, budget: float,s_topscopeclass:str) -> bool:
+        """
+        建筑行业中标金额不在预算的 70%-130%范围,视为异常
+        :return: 返回true 代表异常
+        """
+        if s_topscopeclass in ["建筑", "建筑工程"]:
+            # 独立判断1:低于70%
+            if bidamount < budget * 0.7:
+                return True
+            # 独立判断2:高于130%
+            if bidamount > budget * 1.3:
+                return True
+        return False
+