remark.go 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625
  1. package front
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/shopspring/decimal"
  6. "go.mongodb.org/mongo-driver/bson"
  7. "math"
  8. mgo "mongodb"
  9. qu "qfw/util"
  10. "regexp"
  11. "sort"
  12. "strconv"
  13. "strings"
  14. "sync"
  15. "time"
  16. "util"
  17. )
  18. var (
  19. purchasingField = map[string]string{"itemname": "名称", "brandname": "品牌", "modal": "型号", "unitprice": "单价", "number": "数量"}
  20. )
  21. func (f *Front) RemarkList() {
  22. qu.Catch()
  23. pid := qu.ObjToString(f.GetString("pid"))
  24. tid := qu.ObjToString(f.GetString("tid"))
  25. if f.Method() == "POST" {
  26. //user := f.GetSession("user").(map[string]interface{})
  27. start, _ := f.GetInteger("start")
  28. limit, _ := f.GetInteger("length")
  29. draw, _ := f.GetInteger("draw")
  30. searchStr := f.GetString("search[value]")
  31. search := strings.TrimSpace(searchStr)
  32. query := map[string]interface{}{"s_usertaskid": tid}
  33. ckdata, err := f.GetInteger("i_ckdata")
  34. if err != nil {
  35. ckdata = -1
  36. }
  37. if ckdata == 0 {
  38. query["b_istag"] = false
  39. } else if ckdata == 1 {
  40. query["b_istag"] = true
  41. }
  42. if search != "" {
  43. query["$or"] = []interface{}{
  44. bson.M{"v_baseinfo.title": bson.M{"$regex": search}},
  45. }
  46. }
  47. field := map[string]interface{}{"v_baseinfo.title": 1, "b_istag": 1, "i_ckdata": 1}
  48. info, _ := util.Mgo.Find(util.DATACOLLNAME, query, `{"_id": 1}`, field, false, start, limit)
  49. count := util.Mgo.Count(util.DATACOLLNAME, query)
  50. f.ServeJson(map[string]interface{}{
  51. "draw": draw,
  52. "data": *info,
  53. "recordsFiltered": count,
  54. "recordsTotal": count,
  55. })
  56. } else {
  57. f.T["pid"] = pid
  58. f.T["tid"] = tid
  59. _ = f.Render("project/remark_list.html", &f.T)
  60. }
  61. }
  62. func (f *Front) RemarkDetail() {
  63. pid := f.GetString("pid")
  64. tid := f.GetString("tid")
  65. did := f.GetString("did")
  66. project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, `{"v_fields": 1}`)
  67. fs, _ := (*project)["v_fields"].([]interface{})
  68. rep := getDetail(did, "remark", qu.ObjArrToMapArr(fs)) //获取本条公告的信息
  69. f.T["otherInfo"] = rep["otherInfo"] //展示关联公告信息
  70. f.T["moreInfo"] = rep["moreInfo"] //更多关联公告信息
  71. f.T["pid"] = pid
  72. f.T["tid"] = tid
  73. f.T["did"] = did
  74. f.T["info"] = rep["info"]
  75. f.T["common"] = rep["common"]
  76. f.T["other"] = rep["other"]
  77. f.T["ck_pclistag"] = rep["purchasingTag"]
  78. f.T["enbArr"] = rep["enbArr"]
  79. if rep["pru"] != nil {
  80. m := rep["pru"].(map[string]interface{})
  81. f.T["purchasinglist"] = m["purchasinglist"]
  82. f.T["pcl_new"] = m["pcl_new"]
  83. f.T["PurchasinglistField"] = m["field"]
  84. }
  85. if rep["proc"] != nil {
  86. m := rep["proc"].(map[string]interface{})
  87. f.T["procurementlist"] = m["procurementlist"]
  88. f.T["pcl_new_1"] = m["pcl_new_1"]
  89. f.T["ProcurementlistField"] = m["field"]
  90. }
  91. if rep["pkg"] != nil {
  92. m := rep["pkg"].(map[string]interface{})
  93. f.T["packs"] = m["packs"]
  94. f.T["packskey"] = m["packskey"]
  95. f.T["pkg_new"] = m["pkg_new"]
  96. f.T["PackageField"] = m["field"]
  97. }
  98. if rep["wino"] != nil {
  99. m := rep["wino"].(map[string]interface{})
  100. f.T["worder"] = m["worder"]
  101. f.T["worder_new"] = m["worder_new"]
  102. f.T["WinnerorderField"] = m["field"]
  103. }
  104. f.T["topsubtype"] = util.TopSubStypeArr2
  105. f.T["ck_purchasinglist"] = rep["ck_purchasinglist"]
  106. f.T["ck_package"] = rep["ck_package"]
  107. f.T["ck_winnerorder"] = rep["ck_winnerorder"]
  108. f.T["keyword"] = rep["matchkey"]
  109. f.T["nextid"] = GetNextDataId(did, tid) //下一条id
  110. f.T["lastid"] = GetLastDataId(did, tid) //上一条id
  111. _ = f.Render("project/remark_detail.html", &f.T)
  112. }
  113. func getDetail(id, stype string, fs []map[string]interface{}) map[string]interface{} {
  114. rep := map[string]interface{}{}
  115. infoTmp, _ := util.Mgo.FindById(util.DATACOLLNAME, id, ``)
  116. rep["s_excp_info"] = (*infoTmp)["s_excp_info"]
  117. baseInfo := (*infoTmp)["v_baseinfo"].(map[string]interface{}) //字段值
  118. var bzInfo map[string]interface{} //标注信息
  119. if (*infoTmp)["v_taginfo"] != nil {
  120. bzInfo = (*infoTmp)["v_taginfo"].(map[string]interface{})
  121. } else {
  122. bzInfo = make(map[string]interface{})
  123. }
  124. baseInfo["detail"] = qu.ObjToString(baseInfo["title"]) + "</br>" + qu.ObjToString(baseInfo["detail"])
  125. baseInfo["_id"] = mgo.BsonIdToSId(baseInfo["_id"])
  126. purchasingTag, _ := baseInfo["purchasinglist_alltag"].(bool)
  127. rep["purchasingTag"] = purchasingTag
  128. href := qu.ObjToString(baseInfo["href"])
  129. if !strings.HasPrefix(href, "http") {
  130. baseInfo["href"] = "https://" + href
  131. }
  132. rep["matchkey"] = baseInfo["matchkey"]
  133. rep["info"] = baseInfo
  134. common, other, pruM, proM, pkgM, winM, enbArr := setExtComMap(baseInfo, bzInfo, fs, stype)
  135. rep["common"] = common
  136. rep["other"] = other
  137. rep["pkg"] = pkgM // 多包信息
  138. rep["pru"] = pruM //标的物
  139. rep["proc"] = proM //采购意向
  140. rep["wino"] = winM //中标候选人
  141. otherInfo, moreInfo := setOtherInfo(baseInfo) //处理公告关联信息
  142. rep["enbArr"] = enbArr
  143. rep["otherInfo"] = otherInfo
  144. rep["moreInfo"] = moreInfo
  145. //
  146. if bzInfo["purchasinglist"] != nil {
  147. rep["ck_purchasinglist"] = "1"
  148. } else {
  149. rep["ck_purchasinglist"] = "-1"
  150. }
  151. if bzInfo["package"] != nil {
  152. rep["ck_package"] = "1"
  153. } else {
  154. rep["ck_package"] = "-1"
  155. }
  156. if bzInfo["winnerorder"] != nil {
  157. rep["ck_winnerorder"] = "1"
  158. } else {
  159. rep["ck_winnerorder"] = "-1"
  160. }
  161. return rep
  162. }
  163. // 拼装抽取common值
  164. func setExtComMap(info, bzInfo map[string]interface{}, fs []map[string]interface{}, stype string) ([]interface{}, []interface{},
  165. map[string]interface{}, map[string]interface{}, map[string]interface{}, map[string]interface{}, []string) {
  166. var common []interface{} // 基本字段信息
  167. var other []interface{} //自定义字段信息
  168. purM := make(map[string]interface{}) // 标的物信息
  169. proM := make(map[string]interface{}) // 采购意向信息
  170. pkgM := make(map[string]interface{}) // 多包信息
  171. winM := make(map[string]interface{}) // 中标候选
  172. var enbArr []string //标的物信息、采购意向信息、多包信息、中标候选字段隐藏
  173. //基本参数
  174. for _, v := range fs {
  175. key := qu.ObjToString(v["key"])
  176. if key == "purchasinglist" {
  177. if v["child"] != nil {
  178. enbArr = append(enbArr, key)
  179. child := qu.ObjArrToMapArr(v["child"].([]interface{}))
  180. purchasinglist, isNewStatus := setPurchasingMap(info, child, stype)
  181. purM["purchasinglist"] = purchasinglist
  182. purM["pcl_new"] = isNewStatus
  183. var m []map[string]string
  184. for _, v := range child {
  185. key := qu.ObjToString(v["key"])
  186. descript := qu.ObjToString(v["descript"])
  187. m = append(m, map[string]string{key: descript})
  188. }
  189. purM["field"] = m
  190. }
  191. } else if key == "procurementlist" {
  192. if v["child"] != nil {
  193. enbArr = append(enbArr, key)
  194. child := qu.ObjArrToMapArr(v["child"].([]interface{}))
  195. purchasinglist_1, isNewStatus1 := setPurchasingMap1(info, child, stype)
  196. proM["procurementlist"] = purchasinglist_1
  197. proM["pcl_new_1"] = isNewStatus1
  198. var m []map[string]string
  199. for _, v := range child {
  200. key := qu.ObjToString(v["key"])
  201. descript := qu.ObjToString(v["descript"])
  202. m = append(m, map[string]string{key: descript})
  203. }
  204. proM["field"] = m
  205. }
  206. } else if key == "package" {
  207. if v["child"] != nil {
  208. enbArr = append(enbArr, key)
  209. child := qu.ObjArrToMapArr(v["child"].([]interface{}))
  210. packs, packskey, pkg_new := setPaceMap(info, child, stype)
  211. pkgM["packs"] = packs
  212. pkgM["packskey"] = packskey
  213. pkgM["pkg_new"] = pkg_new
  214. var m []map[string]string
  215. for _, v := range child {
  216. key := qu.ObjToString(v["key"])
  217. descript := qu.ObjToString(v["descript"])
  218. m = append(m, map[string]string{key: descript})
  219. }
  220. pkgM["field"] = m
  221. }
  222. } else if key == "winnerorder" {
  223. if v["child"] != nil {
  224. enbArr = append(enbArr, key)
  225. child := qu.ObjArrToMapArr(v["child"].([]interface{}))
  226. worder, worderNew := setWorderMap(info, child, stype)
  227. winM["worder"] = worder
  228. winM["worder_new"] = worderNew
  229. var m []map[string]string
  230. for _, v := range child {
  231. key := qu.ObjToString(v["key"])
  232. descript := qu.ObjToString(v["descript"])
  233. m = append(m, map[string]string{key: descript})
  234. }
  235. winM["field"] = m
  236. }
  237. } else if key == "extend" {
  238. if v["child"] != nil {
  239. enbArr = append(enbArr, key)
  240. for _, tm := range qu.ObjArrToMapArr(v["child"].([]interface{})) {
  241. if stype == "remark" {
  242. tm["status"] = "1"
  243. } else {
  244. tm["status"] = "-1"
  245. }
  246. tm["value"] = info[qu.ObjToString(tm["key"])]
  247. other = append(other, tm)
  248. }
  249. }
  250. } else {
  251. if key == "bidopentime" || key == "publishtime" || key == "bidendtime" || key == "project_startdate" ||
  252. key == "project_completedate" || key == "signaturedate" {
  253. tmpTime := qu.Int64All(info[key])
  254. if tmpTime > 0 {
  255. v["value"] = qu.FormatDateByInt64(&tmpTime, qu.Date_Full_Layout)
  256. } else {
  257. v["value"] = info[key]
  258. }
  259. } else if key == "subtype" {
  260. if info["toptype"] != nil && info["subtype"] != nil {
  261. v["value"] = qu.ObjToString(info["toptype"]) + "-" + qu.ObjToString(info[fmt.Sprint(v["key"])])
  262. } else {
  263. v["value"] = ""
  264. }
  265. } else {
  266. v["value"] = info[key]
  267. }
  268. if stype == "remark" {
  269. v["status"] = "1"
  270. } else {
  271. v["status"] = "-1"
  272. }
  273. common = append(common, v)
  274. }
  275. }
  276. if len(common) > 0 {
  277. enbArr = append(enbArr, "common")
  278. }
  279. return common, other, purM, proM, pkgM, winM, enbArr
  280. }
  281. var mm = map[string]string{
  282. "itemname": "产品名称",
  283. "brandname": "品牌",
  284. "madel": "型号",
  285. "unitname": "计量单位",
  286. "unitprice": "单价",
  287. "number": "数量",
  288. "totalprice": "总价",
  289. "departroom": "科室",
  290. }
  291. // 拼装子包信息
  292. func setPaceMap(info map[string]interface{}, confpack []map[string]interface{}, stype string) ([]map[string]interface{}, []string, []bool) {
  293. //bzpack := bzInfo["package"].(map[string]interface{})
  294. packs := map[string]map[string]interface{}{}
  295. var sortpackskey []string
  296. isNewPkg := map[string]bool{} //记录子包是否是新增的
  297. if packages, ok := info["package"].(map[string]interface{}); ok && len(packages) > 0 {
  298. for k, tmpackage := range packages { //遍历分包
  299. if tmppack, ok := tmpackage.(map[string]interface{}); ok {
  300. isNew, _ := tmppack["isnew"].(bool)
  301. status := "-1"
  302. if stype == "remark" && tmppack["package_son"] != nil {
  303. status = "1"
  304. }
  305. isNewPkg[k] = isNew
  306. sortpackskey = append(sortpackskey, k)
  307. var pack []interface{}
  308. for _, cpack := range confpack {
  309. key := qu.ObjToString(cpack["key"])
  310. if key == "winner" || key == "bidamount" { //中标单位和中标金额winner_all特殊处理
  311. continue
  312. }
  313. tp := map[string]interface{}{
  314. "key": key,
  315. "descript": cpack["descript"],
  316. }
  317. if tmppack[key] != nil {
  318. tp["value"] = tmppack[key]
  319. } else {
  320. tp["value"] = ""
  321. }
  322. tp["status"] = status
  323. pack = append(pack, tp)
  324. }
  325. //特殊处理中标单位和中标金额
  326. winnerall := []interface{}{}
  327. if tmpWinnerAll, ok := tmppack["winner_all"].([]interface{}); ok && len(tmpWinnerAll) > 0 {
  328. for _, tmp := range tmpWinnerAll {
  329. tmpMap := tmp.(map[string]interface{})
  330. win := map[string]interface{}{
  331. "descript": "标段(包)中标单位",
  332. "key": "winner",
  333. "status": status,
  334. "value": qu.ObjToString(tmpMap["winner"]),
  335. }
  336. winnerall = append(winnerall, win)
  337. var bidamount interface{}
  338. if tmpMap["bidamount"] == nil {
  339. bidamount = ""
  340. } else {
  341. bidamount = strconv.FormatFloat(qu.Float64All(tmpMap["bidamount"]), 'f', -1, 64)
  342. }
  343. bid := map[string]interface{}{
  344. "descript": "标段(包)中标金额",
  345. "key": "bidamount",
  346. "status": status,
  347. "value": bidamount,
  348. }
  349. winnerall = append(winnerall, bid)
  350. }
  351. } else {
  352. winnerall = append(winnerall, map[string]interface{}{
  353. "descript": "标段(包)中标单位",
  354. "key": "winner",
  355. "status": "-1",
  356. "value": "",
  357. })
  358. winnerall = append(winnerall, map[string]interface{}{
  359. "descript": "标段(包)中标金额",
  360. "key": "bidamount",
  361. "status": "-1",
  362. "value": "",
  363. })
  364. }
  365. // 子包 标的物
  366. var p_inputs []interface{}
  367. if plist, o1 := tmppack["purchasinglist"].([]interface{}); o1 {
  368. for _, v := range plist {
  369. var inputs []interface{}
  370. v1 := v.(map[string]interface{})
  371. for key, value := range v1 {
  372. tp := map[string]interface{}{
  373. "key": key,
  374. "descript": mm[key],
  375. }
  376. tp["value"] = value
  377. tp["status"] = status
  378. inputs = append(inputs, tp)
  379. }
  380. p_inputs = append(p_inputs, inputs)
  381. }
  382. }
  383. packs[k] = map[string]interface{}{
  384. "pack": pack,
  385. "packstatus": status,
  386. "winnerall": winnerall,
  387. "purchasinglist": p_inputs,
  388. }
  389. }
  390. }
  391. }
  392. sort.Strings(sortpackskey)
  393. var packages []map[string]interface{}
  394. var isNewPkgArr []bool
  395. for _, v := range sortpackskey {
  396. packages = append(packages, packs[v])
  397. isNewPkgArr = append(isNewPkgArr, isNewPkg[v])
  398. }
  399. return packages, sortpackskey, isNewPkgArr
  400. }
  401. // 拼装标的物
  402. func setPurchasingMap(info map[string]interface{}, pur []map[string]interface{}, stype string) ([]interface{}, []map[string]interface{}) {
  403. var purchasinglists []interface{}
  404. //isNewPcl := []bool{} //记录子包是否是新增的
  405. var isNewAndStatus []map[string]interface{}
  406. if tmpcls, ok := info["purchasinglist"].([]interface{}); ok {
  407. for _, v := range tmpcls {
  408. if pcl, ok := v.(map[string]interface{}); ok {
  409. //isNew, _ := pcl["isnew"].(bool)
  410. isNew := false
  411. status := "-1"
  412. if stype == "remark" && pcl["purchasinglist_son"] != nil {
  413. status = "1"
  414. }
  415. //isNewPcl = append(isNewPcl, isNew)
  416. isNewAndStatus = append(isNewAndStatus, map[string]interface{}{"isnew": isNew, "status": status})
  417. var pcls []interface{}
  418. for _, ps := range pur {
  419. value := pcl[qu.ObjToString(ps["key"])]
  420. if value == nil {
  421. value = ""
  422. }
  423. tp := map[string]interface{}{
  424. "key": ps["key"],
  425. "descript": ps["descript"],
  426. "value": value,
  427. "status": status,
  428. }
  429. // if pcl[preKey+fmt.Sprint(tp["key"])] == nil {
  430. // tp["status"] = "-1"
  431. // } else {
  432. // tp["status"] = "1"
  433. // }
  434. pcls = append(pcls, tp)
  435. }
  436. purchasinglists = append(purchasinglists, pcls)
  437. }
  438. }
  439. }
  440. return purchasinglists, isNewAndStatus
  441. }
  442. // 采购意向
  443. func setPurchasingMap1(info map[string]interface{}, pro []map[string]interface{}, stype string) ([]interface{}, []map[string]interface{}) {
  444. var procurementlists []interface{}
  445. //isNewPcl := []bool{} //记录子包是否是新增的
  446. var isNewAndStatus []map[string]interface{}
  447. if tmpcls, ok := info["procurementlist"].([]interface{}); ok {
  448. for _, v := range tmpcls {
  449. if pcl, ok := v.(map[string]interface{}); ok {
  450. //isNew, _ := pcl["isnew"].(bool)
  451. isNew := false
  452. status := "-1"
  453. if stype == "remark" && pcl["purchasinglist_son"] != nil {
  454. status = "1"
  455. }
  456. //isNewPcl = append(isNewPcl, isNew)
  457. isNewAndStatus = append(isNewAndStatus, map[string]interface{}{"isnew": isNew, "status": status})
  458. var pcls []interface{}
  459. for _, ps := range pro {
  460. value := pcl[qu.ObjToString(ps["key"])]
  461. if value == nil {
  462. value = ""
  463. }
  464. tp := map[string]interface{}{
  465. "key": ps["key"],
  466. "descript": ps["descript"],
  467. "value": value,
  468. "status": status,
  469. }
  470. // if pcl[preKey+fmt.Sprint(tp["key"])] == nil {
  471. // tp["status"] = "-1"
  472. // } else {
  473. // tp["status"] = "1"
  474. // }
  475. pcls = append(pcls, tp)
  476. }
  477. procurementlists = append(procurementlists, pcls)
  478. }
  479. }
  480. }
  481. return procurementlists, isNewAndStatus
  482. }
  483. // 拼装中标候选人
  484. func setWorderMap(info map[string]interface{}, winnerorder []map[string]interface{}, stype string) ([]interface{}, []map[string]interface{}) {
  485. //基本参数--中标候选人
  486. worders := []interface{}{}
  487. isNewAndStatus := []map[string]interface{}{}
  488. if tmpwds, ok := info["winnerorder"].([]interface{}); ok {
  489. for _, v := range tmpwds {
  490. if wd, ok := v.(map[string]interface{}); ok {
  491. //isNew, _ := wd["isnew"].(bool)
  492. isNew := false
  493. status := "-1"
  494. if stype == "remark" && wd["winnerorder_son"] != nil {
  495. status = "1"
  496. }
  497. isNewAndStatus = append(isNewAndStatus, map[string]interface{}{"isnew": isNew, "status": status})
  498. wds := []interface{}{}
  499. for _, cp := range winnerorder {
  500. value := wd[qu.ObjToString(cp["key"])]
  501. if value == nil {
  502. value = ""
  503. }
  504. tp := map[string]interface{}{
  505. "key": cp["key"],
  506. "descript": cp["descript"],
  507. "value": value,
  508. "status": status,
  509. }
  510. wds = append(wds, tp)
  511. }
  512. worders = append(worders, wds)
  513. }
  514. }
  515. }
  516. return worders, isNewAndStatus
  517. }
  518. // 获取公告关联信息
  519. func setOtherInfo(info map[string]interface{}) (result, moreArr []map[string]interface{}) {
  520. if otherInfo, ok := info["info"].([]interface{}); ok && len(otherInfo) > 0 {
  521. //中标,成交、合同、招标(不含变更)
  522. /*
  523. [
  524. {},
  525. {},
  526. ]
  527. */
  528. zbArr := []map[string]interface{}{}
  529. cjArr := []map[string]interface{}{}
  530. htArr := []map[string]interface{}{}
  531. zbbArr := []map[string]interface{}{}
  532. for _, tmp := range otherInfo {
  533. tmpInfo := tmp.(map[string]interface{})
  534. tmpInfo["detail"] = qu.ObjToString(tmpInfo["title"]) + "</br>" + qu.ObjToString(tmpInfo["title"])
  535. toptype := tmpInfo["toptype"]
  536. subtype := tmpInfo["subtype"]
  537. ptime := ""
  538. tmpPtime := qu.Int64All(tmpInfo["publishtime"])
  539. if tmpPtime > 0 {
  540. ptime = qu.FormatDateByInt64(&tmpPtime, qu.Date_Full_Layout)
  541. }
  542. tmpInfo["publishtime_str"] = ptime
  543. if subtype == "中标" {
  544. zbArr = append(zbArr, tmpInfo)
  545. } else if subtype == "成交" {
  546. cjArr = append(cjArr, tmpInfo)
  547. } else if subtype == "合同" {
  548. htArr = append(htArr, tmpInfo)
  549. } else if toptype == "招标" && subtype != "变更" {
  550. zbbArr = append(zbbArr, tmpInfo)
  551. } else { //标注页不展示的信息,更多中展示
  552. moreArr = append(moreArr, map[string]interface{}{
  553. "publishtime": tmpInfo["publishtime_str"],
  554. "subtype": subtype,
  555. "title": tmpInfo["title"],
  556. "href": util.GetJyHref(qu.ObjToString(tmpInfo["id"])),
  557. })
  558. }
  559. }
  560. publishtime := qu.Float64All(info["publishtime"])
  561. //中标信息
  562. if zbLen := len(zbArr); zbLen > 0 {
  563. rzb := DealData(zbLen, publishtime, zbArr, &moreArr)
  564. result = append(result, rzb)
  565. }
  566. //成交
  567. if cjLen := len(cjArr); cjLen > 0 {
  568. rcj := DealData(cjLen, publishtime, cjArr, &moreArr)
  569. result = append(result, rcj)
  570. }
  571. //合同
  572. if htLen := len(htArr); htLen > 0 {
  573. rht := DealData(htLen, publishtime, htArr, &moreArr)
  574. result = append(result, rht)
  575. }
  576. result = append(result, zbbArr...)
  577. }
  578. return
  579. }
  580. func DealData(tmpLen int, publishtime float64, tmp []map[string]interface{}, moreArr *[]map[string]interface{}) (resultTmp map[string]interface{}) {
  581. if tmpLen == 1 || publishtime <= 0 { //相同类型只有一条或者原公告发布时间异常取第一条公告
  582. resultTmp = tmp[0]
  583. for _, t := range tmp[1:] { //将过滤掉的数据加入到更多中
  584. *moreArr = append(*moreArr, map[string]interface{}{
  585. "publishtime": t["publishtime_str"],
  586. "subtype": t["subtype"],
  587. "title": t["title"],
  588. "href": util.GetJyHref(qu.ObjToString(t["id"])),
  589. })
  590. }
  591. return
  592. } else {
  593. diff := float64(0) //记录差值
  594. index := 0
  595. for i, zb := range tmp {
  596. pTmp := qu.Float64All(zb["publishtime"])
  597. diffTmp := math.Abs(publishtime - pTmp) //绝对值
  598. if i == 0 {
  599. diff = diffTmp
  600. } else if diffTmp < diff { //记录较小差值的数据索引位置
  601. diff = diffTmp
  602. index = i
  603. } else { //将过滤掉的数据加入到更多中
  604. *moreArr = append(*moreArr, map[string]interface{}{
  605. "publishtime": zb["publishtime_str"],
  606. "subtype": zb["subtype"],
  607. "title": zb["title"],
  608. "href": util.GetJyHref(qu.ObjToString(zb["id"])),
  609. })
  610. }
  611. }
  612. resultTmp = tmp[index]
  613. }
  614. return
  615. }
  616. // GetNextDataId 获取当前数据下一条的id
  617. func GetNextDataId(id, tid string) string {
  618. nextIdQuery := map[string]interface{}{
  619. //"b_istag": false,
  620. "_id": map[string]interface{}{
  621. "$gt": mgo.StringTOBsonId(id),
  622. },
  623. }
  624. if tid != "" {
  625. nextIdQuery["s_usertaskid"] = tid
  626. } else {
  627. }
  628. one, _ := util.Mgo.Find(util.DATACOLLNAME, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
  629. if len(*one) == 1 && len((*one)[0]) > 0 {
  630. return mgo.BsonIdToSId((*one)[0]["_id"])
  631. } else {
  632. //delete(nextIdQuery, "_id")
  633. //one, _ = util.Mgo.Find(coll, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
  634. //if len(*one) == 1 && len((*one)[0]) > 0 {
  635. // if mgo.BsonIdToSId((*one)[0]["_id"]) == id {
  636. // return ""
  637. // }
  638. // return mgo.BsonIdToSId((*one)[0]["_id"])
  639. //}
  640. }
  641. return ""
  642. }
  643. func GetLastDataId(id, tid string) string {
  644. nextIdQuery := map[string]interface{}{
  645. //"b_istag": false,
  646. "_id": map[string]interface{}{
  647. "$lt": mgo.StringTOBsonId(id),
  648. },
  649. }
  650. if tid != "" {
  651. nextIdQuery["s_usertaskid"] = tid
  652. }
  653. one, _ := util.Mgo.Find(util.DATACOLLNAME, nextIdQuery, `{"_id":-1}`, `{"_id":1}`, true, 0, 1)
  654. if len(*one) == 1 && len((*one)[0]) > 0 {
  655. return mgo.BsonIdToSId((*one)[0]["_id"])
  656. } else {
  657. //delete(nextIdQuery, "_id")
  658. //one, _ = util.Mgo.Find(coll, nextIdQuery, `{"_id":-1}`, `{"_id":-1}`, true, 0, 1)
  659. //if len(*one) == 1 && len((*one)[0]) > 0 {
  660. // if mgo.BsonIdToSId((*one)[0]["_id"]) == id {
  661. // return ""
  662. // }
  663. // return mgo.BsonIdToSId((*one)[0]["_id"])
  664. //}
  665. }
  666. return ""
  667. }
  668. // GetNextDataId1 质检下一条
  669. func GetNextDataId1(id, tid, tag string) string {
  670. nextIdQuery := map[string]interface{}{
  671. "_id": map[string]interface{}{
  672. "$gt": mgo.StringTOBsonId(id),
  673. },
  674. //"b_check": false,
  675. }
  676. if tid != "" {
  677. // 数据有任务 查询带上标注标记
  678. nextIdQuery["i_ckdata"] = 2
  679. if tag == "group" {
  680. nextIdQuery["s_grouptaskid"] = tid
  681. } else {
  682. nextIdQuery["s_usertaskid"] = tid
  683. }
  684. } else {
  685. nextIdQuery["i_ckdata"] = 2
  686. }
  687. one, _ := util.Mgo.Find(util.DATACOLLNAME, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
  688. if len(*one) == 1 && len((*one)[0]) > 0 {
  689. return mgo.BsonIdToSId((*one)[0]["_id"])
  690. } else {
  691. //delete(nextIdQuery, "_id")
  692. //one, _ = util.Mgo.Find(coll, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
  693. //if len(*one) == 1 && len((*one)[0]) > 0 {
  694. // if mgo.BsonIdToSId((*one)[0]["_id"]) == id {
  695. // return ""
  696. // }
  697. // return mgo.BsonIdToSId((*one)[0]["_id"])
  698. //}
  699. }
  700. return ""
  701. }
  702. func GetLastDataId1(id, tid, tag string) string {
  703. nextIdQuery := map[string]interface{}{
  704. "_id": map[string]interface{}{
  705. "$lt": mgo.StringTOBsonId(id),
  706. },
  707. //"b_check": false,
  708. }
  709. if tid != "" {
  710. // 数据有任务 查询带上标注标记
  711. nextIdQuery["i_ckdata"] = 2
  712. if tag == "group" {
  713. nextIdQuery["s_grouptaskid"] = tid
  714. } else {
  715. nextIdQuery["s_usertaskid"] = tid
  716. }
  717. } else {
  718. nextIdQuery["i_ckdata"] = 2
  719. }
  720. one, _ := util.Mgo.Find(util.DATACOLLNAME, nextIdQuery, `{"_id":-1}`, `{"_id":1}`, true, 0, 1)
  721. if len(*one) == 1 && len((*one)[0]) > 0 {
  722. return mgo.BsonIdToSId((*one)[0]["_id"])
  723. } else {
  724. //delete(nextIdQuery, "_id")
  725. //one, _ = util.Mgo.Find(coll, nextIdQuery, `{"_id":-1}`, `{"_id":1}`, true, 0, 1)
  726. //if len(*one) == 1 && len((*one)[0]) > 0 {
  727. // if mgo.BsonIdToSId((*one)[0]["_id"]) == id {
  728. // return ""
  729. // }
  730. // return mgo.BsonIdToSId((*one)[0]["_id"])
  731. //}
  732. }
  733. return ""
  734. }
  735. func (f *Front) CheckList() {
  736. qu.Catch()
  737. if f.Method() == "POST" {
  738. user := f.GetSession("user").(map[string]interface{})
  739. iRole := qu.ObjToString(user["i_role"])
  740. gid := qu.ObjToString(user["s_groupid"])
  741. start, _ := f.GetInteger("start")
  742. limit, _ := f.GetInteger("length")
  743. draw, _ := f.GetInteger("draw")
  744. status := f.GetString("s_status")
  745. searchStr := f.GetString("search[value]")
  746. search := strings.TrimSpace(searchStr)
  747. query := map[string]interface{}{
  748. "s_stype": "user",
  749. }
  750. if iRole != "0" {
  751. query["s_groupid"] = gid
  752. }
  753. if status != "-1" { //任务状态
  754. query["s_status"] = status
  755. } else {
  756. query["s_status"] = map[string]interface{}{
  757. "$in": []string{"未开始", "进行中", "已完成"},
  758. }
  759. }
  760. if search != "" {
  761. query["$or"] = []interface{}{
  762. map[string]interface{}{"s_projectname": map[string]interface{}{"$regex": search}},
  763. }
  764. }
  765. count := util.Mgo.Count(util.TASKCOLLNAME, query)
  766. list, _ := util.Mgo.Find(util.TASKCOLLNAME, query, bson.M{"_id": -1}, nil, false, start, limit)
  767. for _, l := range *list {
  768. if status := qu.ObjToString(l["s_status"]); status == "进行中" { //更新任务进度
  769. giveNum := qu.IntAll(l["i_givenum"])
  770. tagNum := util.Mgo.Count(util.TASKCOLLNAME, map[string]interface{}{"s_usertaskid": mgo.BsonIdToSId(l["_id"]), "b_istag": true})
  771. progressFloat := float64(tagNum) / float64(giveNum)
  772. value, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", progressFloat), 64)
  773. decimalValue := decimal.NewFromFloat(value)
  774. decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
  775. value, _ = decimalValue.Float64()
  776. progress := fmt.Sprint(value) + "%"
  777. l["s_progress"] = progress
  778. }
  779. }
  780. f.ServeJson(map[string]interface{}{"draw": draw, "data": *list, "recordsFiltered": count, "recordsTotal": count})
  781. } else {
  782. _ = f.Render("project/check_task_list.html")
  783. }
  784. }
  785. func (f *Front) CheckData() {
  786. qu.Catch()
  787. pid := f.GetString("pid")
  788. gid := f.GetString("gid")
  789. tid := f.GetString("tid")
  790. if f.Method() == "POST" {
  791. start, _ := f.GetInteger("start")
  792. limit, _ := f.GetInteger("length")
  793. draw, _ := f.GetInteger("draw")
  794. query := make(map[string]interface{})
  795. query["b_istag"] = true
  796. query["s_usertaskid"] = tid
  797. status := f.GetString("s_status")
  798. s_excp := f.GetString("s_excp")
  799. if status == "1" {
  800. query["b_check"] = true
  801. } else if status == "-1" {
  802. query["b_check"] = false
  803. } else {
  804. query["b_istag"] = true // 默认查询 已标注数据
  805. }
  806. if s_excp == "1" {
  807. query["s_excp"] = nil
  808. } else if s_excp == "-1" {
  809. query["s_excp"] = map[string]interface{}{"$exists": true}
  810. }
  811. count := util.Mgo.Count(util.DATACOLLNAME, query)
  812. fields := map[string]interface{}{"v_baseinfo.title": 1, "b_check": 1, "i_ckdata": 1, "s_login": 1, "b_istag": 1, "s_excp": 1, "s_excp_info": 1}
  813. info, _ := util.Mgo.Find(util.DATACOLLNAME, query, `{"_id": 1}`, fields, false, start, limit)
  814. f.ServeJson(map[string]interface{}{
  815. "draw": draw,
  816. "data": *info,
  817. "recordsFiltered": count,
  818. "recordsTotal": count,
  819. })
  820. } else {
  821. task, _ := util.Mgo.FindById(util.TASKCOLLNAME, tid, map[string]interface{}{"i_givenum": 1})
  822. f.T["taskNum"] = (*task)["i_givenum"]
  823. tagCount, checkCount := 0, 0
  824. tagCount = util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"s_usertaskid": tid, "b_istag": true})
  825. checkCount = util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"s_usertaskid": tid, "b_check": true})
  826. f.T["taskTagNum"] = tagCount
  827. f.T["taskCheckNum"] = checkCount
  828. f.T["pid"] = pid
  829. f.T["tid"] = tid
  830. f.T["gid"] = gid
  831. f.T["topsubtype"] = util.TopSubStypeArr
  832. f.T["allfield"] = util.AllFieldArr
  833. _ = f.Render("project/check_user_data_list.html", &f.T)
  834. }
  835. }
  836. func (f *Front) CheckJyData() {
  837. qu.Catch()
  838. pid := f.GetString("pid")
  839. gid := f.GetString("gid")
  840. tid := f.GetString("tid")
  841. stype := f.GetString("stype")
  842. datatype, _ := f.GetInteger("datatype")
  843. if f.Method() == "POST" {
  844. start, _ := f.GetInteger("start")
  845. limit, _ := f.GetInteger("length")
  846. draw, _ := f.GetInteger("draw")
  847. query := make(map[string]interface{})
  848. if tid != "" {
  849. // 任务数据质检
  850. query["b_istag"] = true
  851. if stype == "group" {
  852. query["s_grouptaskid"] = tid
  853. f.SetSession("check", "group")
  854. } else {
  855. f.SetSession("check", "user")
  856. query["s_usertaskid"] = tid
  857. }
  858. } else {
  859. if stype == "notag" {
  860. query["b_istagging"] = false
  861. if datatype == 1 {
  862. // 待分发数据
  863. query["b_isgivegroup"] = false
  864. } else {
  865. // 已分发 标注数据
  866. query["b_istag"] = true
  867. query["b_isgivegroup"] = true
  868. }
  869. } else if stype == "tag" { //未达标
  870. query["b_istagging"] = true
  871. query["i_ckdata"] = 2
  872. } else {
  873. query["i_ckdata"] = 2
  874. }
  875. }
  876. status := f.GetString("s_status")
  877. s_excp := f.GetString("s_excp")
  878. s_isEff := f.GetString("isEff")
  879. field := f.GetString("field") //字段
  880. dataType1 := f.GetString("datatype1") //信息类型
  881. min := f.GetString("minval") //min max不用int类型接收,以免有默认值0
  882. max := f.GetString("maxval")
  883. hasno, _ := f.GetBool("hasno") //是否存在
  884. notag, _ := f.GetBool("notag") //是否标注
  885. searchStr := f.GetString("search[value]")
  886. searchStr = strings.TrimSpace(searchStr)
  887. if searchStr != "" {
  888. query["$or"] = []interface{}{
  889. map[string]interface{}{"v_baseinfo.projectname": map[string]interface{}{"$regex": searchStr}},
  890. map[string]interface{}{"v_baseinfo.title": map[string]interface{}{"$regex": searchStr}},
  891. }
  892. }
  893. if status == "1" {
  894. query["b_check"] = true
  895. } else if status == "-1" {
  896. query["b_check"] = false
  897. }
  898. if s_isEff == "1" {
  899. query["b_isEff"] = true
  900. } else if s_isEff == "-1" {
  901. query["b_isEff"] = false
  902. }
  903. if s_excp == "1" {
  904. query["s_excp"] = nil
  905. } else if s_excp == "-1" {
  906. query["s_excp"] = map[string]interface{}{"$exists": true}
  907. }
  908. if dataType1 != "-1" && dataType1 != "" { //类型
  909. if dataType1 == util.SPECIALTYPE {
  910. query["v_baseinfo.subtype"] = map[string]interface{}{
  911. "$exists": false,
  912. }
  913. } else {
  914. subtype := strings.Split(dataType1, "-")[1]
  915. query["v_baseinfo.subtype"] = subtype
  916. }
  917. }
  918. fieldScreen := false
  919. if field != "-1" && field != "" { //字段
  920. fieldScreen = true
  921. queryfield := map[string]interface{}{
  922. "$exists": !hasno,
  923. }
  924. numMap := map[string]interface{}{}
  925. if field == "budget" || field == "bidamount" { //金额区间
  926. if min != "" {
  927. minint := qu.IntAll(min)
  928. numMap["$gte"] = minint
  929. }
  930. if max != "" {
  931. maxint := qu.IntAll(max)
  932. numMap["$lte"] = maxint
  933. }
  934. }
  935. if len(numMap) > 0 {
  936. if !hasno {
  937. query["v_baseinfo."+field] = numMap
  938. } else {
  939. query["$or"] = []map[string]interface{}{
  940. {"v_baseinfo." + field: queryfield},
  941. {"v_baseinfo." + field: numMap},
  942. }
  943. }
  944. } else {
  945. if hasno {
  946. query["$or"] = []interface{}{
  947. map[string]interface{}{
  948. "v_baseinfo." + field: queryfield,
  949. },
  950. map[string]interface{}{
  951. "v_baseinfo." + field: map[string]interface{}{
  952. "$eq": "",
  953. },
  954. },
  955. }
  956. } else {
  957. query["$and"] = []interface{}{
  958. map[string]interface{}{
  959. "v_baseinfo." + field: queryfield,
  960. },
  961. map[string]interface{}{
  962. "v_baseinfo." + field: map[string]interface{}{
  963. "$ne": "",
  964. },
  965. },
  966. }
  967. }
  968. }
  969. }
  970. if fieldScreen && notag {
  971. query["v_taginfo."+field] = map[string]interface{}{
  972. "$exists": false,
  973. }
  974. } else if !fieldScreen && notag {
  975. query["i_ckdata"] = 0
  976. }
  977. count := util.Mgo.Count(util.DATACOLLNAME, query)
  978. fields := map[string]interface{}{"v_baseinfo.title": 1, "b_check": 1, "i_ckdata": 1, "s_login": 1, "b_istag": 1, "s_excp": 1, "s_excp_info": 1, "b_isEff": 1}
  979. info, _ := util.Mgo.Find(util.DATACOLLNAME, query, `{"_id": 1}`, fields, false, start, limit)
  980. f.ServeJson(map[string]interface{}{
  981. "draw": draw,
  982. "data": *info,
  983. "recordsFiltered": count,
  984. "recordsTotal": count,
  985. })
  986. } else {
  987. if tid == "" {
  988. query1 := make(map[string]interface{})
  989. if stype == "all" {
  990. project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"i_importnum": 1})
  991. f.T["taskNum"] = (*project)["i_importnum"]
  992. query1["i_ckdata"] = 2
  993. } else if stype == "notag" {
  994. f.T["taskNum"] = util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"b_istagging": false})
  995. query1["b_istagging"] = false
  996. if datatype == 1 {
  997. // 待分发数据
  998. query1["b_isgivegroup"] = false
  999. //query1["b_istagging"] = false
  1000. } else {
  1001. // 标注数据
  1002. query1["b_istag"] = true
  1003. query1["b_isgivegroup"] = true
  1004. }
  1005. } else if stype == "tag" {
  1006. f.T["taskNum"] = util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"b_istagging": false})
  1007. query1["b_istagging"] = true //未达标
  1008. query1["i_ckdata"] = 2
  1009. } else {
  1010. project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"i_importnum": 1})
  1011. f.T["taskNum"] = (*project)["i_importnum"]
  1012. query1["i_ckdata"] = 2
  1013. }
  1014. count := util.Mgo.Count(util.DATACOLLNAME, query1)
  1015. //f.T["taskNum"] = count
  1016. f.T["taskTagNum"] = count
  1017. query1["b_check"] = true // 已质检
  1018. checkCount := util.Mgo.Count(util.DATACOLLNAME, query1)
  1019. f.T["taskCheckNum"] = checkCount
  1020. } else {
  1021. task, _ := util.Mgo.FindById(util.TASKCOLLNAME, tid, map[string]interface{}{"i_givenum": 1})
  1022. f.T["taskNum"] = (*task)["i_givenum"]
  1023. tagCount, checkCount := 0, 0
  1024. if stype == "group" {
  1025. tagCount = util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"s_grouptaskid": tid, "b_istag": true})
  1026. checkCount = util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"s_grouptaskid": tid, "b_check": true})
  1027. } else {
  1028. tagCount = util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"s_usertaskid": tid, "b_istag": true})
  1029. checkCount = util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"s_usertaskid": tid, "b_check": true})
  1030. }
  1031. f.T["taskTagNum"] = tagCount
  1032. f.T["taskCheckNum"] = checkCount
  1033. }
  1034. project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"purchasinglist_key": 1})
  1035. f.T["pid"] = pid
  1036. f.T["tid"] = tid
  1037. f.T["gid"] = gid
  1038. f.T["stype"] = stype
  1039. f.T["datatype"] = datatype
  1040. f.T["topsubtype"] = util.TopSubStypeArr
  1041. f.T["allfield"] = util.AllFieldArr
  1042. f.T["purchasinglist_key"] = (*project)["purchasinglist_key"]
  1043. _ = f.Render("project/check_data_list.html", &f.T)
  1044. }
  1045. }
  1046. func (f *Front) CheckDetail() {
  1047. qu.Catch()
  1048. tid := f.GetString("tid")
  1049. pid := f.GetString("pid")
  1050. did := f.GetString("did")
  1051. project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, `{"v_fields": 1}`)
  1052. fs, _ := (*project)["v_fields"].([]interface{})
  1053. rep := getDetail(did, "check", qu.ObjArrToMapArr(fs)) //获取本条公告的信息
  1054. f.T["otherInfo"] = rep["otherInfo"] //展示关联公告信息
  1055. f.T["moreInfo"] = rep["moreInfo"] //更多关联公告信息
  1056. f.T["s_excp_info"] = rep["s_excp_info"]
  1057. f.T["pid"] = pid
  1058. f.T["tid"] = tid
  1059. f.T["did"] = did
  1060. f.T["info"] = rep["info"]
  1061. f.T["common"] = rep["common"]
  1062. f.T["other"] = rep["other"]
  1063. f.T["ck_pclistag"] = rep["purchasingTag"]
  1064. f.T["enbArr"] = rep["enbArr"]
  1065. if rep["pru"] != nil {
  1066. m := rep["pru"].(map[string]interface{})
  1067. f.T["purchasinglist"] = m["purchasinglist"]
  1068. f.T["pcl_new"] = m["pcl_new"]
  1069. f.T["PurchasinglistField"] = m["field"]
  1070. }
  1071. if rep["proc"] != nil {
  1072. m := rep["proc"].(map[string]interface{})
  1073. f.T["procurementlist"] = m["procurementlist"]
  1074. f.T["pcl_new_1"] = m["pcl_new_1"]
  1075. f.T["ProcurementlistField"] = m["field"]
  1076. }
  1077. if rep["pkg"] != nil {
  1078. m := rep["pkg"].(map[string]interface{})
  1079. f.T["packs"] = m["packs"]
  1080. f.T["packskey"] = m["packskey"]
  1081. f.T["pkg_new"] = m["pkg_new"]
  1082. f.T["PackageField"] = m["field"]
  1083. }
  1084. if rep["wino"] != nil {
  1085. m := rep["wino"].(map[string]interface{})
  1086. f.T["worder"] = m["worder"]
  1087. f.T["worder_new"] = m["worder_new"]
  1088. f.T["WinnerorderField"] = m["field"]
  1089. }
  1090. f.T["topsubtype"] = util.TopSubStypeArr2
  1091. f.T["ck_purchasinglist"] = rep["ck_purchasinglist"]
  1092. f.T["ck_package"] = rep["ck_package"]
  1093. f.T["ck_winnerorder"] = rep["ck_winnerorder"]
  1094. f.T["topsubtype"] = util.TopSubStypeArr2
  1095. f.T["nextid"] = GetNextDataId1(did, tid, qu.ObjToString(f.GetSession("check"))) //下一条id
  1096. f.T["lastid"] = GetLastDataId1(did, tid, qu.ObjToString(f.GetSession("check"))) //下一条id
  1097. _ = f.Render("project/check_detail.html", &f.T)
  1098. }
  1099. func (f *Front) CheckSave() {
  1100. defer qu.Catch()
  1101. success := false
  1102. msg := ""
  1103. user := f.GetSession("user").(map[string]interface{})
  1104. username := qu.ObjToString(user["s_login"]) //当前登录用户
  1105. userId := qu.ObjToString(user["id"]) //当前登录用户标识
  1106. userRole := qu.ObjToString(user["i_role"]) //当前登录用户权限
  1107. var obj []map[string]interface{}
  1108. infoId := f.GetString("s_infoid")
  1109. pid := f.GetString("pid")
  1110. project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"s_name": 1, "v_fields": 1})
  1111. data := f.GetString("data")
  1112. err := json.Unmarshal([]byte(data), &obj)
  1113. if err != nil {
  1114. qu.Debug("Json Unmarshal Error")
  1115. f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
  1116. return
  1117. }
  1118. tagSet := map[string]interface{}{} //被标注字段状态
  1119. baseSet := map[string]interface{}{} //要修改的字段信息
  1120. baseUnset := map[string]interface{}{} //要删除的字段信息
  1121. if len(obj) == 1 { //单独保存某个一级
  1122. content, ok := obj[0]["content"].([]interface{})
  1123. if !ok || len(content) == 0 {
  1124. f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
  1125. return
  1126. }
  1127. title := qu.ObjToString(obj[0]["title"])
  1128. istag, _ := obj[0]["checkAllTag"].(bool)
  1129. status := qu.IntAll(obj[0]["status"])
  1130. switch title {
  1131. case "基本字段":
  1132. MarkBase(content, tagSet, baseSet, baseUnset)
  1133. case "标的信息":
  1134. MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
  1135. case "采购意向信息":
  1136. MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
  1137. case "多包信息":
  1138. MarkPackage(content, tagSet, baseSet, baseUnset, status)
  1139. case "中标候选人信息":
  1140. MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
  1141. case "自定义字段":
  1142. MarkOther(content, tagSet, baseSet, baseUnset)
  1143. }
  1144. } else {
  1145. for _, val := range obj {
  1146. title := qu.ObjToString(val["title"])
  1147. content, ok := val["content"].([]interface{})
  1148. status := qu.IntAll(val["status"])
  1149. if !ok && len(content) > 0 {
  1150. qu.Debug("Content Error")
  1151. continue
  1152. }
  1153. istag, _ := val["checkAllTag"].(bool)
  1154. switch title {
  1155. case "基本字段":
  1156. MarkBase(content, tagSet, baseSet, baseUnset)
  1157. case "标的信息":
  1158. MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
  1159. case "采购意向信息":
  1160. MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
  1161. case "多包信息":
  1162. MarkPackage(content, tagSet, baseSet, baseUnset, status)
  1163. case "中标候选人信息":
  1164. MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
  1165. case "自定义字段":
  1166. MarkOther(content, tagSet, baseSet, baseUnset)
  1167. }
  1168. }
  1169. }
  1170. dataInfo, _ := util.Mgo.FindById(util.DATACOLLNAME, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1}) //查询标注保存前的原始信息
  1171. tagInfo, _ := (*dataInfo)["v_taginfo"].(map[string]interface{})
  1172. baseInfo, _ := (*dataInfo)["v_baseinfo"].(map[string]interface{})
  1173. if tagInfo != nil && len(tagInfo) > 0 {
  1174. for field, tmpStatus := range tagSet { //比对本次标注信息和历史标注信息
  1175. status := qu.IntAll(tmpStatus) //此次被标注字段的状态
  1176. markedStatus := qu.IntAll(tagInfo[field]) //历史标注状态
  1177. if status == 1 && markedStatus != 0 { //此次标注结果为正确,且有历史标注记录,不做修改
  1178. //qu.Debug("已标注字段field---", field)
  1179. //delete(tagSet, field)
  1180. delete(baseSet, field)
  1181. //continue
  1182. }
  1183. }
  1184. }
  1185. allTagFields := map[string]interface{}{} //记录此此标注所有标注信息,用于日志记录
  1186. for k, _ := range tagSet {
  1187. allTagFields[k] = true
  1188. }
  1189. for k, v := range baseSet {
  1190. allTagFields[k] = v
  1191. }
  1192. for k, _ := range baseUnset {
  1193. allTagFields[k] = nil
  1194. }
  1195. // 质检时,标注标记变成质检标记
  1196. checkFields := qu.ObjArrToMapArr((*project)["v_fields"].([]interface{}))
  1197. //datatype := qu.ObjToString((*project)["s_datatype"])
  1198. checkSet := make(map[string]interface{})
  1199. for _, v := range checkFields {
  1200. key := qu.ObjToString(v["key"])
  1201. if key == "extend" && v["child"] != nil {
  1202. for _, v1 := range qu.ObjArrToMapArr(v["child"].([]interface{})) {
  1203. key1 := qu.ObjToString(v1["key"])
  1204. checkSet[key1] = tagSet[key1]
  1205. }
  1206. } else {
  1207. checkSet[key] = tagSet[key]
  1208. }
  1209. }
  1210. if len(tagSet) > 0 || baseInfo["purchasinglist_alltag"] != nil { //purchasinglist_alltag特殊处理
  1211. //1、更新数据源信息
  1212. setResult := map[string]interface{}{ //更新字段集
  1213. "i_updatetime": time.Now().Unix(),
  1214. "b_check": true,
  1215. "s_checkid": userId,
  1216. "b_istag": true,
  1217. //"b_isgivegroup": true,
  1218. //"b_isgiveuser": true,
  1219. "s_userid": userId,
  1220. }
  1221. for field, val := range checkSet { //更新质检字段
  1222. setResult["v_taginfo."+field] = val
  1223. }
  1224. setResult["v_checkinfo"] = checkSet
  1225. for field, val := range baseSet { //更新基本字段
  1226. setResult["v_baseinfo."+field] = val
  1227. //baseInfo[field] = val
  1228. }
  1229. baseUnsetResult := map[string]interface{}{} //删除字段集
  1230. for field, _ := range baseUnset { //删除基本字段
  1231. baseUnsetResult["v_baseinfo."+field] = ""
  1232. //delete(baseInfo, field)
  1233. }
  1234. ex, exp := DataException(baseInfo)
  1235. if ex != "" {
  1236. setResult["s_excp"] = ex
  1237. setResult["s_excp_info"] = exp
  1238. } else {
  1239. baseUnsetResult["s_excp"] = ""
  1240. baseUnsetResult["s_excp_info"] = ""
  1241. }
  1242. set := map[string]interface{}{
  1243. "$set": setResult,
  1244. }
  1245. if len(baseUnsetResult) > 0 {
  1246. set["$unset"] = baseUnsetResult
  1247. }
  1248. qu.Debug(infoId)
  1249. qu.Debug(set)
  1250. success = util.Mgo.UpdateById(util.DATACOLLNAME, infoId, set)
  1251. //2、更新marked表
  1252. tmp, _ := util.Mgo.FindById(util.DATACOLLNAME, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1, "i_ckdata": 1})
  1253. delete(*tmp, "_id")
  1254. (*tmp)["updatetime"] = time.Now().Unix()
  1255. _ = util.Mgo.Update(util.AllToColl, map[string]interface{}{"_id": mgo.StringTOBsonId(infoId)}, map[string]interface{}{"$set": tmp}, true, false)
  1256. }
  1257. //3、保存标注日志
  1258. _ = SaveLog(infoId, "", username, userId, userRole, qu.ObjToString((*project)["s_name"]), "质检", baseInfo, allTagFields)
  1259. f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
  1260. }
  1261. func (f *Front) CheckResult() {
  1262. pid := f.GetString("pid")
  1263. tid := f.GetString("tid")
  1264. stype := f.GetString("stype")
  1265. datatype, _ := f.GetInteger("datatype")
  1266. var allNum int
  1267. projcet, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"v_fields": 1, "appid": 1})
  1268. appid := qu.ObjToString((*projcet)["appid"])
  1269. markNum, checkNum, checkNumR := 0, 0, 0 // 标注数量, 审核数据量, 审核数据完全正确的数据量
  1270. cmaps := make(map[string]int) // 标注字段整体准确率
  1271. cmaps_m := make(map[string]string)
  1272. umaps := make(map[string]interface{}) // 按人员 字段准确率
  1273. for _, v := range qu.ObjArrToMapArr((*projcet)["v_fields"].([]interface{})) {
  1274. key := qu.ObjToString(v["key"])
  1275. if key == "extend" && v["child"] != nil {
  1276. for _, v1 := range qu.ObjArrToMapArr(v["child"].([]interface{})) {
  1277. key1 := qu.ObjToString(v1["key"])
  1278. cmaps[key1] = 0
  1279. cmaps_m[key1] = qu.ObjToString(v1["descript"])
  1280. }
  1281. } else {
  1282. cmaps[key] = 0
  1283. cmaps_m[key] = qu.ObjToString(v["descript"])
  1284. }
  1285. }
  1286. qu.Debug(cmaps)
  1287. sess := util.Mgo.GetMgoConn()
  1288. defer util.Mgo.DestoryMongoConn(sess)
  1289. query := make(map[string]interface{})
  1290. if tid == "" {
  1291. query1 := make(map[string]interface{})
  1292. if stype == "all" {
  1293. query1["appid"] = appid
  1294. query1["i_ckdata"] = 2
  1295. } else if stype == "notag" {
  1296. if datatype == 1 {
  1297. // 待分发数据
  1298. query1["b_isgivegroup"] = false
  1299. query1["b_istagging"] = false
  1300. } else {
  1301. // 标注数据
  1302. query1["i_ckdata"] = 2
  1303. query1["b_isgivegroup"] = false
  1304. }
  1305. } else if stype == "tag" {
  1306. query1["b_istagging"] = true //未达标
  1307. query1["i_ckdata"] = 2
  1308. }
  1309. allNum = util.Mgo.Count(util.DATACOLLNAME, query1)
  1310. } else {
  1311. task, _ := util.Mgo.FindById(util.TASKCOLLNAME, tid, map[string]interface{}{"i_givenum": 1})
  1312. allNum = qu.IntAll((*task)["i_givenum"]) //任务数据量
  1313. if stype == "group" {
  1314. query["s_grouptaskid"] = tid
  1315. } else {
  1316. query["s_usertaskid"] = tid
  1317. }
  1318. }
  1319. query["appid"] = appid
  1320. query["b_check"] = true
  1321. checkNum = util.Mgo.Count(util.DATACOLLNAME, query)
  1322. result := sess.DB(util.Mgo.DbName).C(util.DATACOLLNAME).Find(query).Iter()
  1323. if checkNum == 0 {
  1324. f.ServeJson(map[string]interface{}{"rep": false, "msg": "无质检审核数据!"})
  1325. return
  1326. }
  1327. // 排序
  1328. purchasingTag := false // 标的物统计标识
  1329. var strs []string
  1330. if cmaps["purchasinglist"] != 0 {
  1331. purchasingTag = true
  1332. delete(cmaps, "purchasinglist")
  1333. }
  1334. for k := range cmaps {
  1335. strs = append(strs, k)
  1336. }
  1337. pNum, pEffNum := 0, 0 // 标的物数量, 标的物有效数量
  1338. fieldNumMap := make(map[string]int) //字段总标注量,
  1339. tagNumMap := make(map[string]int) //字段标注数据量(标的物有效)
  1340. rightNumMap := make(map[string]int) //正确数据(标的物有效)
  1341. for tmp := make(map[string]interface{}); result.Next(&tmp); markNum++ {
  1342. user := qu.ObjToString(tmp["s_login"])
  1343. var up map[string]int
  1344. if umaps[user] == nil {
  1345. up = make(map[string]int)
  1346. } else {
  1347. up = umaps[user].(map[string]int)
  1348. }
  1349. up["ck_count"] += 1
  1350. umaps[user] = up
  1351. if tmp["b_check"].(bool) {
  1352. if f, ok := tmp["v_checkinfo"].(map[string]interface{}); ok {
  1353. flag := true // 数据整体准确率
  1354. // 按人员统计字段准备率
  1355. var up map[string]int
  1356. if umaps[user] == nil {
  1357. up = make(map[string]int)
  1358. } else {
  1359. up = umaps[user].(map[string]int)
  1360. }
  1361. for k1 := range cmaps {
  1362. if qu.IntAll(f[k1]) == 1 {
  1363. cmaps[k1] += 1 // 字段整体正确率
  1364. up[k1] += 1
  1365. } else {
  1366. flag = false
  1367. }
  1368. }
  1369. up["re_count"] += 1
  1370. umaps[user] = up
  1371. if flag {
  1372. checkNumR++
  1373. up["re_rg_count"] += 1
  1374. }
  1375. }
  1376. }
  1377. if tmp["b_check"].(bool) && purchasingTag {
  1378. info := tmp["v_baseinfo"].(map[string]interface{})
  1379. checkInfo := tmp["v_checkinfo"].(map[string]interface{})
  1380. if pList, o := info["purchasinglist"].([]interface{}); o {
  1381. pNum += len(pList)
  1382. if tmp["b_isEff"].(bool) {
  1383. pEffNum += 1
  1384. }
  1385. for _, p := range pList {
  1386. p1 := p.(map[string]interface{})
  1387. for f := range purchasingField {
  1388. if qu.ObjToString(p1[f]) != "" {
  1389. fieldNumMap[f] += 1
  1390. if b, o := p1["b_isEff"].(bool); b && o {
  1391. tagNumMap[f] += 1
  1392. }
  1393. }
  1394. }
  1395. }
  1396. }
  1397. if cList, o := checkInfo["purchasinglist"].([]interface{}); o {
  1398. for _, c := range cList {
  1399. c1 := c.(map[string]interface{})
  1400. for f := range purchasingField {
  1401. if qu.IntAll(c1[f]) == 1 {
  1402. rightNumMap[f] += 1
  1403. }
  1404. }
  1405. }
  1406. }
  1407. }
  1408. }
  1409. pResult := method(fieldNumMap, tagNumMap, rightNumMap)
  1410. // 前台页面数据
  1411. dataSource := make(map[string]interface{})
  1412. var userSelect []string
  1413. var dataSelect []map[string]interface{}
  1414. userSelect = append(userSelect, "全部")
  1415. tmp := make(map[string]interface{})
  1416. tmp["name"] = "全部"
  1417. tmp["num1"] = allNum
  1418. tmp["num2"] = checkNum
  1419. tmp["num3"] = checkNumR
  1420. tmp["num4"] = CountPr(checkNumR, checkNum)
  1421. dataSelect = append(dataSelect, tmp)
  1422. sort.Strings(strs)
  1423. for _, v := range strs {
  1424. tmp1 := make(map[string]interface{})
  1425. tmp1["name"] = cmaps_m[v]
  1426. tmp1["num1"] = markNum
  1427. tmp1["num2"] = checkNum
  1428. tmp1["num3"] = cmaps[v]
  1429. tmp1["num4"] = CountPr(cmaps[v], checkNum)
  1430. dataSelect = append(dataSelect, tmp1)
  1431. }
  1432. dataSource["全部"] = dataSelect
  1433. for k1, v1 := range umaps {
  1434. if v2, o := v1.(map[string]int); o {
  1435. userSelect = append(userSelect, k1)
  1436. var dataSelect1 []map[string]interface{}
  1437. tmp2 := make(map[string]interface{})
  1438. tmp2["name"] = "全部"
  1439. tmp2["num1"] = v2["ck_count"]
  1440. tmp2["num2"] = v2["re_count"]
  1441. tmp2["num3"] = v2["re_rg_count"]
  1442. tmp2["num4"] = CountPr(v2["re_rg_count"], v2["re_count"])
  1443. dataSelect1 = append(dataSelect1, tmp2)
  1444. for k, v := range cmaps_m {
  1445. tmp1 := make(map[string]interface{})
  1446. tmp1["name"] = v
  1447. tmp1["num1"] = v2["ck_count"]
  1448. tmp1["num2"] = v2["re_count"]
  1449. tmp1["num3"] = v2[k]
  1450. tmp1["num4"] = CountPr(v2[k], v2["re_count"])
  1451. dataSelect1 = append(dataSelect1, tmp1)
  1452. }
  1453. dataSource[k1] = dataSelect1
  1454. }
  1455. }
  1456. f.T["pid"] = pid
  1457. f.T["tid"] = tid
  1458. f.T["taskNum"] = allNum
  1459. f.T["taskTagNum"] = markNum
  1460. f.T["taskCheckNum"] = checkNum
  1461. f.T["taskCheckRight"] = checkNumR
  1462. f.T["pNum"] = pNum // 标的物数量
  1463. f.T["pEffNum"] = pEffNum //标的物有效数据量
  1464. f.T["tableData"] = dataSource
  1465. f.T["pResult"] = pResult
  1466. f.T["userSelect"] = userSelect
  1467. _ = f.Render("project/check_result.html", &f.T)
  1468. }
  1469. // @Description 标的物统计结果
  1470. // @Author J 2022/4/25 2:20 PM
  1471. func method(m1, m2, m3 map[string]int) []map[string]interface{} {
  1472. var result []map[string]interface{}
  1473. for f, v := range purchasingField {
  1474. m := make(map[string]interface{})
  1475. m["name"] = v
  1476. m["num"] = m1[f]
  1477. m["num1"] = m2[f]
  1478. m["num2"] = m3[f]
  1479. m["num3"] = CountPr(m2[f], m3[f])
  1480. result = append(result, m)
  1481. }
  1482. return result
  1483. }
  1484. // CountPr 计算百分比
  1485. func CountPr(c1, c2 int) string {
  1486. decimal.DivisionPrecision = 2
  1487. if c1 == 0 || c2 == 0 {
  1488. return "0"
  1489. }
  1490. d := decimal.NewFromInt32(int32(c1)).Div(decimal.NewFromInt32(int32(c2))).Mul(decimal.NewFromInt32(100))
  1491. return d.String() + "%"
  1492. }
  1493. func (f *Front) CheckExcpResult() {
  1494. pid := f.GetString("pid")
  1495. tid := f.GetString("tid")
  1496. stype := f.GetString("stype")
  1497. query := make(map[string]interface{})
  1498. var dataSource []map[string]interface{}
  1499. if tid != "" {
  1500. if stype == "group" {
  1501. query["s_grouptaskid"] = tid
  1502. } else {
  1503. query["s_usertaskid"] = tid
  1504. }
  1505. query["s_excp"] = map[string]interface{}{"$exists": true}
  1506. } else {
  1507. pinfo, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, bson.M{"appid": 1})
  1508. query["appid"] = qu.ObjToString((*pinfo)["appid"])
  1509. query["s_excp"] = map[string]interface{}{"$exists": true}
  1510. excpNum := util.Mgo.Count(util.DATACOLLNAME, query)
  1511. tagNum := util.Mgo.Count(util.DATACOLLNAME, map[string]interface{}{"i_ckdata": 2})
  1512. dataSource = append(dataSource, map[string]interface{}{"name": "达标数据", "num1": excpNum, "num2": tagNum, "num3": CountPr(excpNum, tagNum)})
  1513. }
  1514. f.T["tableData"] = dataSource
  1515. f.T["pid"] = pid
  1516. f.T["tid"] = tid
  1517. _ = f.Render("project/check_excp_result.html", &f.T)
  1518. }
  1519. func (f *Front) CheckExcpData() {
  1520. appid := f.GetString("appid")
  1521. // 达标,待分发数据
  1522. query := map[string]interface{}{
  1523. "appid": appid,
  1524. "b_istagging": false,
  1525. //"b_isgivegroup": false,
  1526. }
  1527. pool := make(chan bool, 3)
  1528. wg := &sync.WaitGroup{}
  1529. sess := util.Mgo.GetMgoConn()
  1530. defer util.Mgo.DestoryMongoConn(sess)
  1531. count := 0
  1532. it := sess.DB(util.Mgo.DbName).C(util.DATACOLLNAME).Find(query).Select(nil).Iter()
  1533. for tmp := make(map[string]interface{}); it.Next(&tmp); count++ {
  1534. if tmp["s_excp"] != nil {
  1535. f.ServeJson(map[string]interface{}{"success": true})
  1536. break
  1537. }
  1538. pool <- true
  1539. wg.Add(1)
  1540. go func(tmp map[string]interface{}) {
  1541. defer func() {
  1542. <-pool
  1543. wg.Done()
  1544. info := tmp["v_baseinfo"].(map[string]interface{})
  1545. ex, exp := DataException(info)
  1546. if ex != "" {
  1547. util.Mgo.UpdateById(util.DATACOLLNAME, tmp["_id"], map[string]interface{}{"$set": map[string]interface{}{"s_excp": ex, "s_excp_info": exp}})
  1548. }
  1549. }()
  1550. }(tmp)
  1551. }
  1552. f.ServeJson(map[string]interface{}{"success": true})
  1553. }
  1554. var regReplAllSymbol = regexp.MustCompile("[<《【\\[{{〔>》】\\]}}〕,,;;::'\"“”。.??/+=\\-_—*&…^%$¥@#!!`~·]")
  1555. func DataException(tmp map[string]interface{}) (string, string) {
  1556. var tag []string
  1557. var exp string
  1558. if tmp["buyer"] != nil && tmp["buyer"] == tmp["s_winner"] {
  1559. tag = append(tag, "1")
  1560. exp += "采购单位与中标单位相等,"
  1561. }
  1562. if tmp["agency"] != nil && tmp["buyer"] == tmp["agency"] {
  1563. tag = append(tag, "2")
  1564. exp += "采购单位与代理机构相等,"
  1565. }
  1566. if tmp["s_winner"] != nil && tmp["s_winner"] == tmp["agency"] {
  1567. tag = append(tag, "3")
  1568. exp += "中标单位与代理机构相等,"
  1569. }
  1570. if tmp["bidamount"] != nil && tmp["budget"] != nil {
  1571. if qu.Float64All(tmp["bidamount"]) > qu.Float64All(tmp["budget"]) {
  1572. tag = append(tag, "4")
  1573. exp += "中标金额大于预算,"
  1574. }
  1575. if qu.Float64All(tmp["bidamount"]) < (qu.Float64All(tmp["budget"]) / 2) {
  1576. tag = append(tag, "5")
  1577. exp += "中标金额小于预算的一半,"
  1578. }
  1579. if tmp["budget"] == 0 && qu.Float64All(tmp["bidamount"]) != 0 {
  1580. tag = append(tag, "6")
  1581. exp += "预算为0,中标金额不为0,"
  1582. }
  1583. if qu.Float64All(tmp["budget"]) != 0 && tmp["bidamount"] == 0 {
  1584. tag = append(tag, "7")
  1585. exp += "预算不为0,中标金额为0,"
  1586. }
  1587. }
  1588. if b := qu.ObjToString(tmp["buyer"]); b != "" {
  1589. if regReplAllSymbol.MatchString(b) {
  1590. tag = append(tag, "8")
  1591. exp += "采购单位含有特殊符号,"
  1592. }
  1593. }
  1594. if a := qu.ObjToString(tmp["agency"]); a != "" {
  1595. if regReplAllSymbol.MatchString(a) {
  1596. tag = append(tag, "9")
  1597. exp += "中标单位含有特殊符号,"
  1598. }
  1599. }
  1600. if a := qu.ObjToString(tmp["s_winner"]); a != "" {
  1601. if regReplAllSymbol.MatchString(a) {
  1602. tag = append(tag, "10")
  1603. exp += "代理机构含有特殊符号,"
  1604. }
  1605. }
  1606. return strings.Join(tag, ","), exp
  1607. }
  1608. // JyMarkList 剑鱼管理员标注信息列表
  1609. func (f *Front) JyMarkList() {
  1610. defer qu.Catch()
  1611. stype := f.GetString("stype") //all:全量标注;notag:达标数据标注;tag:未达标数据标注
  1612. if f.Method() == "POST" {
  1613. start, _ := f.GetInteger("start")
  1614. limit, _ := f.GetInteger("length")
  1615. draw, _ := f.GetInteger("draw")
  1616. appid := f.GetString("appid")
  1617. istag := f.GetString("b_istag") //
  1618. field := f.GetString("field") //字段
  1619. dataType := f.GetString("datatype") //信息类型
  1620. min := f.GetString("minval") //min max不用int类型接收,以免有默认值0
  1621. max := f.GetString("maxval")
  1622. hasno, _ := f.GetBool("hasno") //是否存在
  1623. notag, _ := f.GetBool("notag") //是否标注
  1624. query := map[string]interface{}{ //剑鱼自用的标注页面, 查询待分发的数据量
  1625. "appid": appid,
  1626. "b_isgivegroup": false,
  1627. //"b_isgiveuser": false,
  1628. }
  1629. if istag == "true" {
  1630. query["b_istag"] = true
  1631. } else if istag == "false" {
  1632. query["b_istag"] = false
  1633. }
  1634. if stype == "notag" { //查询达标
  1635. query["b_istagging"] = false
  1636. } else if stype == "tag" { //查询未达标
  1637. query["b_istagging"] = true
  1638. }
  1639. if dataType != "-1" && dataType != "" { //类型
  1640. if dataType == util.SPECIALTYPE {
  1641. query["v_baseinfo.subtype"] = map[string]interface{}{
  1642. "$exists": false,
  1643. }
  1644. } else {
  1645. subtype := strings.Split(dataType, "-")[1]
  1646. query["v_baseinfo.subtype"] = subtype
  1647. }
  1648. }
  1649. fieldScreen := false
  1650. if field != "-1" && field != "" { //字段
  1651. fieldScreen = true
  1652. queryfield := map[string]interface{}{
  1653. "$exists": !hasno,
  1654. }
  1655. numMap := map[string]interface{}{}
  1656. if field == "budget" || field == "bidamount" { //金额区间
  1657. if min != "" {
  1658. minint := qu.IntAll(min)
  1659. numMap["$gte"] = minint
  1660. }
  1661. if max != "" {
  1662. maxint := qu.IntAll(max)
  1663. numMap["$lte"] = maxint
  1664. }
  1665. }
  1666. if len(numMap) > 0 {
  1667. if !hasno {
  1668. query["v_baseinfo."+field] = numMap
  1669. } else {
  1670. query["$or"] = []map[string]interface{}{
  1671. {"v_baseinfo." + field: queryfield},
  1672. {"v_baseinfo." + field: numMap},
  1673. }
  1674. }
  1675. } else {
  1676. if hasno {
  1677. query["$or"] = []interface{}{
  1678. map[string]interface{}{
  1679. "v_baseinfo." + field: queryfield,
  1680. },
  1681. map[string]interface{}{
  1682. "v_baseinfo." + field: map[string]interface{}{
  1683. "$eq": "",
  1684. },
  1685. },
  1686. }
  1687. } else {
  1688. query["$and"] = []interface{}{
  1689. map[string]interface{}{
  1690. "v_baseinfo." + field: queryfield,
  1691. },
  1692. map[string]interface{}{
  1693. "v_baseinfo." + field: map[string]interface{}{
  1694. "$ne": "",
  1695. },
  1696. },
  1697. }
  1698. }
  1699. //query["v_baseinfo."+field] = queryfield
  1700. }
  1701. }
  1702. if fieldScreen && notag {
  1703. query["v_taginfo."+field] = map[string]interface{}{
  1704. "$exists": false,
  1705. }
  1706. } else if !fieldScreen && notag {
  1707. query["i_ckdata"] = 0
  1708. }
  1709. count := util.Mgo.Count(util.DATACOLLNAME, query)
  1710. fields := map[string]interface{}{"v_baseinfo.title": 1, "b_istag": 1, "i_ckdata": 1}
  1711. qu.Debug(query)
  1712. list, _ := util.Mgo.Find(util.DATACOLLNAME, query, map[string]interface{}{"_id": 1}, fields, false, start, limit)
  1713. f.ServeJson(map[string]interface{}{"draw": draw, "data": *list, "recordsFiltered": count, "recordsTotal": count})
  1714. } else {
  1715. appid := f.GetString("appid")
  1716. f.T["pid"] = f.GetString("pid")
  1717. f.T["stype"] = stype
  1718. f.T["appid"] = appid
  1719. f.T["topsubtype"] = util.TopSubStypeArr
  1720. f.T["allfield"] = util.AllFieldArr
  1721. _ = f.Render("project/remark_jy_list.html", &f.T)
  1722. }
  1723. }
  1724. // JyUserDataMark 剑鱼管理人员数据标注
  1725. func (f *Front) JyUserDataMark() {
  1726. defer qu.Catch()
  1727. success := false
  1728. msg := ""
  1729. user := f.GetSession("user").(map[string]interface{})
  1730. username := qu.ObjToString(user["s_login"]) //当前登录用户
  1731. groupId := qu.ObjToString(user["s_groupid"])
  1732. userId := qu.ObjToString(user["id"]) //当前登录用户标识
  1733. userRole := qu.ObjToString(user["i_role"]) //当前登录用户权限
  1734. obj := []map[string]interface{}{}
  1735. infoId := f.GetString("s_infoid")
  1736. isEff, _ := f.GetBool("isEff")
  1737. pid := f.GetString("pid")
  1738. data := f.GetString("data")
  1739. err := json.Unmarshal([]byte(data), &obj)
  1740. if err != nil {
  1741. qu.Debug("Json Unmarshal Error")
  1742. f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
  1743. return
  1744. }
  1745. tagSet := map[string]interface{}{} //被标注字段状态
  1746. baseSet := map[string]interface{}{} //要修改的字段信息
  1747. baseUnset := map[string]interface{}{} //要删除的字段信息
  1748. if len(obj) == 1 { //单独保存某个一级
  1749. content, ok := obj[0]["content"].([]interface{})
  1750. if !ok || len(content) == 0 {
  1751. f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
  1752. return
  1753. }
  1754. title := qu.ObjToString(obj[0]["title"])
  1755. istag, _ := obj[0]["checkAllTag"].(bool)
  1756. status := qu.IntAll(obj[0]["status"])
  1757. switch title {
  1758. case "基本字段":
  1759. MarkBase(content, tagSet, baseSet, baseUnset)
  1760. case "标的信息":
  1761. MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
  1762. case "采购意向信息":
  1763. MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
  1764. case "多包信息":
  1765. MarkPackage(content, tagSet, baseSet, baseUnset, status)
  1766. case "中标候选人信息":
  1767. MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
  1768. case "自定义字段":
  1769. MarkOther(content, tagSet, baseSet, baseUnset)
  1770. }
  1771. } else {
  1772. for _, val := range obj {
  1773. title := qu.ObjToString(val["title"])
  1774. content, ok := val["content"].([]interface{})
  1775. status := qu.IntAll(val["status"])
  1776. if !ok {
  1777. qu.Debug("Content Error")
  1778. continue
  1779. }
  1780. istag, _ := val["checkAllTag"].(bool)
  1781. switch title {
  1782. case "基本字段":
  1783. MarkBase(content, tagSet, baseSet, baseUnset)
  1784. case "标的信息":
  1785. MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
  1786. case "采购意向信息":
  1787. MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
  1788. case "多包信息":
  1789. MarkPackage(content, tagSet, baseSet, baseUnset, status)
  1790. case "中标候选人信息":
  1791. MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
  1792. case "自定义字段":
  1793. MarkOther(content, tagSet, baseSet, baseUnset)
  1794. }
  1795. }
  1796. }
  1797. qu.Debug("baseUnset===", baseUnset)
  1798. dataInfo, _ := util.Mgo.FindById(util.DATACOLLNAME, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1}) //查询标注保存前的原始信息
  1799. //tagInfo, _ := (*dataInfo)["v_taginfo"].(map[string]interface{})
  1800. baseInfo, _ := (*dataInfo)["v_baseinfo"].(map[string]interface{})
  1801. //if tagInfo != nil && len(tagInfo) > 0 {
  1802. // for field, tmpStatus := range tagSet { //比对本次标注信息和历史标注信息
  1803. // status := qu.IntAll(tmpStatus) //此次被标注字段的状态
  1804. // markedStatus := qu.IntAll(tagInfo[field]) //历史标注状态
  1805. // if status == 1 && markedStatus != 0 { //此次标注结果为正确,且有历史标注记录,不做修改
  1806. // delete(tagSet, field)
  1807. // delete(baseSet, field)
  1808. // //continue
  1809. // }
  1810. // //else {
  1811. // // qu.Debug("未标注字段field---", field, status)
  1812. // //}
  1813. // }
  1814. //}
  1815. //
  1816. qu.Debug("baseSet===", baseSet)
  1817. allTagFields := map[string]interface{}{} //记录此此标注所有标注信息,用于日志记录
  1818. for k, _ := range tagSet {
  1819. allTagFields[k] = true
  1820. }
  1821. for k, v := range baseSet {
  1822. allTagFields[k] = v
  1823. }
  1824. for k, _ := range baseUnset {
  1825. allTagFields[k] = nil
  1826. }
  1827. if len(tagSet) >= 0 || baseInfo["purchasinglist_alltag"] != nil { //purchasinglist_alltag特殊处理
  1828. //1、更新数据源信息
  1829. setResult := map[string]interface{}{ //更新字段集
  1830. "i_updatetime": time.Now().Unix(),
  1831. "i_ckdata": 2,
  1832. "b_istag": true,
  1833. "s_userid": userId,
  1834. "s_groupid": groupId,
  1835. //"b_isgiveuser": true,
  1836. //"b_isgivegroup": true,
  1837. "s_login": username,
  1838. }
  1839. for field, val := range tagSet { //更新标注字段
  1840. setResult["v_taginfo."+field] = val
  1841. }
  1842. for field, val := range baseSet { //更新基本字段
  1843. setResult["v_baseinfo."+field] = val
  1844. }
  1845. baseUnsetResult := map[string]interface{}{} //删除字段集
  1846. for field, _ := range baseUnset { //删除基本字段
  1847. baseUnsetResult["v_baseinfo."+field] = ""
  1848. }
  1849. setResult["isEff"] = isEff
  1850. set := map[string]interface{}{
  1851. "$set": setResult,
  1852. }
  1853. if len(baseUnsetResult) > 0 {
  1854. set["$unset"] = baseUnsetResult
  1855. }
  1856. qu.Debug(infoId)
  1857. qu.Debug(set)
  1858. success = util.Mgo.UpdateById(util.DATACOLLNAME, infoId, set)
  1859. //2、更新marked表
  1860. tmp, _ := util.Mgo.FindById(util.DATACOLLNAME, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1, "i_ckdata": 1})
  1861. delete((*tmp), "_id")
  1862. (*tmp)["updatetime"] = time.Now().Unix()
  1863. _ = util.Mgo.Update(util.AllToColl, map[string]interface{}{"_id": mgo.StringTOBsonId(infoId)}, map[string]interface{}{"$set": tmp}, true, false)
  1864. }
  1865. /*
  1866. } else {
  1867. 表示页面标注时未做修改标注
  1868. }
  1869. */
  1870. //3、保存标注日志
  1871. project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"s_name": 1})
  1872. _ = SaveLog(infoId, "", username, userId, userRole, qu.ObjToString((*project)["s_name"]), "标注", baseInfo, allTagFields)
  1873. f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
  1874. }
  1875. // UserDataMark 标注人员数据标注(基于任务的标注)
  1876. func (f *Front) UserDataMark() {
  1877. defer qu.Catch()
  1878. success := false
  1879. msg := ""
  1880. user := f.GetSession("user").(map[string]interface{})
  1881. username := qu.ObjToString(user["s_login"]) //当前登录用户
  1882. userId := qu.ObjToString(user["id"]) //当前登录用户标识
  1883. userRole := qu.ObjToString(user["i_role"]) //当前登录用户权限
  1884. isEff, _ := f.GetBool("isEff")
  1885. obj := []map[string]interface{}{}
  1886. infoId := f.GetString("s_infoid")
  1887. userTaskId := f.GetString("s_usertaskid")
  1888. data := f.GetString("data")
  1889. err := json.Unmarshal([]byte(data), &obj)
  1890. if err != nil {
  1891. qu.Debug("Json Unmarshal Error")
  1892. f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
  1893. return
  1894. }
  1895. tagSet := map[string]interface{}{} //被标注字段状态
  1896. baseSet := map[string]interface{}{} //要修改的字段信息
  1897. baseUnset := map[string]interface{}{} //要删除的字段信息
  1898. //isSaveMarked := false
  1899. if len(obj) == 1 { //单独保存某个一级
  1900. content, ok := obj[0]["content"].([]interface{})
  1901. if !ok || len(content) == 0 {
  1902. f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
  1903. return
  1904. }
  1905. title := qu.ObjToString(obj[0]["title"])
  1906. istag, _ := obj[0]["checkAllTag"].(bool)
  1907. status := qu.IntAll(obj[0]["status"])
  1908. switch title {
  1909. case "基本字段":
  1910. MarkBase(content, tagSet, baseSet, baseUnset)
  1911. case "标的信息":
  1912. MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
  1913. case "采购意向信息":
  1914. MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
  1915. case "多包信息":
  1916. MarkPackage(content, tagSet, baseSet, baseUnset, status)
  1917. case "中标候选人信息":
  1918. MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
  1919. case "自定义字段":
  1920. MarkOther(content, tagSet, baseSet, baseUnset)
  1921. }
  1922. } else {
  1923. for _, val := range obj {
  1924. title := qu.ObjToString(val["title"])
  1925. content, ok := val["content"].([]interface{})
  1926. status := qu.IntAll(val["status"])
  1927. if !ok {
  1928. qu.Debug("Content Error")
  1929. continue
  1930. }
  1931. istag, _ := val["checkAllTag"].(bool)
  1932. switch title {
  1933. case "基本字段":
  1934. MarkBase(content, tagSet, baseSet, baseUnset)
  1935. case "标的信息":
  1936. MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
  1937. case "采购意向信息":
  1938. MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
  1939. case "多包信息":
  1940. MarkPackage(content, tagSet, baseSet, baseUnset, status)
  1941. case "中标候选人信息":
  1942. MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
  1943. case "自定义字段":
  1944. MarkOther(content, tagSet, baseSet, baseUnset)
  1945. }
  1946. }
  1947. }
  1948. //
  1949. userTask, _ := util.Mgo.FindById(util.TASKCOLLNAME, userTaskId, map[string]interface{}{"s_personid": 1, "s_personname": 1, "s_projectname": 1})
  1950. if userTask == nil || len(*userTask) == 0 {
  1951. f.ServeJson(map[string]interface{}{"success": success, "msg": "查询用户任务失败"})
  1952. return
  1953. } //数据源表
  1954. dataInfo, _ := util.Mgo.FindById(util.DATACOLLNAME, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1}) //查询标注保存前的原始信息
  1955. //tagInfo, _ := (*dataInfo)["v_taginfo"].(map[string]interface{})
  1956. baseInfo, _ := (*dataInfo)["v_baseinfo"].(map[string]interface{})
  1957. //if tagInfo != nil && len(tagInfo) > 0 {
  1958. // for field, tmpStatus := range tagSet { //比对本次标注信息和历史标注信息
  1959. // status := qu.IntAll(tmpStatus) //此次被标注字段的状态
  1960. // markedStatus := qu.IntAll(tagInfo[field]) //历史标注状态
  1961. // if status == 1 && markedStatus != 0 { //此次标注结果为正确,且有历史标注记录,不做修改
  1962. // qu.Debug("已标注字段field---", field)
  1963. // delete(tagSet, field)
  1964. // delete(baseSet, field)
  1965. // //continue
  1966. // }
  1967. // //else {
  1968. // // qu.Debug("未标注字段field---", field, status)
  1969. // //}
  1970. // }
  1971. //}
  1972. allTagFields := map[string]interface{}{} //记录此此标注所有标注信息,用于日志记录
  1973. for k, _ := range tagSet {
  1974. allTagFields[k] = true
  1975. }
  1976. for k, v := range baseSet {
  1977. allTagFields[k] = v
  1978. }
  1979. for k, _ := range baseUnset {
  1980. allTagFields[k] = nil
  1981. }
  1982. if len(tagSet) >= 0 || baseInfo["purchasinglist_alltag"] != nil { //purchasinglist_alltag特殊处理
  1983. //1、更新数据源信息
  1984. setResult := map[string]interface{}{ //更新字段集
  1985. "i_updatetime": time.Now().Unix(),
  1986. "i_ckdata": 2,
  1987. "b_istag": true,
  1988. }
  1989. for field, val := range tagSet { //更新标注字段
  1990. setResult["v_taginfo."+field] = val
  1991. }
  1992. for field, val := range baseSet { //更新基本字段
  1993. setResult["v_baseinfo."+field] = val
  1994. //baseInfo[field] = val
  1995. }
  1996. baseUnsetResult := map[string]interface{}{} //删除字段集
  1997. for field, _ := range baseUnset { //删除基本字段
  1998. baseUnsetResult["v_baseinfo."+field] = ""
  1999. //delete(baseInfo, field)
  2000. }
  2001. ex, exp := DataException(baseInfo)
  2002. if ex != "" {
  2003. setResult["s_excp"] = ex
  2004. setResult["s_excp_info"] = exp
  2005. }
  2006. setResult["isEff"] = isEff
  2007. set := map[string]interface{}{
  2008. "$set": setResult,
  2009. }
  2010. if len(baseUnsetResult) > 0 {
  2011. set["$unset"] = baseUnsetResult
  2012. }
  2013. qu.Debug(set)
  2014. success = util.Mgo.UpdateById(util.DATACOLLNAME, infoId, set)
  2015. //2、更新marked表
  2016. tmp, _ := util.Mgo.FindById(util.DATACOLLNAME, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1, "i_ckdata": 1})
  2017. delete((*tmp), "_id")
  2018. (*tmp)["updatetime"] = time.Now().Unix()
  2019. _ = util.Mgo.Update(util.AllToColl, map[string]interface{}{"_id": mgo.StringTOBsonId(infoId)}, map[string]interface{}{"$set": tmp}, true, false)
  2020. }
  2021. /*
  2022. } else {
  2023. 表示页面标注时未做修改标注
  2024. }
  2025. */
  2026. //3、修改任务状态
  2027. _ = util.Mgo.Update(util.TASKCOLLNAME, map[string]interface{}{"_id": (*userTask)["_id"], "s_status": "未开始"}, map[string]interface{}{
  2028. "$set": map[string]interface{}{
  2029. "i_starttime": time.Now().Unix(),
  2030. "i_updatetime": time.Now().Unix(),
  2031. "s_updateperson": username,
  2032. "s_status": "进行中",
  2033. },
  2034. }, false, false)
  2035. //4、保存标注日志
  2036. _ = SaveLog(infoId, userTaskId, username, userId, userRole, qu.ObjToString((*userTask)["s_projectname"]), "标注", baseInfo, allTagFields)
  2037. f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
  2038. }
  2039. // MarkBase 标注基本信息
  2040. func MarkBase(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}) {
  2041. defer qu.Catch()
  2042. info, _ := content[0].(map[string]interface{})
  2043. if uInputs, ok := info["uInput"].([]interface{}); ok {
  2044. for _, tmp := range uInputs {
  2045. if tmpMap, ok := tmp.(map[string]interface{}); ok {
  2046. if status := qu.IntAll(tmpMap["status"]); status != -1 {
  2047. key := qu.ObjToString(tmpMap["key"]) //字段
  2048. if key == "" {
  2049. continue
  2050. }
  2051. if status == 2 { //新增、修改、删除
  2052. input := tmpMap["input"] //值
  2053. if key == "bidamounttype" || key == "subtype" || key == "attach_discern" || key == "attach_ext" || key == "isrepeat" { //附件识别、抽取select
  2054. input = tmpMap["select"]
  2055. }
  2056. if input == "" { //删除原字段
  2057. baseUnset[key] = ""
  2058. } else { //修改原字段
  2059. if key == "budget" || key == "bidamount" || key == "biddiscount" {
  2060. input = qu.Float64All(input)
  2061. //input, _ = strconv.ParseFloat(qu.ObjToString(input), 32)
  2062. }
  2063. if key == "subtype" {
  2064. if topsubtype := strings.Split(qu.ObjToString(input), "-"); len(topsubtype) == 2 {
  2065. baseSet["toptype"] = topsubtype[0]
  2066. baseSet[key] = topsubtype[1]
  2067. }
  2068. } else if key == "s_winner" {
  2069. if strings.Contains(qu.ObjToString(input), ",") {
  2070. baseSet[key] = strings.ReplaceAll(qu.ObjToString(input), ",", ",")
  2071. } else {
  2072. baseSet[key] = input
  2073. }
  2074. } else {
  2075. baseSet[key] = input
  2076. }
  2077. }
  2078. }
  2079. tagSet[key] = status //记录被标注状态
  2080. }
  2081. }
  2082. }
  2083. }
  2084. }
  2085. // MarkTimePlace 标注时间地点
  2086. func MarkTimePlace(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}) {
  2087. info, _ := content[0].(map[string]interface{})
  2088. if uInputs, ok := info["uInput"].([]interface{}); ok {
  2089. for _, tmp := range uInputs {
  2090. if tmpMap, ok := tmp.(map[string]interface{}); ok {
  2091. if status := qu.IntAll(tmpMap["status"]); status != -1 {
  2092. key := qu.ObjToString(tmpMap["key"]) //字段
  2093. if key == "" {
  2094. continue
  2095. }
  2096. if status == 2 { //新增、修改、删除
  2097. input := tmpMap["input"] //值
  2098. if input == "" {
  2099. baseUnset[key] = ""
  2100. } else {
  2101. if key == "bidopentime" || key == "publishtime" || key == "bidendtime" || key == "project_startdate" || key == "project_completedate" {
  2102. inputTmp, _ := time.ParseInLocation(qu.Date_Full_Layout, input.(string), time.Local)
  2103. input = inputTmp.Unix()
  2104. } else if key == "project_duration" {
  2105. input = qu.IntAll(input)
  2106. }
  2107. baseSet[key] = input
  2108. }
  2109. }
  2110. tagSet[key] = status
  2111. }
  2112. }
  2113. }
  2114. }
  2115. }
  2116. func MarkPurchasinglist(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, istag bool, status int) {
  2117. if status == -1 {
  2118. return
  2119. }
  2120. baseSet["purchasinglist_alltag"] = istag //标的信息是否标注完全
  2121. purchasinglist := []interface{}{}
  2122. purchasinglistStatus := []interface{}{}
  2123. delpclson := 0
  2124. for _, con := range content {
  2125. info, _ := con.(map[string]interface{})
  2126. //isNew, _ := info["isnew"].(bool) //是否是新增子包
  2127. pclSonStatus := qu.IntAll(info["status"])
  2128. if pclSonStatus == 4 {
  2129. delpclson++
  2130. }
  2131. if uInputs, ok := info["uInput"].([]interface{}); ok {
  2132. result := map[string]interface{}{
  2133. //"isnew": isNew,
  2134. }
  2135. statusMap := make(map[string]interface{})
  2136. for _, tmp := range uInputs {
  2137. if tmpMap, ok := tmp.(map[string]interface{}); ok {
  2138. key := qu.ObjToString(tmpMap["key"]) //字段
  2139. input := tmpMap["input"] //值
  2140. status := qu.IntAll(tmpMap["status"])
  2141. statusMap[key] = status
  2142. isNull := false
  2143. if input == "" { //判断前台页面是否填值,无值不进行字段存储
  2144. isNull = true
  2145. } else if key == "number" || key == "unitprice" || key == "totalprice" {
  2146. input = qu.Float64All(input)
  2147. }
  2148. if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
  2149. result[key] = input
  2150. }
  2151. }
  2152. }
  2153. if pclSonStatus != -1 { //没有标注的标的信息不打标记
  2154. result["purchasinglist_son"] = pclSonStatus
  2155. }
  2156. if len(result) > 0 && pclSonStatus != 4 {
  2157. purchasinglist = append(purchasinglist, result)
  2158. purchasinglistStatus = append(purchasinglistStatus, statusMap)
  2159. }
  2160. }
  2161. }
  2162. if len(purchasinglist)+delpclson == len(content) {
  2163. if len(purchasinglist) > 0 {
  2164. baseSet["purchasinglist"] = purchasinglist
  2165. } else if len(content) > 0 && delpclson == len(content) { //只有删除
  2166. baseUnset["purchasinglist"] = ""
  2167. }
  2168. //tagSet["purchasinglist"] = status
  2169. tagSet["purchasinglist"] = purchasinglistStatus
  2170. } else {
  2171. qu.Debug("Purchasinglist Tag Error")
  2172. }
  2173. }
  2174. func MarkProcurementList(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, istag bool, status int) {
  2175. if status == -1 {
  2176. return
  2177. }
  2178. baseSet["procurementlist_alltag"] = istag //是否标注完全
  2179. procurementlist := []interface{}{}
  2180. procurementlistStatus := []interface{}{}
  2181. delpclson := 0
  2182. for _, con := range content {
  2183. info, _ := con.(map[string]interface{})
  2184. //isNew, _ := info["isnew"].(bool) //是否是新增子包
  2185. pclSonStatus := qu.IntAll(info["status"])
  2186. if pclSonStatus == 4 {
  2187. delpclson++
  2188. }
  2189. if uInputs, ok := info["uInput"].([]interface{}); ok {
  2190. result := map[string]interface{}{
  2191. //"isnew": isNew,
  2192. }
  2193. statusMap := make(map[string]interface{})
  2194. for _, tmp := range uInputs {
  2195. if tmpMap, ok := tmp.(map[string]interface{}); ok {
  2196. key := qu.ObjToString(tmpMap["key"]) //字段
  2197. input := tmpMap["input"] //值
  2198. status := qu.IntAll(tmpMap["status"])
  2199. statusMap[key] = status
  2200. isNull := false
  2201. if input == "" { //判断前台页面是否填值,无值不进行字段存储
  2202. isNull = true
  2203. } else if key == "number" || key == "unitprice" || key == "totalprice" {
  2204. input = qu.Float64All(input)
  2205. }
  2206. if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
  2207. result[key] = input
  2208. }
  2209. }
  2210. }
  2211. if pclSonStatus != -1 { //没有标注的标的信息不打标记
  2212. result["procurementlist_son"] = pclSonStatus
  2213. }
  2214. if len(result) > 0 && pclSonStatus != 4 {
  2215. procurementlist = append(procurementlist, result)
  2216. procurementlistStatus = append(procurementlistStatus, statusMap)
  2217. }
  2218. }
  2219. }
  2220. if len(procurementlist)+delpclson == len(content) {
  2221. if len(procurementlist) > 0 {
  2222. baseSet["procurementlist"] = procurementlist
  2223. } else if len(content) > 0 && delpclson == len(content) { //只有删除
  2224. baseUnset["procurementlist"] = ""
  2225. }
  2226. //tagSet["purchasinglist"] = status
  2227. tagSet["procurementlist"] = status
  2228. } else {
  2229. qu.Debug("ProcurementList Tag Error")
  2230. }
  2231. }
  2232. // MarkPackage 标注多包信息
  2233. func MarkPackage(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, status int) {
  2234. if status == -1 {
  2235. return
  2236. }
  2237. pkgs := map[string]interface{}{}
  2238. total := 0.0
  2239. newNum := 1
  2240. delpkgson := 0 //记录子包删除个数
  2241. var sw []string
  2242. for _, con := range content {
  2243. info, _ := con.(map[string]interface{})
  2244. pkgSonStatus := qu.IntAll(info["status"])
  2245. if pkgSonStatus == 4 {
  2246. delpkgson++
  2247. }
  2248. num := fmt.Sprint(info["num"]) //包号
  2249. isNew, _ := info["isnew"].(bool) //是否是新增子包
  2250. if isNew { //新增子包新建包名
  2251. num = "new" + fmt.Sprint(newNum)
  2252. newNum++
  2253. }
  2254. if uInputs, ok := info["uInput"].([]interface{}); ok {
  2255. result := map[string]interface{}{
  2256. "isnew": isNew,
  2257. }
  2258. winnerArr := []interface{}{}
  2259. bidamountArr := []interface{}{}
  2260. for _, tmp := range uInputs {
  2261. if tmpMap, ok := tmp.(map[string]interface{}); ok {
  2262. key := qu.ObjToString(tmpMap["key"]) //字段
  2263. input := tmpMap["input"] //值
  2264. isNull := false //记录字段是否有值
  2265. if key == "bidamounttype" {
  2266. input = tmpMap["select"]
  2267. } else {
  2268. if input == "" { //判断前台页面是否填值,无值不进行字段存储
  2269. isNull = true
  2270. } else if key == "bidamount" || key == "budget" {
  2271. input = qu.Float64All(input)
  2272. //input, _ = strconv.ParseFloat(qu.ObjToString(input), 32)
  2273. }
  2274. }
  2275. if key == "winner" {
  2276. if isNull {
  2277. winnerArr = append(winnerArr, nil)
  2278. } else {
  2279. winnerArr = append(winnerArr, input)
  2280. }
  2281. continue
  2282. } else if key == "bidamount" {
  2283. if isNull {
  2284. bidamountArr = append(bidamountArr, nil)
  2285. } else {
  2286. bidamountArr = append(bidamountArr, input)
  2287. }
  2288. continue
  2289. }
  2290. if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
  2291. result[key] = input
  2292. }
  2293. }
  2294. }
  2295. winner_all := []interface{}{}
  2296. if len(winnerArr) == len(bidamountArr) {
  2297. for i, w := range winnerArr {
  2298. b := bidamountArr[i]
  2299. wbMap := map[string]interface{}{}
  2300. if w != nil {
  2301. wbMap["winner"] = w
  2302. sw = append(sw, qu.ObjToString(w))
  2303. }
  2304. if b != nil {
  2305. total += qu.Float64All(b)
  2306. wbMap["bidamount"] = b
  2307. }
  2308. if len(wbMap) > 0 {
  2309. winner_all = append(winner_all, wbMap)
  2310. }
  2311. }
  2312. }
  2313. if len(winner_all) > 0 {
  2314. result["winner_all"] = winner_all
  2315. }
  2316. result["package_son"] = pkgSonStatus
  2317. if len(result) > 0 && pkgSonStatus != 4 { //要删除的子包不再保存
  2318. pkgs[num] = result
  2319. }
  2320. var purList []map[string]interface{}
  2321. // 处理包的标的物
  2322. if plist, ok := info["content"].([]interface{}); ok {
  2323. for _, v := range plist {
  2324. if v1, o1 := v.(map[string]interface{}); o1 {
  2325. if uts, o2 := v1["uInput"].([]interface{}); o2 {
  2326. m1 := make(map[string]interface{})
  2327. for _, tmp := range uts {
  2328. if temp, o3 := tmp.(map[string]interface{}); o3 {
  2329. if qu.ObjToString(temp["key"]) != "" && qu.ObjToString(temp["input"]) != "" {
  2330. m1[qu.ObjToString(temp["key"])] = qu.ObjToString(temp["input"])
  2331. }
  2332. }
  2333. }
  2334. if len(m1) > 0 {
  2335. purList = append(purList, m1)
  2336. }
  2337. }
  2338. }
  2339. }
  2340. if len(purList) > 0 {
  2341. result["purchasinglist"] = purList
  2342. }
  2343. qu.Debug(purList)
  2344. }
  2345. }
  2346. }
  2347. if len(pkgs)+delpkgson == len(content) {
  2348. if len(pkgs) > 0 {
  2349. baseSet["package"] = pkgs
  2350. baseSet["s_winner"] = strings.Join(sw, ",")
  2351. baseSet["bidamount"] = total
  2352. } else if len(content) == 0 { //只有删除
  2353. baseUnset["package"] = ""
  2354. }
  2355. tagSet["package"] = status
  2356. } else {
  2357. qu.Debug("Package Tag Error")
  2358. }
  2359. }
  2360. // 标注中标候选人信息
  2361. func MarkWonderorder(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, status int) {
  2362. if status == -1 {
  2363. return
  2364. }
  2365. winnerorder := []interface{}{}
  2366. delwodrson := 0
  2367. for _, con := range content {
  2368. info, _ := con.(map[string]interface{})
  2369. isNew, _ := info["isnew"].(bool) //是否是新增子包
  2370. wodrSonStatus := qu.IntAll(info["status"])
  2371. if wodrSonStatus == 4 {
  2372. delwodrson++
  2373. }
  2374. if uInputs, ok := info["uInput"].([]interface{}); ok {
  2375. result := map[string]interface{}{
  2376. "isnew": isNew,
  2377. }
  2378. for _, tmp := range uInputs {
  2379. if tmpMap, ok := tmp.(map[string]interface{}); ok {
  2380. key := qu.ObjToString(tmpMap["key"]) //字段
  2381. input := tmpMap["input"] //值
  2382. isNull := false
  2383. if input == "" { //判断前台页面是否填值,无值不进行字段存储
  2384. isNull = true
  2385. } else if key == "price" {
  2386. input = qu.Float64All(input)
  2387. //input, _ = strconv.ParseFloat(qu.ObjToString(input), 32)
  2388. }
  2389. if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
  2390. result[key] = input
  2391. }
  2392. result["winnerorder_son"] = wodrSonStatus
  2393. }
  2394. }
  2395. if len(result) > 0 && wodrSonStatus != 4 {
  2396. winnerorder = append(winnerorder, result)
  2397. }
  2398. }
  2399. }
  2400. if len(winnerorder)+delwodrson == len(content) {
  2401. if len(winnerorder) > 0 {
  2402. baseSet["winnerorder"] = winnerorder
  2403. } else if len(content) > 0 && delwodrson == len(content) { //只有删除
  2404. baseUnset["winnerorder"] = ""
  2405. }
  2406. tagSet["winnerorder"] = status
  2407. } else {
  2408. qu.Debug("Winnerorder Tag Error")
  2409. }
  2410. }
  2411. // 标注其他信息
  2412. func MarkOther(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}) {
  2413. info, _ := content[0].(map[string]interface{})
  2414. if uInputs, ok := info["uInput"].([]interface{}); ok {
  2415. for _, tmp := range uInputs {
  2416. if tmpMap, ok := tmp.(map[string]interface{}); ok {
  2417. if status := qu.IntAll(tmpMap["status"]); status != -1 {
  2418. key := qu.ObjToString(tmpMap["key"]) //字段
  2419. if key == "" {
  2420. continue
  2421. }
  2422. if status == 2 { //新增、修改、删除
  2423. input := tmpMap["input"] //值
  2424. if tmpMap["selectArr"] != nil && tmpMap["select"] != nil {
  2425. input = tmpMap["select"]
  2426. }
  2427. if input == "" {
  2428. baseUnset[key] = ""
  2429. } else {
  2430. if key == "signaturedate" {
  2431. inputTmp, _ := time.ParseInLocation(qu.Date_Full_Layout, input.(string), time.Local)
  2432. input = inputTmp.Unix()
  2433. } else if key == "bid_bond" || key == "contract_bond" || key == "supervisorrate" || key == "agencyrate" || key == "docamount" || key == "agencyfee" ||
  2434. key == "biddiscount" {
  2435. input = qu.Float64All(input)
  2436. //input, _ = strconv.ParseFloat(qu.ObjToString(input), 32)
  2437. }
  2438. baseSet[key] = input
  2439. }
  2440. }
  2441. tagSet[key] = status
  2442. }
  2443. }
  2444. }
  2445. }
  2446. }
  2447. // SaveLog 标注日志保存
  2448. func SaveLog(s_infoid, s_usertaskid, username, userid, role, projectname, s_stype string, baseInfo, allTagFields map[string]interface{}) (success bool) {
  2449. defer qu.Catch()
  2450. v_before := map[string]interface{}{}
  2451. for f, v := range allTagFields {
  2452. if _, ok := v.(bool); ok && f != "purchasinglist_alltag" { //表示此次标注status=1的字段
  2453. allTagFields[f] = baseInfo[f]
  2454. }
  2455. v_before[f] = baseInfo[f]
  2456. }
  2457. save := map[string]interface{}{
  2458. "s_projectname": projectname,
  2459. "s_taskid": s_usertaskid,
  2460. "s_infoid": s_infoid,
  2461. "s_stype": s_stype,
  2462. "s_userid": userid,
  2463. "s_role": role,
  2464. "s_username": username,
  2465. "i_createtime": time.Now().Unix(),
  2466. "v_before": v_before,
  2467. "v_after": allTagFields,
  2468. }
  2469. id := util.Mgo.Save(util.LOGCOLLNAME, save)
  2470. if id != "" {
  2471. success = true
  2472. }
  2473. return
  2474. }
  2475. func (f *Front) CheckDataPurchase() {
  2476. defer qu.Catch()
  2477. if f.Method() == "POST" {
  2478. datatype, _ := f.GetInteger("datatype")
  2479. stype := f.GetString("stype")
  2480. tid := f.GetString("taskid")
  2481. pid := f.GetString("pid")
  2482. appid := f.GetString("appid")
  2483. keyword := f.GetString("keyword")
  2484. keyword = strings.ReplaceAll(keyword, ",", ",")
  2485. keyArr := strings.Split(keyword, ",")
  2486. query := make(map[string]interface{})
  2487. if tid != "" {
  2488. query["b_istag"] = true
  2489. if stype == "group" {
  2490. query["s_grouptaskid"] = tid
  2491. } else {
  2492. query["s_usertaskid"] = tid
  2493. }
  2494. } else {
  2495. query["appid"] = appid
  2496. if stype == "notag" {
  2497. query["b_istagging"] = false
  2498. if datatype == 1 {
  2499. // 待分发数据
  2500. query["b_isgivegroup"] = false
  2501. } else {
  2502. // 已分发 标注数据
  2503. query["b_istag"] = true
  2504. query["b_isgivegroup"] = true
  2505. }
  2506. } else if stype == "tag" { //未达标
  2507. query["b_istagging"] = true
  2508. query["i_ckdata"] = 2
  2509. } else {
  2510. query["i_ckdata"] = 2
  2511. }
  2512. }
  2513. util.Mgo.UpdateById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"$set": map[string]interface{}{"purchasinglist_key": keyword}})
  2514. query["v_baseinfo.purchasinglist"] = map[string]interface{}{"$exists": true}
  2515. info, _ := util.Mgo.Find(util.DATACOLLNAME, query, `{"_id": 1}`, `{"v_baseinfo": 1, "b_isEff": 1, "v_checkinfo": 1, "v_taginfo": 1}`, false, -1, -1)
  2516. var updateArr [][]map[string]interface{}
  2517. for _, m := range *info {
  2518. baseinfo := m["v_baseinfo"].(map[string]interface{})
  2519. //taginfo := m["v_taginfo"].(map[string]interface{})
  2520. //checkinfo := m["v_checkinfo"].(map[string]interface{})
  2521. //var pursTag, pursCheck []interface{}
  2522. purs := baseinfo["purchasinglist"].([]interface{})
  2523. //if taginfo["purchasinglist"] != nil {
  2524. // pursTag = taginfo["purchasinglist"].([]interface{})
  2525. //}
  2526. //if checkinfo["purchasinglist"] != nil {
  2527. // pursCheck = checkinfo["purchasinglist"].([]interface{})
  2528. //}
  2529. if len(purs) > 0 {
  2530. //arr1 := []map[string]interface{}{} //检验通过
  2531. //arr2 := []map[string]interface{}{} //检验未通过
  2532. for _, m2 := range qu.ObjArrToMapArr(purs) {
  2533. if validPurchase(keyArr, qu.ObjToString(m2["itemname"])) {
  2534. m2["b_isEff"] = true
  2535. if m["b_isEff"] != nil && !m["b_isEff"].(bool) {
  2536. m["b_isEff"] = true
  2537. }
  2538. //arr1 = append(arr1, m2)
  2539. } else {
  2540. m2["b_isEff"] = false
  2541. //arr2 = append(arr2, m2)
  2542. }
  2543. }
  2544. //baseinfo["purchasinglist"] = append(arr1, arr2...)
  2545. var update []map[string]interface{}
  2546. update = append(update, map[string]interface{}{"_id": m["_id"]})
  2547. update = append(update, map[string]interface{}{"$set": m})
  2548. updateArr = append(updateArr, update)
  2549. }
  2550. if len(updateArr) > 500 {
  2551. tmps := updateArr
  2552. util.Mgo.UpdateBulk(util.DATACOLLNAME, tmps...)
  2553. updateArr = [][]map[string]interface{}{}
  2554. }
  2555. }
  2556. if len(updateArr) > 0 {
  2557. util.Mgo.UpSertBulk(util.DATACOLLNAME, updateArr...)
  2558. }
  2559. f.ServeJson(map[string]interface{}{"success": true, "msg": ""})
  2560. }
  2561. }
  2562. func validPurchase(arr []string, str string) bool {
  2563. for _, s := range arr {
  2564. if strings.Contains(str, s) {
  2565. return true
  2566. }
  2567. }
  2568. return false
  2569. }