|
@@ -124,11 +124,26 @@ func (f *Front) ProjectSave() {
|
|
|
}
|
|
|
} else if stype == "coll" { //数据库导入
|
|
|
historyid := f.GetString("s_historyid")
|
|
|
- if historyid == "" {
|
|
|
+ collName := f.GetString("coll")
|
|
|
+ q := f.GetString("s_query")
|
|
|
+ if historyid == "" || collName == "" {
|
|
|
f.ServeJson(map[string]interface{}{"success": false, "msg": "数据导出ID字段"})
|
|
|
return
|
|
|
}
|
|
|
- s_departname, s_entname, s_rulename, importDataNum = ImportDataByColl(historyid, &success, &msg, &successNum)
|
|
|
+ query1 := make(map[string]interface{})
|
|
|
+ if q != "" {
|
|
|
+ if err := json.Unmarshal([]byte(q), &query1); err != nil {
|
|
|
+ qu.Debug("GroupInfo Unmarshal Failed:", err)
|
|
|
+ f.ServeJson(map[string]interface{}{"success": false, "msg": "查询条件有误"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ query1["historyId"] = historyid
|
|
|
+ if c := util.MgoJy.Count(collName, query1); c == 0 {
|
|
|
+ f.ServeJson(map[string]interface{}{"success": false, "msg": "查询数据量为0!"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ s_departname, s_entname, s_rulename, importDataNum = ImportDataByColl(collName, query1, &success, &msg, &successNum)
|
|
|
qu.Debug(s_departname, s_entname, s_rulename, importDataNum)
|
|
|
//保存项目信息
|
|
|
set = map[string]interface{}{
|
|
@@ -167,7 +182,6 @@ func (f *Front) ProjectSave() {
|
|
|
}
|
|
|
if success {
|
|
|
success = util.Mgo.Update(util.PROJECTCOLLNAME, query, map[string]interface{}{"$set": set}, true, false)
|
|
|
- qu.Debug("Save Project:", success)
|
|
|
if !success { //保存项目失败
|
|
|
msg = "新建项目失败\n" + msg
|
|
|
} else {
|
|
@@ -228,11 +242,27 @@ func (f *Front) ProjectAddData() {
|
|
|
}
|
|
|
} else if stype == "coll" {
|
|
|
historyid := f.GetString("s_historyid")
|
|
|
- if historyid == "" {
|
|
|
+ collName := f.GetString("coll")
|
|
|
+ q := f.GetString("s_query")
|
|
|
+ if historyid == "" || collName == "" {
|
|
|
f.ServeJson(map[string]interface{}{"success": false, "msg": "数据导出ID字段"})
|
|
|
return
|
|
|
}
|
|
|
- _, _, _, importDataNum = ImportDataByColl(historyid, &success, &msg, &successNum)
|
|
|
+ query1 := make(map[string]interface{})
|
|
|
+ if q != "" {
|
|
|
+ if err := json.Unmarshal([]byte(q), &query1); err != nil {
|
|
|
+ qu.Debug("GroupInfo Unmarshal Failed:", err)
|
|
|
+ f.ServeJson(map[string]interface{}{"success": false, "msg": "查询条件有误"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ query1["historyId"] = historyid
|
|
|
+ qu.Debug(query1)
|
|
|
+ if c := util.MgoJy.Count(collName, query1); c == 0 {
|
|
|
+ f.ServeJson(map[string]interface{}{"success": false, "msg": "查询数据量为0!"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ _, _, _, importDataNum = ImportDataByColl(collName, query1, &success, &msg, &successNum)
|
|
|
if !success {
|
|
|
f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
|
|
|
return
|
|
@@ -335,8 +365,7 @@ func (f *Front) ProjectQualityAssessment() {
|
|
|
appid := qu.ObjToString((*project)["appid"])
|
|
|
// todo
|
|
|
util.Mgo.Update(util.DATACOLLNAME, bson.M{"appid": appid}, bson.M{"$set": bson.M{"b_istagging": true}}, false, true)
|
|
|
- b := util.Mgo.UpdateById(util.PROJECTCOLLNAME, projectid, map[string]interface{}{"$set": map[string]interface{}{"b_isassessment": true, "s_status": "进行中", "i_starttime": time.Now().Unix()}})
|
|
|
- qu.Debug("Update Porject:"+projectid+" Status Success:", b)
|
|
|
+ util.Mgo.UpdateById(util.PROJECTCOLLNAME, projectid, map[string]interface{}{"$set": map[string]interface{}{"b_isassessment": true, "s_status": "进行中", "i_starttime": time.Now().Unix()}})
|
|
|
success = true
|
|
|
} else if ok && isAssessment {
|
|
|
success = true
|
|
@@ -1023,7 +1052,7 @@ func ImportDataByExcel(mf multipart.File, success *bool, msg *string, successNum
|
|
|
}
|
|
|
|
|
|
// ImportDataByColl 通过表获取数据源
|
|
|
-func ImportDataByColl(historyid string, success *bool, msg *string, successNum *int64) (departname, entname string, rulename []string, importDataNum int) {
|
|
|
+func ImportDataByColl(collName string, query map[string]interface{}, success *bool, msg *string, successNum *int64) (departname, entname string, rulename []string, importDataNum int) {
|
|
|
defer qu.Catch()
|
|
|
rulenameMap := map[string]bool{}
|
|
|
sess := util.MgoJy.GetMgoConn()
|
|
@@ -1032,10 +1061,7 @@ func ImportDataByColl(historyid string, success *bool, msg *string, successNum *
|
|
|
wg := &sync.WaitGroup{}
|
|
|
lock := &sync.Mutex{}
|
|
|
idInfoArr := []util.Data{} //记录数据id及需要保存的字段信息
|
|
|
- query := map[string]interface{}{
|
|
|
- "historyId": historyid,
|
|
|
- }
|
|
|
- it := sess.DB(util.MgoJy.DbName).C(util.JyHistory).Find(&query).Iter()
|
|
|
+ it := sess.DB(util.MgoJy.DbName).C(collName).Find(&query).Iter()
|
|
|
n := 0
|
|
|
for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
|
|
|
ch <- true
|