merge_select.go 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. package main
  2. // "fmt"
  3. // 根据字符特征打分
  4. // 3为最高分,pj为评级 A AD A AA AA AB
  5. func Select(compareStr string, info *Info, compareInfo *ProjectCache) (res, pj int) {
  6. //没有可对比的项目名称、或项目编号 //评级
  7. if compareNoPass[compareStr] {
  8. } else {
  9. switch compareStr {
  10. case "AAA":
  11. res = 3
  12. pj = 3
  13. case "AAB":
  14. res = 3
  15. pj = 3
  16. case "ABA":
  17. res = 3
  18. pj = 3
  19. case "ABB":
  20. if info.LenPN > 10 || info.PCBH > 8 || info.PTCBH > 8 {
  21. res = 3
  22. } else {
  23. res = 2
  24. }
  25. pj = 3
  26. case "BAA":
  27. if info.PNBH > 10 || info.LenPC > 8 || info.LenPTC > 8 {
  28. res = 3
  29. } else {
  30. res = 2
  31. }
  32. pj = 3
  33. case "BAB":
  34. if info.PNBH > 10 || info.LenPTC > 8 || info.PTCBH > 8 {
  35. res = 3
  36. } else {
  37. res = 2
  38. }
  39. pj = 3
  40. case "BBA":
  41. if info.PNBH > 10 || info.PCBH > 8 || info.LenPC > 8 {
  42. res = 3
  43. } else {
  44. res = 2
  45. }
  46. pj = 3
  47. case "BBB":
  48. v := 0
  49. if info.PNBH > 10 {
  50. v++
  51. }
  52. if info.PCBH > 8 {
  53. v++
  54. }
  55. if info.PTCBH > 8 {
  56. v++
  57. }
  58. if v > 1 {
  59. res = 3
  60. } else {
  61. res = 2
  62. }
  63. pj = 2
  64. case "AAD":
  65. if info.LenPC > 8 || info.LenPN > 12 {
  66. res = 3
  67. } else {
  68. res = 2
  69. }
  70. pj = 3
  71. case "ABD":
  72. if info.LenPN > 10 && info.PCBH > 8 {
  73. res = 3
  74. pj = 2
  75. } else if info.LenPN > 10 || info.PCBH > 8 {
  76. res = 2
  77. pj = 3
  78. } else {
  79. res = 1
  80. pj = 3
  81. }
  82. case "BAD":
  83. if info.LenPC > 13 || (info.PNBH > 10 && info.LenPC > 8) {
  84. res = 3
  85. pj = 3
  86. } else if info.PNBH > 10 || info.LenPC > 8 {
  87. res = 2
  88. pj = 3
  89. } else {
  90. res = 1
  91. pj = 3
  92. }
  93. case "BBD":
  94. if info.PNBH > 12 && info.PCBH > 10 {
  95. res = 3
  96. pj = 1
  97. } else if info.PNBH > 10 && info.PCBH > 8 {
  98. res = 2
  99. pj = 3
  100. } else {
  101. res = 1
  102. pj = 3
  103. }
  104. case "ADA":
  105. if info.LenPN > 12 || (info.LenPTC > 8 && !StrOrNum2.MatchString(info.PTC)) {
  106. res = 3
  107. } else {
  108. res = 2
  109. }
  110. pj = 2
  111. case "ADB":
  112. if info.LenPN > 10 && info.PTCBH > 8 && !StrOrNum2.MatchString(info.PTC) {
  113. res = 3
  114. pj = 2
  115. } else if info.LenPN > 10 || info.PTCBH > 8 {
  116. res = 2
  117. pj = 3
  118. } else {
  119. res = 1
  120. pj = 3
  121. }
  122. case "BDA":
  123. if info.PNBH > 10 && info.LenPTC > 8 && !StrOrNum2.MatchString(info.PTC) {
  124. res = 3
  125. pj = 2
  126. } else if info.PNBH > 10 || info.LenPTC > 8 {
  127. res = 2
  128. pj = 3
  129. } else {
  130. res = 1
  131. pj = 3
  132. }
  133. case "BDB":
  134. if info.PNBH > 12 && info.PTCBH > 10 && !StrOrNum2.MatchString(info.PTC) {
  135. res = 3
  136. } else if info.PNBH > 10 && info.PTCBH > 8 {
  137. res = 2
  138. } else {
  139. res = 1
  140. }
  141. pj = 2
  142. case "ADD":
  143. if info.LenPN > 18 {
  144. res = 3
  145. pj = 2
  146. } else if info.LenPN > 10 {
  147. res = 2
  148. pj = 2
  149. } else {
  150. res = 1
  151. pj = 2
  152. }
  153. case "BDD":
  154. if CheckContain(info.ProjectName, compareInfo.ProjectName) != 3 {
  155. if info.PNBH > 10 {
  156. res = 2
  157. } else {
  158. res = 1
  159. }
  160. pj = 1
  161. }
  162. case "DAA":
  163. if info.LenPTC > 8 || info.LenPC > 8 {
  164. res = 3
  165. pj = 2
  166. } else {
  167. res = 2
  168. pj = 3
  169. }
  170. case "DAB":
  171. if info.LenPC > 8 && info.PTCBH > 8 {
  172. res = 3
  173. pj = 2
  174. } else if info.LenPC > 8 || info.PTCBH > 8 {
  175. res = 2
  176. pj = 3
  177. } else {
  178. res = 1
  179. pj = 3
  180. }
  181. case "DAD":
  182. if info.LenPC > 14 && !StrOrNum2.MatchString(info.ProjectCode) {
  183. res = 3
  184. pj = 2
  185. } else if info.LenPC > 8 {
  186. res = 2
  187. pj = 2
  188. } else {
  189. res = 1
  190. pj = 2
  191. }
  192. case "DBA":
  193. if info.PCBH > 8 && info.LenPC > 8 && !StrOrNum2.MatchString(info.PTC) {
  194. res = 3
  195. pj = 2
  196. } else if info.PCBH > 8 || info.LenPC > 8 {
  197. res = 2
  198. pj = 2
  199. } else {
  200. res = 1
  201. pj = 3
  202. }
  203. case "DBB":
  204. if info.PCBH > 10 && info.PTCBH > 10 && !StrOrNum2.MatchString(info.ProjectCode) {
  205. res = 3
  206. pj = 1
  207. } else if info.PCBH > 8 && info.PTCBH > 8 {
  208. res = 2
  209. pj = 2
  210. } else {
  211. res = 1
  212. pj = 3
  213. }
  214. case "DBD":
  215. if info.PCBH > 12 && !StrOrNum2.MatchString(info.ProjectCode) {
  216. res = 2
  217. pj = 1
  218. } else {
  219. res = 1
  220. pj = 1
  221. }
  222. case "DDA":
  223. if info.LenPTC > 14 && !StrOrNum2.MatchString(info.PTC) {
  224. res = 3
  225. pj = 1
  226. } else if info.LenPTC > 8 {
  227. res = 2
  228. pj = 1
  229. } else {
  230. res = 1
  231. pj = 2
  232. }
  233. case "DDB":
  234. if info.PTCBH > 12 && !StrOrNum2.MatchString(info.PTC) {
  235. res = 2
  236. } else {
  237. res = 1
  238. }
  239. pj = 1
  240. case "ACA":
  241. if info.LenPN > 10 && info.LenPTC > 8 && info.LenPC != len([]rune(compareInfo.ProjectCode)) && !StrOrNum2.MatchString(info.PTC) {
  242. res = 3
  243. pj = 2
  244. } else if info.LenPN > 10 || info.LenPTC > 8 {
  245. res = 2
  246. pj = 2
  247. } else {
  248. res = 1
  249. pj = 3
  250. }
  251. case "ACB":
  252. if info.LenPN > 10 && info.PTCBH > 8 && info.LenPC != len([]rune(compareInfo.ProjectCode)) && !StrOrNum2.MatchString(info.PTC) {
  253. res = 3
  254. pj = 2
  255. } else if info.LenPN > 10 || info.PTCBH > 8 {
  256. res = 2
  257. pj = 2
  258. } else {
  259. res = 1
  260. pj = 3
  261. }
  262. case "BCA":
  263. if (info.PNBH > 10 && info.LenPTC > 8) || info.LenPTC > 12 && info.LenPC != len([]rune(compareInfo.ProjectCode)) && !StrOrNum2.MatchString(info.PTC) {
  264. res = 3
  265. pj = 2
  266. } else if info.PNBH > 10 || info.LenPTC > 8 {
  267. res = 2
  268. pj = 2
  269. } else {
  270. res = 1
  271. pj = 3
  272. }
  273. case "BCB":
  274. if info.PNBH > 12 && info.PTCBH > 12 && info.LenPC != len([]rune(compareInfo.ProjectCode)) && !StrOrNum2.MatchString(info.PTC) {
  275. res = 3
  276. pj = 1
  277. } else if info.PNBH > 10 || info.PTCBH > 8 {
  278. res = 2
  279. pj = 2
  280. } else {
  281. res = 1
  282. pj = 2
  283. }
  284. case "AAC":
  285. if (info.LenPN > 10 && info.LenPC > 8) || info.LenPN > 14 || (info.LenPC > 10 && !StrOrNum2.MatchString(info.ProjectCode)) {
  286. res = 3
  287. pj = 3
  288. } else {
  289. res = 2
  290. pj = 3
  291. }
  292. case "ABC":
  293. if info.LenPN > 14 && info.PCBH > 10 && !StrOrNum2.MatchString(info.ProjectCode) {
  294. res = 3
  295. pj = 2
  296. } else if info.LenPN > 10 || info.PCBH > 8 {
  297. res = 2
  298. pj = 3
  299. } else {
  300. res = 1
  301. pj = 3
  302. }
  303. case "BAC":
  304. if info.PNBH > 14 && info.LenPC > 8 && !StrOrNum2.MatchString(info.ProjectCode) {
  305. res = 3
  306. pj = 2
  307. } else if info.PNBH > 10 || info.LenPC > 8 {
  308. res = 2
  309. pj = 3
  310. } else {
  311. res = 1
  312. pj = 3
  313. }
  314. case "BBC":
  315. if info.PNBH > 14 && info.PCBH > 10 && !StrOrNum2.MatchString(info.ProjectCode) {
  316. res = 3
  317. pj = 1
  318. } else if info.PNBH > 10 || info.PCBH > 8 {
  319. res = 2
  320. pj = 2
  321. } else {
  322. res = 1
  323. pj = 2
  324. }
  325. case "ACC":
  326. if info.LenPC != len([]rune(compareInfo.ProjectCode)) {
  327. if info.LenPN > 16 {
  328. res = 2
  329. pj = 1
  330. } else {
  331. res = 1
  332. pj = 2
  333. }
  334. }
  335. case "ACD":
  336. //项目编号不一致
  337. //fmt.Println(info.LenPC, info.ProjectCode, "--", len([]rune(compareInfo.ProjectCode), compareInfo.ProjectCode, info.LenPC != len([]rune(compareInfo.ProjectCode)))
  338. if info.LenPC != len([]rune(compareInfo.ProjectCode)) {
  339. if info.LenPN > 16 {
  340. res = 2
  341. } else {
  342. res = 1
  343. }
  344. pj = 1
  345. }
  346. //测试的,没有用
  347. // res = 2
  348. // pj = 2
  349. case "ADC":
  350. if info.LenPN > 16 {
  351. res = 2
  352. } else {
  353. res = 1
  354. }
  355. pj = 1
  356. case "BCC":
  357. //项目编号不一致
  358. if info.LenPC != len([]rune(compareInfo.ProjectCode)) {
  359. if info.PNBH > 12 {
  360. res = 1
  361. }
  362. pj = 1
  363. }
  364. case "BCD":
  365. //项目编号不一致
  366. if info.LenPC != len([]rune(compareInfo.ProjectCode)) {
  367. if info.PNBH > 8 {
  368. res = 1
  369. }
  370. pj = 1
  371. }
  372. case "BDC":
  373. if info.PNBH > 7 {
  374. res = 1
  375. }
  376. pj = 1
  377. case "CAA":
  378. if info.LenPC > 12 || info.LenPTC > 12 {
  379. res = 3
  380. pj = 2
  381. } else if info.LenPC > 8 || info.LenPTC > 8 {
  382. res = 2
  383. pj = 3
  384. } else {
  385. res = 1
  386. pj = 3
  387. }
  388. case "CAB":
  389. if info.LenPC > 12 && info.PTCBH > 8 {
  390. res = 3
  391. pj = 2
  392. } else if info.LenPC > 12 || info.PTCBH > 8 {
  393. res = 2
  394. pj = 3
  395. } else {
  396. res = 1
  397. pj = 3
  398. }
  399. case "CAC":
  400. if info.LenPC > 9 && !StrOrNum2.MatchString(info.ProjectCode) {
  401. res = 2
  402. pj = 2
  403. } else {
  404. res = 1
  405. pj = 1
  406. }
  407. case "CAD":
  408. if info.LenPC > 9 && !StrOrNum2.MatchString(info.ProjectCode) {
  409. res = 2
  410. } else {
  411. res = 1
  412. }
  413. pj = 1
  414. case "CBA":
  415. if info.LenPTC > 14 && info.PCBH > 12 {
  416. res = 3
  417. pj = 2
  418. } else if info.LenPTC > 12 || info.PCBH > 10 {
  419. res = 2
  420. pj = 2
  421. } else {
  422. res = 1
  423. pj = 2
  424. }
  425. case "CBB":
  426. if info.PCBH > 13 && info.PTCBH > 13 {
  427. res = 3
  428. pj = 1
  429. } else if info.PCBH > 9 || info.PTCBH > 9 {
  430. res = 2
  431. pj = 2
  432. } else {
  433. res = 1
  434. pj = 2
  435. }
  436. case "CBC":
  437. if info.PCBH > 14 && !StrOrNum2.MatchString(info.ProjectCode) {
  438. res = 2
  439. } else if info.PCBH > 5 {
  440. res = 1
  441. }
  442. pj = 1
  443. case "CBD":
  444. if info.PCBH > 14 && !StrOrNum2.MatchString(info.ProjectCode) {
  445. res = 2
  446. } else if info.PCBH > 5 {
  447. res = 1
  448. }
  449. pj = 1
  450. case "CCA":
  451. if info.LenPC != len([]rune(compareInfo.ProjectCode)) {
  452. if info.LenPTC > 12 && !StrOrNum2.MatchString(info.PTC) {
  453. res = 2
  454. } else if info.LenPTC > 5 {
  455. res = 1
  456. }
  457. pj = 1
  458. }
  459. case "CCB":
  460. if info.LenPC != len([]rune(compareInfo.ProjectCode)) {
  461. if info.PTCBH > 10 && !StrOrNum2.MatchString(info.PTC) {
  462. res = 1
  463. }
  464. pj = 1
  465. }
  466. case "CDA":
  467. if info.LenPTC > 12 && !StrOrNum2.MatchString(info.PTC) {
  468. res = 2
  469. } else {
  470. res = 1
  471. }
  472. pj = 1
  473. case "CDB":
  474. if info.PTCBH > 10 && !StrOrNum2.MatchString(info.PTC) {
  475. res = 1
  476. pj = 1
  477. }
  478. case "DAC":
  479. if info.LenPC > 13 && !StrOrNum2.MatchString(info.ProjectCode) {
  480. res = 3
  481. } else if info.LenPC > 8 {
  482. res = 2
  483. } else {
  484. res = 1
  485. }
  486. pj = 1
  487. case "DBC":
  488. if info.PCBH > 8 {
  489. res = 1
  490. }
  491. pj = 1
  492. case "DCA":
  493. if info.LenPC != len([]rune(compareInfo.ProjectCode)) {
  494. if info.LenPTC > 10 {
  495. res = 2
  496. } else {
  497. res = 1
  498. }
  499. pj = 1
  500. }
  501. case "DCB":
  502. if info.LenPC != len([]rune(compareInfo.ProjectCode)) {
  503. if info.PTCBH > 8 && !StrOrNum2.MatchString(info.PTC) {
  504. res = 1
  505. }
  506. pj = 1
  507. }
  508. }
  509. }
  510. // fmt.Println("end:", pj, res)
  511. return
  512. }