Browse Source

Merge branch 'dev2.0' of http://192.168.3.207:8080/data_processing/data_validation into dev2.0

* 'dev2.0' of http://192.168.3.207:8080/data_processing/data_validation:
  xg
  xg
Jianghan 3 years ago
parent
commit
73ce0fb8b1
5 changed files with 32 additions and 24 deletions
  1. 18 7
      src/front/group.go
  2. 5 1
      src/front/project.go
  3. 4 1
      src/front/remark.go
  4. 5 1
      src/front/user.go
  5. 0 14
      src/main.go

+ 18 - 7
src/front/group.go

@@ -2,6 +2,7 @@ package front
 
 import (
 	"fmt"
+	"github.com/shopspring/decimal"
 	"github.com/tealeg/xlsx"
 	"mongodb"
 	"os"
@@ -52,7 +53,10 @@ func (f *Front) GroupTaskListByGroup() {
 				tagNum := util.Mgo.Count(sourceinfo, map[string]interface{}{"s_grouptaskid": groupTaskId, "b_istag": true})
 				progressFloat := float64(tagNum) / float64(giveNum)
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", progressFloat), 64)
-				progress := fmt.Sprint(value*100) + "%"
+				decimalValue := decimal.NewFromFloat(value)
+				decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
+				value, _ = decimalValue.Float64()
+				progress := fmt.Sprint(value) + "%"
 				l["s_progress"] = progress
 				//同步数据库
 				util.Mgo.UpdateById(util.TASKCOLLNAME, l["_id"], map[string]interface{}{"$set": map[string]interface{}{"s_progress": progress}})
@@ -74,8 +78,8 @@ func (f *Front) GroupTaskListByAdmin() {
 		status := f.GetString("s_status")
 		searchStr := f.GetString("search[value]")
 		search := strings.TrimSpace(searchStr)
-		starttime, _ := f.GetInt("starttime")
-		endtime, _ := f.GetInt("endtime")
+		starttime, _ := f.GetInt("i_starttime")
+		completetime, _ := f.GetInt("i_completetime")
 		query := map[string]interface{}{
 			"s_stype": "group", //检索用户组任务
 		}
@@ -84,9 +88,9 @@ func (f *Front) GroupTaskListByAdmin() {
 				"$gte": starttime,
 			}
 		}
-		if endtime > 0 {
+		if completetime > 0 {
 			query["i_completetime"] = map[string]interface{}{
-				"$lte": endtime,
+				"$lte": completetime,
 			}
 		}
 		if status != "-1" { //任务状态
@@ -113,7 +117,10 @@ func (f *Front) GroupTaskListByAdmin() {
 				tagNum := util.Mgo.Count(sourceinfo, map[string]interface{}{"s_grouptaskid": groupTaskId, "b_istag": true})
 				progressFloat := float64(tagNum) / float64(giveNum)
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", progressFloat), 64)
-				progress := fmt.Sprint(value*100) + "%"
+				decimalValue := decimal.NewFromFloat(value)
+				decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
+				value, _ = decimalValue.Float64()
+				progress := fmt.Sprint(value) + "%"
 				l["s_progress"] = progress
 				//同步数据库
 				util.Mgo.UpdateById(util.TASKCOLLNAME, l["_id"], map[string]interface{}{"$set": map[string]interface{}{"s_progress": progress}})
@@ -166,7 +173,10 @@ func (f *Front) GroupUserTaskList() {
 				tagNum := util.Mgo.Count(sourceinfo, map[string]interface{}{"s_usertaskid": mongodb.BsonIdToSId(l["_id"]), "b_istag": true})
 				progressFloat := float64(tagNum) / float64(giveNum)
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", progressFloat), 64)
-				progress := fmt.Sprint(value*100) + "%"
+				decimalValue := decimal.NewFromFloat(value)
+				decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
+				value, _ = decimalValue.Float64()
+				progress := fmt.Sprint(value) + "%"
 				l["s_progress"] = progress
 				//同步数据库
 				util.Mgo.UpdateById(util.TASKCOLLNAME, l["_id"], map[string]interface{}{"$set": map[string]interface{}{"s_progress": progress}})
@@ -294,6 +304,7 @@ func (f *Front) GroupTaskExport() {
 			"i_completetime": 1,
 		}
 		list, _ := util.Mgo.Find(util.TASKCOLLNAME, query, nil, fields, false, -1, -1)
+		qu.Debug(len(*list))
 		for _, l := range *list {
 			row := sheet.AddRow()
 			entname := qu.ObjToString(l["s_entname"])

+ 5 - 1
src/front/project.go

@@ -3,6 +3,7 @@ package front
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/shopspring/decimal"
 	"github.com/tealeg/xlsx"
 	"go.mongodb.org/mongo-driver/bson/primitive"
 	"io/ioutil"
@@ -313,7 +314,10 @@ func (f *Front) ProjectGroupTaskList() {
 				tagNum := util.Mgo.Count(sourceinfo, map[string]interface{}{"s_grouptaskid": groupTaskId, "b_istag": true})
 				progressFloat := float64(tagNum) / float64(giveNum)
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", progressFloat), 64)
-				progress := fmt.Sprint(value*100) + "%"
+				decimalValue := decimal.NewFromFloat(value)
+				decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
+				value, _ = decimalValue.Float64()
+				progress := fmt.Sprint(value) + "%"
 				l["s_progress"] = progress
 				//同步数据库
 				util.Mgo.UpdateById(util.TASKCOLLNAME, l["_id"], map[string]interface{}{"$set": map[string]interface{}{"s_progress": progress}})

+ 4 - 1
src/front/remark.go

@@ -613,7 +613,10 @@ func (f *Front) CheckList() {
 				tagNum := util.Mgo.Count(sourceinfo, map[string]interface{}{"s_usertaskid": mgo.BsonIdToSId(l["_id"]), "b_istag": true})
 				progressFloat := float64(tagNum) / float64(giveNum)
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", progressFloat), 64)
-				progress := fmt.Sprint(value*100) + "%"
+				decimalValue := decimal.NewFromFloat(value)
+				decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
+				value, _ = decimalValue.Float64()
+				progress := fmt.Sprint(value) + "%"
 				l["s_progress"] = progress
 			}
 		}

+ 5 - 1
src/front/user.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/dchest/captcha"
 	"github.com/gorilla/sessions"
+	"github.com/shopspring/decimal"
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson/primitive"
 	mgo "mongodb"
@@ -727,7 +728,10 @@ func (f *Front) UserTaskList() {
 				tagNum := Mgo.Count(sourceinfo, map[string]interface{}{"s_usertaskid": mgo.BsonIdToSId(l["_id"]), "b_istag": true})
 				progressFloat := float64(tagNum) / float64(giveNum)
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", progressFloat), 64)
-				progress := fmt.Sprint(value*100) + "%"
+				decimalValue := decimal.NewFromFloat(value)
+				decimalValue = decimalValue.Mul(decimal.NewFromInt(100))
+				value, _ = decimalValue.Float64()
+				progress := fmt.Sprint(value) + "%"
 				l["s_progress"] = progress
 				//同步数据库
 				Mgo.UpdateById(TASKCOLLNAME, l["_id"], map[string]interface{}{"$set": map[string]interface{}{"s_progress": progress}})

+ 0 - 14
src/main.go

@@ -34,19 +34,5 @@ func init() {
 }
 
 func main() {
-	//qu.Debug(SE.EncodeString("5c0a207ca5cb26b9b76ce197"))
-	//return
-	//go front.QuaFieldScore([]string{"buyer"},"zktest_data") //临时测试-质量
-	//Mgo.UpdateById("test11", "61a9975a180a78e6edf8285d", map[string]interface{}{
-	//	"$inc": map[string]interface{}{
-	//		"count": -555,
-	//	},
-	//})
-	//success := false
-	//msg := ""
-	//successNum := int64(0)
-	//s_departname, s_entname, s_rulename, importDataNum := front.ImportDataByColl("test", "615278a07f395572067fc599", &success, &msg, &successNum)
-	//qu.Debug(s_departname, s_entname, s_rulename, importDataNum)
-	//qu.Debug(success, msg, successNum)
 	xweb.Run(":" + qu.ObjToString(Sysconfig["port"]))
 }