maxiaoshan 3 vuotta sitten
vanhempi
commit
0c379a18d6
3 muutettua tiedostoa jossa 43 lisäystä ja 38 poistoa
  1. 7 2
      src/front/group.go
  2. 36 36
      src/front/quality.go
  3. BIN
      src/web/model/taskexportmodel.xlsx

+ 7 - 2
src/front/group.go

@@ -167,10 +167,11 @@ func (f *Front) GroupTaskExport() {
 			"$lte": completetime,
 		}
 	}
+	query = map[string]interface{}{}
 	qu.Debug("Query:", query)
 	count := util.Mgo.Count(util.TASKCOLLNAME, query)
 	if count > 0 {
-		file, err := xlsx.OpenFile("taskexportmodel.xlsx")
+		file, err := xlsx.OpenFile("web/model/taskexportmodel.xlsx")
 		if err != nil {
 			qu.Debug("Load Excel Model Error")
 			f.ServeJson("加载脚本失败")
@@ -198,6 +199,7 @@ func (f *Front) GroupTaskExport() {
 			groupname := qu.ObjToString(l["s_groupname"])
 			personname := qu.ObjToString(l["s_personname"])
 			givenum := qu.IntAll(l["i_givenum"])
+			status := qu.ObjToString(l["s_status"])
 			starttimestr := ""
 			if starttime := qu.Int64All(l["i_starttime"]); starttime != 0 {
 				starttimestr = qu.FormatDateByInt64(&starttime, qu.Date_Full_Layout)
@@ -213,6 +215,7 @@ func (f *Front) GroupTaskExport() {
 			row.AddCell().SetValue(groupname)
 			row.AddCell().SetValue(personname)
 			row.AddCell().SetValue(givenum)
+			row.AddCell().SetValue(status)
 			row.AddCell().SetValue(starttimestr)
 			row.AddCell().SetValue(completetimestr)
 		}
@@ -224,9 +227,11 @@ func (f *Front) GroupTaskExport() {
 			f.ServeJson("导出失败")
 			return
 		}
+		arr := strings.Split(fname, "/")
+		f.ResponseWriter.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", arr[len(arr)-1]))
 		f.ServeFile(fname)
 		go func(path string) {
-			time.Sleep(time.Minute * 10)
+			time.Sleep(time.Second * 30)
 			os.Remove(path)
 		}(fname)
 	} else {

+ 36 - 36
src/front/quality.go

@@ -8,11 +8,12 @@ import (
 	"time"
 	u "util"
 )
+
 func (f *Front) QuaScoreData() {
 	defer qu.Catch()
 	coll_name := f.GetString("coll_name")
 	field_tag := f.GetSlice("field_tag")
-	rep := QuaFieldScore(field_tag,coll_name)
+	rep := QuaFieldScore(field_tag, coll_name)
 	f.ServeJson(map[string]interface{}{
 		"rep": rep,
 	})
@@ -27,7 +28,7 @@ func QuaFieldScore(field_tag []string, coll_name string) bool {
 	sess := u.Mgo.GetMgoConn()
 	defer u.Mgo.DestoryMongoConn(sess)
 	it := sess.DB(u.Mgo.DbName).C(coll_name).Find(&q).Sort("_id").Iter()
-	updateFieldScore,total := [][]map[string]interface{}{},0
+	updateFieldScore, total := [][]map[string]interface{}{}, 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
 		if total%1000 == 0 {
 			log.Println("当前数量:", total)
@@ -78,8 +79,8 @@ func calculateFieldScore(tmp map[string]interface{}, field_tag []string) map[str
 	}
 
 	//综合比对是否正确 field_tag   - 指定字段
-	isUse ,v_taginfo:= true,make(map[string]interface{},0)
-	b_isfield_tag := make(map[string]interface{},0)
+	isUse, v_taginfo := true, make(map[string]interface{}, 0)
+	b_isfield_tag := make(map[string]interface{}, 0)
 	for _, key := range field_tag {
 		v_taginfo[key] = int64(1)
 		value := *qu.ObjToMap(update_dict[key])
@@ -89,12 +90,12 @@ func calculateFieldScore(tmp map[string]interface{}, field_tag []string) map[str
 		}
 	}
 
-	for k,v :=range update_dict{
+	for k, v := range update_dict {
 		data := *qu.ObjToMap(v)
 		score := qu.Int64All(data["score"])
 		if score < 99 {
 			b_isfield_tag[k] = true
-		}else {
+		} else {
 			b_isfield_tag[k] = false
 		}
 	}
@@ -105,41 +106,39 @@ func calculateFieldScore(tmp map[string]interface{}, field_tag []string) map[str
 
 	return map[string]interface{}{
 		"$set": map[string]interface{}{
-			"v_fieldscore": update_dict,
-			"v_taginfo" :v_taginfo,
-			"b_cleartag" :false,
-			"b_isfield_tag":b_isfield_tag,
-			"b_istagging":b_istagging,
-			"b_isprchasing":b_isprchasing,
+			"v_fieldscore":  update_dict,
+			"v_taginfo":     v_taginfo,
+			"b_isfield_tag": b_isfield_tag,
+			"b_istagging":   b_istagging,
+			"b_isprchasing": b_isprchasing,
 		},
 	}
 }
 
-
 //标的物-计算
 func calculatePrchasinglist(tmp map[string]interface{}) bool {
 	b_ispurchasing := true //默认需要标注
 	if purchasinglist, ok := tmp["purchasinglist"].([]interface{}); ok {
-		if len(purchasinglist)<=0 {
+		if len(purchasinglist) <= 0 {
 			return b_ispurchasing
 		}
 		isListUserArr := []bool{}
-		for _,data := range purchasinglist{
+		for _, data := range purchasinglist {
 			isUse := isUsePurchasing(*qu.ObjToMap(data))
-			isListUserArr = append(isListUserArr,isUse)
+			isListUserArr = append(isListUserArr, isUse)
 		}
 		b_ispurchasing = !isUseAllPurchasing(isListUserArr)
 		return b_ispurchasing
 	}
 
 	if purchasinglistA, okA := tmp["purchasinglist"].(primitive.A); okA {
-		if len(purchasinglistA)<=0 {
+		if len(purchasinglistA) <= 0 {
 			return b_ispurchasing
 		}
 		isListUserArr := []bool{}
-		for _,data := range purchasinglistA{
+		for _, data := range purchasinglistA {
 			isUse := isUsePurchasing(*qu.ObjToMap(data))
-			isListUserArr = append(isListUserArr,isUse)
+			isListUserArr = append(isListUserArr, isUse)
 		}
 		b_ispurchasing = !isUseAllPurchasing(isListUserArr)
 	}
@@ -147,8 +146,8 @@ func calculatePrchasinglist(tmp map[string]interface{}) bool {
 }
 
 //判断各个标的物是否可用  默认不可用
-func isUsePurchasing(data map[string]interface{}) bool{
-	isUse :=  false
+func isUsePurchasing(data map[string]interface{}) bool {
+	isUse := false
 	num := 1
 	total_score := qu.Float64All(data["score"])
 	if total_score <= float64(0) {
@@ -156,9 +155,9 @@ func isUsePurchasing(data map[string]interface{}) bool{
 	}
 	ner_data := *qu.ObjToMap(data["ner_data"])
 	NerGoods := *qu.ObjToMap(ner_data["NerGoods"])
-	for _,v := range NerGoods{
+	for _, v := range NerGoods {
 		num++
-		total_score+=qu.Float64All(v)
+		total_score += qu.Float64All(v)
 	}
 	//计算总平均分输
 	if total_score/float64(num) > float64(0.3) {
@@ -166,33 +165,34 @@ func isUsePurchasing(data map[string]interface{}) bool{
 	}
 	return isUse
 }
+
 //是否整体可用 - 默认不可用
-func isUseAllPurchasing(isListUserArr []bool) bool{
-	isUse :=  false
+func isUseAllPurchasing(isListUserArr []bool) bool {
+	isUse := false
 	total_num := len(isListUserArr)
-	ok_num :=0
-	for _,v := range isListUserArr {
+	ok_num := 0
+	for _, v := range isListUserArr {
 		if v {
 			ok_num++
 		}
 	}
-	if ok_num==0 {
+	if ok_num == 0 {
 		return isUse
 	}
-	correct := float64(ok_num)/float64(total_num)
-	if total_num<=2 {
-		if correct>=float64(1) {
+	correct := float64(ok_num) / float64(total_num)
+	if total_num <= 2 {
+		if correct >= float64(1) {
 			isUse = true
 		}
-	} else if total_num>2 && total_num<=6 {
-		if correct>=float64(0.6) {
+	} else if total_num > 2 && total_num <= 6 {
+		if correct >= float64(0.6) {
 			isUse = true
 		}
-	}else if total_num>7 {
-		if correct>=float64(0.5) {
+	} else if total_num > 7 {
+		if correct >= float64(0.5) {
 			isUse = true
 		}
-	}else {
+	} else {
 
 	}
 	return isUse

BIN
src/web/model/taskexportmodel.xlsx