|
@@ -2,15 +2,16 @@
|
|
package front
|
|
package front
|
|
|
|
|
|
import (
|
|
import (
|
|
- "container/list"
|
|
|
|
|
|
+ //"container/list"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
qu "qfw/util"
|
|
qu "qfw/util"
|
|
|
|
+ "sync/atomic"
|
|
|
|
|
|
//"qfw/util/mongodb"
|
|
//"qfw/util/mongodb"
|
|
mgo "mongodb"
|
|
mgo "mongodb"
|
|
- "qfw/util/redis"
|
|
|
|
|
|
+ //"qfw/util/redis"
|
|
"sort"
|
|
"sort"
|
|
"strings"
|
|
"strings"
|
|
"sync"
|
|
"sync"
|
|
@@ -25,7 +26,7 @@ import (
|
|
|
|
|
|
type Front struct {
|
|
type Front struct {
|
|
*xweb.Action
|
|
*xweb.Action
|
|
- index xweb.Mapper `xweb:"/"`
|
|
|
|
|
|
+ //index xweb.Mapper `xweb:"/"`
|
|
// pack xweb.Mapper `xweb:"/package"`
|
|
// pack xweb.Mapper `xweb:"/package"`
|
|
listInfo xweb.Mapper `xweb:"/list"`
|
|
listInfo xweb.Mapper `xweb:"/list"`
|
|
elist xweb.Mapper `xweb:"/elist"`
|
|
elist xweb.Mapper `xweb:"/elist"`
|
|
@@ -35,16 +36,17 @@ type Front struct {
|
|
importByExcel xweb.Mapper `xweb:"/importbyexcel"`
|
|
importByExcel xweb.Mapper `xweb:"/importbyexcel"`
|
|
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"`
|
|
}
|
|
}
|
|
|
|
|
|
-var IdList *list.List //所有数据
|
|
|
|
|
|
+//var IdList *list.List //所有数据
|
|
//var IdPackList *list.List //含有分包的数据
|
|
//var IdPackList *list.List //含有分包的数据
|
|
var preKey = "ck_"
|
|
var preKey = "ck_"
|
|
var preErr = "err_"
|
|
var preErr = "err_"
|
|
var SE = qu.SimpleEncrypt{Key: "topJYBX2019"}
|
|
var SE = qu.SimpleEncrypt{Key: "topJYBX2019"}
|
|
var Max, Min string
|
|
var Max, Min string
|
|
-
|
|
|
|
-const BIDDINGID = "5a862f0640d2d9bbe88e3cec" //bidding表最小id
|
|
|
|
|
|
+var HasNo bool //预算和中标金额是否存在标记
|
|
|
|
+var QueryFind map[string]interface{} //查询
|
|
|
|
|
|
/*
|
|
/*
|
|
status
|
|
status
|
|
@@ -54,6 +56,7 @@ const BIDDINGID = "5a862f0640d2d9bbe88e3cec" //bidding表最小id
|
|
3:修改
|
|
3:修改
|
|
4:删除
|
|
4:删除
|
|
*/
|
|
*/
|
|
|
|
+/**
|
|
//查询初始化的数据
|
|
//查询初始化的数据
|
|
func (i *Front) Index() error {
|
|
func (i *Front) Index() error {
|
|
_id := ""
|
|
_id := ""
|
|
@@ -90,9 +93,9 @@ func (i *Front) Index() error {
|
|
i.T["worder"] = rep["worder"]
|
|
i.T["worder"] = rep["worder"]
|
|
i.T["packs"] = rep["packs"]
|
|
i.T["packs"] = rep["packs"]
|
|
i.T["packskey"] = rep["packskey"]
|
|
i.T["packskey"] = rep["packskey"]
|
|
- i.T["pcl_isext"] = rep["pcl_isext"]
|
|
|
|
- i.T["wodr_isext"] = rep["wodr_isext"]
|
|
|
|
- i.T["pkg_isext"] = rep["pkg_isext"]
|
|
|
|
|
|
+ i.T["ck_pclisext"] = rep["ck_pclisext"]
|
|
|
|
+ i.T["ck_wodrisext"] = rep["ck_wodrisext"]
|
|
|
|
+ i.T["ck_pkgisext"] = rep["ck_pkgisext"]
|
|
i.T["timeplace"] = rep["timeplace"]
|
|
i.T["timeplace"] = rep["timeplace"]
|
|
i.T["purchasinglist"] = rep["purchasinglist"]
|
|
i.T["purchasinglist"] = rep["purchasinglist"]
|
|
i.T["other"] = rep["other"]
|
|
i.T["other"] = rep["other"]
|
|
@@ -109,7 +112,7 @@ func (i *Front) Index() error {
|
|
|
|
|
|
return i.Render("detail.html", &i.T)
|
|
return i.Render("detail.html", &i.T)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+*/
|
|
//列表
|
|
//列表
|
|
func (i *Front) ListInfo() error {
|
|
func (i *Front) ListInfo() error {
|
|
spidercode := i.GetString("spidercode")
|
|
spidercode := i.GetString("spidercode")
|
|
@@ -118,7 +121,11 @@ func (i *Front) ListInfo() error {
|
|
stype := i.GetString("type")
|
|
stype := i.GetString("type")
|
|
Min = i.GetString("minval")
|
|
Min = i.GetString("minval")
|
|
Max = i.GetString("maxval")
|
|
Max = i.GetString("maxval")
|
|
-
|
|
|
|
|
|
+ HasNo, _ = i.GetBool("hasno")
|
|
|
|
+ pagenum, _ := i.GetInteger("pagenum")
|
|
|
|
+ if pagenum == 0 {
|
|
|
|
+ pagenum = 1
|
|
|
|
+ }
|
|
if coll != "" { //指定表
|
|
if coll != "" { //指定表
|
|
util.Coll = coll
|
|
util.Coll = coll
|
|
}
|
|
}
|
|
@@ -128,24 +135,29 @@ func (i *Front) ListInfo() error {
|
|
if field == "" {
|
|
if field == "" {
|
|
field = "-1"
|
|
field = "-1"
|
|
}
|
|
}
|
|
- listData := getListInfo(spidercode, stype, field)
|
|
|
|
- if len(listData) > 0 { //每次查询更新内存中标注数据
|
|
|
|
- IdList = list.New()
|
|
|
|
- for _, v := range listData {
|
|
|
|
- IdList.PushBack(mgo.BsonIdToSId(v["_id"]))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ listData := getListInfo(spidercode, stype, field, pagenum)
|
|
|
|
+ //if len(listData) > 0 { //每次查询更新内存中标注数据
|
|
|
|
+ // IdList = list.New()
|
|
|
|
+ // for _, v := range listData {
|
|
|
|
+ // IdList.PushBack(mgo.BsonIdToSId(v["_id"]))
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
i.T["list"] = listData
|
|
i.T["list"] = listData
|
|
i.T["type"] = stype
|
|
i.T["type"] = stype
|
|
i.T["field"] = field
|
|
i.T["field"] = field
|
|
i.T["spidercode"] = spidercode
|
|
i.T["spidercode"] = spidercode
|
|
i.T["coll"] = coll
|
|
i.T["coll"] = coll
|
|
i.T["topsubtype"] = util.TopSubStypeArr
|
|
i.T["topsubtype"] = util.TopSubStypeArr
|
|
- i.T["allfield"] = util.AllField
|
|
|
|
|
|
+ i.T["allfield"] = util.AllFieldArr
|
|
i.T["fromtable"] = util.Coll
|
|
i.T["fromtable"] = util.Coll
|
|
i.T["dbname"] = util.Config.Dbname
|
|
i.T["dbname"] = util.Config.Dbname
|
|
i.T["max"] = Max
|
|
i.T["max"] = Max
|
|
i.T["min"] = Min
|
|
i.T["min"] = Min
|
|
|
|
+ i.T["hasno"] = HasNo
|
|
|
|
+ checkedNum, allNum := GetCheckedAndAllDataInfo() //已标和总数信息
|
|
|
|
+ i.T["checkednum"] = checkedNum
|
|
|
|
+ i.T["allnum"] = allNum
|
|
|
|
+ i.T["pagenum"] = pagenum
|
|
return i.Render("list.html", &i.T)
|
|
return i.Render("list.html", &i.T)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -170,6 +182,7 @@ func (i *Front) Biaozhu() error {
|
|
//ispackage := i.GetString("ispackage")
|
|
//ispackage := i.GetString("ispackage")
|
|
key := i.GetString("key")
|
|
key := i.GetString("key")
|
|
_id := i.GetString("_id")
|
|
_id := i.GetString("_id")
|
|
|
|
+ stype, _ := i.GetInteger("stype")
|
|
err := json.Unmarshal([]byte(key), &obj)
|
|
err := json.Unmarshal([]byte(key), &obj)
|
|
if err != nil {
|
|
if err != nil {
|
|
i.ServeJson(b)
|
|
i.ServeJson(b)
|
|
@@ -233,9 +246,61 @@ func (i *Front) Biaozhu() error {
|
|
// qu.Debug("errset---", errset)
|
|
// qu.Debug("errset---", errset)
|
|
// qu.Debug("set---", set)
|
|
// qu.Debug("set---", set)
|
|
// qu.Debug("unset---", unset)
|
|
// qu.Debug("unset---", unset)
|
|
|
|
+ unerrset := map[string]interface{}{} //记录errdata错误信息表删除
|
|
|
|
+ data, _ := util.MgoM.FindById(util.Coll, _id, nil)
|
|
|
|
+ //标注误操作处理
|
|
|
|
+ if len(set) > 0 { //set中为本次标注保存的数据(ck_bidopentime:1;ck_buyer:2;buyer:"XXX")
|
|
|
|
+ for s, sv := range set {
|
|
|
|
+ //区分是标记字段,还是普通字段(标记字段:ck_buyer;普通字段:buyer)
|
|
|
|
+ if strings.HasPrefix(s, preKey) { //标记字段
|
|
|
|
+ status := qu.IntAll(sv)
|
|
|
|
+ field := s[3:] //去除前缀,获得字段
|
|
|
|
+ if s == preKey+"package" || s == preKey+"purchasinglist" || s == preKey+"winnerorder" {
|
|
|
|
+ if (*data)[s] != nil { //package、purchasinglist、winnerorder已标注,不再修改
|
|
|
|
+ delete(set, s)
|
|
|
|
+ delete(set, field)
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if set[field] == nil && status != 4 { //表示该字段没有要修改的值,此时标记为1或4(亦或是ck_wodrisext;ck_pkgisext;ck_pclisext)
|
|
|
|
+ continue
|
|
|
|
+ } else { //此时有修改的值和标记2、3、4
|
|
|
|
+ if checkedStatus := qu.IntAll((*data)[s]); checkedStatus != 0 { //已有标注信息的状态
|
|
|
|
+ if status == 2 && checkedStatus == 4 { //4>2,errdata删除,marked新增该字段,标记变为1
|
|
|
|
+ unerrset[field] = ""
|
|
|
|
+ set[s] = 1
|
|
|
|
+ } else if status == 3 {
|
|
|
|
+ if checkedStatus == 2 { //2>3,marked 修改该字段,标记变为2
|
|
|
|
+ set[s] = 2
|
|
|
|
+ } else if checkedStatus == 3 { //3>3,对比errdata错误值:相等变为1,errdata删除;不等变为3,marked修改该字段
|
|
|
|
+ errdata, _ := util.MgoM.FindById(util.Config.Totablel, _id, `{"`+field+`":1}`)
|
|
|
|
+ if errdata != nil && len(*errdata) != 0 {
|
|
|
|
+ errText := fmt.Sprint((*errdata)[field])
|
|
|
|
+ text := fmt.Sprint(set[field])
|
|
|
|
+ if errText == text {
|
|
|
|
+ set[s] = 1
|
|
|
|
+ unerrset[field] = ""
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if status == 4 {
|
|
|
|
+ if checkedStatus == 2 { //2>4,errdata删除,marked删除该字段,标记变为1
|
|
|
|
+ unerrset[field] = ""
|
|
|
|
+ set[s] = 1
|
|
|
|
+ unset[field] = ""
|
|
|
|
+ } else if checkedStatus == 3 { //3>4,marked删除该字段,标记变为4
|
|
|
|
+ set[s] = 4
|
|
|
|
+ unset[field] = ""
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//存储原错误信息
|
|
//存储原错误信息
|
|
|
|
+ errUpdata := map[string]interface{}{}
|
|
if len(errset) > 0 {
|
|
if len(errset) > 0 {
|
|
- data, _ := util.MgoM.FindById(util.Coll, _id, nil)
|
|
|
|
for f, v := range errset {
|
|
for f, v := range errset {
|
|
if (*data)[preKey+f] != nil { //已标注保存过不再记录错误信息
|
|
if (*data)[preKey+f] != nil { //已标注保存过不再记录错误信息
|
|
delete(errset, f)
|
|
delete(errset, f)
|
|
@@ -279,35 +344,52 @@ func (i *Front) Biaozhu() error {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(errset) > 0 {
|
|
if len(errset) > 0 {
|
|
- util.MgoM.Update(util.Config.Totablel, `{"_id":"`+_id+`"}`, map[string]interface{}{"$set": errset}, true, false)
|
|
|
|
|
|
+ //qu.Debug("errset---", errset)
|
|
|
|
+ errUpdata["$set"] = errset
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if len(unerrset) > 0 {
|
|
|
|
+ //qu.Debug("unerrset---", unerrset)
|
|
|
|
+ errUpdata["$unset"] = unerrset
|
|
|
|
+ }
|
|
|
|
+ if len(errUpdata) > 0 {
|
|
|
|
+ util.MgoM.Update(util.Config.Totablel, `{"_id":"`+_id+`"}`, errUpdata, true, false)
|
|
|
|
+ }
|
|
|
|
+ //qu.Debug("set---", set)
|
|
//更新正确信息
|
|
//更新正确信息
|
|
update := map[string]interface{}{}
|
|
update := map[string]interface{}{}
|
|
if len(set) > 0 {
|
|
if len(set) > 0 {
|
|
|
|
+ set["ck_data"] = stype
|
|
update["$set"] = set
|
|
update["$set"] = set
|
|
}
|
|
}
|
|
if len(unset) > 0 {
|
|
if len(unset) > 0 {
|
|
update["$unset"] = unset
|
|
update["$unset"] = unset
|
|
}
|
|
}
|
|
- b = util.MgoM.Update(util.Coll, `{"_id":"`+_id+`"}`, update, false, false)
|
|
|
|
- if b {
|
|
|
|
- for e := IdList.Front(); e != nil; e = e.Next() { //遍历IdList,删除元素
|
|
|
|
- if _id == qu.ObjToString(e.Value) {
|
|
|
|
- IdList.Remove(e)
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if util.Coll != util.Config.Fromtable && isSaveMarked { //util.coll此时的标注表 util.Config.Fromtable默认标注表
|
|
|
|
- data, _ := util.MgoM.FindById(util.Coll, _id, nil)
|
|
|
|
- if data != nil && len(*data) > 0 {
|
|
|
|
- if !util.MgoM.Update(util.Config.Fromtable, map[string]interface{}{"_id": (*data)["_id"]}, map[string]interface{}{"$set": *data}, true, false) {
|
|
|
|
- qu.Debug("同步marked失败,", _id)
|
|
|
|
|
|
+ if len(update) > 0 {
|
|
|
|
+ b = util.MgoM.Update(util.Coll, `{"_id":"`+_id+`"}`, update, false, false)
|
|
|
|
+ if b {
|
|
|
|
+ //for e := IdList.Front(); e != nil; e = e.Next() { //遍历IdList,删除元素
|
|
|
|
+ // if _id == qu.ObjToString(e.Value) {
|
|
|
|
+ // IdList.Remove(e)
|
|
|
|
+ // break
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ if util.Coll != util.Config.Fromtable && isSaveMarked { //util.coll此时的标注表 util.Config.Fromtable默认标注表
|
|
|
|
+ data, _ := util.MgoM.FindById(util.Coll, _id, nil)
|
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
|
+ update := map[string]interface{}{"$set": *data}
|
|
|
|
+ if len(unset) > 0 {
|
|
|
|
+ update["$unset"] = unset
|
|
|
|
+ }
|
|
|
|
+ if !util.MgoM.Update(util.Config.Fromtable, map[string]interface{}{"_id": (*data)["_id"]}, update, true, false) {
|
|
|
|
+ qu.Debug("同步marked失败,", _id)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ i.ServeJson(b)
|
|
}
|
|
}
|
|
- i.ServeJson(b)
|
|
|
|
|
|
+
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
@@ -320,9 +402,9 @@ func (i *Front) Detail(id string) error {
|
|
i.T["worder"] = rep["worder"]
|
|
i.T["worder"] = rep["worder"]
|
|
i.T["packs"] = rep["packs"]
|
|
i.T["packs"] = rep["packs"]
|
|
i.T["packskey"] = rep["packskey"]
|
|
i.T["packskey"] = rep["packskey"]
|
|
- i.T["pcl_isext"] = rep["pcl_isext"]
|
|
|
|
- i.T["wodr_isext"] = rep["wodr_isext"]
|
|
|
|
- i.T["pkg_isext"] = rep["pkg_isext"]
|
|
|
|
|
|
+ i.T["ck_pclisext"] = rep["ck_pclisext"]
|
|
|
|
+ i.T["ck_wodrisext"] = rep["ck_wodrisext"]
|
|
|
|
+ i.T["ck_pkgisext"] = rep["ck_pkgisext"]
|
|
i.T["timeplace"] = rep["timeplace"]
|
|
i.T["timeplace"] = rep["timeplace"]
|
|
i.T["purchasinglist"] = rep["purchasinglist"]
|
|
i.T["purchasinglist"] = rep["purchasinglist"]
|
|
i.T["other"] = rep["other"]
|
|
i.T["other"] = rep["other"]
|
|
@@ -335,17 +417,23 @@ func (i *Front) Detail(id string) error {
|
|
i.T["worder_new"] = rep["worder_new"]
|
|
i.T["worder_new"] = rep["worder_new"]
|
|
i.T["pcl_new"] = rep["pcl_new"]
|
|
i.T["pcl_new"] = rep["pcl_new"]
|
|
i.T["pkg_new"] = rep["pkg_new"]
|
|
i.T["pkg_new"] = rep["pkg_new"]
|
|
|
|
+ i.T["nextid"] = GetNextDataId(id) //下一条id
|
|
|
|
+ checkedNum, allNum := GetCheckedAndAllDataInfo() //已标和总数信息
|
|
|
|
+ i.T["checkednum"] = checkedNum
|
|
|
|
+ i.T["allnum"] = allNum
|
|
return i.Render("detail.html", &i.T)
|
|
return i.Render("detail.html", &i.T)
|
|
}
|
|
}
|
|
|
|
|
|
//通过excel表格导入
|
|
//通过excel表格导入
|
|
func (i *Front) ImportByExcel() {
|
|
func (i *Front) ImportByExcel() {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
- success := false
|
|
|
|
|
|
+ //success := false
|
|
msg := ""
|
|
msg := ""
|
|
|
|
+ importNum := 0
|
|
|
|
+ successNum := int64(0)
|
|
coll := i.GetString("excelcoll")
|
|
coll := i.GetString("excelcoll")
|
|
if coll == "" {
|
|
if coll == "" {
|
|
- i.ServeJson(map[string]interface{}{"success": success, "msg": "表名错误"})
|
|
|
|
|
|
+ i.ServeJson(map[string]interface{}{"msg": "表名错误"})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
mf, _, err := i.GetFile("xlsx")
|
|
mf, _, err := i.GetFile("xlsx")
|
|
@@ -356,28 +444,46 @@ func (i *Front) ImportByExcel() {
|
|
rows := sheet.Rows
|
|
rows := sheet.Rows
|
|
idcolnum := -1
|
|
idcolnum := -1
|
|
ids := []string{}
|
|
ids := []string{}
|
|
- for i, row := range rows {
|
|
|
|
- if i == 0 {
|
|
|
|
|
|
+ cellFieldName := map[int]string{} //记录客户需求字段所在的列
|
|
|
|
+ tmpMap := map[string]map[string]interface{}{} //excel表中需要保存字段集合
|
|
|
|
+ for rn, row := range rows {
|
|
|
|
+ if rn == 0 {
|
|
for j, cell := range row.Cells {
|
|
for j, cell := range row.Cells {
|
|
- if cell.Value == "唯一标识" {
|
|
|
|
|
|
+ val := cell.Value
|
|
|
|
+ if fieldName := util.Config.CustomerField[val]; fieldName != "" { //客户需求字段
|
|
|
|
+ cellFieldName[j] = fieldName
|
|
|
|
+ }
|
|
|
|
+ if val == "唯一标识" || val == "信息标识" { //id所在列
|
|
idcolnum = j
|
|
idcolnum = j
|
|
- break
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if idcolnum == -1 {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- if idcolnum == -1 {
|
|
|
|
- success = false
|
|
|
|
|
|
+ if len(row.Cells) != len(rows[0].Cells) {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ tmp := map[string]interface{}{}
|
|
|
|
+ for j, f := range cellFieldName {
|
|
|
|
+ tmp[f] = row.Cells[j].Value
|
|
|
|
+ }
|
|
|
|
+ id := row.Cells[idcolnum].String() //加密的id
|
|
|
|
+ if id == "" {
|
|
break
|
|
break
|
|
}
|
|
}
|
|
- id := row.Cells[idcolnum].String()
|
|
|
|
- ids = append(ids, SE.DecodeString(id))
|
|
|
|
|
|
+ id = SE.DecodeString(id) //解密后id
|
|
|
|
+ tmpMap[id] = tmp
|
|
|
|
+ ids = append(ids, id)
|
|
}
|
|
}
|
|
- if len(ids) > 0 {
|
|
|
|
- success, msg = GetDataById(coll, ids, "excel")
|
|
|
|
|
|
+ importNum = len(ids) //excel表数据个数
|
|
|
|
+ if importNum > 0 {
|
|
|
|
+ _, msg, successNum = GetDataById(coll, ids, "excel", tmpMap)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- i.ServeJson(map[string]interface{}{"success": success, "msg": msg})
|
|
|
|
|
|
+ msg = fmt.Sprintf("共查询%d条,导入成功%d条\n", importNum, successNum) + msg
|
|
|
|
+ i.ServeJson(map[string]interface{}{"msg": msg})
|
|
}
|
|
}
|
|
|
|
|
|
func (i *Front) GetEsCount() {
|
|
func (i *Front) GetEsCount() {
|
|
@@ -397,12 +503,13 @@ func (i *Front) GetEsCount() {
|
|
//通过es语句导入
|
|
//通过es语句导入
|
|
func (i *Front) ImportByEs() {
|
|
func (i *Front) ImportByEs() {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
- success := false
|
|
|
|
|
|
+ //success := false
|
|
msg := ""
|
|
msg := ""
|
|
|
|
+ successNum := int64(0)
|
|
estext := i.GetString("estext") //es查询语句
|
|
estext := i.GetString("estext") //es查询语句
|
|
coll := i.GetString("coll") //导入表
|
|
coll := i.GetString("coll") //导入表
|
|
if coll == "" {
|
|
if coll == "" {
|
|
- i.ServeJson(map[string]interface{}{"success": success, "msg": "表名错误"})
|
|
|
|
|
|
+ i.ServeJson(map[string]interface{}{"msg": "表名错误"})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
client := util.Es.GetEsConn()
|
|
client := util.Es.GetEsConn()
|
|
@@ -433,7 +540,6 @@ func (i *Front) ImportByEs() {
|
|
searchResult, err := client.Scroll(util.Index).Size(200).ScrollId(scrollId).Do() //查询
|
|
searchResult, err := client.Scroll(util.Index).Size(200).ScrollId(scrollId).Do() //查询
|
|
if err != nil {
|
|
if err != nil {
|
|
if err.Error() == "EOS" { //迭代完毕
|
|
if err.Error() == "EOS" { //迭代完毕
|
|
- success = true
|
|
|
|
qu.Debug("Es Search Data Over:", err)
|
|
qu.Debug("Es Search Data Over:", err)
|
|
} else {
|
|
} else {
|
|
qu.Debug("Es Search Data Error:", err)
|
|
qu.Debug("Es Search Data Error:", err)
|
|
@@ -473,15 +579,15 @@ func (i *Front) ImportByEs() {
|
|
}
|
|
}
|
|
//判断数量
|
|
//判断数量
|
|
if int64(len(ids)) != escount {
|
|
if int64(len(ids)) != escount {
|
|
- success = false
|
|
|
|
msg = "查询数据和结果不一致"
|
|
msg = "查询数据和结果不一致"
|
|
} else { //入库
|
|
} else { //入库
|
|
- success, msg = GetDataById(coll, ids, "es")
|
|
|
|
|
|
+ _, msg, successNum = GetDataById(coll, ids, "es", map[string]map[string]interface{}{})
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
msg = "无查询数据"
|
|
msg = "无查询数据"
|
|
}
|
|
}
|
|
- i.ServeJson(map[string]interface{}{"success": success, "msg": msg})
|
|
|
|
|
|
+ msg = fmt.Sprintf("共查询%d条,导入成功%d条\n", escount, successNum) + msg
|
|
|
|
+ i.ServeJson(map[string]interface{}{"msg": msg})
|
|
}
|
|
}
|
|
|
|
|
|
//统计抽查
|
|
//统计抽查
|
|
@@ -543,21 +649,32 @@ func (i *Front) Tj() error {
|
|
return i.Render("tj.html", &i.T)
|
|
return i.Render("tj.html", &i.T)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//标注完成
|
|
|
|
+func (i *Front) FinishCheck() {
|
|
|
|
+ i.Render("finish.html")
|
|
|
|
+}
|
|
|
|
+
|
|
//查询列表数据
|
|
//查询列表数据
|
|
-func getListInfo(spidercode, stype, field string) []map[string]interface{} {
|
|
|
|
- query := map[string]interface{}{}
|
|
|
|
|
|
+func getListInfo(spidercode, stype, field string, currentpage int) []map[string]interface{} {
|
|
|
|
+ QueryFind = map[string]interface{}{}
|
|
if spidercode != "" {
|
|
if spidercode != "" {
|
|
- query["spidercode"] = spidercode
|
|
|
|
|
|
+ QueryFind["spidercode"] = spidercode
|
|
}
|
|
}
|
|
if stype != "-1" && stype != "" {
|
|
if stype != "-1" && stype != "" {
|
|
- subtype := strings.Split(stype, "-")[1]
|
|
|
|
- query["subtype"] = subtype
|
|
|
|
|
|
+ if stype == util.SPECIALTYPE {
|
|
|
|
+ QueryFind["subtype"] = map[string]interface{}{
|
|
|
|
+ "$exists": false,
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ subtype := strings.Split(stype, "-")[1]
|
|
|
|
+ QueryFind["subtype"] = subtype
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if field != "-1" && field != "" {
|
|
if field != "-1" && field != "" {
|
|
- query[field] = map[string]interface{}{
|
|
|
|
- "$exists": true, //字段存在
|
|
|
|
- }
|
|
|
|
- query[preKey+field] = map[string]interface{}{
|
|
|
|
|
|
+ //query[field] = map[string]interface{}{
|
|
|
|
+ // "$exists": true, //字段存在
|
|
|
|
+ //}
|
|
|
|
+ QueryFind[preKey+field] = map[string]interface{}{
|
|
"$exists": false, //field未曾标记
|
|
"$exists": false, //field未曾标记
|
|
}
|
|
}
|
|
if field == "budget" || field == "bidamount" { //金额区间
|
|
if field == "budget" || field == "bidamount" { //金额区间
|
|
@@ -570,32 +687,43 @@ func getListInfo(spidercode, stype, field string) []map[string]interface{} {
|
|
maxint := qu.IntAll(Max)
|
|
maxint := qu.IntAll(Max)
|
|
numMap["$lte"] = maxint
|
|
numMap["$lte"] = maxint
|
|
}
|
|
}
|
|
- if len(numMap) > 0 { //给定了区间,查询此区间或者budget、bidamount不存在的数据
|
|
|
|
- //query[field] = numMap
|
|
|
|
- delete(query, field)
|
|
|
|
- query["$or"] = []interface{}{
|
|
|
|
- map[string]interface{}{
|
|
|
|
- field: map[string]interface{}{
|
|
|
|
- "$exists": false,
|
|
|
|
- },
|
|
|
|
|
|
+ queryArr := []interface{}{}
|
|
|
|
+ if HasNo { //包含field不存在的数据
|
|
|
|
+ queryArr = append(queryArr, map[string]interface{}{
|
|
|
|
+ field: map[string]interface{}{
|
|
|
|
+ "$exists": false,
|
|
},
|
|
},
|
|
- map[string]interface{}{
|
|
|
|
- field: numMap,
|
|
|
|
- },
|
|
|
|
- }
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if len(numMap) > 0 { //给定了区间,查询此区间或者budget、bidamount不存在的数据
|
|
|
|
+ queryArr = append(queryArr, map[string]interface{}{
|
|
|
|
+ field: numMap,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ if len(queryArr) > 0 {
|
|
|
|
+ QueryFind["$or"] = queryArr
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ HasNo = false //当字段不是budget、bidamount时,HasNo改为false,仅作用于页面展示
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- qu.Debug("query:", util.Coll, query)
|
|
|
|
- infoList, _ := util.MgoM.Find(util.Coll, query, nil, `{"_id":1,"title":1,"detail":1,"site":1,"href":1}`, false, 0, 50)
|
|
|
|
|
|
+ qu.Debug("query:", util.Coll, QueryFind)
|
|
|
|
+ start := (currentpage - 1) * 50
|
|
|
|
+ infoList, _ := util.MgoM.Find(util.Coll, QueryFind, `{"_id":1}`, `{"_id":1,"title":1,"detail":1,"site":1,"href":1,"ck_data":1}`, false, start, 50)
|
|
for k, v := range *infoList {
|
|
for k, v := range *infoList {
|
|
|
|
+ ck_data := qu.IntAll(v["ck_data"])
|
|
|
|
+ if ck_data > 0 {
|
|
|
|
+ v["checked"] = true
|
|
|
|
+ } else {
|
|
|
|
+ v["checked"] = false
|
|
|
|
+ }
|
|
href := fmt.Sprint(v["href"])
|
|
href := fmt.Sprint(v["href"])
|
|
if !strings.HasPrefix(href, "http") {
|
|
if !strings.HasPrefix(href, "http") {
|
|
v["href"] = "http://" + href
|
|
v["href"] = "http://" + href
|
|
}
|
|
}
|
|
v["_id"] = mgo.BsonIdToSId(v["_id"])
|
|
v["_id"] = mgo.BsonIdToSId(v["_id"])
|
|
(*infoList)[k] = v
|
|
(*infoList)[k] = v
|
|
|
|
+ v["num"] = k + 1 + start
|
|
}
|
|
}
|
|
return *infoList
|
|
return *infoList
|
|
}
|
|
}
|
|
@@ -611,12 +739,12 @@ func getDetail(id string) map[string]interface{} {
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
info["_id"] = mgo.BsonIdToSId(info["_id"])
|
|
info["_id"] = mgo.BsonIdToSId(info["_id"])
|
|
- pcl_isext, _ := info["pcl_isext"].(bool)
|
|
|
|
- wodr_isext, _ := info["wodr_isext"].(bool)
|
|
|
|
- pkg_isext, _ := info["pkg_isext"].(bool)
|
|
|
|
- rep["pcl_isext"] = pcl_isext
|
|
|
|
- rep["wodr_isext"] = wodr_isext
|
|
|
|
- rep["pkg_isext"] = pkg_isext
|
|
|
|
|
|
+ ck_pclisext, _ := info["ck_pclisext"].(bool)
|
|
|
|
+ ck_wodrisext, _ := info["ck_wodrisext"].(bool)
|
|
|
|
+ ck_pkgisext, _ := info["ck_pkgisext"].(bool)
|
|
|
|
+ rep["ck_pclisext"] = ck_pclisext
|
|
|
|
+ rep["ck_wodrisext"] = ck_wodrisext
|
|
|
|
+ rep["ck_pkgisext"] = ck_pkgisext
|
|
href := qu.ObjToString(info["href"])
|
|
href := qu.ObjToString(info["href"])
|
|
if !strings.HasPrefix(href, "http") {
|
|
if !strings.HasPrefix(href, "http") {
|
|
info["href"] = "http://" + href
|
|
info["href"] = "http://" + href
|
|
@@ -667,7 +795,7 @@ func setWorderMap(info map[string]interface{}) ([]interface{}, []bool) {
|
|
if tmpwds, ok := info["winnerorder"].([]interface{}); ok {
|
|
if tmpwds, ok := info["winnerorder"].([]interface{}); ok {
|
|
for _, v := range tmpwds {
|
|
for _, v := range tmpwds {
|
|
if wd, ok := v.(map[string]interface{}); ok {
|
|
if wd, ok := v.(map[string]interface{}); ok {
|
|
- isNew, _ := wd["isnew"].(bool)
|
|
|
|
|
|
+ isNew, _ := wd["ck_isnew"].(bool)
|
|
isNewWorder = append(isNewWorder, isNew)
|
|
isNewWorder = append(isNewWorder, isNew)
|
|
wds := []interface{}{}
|
|
wds := []interface{}{}
|
|
for _, cp := range winnerorder {
|
|
for _, cp := range winnerorder {
|
|
@@ -699,7 +827,7 @@ func setPurchasingMap(info map[string]interface{}) ([]interface{}, []bool) {
|
|
if tmpcls, ok := info["purchasinglist"].([]interface{}); ok {
|
|
if tmpcls, ok := info["purchasinglist"].([]interface{}); ok {
|
|
for _, v := range tmpcls {
|
|
for _, v := range tmpcls {
|
|
if pcl, ok := v.(map[string]interface{}); ok {
|
|
if pcl, ok := v.(map[string]interface{}); ok {
|
|
- isNew, _ := pcl["isnew"].(bool)
|
|
|
|
|
|
+ isNew, _ := pcl["ck_isnew"].(bool)
|
|
isNewPcl = append(isNewPcl, isNew)
|
|
isNewPcl = append(isNewPcl, isNew)
|
|
pcls := []interface{}{}
|
|
pcls := []interface{}{}
|
|
for _, ps := range purchasinglist {
|
|
for _, ps := range purchasinglist {
|
|
@@ -737,7 +865,7 @@ func setPaceMap(info map[string]interface{}) ([]map[string]interface{}, []string
|
|
if packages, ok := info["package"].(map[string]interface{}); ok && len(packages) > 0 {
|
|
if packages, ok := info["package"].(map[string]interface{}); ok && len(packages) > 0 {
|
|
for k, tmpackage := range packages { //遍历分包
|
|
for k, tmpackage := range packages { //遍历分包
|
|
if tmppack, ok := tmpackage.(map[string]interface{}); ok {
|
|
if tmppack, ok := tmpackage.(map[string]interface{}); ok {
|
|
- isNew, _ := tmppack["isnew"].(bool)
|
|
|
|
|
|
+ isNew, _ := tmppack["ck_isnew"].(bool)
|
|
isNewPkg[k] = isNew
|
|
isNewPkg[k] = isNew
|
|
sortpackskey = append(sortpackskey, k)
|
|
sortpackskey = append(sortpackskey, k)
|
|
pack := []interface{}{}
|
|
pack := []interface{}{}
|
|
@@ -920,15 +1048,20 @@ func BzBDXX(content []interface{}, set, unset, errset map[string]interface{}, is
|
|
if status == -1 {
|
|
if status == -1 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- set["pcl_isext"] = isext //标的信息是否抽取标记
|
|
|
|
|
|
+ set["ck_pclisext"] = isext //标的信息是否抽取标记
|
|
purchasinglist := []interface{}{}
|
|
purchasinglist := []interface{}{}
|
|
errList := []interface{}{}
|
|
errList := []interface{}{}
|
|
|
|
+ delpclson := 0
|
|
for _, con := range content {
|
|
for _, con := range content {
|
|
info, _ := con.(map[string]interface{})
|
|
info, _ := con.(map[string]interface{})
|
|
- isNew, _ := info["isNew"].(bool) //是否是新增子包
|
|
|
|
|
|
+ isNew, _ := info["ck_isnew"].(bool) //是否是新增子包
|
|
|
|
+ pclSonStatus := qu.IntAll(info["status"])
|
|
|
|
+ if pclSonStatus == 4 {
|
|
|
|
+ delpclson++
|
|
|
|
+ }
|
|
if uInputs, ok := info["uInput"].([]interface{}); ok {
|
|
if uInputs, ok := info["uInput"].([]interface{}); ok {
|
|
result := map[string]interface{}{
|
|
result := map[string]interface{}{
|
|
- "isnew": isNew,
|
|
|
|
|
|
+ "ck_isnew": isNew,
|
|
}
|
|
}
|
|
errResult := map[string]interface{}{}
|
|
errResult := map[string]interface{}{}
|
|
for _, tmp := range uInputs {
|
|
for _, tmp := range uInputs {
|
|
@@ -936,24 +1069,32 @@ func BzBDXX(content []interface{}, set, unset, errset map[string]interface{}, is
|
|
key := qu.ObjToString(tmpMap["key"]) //字段
|
|
key := qu.ObjToString(tmpMap["key"]) //字段
|
|
input := tmpMap["input"] //值
|
|
input := tmpMap["input"] //值
|
|
status := qu.IntAll(tmpMap["status"])
|
|
status := qu.IntAll(tmpMap["status"])
|
|
|
|
+ isNull := false
|
|
if key == "number" || key == "unitprice" || key == "totalprice" {
|
|
if key == "number" || key == "unitprice" || key == "totalprice" {
|
|
- input = qu.Float64All(input)
|
|
|
|
|
|
+ if input != "" { //有值
|
|
|
|
+ isNull = false
|
|
|
|
+ input = qu.Float64All(input)
|
|
|
|
+ } else {
|
|
|
|
+ isNull = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
|
|
|
|
+ result[key] = input
|
|
}
|
|
}
|
|
- result[key] = input
|
|
|
|
result[preKey+key] = status
|
|
result[preKey+key] = status
|
|
if !isNew && (status == 2 || status == 3 || status == 4) {
|
|
if !isNew && (status == 2 || status == 3 || status == 4) {
|
|
errResult[key] = status //记录哪个字段错误
|
|
errResult[key] = status //记录哪个字段错误
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if len(result) > 0 {
|
|
|
|
|
|
+ if len(result) > 0 && pclSonStatus != 4 {
|
|
purchasinglist = append(purchasinglist, result)
|
|
purchasinglist = append(purchasinglist, result)
|
|
}
|
|
}
|
|
errList = append(errList, errResult)
|
|
errList = append(errList, errResult)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
errset["purchasinglist"] = errList
|
|
errset["purchasinglist"] = errList
|
|
- if len(purchasinglist) == len(content) {
|
|
|
|
|
|
+ if len(purchasinglist)+delpclson == len(content) {
|
|
set["purchasinglist"] = purchasinglist
|
|
set["purchasinglist"] = purchasinglist
|
|
set[preKey+"purchasinglist"] = status
|
|
set[preKey+"purchasinglist"] = status
|
|
}
|
|
}
|
|
@@ -965,21 +1106,26 @@ func BzDBXX(content []interface{}, set, unset, errset map[string]interface{}, is
|
|
if status == -1 {
|
|
if status == -1 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- set["pkg_isext"] = isext //多包是否抽取标记
|
|
|
|
|
|
+ set["ck_pkgisext"] = isext //多包是否抽取标记
|
|
pkgs := map[string]interface{}{}
|
|
pkgs := map[string]interface{}{}
|
|
errMap := map[string]interface{}{}
|
|
errMap := map[string]interface{}{}
|
|
newNum := 1
|
|
newNum := 1
|
|
|
|
+ delpkgson := 0 //记录子包删除个数
|
|
for _, con := range content {
|
|
for _, con := range content {
|
|
info, _ := con.(map[string]interface{})
|
|
info, _ := con.(map[string]interface{})
|
|
- num := qu.ObjToString(info["num"]) //包号
|
|
|
|
- isNew, _ := info["isNew"].(bool) //是否是新增子包
|
|
|
|
- if isNew { //新增子包新建包名
|
|
|
|
|
|
+ pkgSonStatus := qu.IntAll(info["status"])
|
|
|
|
+ if pkgSonStatus == 4 {
|
|
|
|
+ delpkgson++
|
|
|
|
+ }
|
|
|
|
+ num := fmt.Sprint(info["num"]) //包号
|
|
|
|
+ isNew, _ := info["ck_isnew"].(bool) //是否是新增子包
|
|
|
|
+ if isNew { //新增子包新建包名
|
|
num = "new" + fmt.Sprint(newNum)
|
|
num = "new" + fmt.Sprint(newNum)
|
|
newNum++
|
|
newNum++
|
|
}
|
|
}
|
|
if uInputs, ok := info["uInput"].([]interface{}); ok {
|
|
if uInputs, ok := info["uInput"].([]interface{}); ok {
|
|
result := map[string]interface{}{
|
|
result := map[string]interface{}{
|
|
- "isnew": isNew,
|
|
|
|
|
|
+ "ck_isnew": isNew,
|
|
}
|
|
}
|
|
errResult := map[string]interface{}{}
|
|
errResult := map[string]interface{}{}
|
|
for _, tmp := range uInputs {
|
|
for _, tmp := range uInputs {
|
|
@@ -987,10 +1133,18 @@ func BzDBXX(content []interface{}, set, unset, errset map[string]interface{}, is
|
|
key := qu.ObjToString(tmpMap["key"]) //字段
|
|
key := qu.ObjToString(tmpMap["key"]) //字段
|
|
input := tmpMap["input"] //值
|
|
input := tmpMap["input"] //值
|
|
status := qu.IntAll(tmpMap["status"])
|
|
status := qu.IntAll(tmpMap["status"])
|
|
|
|
+ isNull := false
|
|
if key == "bidamount" || key == "budget" {
|
|
if key == "bidamount" || key == "budget" {
|
|
- input = qu.Float64All(input)
|
|
|
|
|
|
+ if input != "" { //有值
|
|
|
|
+ isNull = false
|
|
|
|
+ input = qu.Float64All(input)
|
|
|
|
+ } else {
|
|
|
|
+ isNull = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
|
|
|
|
+ result[key] = input
|
|
}
|
|
}
|
|
- result[key] = input
|
|
|
|
result[preKey+key] = status
|
|
result[preKey+key] = status
|
|
if !isNew && (status == 2 || status == 3 || status == 4) {
|
|
if !isNew && (status == 2 || status == 3 || status == 4) {
|
|
errResult[key] = status //记录哪个字段错误
|
|
errResult[key] = status //记录哪个字段错误
|
|
@@ -1000,7 +1154,7 @@ func BzDBXX(content []interface{}, set, unset, errset map[string]interface{}, is
|
|
if len(errResult) > 0 {
|
|
if len(errResult) > 0 {
|
|
errMap[num] = errResult
|
|
errMap[num] = errResult
|
|
}
|
|
}
|
|
- if len(result) > 0 {
|
|
|
|
|
|
+ if len(result) > 0 && pkgSonStatus != 4 { //要删除的子包不再保存
|
|
pkgs[num] = result
|
|
pkgs[num] = result
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1008,7 +1162,7 @@ func BzDBXX(content []interface{}, set, unset, errset map[string]interface{}, is
|
|
if len(errMap) > 0 {
|
|
if len(errMap) > 0 {
|
|
errset["package"] = errMap
|
|
errset["package"] = errMap
|
|
}
|
|
}
|
|
- if len(pkgs) == len(content) {
|
|
|
|
|
|
+ if len(pkgs)+delpkgson == len(content) {
|
|
set["package"] = pkgs
|
|
set["package"] = pkgs
|
|
set[preKey+"package"] = status
|
|
set[preKey+"package"] = status
|
|
}
|
|
}
|
|
@@ -1022,15 +1176,20 @@ func BzZBHXRXX(content []interface{}, set, unset, errset map[string]interface{},
|
|
if status == -1 {
|
|
if status == -1 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- set["wodr_isext"] = isext //中标候选人是否抽取标记
|
|
|
|
|
|
+ set["ck_wodrisext"] = isext //中标候选人是否抽取标记
|
|
winnerorder := []interface{}{}
|
|
winnerorder := []interface{}{}
|
|
errList := []interface{}{}
|
|
errList := []interface{}{}
|
|
|
|
+ delwodrson := 0
|
|
for _, con := range content {
|
|
for _, con := range content {
|
|
info, _ := con.(map[string]interface{})
|
|
info, _ := con.(map[string]interface{})
|
|
- isNew, _ := info["isNew"].(bool) //是否是新增子包
|
|
|
|
|
|
+ isNew, _ := info["ck_isnew"].(bool) //是否是新增子包
|
|
|
|
+ wodrSonStatus := qu.IntAll(info["status"])
|
|
|
|
+ if wodrSonStatus == 4 {
|
|
|
|
+ delwodrson++
|
|
|
|
+ }
|
|
if uInputs, ok := info["uInput"].([]interface{}); ok {
|
|
if uInputs, ok := info["uInput"].([]interface{}); ok {
|
|
result := map[string]interface{}{
|
|
result := map[string]interface{}{
|
|
- "isnew": isNew,
|
|
|
|
|
|
+ "ck_isnew": isNew,
|
|
}
|
|
}
|
|
errResult := map[string]interface{}{}
|
|
errResult := map[string]interface{}{}
|
|
for _, tmp := range uInputs {
|
|
for _, tmp := range uInputs {
|
|
@@ -1038,24 +1197,32 @@ func BzZBHXRXX(content []interface{}, set, unset, errset map[string]interface{},
|
|
key := qu.ObjToString(tmpMap["key"]) //字段
|
|
key := qu.ObjToString(tmpMap["key"]) //字段
|
|
input := tmpMap["input"] //值
|
|
input := tmpMap["input"] //值
|
|
status := qu.IntAll(tmpMap["status"])
|
|
status := qu.IntAll(tmpMap["status"])
|
|
|
|
+ isNull := false
|
|
if key == "price" {
|
|
if key == "price" {
|
|
- input = qu.Float64All(input)
|
|
|
|
|
|
+ if input != "" { //有值
|
|
|
|
+ isNull = false
|
|
|
|
+ input = qu.Float64All(input)
|
|
|
|
+ } else {
|
|
|
|
+ isNull = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !isNull { //避免数字类型的字段在没有填写值的情况默认给0
|
|
|
|
+ result[key] = input
|
|
}
|
|
}
|
|
- result[key] = input
|
|
|
|
result[preKey+key] = status
|
|
result[preKey+key] = status
|
|
if !isNew && (status == 2 || status == 3 || status == 4) {
|
|
if !isNew && (status == 2 || status == 3 || status == 4) {
|
|
errResult[key] = status //记录哪个字段错误
|
|
errResult[key] = status //记录哪个字段错误
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if len(result) > 0 {
|
|
|
|
|
|
+ if len(result) > 0 && wodrSonStatus != 4 {
|
|
winnerorder = append(winnerorder, result)
|
|
winnerorder = append(winnerorder, result)
|
|
}
|
|
}
|
|
errList = append(errList, errResult)
|
|
errList = append(errList, errResult)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
errset["winnerorder"] = errList
|
|
errset["winnerorder"] = errList
|
|
- if len(winnerorder) == len(content) {
|
|
|
|
|
|
+ if len(winnerorder)+delwodrson == len(content) {
|
|
set["winnerorder"] = winnerorder
|
|
set["winnerorder"] = winnerorder
|
|
set[preKey+"winnerorder"] = status
|
|
set[preKey+"winnerorder"] = status
|
|
}
|
|
}
|
|
@@ -1079,7 +1246,7 @@ func BzQYXX(content []interface{}, set, unset, errset map[string]interface{}) {
|
|
} else if key == "signaturedate" { //
|
|
} else if key == "signaturedate" { //
|
|
inputTmp, _ := time.ParseInLocation(qu.Date_Full_Layout, input.(string), time.Local)
|
|
inputTmp, _ := time.ParseInLocation(qu.Date_Full_Layout, input.(string), time.Local)
|
|
input = inputTmp.Unix()
|
|
input = inputTmp.Unix()
|
|
- } else if key == "bid_bond" || key == "contract_bond" || key == "supervisorrate" || key == "agency_rate" || key == "docamount" || key == "agency_fee" {
|
|
|
|
|
|
+ } else if key == "bid_bond" || key == "contract_bond" || key == "supervisorrate" || key == "agencyrate" || key == "docamount" || key == "agencyfee" {
|
|
input = qu.Float64All(input)
|
|
input = qu.Float64All(input)
|
|
}
|
|
}
|
|
set[key] = input
|
|
set[key] = input
|
|
@@ -1121,13 +1288,14 @@ func mapIntAdd(k, val string, tmp map[string]map[string]int) map[string]map[stri
|
|
}
|
|
}
|
|
|
|
|
|
//通过id查询数据
|
|
//通过id查询数据
|
|
-func GetDataById(coll string, ids []string, stype string) (bool, string) {
|
|
|
|
|
|
+func GetDataById(coll string, ids []string, stype string, tmp map[string]map[string]interface{}) (bool, string, int64) {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
success := true
|
|
success := true
|
|
msg := ""
|
|
msg := ""
|
|
wg := &sync.WaitGroup{}
|
|
wg := &sync.WaitGroup{}
|
|
lock := &sync.Mutex{}
|
|
lock := &sync.Mutex{}
|
|
ch := make(chan bool, 5)
|
|
ch := make(chan bool, 5)
|
|
|
|
+ n := int64(0)
|
|
for i, id := range ids {
|
|
for i, id := range ids {
|
|
wg.Add(1)
|
|
wg.Add(1)
|
|
ch <- true
|
|
ch <- true
|
|
@@ -1138,11 +1306,11 @@ func GetDataById(coll string, ids []string, stype string) (bool, string) {
|
|
}()
|
|
}()
|
|
tmpBidColl := util.BidColl1 //bidding
|
|
tmpBidColl := util.BidColl1 //bidding
|
|
//查询bidding
|
|
//查询bidding
|
|
- if id < "5a862f0640d2d9bbe88e3cec" {
|
|
|
|
|
|
+ if id < util.BIDDINGSTARTID {
|
|
tmpBidColl = util.BidColl2 //bidding_back
|
|
tmpBidColl = util.BidColl2 //bidding_back
|
|
}
|
|
}
|
|
bidData, _ := util.MgoB.FindById(tmpBidColl, id, nil)
|
|
bidData, _ := util.MgoB.FindById(tmpBidColl, id, nil)
|
|
- if bidData != nil && len(*bidData) > 0 {
|
|
|
|
|
|
+ if bidData != nil && len(*bidData) > 0 { //bidding表数据存在
|
|
//查询extract
|
|
//查询extract
|
|
extData, _ := util.MgoE.FindById(util.ExtColl1, id, nil)
|
|
extData, _ := util.MgoE.FindById(util.ExtColl1, id, nil)
|
|
if extData == nil || len(*extData) == 0 {
|
|
if extData == nil || len(*extData) == 0 {
|
|
@@ -1154,41 +1322,113 @@ func GetDataById(coll string, ids []string, stype string) (bool, string) {
|
|
(*bidData)[k] = v
|
|
(*bidData)[k] = v
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- markData, _ := util.MgoM.FindById(coll, id, nil)
|
|
|
|
|
|
+ //对比marked表是否已标注该数据
|
|
|
|
+ markData, _ := util.MgoM.FindById(util.Config.Fromtable, id, nil)
|
|
|
|
+ if markData != nil && len(*markData) > 0 {
|
|
|
|
+ UpdateMarkColl(bidData, markData) //比对更新数据
|
|
|
|
+ } else {
|
|
|
|
+ (*bidData)["ck_data"] = 0 //设置ck_data默认值0
|
|
|
|
+ }
|
|
|
|
+ //合并导入表中客户所需的字段
|
|
|
|
+ if len(tmp) > 0 {
|
|
|
|
+ for k, v := range tmp[id] {
|
|
|
|
+ (*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
|
|
|
|
+ (*bidData)["id"] = id
|
|
//保存数据
|
|
//保存数据
|
|
- if len(*markData) == 0 { //直接保存
|
|
|
|
- qu.Debug("---直接保存---")
|
|
|
|
- util.MgoM.SaveByOriID(coll, bidData)
|
|
|
|
|
|
+ if util.MgoM.SaveByOriID(coll, bidData) {
|
|
|
|
+ atomic.AddInt64(&n, 1) //计数
|
|
} else {
|
|
} else {
|
|
- qu.Debug("---更新---")
|
|
|
|
- UpdateMarkColl(bidData, markData, coll) //比对更新数据
|
|
|
|
|
|
+ lock.Lock()
|
|
|
|
+ *success = false
|
|
|
|
+ if stype == "excel" {
|
|
|
|
+ *msg += "第" + fmt.Sprint(i+2) + "行未查询到数据:" + id + ";\n"
|
|
|
|
+ } else {
|
|
|
|
+ *msg += "未查询到数据:" + id + ";\n"
|
|
|
|
+ }
|
|
|
|
+ lock.Unlock()
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
lock.Lock()
|
|
lock.Lock()
|
|
*success = false
|
|
*success = false
|
|
if stype == "excel" {
|
|
if stype == "excel" {
|
|
- *msg += "第" + fmt.Sprint(i+2) + "行未查询到数据;\n"
|
|
|
|
|
|
+ *msg += "第" + fmt.Sprint(i+2) + "行未查询到数据:" + id + ";\n"
|
|
} else {
|
|
} else {
|
|
- *msg += id + " 未查询到数据;\n"
|
|
|
|
|
|
+ *msg += "未查询到数据:" + id + ";\n"
|
|
}
|
|
}
|
|
lock.Unlock()
|
|
lock.Unlock()
|
|
}
|
|
}
|
|
}(i, id, &success, &msg)
|
|
}(i, id, &success, &msg)
|
|
}
|
|
}
|
|
wg.Wait()
|
|
wg.Wait()
|
|
- return success, msg
|
|
|
|
|
|
+ return success, msg, n
|
|
}
|
|
}
|
|
|
|
|
|
//更新数据
|
|
//更新数据
|
|
-func UpdateMarkColl(bidData, markData *map[string]interface{}, coll string) {
|
|
|
|
|
|
+func UpdateMarkColl(bidData, markData *map[string]interface{}) {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
- set := map[string]interface{}{}
|
|
|
|
- for k, v := range *bidData {
|
|
|
|
- if k != "_id" && (*markData)[preKey+k] == nil { //只更新未标注过的字段
|
|
|
|
- set[k] = v
|
|
|
|
|
|
+ ck_data := qu.IntAll((*markData)["ck_data"])
|
|
|
|
+ if ck_data == 2 { //某些字段已标注
|
|
|
|
+ for fk, fv := range *markData {
|
|
|
|
+ ckFieldArr := strings.Split(fk, preKey)
|
|
|
|
+ if len(ckFieldArr) == 2 {
|
|
|
|
+ field := ckFieldArr[1]
|
|
|
|
+ (*bidData)[fk] = fv //补充标记
|
|
|
|
+ if (*markData)[field] != nil {
|
|
|
|
+ (*bidData)[field] = (*markData)[field] //字段更新
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ (*markData)["ck_data"] = 0 //marked表中该条数据如果为字段验证,临时表ck_data:0;若为数据验证ck_data:1
|
|
}
|
|
}
|
|
- if len(set) > 0 {
|
|
|
|
- util.MgoM.Update(coll, map[string]interface{}{"_id": (*bidData)["_id"]}, map[string]interface{}{"$set": set}, false, false)
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//获取当前数据下一条的id
|
|
|
|
+func GetNextDataId(id string) string {
|
|
|
|
+ nextIdQuery := map[string]interface{}{
|
|
|
|
+ "_id": map[string]interface{}{
|
|
|
|
+ "$gt": mgo.StringTOBsonId(id),
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ for k, v := range QueryFind {
|
|
|
|
+ nextIdQuery[k] = v
|
|
|
|
+ }
|
|
|
|
+ one, _ := util.MgoM.Find(util.Coll, nextIdQuery, `{"_id":1}`, `{"_id":1}`, true, 0, 1)
|
|
|
|
+ if one != nil && len(*one) == 1 {
|
|
|
|
+ return mgo.BsonIdToSId((*one)[0]["_id"])
|
|
|
|
+ }
|
|
|
|
+ return id
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//获取已标注和数据总数的信息
|
|
|
|
+func GetCheckedAndAllDataInfo() (int, int) {
|
|
|
|
+ allCount := util.MgoM.Count(util.Coll, QueryFind)
|
|
|
|
+ ckDataQuery := map[string]interface{}{
|
|
|
|
+ "ck_data": map[string]interface{}{
|
|
|
|
+ "$gt": 0,
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ for k, v := range QueryFind {
|
|
|
|
+ ckDataQuery[k] = v
|
|
}
|
|
}
|
|
|
|
+ checkedCount := util.MgoM.Count(util.Coll, ckDataQuery)
|
|
|
|
+ return checkedCount, allCount
|
|
}
|
|
}
|