animeic 2 years ago
parent
commit
7bfdfe0c13
3 changed files with 53 additions and 17 deletions
  1. 48 13
      boxcost/api/print.go
  2. 1 1
      boxcost/api/router.go
  3. 4 3
      boxcost/db/model/pack.go

+ 48 - 13
boxcost/api/print.go

@@ -1,5 +1,11 @@
 package api
 
+import (
+	"fmt"
+
+	"github.com/gin-gonic/gin"
+)
+
 // import (
 // 	"box-cost/db/model"
 // 	"box-cost/db/repo"
@@ -19,22 +25,51 @@ package api
 // 	"go.mongodb.org/mongo-driver/mongo"
 // )
 
-// func Printr(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+func Printr(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 
-// 	// https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/image/jpg/1675757991547cnt7X9_2.jpg zhang
-// 	// https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/image/jpg/1675758027305uLKtda_1.jpg zhu
-// 	loc, _ := time.LoadLocation("Local")
-// 	date := time.Now().Format("2006-01-02")
-// 	startDate := date + " 00:00:00"
-// 	startTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startDate, loc)
-// 	endDate := date + " 23:59:59"
-// 	endTime, _ := time.ParseInLocation("2006-01-02 15:04:05", endDate, loc)
-// 	fmt.Println(startTime.Unix())
-// 	fmt.Println(endTime.Unix())
+	// https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/image/jpg/1675757991547cnt7X9_2.jpg zhang
+	// https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/image/jpg/1675758027305uLKtda_1.jpg zhu
+	// loc, _ := time.LoadLocation("Local")
+	// date := time.Now().Format("2006-01-02")
+	// startDate := date + " 00:00:00"
+	// startTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startDate, loc)
+	// endDate := date + " 23:59:59"
+	// endTime, _ := time.ParseInLocation("2006-01-02 15:04:05", endDate, loc)
+	// fmt.Println(startTime.Unix())
+	// fmt.Println(endTime.Unix())
 
-// 	return "success", nil
+	// return "success", nil
+	arr := []string{"a", "b", "a", "c", "c", "b"}
+	newArr := removeDuplication_sort(arr)
+	for k, v := range newArr {
+		fmt.Println("k:%d,v:%s", k, v)
+	}
+	return nil, nil
 
-// }
+}
+
+func removeDuplication_sort(arr []string) []string {
+	length := len(arr)
+	if length == 0 {
+		return arr
+	}
+
+	j := 0
+	for i := 1; i < length; i++ {
+		if arr[i] != arr[j] {
+			j++
+			if j < i {
+				swap(arr, i, j)
+			}
+		}
+	}
+
+	return arr[:j+1]
+}
+
+func swap(arr []string, a, b int) {
+	arr[a], arr[b] = arr[b], arr[a]
+}
 
 // // 生成百万数据
 // func GenData(_ *gin.Context, apictx *ApiSession) (interface{}, error) {

+ 1 - 1
boxcost/api/router.go

@@ -14,7 +14,7 @@ func RegRouters(svc *Service) {
 
 	//数据存储
 	boxcost.POST("/save/policy", ServiceObsUploadPolicy)
-	// boxcost.GET("/printr", Printr)
+	boxcost.GET("/printr", Printr)
 	// boxcost.GET("/genData", GenData)
 	// boxcost.GET("/searchData", SearchData)
 

+ 4 - 3
boxcost/db/model/pack.go

@@ -78,7 +78,8 @@ type ComponentStage struct {
 	Norm       string    `bson:"norm,omitempty" json:"norm"`         // 规格
 	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
 	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
-	Type       int       `bson:"type,omitempty" json:"type"`     //1-材料 2-工艺 3-成品
-	Group      string    `bson:"group,omitempty" json:"group"`   //工序合标记,相同Group的数据合并成一个单据
-	BillId     string    `bson:"billId,omitempty" json:"billId"` //订单Id
+	Type       int       `bson:"type,omitempty" json:"type"`         //1-材料 2-工艺 3-成品
+	Group      string    `bson:"group,omitempty" json:"group"`       //工序合标记,相同Group的数据合并成一个单据
+	BillId     string    `bson:"billId,omitempty" json:"billId"`     //订单Id
+	BillType   string    `bson:"billType,omitempty" json:"billType"` //订单type // 1,2,3
 }