liumiaomiao преди 1 седмица
родител
ревизия
90ae064a64
променени са 4 файла, в които са добавени 139 реда и са изтрити 104 реда
  1. 45 12
      app.py
  2. 40 55
      tables/fields/bidamount.py
  3. 21 7
      tables/fields/buyer.py
  4. 33 30
      tables/fields/s_winner.py

+ 45 - 12
app.py

@@ -225,7 +225,7 @@ if __name__ == '__main__':
     "dataging" : int(0),
     # "bidopentime":int(1798739414),
     # "publishtime" : int(1751937052),
-    "subtype" : "成交",
+    "subtype" : "中标",
     "purchasinglist" : [
         {
             "score" : 0.8275, 
@@ -258,11 +258,11 @@ if __name__ == '__main__':
     "basicClass" : "货物", 
     "rate" : "97%", 
     "autoid" : int(249351001), 
-    # "bidamount" : 1034.1111,
+    "bidamount" : 10000,
     "bidway" : "电子投标", 
-    "budget" : 30.0,
+    "budget" : 30000.0,
     "supervisorrate": 0.03,
-    # "buyer" : "哈密市伊州区花园乡人民政府",
+    "buyer" : "玖宸(北京)科技有限公司",
     "buyerclass" : "医疗", 
     "dataprocess" : int(8), 
     "description" : "二连浩特市人民医院在政采商城电子卖场完成协议供货直购采购,采购结果确认如下:一、项目概述采购编号:ELHTSZFCG-DD-2023-407774采购单位:二连浩特市人民医院所属区域:二连浩特市本级预算金额(元):15,440.00采购人及", 
@@ -276,7 +276,7 @@ if __name__ == '__main__':
     "projectname" : "二连浩特市人民医院台式计算机(等)直接订购", 
     "purchasing_tag" : "台式计算机,计算机,摄像头,液晶显示器,DR,M9,液晶,4G", 
     "s_subscopeclass" : "信息技术_其他,行政办公_通用办公设备", 
-    "s_topscopeclass" : "行政办公,信息技术", 
+    "s_topscopeclass" : "行政办公,信息技术,建筑工程",
     "s_winner" : "玖宸(北京)科技有限公司",
     "subscopeclass" : [
         "信息技术_其他", 
@@ -557,21 +557,54 @@ if __name__ == '__main__':
     # #     }
     # })
     result = check(row, rules={
-        "s_winner": {
+         "bidamount" : {
+            "0101" : {
+                "name" : "预算/中标金额,不在[0.7,1.3]",
+                "parent_name" : "金额错误",
+                "parent_code" : "01"
+            },
+            "0102" : {
+                "name" : "过大过小,不在[100,10亿]",
+                "parent_name" : "金额错误",
+                "parent_code" : "01"
+            },
+            "0103" : {
+                "name" : "中标金额小数点位数超过4位",
+                "parent_name" : "金额错误",
+                "parent_code" : "01",
+                "checkFn" : "01"
+            },
+            "0104" : {
+                "name" : "中标金额存在费率,折扣率",
+                "parent_name" : "金额错误",
+                "parent_code" : "01"
+            },
+            "0301" : {
+                "name" : "中标金额<0",
+                "parent_name" : "金额错误",
+                "parent_code" : "01"
+            },
+            "0601" : {
+                "name" : "中标金额 > 预算金额",
+                "parent_name" : "金额错误",
+                "parent_code" : "01"
+            }
+        },
+        "buyer": {
             "0103": {
                 "name": "包含叠词,异常词汇,特殊词汇",
                 "parent_name": "名称错误",
                 "parent_code": "01"
             },
-            "0104": {
-                "name": "中标单位包含采购单位",
-                "parent_name": "名称错误",
-                "parent_code": "01"
-            },
             "0301": {
-                "name": "中标单位名称长度<3",
+                "name": "采购单位名称长度<3",
                 "parent_name": "名称长度异常错误",
                 "parent_code": "03"
+            },
+            "0105": {
+                "name": "采购单位与中标单位一致",
+                "parent_name": "名称错误",
+                "parent_code": "01"
             }
         },
         # "entname": {

+ 40 - 55
tables/fields/bidamount.py

@@ -11,7 +11,7 @@ class BidAmountChecker(object):
     def __init__(self):
         self.errors_tables = {
             "0101": {
-                "name": "预算/中标金额不在:[0.7,1.3]",
+                "name": "建筑行业,预算/中标金额不在:[0.7,1.3]",
                 "parent_name": "金额错误",
                 "parent_code": "01",
                 "checkFn": self.check0101
@@ -45,73 +45,72 @@ class BidAmountChecker(object):
                 "parent_name": "金额错误",
                 "parent_code": "01",
                 "checkFn": self.check0601
-            },
-            "0701": {
-                "name": "建筑行业中标金额不在预算的 70%-130%范围",
-                "parent_name": "金额错误",
-                "parent_code": "01",
-                "checkFn": self.check0701
             }
         }
 
     @staticmethod
-    def check0101(budget: float, bidamount: float) -> bool:
+    def check0101(budget: float, bidamount: float,s_topscopeclass:str,subtype:str) -> bool:
         """
         预算和中标金额的比例
         :param budget:
         :param amount:
         :return:返回true 代表异常
         """
-        if budget and bidamount:
-            if 0.7 < budget / bidamount < 1.3:
-                return False
-            else:
-                return True
-        else:
-            # 两者中有一方为空不判断,---0,None,空字符,空字符串都是空
-            return False
+        if subtype in ("中标","成交","合同","验收"):
+            if "建筑工程" in s_topscopeclass or "建筑" in s_topscopeclass:
+                if budget and bidamount:
+                    if 0.7 < budget / bidamount < 1.3:
+                        return False
+                    else:
+                        return True
+                else:
+                    # 两者中有一方为空不判断,---0,None,空字符,空字符串都是空
+                    return False
 
     @staticmethod
-    def check0102(bidamount: float) -> bool:
+    def check0102(bidamount: float,subtype:str) -> bool:
         """
         中标金额过大过小[100,10亿]
         :param price:
         :return: 返回true 代表异常
         """
-        if 100 < bidamount < 1000000000:
-            return False
-        return True
+        if subtype in ("中标", "成交", "合同", "验收"):
+            if 100 < bidamount < 1000000000:
+                return False
+            return True
 
     @staticmethod
-    def check0103(bidamount: float) -> bool:
+    def check0103(bidamount: float,subtype:str) -> bool:
         """
         中标金额小数点位数超过4位,视为异常
         :param price:
         :return: 返回true 代表异常
         """
-        # 将数字转换为字符串
-        number_str = str(bidamount)
-        # 检查是否有小数点
-        if '.' in number_str:
-            # 分割整数部分和小数部分
-            integer_part, decimal_part = number_str.split('.')
-            # 返回小数部分的长度
-            length= len(decimal_part)
-        else:
-            length = 0
-        if length > 4 :
-            return True
+        if subtype in ("中标", "成交", "合同", "验收"):
+            # 将数字转换为字符串
+            number_str = str(bidamount)
+            # 检查是否有小数点
+            if '.' in number_str:
+                # 分割整数部分和小数部分
+                integer_part, decimal_part = number_str.split('.')
+                # 返回小数部分的长度
+                length= len(decimal_part)
+            else:
+                length = 0
+            if length > 4:
+                return True
 
     @staticmethod
-    def check0104(supervisorrate:float) -> bool:
+    def check0104(supervisorrate:float,subtype:str) -> bool:
         """
         中标金额存在费率,折扣率
         :param price:
         :return: 返回true 代表异常
         """
-        if supervisorrate==0 :
-            return False
-        return True
+        if subtype in ("中标", "成交", "合同", "验收"):
+            if supervisorrate==0:
+                return False
+            return True
 
     @staticmethod
     def check0301(bidamount: float) -> bool :
@@ -124,27 +123,13 @@ class BidAmountChecker(object):
         return False
 
     @staticmethod
-    def check0601(bidamount: float,budget:float) -> bool:
+    def check0601(bidamount: float,budget:float,subtype:str) -> 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:
+        if subtype in ("中标", "成交", "合同", "验收"):
+            if bidamount > budget:
                 return True
-            # 独立判断2:高于130%
-            if bidamount > budget * 1.3:
-                return True
-        return False
+            return False
 

+ 21 - 7
tables/fields/buyer.py

@@ -55,6 +55,12 @@ class BuyerChecker(object):
                 "parent_name": "名称长度异常错误",
                 "parent_code": "03",
                 "checkFn": self.check0301
+            },
+            "0105": {
+                "name": "采购单位与中标单位一致",
+                "parent_name": "名称错误",
+                "parent_code": "01",
+                "checkFn": self.check0105
             }
         }
         #
@@ -313,20 +319,28 @@ class BuyerChecker(object):
                 if p2.search(buyer):
                     return True
         return False
-        # 如果采购单位类型in ("学校","教育","卫健委","医疗","政府办","政务中心"),则采购单位名称中一般都含有地名
+
+    def check0301(self, buyer: str):
+        """
+        return  True 代表异常
+        """
+        if len(buyer) < 3:
+            return True
+        return False
 
     def check0104(self, buyer: str, buyerclass: str):
+        """
+        #如果采购单位类型in ("学校","教育","卫健委","医疗","政府办","政务中心"),则采购单位名称中一般都含有地名
+        """
         if buyerclass in ("学校", "教育", "卫健委", "医疗", "政府办", "政务中心"):
             province, city, district = get_city_info(buyer)
             if province == None and city == None and district == None:
                 return True
         return False
 
-    def check0301(self, buyer: str):
-        """
-        return  True 代表异常
-        """
-        if len(buyer) < 3:
-            return True
+    def check0105(self, buyer: str, s_winner: str):
+        if buyer and s_winner:
+            if buyer == s_winner:
+                return True
         return False
 

+ 33 - 30
tables/fields/s_winner.py

@@ -277,44 +277,47 @@ class WinnerChecker(object):
                             return False
         return True
 
-    def check0103(self,s_winner:str):
-        #中标单位名称以异常词开始
-        with open(abnormal_config["table_field_config"]["path1"], "r") as f:
-            reads = csv.reader(f)
-            for n in  reads:
-                p1 = re.compile("^"+n[0])
-                if p1.match(s_winner):
-                    return True
+    def check0103(self,s_winner:str,subtype:str):
+        if subtype in ("中标", "成交", "合同", "验收"):
+            #中标单位名称以异常词开始
+            with open(abnormal_config["table_field_config"]["path1"], "r") as f:
+                reads = csv.reader(f)
+                for n in  reads:
+                    p1 = re.compile("^"+n[0])
+                    if p1.match(s_winner):
+                        return True
 
-        # 中标单位名称包含异常词
-        with open(abnormal_config["table_field_config"]["path2"], "r") as f:
-            reads = csv.reader(f)
-            for n in  reads:
-                if n[0] in s_winner:
-                    return True
-        # 中标单位名称以异常词结尾
-        with open(abnormal_config["table_field_config"]["path3"], "r") as f:
-            reads = csv.reader(f)
-            for w in reads:
-                if re.search(f"{w[0]}$", s_winner):
-                    return True
-        return False
-    def check0301(self,s_winner:str):
+            # 中标单位名称包含异常词
+            with open(abnormal_config["table_field_config"]["path2"], "r") as f:
+                reads = csv.reader(f)
+                for n in  reads:
+                    if n[0] in s_winner:
+                        return True
+            # 中标单位名称以异常词结尾
+            with open(abnormal_config["table_field_config"]["path3"], "r") as f:
+                reads = csv.reader(f)
+                for w in reads:
+                    if re.search(f"{w[0]}$", s_winner):
+                        return True
+            return False
+    def check0301(self,s_winner:str,subtype:str):
         """
         中标单位长度异常检测
         :param obj:代表一个item
         :return:返回true 代表异常
         """
-        if len(s_winner) < 3:
-            return True
-        return False
-    def check0104(self,s_winner:str,buyer:str):
+        if subtype in ("中标", "成交", "合同", "验收"):
+            if len(s_winner) < 3:
+                return True
+            return False
+    def check0104(self,s_winner:str,buyer:str,subtype:str):
         """
         中标单位包含采购单位
         :param obj:代表一个item
         :return:返回true 代表异常
         """
-        if buyer:
-            if buyer in s_winner:
-                return True
-        return False
+        if subtype in ("中标", "成交", "合同", "验收"):
+            if buyer and s_winner:
+                if buyer in s_winner:
+                    return True
+            return False