|
@@ -1,6 +1,7 @@
|
|
|
package front
|
|
|
|
|
|
import (
|
|
|
+ "crons"
|
|
|
"dataValidation/util"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
@@ -10,12 +11,15 @@ import (
|
|
|
"io"
|
|
|
qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
|
|
|
"jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
|
|
|
+ "math"
|
|
|
"os"
|
|
|
+ "qfw/util/redis"
|
|
|
"sort"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
+ "util"
|
|
|
)
|
|
|
|
|
|
// GroupTaskListByGroup 用户组权限用户组任务列表
|
|
@@ -184,7 +188,7 @@ func (f *Front) GroupUserTaskList() {
|
|
|
}
|
|
|
qu.Debug("Query:", query)
|
|
|
count := util.Mgo.Count(util.TASKCOLLNAME, query)
|
|
|
- list, _ := util.Mgo.Find(util.TASKCOLLNAME, query, map[string]interface{}{"_id": -1}, nil, false, int(start), int(limit))
|
|
|
+ list, _ := util.Mgo.Find(util.TASKCOLLNAME, query, map[string]interface{}{"_id": -1}, nil, false, start, limit)
|
|
|
for _, l := range *list {
|
|
|
if status := qu.ObjToString(l["s_status"]); status == "进行中" { //更新任务进度
|
|
|
giveNum := qu.IntAll(l["i_givenum"])
|
|
@@ -336,7 +340,6 @@ func syncJyData(source, tid, pid string) int {
|
|
|
info["isOptimization"] = qu.IntAll(tmp["is_push"])
|
|
|
info["ispanchong"] = 1
|
|
|
info["earliestDay"] = qu.IntAll(tmp["earliestDay"])
|
|
|
- //util.MgoJy.Del(util.JYPushColl, bson.M{"id": info["id"], "isOptimization": info["isOptimization"]})
|
|
|
util.MgoJy.Save(util.JYPushColl, info)
|
|
|
util.Mgo.UpdateById(source, tmp["_id"], bson.M{"$set": bson.M{"sendflag": true}})
|
|
|
|
|
@@ -344,8 +347,9 @@ func syncJyData(source, tid, pid string) int {
|
|
|
tmp = make(map[string]interface{})
|
|
|
}
|
|
|
wg.Wait()
|
|
|
- } else if pid == "676a624edadb2b5c6413bdee" || pid == "676a6230dadb2b5c6413b691" {
|
|
|
- // 江苏联通 招标/中标
|
|
|
+ } else if pid == "676a624edadb2b5c6413bdee" || pid == "676a6230dadb2b5c6413b691" || pid == "676e01bddadb2b5c6470ffa9" ||
|
|
|
+ pid == "677b52bddadb2b5c64c974c5" {
|
|
|
+ // 江苏联通 招标/中标/运营商
|
|
|
q = bson.M{"s_grouptaskid": tid, "is_repeat": 1}
|
|
|
query := sess.DB(util.Mgo.DbName).C(source).Find(q).Select(nil).Iter()
|
|
|
for tmp := make(map[string]interface{}); query.Next(&tmp); count++ {
|
|
@@ -366,6 +370,7 @@ func syncJyData(source, tid, pid string) int {
|
|
|
info["ispanchong"] = 1
|
|
|
info["earliestDay"] = qu.IntAll(tmp["earliestDay"])
|
|
|
//util.MgoJy.Save(util.JYPushColl, info)
|
|
|
+ delete(info, "_id")
|
|
|
util.MgoJy.Save("usermail_tmp_js", info)
|
|
|
util.Mgo.UpdateById(source, tmp["_id"], bson.M{"$set": bson.M{"sendflag": true}})
|
|
|
|
|
@@ -907,6 +912,7 @@ func (f *Front) GroupExportData() {
|
|
|
}
|
|
|
list, _ := util.Mgo.Find(sourceinfo, q, nil, fields, false, -1, -1)
|
|
|
for _, l := range *list {
|
|
|
+ id := util.SE.EncodeString(mongodb.BsonIdToSId(l["_id"]))
|
|
|
baseinfo := l["v_baseinfo"].(map[string]interface{})
|
|
|
if baseinfo["package"] != nil {
|
|
|
pkg := baseinfo["package"].(map[string]interface{})
|
|
@@ -948,10 +954,14 @@ func (f *Front) GroupExportData() {
|
|
|
row.AddCell().SetValue(qu.ObjToString(l["tagname"]))
|
|
|
row.AddCell().SetValue(qu.ObjToString(l["tagname2"]))
|
|
|
row.AddCell().SetValue(qu.ObjToString(baseinfo["is_effective"]))
|
|
|
+ if l["is_repeat"] != nil {
|
|
|
+ row.AddCell().SetValue(l["is_repeat"])
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
row := sheet.AddRow()
|
|
|
- row.AddCell().SetValue(util.SE.EncodeString(qu.ObjToString(l["id"])))
|
|
|
+ row.AddCell().SetValue(id)
|
|
|
row.AddCell().SetValue(qu.ObjToString(baseinfo["s_winner"]))
|
|
|
row.AddCell().SetValue(qu.ObjToString(baseinfo["buyer"]))
|
|
|
row.AddCell().SetValue(qu.ObjToString(baseinfo["projectcode"]))
|
|
@@ -971,6 +981,9 @@ func (f *Front) GroupExportData() {
|
|
|
row.AddCell().SetValue(qu.ObjToString(l["tagname"]))
|
|
|
row.AddCell().SetValue(qu.ObjToString(l["tagname2"]))
|
|
|
row.AddCell().SetValue(qu.ObjToString(baseinfo["is_effective"]))
|
|
|
+ if l["is_repeat"] != nil {
|
|
|
+ row.AddCell().SetValue(l["is_repeat"])
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
fname := fmt.Sprintf(modelpath, time.Now().Unix())
|
|
@@ -1090,7 +1103,7 @@ func (f *Front) GroupImportData() {
|
|
|
if s := qu.ObjToString(baseinfo["s_winner"]); s != "" {
|
|
|
update["v_baseinfo.s_winner"] = s + "," + qu.ObjToString(update["v_baseinfo.s_winner"])
|
|
|
}
|
|
|
- update["v_baseinfo.bidamount"] = qu.Float64All(update["v_baseinfo.bidamount"]) + qu.Float64All(baseinfo["bidamount"])
|
|
|
+ update["v_baseinfo.bidamount"] = math.Round(qu.Float64All(update["v_baseinfo.bidamount"]) + qu.Float64All(baseinfo["bidamount"]))
|
|
|
c1++
|
|
|
}
|
|
|
} else {
|
|
@@ -1238,3 +1251,151 @@ func countFuc(stype, coll, tid, sctype string) (int, int, int) {
|
|
|
}
|
|
|
return size, pCount, cCount
|
|
|
}
|
|
|
+
|
|
|
+func (f *Front) PushRepeatData() {
|
|
|
+ defer qu.Catch()
|
|
|
+ sourceinfo := f.GetString("s_sourceinfo")
|
|
|
+ mf, _, err := f.GetFile("xlsx")
|
|
|
+ if err != nil {
|
|
|
+ f.ServeJson(map[string]interface{}{"success": false, "msg": "数据导入失败"})
|
|
|
+ }
|
|
|
+ binary, _ := io.ReadAll(mf)
|
|
|
+ xls, _ := xlsx.OpenBinary(binary)
|
|
|
+ sheet := xls.Sheets[0]
|
|
|
+ rows := sheet.Rows
|
|
|
+ idcolnum := -1
|
|
|
+ cellFieldName := map[int]string{}
|
|
|
+ count := 0
|
|
|
+ for rn, row := range rows {
|
|
|
+ update := make(map[string]interface{})
|
|
|
+ del := make(map[string]interface{})
|
|
|
+ if rn == 0 {
|
|
|
+ for index, cell := range row.Cells {
|
|
|
+ if cell.Value == "唯一标识" || cell.Value == "信息标识" { //id所在列
|
|
|
+ idcolnum = index
|
|
|
+ }
|
|
|
+ if v := FieldsMap[cell.Value]; v != "" {
|
|
|
+ cellFieldName[index] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if idcolnum == -1 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ } else {
|
|
|
+ id := row.Cells[idcolnum].String()
|
|
|
+ id = util.SE.DecodeString(id)
|
|
|
+ for i, f1 := range cellFieldName {
|
|
|
+ if val := row.Cells[i].Value; val != "" {
|
|
|
+ if f1 == "is_push" || f1 == "is_repeat" || f1 == "earliestDay" {
|
|
|
+ update[f1] = qu.IntAll(val)
|
|
|
+ } else if f1 == "multipackage" {
|
|
|
+ update[fmt.Sprintf("v_baseinfo.%s", f1)] = qu.IntAll(val)
|
|
|
+ } else if f1 == "bidamount" {
|
|
|
+ update[fmt.Sprintf("v_baseinfo.%s", f1)] = qu.Float64All(val)
|
|
|
+ } else {
|
|
|
+ update[fmt.Sprintf("v_baseinfo.%s", f1)] = val
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if f1 != "is_push" {
|
|
|
+ del[fmt.Sprintf("v_baseinfo.%s", f1)] = "1"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(del) > 0 {
|
|
|
+ util.Mgo.UpdateById(sourceinfo, id, bson.M{"$set": update, "$unset": del})
|
|
|
+ } else {
|
|
|
+ util.Mgo.UpdateById(sourceinfo, bson.M{"id": id}, bson.M{"$set": update})
|
|
|
+ }
|
|
|
+
|
|
|
+ tmp, _ := util.Mgo.FindById(sourceinfo, id, nil)
|
|
|
+ if (*tmp)["v_baseinfo"] == nil {
|
|
|
+ qu.Debug("id------", id)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ info := (*tmp)["v_baseinfo"].(map[string]interface{})
|
|
|
+ info["createtime"] = time.Now().Unix()
|
|
|
+ if qu.ObjToString(info["id"]) == "" {
|
|
|
+ info["id"] = id
|
|
|
+ }
|
|
|
+ delete(info, "_id")
|
|
|
+ info["isOptimization"] = qu.IntAll((*tmp)["is_push"])
|
|
|
+ info["ispanchong"] = 1
|
|
|
+ info["earliestDay"] = qu.IntAll((*tmp)["earliestDay"])
|
|
|
+ util.MgoJy.Save("usermail_tmp_js", info)
|
|
|
+ count++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ f.ServeJson(map[string]interface{}{"success": true, "msg": "数据导入成功", "count": count})
|
|
|
+}
|
|
|
+
|
|
|
+func (f *Front) RepeatData() {
|
|
|
+ sourceinfo := f.GetString("s_sourceinfo")
|
|
|
+ groupTaskId := f.GetString("taskid")
|
|
|
+ sess := util.Mgo.GetMgoConn()
|
|
|
+ defer util.Mgo.DestoryMongoConn(sess)
|
|
|
+
|
|
|
+ if crons.Processing {
|
|
|
+ f.ServeJson(map[string]interface{}{"success": false, "msg": "定时任务保存数据中,请稍后执行"})
|
|
|
+ } else {
|
|
|
+ crons.RepeatData()
|
|
|
+ ch := make(chan bool, 5)
|
|
|
+ wg := &sync.WaitGroup{}
|
|
|
+ q := bson.M{"s_grouptaskid": groupTaskId}
|
|
|
+ count := 0
|
|
|
+ query := sess.DB(util.Mgo.DbName).C(sourceinfo).Find(q).Select(nil).Iter()
|
|
|
+ for tmp := make(map[string]interface{}); query.Next(&tmp); count++ {
|
|
|
+ ch <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
+ defer func() {
|
|
|
+ <-ch
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ if getRepeat(tmp) {
|
|
|
+ util.Mgo.UpdateById(sourceinfo, tmp["_id"], bson.M{"$set": bson.M{"is_repeat": 0}})
|
|
|
+ }
|
|
|
+ }(tmp)
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+ f.ServeJson(map[string]interface{}{"success": true, "msg": "数据判重结束"})
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func getRepeat(tmp map[string]interface{}) bool {
|
|
|
+ subtype := qu.ObjToString(tmp["subtype"])
|
|
|
+ pname := qu.ObjToString(tmp["projectname"])
|
|
|
+ pcode := qu.ObjToString(tmp["projectcode"])
|
|
|
+ city := qu.ObjToString(tmp["city"])
|
|
|
+ budget := qu.Float64All(tmp["budget"])
|
|
|
+ bidamount := qu.Float64All(tmp["bidamount"])
|
|
|
+ buyer := qu.ObjToString(tmp["buyer"])
|
|
|
+ winner := qu.ObjToString(tmp["s_winner"])
|
|
|
+
|
|
|
+ key := ""
|
|
|
+ if subtype == "采购意向" {
|
|
|
+ key = fmt.Sprintf(crons.CgKey, subtype, pname, budget, buyer)
|
|
|
+ } else if strings.Contains("招标、邀标、竞价、竞谈、询价", subtype) {
|
|
|
+ key = fmt.Sprintf(crons.ZbKey, subtype, city, pname, budget, buyer)
|
|
|
+ } else if strings.Contains("中标、成交、单一", subtype) {
|
|
|
+ title := qu.ObjToString(tmp["title"])
|
|
|
+ for _, vv := range crons.ItemArr {
|
|
|
+ if strings.Contains(title, vv) {
|
|
|
+ crons.ItemOk = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if crons.ItemOk {
|
|
|
+ key = fmt.Sprintf(crons.ZgbKey, "候选人公式", city, pname, bidamount, pcode, winner, buyer)
|
|
|
+ } else {
|
|
|
+ key = fmt.Sprintf(crons.ZgbKey, "中标通知", city, pname, bidamount, pcode, winner, buyer)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if redis.Get("repeat", key) != nil {
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+}
|