merge_select.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. package main
  2. import (
  3. "math"
  4. "regexp"
  5. )
  6. func Select(compareStr string, info *Info, compareInfo *ProjectInfo) (res int) {
  7. //没有可对比的项目名称、或项目编号
  8. if compareNoPass[compareStr] {
  9. } else {
  10. switch compareStr {
  11. case "AAA":
  12. res = 3
  13. case "AAB":
  14. res = 3
  15. case "ABA":
  16. res = 3
  17. case "ABB":
  18. if info.LenPTC > 6 || info.LenPC > 6 {
  19. res = 3
  20. } else {
  21. res = 2
  22. }
  23. case "BAA":
  24. if info.LenPN > 10 {
  25. res = 3
  26. } else {
  27. res = 2
  28. }
  29. case "BAB":
  30. if info.LenPN > 10 || info.LenPTC > 6 {
  31. res = 3
  32. } else {
  33. res = 2
  34. }
  35. case "BBA":
  36. if info.LenPN > 10 || info.LenPC > 6 {
  37. res = 3
  38. } else {
  39. res = 2
  40. }
  41. case "BBB":
  42. v := 0
  43. if info.LenPN > 10 {
  44. v++
  45. }
  46. if info.LenPC > 6 {
  47. v++
  48. }
  49. if info.LenPTC > 6 {
  50. v++
  51. }
  52. if v > 1 {
  53. res = 3
  54. } else if v == 1 {
  55. res = 2
  56. } else {
  57. res = 1
  58. }
  59. case "AAD":
  60. res = 3
  61. case "ABD":
  62. if info.LenPC > 12 || info.LenPN > 16 {
  63. res = 3
  64. } else {
  65. res = 2
  66. }
  67. case "BAD":
  68. if info.LenPC > 12 || info.LenPN > 16 {
  69. res = 3
  70. } else {
  71. res = 2
  72. }
  73. case "BBD":
  74. if info.LenPC > 12 && info.LenPN > 16 {
  75. res = 3
  76. } else {
  77. res = 2
  78. }
  79. case "ADA":
  80. res = 3
  81. case "ADB":
  82. if info.LenPTC > 12 || info.LenPN > 16 {
  83. res = 3
  84. } else {
  85. res = 2
  86. }
  87. case "BDA":
  88. if info.LenPTC > 12 || info.LenPN > 16 {
  89. res = 3
  90. } else {
  91. res = 2
  92. }
  93. case "BDB":
  94. if info.LenPTC > 12 && info.LenPN > 16 {
  95. res = 3
  96. } else {
  97. res = 2
  98. }
  99. case "ADD":
  100. // if info.LenPN > 18 {
  101. // res = 3
  102. // } else
  103. if info.LenPN > 14 {
  104. res = 2
  105. } else {
  106. res = 1
  107. }
  108. case "BDD":
  109. if info.LenPN > 18 {
  110. res = 2
  111. } else {
  112. res = 1
  113. }
  114. case "DAA":
  115. if info.LenPTC > 12 || info.LenPC > 12 {
  116. res = 2
  117. } else {
  118. res = 1
  119. }
  120. case "DAB":
  121. if info.LenPTC > 12 {
  122. res = 2
  123. } else {
  124. res = 1
  125. }
  126. case "DAD":
  127. if info.LenPTC > 14 {
  128. res = 2
  129. } else {
  130. res = 1
  131. }
  132. case "DBA":
  133. if info.LenPC > 12 {
  134. res = 2
  135. } else {
  136. res = 1
  137. }
  138. case "DBB":
  139. if info.LenPTC > 12 && info.LenPC > 12 {
  140. res = 2
  141. } else {
  142. res = 1
  143. }
  144. case "DBD":
  145. if info.LenPC > 8 {
  146. res = 1
  147. }
  148. case "DDA":
  149. if info.LenPTC > 12 {
  150. res = 2
  151. } else {
  152. res = 1
  153. }
  154. case "DDB":
  155. if info.LenPC > 8 {
  156. res = 1
  157. }
  158. case "ACA":
  159. if info.LenPN > 12 || info.LenPTC > 9 {
  160. res = 2
  161. } else {
  162. res = 1
  163. }
  164. case "ACB":
  165. if info.LenPN > 14 && info.LenPTC > 10 {
  166. res = 2
  167. } else {
  168. res = 1
  169. }
  170. case "BCA":
  171. if info.LenPN > 12 && info.LenPTC > 9 {
  172. res = 2
  173. } else {
  174. res = 1
  175. }
  176. case "BCB":
  177. if info.LenPN > 12 && info.LenPTC > 9 {
  178. res = 2
  179. } else if info.LenPN > 16 || info.LenPTC > 12 {
  180. res = 1
  181. }
  182. case "AAC":
  183. if info.LenPN > 12 || info.LenPC > 9 {
  184. res = 3
  185. } else {
  186. res = 2
  187. }
  188. case "ABC":
  189. if info.LenPN > 14 || info.LenPC > 12 {
  190. res = 2
  191. } else {
  192. res = 1
  193. }
  194. case "BAC":
  195. if info.LenPN > 14 || info.LenPC > 12 {
  196. res = 2
  197. } else {
  198. res = 1
  199. }
  200. case "BBC":
  201. // if info.LenPN > 12 && info.LenPTC > 9 {
  202. // res = 1
  203. // } else {
  204. // res = 1
  205. // }
  206. res = 1
  207. case "ACC":
  208. // if info.LenPC > 4 && len(compareInfo.ProjectCode) > 4 && CheckHanAndNum(info.ProjectCode) && CheckHanAndNum(compareInfo.ProjectCode) {
  209. // //未考虑MPC
  210. // } else if info.LenPN > 16 {
  211. // res = 1
  212. // }
  213. //
  214. case "ACD":
  215. //项目编号不一致
  216. if math.Abs(float64(info.LenPC-len([]rune(compareInfo.ProjectCode)))) > 3 && info.LenPN > 12 {
  217. res = 1
  218. }
  219. case "ADC":
  220. if info.LenPN > 16 {
  221. res = 1
  222. }
  223. case "BCC":
  224. //项目编号不一致
  225. case "BCD":
  226. //项目编号不一致
  227. if info.LenPC > 4 && len(compareInfo.ProjectCode) > 4 && (!_numreg1.MatchString(info.ProjectCode) && !_numreg1.MatchString(compareInfo.ProjectCode)) {
  228. //未考虑MPC
  229. } else if info.LenPN > 18 && info.LenPC-len([]rune(compareInfo.ProjectCode)) != 0 {
  230. res = 1
  231. }
  232. case "BDC":
  233. if info.LenPN > 18 && info.LenPTC-len([]rune(compareInfo.ProjectCode)) != 0 {
  234. res = 1
  235. }
  236. case "CAA":
  237. if info.LenPC > 10 || info.LenPTC > 10 {
  238. res = 2
  239. } else {
  240. res = 1
  241. }
  242. case "CAB":
  243. if info.LenPC > 10 && info.LenPTC > 10 {
  244. res = 2
  245. } else {
  246. res = 1
  247. }
  248. case "CAC":
  249. if info.LenPC > 14 && math.Abs(float64(info.LenPN-len([]rune(compareInfo.ProjectName)))) > 4 {
  250. res = 1
  251. }
  252. case "CAD":
  253. if info.LenPC > 14 && math.Abs(float64(info.LenPN-len([]rune(compareInfo.ProjectName)))) > 4 {
  254. res = 1
  255. }
  256. case "CBA":
  257. if info.LenPC > 10 && info.LenPTC > 10 {
  258. res = 1
  259. }
  260. case "CBB":
  261. if info.LenPC > 10 && info.LenPTC > 10 {
  262. res = 1
  263. }
  264. case "CBC":
  265. if info.LenPC > 14 || (info.LenPC > 9 && !numCheckPc.MatchString(info.ProjectCode)) {
  266. res = 1
  267. }
  268. case "CBD":
  269. if info.LenPC > 14 || (info.LenPC > 10 && !numCheckPc.MatchString(info.ProjectCode)) {
  270. res = 1
  271. }
  272. case "CCA":
  273. if (info.LenPTC > 12 && !numCheckPc.MatchString(info.PTC)) || CheckHanAndNum(info.PTC) {
  274. res = 1
  275. }
  276. case "CCB":
  277. //
  278. case "CDA":
  279. if info.LenPTC > 10 || (info.LenPTC > 8 && !numCheckPc.MatchString(info.PTC)) || CheckHanAndNum(info.PTC) {
  280. res = 1
  281. }
  282. case "CDB":
  283. if info.LenPTC > 15 || (info.LenPTC > 12 && !numCheckPc.MatchString(info.PTC)) {
  284. res = 1
  285. }
  286. case "DAC":
  287. if info.LenPC > 12 || (info.LenPC > 10 && !numCheckPc.MatchString(info.ProjectCode)) || CheckHanAndNum(info.ProjectCode) {
  288. res = 1
  289. }
  290. case "DBC":
  291. if info.LenPC > 15 || (info.LenPC > 12 && !numCheckPc.MatchString(info.ProjectCode)) {
  292. res = 1
  293. }
  294. case "DCA":
  295. if info.LenPTC > 14 || (info.LenPTC > 10 && !numCheckPc.MatchString(info.PTC)) || CheckHanAndNum(info.PTC) {
  296. res = 1
  297. }
  298. case "DCB":
  299. //
  300. if !CheckHanAndNum(info.PTC) && !numCheckPc.MatchString(info.PTC) && info.LenPTC > 10 {
  301. res = 1
  302. }
  303. }
  304. }
  305. return
  306. }
  307. var nreg1 = regexp.MustCompile("[0-9]{2,}")
  308. var zreg1 = regexp.MustCompile("[a-zA-Z]{1,}")
  309. var hreg1 = regexp.MustCompile(`[\p{Han}]+`)
  310. func CheckHanAndNum(str string) (b bool) {
  311. return nreg1.MatchString(str) && hreg1.MatchString(str)
  312. }
  313. func CheckZimuAndNum(str string) (b bool) {
  314. return zreg1.MatchString(str) && nreg1.MatchString(str)
  315. }