|
@@ -37,6 +37,7 @@ type Front struct {
|
|
importByEs xweb.Mapper `xweb:"/importbyes"`
|
|
importByEs xweb.Mapper `xweb:"/importbyes"`
|
|
getEsCount xweb.Mapper `xweb:"/getescount"`
|
|
getEsCount xweb.Mapper `xweb:"/getescount"`
|
|
finishCheck xweb.Mapper `xweb:"/finishcheck"`
|
|
finishCheck xweb.Mapper `xweb:"/finishcheck"`
|
|
|
|
+ syncMarked xweb.Mapper `xweb:"/syncmarked"`
|
|
}
|
|
}
|
|
|
|
|
|
//var IdList *list.List //所有数据
|
|
//var IdList *list.List //所有数据
|
|
@@ -343,10 +344,9 @@ func (i *Front) Biaozhu() error {
|
|
errset[f] = (*data)[f]
|
|
errset[f] = (*data)[f]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if len(errset) > 0 {
|
|
|
|
- //qu.Debug("errset---", errset)
|
|
|
|
- errUpdata["$set"] = errset
|
|
|
|
- }
|
|
|
|
|
|
+ //qu.Debug("errset---", errset)
|
|
|
|
+ errset["updatetime"] = time.Now().Unix()
|
|
|
|
+ errUpdata["$set"] = errset
|
|
}
|
|
}
|
|
if len(unerrset) > 0 {
|
|
if len(unerrset) > 0 {
|
|
//qu.Debug("unerrset---", unerrset)
|
|
//qu.Debug("unerrset---", unerrset)
|
|
@@ -360,6 +360,7 @@ func (i *Front) Biaozhu() error {
|
|
update := map[string]interface{}{}
|
|
update := map[string]interface{}{}
|
|
if len(set) > 0 {
|
|
if len(set) > 0 {
|
|
set["ck_data"] = stype
|
|
set["ck_data"] = stype
|
|
|
|
+ set["updatetime"] = time.Now().Unix()
|
|
update["$set"] = set
|
|
update["$set"] = set
|
|
}
|
|
}
|
|
if len(unset) > 0 {
|
|
if len(unset) > 0 {
|
|
@@ -449,11 +450,11 @@ func (i *Front) ImportByExcel() {
|
|
for rn, row := range rows {
|
|
for rn, row := range rows {
|
|
if rn == 0 {
|
|
if rn == 0 {
|
|
for j, cell := range row.Cells {
|
|
for j, cell := range row.Cells {
|
|
- val := cell.Value
|
|
|
|
- if fieldName := util.Config.CustomerField[val]; fieldName != "" { //客户需求字段
|
|
|
|
|
|
+ title := cell.Value
|
|
|
|
+ if fieldName := util.Config.CustomerField[title]; fieldName != "" { //客户需求字段
|
|
cellFieldName[j] = fieldName
|
|
cellFieldName[j] = fieldName
|
|
}
|
|
}
|
|
- if val == "唯一标识" || val == "信息标识" { //id所在列
|
|
|
|
|
|
+ if title == "唯一标识" || title == "信息标识" { //id所在列
|
|
idcolnum = j
|
|
idcolnum = j
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -462,12 +463,22 @@ func (i *Front) ImportByExcel() {
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- if len(row.Cells) != len(rows[0].Cells) {
|
|
|
|
|
|
+ if len(row.Cells) < len(rows[0].Cells) {
|
|
break
|
|
break
|
|
}
|
|
}
|
|
tmp := map[string]interface{}{}
|
|
tmp := map[string]interface{}{}
|
|
for j, f := range cellFieldName {
|
|
for j, f := range cellFieldName {
|
|
- tmp[f] = row.Cells[j].Value
|
|
|
|
|
|
+ if val := row.Cells[j].Value; val != "" {
|
|
|
|
+ if f == "capital" { //注册资金(万元)
|
|
|
|
+ cf, _ := row.Cells[j].Float()
|
|
|
|
+ tmp[f] = cf
|
|
|
|
+ } else if f == "createtime" { //创建时间
|
|
|
|
+ ci, _ := row.Cells[j].Int64()
|
|
|
|
+ tmp[f] = ci
|
|
|
|
+ } else {
|
|
|
|
+ tmp[f] = val
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
id := row.Cells[idcolnum].String() //加密的id
|
|
id := row.Cells[idcolnum].String() //加密的id
|
|
if id == "" {
|
|
if id == "" {
|
|
@@ -480,6 +491,8 @@ func (i *Front) ImportByExcel() {
|
|
importNum = len(ids) //excel表数据个数
|
|
importNum = len(ids) //excel表数据个数
|
|
if importNum > 0 {
|
|
if importNum > 0 {
|
|
_, msg, successNum = GetDataById(coll, ids, "excel", tmpMap)
|
|
_, msg, successNum = GetDataById(coll, ids, "excel", tmpMap)
|
|
|
|
+ tmpMap = map[string]map[string]interface{}{}
|
|
|
|
+ ids = []string{}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
msg = fmt.Sprintf("共查询%d条,导入成功%d条\n", importNum, successNum) + msg
|
|
msg = fmt.Sprintf("共查询%d条,导入成功%d条\n", importNum, successNum) + msg
|
|
@@ -590,63 +603,55 @@ func (i *Front) ImportByEs() {
|
|
i.ServeJson(map[string]interface{}{"msg": msg})
|
|
i.ServeJson(map[string]interface{}{"msg": msg})
|
|
}
|
|
}
|
|
|
|
|
|
-//统计抽查
|
|
|
|
-func (i *Front) Tj() error {
|
|
|
|
- comm := map[string]map[string]int{}
|
|
|
|
- comm_win := map[string]map[string]int{}
|
|
|
|
- pack := map[string]map[string]int{}
|
|
|
|
- pack_win := map[string]map[string]int{}
|
|
|
|
- list, _ := util.MgoM.Find(util.Config.Totablel, "{}", nil, nil, false, -1, -1)
|
|
|
|
- for _, tmp := range *list {
|
|
|
|
- for k, val := range tmp {
|
|
|
|
- if len(k) > 3 && k[:3] == preKey {
|
|
|
|
- comm = mapIntAdd(k, qu.ObjToString(val), comm)
|
|
|
|
|
|
+//同步数据
|
|
|
|
+func (i *Front) SyncMarked() {
|
|
|
|
+ syncColl := i.GetString("coll")
|
|
|
|
+ sess := util.MgoM.GetMgoConn()
|
|
|
|
+ defer util.MgoM.DestoryMongoConn(sess)
|
|
|
|
+ it := sess.DB(util.Config.Dbname).C(syncColl).Find(nil).Iter()
|
|
|
|
+ count, _ := sess.DB(util.Config.Dbname).C(syncColl).Find(nil).Count()
|
|
|
|
+ n := 0
|
|
|
|
+ lock := &sync.Mutex{}
|
|
|
|
+ wg := &sync.WaitGroup{}
|
|
|
|
+ ch := make(chan bool, 3)
|
|
|
|
+ result := map[string]map[string]interface{}{}
|
|
|
|
+ idArr := []string{}
|
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
|
|
|
|
+ wg.Add(1)
|
|
|
|
+ ch <- true
|
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
|
+ defer func() {
|
|
|
|
+ <-ch
|
|
|
|
+ wg.Done()
|
|
|
|
+ }()
|
|
|
|
+ id := qu.ObjToString(tmp["id"])
|
|
|
|
+ if id == "" {
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if winnerorder, ok := tmp["winnerorder"].([]interface{}); ok {
|
|
|
|
- for _, wd := range winnerorder {
|
|
|
|
- if winner, ok := wd.(map[string]interface{}); ok {
|
|
|
|
- for k, val := range winner {
|
|
|
|
- if len(k) > 3 && k[:3] == preKey {
|
|
|
|
- comm_win = mapIntAdd(k, qu.ObjToString(val), comm_win)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ tmpMap := map[string]interface{}{}
|
|
|
|
+ for _, f := range util.Config.CustomerField {
|
|
|
|
+ if val := tmp[f]; val != nil {
|
|
|
|
+ tmpMap[f] = val
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if ptmp, ok := tmp["package"].(map[string]interface{}); ok {
|
|
|
|
- for _, pktmp := range ptmp {
|
|
|
|
- if pkage, ok := pktmp.(map[string]interface{}); ok {
|
|
|
|
- for k, val := range pkage {
|
|
|
|
- if len(k) > 3 && k[:3] == preKey {
|
|
|
|
- pack = mapIntAdd(k, qu.ObjToString(val), pack)
|
|
|
|
- }
|
|
|
|
- if k == "winnerorder" {
|
|
|
|
- if wtmp, ok := val.([]interface{}); ok {
|
|
|
|
- for _, winner := range wtmp {
|
|
|
|
- if win, ok := winner.(map[string]interface{}); ok {
|
|
|
|
- for wk, wval := range win {
|
|
|
|
- if len(k) > 3 && k[:3] == preKey {
|
|
|
|
- pack_win = mapIntAdd(wk, qu.ObjToString(wval), pack_win)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ lock.Lock()
|
|
|
|
+ idArr = append(idArr, id)
|
|
|
|
+ result[id] = tmpMap
|
|
|
|
+ lock.Unlock()
|
|
|
|
+ }(tmp)
|
|
|
|
+ tmp = map[string]interface{}{}
|
|
}
|
|
}
|
|
- //data := map[string]interface{}{"total": len(list), "comm": comm, "pack": pack, "pack_win": pack_win}
|
|
|
|
- //mongodb.Save("extcheck_tj", data)
|
|
|
|
- i.T["comm"] = comm
|
|
|
|
- i.T["pack"] = pack
|
|
|
|
- i.T["comm_win"] = comm_win
|
|
|
|
- i.T["pack_win"] = pack_win
|
|
|
|
- i.T["total"] = len(*list)
|
|
|
|
- return i.Render("tj.html", &i.T)
|
|
|
|
|
|
+ wg.Wait()
|
|
|
|
+ if count != int64(len(result)) {
|
|
|
|
+ i.ServeJson(map[string]interface{}{"msg": "同步失败", "flag": false})
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //util.MgoM.C.Database(util.Config.Dbname).Collection(syncColl).Drop(util.MgoM.Ctx) //删除syncColl表(清空数据)
|
|
|
|
+ success, msg, successNum := GetDataById(syncColl, idArr, "syncoll", result)
|
|
|
|
+ result = map[string]map[string]interface{}{}
|
|
|
|
+ idArr = []string{}
|
|
|
|
+ msg = fmt.Sprintf("共查询%d条,同步成功%d条\n", count, successNum) + msg
|
|
|
|
+ i.ServeJson(map[string]interface{}{"msg": msg, "flag": success})
|
|
}
|
|
}
|
|
|
|
|
|
//标注完成
|
|
//标注完成
|
|
@@ -1304,6 +1309,14 @@ func GetDataById(coll string, ids []string, stype string, tmp map[string]map[str
|
|
wg.Done()
|
|
wg.Done()
|
|
<-ch
|
|
<-ch
|
|
}()
|
|
}()
|
|
|
|
+ /*
|
|
|
|
+ 1.查bidding
|
|
|
|
+ 2.查extract
|
|
|
|
+ 3.extract合并到bidding(删除item字段以为与客户需要的item不是一个含义)
|
|
|
|
+ 4.对比marked表,替换已标注过的字段值,补充标记
|
|
|
|
+ 5.合并客户所需字段信息,补充id字段
|
|
|
|
+ 6.若为同步时,删除原有id对应的信息,新增该id对应的_id信息
|
|
|
|
+ */
|
|
tmpBidColl := util.BidColl1 //bidding
|
|
tmpBidColl := util.BidColl1 //bidding
|
|
//查询bidding
|
|
//查询bidding
|
|
if id < util.BIDDINGSTARTID {
|
|
if id < util.BIDDINGSTARTID {
|
|
@@ -1322,12 +1335,30 @@ func GetDataById(coll string, ids []string, stype string, tmp map[string]map[str
|
|
(*bidData)[k] = v
|
|
(*bidData)[k] = v
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //删除item
|
|
|
|
+ delete((*bidData), "item")
|
|
//对比marked表是否已标注该数据
|
|
//对比marked表是否已标注该数据
|
|
markData, _ := util.MgoM.FindById(util.Config.Fromtable, id, nil)
|
|
markData, _ := util.MgoM.FindById(util.Config.Fromtable, id, nil)
|
|
if markData != nil && len(*markData) > 0 {
|
|
if markData != nil && len(*markData) > 0 {
|
|
UpdateMarkColl(bidData, markData) //比对更新数据
|
|
UpdateMarkColl(bidData, markData) //比对更新数据
|
|
} else {
|
|
} else {
|
|
(*bidData)["ck_data"] = 0 //设置ck_data默认值0
|
|
(*bidData)["ck_data"] = 0 //设置ck_data默认值0
|
|
|
|
+ //多包、中标候选人、标的信息是否抽取
|
|
|
|
+ if packageMap, ok := (*bidData)["package"].(map[string]interface{}); ok && len(packageMap) > 0 {
|
|
|
|
+ (*bidData)["ck_pkgisext"] = true
|
|
|
|
+ } else {
|
|
|
|
+ (*bidData)["ck_pkgisext"] = false
|
|
|
|
+ }
|
|
|
|
+ if winorderArr, ok := (*bidData)["winnerorder"].([]interface{}); ok && len(winorderArr) > 0 {
|
|
|
|
+ (*bidData)["ck_wodrisext"] = true
|
|
|
|
+ } else {
|
|
|
|
+ (*bidData)["ck_wodrisext"] = false
|
|
|
|
+ }
|
|
|
|
+ if purchArr, ok := (*bidData)["purchasinglist"].([]interface{}); ok && len(purchArr) > 0 {
|
|
|
|
+ (*bidData)["ck_pclisext"] = true
|
|
|
|
+ } else {
|
|
|
|
+ (*bidData)["ck_pclisext"] = false
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//合并导入表中客户所需的字段
|
|
//合并导入表中客户所需的字段
|
|
if len(tmp) > 0 {
|
|
if len(tmp) > 0 {
|
|
@@ -1335,24 +1366,16 @@ func GetDataById(coll string, ids []string, stype string, tmp map[string]map[str
|
|
(*bidData)[k] = v
|
|
(*bidData)[k] = v
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //多包、中标候选人、标的信息是否抽取
|
|
|
|
- if packageMap, ok := (*bidData)["package"].(map[string]interface{}); ok && len(packageMap) > 0 {
|
|
|
|
- (*bidData)["ck_pkgisext"] = true
|
|
|
|
- } else {
|
|
|
|
- (*bidData)["ck_pkgisext"] = false
|
|
|
|
- }
|
|
|
|
- if winorderArr, ok := (*bidData)["winnerorder"].([]interface{}); ok && len(winorderArr) > 0 {
|
|
|
|
- (*bidData)["ck_wodrisext"] = true
|
|
|
|
- } else {
|
|
|
|
- (*bidData)["ck_wodrisext"] = false
|
|
|
|
- }
|
|
|
|
- if purchArr, ok := (*bidData)["purchasinglist"].([]interface{}); ok && len(purchArr) > 0 {
|
|
|
|
- (*bidData)["ck_pclisext"] = true
|
|
|
|
- } else {
|
|
|
|
- (*bidData)["ck_pclisext"] = false
|
|
|
|
- }
|
|
|
|
//补充id
|
|
//补充id
|
|
(*bidData)["id"] = id
|
|
(*bidData)["id"] = id
|
|
|
|
+ if stype == "syncoll" { //同步数据时删除原始数据
|
|
|
|
+ if util.MgoM.Delete(coll, `{"id":"`+id+`"}`) == 0 {
|
|
|
|
+ lock.Lock()
|
|
|
|
+ *msg += "同步未删除成功数据id:" + id + ";\n"
|
|
|
|
+ *success = false
|
|
|
|
+ lock.Unlock()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//保存数据
|
|
//保存数据
|
|
if util.MgoM.SaveByOriID(coll, bidData) {
|
|
if util.MgoM.SaveByOriID(coll, bidData) {
|
|
atomic.AddInt64(&n, 1) //计数
|
|
atomic.AddInt64(&n, 1) //计数
|
|
@@ -1360,9 +1383,9 @@ func GetDataById(coll string, ids []string, stype string, tmp map[string]map[str
|
|
lock.Lock()
|
|
lock.Lock()
|
|
*success = false
|
|
*success = false
|
|
if stype == "excel" {
|
|
if stype == "excel" {
|
|
- *msg += "第" + fmt.Sprint(i+2) + "行未查询到数据:" + id + ";\n"
|
|
|
|
|
|
+ *msg += "第" + fmt.Sprint(i+2) + "行未保存成功数据_id:" + id + ";\n"
|
|
} else {
|
|
} else {
|
|
- *msg += "未查询到数据:" + id + ";\n"
|
|
|
|
|
|
+ *msg += "未保存成功数据_id:" + id + ";\n"
|
|
}
|
|
}
|
|
lock.Unlock()
|
|
lock.Unlock()
|
|
}
|
|
}
|
|
@@ -1372,7 +1395,7 @@ func GetDataById(coll string, ids []string, stype string, tmp map[string]map[str
|
|
if stype == "excel" {
|
|
if stype == "excel" {
|
|
*msg += "第" + fmt.Sprint(i+2) + "行未查询到数据:" + id + ";\n"
|
|
*msg += "第" + fmt.Sprint(i+2) + "行未查询到数据:" + id + ";\n"
|
|
} else {
|
|
} else {
|
|
- *msg += "未查询到数据:" + id + ";\n"
|
|
|
|
|
|
+ *msg += "未查询到数据_id:" + id + ";\n"
|
|
}
|
|
}
|
|
lock.Unlock()
|
|
lock.Unlock()
|
|
}
|
|
}
|
|
@@ -1397,7 +1420,10 @@ func UpdateMarkColl(bidData, markData *map[string]interface{}) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- (*markData)["ck_data"] = 0 //marked表中该条数据如果为字段验证,临时表ck_data:0;若为数据验证ck_data:1
|
|
|
|
|
|
+ (*bidData)["ck_data"] = 0 //marked表中该条数据如果为字段验证,临时表ck_data:0;若为数据验证ck_data:1
|
|
|
|
+ } else if ck_data == 1 {
|
|
|
|
+ *bidData = *markData
|
|
|
|
+ (*bidData)["ck_data"] = 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1432,3 +1458,62 @@ func GetCheckedAndAllDataInfo() (int, int) {
|
|
checkedCount := util.MgoM.Count(util.Coll, ckDataQuery)
|
|
checkedCount := util.MgoM.Count(util.Coll, ckDataQuery)
|
|
return checkedCount, allCount
|
|
return checkedCount, allCount
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//统计抽查
|
|
|
|
+func (i *Front) Tj() error {
|
|
|
|
+ comm := map[string]map[string]int{}
|
|
|
|
+ comm_win := map[string]map[string]int{}
|
|
|
|
+ pack := map[string]map[string]int{}
|
|
|
|
+ pack_win := map[string]map[string]int{}
|
|
|
|
+ list, _ := util.MgoM.Find(util.Config.Totablel, "{}", nil, nil, false, -1, -1)
|
|
|
|
+ for _, tmp := range *list {
|
|
|
|
+ for k, val := range tmp {
|
|
|
|
+ if len(k) > 3 && k[:3] == preKey {
|
|
|
|
+ comm = mapIntAdd(k, qu.ObjToString(val), comm)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if winnerorder, ok := tmp["winnerorder"].([]interface{}); ok {
|
|
|
|
+ for _, wd := range winnerorder {
|
|
|
|
+ if winner, ok := wd.(map[string]interface{}); ok {
|
|
|
|
+ for k, val := range winner {
|
|
|
|
+ if len(k) > 3 && k[:3] == preKey {
|
|
|
|
+ comm_win = mapIntAdd(k, qu.ObjToString(val), comm_win)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ptmp, ok := tmp["package"].(map[string]interface{}); ok {
|
|
|
|
+ for _, pktmp := range ptmp {
|
|
|
|
+ if pkage, ok := pktmp.(map[string]interface{}); ok {
|
|
|
|
+ for k, val := range pkage {
|
|
|
|
+ if len(k) > 3 && k[:3] == preKey {
|
|
|
|
+ pack = mapIntAdd(k, qu.ObjToString(val), pack)
|
|
|
|
+ }
|
|
|
|
+ if k == "winnerorder" {
|
|
|
|
+ if wtmp, ok := val.([]interface{}); ok {
|
|
|
|
+ for _, winner := range wtmp {
|
|
|
|
+ if win, ok := winner.(map[string]interface{}); ok {
|
|
|
|
+ for wk, wval := range win {
|
|
|
|
+ if len(k) > 3 && k[:3] == preKey {
|
|
|
|
+ pack_win = mapIntAdd(wk, qu.ObjToString(wval), pack_win)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //data := map[string]interface{}{"total": len(list), "comm": comm, "pack": pack, "pack_win": pack_win}
|
|
|
|
+ //mongodb.Save("extcheck_tj", data)
|
|
|
|
+ i.T["comm"] = comm
|
|
|
|
+ i.T["pack"] = pack
|
|
|
|
+ i.T["comm_win"] = comm_win
|
|
|
|
+ i.T["pack_win"] = pack_win
|
|
|
|
+ i.T["total"] = len(*list)
|
|
|
|
+ return i.Render("tj.html", &i.T)
|
|
|
|
+}
|