123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535 |
- package front
- import (
- "encoding/json"
- "fmt"
- "github.com/shopspring/decimal"
- "go.mongodb.org/mongo-driver/bson"
- "math"
- mgo "mongodb"
- qu "qfw/util"
- "regexp"
- "sort"
- "strconv"
- "strings"
- "sync"
- "time"
- "util"
- )
- var (
- purchasingField = map[string]string{"itemname": "名称", "brandname": "品牌", "modal": "型号", "unitprice": "单价", "number": "数量"}
- )
- func (f *Front) RemarkList() {
- qu.Catch()
- pid := qu.ObjToString(f.GetString("pid"))
- tid := qu.ObjToString(f.GetString("tid"))
- sourceinfo := qu.ObjToString(f.GetString("s_sourceinfo"))
- if f.Method() == "POST" {
- //user := f.GetSession("user").(map[string]interface{})
- start, _ := f.GetInteger("start")
- limit, _ := f.GetInteger("length")
- draw, _ := f.GetInteger("draw")
- searchStr := f.GetString("search[value]")
- search := strings.TrimSpace(searchStr)
- query := map[string]interface{}{"s_usertaskid": tid}
- ckdata, err := f.GetInteger("i_ckdata")
- if err != nil {
- ckdata = -1
- }
- if ckdata == 0 {
- query["b_istag"] = false
- } else if ckdata == 1 {
- query["b_istag"] = true
- }
- if search != "" {
- query["$or"] = []interface{}{
- bson.M{"v_baseinfo.title": bson.M{"$regex": search}},
- }
- }
- qu.Debug(query)
- field := map[string]interface{}{"v_baseinfo.title": 1, "b_istag": 1, "i_ckdata": 1}
- info, _ := util.Mgo.Find(sourceinfo, query, `{"_id": 1}`, field, false, start, limit)
- count := util.Mgo.Count(sourceinfo, query)
- qu.Debug(query, sourceinfo, count)
- f.ServeJson(map[string]interface{}{
- "draw": draw,
- "data": *info,
- "recordsFiltered": count,
- "recordsTotal": count,
- })
- } else {
- f.T["pid"] = pid
- f.T["tid"] = tid
- f.T["s_sourceinfo"] = sourceinfo
- _ = f.Render("project/remark_list.html", &f.T)
- }
- }
- func (f *Front) RemarkDetail() {
- pid := f.GetString("pid")
- tid := f.GetString("tid")
- did := f.GetString("did")
- coll := f.GetString("s_sourceinfo")
- project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, `{"v_fields": 1}`)
- if len(*project) > 0 {
- field := make(map[string]bool)
- vf := (*project)["v_fields"].(map[string]interface{})
- for k := range vf {
- field[k] = true
- }
- f.T["fields"] = field
- }
- qu.Debug(pid, did, coll)
- rep := getDetail(did, coll) //获取本条公告的信息
- f.T["otherInfo"] = rep["otherInfo"] //展示关联公告信息
- f.T["moreInfo"] = rep["moreInfo"] //更多关联公告信息
- f.T["pid"] = pid
- f.T["tid"] = tid
- f.T["did"] = did
- f.T["coll"] = coll
- f.T["info"] = rep["info"]
- f.T["common"] = rep["common"]
- f.T["worder"] = rep["worder"]
- f.T["packs"] = rep["packs"]
- f.T["packskey"] = rep["packskey"]
- f.T["ck_pclistag"] = rep["purchasingTag"]
- f.T["timeplace"] = rep["timeplace"]
- f.T["purchasinglist"] = rep["purchasinglist"]
- f.T["procurementlist"] = rep["procurementlist"]
- f.T["other"] = rep["other"]
- f.T["PurchasinglistField"] = util.PurchasinglistField
- f.T["ProcurementlistField"] = util.PurchasinglistField1
- f.T["WinnerorderField"] = util.WinnerorderField
- f.T["PackageField"] = util.PackageField
- f.T["topsubtype"] = util.TopSubStypeArr2
- f.T["ck_purchasinglist"] = rep["ck_purchasinglist"]
- f.T["ck_package"] = rep["ck_package"]
- f.T["ck_winnerorder"] = rep["ck_winnerorder"]
- f.T["worder_new"] = rep["worder_new"]
- f.T["pcl_new"] = rep["pcl_new"]
- f.T["pcl_new_1"] = rep["pcl_new_1"]
- f.T["pkg_new"] = rep["pkg_new"]
- f.T["keyword"] = rep["matchkey"]
- f.T["nextid"] = GetNextDataId(did, coll, tid) //下一条id
- _ = f.Render("project/remark_detail.html", &f.T)
- }
- func getDetail(id, coll string) map[string]interface{} {
- rep := map[string]interface{}{}
- infoTmp, _ := util.Mgo.FindById(coll, id, ``)
- rep["s_excp_info"] = (*infoTmp)["s_excp_info"]
- baseInfo := (*infoTmp)["v_baseinfo"].(map[string]interface{}) //字段值
- var bzInfo map[string]interface{} //标注信息
- if (*infoTmp)["v_taginfo"] != nil {
- bzInfo = (*infoTmp)["v_taginfo"].(map[string]interface{})
- } else {
- bzInfo = make(map[string]interface{})
- }
- baseInfo["detail"] = qu.ObjToString(baseInfo["title"]) + "</br>" + qu.ObjToString(baseInfo["detail"])
- baseInfo["_id"] = mgo.BsonIdToSId(baseInfo["_id"])
- purchasingTag, _ := baseInfo["purchasinglist_alltag"].(bool)
- rep["purchasingTag"] = purchasingTag
- href := qu.ObjToString(baseInfo["href"])
- if !strings.HasPrefix(href, "http") {
- baseInfo["href"] = "https://" + href
- }
- rep["matchkey"] = baseInfo["matchkey"]
- rep["info"] = baseInfo
- common, timeplace, other := setExtComMap(baseInfo, bzInfo) //拼装抽取common值
- rep["common"] = common
- rep["timeplace"] = timeplace
- rep["other"] = other
- packs, packskey, pkg_new := setPaceMap(baseInfo) //拼装子包信息
- rep["packs"] = packs
- rep["packskey"] = packskey
- rep["pkg_new"] = pkg_new
- purchasinglist, isNewStatus := setPurchasingMap(baseInfo) //标的物
- rep["purchasinglist"] = purchasinglist
- rep["pcl_new"] = isNewStatus
- purchasinglist_1, isNewStatus1 := setPurchasingMap1(baseInfo) //标的物(采购意向)
- rep["procurementlist"] = purchasinglist_1
- rep["pcl_new_1"] = isNewStatus1
- worder, worder_new := setWorderMap(baseInfo) //中标候选人
- rep["worder"] = worder
- rep["worder_new"] = worder_new
- otherInfo, moreInfo := setOtherInfo(baseInfo) //处理公告关联信息
- rep["otherInfo"] = otherInfo
- rep["moreInfo"] = moreInfo
- //
- if bzInfo["purchasinglist"] != nil {
- rep["ck_purchasinglist"] = "1"
- } else {
- rep["ck_purchasinglist"] = "-1"
- }
- if bzInfo["package"] != nil {
- rep["ck_package"] = "1"
- } else {
- rep["ck_package"] = "-1"
- }
- if bzInfo["winnerorder"] != nil {
- rep["ck_winnerorder"] = "1"
- } else {
- rep["ck_winnerorder"] = "-1"
- }
- return rep
- }
- // 拼装抽取common值
- func setExtComMap(info, bzInfo map[string]interface{}) ([]interface{}, []interface{}, []interface{}) {
- //基本参数
- common, _ := util.BiaoZhu["common"].([]interface{})
- for k, tmp := range common {
- if cp, ok := tmp.(map[string]interface{}); ok {
- if info[fmt.Sprint(cp["key"])] == nil {
- cp["value"] = ""
- } else {
- if cp["key"] == "subtype" {
- if info["toptype"] != nil && info["subtype"] != nil {
- cp["value"] = qu.ObjToString(info["toptype"]) + "-" + qu.ObjToString(info[fmt.Sprint(cp["key"])])
- } else {
- cp["value"] = ""
- }
- } else {
- cp["value"] = info[fmt.Sprint(cp["key"])]
- }
- }
- if bzInfo[fmt.Sprint(cp["key"])] == nil {
- cp["status"] = "-1"
- } else {
- cp["status"] = "1"
- }
- common[k] = cp
- }
- }
- //时间地点信息
- timeplace, _ := util.BiaoZhu["timeplace"].([]interface{})
- for k, tmp := range timeplace {
- if tp, ok := tmp.(map[string]interface{}); ok {
- if info[fmt.Sprint(tp["key"])] == nil {
- tp["value"] = ""
- } else {
- key := tp["key"]
- if key == "bidopentime" || key == "publishtime" || key == "bidendtime" || key == "project_startdate" || key == "project_completedate" {
- tmpTime := qu.Int64All(info[fmt.Sprint(tp["key"])])
- if tmpTime > 0 {
- tp["value"] = qu.FormatDateByInt64(&tmpTime, qu.Date_Full_Layout)
- } else {
- tp["value"] = info[qu.ObjToString(tp["key"])]
- }
- } else {
- tp["value"] = info[fmt.Sprint(tp["key"])]
- }
- }
- if bzInfo[fmt.Sprint(tp["key"])] == nil {
- tp["status"] = "-1"
- } else {
- tp["status"] = "1"
- }
- timeplace[k] = tp
- }
- }
- //other信息
- other, _ := util.BiaoZhu["other"].([]interface{})
- for k, tmp := range other {
- if cp, ok := tmp.(map[string]interface{}); ok {
- if info[fmt.Sprint(cp["key"])] == nil {
- cp["value"] = ""
- } else {
- if cp["key"] == "signaturedate" {
- bidopentime := qu.Int64All(info[fmt.Sprint(cp["key"])])
- if bidopentime > 0 {
- cp["value"] = qu.FormatDateByInt64(&bidopentime, qu.Date_Full_Layout)
- } else {
- cp["value"] = info[qu.ObjToString(cp["key"])]
- }
- } else {
- cp["value"] = info[fmt.Sprint(cp["key"])]
- }
- }
- //log.Println(cp)
- if bzInfo[fmt.Sprint(cp["key"])] == nil {
- cp["status"] = "-1"
- } else {
- cp["status"] = "1"
- }
- other[k] = cp
- }
- }
- return common, timeplace, other
- }
- // 拼装子包信息
- func setPaceMap(info map[string]interface{}) ([]map[string]interface{}, []string, []bool) {
- var confpack []interface{}
- confpack, _ = util.BiaoZhu["package"].([]interface{})
- //bzpack := bzInfo["package"].(map[string]interface{})
- packs := map[string]map[string]interface{}{}
- var sortpackskey []string
- isNewPkg := map[string]bool{} //记录子包是否是新增的
- if packages, ok := info["package"].(map[string]interface{}); ok && len(packages) > 0 {
- for k, tmpackage := range packages { //遍历分包
- if tmppack, ok := tmpackage.(map[string]interface{}); ok {
- //isNew, _ := tmppack["isnew"].(bool)
- isNew := false
- status := "-1"
- if tmppack["package_son"] != nil {
- status = "1"
- }
- isNewPkg[k] = isNew
- sortpackskey = append(sortpackskey, k)
- var pack []interface{}
- for _, cpack := range confpack {
- cpack, _ := cpack.(map[string]interface{})
- key := qu.ObjToString(cpack["key"])
- if key == "winner" || key == "bidamount" { //中标单位和中标金额winner_all特殊处理
- continue
- }
- tp := map[string]interface{}{
- "key": key,
- "descript": cpack["descript"],
- }
- if tmppack[fmt.Sprint(tp["key"])] != nil {
- tp["value"] = tmppack[qu.ObjToString(tp["key"])]
- } else {
- tp["value"] = ""
- }
- tp["status"] = status
- pack = append(pack, tp)
- }
- //特殊处理中标单位和中标金额
- winnerall := []interface{}{}
- if tmpWinnerAll, ok := tmppack["winner_all"].([]interface{}); ok && len(tmpWinnerAll) > 0 {
- for _, tmp := range tmpWinnerAll {
- tmpMap := tmp.(map[string]interface{})
- win := map[string]interface{}{
- "descript": "标段(包)中标单位",
- "key": "winner",
- "status": status,
- "value": qu.ObjToString(tmpMap["winner"]),
- }
- winnerall = append(winnerall, win)
- var bidamount interface{}
- if tmpMap["bidamount"] == nil {
- bidamount = ""
- } else {
- bidamount = strconv.FormatFloat(qu.Float64All(tmpMap["bidamount"]), 'f', -1, 64)
- }
- bid := map[string]interface{}{
- "descript": "标段(包)中标金额",
- "key": "bidamount",
- "status": status,
- "value": bidamount,
- }
- winnerall = append(winnerall, bid)
- }
- } else {
- winnerall = append(winnerall, map[string]interface{}{
- "descript": "标段(包)中标单位",
- "key": "winner",
- "status": "-1",
- "value": "",
- })
- winnerall = append(winnerall, map[string]interface{}{
- "descript": "标段(包)中标金额",
- "key": "bidamount",
- "status": "-1",
- "value": "",
- })
- }
- packs[k] = map[string]interface{}{
- "pack": pack,
- "packstatus": status,
- "winnerall": winnerall,
- }
- }
- }
- }
- sort.Strings(sortpackskey)
- var packages []map[string]interface{}
- var isNewPkgArr []bool
- for _, v := range sortpackskey {
- packages = append(packages, packs[v])
- isNewPkgArr = append(isNewPkgArr, isNewPkg[v])
- }
- return packages, sortpackskey, isNewPkgArr
- }
- // 拼装标的物
- func setPurchasingMap(info map[string]interface{}) ([]interface{}, []map[string]interface{}) {
- purchasinglist, _ := util.BiaoZhu["purchasinglist"].([]interface{})
- var purchasinglists []interface{}
- //isNewPcl := []bool{} //记录子包是否是新增的
- var isNewAndStatus []map[string]interface{}
- if tmpcls, ok := info["purchasinglist"].([]interface{}); ok {
- for _, v := range tmpcls {
- if pcl, ok := v.(map[string]interface{}); ok {
- //isNew, _ := pcl["isnew"].(bool)
- isNew := false
- status := "-1"
- if pcl["purchasinglist_son"] != nil {
- status = "1"
- }
- //isNewPcl = append(isNewPcl, isNew)
- isNewAndStatus = append(isNewAndStatus, map[string]interface{}{"isnew": isNew, "status": status})
- var pcls []interface{}
- for _, ps := range purchasinglist {
- ps, _ := ps.(map[string]interface{})
- value := pcl[qu.ObjToString(ps["key"])]
- if value == nil {
- value = ""
- }
- tp := map[string]interface{}{
- "key": ps["key"],
- "descript": ps["descript"],
- "value": value,
- "status": status,
- }
- // if pcl[preKey+fmt.Sprint(tp["key"])] == nil {
- // tp["status"] = "-1"
- // } else {
- // tp["status"] = "1"
- // }
- pcls = append(pcls, tp)
- }
- purchasinglists = append(purchasinglists, pcls)
- }
- }
- }
- return purchasinglists, isNewAndStatus
- }
- // 采购意向
- func setPurchasingMap1(info map[string]interface{}) ([]interface{}, []map[string]interface{}) {
- procurementlist, _ := util.BiaoZhu["procurementlist"].([]interface{})
- var procurementlists []interface{}
- //isNewPcl := []bool{} //记录子包是否是新增的
- var isNewAndStatus []map[string]interface{}
- if tmpcls, ok := info["procurementlist"].([]interface{}); ok {
- for _, v := range tmpcls {
- if pcl, ok := v.(map[string]interface{}); ok {
- //isNew, _ := pcl["isnew"].(bool)
- isNew := false
- status := "-1"
- if pcl["purchasinglist_son"] != nil {
- status = "1"
- }
- //isNewPcl = append(isNewPcl, isNew)
- isNewAndStatus = append(isNewAndStatus, map[string]interface{}{"isnew": isNew, "status": status})
- var pcls []interface{}
- for _, ps := range procurementlist {
- ps, _ := ps.(map[string]interface{})
- value := pcl[qu.ObjToString(ps["key"])]
- if value == nil {
- value = ""
- }
- tp := map[string]interface{}{
- "key": ps["key"],
- "descript": ps["descript"],
- "value": value,
- "status": status,
- }
- // if pcl[preKey+fmt.Sprint(tp["key"])] == nil {
- // tp["status"] = "-1"
- // } else {
- // tp["status"] = "1"
- // }
- pcls = append(pcls, tp)
- }
- procurementlists = append(procurementlists, pcls)
- }
- }
- }
- return procurementlists, isNewAndStatus
- }
- // 拼装中标候选人
- func setWorderMap(info map[string]interface{}) ([]interface{}, []map[string]interface{}) {
- //基本参数--中标候选人
- winnerorder, _ := util.BiaoZhu["winnerorder"].([]interface{})
- worders := []interface{}{}
- isNewAndStatus := []map[string]interface{}{}
- if tmpwds, ok := info["winnerorder"].([]interface{}); ok {
- for _, v := range tmpwds {
- if wd, ok := v.(map[string]interface{}); ok {
- //isNew, _ := wd["isnew"].(bool)
- isNew := false
- status := "-1"
- if wd["winnerorder_son"] != nil {
- status = "1"
- }
- isNewAndStatus = append(isNewAndStatus, map[string]interface{}{"isnew": isNew, "status": status})
- wds := []interface{}{}
- for _, cp := range winnerorder {
- cp, _ := cp.(map[string]interface{})
- value := wd[qu.ObjToString(cp["key"])]
- if value == nil {
- value = ""
- }
- tp := map[string]interface{}{
- "key": cp["key"],
- "descript": cp["descript"],
- "value": value,
- "status": status,
- }
- wds = append(wds, tp)
- }
- worders = append(worders, wds)
- }
- }
- }
- return worders, isNewAndStatus
- }
- // 获取公告关联信息
- func setOtherInfo(info map[string]interface{}) (result, moreArr []map[string]interface{}) {
- if otherInfo, ok := info["info"].([]interface{}); ok && len(otherInfo) > 0 {
- //中标,成交、合同、招标(不含变更)
- /*
- [
- {},
- {},
- ]
- */
- zbArr := []map[string]interface{}{}
- cjArr := []map[string]interface{}{}
- htArr := []map[string]interface{}{}
- zbbArr := []map[string]interface{}{}
- for _, tmp := range otherInfo {
- tmpInfo := tmp.(map[string]interface{})
- tmpInfo["detail"] = qu.ObjToString(tmpInfo["title"]) + "</br>" + qu.ObjToString(tmpInfo["title"])
- toptype := tmpInfo["toptype"]
- subtype := tmpInfo["subtype"]
- ptime := ""
- tmpPtime := qu.Int64All(tmpInfo["publishtime"])
- if tmpPtime > 0 {
- ptime = qu.FormatDateByInt64(&tmpPtime, qu.Date_Full_Layout)
- }
- tmpInfo["publishtime_str"] = ptime
- if subtype == "中标" {
- zbArr = append(zbArr, tmpInfo)
- } else if subtype == "成交" {
- cjArr = append(cjArr, tmpInfo)
- } else if subtype == "合同" {
- htArr = append(htArr, tmpInfo)
- } else if toptype == "招标" && subtype != "变更" {
- zbbArr = append(zbbArr, tmpInfo)
- } else { //标注页不展示的信息,更多中展示
- moreArr = append(moreArr, map[string]interface{}{
- "publishtime": tmpInfo["publishtime_str"],
- "subtype": subtype,
- "title": tmpInfo["title"],
- "href": util.GetJyHref(qu.ObjToString(tmpInfo["id"])),
- })
- }
- }
- publishtime := qu.Float64All(info["publishtime"])
- //中标信息
- if zbLen := len(zbArr); zbLen > 0 {
- rzb := DealData(zbLen, publishtime, zbArr, &moreArr)
- result = append(result, rzb)
- }
- //成交
- if cjLen := len(cjArr); cjLen > 0 {
- rcj := DealData(cjLen, publishtime, cjArr, &moreArr)
- result = append(result, rcj)
- }
- //合同
- if htLen := len(htArr); htLen > 0 {
- rht := DealData(htLen, publishtime, htArr, &moreArr)
- result = append(result, rht)
- }
- result = append(result, zbbArr...)
- }
- return
- }
- func DealData(tmpLen int, publishtime float64, tmp []map[string]interface{}, moreArr *[]map[string]interface{}) (resultTmp map[string]interface{}) {
- if tmpLen == 1 || publishtime <= 0 { //相同类型只有一条或者原公告发布时间异常取第一条公告
- resultTmp = tmp[0]
- for _, t := range tmp[1:] { //将过滤掉的数据加入到更多中
- *moreArr = append(*moreArr, map[string]interface{}{
- "publishtime": t["publishtime_str"],
- "subtype": t["subtype"],
- "title": t["title"],
- "href": util.GetJyHref(qu.ObjToString(t["id"])),
- })
- }
- return
- } else {
- diff := float64(0) //记录差值
- index := 0
- for i, zb := range tmp {
- pTmp := qu.Float64All(zb["publishtime"])
- diffTmp := math.Abs(publishtime - pTmp) //绝对值
- if i == 0 {
- diff = diffTmp
- } else if diffTmp < diff { //记录较小差值的数据索引位置
- diff = diffTmp
- index = i
- } else { //将过滤掉的数据加入到更多中
- *moreArr = append(*moreArr, map[string]interface{}{
- "publishtime": zb["publishtime_str"],
- "subtype": zb["subtype"],
- "title": zb["title"],
- "href": util.GetJyHref(qu.ObjToString(zb["id"])),
- })
- }
- }
- resultTmp = tmp[index]
- }
- return
- }
- // GetNextDataId 获取当前数据下一条的id
- func GetNextDataId(id, coll, tid string) string {
- nextIdQuery := map[string]interface{}{
- "b_istag": false,
- "_id": map[string]interface{}{
- "$gt": mgo.StringTOBsonId(id),
- },
- }
- if tid != "" {
- nextIdQuery["s_usertaskid"] = tid
- }
- qu.Debug(nextIdQuery)
- one, _ := util.Mgo.Find(coll, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
- qu.Debug((*one)[0])
- if len(*one) == 1 && len((*one)[0]) > 0 {
- return mgo.BsonIdToSId((*one)[0]["_id"])
- } else {
- delete(nextIdQuery, "_id")
- qu.Debug(nextIdQuery)
- one, _ = util.Mgo.Find(coll, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
- if len(*one) == 1 && len((*one)[0]) > 0 {
- if mgo.BsonIdToSId((*one)[0]["_id"]) == id {
- return ""
- }
- return mgo.BsonIdToSId((*one)[0]["_id"])
- }
- }
- return ""
- }
- // GetNextDataId1 质检下一条
- func GetNextDataId1(id, coll, tid, tag string) string {
- nextIdQuery := map[string]interface{}{
- "_id": map[string]interface{}{
- "$gt": mgo.StringTOBsonId(id),
- },
- "b_check": false,
- }
- if tid != "" {
- // 数据有任务 查询带上标注标记
- nextIdQuery["i_ckdata"] = 2
- if tag == "group" {
- nextIdQuery["s_grouptaskid"] = tid
- } else {
- nextIdQuery["s_usertaskid"] = tid
- }
- } else {
- nextIdQuery["i_ckdata"] = 2
- }
- qu.Debug(nextIdQuery, coll)
- one, _ := util.Mgo.Find(coll, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
- if len(*one) == 1 && len((*one)[0]) > 0 {
- return mgo.BsonIdToSId((*one)[0]["_id"])
- } else {
- delete(nextIdQuery, "_id")
- one, _ = util.Mgo.Find(coll, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
- if len(*one) == 1 && len((*one)[0]) > 0 {
- if mgo.BsonIdToSId((*one)[0]["_id"]) == id {
- return ""
- }
- return mgo.BsonIdToSId((*one)[0]["_id"])
- }
- }
- return ""
- }
- func (f *Front) CheckList() {
- qu.Catch()
- if f.Method() == "POST" {
- user := f.GetSession("user").(map[string]interface{})
- iRole := qu.ObjToString(user["i_role"])
- gid := qu.ObjToString(user["s_groupid"])
- start, _ := f.GetInteger("start")
- limit, _ := f.GetInteger("length")
- draw, _ := f.GetInteger("draw")
- status := f.GetString("s_status")
- searchStr := f.GetString("search[value]")
- search := strings.TrimSpace(searchStr)
- query := map[string]interface{}{
- "s_stype": "user",
- }
- if iRole != "0" {
- query["s_groupid"] = gid
- }
- if status != "-1" { //任务状态
- query["s_status"] = status
- } else {
- query["s_status"] = map[string]interface{}{
- "$in": []string{"未开始", "进行中", "已完成"},
- }
- }
- if search != "" {
- query["$or"] = []interface{}{
- map[string]interface{}{"s_projectname": map[string]interface{}{"$regex": search}},
- }
- }
- qu.Debug("Query:", query)
- count := util.Mgo.Count(util.TASKCOLLNAME, query)
- list, _ := util.Mgo.Find(util.TASKCOLLNAME, query, bson.M{"_id": -1}, nil, false, start, limit)
- for _, l := range *list {
- if status := qu.ObjToString(l["s_status"]); status == "进行中" { //更新任务进度
- giveNum := qu.IntAll(l["i_givenum"])
- sourceinfo := qu.ObjToString(l["s_sourceinfo"])
- tagNum := util.Mgo.Count(sourceinfo, map[string]interface{}{"s_usertaskid": mgo.BsonIdToSId(l["_id"]), "b_istag": true})
- progressFloat := float64(tagNum) / float64(giveNum)
- value, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", progressFloat), 64)
- decimalValue := decimal.NewFromFloat(value)
- decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
- value, _ = decimalValue.Float64()
- progress := fmt.Sprint(value) + "%"
- l["s_progress"] = progress
- }
- }
- f.ServeJson(map[string]interface{}{"draw": draw, "data": *list, "recordsFiltered": count, "recordsTotal": count})
- } else {
- _ = f.Render("project/check_task_list.html")
- }
- }
- func (f *Front) CheckData() {
- qu.Catch()
- pid := f.GetString("pid")
- gid := f.GetString("gid")
- tid := f.GetString("tid")
- sourceinfo := f.GetString("s_sourceinfo")
- if f.Method() == "POST" {
- start, _ := f.GetInteger("start")
- limit, _ := f.GetInteger("length")
- draw, _ := f.GetInteger("draw")
- query := make(map[string]interface{})
- query["b_istag"] = true
- query["s_usertaskid"] = tid
- status := f.GetString("s_status")
- s_excp := f.GetString("s_excp")
- if status == "1" {
- query["b_check"] = true
- } else if status == "-1" {
- query["b_check"] = false
- } else {
- query["b_istag"] = true // 默认查询 已标注数据
- }
- if s_excp == "1" {
- query["s_excp"] = nil
- } else if s_excp == "-1" {
- query["s_excp"] = map[string]interface{}{"$exists": true}
- }
- qu.Debug(query)
- count := util.Mgo.Count(sourceinfo, query)
- 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}
- info, _ := util.Mgo.Find(sourceinfo, query, `{"_id": 1}`, fields, false, start, limit)
- f.ServeJson(map[string]interface{}{
- "draw": draw,
- "data": *info,
- "recordsFiltered": count,
- "recordsTotal": count,
- })
- } else {
- task, _ := util.Mgo.FindById(util.TASKCOLLNAME, tid, map[string]interface{}{"i_givenum": 1})
- f.T["taskNum"] = (*task)["i_givenum"]
- tagCount, checkCount := 0, 0
- tagCount = util.Mgo.Count(sourceinfo, map[string]interface{}{"s_usertaskid": tid, "b_istag": true})
- checkCount = util.Mgo.Count(sourceinfo, map[string]interface{}{"s_usertaskid": tid, "b_check": true})
- f.T["taskTagNum"] = tagCount
- f.T["taskCheckNum"] = checkCount
- f.T["pid"] = pid
- f.T["tid"] = tid
- f.T["gid"] = gid
- f.T["sourceinfo"] = sourceinfo
- f.T["topsubtype"] = util.TopSubStypeArr
- f.T["allfield"] = util.AllFieldArr
- _ = f.Render("project/check_user_data_list.html", &f.T)
- }
- }
- func (f *Front) CheckJyData() {
- qu.Catch()
- pid := f.GetString("pid")
- gid := f.GetString("gid")
- tid := f.GetString("tid")
- stype := f.GetString("stype")
- sourceinfo := f.GetString("s_sourceinfo")
- datatype, _ := f.GetInteger("datatype")
- if f.Method() == "POST" {
- start, _ := f.GetInteger("start")
- limit, _ := f.GetInteger("length")
- draw, _ := f.GetInteger("draw")
- query := make(map[string]interface{})
- if tid != "" {
- // 任务数据质检
- query["b_istag"] = true
- if stype == "group" {
- query["s_grouptaskid"] = tid
- f.SetSession("check", "group")
- } else {
- f.SetSession("check", "user")
- query["s_usertaskid"] = tid
- }
- } else {
- if stype == "notag" {
- query["b_istagging"] = false
- if datatype == 1 {
- // 待分发数据
- query["b_isgivegroup"] = false
- } else {
- // 已分发 标注数据
- query["b_istag"] = true
- query["b_isgivegroup"] = true
- }
- } else if stype == "tag" { //未达标
- query["b_istagging"] = true
- query["i_ckdata"] = 2
- } else {
- query["i_ckdata"] = 2
- }
- }
- status := f.GetString("s_status")
- s_excp := f.GetString("s_excp")
- s_isEff := f.GetString("isEff")
- field := f.GetString("field") //字段
- dataType1 := f.GetString("datatype1") //信息类型
- min := f.GetString("minval") //min max不用int类型接收,以免有默认值0
- max := f.GetString("maxval")
- hasno, _ := f.GetBool("hasno") //是否存在
- notag, _ := f.GetBool("notag") //是否标注
- if status == "1" {
- query["b_check"] = true
- } else if status == "-1" {
- query["b_check"] = false
- }
- if s_isEff == "1" {
- query["b_isEff"] = true
- } else if s_isEff == "-1" {
- query["b_isEff"] = false
- }
- if s_excp == "1" {
- query["s_excp"] = nil
- } else if s_excp == "-1" {
- query["s_excp"] = map[string]interface{}{"$exists": true}
- }
- if dataType1 != "-1" && dataType1 != "" { //类型
- if dataType1 == util.SPECIALTYPE {
- query["v_baseinfo.subtype"] = map[string]interface{}{
- "$exists": false,
- }
- } else {
- subtype := strings.Split(dataType1, "-")[1]
- query["v_baseinfo.subtype"] = subtype
- }
- }
- fieldScreen := false
- if field != "-1" && field != "" { //字段
- fieldScreen = true
- queryfield := map[string]interface{}{
- "$exists": !hasno,
- }
- numMap := map[string]interface{}{}
- if field == "budget" || field == "bidamount" { //金额区间
- if min != "" {
- minint := qu.IntAll(min)
- numMap["$gte"] = minint
- }
- if max != "" {
- maxint := qu.IntAll(max)
- numMap["$lte"] = maxint
- }
- }
- if len(numMap) > 0 {
- if !hasno {
- query["v_baseinfo."+field] = numMap
- } else {
- query["$or"] = []map[string]interface{}{
- {"v_baseinfo." + field: queryfield},
- {"v_baseinfo." + field: numMap},
- }
- }
- } else {
- if hasno {
- query["$or"] = []interface{}{
- map[string]interface{}{
- "v_baseinfo." + field: queryfield,
- },
- map[string]interface{}{
- "v_baseinfo." + field: map[string]interface{}{
- "$eq": "",
- },
- },
- }
- } else {
- query["$and"] = []interface{}{
- map[string]interface{}{
- "v_baseinfo." + field: queryfield,
- },
- map[string]interface{}{
- "v_baseinfo." + field: map[string]interface{}{
- "$ne": "",
- },
- },
- }
- }
- }
- }
- if fieldScreen && notag {
- query["v_taginfo."+field] = map[string]interface{}{
- "$exists": false,
- }
- } else if !fieldScreen && notag {
- query["i_ckdata"] = 0
- }
- qu.Debug(query)
- count := util.Mgo.Count(sourceinfo, query)
- 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}
- info, _ := util.Mgo.Find(sourceinfo, query, `{"_id": 1}`, fields, false, start, limit)
- f.ServeJson(map[string]interface{}{
- "draw": draw,
- "data": *info,
- "recordsFiltered": count,
- "recordsTotal": count,
- })
- } else {
- if tid == "" {
- query1 := make(map[string]interface{})
- if stype == "all" {
- project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"i_importnum": 1})
- f.T["taskNum"] = (*project)["i_importnum"]
- query1["i_ckdata"] = 2
- } else if stype == "notag" {
- f.T["taskNum"] = util.Mgo.Count(sourceinfo, map[string]interface{}{"b_istagging": false})
- query1["b_istagging"] = false
- if datatype == 1 {
- // 待分发数据
- query1["b_isgivegroup"] = false
- //query1["b_istagging"] = false
- } else {
- // 标注数据
- query1["b_istag"] = true
- query1["b_isgivegroup"] = true
- }
- } else if stype == "tag" {
- f.T["taskNum"] = util.Mgo.Count(sourceinfo, map[string]interface{}{"b_istagging": false})
- query1["b_istagging"] = true //未达标
- query1["i_ckdata"] = 2
- } else {
- project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"i_importnum": 1})
- f.T["taskNum"] = (*project)["i_importnum"]
- query1["i_ckdata"] = 2
- }
- qu.Debug(sourceinfo, query1)
- count := util.Mgo.Count(sourceinfo, query1)
- //f.T["taskNum"] = count
- f.T["taskTagNum"] = count
- query1["b_check"] = true // 已质检
- checkCount := util.Mgo.Count(sourceinfo, query1)
- f.T["taskCheckNum"] = checkCount
- } else {
- task, _ := util.Mgo.FindById(util.TASKCOLLNAME, tid, map[string]interface{}{"i_givenum": 1})
- f.T["taskNum"] = (*task)["i_givenum"]
- tagCount, checkCount := 0, 0
- if stype == "group" {
- tagCount = util.Mgo.Count(sourceinfo, map[string]interface{}{"s_grouptaskid": tid, "b_istag": true})
- checkCount = util.Mgo.Count(sourceinfo, map[string]interface{}{"s_grouptaskid": tid, "b_check": true})
- } else {
- tagCount = util.Mgo.Count(sourceinfo, map[string]interface{}{"s_usertaskid": tid, "b_istag": true})
- checkCount = util.Mgo.Count(sourceinfo, map[string]interface{}{"s_usertaskid": tid, "b_check": true})
- }
- f.T["taskTagNum"] = tagCount
- f.T["taskCheckNum"] = checkCount
- }
- project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"purchasinglist_key": 1})
- f.T["pid"] = pid
- f.T["tid"] = tid
- f.T["gid"] = gid
- f.T["sourceinfo"] = sourceinfo
- f.T["stype"] = stype
- f.T["datatype"] = datatype
- f.T["topsubtype"] = util.TopSubStypeArr
- f.T["allfield"] = util.AllFieldArr
- f.T["purchasinglist_key"] = (*project)["purchasinglist_key"]
- _ = f.Render("project/check_data_list.html", &f.T)
- }
- }
- func (f *Front) CheckDetail() {
- qu.Catch()
- tid := f.GetString("tid")
- pid := f.GetString("pid")
- did := f.GetString("did")
- coll := f.GetString("s_sourceinfo")
- project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, `{"v_fields": 1}`)
- if len(*project) > 0 {
- field := make(map[string]bool)
- vf := (*project)["v_fields"].(map[string]interface{})
- for k := range vf {
- field[k] = true
- }
- f.T["fields"] = field
- }
- qu.Debug(pid, did, coll)
- rep := getDetail(did, coll) //获取本条公告的信息
- f.T["otherInfo"] = rep["otherInfo"] //展示关联公告信息
- f.T["moreInfo"] = rep["moreInfo"] //更多关联公告信息
- f.T["s_excp_info"] = rep["s_excp_info"]
- f.T["pid"] = pid
- f.T["tid"] = tid
- f.T["did"] = did
- f.T["coll"] = coll
- f.T["info"] = rep["info"]
- f.T["common"] = rep["common"]
- f.T["worder"] = rep["worder"]
- f.T["packs"] = rep["packs"]
- f.T["packskey"] = rep["packskey"]
- f.T["ck_pclistag"] = rep["purchasingTag"]
- f.T["timeplace"] = rep["timeplace"]
- f.T["purchasinglist"] = rep["purchasinglist"]
- f.T["other"] = rep["other"]
- f.T["PurchasinglistField"] = util.PurchasinglistField
- f.T["PurchasinglistField1"] = util.PurchasinglistField1
- f.T["WinnerorderField"] = util.WinnerorderField
- f.T["PackageField"] = util.PackageField
- f.T["topsubtype"] = util.TopSubStypeArr2
- f.T["ck_purchasinglist"] = rep["ck_purchasinglist"]
- f.T["ck_package"] = rep["ck_package"]
- f.T["ck_winnerorder"] = rep["ck_winnerorder"]
- f.T["worder_new"] = rep["worder_new"]
- f.T["pcl_new"] = rep["pcl_new"]
- f.T["pkg_new"] = rep["pkg_new"]
- f.T["nextid"] = GetNextDataId1(did, coll, tid, qu.ObjToString(f.GetSession("check"))) //下一条id
- _ = f.Render("project/check_detail.html", &f.T)
- }
- func (f *Front) CheckSave() {
- defer qu.Catch()
- success := false
- msg := ""
- user := f.GetSession("user").(map[string]interface{})
- username := qu.ObjToString(user["s_login"]) //当前登录用户
- userId := qu.ObjToString(user["id"]) //当前登录用户标识
- userRole := qu.ObjToString(user["i_role"]) //当前登录用户权限
- var obj []map[string]interface{}
- infoId := f.GetString("s_infoid")
- sourceInfo := f.GetString("s_sourceinfo")
- pid := f.GetString("pid")
- qu.Debug("Data ID:", infoId)
- project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"s_name": 1, "v_fields": 1})
- data := f.GetString("data")
- err := json.Unmarshal([]byte(data), &obj)
- if err != nil {
- qu.Debug("Json Unmarshal Error")
- f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
- return
- }
- tagSet := map[string]interface{}{} //被标注字段状态
- baseSet := map[string]interface{}{} //要修改的字段信息
- baseUnset := map[string]interface{}{} //要删除的字段信息
- if len(obj) == 1 { //单独保存某个一级
- content, ok := obj[0]["content"].([]interface{})
- if !ok || len(content) == 0 {
- f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
- return
- }
- title := qu.ObjToString(obj[0]["title"])
- istag, _ := obj[0]["checkAllTag"].(bool)
- status := qu.IntAll(obj[0]["status"])
- switch title {
- case "基本字段":
- MarkBase(content, tagSet, baseSet, baseUnset)
- case "时间地点":
- MarkTimePlace(content, tagSet, baseSet, baseUnset)
- case "标的信息":
- MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
- case "采购意向信息":
- MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
- case "多包信息":
- MarkPackage(content, tagSet, baseSet, baseUnset, status)
- case "中标候选人信息":
- MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
- case "其余信息":
- MarkOther(content, tagSet, baseSet, baseUnset)
- }
- } else {
- for j, val := range obj {
- content, ok := val["content"].([]interface{})
- status := qu.IntAll(val["status"])
- if !ok {
- qu.Debug("Content Error")
- continue
- }
- istag, _ := val["checkAllTag"].(bool)
- if j == 0 { //基本信息
- MarkBase(content, tagSet, baseSet, baseUnset)
- } else if j == 1 { //时间地点
- MarkTimePlace(content, tagSet, baseSet, baseUnset)
- } else if j == 2 { //标的物
- MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
- } else if j == 3 { //采购意向
- MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
- } else if j == 4 { //多包
- MarkPackage(content, tagSet, baseSet, baseUnset, status)
- } else if j == 5 { //候选人
- MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
- } else { //其余信息
- MarkOther(content, tagSet, baseSet, baseUnset)
- }
- }
- }
- dataInfo, _ := util.Mgo.FindById(sourceInfo, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1}) //查询标注保存前的原始信息
- tagInfo, _ := (*dataInfo)["v_taginfo"].(map[string]interface{})
- baseInfo, _ := (*dataInfo)["v_baseinfo"].(map[string]interface{})
- if tagInfo != nil && len(tagInfo) > 0 {
- for field, tmpStatus := range tagSet { //比对本次标注信息和历史标注信息
- status := qu.IntAll(tmpStatus) //此次被标注字段的状态
- markedStatus := qu.IntAll(tagInfo[field]) //历史标注状态
- if status == 1 && markedStatus != 0 { //此次标注结果为正确,且有历史标注记录,不做修改
- qu.Debug("已标注字段field---", field)
- //delete(tagSet, field)
- delete(baseSet, field)
- //continue
- }
- }
- }
- allTagFields := map[string]interface{}{} //记录此此标注所有标注信息,用于日志记录
- for k, _ := range tagSet {
- allTagFields[k] = true
- }
- for k, v := range baseSet {
- allTagFields[k] = v
- }
- for k, _ := range baseUnset {
- allTagFields[k] = nil
- }
- //qu.Debug("allTagFields===", allTagFields)
- //qu.Debug("tagSet===", tagSet)
- // 质检时,标注标记变成质检标记
- checkFields, _ := (*project)["v_fields"].(map[string]interface{})
- //datatype := qu.ObjToString((*project)["s_datatype"])
- qu.Debug(checkFields)
- checkSet := make(map[string]interface{})
- for k := range checkFields {
- checkSet[k] = tagSet[k]
- }
- if len(tagSet) > 0 || baseInfo["purchasinglist_alltag"] != nil { //purchasinglist_alltag特殊处理
- //1、更新数据源信息
- setResult := map[string]interface{}{ //更新字段集
- "i_updatetime": time.Now().Unix(),
- "b_check": true,
- "s_checkid": userId,
- "b_istag": true,
- //"b_isgivegroup": true,
- //"b_isgiveuser": true,
- "s_userid": userId,
- }
- for field, val := range checkSet { //更新质检字段
- setResult["v_taginfo."+field] = val
- }
- setResult["v_checkinfo"] = checkSet
- for field, val := range baseSet { //更新基本字段
- setResult["v_baseinfo."+field] = val
- baseInfo[field] = val
- }
- baseUnsetResult := map[string]interface{}{} //删除字段集
- for field, _ := range baseUnset { //删除基本字段
- baseUnsetResult["v_baseinfo."+field] = ""
- delete(baseInfo, field)
- }
- ex, exp := DataException(baseInfo)
- if ex != "" {
- setResult["s_excp"] = ex
- setResult["s_excp_info"] = exp
- } else {
- baseUnsetResult["s_excp"] = ""
- baseUnsetResult["s_excp_info"] = ""
- }
- set := map[string]interface{}{
- "$set": setResult,
- }
- if len(baseUnsetResult) > 0 {
- set["$unset"] = baseUnsetResult
- }
- success = util.Mgo.UpdateById(sourceInfo, infoId, set)
- //2、更新marked表
- tmp, _ := util.Mgo.FindById(sourceInfo, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1, "i_ckdata": 1})
- qu.Debug("infoId:", infoId)
- delete(*tmp, "_id")
- (*tmp)["updatetime"] = time.Now().Unix()
- b := util.Mgo.Update(util.AllToColl, map[string]interface{}{"_id": mgo.StringTOBsonId(infoId)}, map[string]interface{}{"$set": tmp}, true, false)
- qu.Debug("Update Marked:", b)
- }
- //3、保存标注日志
- b := SaveLog(infoId, "", username, userId, userRole, qu.ObjToString((*project)["s_name"]), "质检", baseInfo, allTagFields)
- qu.Debug("Save Log:", b)
- f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
- }
- func (f *Front) CheckResult() {
- qu.Catch()
- pid := f.GetString("pid")
- tid := f.GetString("tid")
- sourceinfo := f.GetString("s_sourceinfo")
- stype := f.GetString("stype")
- datatype, _ := f.GetInteger("datatype")
- var allNum int
- projcet, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"v_fields": 1})
- //tagCount := util.Mgo.Count(sourceinfo, map[string]interface{}{"s_grouptaskid": tid, "b_istag": true})
- //checkCount := util.Mgo.Count(sourceinfo, map[string]interface{}{"s_grouptaskid": tid, "b_check": true})
- markNum, checkNum, checkNumR := 0, 0, 0 // 标注数量, 审核数据量, 审核数据完全正确的数据量
- cmaps := make(map[string]int) // 标注字段整体准确率
- umaps := make(map[string]interface{}) // 按人员 字段准确率
- for k := range (*projcet)["v_fields"].(map[string]interface{}) {
- cmaps[k] = 0
- }
- sess := util.Mgo.GetMgoConn()
- defer util.Mgo.DestoryMongoConn(sess)
- query := make(map[string]interface{})
- if tid == "" {
- query1 := make(map[string]interface{})
- if stype == "all" {
- query1["i_ckdata"] = 2
- } else if stype == "notag" {
- if datatype == 1 {
- // 待分发数据
- query1["b_isgivegroup"] = false
- query1["b_istagging"] = false
- } else {
- // 标注数据
- query1["i_ckdata"] = 2
- query1["b_isgivegroup"] = false
- }
- } else if stype == "tag" {
- query1["b_istagging"] = true //未达标
- query1["i_ckdata"] = 2
- }
- allNum = util.Mgo.Count(sourceinfo, query1)
- } else {
- task, _ := util.Mgo.FindById(util.TASKCOLLNAME, tid, map[string]interface{}{"i_givenum": 1})
- allNum = qu.IntAll((*task)["i_givenum"]) //任务数据量
- if stype == "group" {
- query["s_grouptaskid"] = tid
- } else {
- query["s_usertaskid"] = tid
- }
- }
- query["b_check"] = true
- qu.Debug(query)
- checkNum = util.Mgo.Count(sourceinfo, query)
- result := sess.DB(util.Mgo.DbName).C(sourceinfo).Find(query).Iter()
- if checkNum == 0 {
- f.ServeJson(map[string]interface{}{"rep": false, "msg": "无质检审核数据!"})
- return
- }
- // 排序
- fields := (*projcet)["v_fields"].(map[string]interface{})
- purchasingTag := false // 标的物统计标识
- var strs []string
- if fields["purchasinglist"] != nil {
- purchasingTag = true
- delete(fields, "purchasinglist")
- }
- for k := range fields {
- strs = append(strs, k)
- }
- pNum, pEffNum := 0, 0 // 标的物数量, 标的物有效数量
- fieldNumMap := make(map[string]int) //字段总标注量,
- tagNumMap := make(map[string]int) //字段标注数据量(标的物有效)
- rightNumMap := make(map[string]int) //正确数据(标的物有效)
- for tmp := make(map[string]interface{}); result.Next(&tmp); markNum++ {
- user := qu.ObjToString(tmp["s_login"])
- var up map[string]int
- if umaps[user] == nil {
- up = make(map[string]int)
- } else {
- up = umaps[user].(map[string]int)
- }
- up["ck_count"] += 1
- umaps[user] = up
- if tmp["b_check"].(bool) {
- if f, ok := tmp["v_checkinfo"].(map[string]interface{}); ok {
- flag := true // 数据整体准确率
- // 按人员统计字段准备率
- var up map[string]int
- if umaps[user] == nil {
- up = make(map[string]int)
- } else {
- up = umaps[user].(map[string]int)
- }
- for k1 := range cmaps {
- if qu.IntAll(f[k1]) == 1 {
- cmaps[k1] += 1 // 字段整体正确率
- up[k1] += 1
- } else {
- flag = false
- }
- }
- up["re_count"] += 1
- umaps[user] = up
- if flag {
- checkNumR++
- up["re_rg_count"] += 1
- }
- }
- }
- if tmp["b_check"].(bool) && purchasingTag {
- info := tmp["v_baseinfo"].(map[string]interface{})
- checkInfo := tmp["v_checkinfo"].(map[string]interface{})
- if pList, o := info["purchasinglist"].([]interface{}); o {
- pNum += len(pList)
- if tmp["b_isEff"].(bool) {
- pEffNum += 1
- }
- for _, p := range pList {
- p1 := p.(map[string]interface{})
- for f := range purchasingField {
- if qu.ObjToString(p1[f]) != "" {
- fieldNumMap[f] += 1
- if b, o := p1["b_isEff"].(bool); b && o {
- tagNumMap[f] += 1
- }
- }
- }
- }
- }
- if cList, o := checkInfo["purchasinglist"].([]interface{}); o {
- for _, c := range cList {
- c1 := c.(map[string]interface{})
- for f := range purchasingField {
- if qu.IntAll(c1[f]) == 1 {
- rightNumMap[f] += 1
- }
- }
- }
- }
- }
- }
- qu.Debug(cmaps)
- qu.Debug(umaps)
- pResult := method(fieldNumMap, tagNumMap, rightNumMap)
- // 前台页面数据
- dataSource := make(map[string]interface{})
- var userSelect []string
- var dataSelect []map[string]interface{}
- userSelect = append(userSelect, "全部")
- tmp := make(map[string]interface{})
- tmp["name"] = "全部"
- tmp["num1"] = allNum
- tmp["num2"] = checkNum
- tmp["num3"] = checkNumR
- tmp["num4"] = CountPr(checkNumR, checkNum)
- dataSelect = append(dataSelect, tmp)
- sort.Strings(strs)
- for _, v := range strs {
- tmp1 := make(map[string]interface{})
- tmp1["name"] = fields[v]
- tmp1["num1"] = markNum
- tmp1["num2"] = checkNum
- tmp1["num3"] = cmaps[v]
- tmp1["num4"] = CountPr(cmaps[v], checkNum)
- dataSelect = append(dataSelect, tmp1)
- }
- dataSource["全部"] = dataSelect
- for k1, v1 := range umaps {
- if v2, o := v1.(map[string]int); o {
- userSelect = append(userSelect, k1)
- var dataSelect1 []map[string]interface{}
- tmp2 := make(map[string]interface{})
- tmp2["name"] = "全部"
- tmp2["num1"] = v2["ck_count"]
- tmp2["num2"] = v2["re_count"]
- tmp2["num3"] = v2["re_rg_count"]
- tmp2["num4"] = CountPr(v2["re_rg_count"], v2["re_count"])
- dataSelect1 = append(dataSelect1, tmp2)
- for k, v := range fields {
- tmp1 := make(map[string]interface{})
- tmp1["name"] = v
- tmp1["num1"] = v2["ck_count"]
- tmp1["num2"] = v2["re_count"]
- tmp1["num3"] = v2[k]
- tmp1["num4"] = CountPr(v2[k], v2["re_count"])
- dataSelect1 = append(dataSelect1, tmp1)
- }
- dataSource[k1] = dataSelect1
- }
- }
- qu.Debug("字段统计---", dataSource)
- qu.Debug("字段统计---", pResult)
- f.T["pid"] = pid
- f.T["tid"] = tid
- f.T["sourceinfo"] = sourceinfo
- f.T["taskNum"] = allNum
- f.T["taskTagNum"] = markNum
- f.T["taskCheckNum"] = checkNum
- f.T["taskCheckRight"] = checkNumR
- f.T["pNum"] = pNum // 标的物数量
- f.T["pEffNum"] = pEffNum //标的物有效数据量
- f.T["tableData"] = dataSource
- f.T["pResult"] = pResult
- f.T["userSelect"] = userSelect
- _ = f.Render("project/check_result.html", &f.T)
- }
- // @Description 标的物统计结果
- // @Author J 2022/4/25 2:20 PM
- func method(m1, m2, m3 map[string]int) []map[string]interface{} {
- var result []map[string]interface{}
- for f, v := range purchasingField {
- m := make(map[string]interface{})
- m["name"] = v
- m["num"] = m1[f]
- m["num1"] = m2[f]
- m["num2"] = m3[f]
- m["num3"] = CountPr(m2[f], m3[f])
- result = append(result, m)
- }
- return result
- }
- // CountPr 计算百分比
- func CountPr(c1, c2 int) string {
- decimal.DivisionPrecision = 2
- if c1 == 0 || c2 == 0 {
- return "0"
- }
- d := decimal.NewFromInt32(int32(c1)).Div(decimal.NewFromInt32(int32(c2))).Mul(decimal.NewFromInt32(100))
- return d.String() + "%"
- }
- func (f *Front) CheckExcpResult() {
- pid := f.GetString("pid")
- tid := f.GetString("tid")
- sourceinfo := f.GetString("s_sourceinfo")
- stype := f.GetString("stype")
- query := make(map[string]interface{})
- var dataSource []map[string]interface{}
- if tid != "" {
- if stype == "group" {
- query["s_grouptaskid"] = tid
- } else {
- query["s_usertaskid"] = tid
- }
- query["s_excp"] = map[string]interface{}{"$exists": true}
- } else {
- query["s_excp"] = map[string]interface{}{"$exists": true}
- excpNum := util.Mgo.Count(sourceinfo, query)
- tagNum := util.Mgo.Count(sourceinfo, map[string]interface{}{"i_ckdata": 2})
- dataSource = append(dataSource, map[string]interface{}{"name": "达标数据", "num1": excpNum, "num2": tagNum, "num3": CountPr(excpNum, tagNum)})
- }
- f.T["tableData"] = dataSource
- f.T["pid"] = pid
- f.T["tid"] = tid
- f.T["sourceinfo"] = sourceinfo
- _ = f.Render("project/check_excp_result.html", &f.T)
- }
- func (f *Front) CheckExcpData() {
- sourceinfo := f.GetString("s_sourceinfo")
- // 达标,待分发数据
- query := map[string]interface{}{
- "b_istagging": false,
- //"b_isgivegroup": false,
- }
- pool := make(chan bool, 3)
- wg := &sync.WaitGroup{}
- sess := util.Mgo.GetMgoConn()
- defer util.Mgo.DestoryMongoConn(sess)
- count := 0
- it := sess.DB(util.Mgo.DbName).C(sourceinfo).Find(query).Select(nil).Iter()
- for tmp := make(map[string]interface{}); it.Next(&tmp); count++ {
- if tmp["s_excp"] != nil {
- f.ServeJson(map[string]interface{}{"success": true})
- break
- }
- pool <- true
- wg.Add(1)
- go func(tmp map[string]interface{}) {
- defer func() {
- <-pool
- wg.Done()
- info := tmp["v_baseinfo"].(map[string]interface{})
- ex, exp := DataException(info)
- if ex != "" {
- util.Mgo.UpdateById(sourceinfo, tmp["_id"], map[string]interface{}{"$set": map[string]interface{}{"s_excp": ex, "s_excp_info": exp}})
- }
- }()
- }(tmp)
- }
- f.ServeJson(map[string]interface{}{"success": true})
- }
- var regReplAllSymbol = regexp.MustCompile("[<《【\\[{{〔>》】\\]}}〕,,;;::'\"“”。.??/+=\\-_—*&…^%$¥@#!!`~·]")
- func DataException(tmp map[string]interface{}) (string, string) {
- var tag []string
- var exp string
- if tmp["buyer"] != nil && tmp["buyer"] == tmp["s_winner"] {
- tag = append(tag, "1")
- exp += "采购单位与中标单位相等,"
- }
- if tmp["agency"] != nil && tmp["buyer"] == tmp["agency"] {
- tag = append(tag, "2")
- exp += "采购单位与代理机构相等,"
- }
- if tmp["s_winner"] != nil && tmp["s_winner"] == tmp["agency"] {
- tag = append(tag, "3")
- exp += "中标单位与代理机构相等,"
- }
- if tmp["bidamount"] != nil && tmp["budget"] != nil {
- if qu.Float64All(tmp["bidamount"]) > qu.Float64All(tmp["budget"]) {
- tag = append(tag, "4")
- exp += "中标金额大于预算,"
- }
- if qu.Float64All(tmp["bidamount"]) < (qu.Float64All(tmp["budget"]) / 2) {
- tag = append(tag, "5")
- exp += "中标金额小于预算的一半,"
- }
- if tmp["budget"] == 0 && qu.Float64All(tmp["bidamount"]) != 0 {
- tag = append(tag, "6")
- exp += "预算为0,中标金额不为0,"
- }
- if qu.Float64All(tmp["budget"]) != 0 && tmp["bidamount"] == 0 {
- tag = append(tag, "7")
- exp += "预算不为0,中标金额为0,"
- }
- }
- if b := qu.ObjToString(tmp["buyer"]); b != "" {
- if regReplAllSymbol.MatchString(b) {
- tag = append(tag, "8")
- exp += "采购单位含有特殊符号,"
- }
- }
- if a := qu.ObjToString(tmp["agency"]); a != "" {
- if regReplAllSymbol.MatchString(a) {
- tag = append(tag, "9")
- exp += "中标单位含有特殊符号,"
- }
- }
- if a := qu.ObjToString(tmp["s_winner"]); a != "" {
- if regReplAllSymbol.MatchString(a) {
- tag = append(tag, "10")
- exp += "代理机构含有特殊符号,"
- }
- }
- return strings.Join(tag, ","), exp
- }
- // JyMarkList 剑鱼管理员标注信息列表
- func (f *Front) JyMarkList() {
- defer qu.Catch()
- stype := f.GetString("stype") //all:全量标注;notag:达标数据标注;tag:未达标数据标注
- if f.Method() == "POST" {
- start, _ := f.GetInteger("start")
- limit, _ := f.GetInteger("length")
- draw, _ := f.GetInteger("draw")
- sourceInfo := f.GetString("s_sourceinfo") //数据源表
- istag := f.GetString("b_istag") //
- field := f.GetString("field") //字段
- dataType := f.GetString("datatype") //信息类型
- min := f.GetString("minval") //min max不用int类型接收,以免有默认值0
- max := f.GetString("maxval")
- hasno, _ := f.GetBool("hasno") //是否存在
- notag, _ := f.GetBool("notag") //是否标注
- query := map[string]interface{}{ //剑鱼自用的标注页面, 查询待分发的数据量
- "b_isgivegroup": false,
- //"b_isgiveuser": false,
- }
- if istag == "true" {
- query["b_istag"] = true
- } else if istag == "false" {
- query["b_istag"] = false
- }
- if stype == "notag" { //查询达标
- query["b_istagging"] = false
- } else if stype == "tag" { //查询未达标
- query["b_istagging"] = true
- }
- if dataType != "-1" && dataType != "" { //类型
- if dataType == util.SPECIALTYPE {
- query["v_baseinfo.subtype"] = map[string]interface{}{
- "$exists": false,
- }
- } else {
- subtype := strings.Split(dataType, "-")[1]
- query["v_baseinfo.subtype"] = subtype
- }
- }
- fieldScreen := false
- if field != "-1" && field != "" { //字段
- fieldScreen = true
- queryfield := map[string]interface{}{
- "$exists": !hasno,
- }
- numMap := map[string]interface{}{}
- if field == "budget" || field == "bidamount" { //金额区间
- if min != "" {
- minint := qu.IntAll(min)
- numMap["$gte"] = minint
- }
- if max != "" {
- maxint := qu.IntAll(max)
- numMap["$lte"] = maxint
- }
- }
- if len(numMap) > 0 {
- if !hasno {
- query["v_baseinfo."+field] = numMap
- } else {
- query["$or"] = []map[string]interface{}{
- {"v_baseinfo." + field: queryfield},
- {"v_baseinfo." + field: numMap},
- }
- }
- } else {
- if hasno {
- query["$or"] = []interface{}{
- map[string]interface{}{
- "v_baseinfo." + field: queryfield,
- },
- map[string]interface{}{
- "v_baseinfo." + field: map[string]interface{}{
- "$eq": "",
- },
- },
- }
- } else {
- query["$and"] = []interface{}{
- map[string]interface{}{
- "v_baseinfo." + field: queryfield,
- },
- map[string]interface{}{
- "v_baseinfo." + field: map[string]interface{}{
- "$ne": "",
- },
- },
- }
- }
- //query["v_baseinfo."+field] = queryfield
- }
- }
- if fieldScreen && notag {
- query["v_taginfo."+field] = map[string]interface{}{
- "$exists": false,
- }
- } else if !fieldScreen && notag {
- query["i_ckdata"] = 0
- }
- count := util.Mgo.Count(sourceInfo, query)
- qu.Debug("query:", query, sourceInfo, count)
- fields := map[string]interface{}{"v_baseinfo.title": 1, "b_istag": 1, "i_ckdata": 1}
- list, _ := util.Mgo.Find(sourceInfo, query, map[string]interface{}{"_id": 1}, fields, false, start, limit)
- //checkedNum, allNum := GetCheckedAndAllDataInfo(query, coll) //已标和总数信息
- f.ServeJson(map[string]interface{}{"draw": draw, "data": *list, "recordsFiltered": count, "recordsTotal": count})
- } else {
- pid := f.GetString("pid")
- info, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"s_sourceinfo": 1})
- f.T["s_sourceinfo"] = (*info)["s_sourceinfo"]
- f.T["stype"] = stype
- f.T["pid"] = pid
- f.T["topsubtype"] = util.TopSubStypeArr
- f.T["allfield"] = util.AllFieldArr
- _ = f.Render("project/remark_jy_list.html", &f.T)
- }
- }
- // JyUserDataMark 剑鱼管理人员数据标注
- func (f *Front) JyUserDataMark() {
- defer qu.Catch()
- qu.Debug("jy save...")
- success := false
- msg := ""
- user := f.GetSession("user").(map[string]interface{})
- username := qu.ObjToString(user["s_login"]) //当前登录用户
- groupId := qu.ObjToString(user["s_groupid"])
- userId := qu.ObjToString(user["id"]) //当前登录用户标识
- userRole := qu.ObjToString(user["i_role"]) //当前登录用户权限
- obj := []map[string]interface{}{}
- infoId := f.GetString("s_infoid")
- sourceInfo := f.GetString("s_sourceinfo")
- remark := f.GetString("remark")
- isEff, _ := f.GetBool("isEff")
- pid := f.GetString("pid")
- qu.Debug("Data ID:", infoId)
- data := f.GetString("data")
- err := json.Unmarshal([]byte(data), &obj)
- if err != nil {
- qu.Debug("Json Unmarshal Error")
- f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
- return
- }
- tagSet := map[string]interface{}{} //被标注字段状态
- baseSet := map[string]interface{}{} //要修改的字段信息
- baseUnset := map[string]interface{}{} //要删除的字段信息
- if len(obj) == 1 { //单独保存某个一级
- content, ok := obj[0]["content"].([]interface{})
- if !ok || len(content) == 0 {
- f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
- return
- }
- title := qu.ObjToString(obj[0]["title"])
- istag, _ := obj[0]["checkAllTag"].(bool)
- status := qu.IntAll(obj[0]["status"])
- switch title {
- case "基本字段":
- MarkBase(content, tagSet, baseSet, baseUnset)
- case "时间地点":
- MarkTimePlace(content, tagSet, baseSet, baseUnset)
- case "标的信息":
- MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
- case "采购意向信息":
- MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
- case "多包信息":
- MarkPackage(content, tagSet, baseSet, baseUnset, status)
- case "中标候选人信息":
- MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
- case "其余信息":
- MarkOther(content, tagSet, baseSet, baseUnset)
- }
- } else {
- for j, val := range obj {
- content, ok := val["content"].([]interface{})
- status := qu.IntAll(val["status"])
- if !ok {
- qu.Debug("Content Error")
- continue
- }
- istag, _ := val["checkAllTag"].(bool)
- if j == 0 { //基本信息
- MarkBase(content, tagSet, baseSet, baseUnset)
- } else if j == 1 { //时间地点
- MarkTimePlace(content, tagSet, baseSet, baseUnset)
- } else if j == 2 { //标的物
- MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
- } else if j == 3 { //采购意向
- MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
- } else if j == 4 { //多包
- MarkPackage(content, tagSet, baseSet, baseUnset, status)
- } else if j == 5 { //候选人
- MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
- } else { //其余信息
- MarkOther(content, tagSet, baseSet, baseUnset)
- }
- }
- }
- dataInfo, _ := util.Mgo.FindById(sourceInfo, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1}) //查询标注保存前的原始信息
- tagInfo, _ := (*dataInfo)["v_taginfo"].(map[string]interface{})
- baseInfo, _ := (*dataInfo)["v_baseinfo"].(map[string]interface{})
- if tagInfo != nil && len(tagInfo) > 0 {
- for field, tmpStatus := range tagSet { //比对本次标注信息和历史标注信息
- status := qu.IntAll(tmpStatus) //此次被标注字段的状态
- markedStatus := qu.IntAll(tagInfo[field]) //历史标注状态
- if status == 1 && markedStatus != 0 { //此次标注结果为正确,且有历史标注记录,不做修改
- qu.Debug("已标注字段field---", field)
- delete(tagSet, field)
- delete(baseSet, field)
- //continue
- }
- //else {
- // qu.Debug("未标注字段field---", field, status)
- //}
- }
- }
- //
- allTagFields := map[string]interface{}{} //记录此此标注所有标注信息,用于日志记录
- for k, _ := range tagSet {
- allTagFields[k] = true
- }
- for k, v := range baseSet {
- allTagFields[k] = v
- }
- for k, _ := range baseUnset {
- allTagFields[k] = nil
- }
- qu.Debug("allTagFields===", allTagFields)
- qu.Debug("tagSet===", tagSet)
- if len(tagSet) >= 0 || baseInfo["purchasinglist_alltag"] != nil { //purchasinglist_alltag特殊处理
- //1、更新数据源信息
- setResult := map[string]interface{}{ //更新字段集
- "i_updatetime": time.Now().Unix(),
- "i_ckdata": 2,
- "b_istag": true,
- "s_userid": userId,
- "s_groupid": groupId,
- //"b_isgiveuser": true,
- //"b_isgivegroup": true,
- "s_login": username,
- }
- for field, val := range tagSet { //更新标注字段
- setResult["v_taginfo."+field] = val
- }
- for field, val := range baseSet { //更新基本字段
- setResult["v_baseinfo."+field] = val
- }
- baseUnsetResult := map[string]interface{}{} //删除字段集
- for field, _ := range baseUnset { //删除基本字段
- baseUnsetResult["v_baseinfo."+field] = ""
- }
- if remark != "" {
- setResult["v_taginfo.reamrk"] = remark
- }
- setResult["isEff"] = isEff
- set := map[string]interface{}{
- "$set": setResult,
- }
- if len(baseUnsetResult) > 0 {
- set["$unset"] = baseUnsetResult
- }
- qu.Debug("set---", set)
- success = util.Mgo.UpdateById(sourceInfo, infoId, set)
- //2、更新marked表
- tmp, _ := util.Mgo.FindById(sourceInfo, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1, "i_ckdata": 1})
- qu.Debug("infoId:", infoId)
- delete((*tmp), "_id")
- (*tmp)["updatetime"] = time.Now().Unix()
- b := util.Mgo.Update(util.AllToColl, map[string]interface{}{"_id": mgo.StringTOBsonId(infoId)}, map[string]interface{}{"$set": tmp}, true, false)
- qu.Debug("Update Marked:", b)
- }
- /*
- } else {
- 表示页面标注时未做修改标注
- }
- */
- //3、保存标注日志
- project, _ := util.Mgo.FindById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"s_name": 1})
- b := SaveLog(infoId, "", username, userId, userRole, qu.ObjToString((*project)["s_name"]), "标注", baseInfo, allTagFields)
- qu.Debug("Save Log:", b)
- f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
- }
- // UserDataMark 标注人员数据标注(基于任务的标注)
- func (f *Front) UserDataMark() {
- defer qu.Catch()
- success := false
- msg := ""
- user := f.GetSession("user").(map[string]interface{})
- username := qu.ObjToString(user["s_login"]) //当前登录用户
- userId := qu.ObjToString(user["id"]) //当前登录用户标识
- userRole := qu.ObjToString(user["i_role"]) //当前登录用户权限
- remark := f.GetString("remark")
- isEff, _ := f.GetBool("isEff")
- obj := []map[string]interface{}{}
- infoId := f.GetString("s_infoid")
- userTaskId := f.GetString("s_usertaskid")
- qu.Debug("Task ID:", userTaskId, " Data ID:", infoId)
- data := f.GetString("data")
- err := json.Unmarshal([]byte(data), &obj)
- if err != nil {
- qu.Debug("Json Unmarshal Error")
- f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
- return
- }
- tagSet := map[string]interface{}{} //被标注字段状态
- baseSet := map[string]interface{}{} //要修改的字段信息
- baseUnset := map[string]interface{}{} //要删除的字段信息
- //isSaveMarked := false
- if len(obj) == 1 { //单独保存某个一级
- content, ok := obj[0]["content"].([]interface{})
- if !ok || len(content) == 0 {
- f.ServeJson(map[string]interface{}{"success": success, "msg": "解析数据失败"})
- return
- }
- title := qu.ObjToString(obj[0]["title"])
- istag, _ := obj[0]["checkAllTag"].(bool)
- status := qu.IntAll(obj[0]["status"])
- switch title {
- case "基本字段":
- MarkBase(content, tagSet, baseSet, baseUnset)
- case "时间地点":
- MarkTimePlace(content, tagSet, baseSet, baseUnset)
- case "标的信息":
- MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
- case "采购意向信息":
- MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
- case "多包信息":
- MarkPackage(content, tagSet, baseSet, baseUnset, status)
- case "中标候选人信息":
- MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
- case "其余信息":
- MarkOther(content, tagSet, baseSet, baseUnset)
- }
- } else {
- for j, val := range obj {
- content, ok := val["content"].([]interface{})
- status := qu.IntAll(val["status"])
- if !ok {
- qu.Debug("Content Error")
- continue
- }
- istag, _ := val["checkAllTag"].(bool)
- if j == 0 { //基本信息
- MarkBase(content, tagSet, baseSet, baseUnset)
- } else if j == 1 { //时间地点
- MarkTimePlace(content, tagSet, baseSet, baseUnset)
- } else if j == 2 { //标的物
- MarkPurchasinglist(content, tagSet, baseSet, baseUnset, istag, status)
- } else if j == 3 { //采购意向
- MarkProcurementList(content, tagSet, baseSet, baseUnset, istag, status)
- } else if j == 4 { //多包
- MarkPackage(content, tagSet, baseSet, baseUnset, status)
- } else if j == 5 { //候选人
- MarkWonderorder(content, tagSet, baseSet, baseUnset, status)
- } else { //其余信息
- MarkOther(content, tagSet, baseSet, baseUnset)
- }
- }
- }
- //
- userTask, _ := util.Mgo.FindById(util.TASKCOLLNAME, userTaskId, map[string]interface{}{"s_personid": 1, "s_personname": 1, "s_projectname": 1, "s_sourceinfo": 1})
- if userTask == nil || len(*userTask) == 0 {
- f.ServeJson(map[string]interface{}{"success": success, "msg": "查询用户任务失败"})
- return
- }
- sourceInfo := qu.ObjToString((*userTask)["s_sourceinfo"]) //数据源表
- dataInfo, _ := util.Mgo.FindById(sourceInfo, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1}) //查询标注保存前的原始信息
- tagInfo, _ := (*dataInfo)["v_taginfo"].(map[string]interface{})
- baseInfo, _ := (*dataInfo)["v_baseinfo"].(map[string]interface{})
- if tagInfo != nil && len(tagInfo) > 0 {
- for field, tmpStatus := range tagSet { //比对本次标注信息和历史标注信息
- status := qu.IntAll(tmpStatus) //此次被标注字段的状态
- markedStatus := qu.IntAll(tagInfo[field]) //历史标注状态
- if status == 1 && markedStatus != 0 { //此次标注结果为正确,且有历史标注记录,不做修改
- qu.Debug("已标注字段field---", field)
- delete(tagSet, field)
- delete(baseSet, field)
- //continue
- }
- //else {
- // qu.Debug("未标注字段field---", field, status)
- //}
- }
- }
- //
- allTagFields := map[string]interface{}{} //记录此此标注所有标注信息,用于日志记录
- for k, _ := range tagSet {
- allTagFields[k] = true
- }
- for k, v := range baseSet {
- allTagFields[k] = v
- }
- for k, _ := range baseUnset {
- allTagFields[k] = nil
- }
- qu.Debug("allTagFields===", allTagFields)
- qu.Debug("tagSet===", tagSet)
- if len(tagSet) >= 0 || baseInfo["purchasinglist_alltag"] != nil { //purchasinglist_alltag特殊处理
- //1、更新数据源信息
- setResult := map[string]interface{}{ //更新字段集
- "i_updatetime": time.Now().Unix(),
- "i_ckdata": 2,
- "b_istag": true,
- }
- for field, val := range tagSet { //更新标注字段
- setResult["v_taginfo."+field] = val
- }
- for field, val := range baseSet { //更新基本字段
- setResult["v_baseinfo."+field] = val
- baseInfo[field] = val
- }
- baseUnsetResult := map[string]interface{}{} //删除字段集
- for field, _ := range baseUnset { //删除基本字段
- baseUnsetResult["v_baseinfo."+field] = ""
- delete(baseInfo, field)
- }
- ex, exp := DataException(baseInfo)
- if ex != "" {
- setResult["s_excp"] = ex
- setResult["s_excp_info"] = exp
- }
- // todo
- if remark != "" {
- setResult["v_taginfo.reamrk"] = remark
- }
- setResult["isEff"] = isEff
- set := map[string]interface{}{
- "$set": setResult,
- }
- if len(baseUnsetResult) > 0 {
- set["$unset"] = baseUnsetResult
- }
- qu.Debug("set---", set)
- success = util.Mgo.UpdateById(sourceInfo, infoId, set)
- //2、更新marked表
- tmp, _ := util.Mgo.FindById(sourceInfo, infoId, map[string]interface{}{"v_baseinfo": 1, "v_taginfo": 1, "i_ckdata": 1})
- qu.Debug("infoId:", infoId)
- delete((*tmp), "_id")
- (*tmp)["updatetime"] = time.Now().Unix()
- b := util.Mgo.Update(util.AllToColl, map[string]interface{}{"_id": mgo.StringTOBsonId(infoId)}, map[string]interface{}{"$set": tmp}, true, false)
- qu.Debug("Update Marked:", b)
- }
- /*
- } else {
- 表示页面标注时未做修改标注
- }
- */
- //3、修改任务状态
- b := util.Mgo.Update(util.TASKCOLLNAME, map[string]interface{}{"_id": (*userTask)["_id"], "s_status": "未开始"}, map[string]interface{}{
- "$set": map[string]interface{}{
- "i_starttime": time.Now().Unix(),
- "i_updatetime": time.Now().Unix(),
- "s_updateperson": username,
- "s_status": "进行中",
- },
- }, false, false)
- qu.Debug("Update UserTask:", b)
- //4、保存标注日志
- b = SaveLog(infoId, userTaskId, username, userId, userRole, qu.ObjToString((*userTask)["s_projectname"]), "标注", baseInfo, allTagFields)
- qu.Debug("Save Log:", b)
- f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
- }
- // MarkBase 标注基本信息
- func MarkBase(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}) {
- defer qu.Catch()
- info, _ := content[0].(map[string]interface{})
- if uInputs, ok := info["uInput"].([]interface{}); ok {
- for _, tmp := range uInputs {
- if tmpMap, ok := tmp.(map[string]interface{}); ok {
- if status := qu.IntAll(tmpMap["status"]); status != -1 {
- key := qu.ObjToString(tmpMap["key"]) //字段
- if key == "" {
- continue
- }
- if status == 2 { //新增、修改、删除
- input := tmpMap["input"] //值
- if key == "bidamounttype" || key == "subtype" || key == "attach_discern" || key == "attach_ext" || key == "isrepeat" { //附件识别、抽取select
- input = tmpMap["select"]
- }
- if input == "" { //删除原字段
- baseUnset[key] = ""
- } else { //修改原字段
- if key == "budget" || key == "bidamount" || key == "biddiscount" {
- input = qu.Float64All(input)
- //input, _ = strconv.ParseFloat(qu.ObjToString(input), 32)
- }
- if key == "subtype" {
- if topsubtype := strings.Split(qu.ObjToString(input), "-"); len(topsubtype) == 2 {
- baseSet["toptype"] = topsubtype[0]
- baseSet[key] = topsubtype[1]
- }
- } else if key == "s_winner" {
- if strings.Contains(qu.ObjToString(input), ",") {
- baseSet[key] = strings.ReplaceAll(qu.ObjToString(input), ",", ",")
- } else {
- baseSet[key] = input
- }
- } else {
- baseSet[key] = input
- }
- }
- }
- tagSet[key] = status //记录被标注状态
- }
- }
- }
- }
- qu.Debug("tagSet===", tagSet)
- qu.Debug("baseSet===", baseSet)
- qu.Debug("baseUnset===", baseUnset)
- }
- // MarkTimePlace 标注时间地点
- func MarkTimePlace(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}) {
- info, _ := content[0].(map[string]interface{})
- if uInputs, ok := info["uInput"].([]interface{}); ok {
- for _, tmp := range uInputs {
- if tmpMap, ok := tmp.(map[string]interface{}); ok {
- if status := qu.IntAll(tmpMap["status"]); status != -1 {
- key := qu.ObjToString(tmpMap["key"]) //字段
- if key == "" {
- continue
- }
- if status == 2 { //新增、修改、删除
- input := tmpMap["input"] //值
- if input == "" {
- baseUnset[key] = ""
- } else {
- if key == "bidopentime" || key == "publishtime" || key == "bidendtime" || key == "project_startdate" || key == "project_completedate" {
- inputTmp, _ := time.ParseInLocation(qu.Date_Full_Layout, input.(string), time.Local)
- input = inputTmp.Unix()
- } else if key == "project_duration" {
- input = qu.IntAll(input)
- }
- baseSet[key] = input
- }
- }
- tagSet[key] = status
- }
- }
- }
- }
- qu.Debug("tagSet===", tagSet)
- qu.Debug("baseSet===", baseSet)
- qu.Debug("baseUnset===", baseUnset)
- }
- func MarkPurchasinglist(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, istag bool, status int) {
- if status == -1 {
- return
- }
- baseSet["purchasinglist_alltag"] = istag //标的信息是否标注完全
- purchasinglist := []interface{}{}
- purchasinglistStatus := []interface{}{}
- delpclson := 0
- for _, con := range content {
- info, _ := con.(map[string]interface{})
- //isNew, _ := info["isnew"].(bool) //是否是新增子包
- pclSonStatus := qu.IntAll(info["status"])
- if pclSonStatus == 4 {
- delpclson++
- }
- if uInputs, ok := info["uInput"].([]interface{}); ok {
- result := map[string]interface{}{
- //"isnew": isNew,
- }
- statusMap := make(map[string]interface{})
- for _, tmp := range uInputs {
- if tmpMap, ok := tmp.(map[string]interface{}); ok {
- key := qu.ObjToString(tmpMap["key"]) //字段
- input := tmpMap["input"] //值
- status := qu.IntAll(tmpMap["status"])
- statusMap[key] = status
- isNull := false
- if input == "" { //判断前台页面是否填值,无值不进行字段存储
- isNull = true
- } else if key == "number" || key == "unitprice" || key == "totalprice" {
- input = qu.Float64All(input)
- }
- if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
- result[key] = input
- }
- }
- }
- if pclSonStatus != -1 { //没有标注的标的信息不打标记
- result["purchasinglist_son"] = pclSonStatus
- }
- if len(result) > 0 && pclSonStatus != 4 {
- purchasinglist = append(purchasinglist, result)
- purchasinglistStatus = append(purchasinglistStatus, statusMap)
- }
- }
- }
- qu.Debug("purchasinglist", len(purchasinglist))
- if len(purchasinglist)+delpclson == len(content) {
- if len(purchasinglist) > 0 {
- baseSet["purchasinglist"] = purchasinglist
- } else if len(content) > 0 && delpclson == len(content) { //只有删除
- baseUnset["purchasinglist"] = ""
- }
- //tagSet["purchasinglist"] = status
- tagSet["purchasinglist"] = purchasinglistStatus
- } else {
- qu.Debug("Purchasinglist Tag Error")
- }
- qu.Debug("tagSet===", tagSet)
- qu.Debug("baseSet===", baseSet)
- qu.Debug("baseUnset===", baseUnset)
- }
- func MarkProcurementList(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, istag bool, status int) {
- if status == -1 {
- return
- }
- baseSet["procurementlist_alltag"] = istag //是否标注完全
- procurementlist := []interface{}{}
- procurementlistStatus := []interface{}{}
- delpclson := 0
- for _, con := range content {
- info, _ := con.(map[string]interface{})
- //isNew, _ := info["isnew"].(bool) //是否是新增子包
- pclSonStatus := qu.IntAll(info["status"])
- if pclSonStatus == 4 {
- delpclson++
- }
- if uInputs, ok := info["uInput"].([]interface{}); ok {
- result := map[string]interface{}{
- //"isnew": isNew,
- }
- statusMap := make(map[string]interface{})
- for _, tmp := range uInputs {
- if tmpMap, ok := tmp.(map[string]interface{}); ok {
- key := qu.ObjToString(tmpMap["key"]) //字段
- input := tmpMap["input"] //值
- status := qu.IntAll(tmpMap["status"])
- statusMap[key] = status
- isNull := false
- if input == "" { //判断前台页面是否填值,无值不进行字段存储
- isNull = true
- } else if key == "number" || key == "unitprice" || key == "totalprice" {
- input = qu.Float64All(input)
- }
- if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
- result[key] = input
- }
- }
- }
- if pclSonStatus != -1 { //没有标注的标的信息不打标记
- result["procurementlist_son"] = pclSonStatus
- }
- if len(result) > 0 && pclSonStatus != 4 {
- procurementlist = append(procurementlist, result)
- procurementlistStatus = append(procurementlistStatus, statusMap)
- }
- }
- }
- qu.Debug("procurementlist", len(procurementlist))
- if len(procurementlist)+delpclson == len(content) {
- if len(procurementlist) > 0 {
- baseSet["procurementlist"] = procurementlist
- } else if len(content) > 0 && delpclson == len(content) { //只有删除
- baseUnset["procurementlist"] = ""
- }
- //tagSet["purchasinglist"] = status
- tagSet["procurementlist"] = procurementlistStatus
- } else {
- qu.Debug("ProcurementList Tag Error")
- }
- qu.Debug("tagSet===", tagSet)
- qu.Debug("baseSet===", baseSet)
- qu.Debug("baseUnset===", baseUnset)
- }
- // MarkPackage 标注多包信息
- func MarkPackage(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, status int) {
- if status == -1 {
- return
- }
- pkgs := map[string]interface{}{}
- newNum := 1
- delpkgson := 0 //记录子包删除个数
- var sw []string
- for _, con := range content {
- info, _ := con.(map[string]interface{})
- pkgSonStatus := qu.IntAll(info["status"])
- if pkgSonStatus == 4 {
- delpkgson++
- }
- num := fmt.Sprint(info["num"]) //包号
- isNew, _ := info["isnew"].(bool) //是否是新增子包
- if isNew { //新增子包新建包名
- num = "new" + fmt.Sprint(newNum)
- newNum++
- }
- if uInputs, ok := info["uInput"].([]interface{}); ok {
- result := map[string]interface{}{
- "isnew": isNew,
- }
- winnerArr := []interface{}{}
- bidamountArr := []interface{}{}
- for _, tmp := range uInputs {
- if tmpMap, ok := tmp.(map[string]interface{}); ok {
- key := qu.ObjToString(tmpMap["key"]) //字段
- input := tmpMap["input"] //值
- isNull := false //记录字段是否有值
- if key == "bidamounttype" {
- input = tmpMap["select"]
- } else {
- if input == "" { //判断前台页面是否填值,无值不进行字段存储
- isNull = true
- } else if key == "bidamount" || key == "budget" {
- input = qu.Float64All(input)
- //input, _ = strconv.ParseFloat(qu.ObjToString(input), 32)
- }
- }
- if key == "winner" {
- if isNull {
- winnerArr = append(winnerArr, nil)
- } else {
- winnerArr = append(winnerArr, input)
- }
- continue
- } else if key == "bidamount" {
- if isNull {
- bidamountArr = append(bidamountArr, nil)
- } else {
- bidamountArr = append(bidamountArr, input)
- }
- continue
- }
- if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
- result[key] = input
- }
- }
- }
- winner_all := []interface{}{}
- if len(winnerArr) == len(bidamountArr) {
- for i, w := range winnerArr {
- b := bidamountArr[i]
- wbMap := map[string]interface{}{}
- if w != nil {
- wbMap["winner"] = w
- sw = append(sw, qu.ObjToString(w))
- }
- if b != nil {
- wbMap["bidamount"] = b
- }
- if len(wbMap) > 0 {
- winner_all = append(winner_all, wbMap)
- }
- }
- }
- if len(winner_all) > 0 {
- result["winner_all"] = winner_all
- }
- result["package_son"] = pkgSonStatus
- if len(result) > 0 && pkgSonStatus != 4 { //要删除的子包不再保存
- pkgs[num] = result
- }
- }
- }
- qu.Debug("pkgs", len(pkgs))
- if len(pkgs)+delpkgson == len(content) {
- if len(pkgs) > 0 {
- baseSet["package"] = pkgs
- baseSet["s_winner"] = strings.Join(sw, ",")
- } else if len(content) > 0 && delpkgson == len(content) { //只有删除
- baseUnset["package"] = ""
- }
- tagSet["package"] = status
- } else {
- qu.Debug("Package Tag Error")
- }
- }
- // 标注中标候选人信息
- func MarkWonderorder(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, status int) {
- if status == -1 {
- return
- }
- winnerorder := []interface{}{}
- delwodrson := 0
- for _, con := range content {
- info, _ := con.(map[string]interface{})
- isNew, _ := info["isnew"].(bool) //是否是新增子包
- wodrSonStatus := qu.IntAll(info["status"])
- if wodrSonStatus == 4 {
- delwodrson++
- }
- if uInputs, ok := info["uInput"].([]interface{}); ok {
- result := map[string]interface{}{
- "isnew": isNew,
- }
- for _, tmp := range uInputs {
- if tmpMap, ok := tmp.(map[string]interface{}); ok {
- key := qu.ObjToString(tmpMap["key"]) //字段
- input := tmpMap["input"] //值
- isNull := false
- if input == "" { //判断前台页面是否填值,无值不进行字段存储
- isNull = true
- } else if key == "price" {
- input = qu.Float64All(input)
- //input, _ = strconv.ParseFloat(qu.ObjToString(input), 32)
- }
- if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
- result[key] = input
- }
- result["winnerorder_son"] = wodrSonStatus
- }
- }
- if len(result) > 0 && wodrSonStatus != 4 {
- winnerorder = append(winnerorder, result)
- }
- }
- }
- qu.Debug("winnerorder", len(winnerorder))
- if len(winnerorder)+delwodrson == len(content) {
- if len(winnerorder) > 0 {
- baseSet["winnerorder"] = winnerorder
- } else if len(content) > 0 && delwodrson == len(content) { //只有删除
- baseUnset["winnerorder"] = ""
- }
- tagSet["winnerorder"] = status
- } else {
- qu.Debug("Winnerorder Tag Error")
- }
- qu.Debug("tagSet===", tagSet)
- qu.Debug("baseSet===", baseSet)
- qu.Debug("baseUnset===", baseUnset)
- }
- // 标注其他信息
- func MarkOther(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}) {
- info, _ := content[0].(map[string]interface{})
- if uInputs, ok := info["uInput"].([]interface{}); ok {
- for _, tmp := range uInputs {
- if tmpMap, ok := tmp.(map[string]interface{}); ok {
- if status := qu.IntAll(tmpMap["status"]); status != -1 {
- key := qu.ObjToString(tmpMap["key"]) //字段
- if key == "" {
- continue
- }
- if status == 2 { //新增、修改、删除
- input := tmpMap["input"] //值
- if key == "isppp" || key == "contract_guarantee" || key == "bid_guarantee" {
- input = tmpMap["select"]
- }
- if input == "" {
- baseUnset[key] = ""
- } else {
- if key == "signaturedate" {
- inputTmp, _ := time.ParseInLocation(qu.Date_Full_Layout, input.(string), time.Local)
- input = inputTmp.Unix()
- } else if key == "bid_bond" || key == "contract_bond" || key == "supervisorrate" || key == "agencyrate" || key == "docamount" || key == "agencyfee" ||
- key == "biddiscount" {
- input = qu.Float64All(input)
- //input, _ = strconv.ParseFloat(qu.ObjToString(input), 32)
- }
- baseSet[key] = input
- }
- }
- tagSet[key] = status
- }
- }
- }
- }
- qu.Debug("tagSet===", tagSet)
- qu.Debug("baseSet===", baseSet)
- qu.Debug("baseUnset===", baseUnset)
- }
- // SaveLog 标注日志保存
- func SaveLog(s_infoid, s_usertaskid, username, userid, role, projectname, s_stype string, baseInfo, allTagFields map[string]interface{}) (success bool) {
- defer qu.Debug()
- v_before := map[string]interface{}{}
- for f, v := range allTagFields {
- if _, ok := v.(bool); ok && f != "purchasinglist_alltag" { //表示此次标注status=1的字段
- allTagFields[f] = baseInfo[f]
- }
- v_before[f] = baseInfo[f]
- }
- save := map[string]interface{}{
- "s_projectname": projectname,
- "s_taskid": s_usertaskid,
- "s_infoid": s_infoid,
- "s_stype": s_stype,
- "s_userid": userid,
- "s_role": role,
- "s_username": username,
- "i_createtime": time.Now().Unix(),
- "v_before": v_before,
- "v_after": allTagFields,
- }
- id := util.Mgo.Save(util.LOGCOLLNAME, save)
- if id != "" {
- success = true
- }
- return
- }
- func (f *Front) CheckDataPurchase() {
- defer qu.Catch()
- if f.Method() == "POST" {
- datatype, _ := f.GetInteger("datatype")
- stype := f.GetString("stype")
- sourceinfo := f.GetString("s_sourceinfo")
- tid := f.GetString("taskid")
- pid := f.GetString("pid")
- keyword := f.GetString("keyword")
- keyword = strings.ReplaceAll(keyword, ",", ",")
- keyArr := strings.Split(keyword, ",")
- query := make(map[string]interface{})
- if tid != "" {
- query["b_istag"] = true
- if stype == "group" {
- query["s_grouptaskid"] = tid
- } else {
- query["s_usertaskid"] = tid
- }
- } else {
- if stype == "notag" {
- query["b_istagging"] = false
- if datatype == 1 {
- // 待分发数据
- query["b_isgivegroup"] = false
- } else {
- // 已分发 标注数据
- query["b_istag"] = true
- query["b_isgivegroup"] = true
- }
- } else if stype == "tag" { //未达标
- query["b_istagging"] = true
- query["i_ckdata"] = 2
- } else {
- query["i_ckdata"] = 2
- }
- }
- util.Mgo.UpdateById(util.PROJECTCOLLNAME, pid, map[string]interface{}{"$set": map[string]interface{}{"purchasinglist_key": keyword}})
- query["v_baseinfo.purchasinglist"] = map[string]interface{}{"$exists": true}
- count := util.Mgo.Count(sourceinfo, query)
- qu.Debug(query, count)
- info, _ := util.Mgo.Find(sourceinfo, query, `{"_id": 1}`, `{"v_baseinfo": 1, "b_isEff": 1, "v_checkinfo": 1, "v_taginfo": 1}`, false, -1, -1)
- var updateArr [][]map[string]interface{}
- for _, m := range *info {
- baseinfo := m["v_baseinfo"].(map[string]interface{})
- //taginfo := m["v_taginfo"].(map[string]interface{})
- //checkinfo := m["v_checkinfo"].(map[string]interface{})
- //var pursTag, pursCheck []interface{}
- purs := baseinfo["purchasinglist"].([]interface{})
- //if taginfo["purchasinglist"] != nil {
- // pursTag = taginfo["purchasinglist"].([]interface{})
- //}
- //if checkinfo["purchasinglist"] != nil {
- // pursCheck = checkinfo["purchasinglist"].([]interface{})
- //}
- if len(purs) > 0 {
- //arr1 := []map[string]interface{}{} //检验通过
- //arr2 := []map[string]interface{}{} //检验未通过
- for _, m2 := range qu.ObjArrToMapArr(purs) {
- if validPurchase(keyArr, qu.ObjToString(m2["itemname"])) {
- m2["b_isEff"] = true
- if m["b_isEff"] != nil && !m["b_isEff"].(bool) {
- m["b_isEff"] = true
- }
- //arr1 = append(arr1, m2)
- } else {
- m2["b_isEff"] = false
- //arr2 = append(arr2, m2)
- }
- }
- //baseinfo["purchasinglist"] = append(arr1, arr2...)
- var update []map[string]interface{}
- update = append(update, map[string]interface{}{"_id": m["_id"]})
- update = append(update, map[string]interface{}{"$set": m})
- updateArr = append(updateArr, update)
- }
- if len(updateArr) > 500 {
- tmps := updateArr
- util.Mgo.UpdateBulk(sourceinfo, tmps...)
- updateArr = [][]map[string]interface{}{}
- }
- }
- if len(updateArr) > 0 {
- util.Mgo.UpSertBulk(sourceinfo, updateArr...)
- }
- f.ServeJson(map[string]interface{}{"success": true, "msg": ""})
- }
- }
- func validPurchase(arr []string, str string) bool {
- for _, s := range arr {
- if strings.Contains(str, s) {
- return true
- }
- }
- return false
- }
|