remark.go 82 KB

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