|
@@ -95,6 +95,7 @@ func (f *Front) RemarkDetail() {
|
|
|
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
|
|
@@ -136,12 +137,12 @@ func getDetail(id, coll string) map[string]interface{} {
|
|
|
rep["packs"] = packs
|
|
|
rep["packskey"] = packskey
|
|
|
rep["pkg_new"] = pkg_new
|
|
|
- if qu.IntAll((*infoTmp)["i_ckdata"]) == 2 {
|
|
|
- // 首次标注数据不显示标的物信息
|
|
|
- purchasinglist, isNewStatus := setPurchasingMap(baseInfo) //标的物
|
|
|
- rep["purchasinglist"] = purchasinglist
|
|
|
- rep["pcl_new"] = isNewStatus
|
|
|
- }
|
|
|
+ purchasinglist, isNewStatus := setPurchasingMap(baseInfo) //标的物
|
|
|
+ rep["purchasinglist"] = purchasinglist
|
|
|
+ rep["pcl_new"] = isNewStatus
|
|
|
+ purchasinglist_1, isNewStatus1 := setPurchasingMap1(baseInfo) //标的物(采购意向)
|
|
|
+ rep["purchasinglist_1"] = purchasinglist_1
|
|
|
+ rep["pcl_new_1"] = isNewStatus1
|
|
|
worder, worder_new := setWorderMap(baseInfo) //中标候选人
|
|
|
rep["worder"] = worder
|
|
|
rep["worder_new"] = worder_new
|
|
@@ -391,6 +392,49 @@ func setPurchasingMap(info map[string]interface{}) ([]interface{}, []map[string]
|
|
|
return purchasinglists, isNewAndStatus
|
|
|
}
|
|
|
|
|
|
+func setPurchasingMap1(info map[string]interface{}) ([]interface{}, []map[string]interface{}) {
|
|
|
+ purchasinglist, _ := util.BiaoZhu["purchasinglist_1"].([]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 setWorderMap(info map[string]interface{}) ([]interface{}, []map[string]interface{}) {
|
|
|
//基本参数--中标候选人
|
|
@@ -645,6 +689,60 @@ func (f *Front) CheckList() {
|
|
|
}
|
|
|
|
|
|
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
|
|
|
+ }
|
|
|
+ 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")
|
|
@@ -656,8 +754,6 @@ func (f *Front) CheckData() {
|
|
|
start, _ := f.GetInteger("start")
|
|
|
limit, _ := f.GetInteger("length")
|
|
|
draw, _ := f.GetInteger("draw")
|
|
|
- searchStr := f.GetString("search[value]")
|
|
|
- search := strings.TrimSpace(searchStr)
|
|
|
query := make(map[string]interface{})
|
|
|
if tid != "" {
|
|
|
// 任务数据质检
|
|
@@ -689,6 +785,12 @@ func (f *Front) CheckData() {
|
|
|
}
|
|
|
status := f.GetString("s_status")
|
|
|
s_excp := f.GetString("s_excp")
|
|
|
+ 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" {
|
|
@@ -699,16 +801,79 @@ func (f *Front) CheckData() {
|
|
|
} else if s_excp == "-1" {
|
|
|
query["s_excp"] = map[string]interface{}{"$exists": true}
|
|
|
}
|
|
|
- if search != "" {
|
|
|
- query["$or"] = []interface{}{
|
|
|
- map[string]interface{}{"v_baseinfo.title": map[string]interface{}{"$regex": search}},
|
|
|
- map[string]interface{}{"s_login": map[string]interface{}{"$regex": search}},
|
|
|
+ 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}
|
|
|
info, _ := util.Mgo.Find(sourceinfo, query, `{"_id": 1}`, fields, false, start, limit)
|
|
|
- count := util.Mgo.Count(sourceinfo, query)
|
|
|
- qu.Debug(query, sourceinfo, count)
|
|
|
f.ServeJson(map[string]interface{}{
|
|
|
"draw": draw,
|
|
|
"data": *info,
|
|
@@ -770,6 +935,8 @@ func (f *Front) CheckData() {
|
|
|
f.T["sourceinfo"] = sourceinfo
|
|
|
f.T["stype"] = stype
|
|
|
f.T["datatype"] = datatype
|
|
|
+ f.T["topsubtype"] = util.TopSubStypeArr
|
|
|
+ f.T["allfield"] = util.AllFieldArr
|
|
|
_ = f.Render("project/check_data_list.html", &f.T)
|
|
|
}
|
|
|
}
|
|
@@ -808,6 +975,7 @@ func (f *Front) CheckDetail() {
|
|
|
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
|
|
@@ -1271,3 +1439,905 @@ func DataException(tmp map[string]interface{}) (string, string) {
|
|
|
}
|
|
|
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")
|
|
|
+ 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 "多包信息":
|
|
|
+ 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 { //多包
|
|
|
+ MarkPackage(content, tagSet, baseSet, baseUnset, status)
|
|
|
+ } else if j == 4 { //候选人
|
|
|
+ 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] = ""
|
|
|
+ }
|
|
|
+ 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"]) //当前登录用户权限
|
|
|
+
|
|
|
+ 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 "多包信息":
|
|
|
+ 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 { //多包
|
|
|
+ MarkPackage(content, tagSet, baseSet, baseUnset, status)
|
|
|
+ } else if j == 4 { //候选人
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+}
|
|
|
+
|
|
|
+// MarkPurchasinglist 标注标的信息
|
|
|
+func MarkPurchasinglist(content []interface{}, tagSet, baseSet, baseUnset map[string]interface{}, istag bool, status int) {
|
|
|
+ if status == -1 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ baseSet["purchasinglist_alltag"] = istag //标的信息是否标注完全
|
|
|
+ purchasinglist := []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,
|
|
|
+ }
|
|
|
+ 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"])
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ } else {
|
|
|
+ qu.Debug("Purchasinglist 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 //记录子包删除个数
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ } 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")
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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}`, false, -1, -1)
|
|
|
+ var updateArr [][]map[string]interface{}
|
|
|
+ for _, m := range *info {
|
|
|
+ baseinfo := m["v_baseinfo"].(map[string]interface{})
|
|
|
+ purs := baseinfo["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 {
|
|
|
+ qu.Debug(updateArr)
|
|
|
+ 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
|
|
|
+}
|