analymethod.go 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  1. package pretreated
  2. import (
  3. "fmt"
  4. "github.com/shopspring/decimal"
  5. "jy/clear"
  6. u "jy/util"
  7. qu "qfw/util"
  8. "regexp"
  9. "strings"
  10. )
  11. /*
  12. *
  13. 全局变量,主要是一堆判断正则
  14. *
  15. */
  16. var (
  17. //key 的日期单位
  18. dateReg *regexp.Regexp = regexp.MustCompile(`[年|月|日|天]`)
  19. //清理品目中数字
  20. numclear = regexp.MustCompile("^[\\d一二三四五六七八九十.]+")
  21. num1 = regexp.MustCompile("(\\d)")
  22. //清理表格title中的不需要的内容
  23. tabletitleclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、.,.。_/((人民币万元件个公斤户))]")
  24. tabletitleclear2 = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、,。_??;;~\\-#\\\\()(){}【】\\[\\]<>《》{}〔〕]*")
  25. //清理表格中是key中包含的空格或数字等
  26. tablekeyclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n、.,.。_/]+|^[\\d一二三四五六七八九十]+[、.]*|[((【\\[].*?[))】\\]]")
  27. //清理上阶段kv的匹配的短词
  28. tablekeyclear2 = regexp.MustCompile("(供应商信用融资|供应商公章|主要标的名称|中标人推荐理由|成交供应商推荐理由)")
  29. //清理表格td中的符号
  30. tabletdclear = regexp.MustCompile("[\\s\u3000\u2003\u00a0\\n\u001c、,。_??;;~\\-#\\\\()(){}【】\\[\\]<>《》{}〔〕¥$]*")
  31. //判断key是金额,对万元的处理
  32. moneyReg = regexp.MustCompile("(预算|费|价|额|规模|投资)")
  33. //特殊文本-为表头
  34. specHeadReg = regexp.MustCompile("(成交供应商|中选人)")
  35. //key不需要清理-例如折扣 费率
  36. noClearKeyReg = regexp.MustCompile(`[((](费率|年|月|日|天|日历天|历天)[))]`)
  37. //根据表格的内容判断是不是表头,如果含有金额则不是表头
  38. MoneyReg = regexp.MustCompile("^[\\s  ::0-9.万元()()人民币¥$]+$")
  39. //特殊情况值,不能为表头
  40. noStartHeadReg = regexp.MustCompile("^(\\d标段)$")
  41. GSReg = regexp.MustCompile(".*公司.*")
  42. //判断分包时
  43. moneyNum = regexp.MustCompile("[元整¥万]")
  44. //对隐藏表格的判断
  45. display = regexp.MustCompile("(?i).*?display\\s?[:]\\s?none.*")
  46. //---------------
  47. //求是分包的概率
  48. //根据表格的标签对分包进行打分
  49. TableMultiPackageReg_4 = regexp.MustCompile("(标段|分包|包段|划分|子包|标包|合同段)")
  50. TableMultiPackageReg_2 = regexp.MustCompile("(概况|范围|情况|内容|详细|结果|信息)")
  51. //在判断分包打分前过虑表格key
  52. FilterKey_2 = regexp.MustCompile("招标|投标|项目")
  53. //根据表格的key进行分包打分
  54. FindKey_2 = regexp.MustCompile("([分子][包标](号)?|标[号项段包](划分)?|包件?[号段名数]|包[组件])")
  55. FindKey_3 = regexp.MustCompile("(标段编号|标包|包件|包号)")
  56. //对值进行分包判断
  57. FindVal_1 = regexp.MustCompile("[第]?([一二三四五六七八九十0-9A-Za-zⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ]+)((子|合同|分|施工|监理)?(标段?|包|合同段|标包))|标的[一二三四五六七八九十1-9A-Za-z]+|((子|合同|分|施工|监理)?(包|包件|标)(段|号)?)[  \u3000\u2003\u00a0]*([一二三四五六七八九十0-9A-Za-zⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ]+)")
  58. FindVal2_1 = regexp.MustCompile("([一二三四五六七八九十0-9A-Za-zⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ\\-]+)|^(设计|施工|监理|验收)[分子]?[标包]?[段号]?$")
  59. //判断分包前排除 包件号?
  60. excludeKey = regexp.MustCompile("(标识|数量|分包个数|标段代码|涉及包号|分包数量|项目标号|规格|型号|招标范围|业绩|废标|标段选择要求)|(^编号$)|([^包段标]编号)") //编号|划分
  61. excludeKey2 = regexp.MustCompile("包/[0-9]{0,4}[箱纸张]")
  62. excludeKey3 = regexp.MustCompile("(分包个数|每包[0-9]*元|标线|国标|享受一包服务)")
  63. //-------------
  64. cut = u.NewCut()
  65. //清理表格标签正则
  66. ClearTagReg = regexp.MustCompile("<[^>]*?>|[\\s\\n\\r]*$")
  67. //查找表格标签正则
  68. ttagreg = regexp.MustCompile("(?s)([^\\n::。,;\\s\u3000\u2003\u00a0]{2,30})[::]?[^::。;!\\n]{0,35}[\\s\\n]*$")
  69. //判断表格是表头的概率
  70. checkval = float32(0.6)
  71. //tdval_reg = regexp.MustCompile(`([\p{Han}][\p{Han}\s、()\\(\\)]{1,9})[::]([^::\\n。]{5,60})(?:[;;,,.。\\n\\t\\s])?`)
  72. //空格替换
  73. repSpace = regexp.MustCompile("[\\s\u3000\u2003\u00a0::]+|\\\\t+")
  74. //对表格kv的处理
  75. //对不能标准化的key做批识
  76. filter_tag_zb = regexp.MustCompile("(中标|成交|投标)[\\p{Han}]{0,6}(情况|结果|信息|明细)?")
  77. //中标金额
  78. //包含以下字眼做标准化处理
  79. filter_zbje_k = regexp.MustCompile("(中标|成交|总|拦标|合同|供[应货]商|报)[\\p{Han}、]{0,6}(价|额|[大小]写|[万亿]?元).{0,4}$")
  80. //简单判断金额
  81. filter_zbje_jd = regexp.MustCompile("^[^(售|保证)]{0,4}(价|额).{0,4}$")
  82. //预算金额
  83. filter_ysje_jd = regexp.MustCompile("(预算|预控价|项目概.|项目信息)")
  84. //且排队以下字眼的key
  85. filter_zbje_kn = regexp.MustCompile("得分|打分|时间|业绩|须知|分|电话|要求|需求数量|发布规模$|第[2二3三4四5五]|地址|询价保证金|行号")
  86. //且值包含以下字眼
  87. filter_zbje_v = regexp.MustCompile("[¥$$0-9一二三四五六七八九十,,〇零点..壹贰叁肆伍陆柒捌玖拾百佰千仟万亿億元圆角分整正()::大小写]{2,16}")
  88. //中标单位的处理
  89. //包含以下字眼的Key标准化
  90. filter_zbdw_ky = regexp.MustCompile("(中标|成交|拦标|合同|选中|投标|拟|预|最终)[\\p{Han}、]{0,6}(供[应货]商|企业|单位|人|机构)(名称)?.{0,4}$")
  91. //识别中标单位相关信息
  92. filter_zbdw_info = regexp.MustCompile("(中标|成交|中选|供(货|应))[^候选]{0,}")
  93. //简单判断
  94. filter_zbdw_jd = regexp.MustCompile("(投标|成交|中标|合同)(供应商|单位|人|名称).{0,4}$")
  95. //且不包含以下字眼
  96. filter_zbdw_kn = regexp.MustCompile("第[2二3三4四5五]|得分|地址|询价保证金") //且值包含以下字眼
  97. //且值包含以下字眼
  98. filter_zbdw_v = regexp.MustCompile("(公司|集团|研究院|设计院|局|厂|部|站|城|店|市|所|处)$|([^购]中心|办公|用品)")
  99. //且值包含以下字眼
  100. filter_zbdw_v2 = regexp.MustCompile("(公司|集团|研究院|设计院|局|厂|部|站|城|店|市|所|处)$")
  101. //Tg = map[string]interface{}{}
  102. //一些表格没有表头,是空的,对值是排序的做处理对应 NullTxBid
  103. NullTdReg = regexp.MustCompile("(首选|第[一二三四五1-5])(中标|成交)?(名(称)?|(候选|排序)?(人|单位|供应商))")
  104. NullTxtBid = "成交供应商排名"
  105. projectnameReg = regexp.MustCompile("((公开)?招标)*[((第]*[一二三四五六七八九十a-zA-Z0-9]+(标段|包|标|段)[))]*$")
  106. MhSpilt = regexp.MustCompile("[::]") //降低冒号权重
  107. //指定字段且时间格式
  108. UnTimeSpiltKey = regexp.MustCompile("(招标文件获取截止时间|招标文件获取开始时间|报名截止时间|报名开始时间|投标文件递交开始时间|开工日期|竣工日期)")
  109. UnTimeSpiltValue = regexp.MustCompile("\\d{1,2}[::]\\d{1,2}")
  110. //识别采购单位联系人、联系电话、代理机构联系人、联系电话 -- 名称有异常
  111. ContactInfoVagueReg = regexp.MustCompile("邮政编码|邮编|名称|(征求意见|报名审核购买)?((联系人?(及|和)?|办公|单位)?(((联系)?(电话|方式|号码)([//及]传真|及手机)?|手机)(号码)?|邮箱(地址)?|(详细)?(地(址|点)))|(联系|收料)(人(姓名)?|方式)|传真|电子邮件|(主要负责|项目(负责|联系)|经办)人)|采购方代表")
  112. ContactInfoExcluReg = regexp.MustCompile("[商]名称$")
  113. ContactInfoMustReg = regexp.MustCompile("^(" + ContactInfoVagueReg.String() + ")$")
  114. ContactType = map[string]*regexp.Regexp{
  115. "采购单位": regexp.MustCompile("(采购(项目.{2}|服务)?|比选|询价|招标(服务)?|甲|建设|招标|委托|发包|业主|使用|谈判|本招标项目经办|征求意见联系|项目实施)(人|单位|部门|机构|机关|(执行)?方$)|(项目|建(库|设))单位|招标人信息|采购中心(地址)?|业主|收料人|采购部"),
  116. "代理机构": regexp.MustCompile("(代理|受托|集中采购).{0,2}(人|方|单位|公司|机构)|招标机构|采购代理"),
  117. "中标单位": regexp.MustCompile("^((拟(定)?|预|最终|唯一)?(中标|成交|中选|供(货|应))((成交))?)[^候选]{0,2}(人|方|单位|公司|(服务|供应)?商|企业)"),
  118. "监督部门": regexp.MustCompile("投诉受理部门"),
  119. }
  120. ContactHeadReg = regexp.MustCompile("^(招标人|采购人)$")
  121. ContactBuyerPersonFilterReg = regexp.MustCompile("(管理局)$")
  122. MultipleValueSplitReg = regexp.MustCompile("[,,、\\s\u3000\u2003\u00a0]")
  123. BuyerContacts = []string{"采购单位联系人", "采购单位联系电话", "采购单位联系地址"}
  124. FilterSerial = regexp.MustCompile(".+[、..::,]")
  125. underline = regexp.MustCompile("_+$")
  126. iswinnertabletag = regexp.MustCompile("(中标|候选人|成交|结果|磋商情况)")
  127. nswinnertabletag = regexp.MustCompile("评得分估|标的信息|班子成员")
  128. jsonReg = regexp.MustCompile(`\{.+:[^}]*\} `) // \{".*\":\".+\"}
  129. regHz = regexp.MustCompile("[\u4e00-\u9fa5]")
  130. winnerOrderAndBidResult = regexp.MustCompile("((中标)?候选人|(中标|评标)结果)")
  131. WinnerOrderStr = regexp.MustCompile(`(集团|公司|学校|中心|家具城|门诊|[大中小]+学|部|院|局|厂|店|所|队|社|室|厅|段|会|场|行)$`)
  132. DoubtReg = regexp.MustCompile("(我中心|有(疑问|质疑|异议|意见)|(书面)?提出|不再受理|投诉|质疑|书面形式|监督|公示期(限)?)")
  133. //新增-分包-表格-sortKV
  134. budgetSortKVReg = regexp.MustCompile("(预算)")
  135. bidamountSortKVReg = regexp.MustCompile("(成交结果[((]万元[))]|成交金额|履约金额|中[标选]金额)")
  136. winnerSortKVReg = regexp.MustCompile("(投标人[((]供应商[))]名称)|供应商名称|中标候选人|中[标选]人|中[标选]单位")
  137. )
  138. var fblbReg *regexp.Regexp = regexp.MustCompile("(废标|流标|否决依据|未中标情况说明|负责人资格|负责人业绩|相关业绩|类似项目情况表|技术评分明细表|否决投标人投标的原因|开标记录|附件[:0-9]|越南盾|技术分[^公]|填报项目业绩|未通过.*原因)")
  139. // 59.992664,33.495715,20.001306
  140. var clearnum *regexp.Regexp = regexp.MustCompile("(([0-9.]{1,6}[,,]+){4,}|(\\d{6}[,,]\\d{2}.){2,})")
  141. var glRex *regexp.Regexp = regexp.MustCompile("(成交|中标|候选|排名|名次|供应商排序|中标候选人|名单及其排序|排序)")
  142. var djReg *regexp.Regexp = regexp.MustCompile("^单价")
  143. var hxrRex *regexp.Regexp = regexp.MustCompile("((成交|中标|中选)?候选人[弟|第][1-5一二三四五]名|[弟|第][1-5一二三四五][名]?(成交|中标|中选)?候选人)")
  144. var winMoneyReg *regexp.Regexp = regexp.MustCompile("(报价|投标价|投标报价|评审价|投标总价|含税总价[((]元[))]|总金额)")
  145. var winNoMoneyReg *regexp.Regexp = regexp.MustCompile("(得分|时间|序号|分)")
  146. var cleardwReg *regexp.Regexp = regexp.MustCompile("[((]{1}\\d*[人元件个公斤户]/[人元件个公斤户][))]")
  147. var zbhxrReg *regexp.Regexp = regexp.MustCompile("(中标候选人|投标单位名称|候选人姓名|候选人名称)")
  148. var zbhxrSortReg_1 *regexp.Regexp = regexp.MustCompile("^[第|弟][12345一二三四五]名$")
  149. var zbhxrSortReg_2 *regexp.Regexp = regexp.MustCompile("^([12345一二三四五])$")
  150. var zbhxrSortReg_3 *regexp.Regexp = regexp.MustCompile("^([12345一二三四五])")
  151. var zbhxrSortNameReg *regexp.Regexp = regexp.MustCompile("(中标候选人[第|弟][123一二三]名)|[第|弟][123一二三]中标候选人")
  152. var zbhxrSecondReg *regexp.Regexp = regexp.MustCompile("(中标候选人[第|弟][2二]名)|[第|弟][2二]中标候选人")
  153. var clearnn *regexp.Regexp = regexp.MustCompile("([\\d.]*)[\\n\\s]*[\\((][\\d.]+[)\\)]")
  154. // 分包含有关键词
  155. var pkgValidReg1 *regexp.Regexp = regexp.MustCompile("(中标单位|中标金额)[::]")
  156. var tableClearTextReg *regexp.Regexp = regexp.MustCompile("业绩[::].*")
  157. // 特殊-爬虫文本-抽取单价数量-并计算
  158. func dealWithSpecStructToSpiderCode(text string) string {
  159. text = formattext50.ReplaceAllString(text, "$1&&$2")
  160. arr := strings.Split(text, "&&")
  161. if len(arr) == 2 {
  162. one := qu.Float64All(arr[0])
  163. two := qu.Float64All(arr[1])
  164. if one > 0 && two > 0 {
  165. return fmt.Sprintf("\n合同金额:%f\n", one*two)
  166. }
  167. }
  168. return ""
  169. }
  170. // 对比前后候选人的有效性-true -为新
  171. func thanWinnerOrderEffective(old_order []map[string]interface{}, new_order []map[string]interface{}) bool {
  172. if len(new_order) == 0 || new_order == nil {
  173. return false
  174. }
  175. if len(old_order) == 0 || old_order == nil {
  176. return true
  177. }
  178. old_info, new_info := old_order[0], new_order[0]
  179. if qu.IntAll(old_info["sort"]) > 1 {
  180. return true
  181. } //排序比对
  182. if qu.IntAll(new_info["sort"]) > 1 {
  183. return false
  184. }
  185. //金额比对 -
  186. isuse_1, isuse_2 := false, false
  187. if old_vf, ok := old_info["price"].(float64); ok && old_vf > 0.0 {
  188. isuse_1 = true
  189. } else {
  190. if old_vs, ok := old_info["price"].(string); ok && old_vs != "" {
  191. isuse_1 = true
  192. }
  193. }
  194. if new_vf, ok := new_info["price"].(float64); ok && new_vf > 0.0 {
  195. isuse_2 = true
  196. } else {
  197. if new_vs, ok := new_info["price"].(string); ok && new_vs != "" {
  198. isuse_2 = true
  199. }
  200. }
  201. if isuse_1 && !isuse_2 {
  202. return false
  203. }
  204. if !isuse_1 && isuse_2 {
  205. return true
  206. }
  207. //均正常-优先取新值
  208. return true
  209. }
  210. // 对比前后候选人的有效性-true -为新
  211. func onlyExistsWinEntName(winorder []map[string]interface{}) bool {
  212. if len(winorder) <= 3 {
  213. for _, v := range winorder {
  214. if vf, ok := v["price"].(float64); ok && vf > 0.0 {
  215. return false
  216. }
  217. }
  218. } else {
  219. return false
  220. }
  221. return true
  222. }
  223. func thanExistsNewWinOrder(winorder []map[string]interface{}, new_winorder []map[string]interface{}) bool {
  224. if len(winorder) != len(new_winorder) {
  225. return false
  226. }
  227. isok := 0
  228. for k, v := range winorder {
  229. if qu.ObjToString(v["entname"]) == qu.ObjToString(new_winorder[k]["entname"]) {
  230. if new_price, ok := new_winorder[k]["price"].(float64); ok && new_price > 0.0 {
  231. isok++
  232. }
  233. }
  234. }
  235. if isok == len(winorder) {
  236. return true
  237. }
  238. return false
  239. }
  240. // 多供应商文本构建分包
  241. func dealWithMultiSuppliersText(con string) (bool, string) {
  242. startIndex := MultiStartReg.FindAllStringIndex(con, 1)
  243. endIndex := MultiEndReg.FindAllStringIndex(con, 1)
  244. if len(startIndex) == 1 && len(endIndex) == 1 {
  245. if len(startIndex[0]) > 1 && len(endIndex[0]) > 1 {
  246. t_start, t_end := startIndex[0][1], endIndex[0][0]
  247. if t_end > t_start {
  248. text := con[t_start:t_end]
  249. arr1 := SupplyInfoReg1.FindAllStringSubmatch(text, -1)
  250. if text1 := supplyInfoMethod(arr1, 2, 4); text1 != "" {
  251. return true, strings.ReplaceAll(con, text, text1)
  252. }
  253. arr2 := SupplyInfoReg2.FindAllStringSubmatch(text, -1)
  254. if text2 := supplyInfoMethod(arr2, 2, 4); text2 != "" {
  255. return true, strings.ReplaceAll(con, text, text2)
  256. }
  257. }
  258. }
  259. }
  260. return false, ""
  261. }
  262. // 特殊-重构
  263. func supplyInfoMethod(arr [][]string, w_index int, b_index int) string {
  264. new_text := ""
  265. if len(arr) > 1 {
  266. for k, v := range arr {
  267. key := fmt.Sprintf("包%d", k+1)
  268. new_text += key + "\n中标单位:" + v[w_index] + "\n中标金额:" + v[b_index] + "\n"
  269. }
  270. }
  271. return new_text
  272. }
  273. // 分析方法
  274. func AnalyStart(job *u.Job, isSite bool, codeSite string) {
  275. con := job.Content
  276. //全文的需要修复表格
  277. con = RepairCon(con)
  278. //格式化正文
  279. //con = preConReg1.ReplaceAllString(con, "${1}${2}")
  280. hisReg1_str := hisReg1.FindString(con)
  281. if hisReg1_str != "" && !strings.Contains(hisReg1_str, "中标候选人得分") {
  282. con = hisReg1.ReplaceAllString(con, "${4}")
  283. }
  284. hisReg2_str := hisReg2.FindString(con)
  285. if hisReg2_str != "" && !strings.Contains(hisReg2_str, "中标候选人得分") {
  286. con = hisReg2.ReplaceAllString(con, "${6}")
  287. }
  288. con = formattext.ReplaceAllString(con, "${1}:${2}")
  289. con = formattext2.ReplaceAllString(con, "${1}")
  290. con = formattext3.ReplaceAllString(con, "")
  291. con = formattext4.ReplaceAllString(con, "\n${1}:${2}\n")
  292. //特殊格式-影响分包候选人抽取-候选人等识别-替换
  293. con = formattext5.ReplaceAllString(con, "中标金额:${2}\n")
  294. con = formattext6.ReplaceAllString(con, "$1$2")
  295. con = formattext7.ReplaceAllString(con, "$1$2")
  296. //改变特殊结构
  297. con = formattext10.ReplaceAllString(con, "\n分包$3\n中标单位:$5 中标金额:$6\n")
  298. con = formattext11.ReplaceAllString(con, "${1}\n${2}\n预算金额:${4}\n${5}\n预算金额:${7}\n${8}\n")
  299. con = formattext12.ReplaceAllString(con, "\n${1}:${3}万元\n")
  300. con = formattext13.ReplaceAllString(con, "\n包一\n中标单位:${1}\n中标金额:${3}\n"+"包二\n中标单位:${2}\n中标金额:${4}\n")
  301. con = formattext14.ReplaceAllString(con, "\n包一\n中标单位:${1}\n中标金额:${2}\n"+"包二\n中标单位:${3}\n中标金额:${4}\n")
  302. //多供应商~文本结构~重构
  303. if m_b, m_c := dealWithMultiSuppliersText(con); m_b {
  304. con = m_c
  305. }
  306. //工程业绩描述影响抽取
  307. con = formattext20.ReplaceAllString(con, "\n")
  308. con = formattext21.ReplaceAllString(con, "")
  309. //指定爬虫-特殊结构-计算抽取
  310. if codeSite == "a_zgzfcgw_zfcghtgg_new" {
  311. str := formattext50.FindString(con)
  312. if str != "" {
  313. new_str := dealWithSpecStructToSpiderCode(str)
  314. if new_str != "" {
  315. con = new_str + con
  316. }
  317. }
  318. }
  319. con = formatText(con, "all")
  320. job.ContentClean = HtmlToText(job.Content)
  321. job.Content = con
  322. //计算表格占比,返回表格数组、占比
  323. tabs, _ := ComputeConRatio(con, 1)
  324. /*if len(tabs) > 0 {
  325. newcon, newtabs, newration := FindBigText(con, ration, tabs)
  326. if newcon != "" {
  327. con = newcon
  328. con = formatText(con, "all")
  329. tabs = newtabs
  330. ration = newration
  331. }
  332. }*/
  333. job.BlockPackage = map[string]*u.BlockPackage{}
  334. //分块+处理每块kv
  335. blockArrays, _ := DivideBlock(job.CategorySecond, con, 1, job.RuleBlock, isSite, codeSite)
  336. if len(blockArrays) > 0 { //有分块
  337. //从块里面找分包-文本
  338. if !job.IsFile {
  339. job.BlockPackage = FindPackageFromBlocks(&blockArrays, isSite, codeSite) //从块里面找分包
  340. }
  341. for _, bl := range blockArrays {
  342. if len([]rune(bl.Text)) > 80 {
  343. bl.Block, _ = DivideBlock(job.CategorySecond, bl.Text, 1, job.RuleBlock, isSite, codeSite)
  344. for _, bl_bl := range bl.Block {
  345. processTableInBlock(bl_bl, job, isSite, codeSite)
  346. }
  347. }
  348. FindProjectCode(bl.Text, job) //匹配项目编号
  349. //表格找分包相关---
  350. isUnRulesTab := processTableInBlock(bl, job, isSite, codeSite) //处理表格
  351. if isUnRulesTab { //是否不规则表格
  352. job.IsUnRulesTab = isUnRulesTab
  353. }
  354. //对块行内容业绩相关进行过滤
  355. bl.Text = tableClearTextReg.ReplaceAllString(bl.Text, "")
  356. //新加 未分块table中未能解析到中标候选人,从正文中解析-全文匹配一次
  357. if (job.Winnerorder == nil || len(job.Winnerorder) == 0) || len(job.Winnerorder) > 8 {
  358. //表格没有划分时候:-纯文本匹配
  359. tmp_text := HtmlToText(bl.Text)
  360. bl.Winnerorder = winnerOrderEntity.Find(tmp_text, true, 1, isSite, codeSite)
  361. if thanWinnerOrderEffective(job.Winnerorder, bl.Winnerorder) {
  362. job.Winnerorder = bl.Winnerorder
  363. }
  364. }
  365. //无分包-附件-格式化文本处理-
  366. if (job.BlockPackage == nil || len(job.BlockPackage) == 0) && job.IsFile {
  367. tmp_text := HtmlToText(bl.Text)
  368. job.BlockPackage = FindPackageFromText(job.Title, tmp_text, isSite, codeSite)
  369. }
  370. job.Block = append(job.Block, bl)
  371. }
  372. } else { //未分块,创建分块
  373. //log.Println(con)
  374. bl := &u.Block{}
  375. newCon := con
  376. //log.Println(con)
  377. if len(tabs) > 0 { //解析表格逻辑
  378. job.HasTable = 1 //添加标识:文本中有table
  379. newCon = TextAfterRemoveTable(con)
  380. //log.Println(newCon)
  381. if newCon != "" {
  382. job.BlockPackage = FindPackageFromText(job.Title, newCon, isSite, codeSite)
  383. }
  384. for i := 0; i < len(tabs); i++ {
  385. blockTag := ""
  386. if len(tabs[i].Nodes) > 0 {
  387. if tabs[i].Nodes[0].PrevSibling != nil {
  388. blockTag = tabs[i].Nodes[0].PrevSibling.Data
  389. }
  390. }
  391. //添加标识:文本中有table
  392. //blockTag - 块标签
  393. //处理表格
  394. tabres := AnalyTableV2(tabs[i], job.Category, blockTag, con, 1, job.SourceMid, job.RuleBlock, isSite, codeSite) //解析表格入口 返回:汇总表格对象
  395. job.IsUnRulesTab = tabres.isUnRulesTab
  396. processTableResult(tabres, bl, job, isSite, codeSite)
  397. }
  398. } else {
  399. //从正文里面找分包
  400. job.BlockPackage = FindPackageFromText(job.Title, newCon, isSite, codeSite)
  401. }
  402. bl.Text = HtmlToText(con)
  403. FindProjectCode(bl.Text, job) //匹配项目编号 ~~ 清洗无效信息文本
  404. if blTextReg.MatchString(bl.Text) && !unblTextReg.MatchString(bl.Text) {
  405. if strings.Index(bl.Text, "业绩") > 1 {
  406. //如果有采购单位信息~置前
  407. before_arr := []string{}
  408. if beforeTextReg.MatchString(bl.Text) {
  409. before_arr = beforeTextReg.FindAllString(bl.Text, -1)
  410. }
  411. bl.Text = bl.Text[:strings.Index(bl.Text, "业绩")]
  412. if len(before_arr) > 0 {
  413. bl.Text = strings.Join(before_arr, "\n") + bl.Text
  414. }
  415. }
  416. }
  417. //特殊-指定处理-结构转化formattext100
  418. if formattext100.MatchString(bl.Text) {
  419. new_str := formattext100.FindString(bl.Text)
  420. new_str = formattext100.ReplaceAllString(new_str, "$1")
  421. bl.Text = fmt.Sprintf("中标金额:%s万元\n", new_str) + bl.Text
  422. }
  423. //调用kv解析库-处理detail
  424. bl.Text = formatText(bl.Text, "all")
  425. //处理 :
  426. bl.ColonKV = GetKVAll(bl.Text, "", nil, 1, isSite, codeSite)
  427. //处理空格
  428. bl.SpaceKV = SspacekvEntity.Entrance(bl.Text, "", nil, isSite, codeSite)
  429. //新加 未分块table中未能解析到 中标候选人,从正文中解析
  430. if job.Winnerorder == nil || len(job.Winnerorder) == 0 || len(job.Winnerorder) > 8 {
  431. bl.Winnerorder = winnerOrderEntity.Find(bl.Text, true, 1, isSite, codeSite)
  432. if thanWinnerOrderEffective(job.Winnerorder, bl.Winnerorder) {
  433. job.Winnerorder = bl.Winnerorder
  434. }
  435. } else { //table里面识别出单位候选人-未识别金额...
  436. if onlyExistsWinEntName(job.Winnerorder) {
  437. new_winorder := winnerOrderEntity.Find(bl.Text, true, 1, isSite, codeSite)
  438. if thanExistsNewWinOrder(job.Winnerorder, new_winorder) {
  439. job.Winnerorder = new_winorder
  440. }
  441. }
  442. }
  443. //如果表格查询分包-有分包-但是没有有效值的话 ,正文重新查找
  444. if len(tabs) > 0 && job.BlockPackage != nil {
  445. if !isUsefulPackage(job.BlockPackage) { //表格未识别出有效分包-且文本里面无有效字样
  446. text_pkg := FindPackageFromText(job.Title, bl.Text, isSite, codeSite)
  447. if len(text_pkg) > 0 {
  448. job.BlockPackage = text_pkg
  449. }
  450. }
  451. }
  452. job.Block = append(job.Block, bl)
  453. }
  454. }
  455. // 是否有效分包
  456. func isUsefulPackage(pkg map[string]*u.BlockPackage) bool {
  457. if pkg == nil || len(pkg) == 0 {
  458. return false
  459. }
  460. for _, v := range pkg {
  461. p_winner := v.Winner
  462. p_budget := v.Budget
  463. p_bidamout := v.Bidamount
  464. if p_winner != "" || p_budget > float64(0) || p_bidamout > float64(0) {
  465. return true
  466. }
  467. }
  468. return false
  469. }
  470. // 核查候选人字段是否合理
  471. func verifyPackageWinnerOrder(wins []map[string]interface{}) bool {
  472. temp := map[string]string{}
  473. for k, v := range wins {
  474. if qu.IntAll(v["sort"]) != k+1 {
  475. return false
  476. }
  477. entname := qu.ObjToString(v["entname"])
  478. if temp[entname] == "" {
  479. temp[entname] = entname
  480. } else {
  481. return false
  482. }
  483. }
  484. return true
  485. }
  486. // 判断数组string 是否重复
  487. func isRepeatArrString(arr1, arr2 []string) bool {
  488. is_r := true
  489. for k, v := range arr1 {
  490. if v != arr2[k] {
  491. is_r = false
  492. break
  493. }
  494. }
  495. return is_r
  496. }
  497. // 对sortkv重构
  498. func isResetUnitAmountSortKV(table *Table) {
  499. isUnitAmount := 0
  500. for _, k := range table.SortKV.Keys {
  501. v := table.SortKV.Map[k]
  502. if new_v, ok := v.(string); ok && (k == "中标金额" || k == "单位") {
  503. if k == "单位" && new_v == "万元" {
  504. isUnitAmount++
  505. }
  506. if k == "中标金额" && MoneyReg.MatchString(new_v) && !strings.Contains(new_v, "万") {
  507. isUnitAmount++
  508. }
  509. }
  510. }
  511. if isUnitAmount > 1 {
  512. table.SortKV.Map["中标金额"] = qu.ObjToString(table.SortKV.Map["中标金额"]) + "万元"
  513. }
  514. }
  515. func isResetUnitPriceSortKV(table *Table) {
  516. keyArr := []string{"序号", "数量", "单价"}
  517. isMatch := true
  518. for _, v := range keyArr {
  519. if _, ok := table.SortKV.Map[v].(string); !ok {
  520. isMatch = false
  521. break
  522. }
  523. }
  524. if isMatch && table.SortKV.Map["总价(元)"] == nil {
  525. if qu.ObjToString(table.SortKV.Map["序号"]) == "1" &&
  526. qu.ObjToString(table.SortKV.Map["数量"]) == "1" {
  527. table.SortKV.Map["总价(元)"] = table.SortKV.Map["单价"]
  528. table.SortKV.Keys = append(table.SortKV.Keys, "总价(元)")
  529. }
  530. }
  531. }
  532. func isResetAmountAggregateSortKV(table *Table) {
  533. keyGroup := [][]string{}
  534. keyGroup = append(keyGroup, []string{"序号", "标项名称", "总价(元)"})
  535. keyGroup = append(keyGroup, []string{"序号", "名称", "总价(元)"})
  536. keyGroup = append(keyGroup, []string{"序号", "服务内容", "验收金额(元)"})
  537. keyGroup = append(keyGroup, []string{"序号", "标项名称", "单价(元)", "数量"})
  538. for _, v := range keyGroup {
  539. if len(v) == 3 {
  540. arr1 := u.ConvertInterface(table.SortKV.Map[v[0]])
  541. arr2 := u.ConvertInterface(table.SortKV.Map[v[1]])
  542. arr3 := u.ConvertInterface(table.SortKV.Map[v[2]])
  543. if len(arr1) > 1 && len(arr1) == len(arr2) && len(arr1) == len(arr3) {
  544. amount := float64(0)
  545. for _, nv := range arr3 {
  546. amount = precisionFloat(amount, qu.Float64All(nv))
  547. }
  548. if amount > float64(0) {
  549. table.SortKV.Map[v[2]] = fmt.Sprintf("%f", amount)
  550. }
  551. break
  552. }
  553. }
  554. if len(v) == 4 {
  555. arr1 := u.ConvertInterface(table.SortKV.Map[v[0]])
  556. arr2 := u.ConvertInterface(table.SortKV.Map[v[1]])
  557. arr3 := u.ConvertInterface(table.SortKV.Map[v[2]])
  558. arr4 := u.ConvertInterface(table.SortKV.Map[v[3]])
  559. if len(arr1) > 1 && len(arr1) == len(arr2) && len(arr1) == len(arr3) && len(arr1) == len(arr4) {
  560. amount := float64(0)
  561. for kv, nv := range arr3 {
  562. amount = precisionFloat(amount, qu.Float64All(nv)*qu.Float64All(arr4[kv]))
  563. }
  564. if amount > float64(0) {
  565. if table.SortKV.Map["总价(元)"] == nil {
  566. table.SortKV.Map["总价(元)"] = fmt.Sprintf("%f", amount)
  567. table.SortKV.Keys = append(table.SortKV.Keys, "总价(元)")
  568. } else {
  569. table.SortKV.Map["总价(元)"] = fmt.Sprintf("%f", amount)
  570. }
  571. }
  572. break
  573. }
  574. }
  575. }
  576. }
  577. func isReseterialNumberSortKV(table *Table) {
  578. arr := u.ConvertInterface(table.SortKV.Map["序号"])
  579. if len(arr) > 5 {
  580. table.SortKV.Map["序号"] = arr[:3]
  581. }
  582. }
  583. func isResetWinnerRankingSortKV(table *Table) {
  584. if len(table.SortKV.Map) == 2 && table.SortKV.Map["中标人"] != nil && table.SortKV.Map["中标价格"] != nil {
  585. arr := u.ConvertInterface(table.SortKV.Map["中标人"])
  586. if len(arr) > 1 && len(arr) <= 3 {
  587. table.SortKV.Map["排名"] = []string{"1", "2"}
  588. table.SortKV.Keys = append(table.SortKV.Keys, "排名")
  589. }
  590. }
  591. }
  592. // 精度丢失-相加
  593. func precisionFloat(tmp1, tmp2 float64) float64 {
  594. n1 := decimal.NewFromFloat(tmp1)
  595. n2 := decimal.NewFromFloat(tmp2)
  596. decimalValue := n2.Add(n1)
  597. res, _ := decimalValue.Float64()
  598. return res
  599. }
  600. // 重置as~keys
  601. func resetAsKeysBidamount(as *SortMap) {
  602. keys, values_data := as.Keys, as.Map
  603. if len(keys) == 0 {
  604. return
  605. }
  606. k1, k2 := "投标报价(元)", "经评审的投标价(元)"
  607. value1, value2 := make([]string, 0), make([]string, 0)
  608. is_del := false
  609. if arr, ok := values_data[k1].([]string); ok && len(arr) > 0 {
  610. value1 = arr
  611. } else {
  612. return
  613. }
  614. if arr, ok := values_data[k2].([]string); ok && len(arr) > 0 {
  615. value2 = arr
  616. } else {
  617. return
  618. }
  619. if len(value1) == len(value2) && len(value1) > 0 {
  620. tmp_value := value2[0]
  621. price := winnerOrderEntity.clear("中标金额", tmp_value+GetMoneyUnit(k1, tmp_value))
  622. if pricestr, _ := price.(string); len(pricestr) < 30 && len(pricestr) > 0 {
  623. is_del = true
  624. }
  625. }
  626. if is_del {
  627. as.Map[k1] = as.Map[k2]
  628. }
  629. }
  630. // 判断是否特殊候选人结构表格
  631. func judgmentWinnerOrderHeaderInfo(TRs []*TR) bool {
  632. if len(TRs) < 3 {
  633. return false
  634. }
  635. //是否含有指定关键词
  636. TR_0 := TRs[0]
  637. isLen := 0
  638. for k, v := range TRs {
  639. if k > 0 {
  640. if len(v.TDs) == len(TR_0.TDs) {
  641. isLen++
  642. }
  643. if isLen >= 2 {
  644. break
  645. }
  646. }
  647. }
  648. if isLen < 2 {
  649. return false
  650. }
  651. textArr := [][]string{}
  652. textArr = append(textArr, []string{"投标人", "中标候选人排序", "投标报价(万元)"})
  653. textArr = append(textArr, []string{"投标人", "中标候选人排序", "投标总报价(万元)"})
  654. for _, arr := range textArr {
  655. isok := 0
  656. for _, v := range arr {
  657. for _, v1 := range TR_0.TDs {
  658. if v1.Val == v {
  659. isok++
  660. break
  661. }
  662. }
  663. }
  664. if isok == 3 {
  665. return true
  666. }
  667. }
  668. return false
  669. }
  670. // 预算标签-不一定为分包
  671. func isUnRealBudgetBp(tnv []*u.Tag) bool {
  672. if len(tnv) != 2 {
  673. return false
  674. }
  675. key_1, key_2 := tnv[0].Key, tnv[1].Key
  676. value_1, value_2 := tnv[0].Value, tnv[1].Value
  677. if value_1 != value_2 {
  678. if strings.Contains(key_1, "项目总投资") && strings.Contains(key_2, "项目投资") {
  679. return true
  680. }
  681. if strings.Contains(key_2, "项目总投资") && strings.Contains(key_1, "项目投资") {
  682. return true
  683. }
  684. }
  685. return false
  686. }
  687. // 初始化lineMapArr,lineMap
  688. func initLineMapLineMapArr(table *Table) (lineMapArr map[string]*SortMap, lineMap map[string]*SortMap) {
  689. lineMapArr = make(map[string]*SortMap)
  690. lineMap = make(map[string]*SortMap)
  691. for _, key := range table.SortKV.Keys { //遍历table.SortKV.Keys而不是直接遍历table.SortKV.Map是为了得到table头的顺序
  692. val := table.SortKV.Map[key]
  693. key = regReplAllSpace.ReplaceAllString(key, "")
  694. key = strings.Replace(key, "", "", -1) //处理一个特殊的采购量 经上层处理空格后未处理掉
  695. //qu.Debug(key, "---------------------------", val)
  696. if realTypeVal, ok := val.([]string); ok { //val为数组 {"数量":["1","2","3"]}
  697. /*
  698. {
  699. "商品":["",""],
  700. "商品_"["",""],
  701. }
  702. */
  703. valArr, allempty := filterVal(realTypeVal...) //过滤数据
  704. if allempty {
  705. continue
  706. }
  707. realTypeVal = valArr
  708. line := underline.FindString(key)
  709. lineValMap1 := lineMapArr[line]
  710. // i := 1
  711. // L:
  712. // for { //去除数组空数据
  713. // last := realTypeVal[len(realTypeVal)-i]
  714. // if last == "" {
  715. // i++
  716. // if i > len(realTypeVal) {
  717. // break
  718. // }
  719. // goto L
  720. // } else {
  721. // break
  722. // }
  723. // }
  724. // dislodgeNull := realTypeVal[:(len(realTypeVal) - i + 1)] //去除数组中空数据
  725. if len(realTypeVal) > 0 {
  726. if lineValMap1 == nil {
  727. tmp := NewSortMap()
  728. tmp.AddKey(key, realTypeVal)
  729. lineMapArr[line] = tmp
  730. } else {
  731. lineValMap1.AddKey(key, realTypeVal)
  732. }
  733. }
  734. //qu.Debug("lineMapArr---", lineMapArr[line].Keys, lineMapArr[line].Map)
  735. } else if realTypeVal, b := val.(string); b { //val为字符串 {"数量":"1"}
  736. /*
  737. {
  738. "商品:"",名称:"",
  739. "商品_:"",名称_:"",
  740. "商品__:"",名称__:"",
  741. }
  742. */
  743. valArr, allempty := filterVal(realTypeVal) //过滤数据
  744. if allempty {
  745. continue
  746. }
  747. realTypeVal = valArr[0]
  748. line := underline.FindString(key)
  749. lineValMap2 := lineMap[line]
  750. if lineValMap2 == nil {
  751. tmp := NewSortMap()
  752. tmp.AddKey(key, realTypeVal)
  753. lineMap[line] = tmp
  754. } else {
  755. lineValMap2.AddKey(key, realTypeVal)
  756. }
  757. //qu.Debug("lineMap---", lineMap[line].Keys, lineMap[line].Map)
  758. } else {
  759. // "_id" : ObjectId("5c2c3802a5cb26b9b78646c4")5c2b0551a5cb26b9b7cb05db否5c2a42e6a5cb26b9b763ba5a采购人:一、采购人5c2b06f5a5cb26b9b7cc4409
  760. //成交供应商排名 [map[entname:昆明合优科技有限公司 sortstr:第一中标候选人 sort:1] map[sort:2 entname:昆明厚起科技有限公司 sortstr:第二中标候选人] map[entname:云南远安科技发展有限公司 sortstr:第三中标候选人 sort:3]]
  761. //qu.Debug("err data:", key, val)
  762. }
  763. }
  764. return lineMapArr, lineMap
  765. }
  766. func dealArrData(maxNum int, ka map[string][]string) []map[string]string {
  767. for k2, v2 := range ka {
  768. //处理数组长度不相等,使长度一致
  769. if len(v2) > maxNum {
  770. ka[k2] = v2[:maxNum]
  771. }
  772. }
  773. finalData := assembleData(ka, 1)
  774. if len(finalData) > 0 {
  775. return finalData
  776. }
  777. return nil
  778. }
  779. func dealStrData(kv map[string]string) []map[string]string {
  780. finalData := []map[string]string{}
  781. if len(kv) > 0 {
  782. finalData = assembleData(kv, 2)
  783. }
  784. return finalData
  785. }
  786. // 组装数据,每一行的数据为一数据集合
  787. func assembleData(m interface{}, n int) []map[string]string {
  788. defer qu.Catch()
  789. /*
  790. {
  791. "itemname":["计算机","打印机","机柜"],
  792. "number" :["1","12","4"]
  793. }
  794. */
  795. datas := []map[string]string{}
  796. if n == 1 { //数组数据
  797. realTypeM := m.(map[string][]string)
  798. //根据数组数据的顺序 将多个数组中索引相同的数据拼装成一个map,并将这多个map放入一个arr
  799. /*
  800. arr1 ["a1","b1","c1"]
  801. arr2 ["a2","b2","c2"]
  802. [
  803. {"a1","a2"},
  804. {"b1","b2"},
  805. {"c1","c2"}
  806. ]
  807. */
  808. //start
  809. for k3, v3 := range realTypeM {
  810. for _, val := range v3 {
  811. data := make(map[string]string)
  812. data[k3] = val
  813. datas = append(datas, data)
  814. }
  815. break
  816. }
  817. for i, data := range datas {
  818. for k4, v4 := range realTypeM {
  819. if i < len(v4) { //数组数据长度不一致
  820. if v4[i] != " " {
  821. data[k4] = v4[i]
  822. } else {
  823. delete(data, k4)
  824. }
  825. } else {
  826. fmt.Println("err table")
  827. }
  828. }
  829. datas[i] = data
  830. }
  831. //end
  832. for _, fdv := range datas { //清除空数据和只含特殊符号的数据
  833. for fmk, fmv := range fdv {
  834. if tabletdclear.ReplaceAllString(fmv, "") == "" {
  835. delete(fdv, fmk)
  836. }
  837. }
  838. }
  839. } else { //字符串数据
  840. realTypeM := m.(map[string]string)
  841. datas = append(datas, realTypeM)
  842. }
  843. return datas
  844. }
  845. func convert(key, r string) bool {
  846. defer qu.Catch()
  847. flag := false
  848. key = tabletitleclear.ReplaceAllString(key, "")
  849. reg, err := regexp.Compile(r)
  850. if err != nil {
  851. fmt.Println("reg err:", err)
  852. return false
  853. }
  854. flag = reg.MatchString(key)
  855. return flag
  856. }
  857. func hasKey(table *Table, n int) {
  858. defer qu.Catch()
  859. if table.TableResult.HasKey == 1 {
  860. return
  861. }
  862. if n >= 1 {
  863. table.TableResult.HasKey = 1
  864. }
  865. }
  866. func hasGoods(table *Table, data ...string) {
  867. defer qu.Catch()
  868. goodsArr := make([]string, len(data))
  869. //fmt.Println("table.TableResult.HasGoods=====", table.TableResult.HasGoods)
  870. if table.TableResult.HasGoods == 1 {
  871. return
  872. }
  873. for i, d := range data {
  874. if d != "" {
  875. goods := u.GoodsGet.CheckSensitiveWord(d)
  876. //fmt.Println("goods======", goods)
  877. goodsArr[i] = goods
  878. if len(goods) > 0 {
  879. table.TableResult.HasGoods = 1
  880. break
  881. }
  882. }
  883. }
  884. }
  885. func hasBrand(table *Table, data ...string) ([]string, bool) {
  886. defer qu.Catch()
  887. //fmt.Println("table.TableResult.HasBrand---------", table.TableResult.HasBrand)
  888. brandArr := make([]string, len(data))
  889. // if table.TableResult.HasBrand == 1 {
  890. // return brandArr, 1
  891. // }
  892. allNull := true
  893. for i, d := range data {
  894. //if d != "" {
  895. brand := u.BrandGet.CheckSensitiveWord(d)
  896. if brand != "" {
  897. allNull = false
  898. }
  899. //fmt.Println("brand======", brand)
  900. brandArr[i] = brand
  901. if len(brand) > 0 {
  902. table.TableResult.HasBrand = 1
  903. }
  904. //}
  905. }
  906. return brandArr, allNull
  907. }
  908. // 过滤td值
  909. func filterVal(val ...string) ([]string, bool) {
  910. defer qu.Catch()
  911. n := 0 //记录被过滤的个数
  912. for i, v := range val {
  913. if len(clearnn.FindStringSubmatch(v)) > 0 {
  914. tmpv := clearnn.FindStringSubmatch(v)[1]
  915. if tmpv != "" {
  916. v = tmpv
  917. }
  918. }
  919. afterFilter := tabletdclear.ReplaceAllString(v, "")
  920. afterFilter = NullVal.ReplaceAllString(afterFilter, "")
  921. if afterFilter == "" {
  922. n++
  923. }
  924. val[i] = afterFilter
  925. }
  926. allempty := false
  927. if n == len(val) { //所有都被过滤掉
  928. allempty = true
  929. }
  930. return val, allempty
  931. }
  932. // 过滤itemname全是数字
  933. func filterItem(itemval ...string) []string {
  934. defer qu.Catch()
  935. result := []string{}
  936. for _, v := range itemval {
  937. afterFilter := numclear.ReplaceAllString(v, "")
  938. if afterFilter != "" {
  939. result = append(result, v)
  940. } else {
  941. result = append(result, afterFilter)
  942. }
  943. }
  944. return result
  945. }
  946. // 处理价格
  947. func dealPriceInterface(key string, val ...string) (result []interface{}) {
  948. defer qu.Catch()
  949. for _, v := range val {
  950. if num1.MatchString(v) { //含数字
  951. tdIsWan := strings.Contains(v, "万")
  952. if !tdIsWan {
  953. if strings.Contains(key, "万") {
  954. v = v + "万"
  955. }
  956. }
  957. data := []interface{}{v, ""}
  958. money := clear.ObjToMoney(data)[0]
  959. result = append(result, money)
  960. } else {
  961. result = append(result, "")
  962. }
  963. }
  964. return
  965. }
  966. // 处理number
  967. func dealNumberInterface(val ...string) (result []interface{}) {
  968. defer qu.Catch()
  969. for _, v := range val { //1个 1.00个
  970. n := numclear.FindString(v)
  971. if n == "" {
  972. result = append(result, "")
  973. } else if tmp := clear.NumChar[n]; tmp != nil { //一二三...
  974. result = append(result, tmp)
  975. } else { //数字
  976. result = append(result, qu.IntAll(strings.Split(n, ".")[0]))
  977. }
  978. }
  979. return
  980. }
  981. // 处理价格
  982. func dealPrice(key string, val ...string) []string {
  983. defer qu.Catch()
  984. result := []string{}
  985. for _, v := range val {
  986. data := []interface{}{v, key}
  987. money := clear.ObjToMoney(data)[0]
  988. result = append(result, fmt.Sprintf("%v", money))
  989. }
  990. // result := []string{}
  991. // for _, v := range val { //1.00万元 1元 2.25元/斤
  992. // tmparr := strings.Split(v, ".")
  993. // tmparr[0] = moneyNum.ReplaceAllString(tmparr[0], "")
  994. // if iswan {
  995. // result = append(result, tmparr[0]+"0000")
  996. // } else { //td val值带万
  997. // if strings.Contains(v, "万") { //价格中带有万
  998. // result = append(result, tmparr[0]+"0000")
  999. // } else {
  1000. // result = append(result, tmparr[0])
  1001. // }
  1002. // }
  1003. // }
  1004. return result
  1005. }
  1006. // 处理number
  1007. func dealNumber(val ...string) ([]string, []string) {
  1008. defer qu.Catch()
  1009. unitnameArr := []string{}
  1010. result := []string{}
  1011. for _, v := range val { //1个 1.00个
  1012. n := numclear.FindString(v)
  1013. unitname := numclear.ReplaceAllString(v, "") //匹配个数后的单位
  1014. unitnameArr = append(unitnameArr, unitname)
  1015. //val[i] = strings.Split(n, ".")[0]
  1016. result = append(result, strings.Split(n, ".")[0])
  1017. }
  1018. return result, unitnameArr
  1019. }
  1020. // 是否符合指定结构
  1021. func isPkgRegexArr(regs []*regexp.Regexp, con string) bool {
  1022. S_Index := regs[0].FindAllStringIndex(con, -1)
  1023. E_Index := regs[1].FindAllStringIndex(con, -1)
  1024. if len(S_Index) == len(E_Index) && len(S_Index) == 1 {
  1025. return true
  1026. }
  1027. return false
  1028. }