Selaa lähdekoodia

feat:参标阶段 数据结构调整

wangshan 1 vuosi sitten
vanhempi
commit
65d069e261
1 muutettua tiedostoa jossa 47 lisäystä ja 8 poistoa
  1. 47 8
      jyBXCore/rpc/model/mysql/participateStage.go

+ 47 - 8
jyBXCore/rpc/model/mysql/participateStage.go

@@ -31,10 +31,26 @@ func NewParStage(entId, entUserId, positionId int64, projectId string) *ParStage
 }
 
 type StageInfo struct {
-	Value string
-	Date  string
+	Name  string `json:"name"`
+	Value string `json:"value"`
+	Date  string `json:"date"`
 }
 
+var (
+	stageMap = []string{
+		"参标状态",
+		"投标类型",
+		"已报名",
+		"投标决策",
+		"编制投标文件",
+		"递交投标文件",
+		"中标公示",
+		"签合同",
+		"已结束",
+		"终止参标",
+	}
+)
+
 func (p *ParStage) UpdateStage() {
 	var (
 		recordsMap      = map[string]*StageInfo{}
@@ -44,6 +60,7 @@ func (p *ParStage) UpdateStage() {
 		}
 		now                     = time.Now()
 		createDate              string
+		lastDate                int64 //最新一次更新时间
 		entUserIdBool           = map[string]bool{}
 		positionIdBool          = map[string]bool{}
 		entUserIds, positionIds []string
@@ -73,8 +90,11 @@ func (p *ParStage) UpdateStage() {
 				contentStr    string
 				entUserId     = strconv.FormatInt(gconv.Int64(rv["ent_user_id"]), 10)
 				positionId    = strconv.FormatInt(gconv.Int64(rv["position_id"]), 10)
+				cdStr         = strings.Split(gconv.String(rv["create_date"]), " ")[0]
+				cdTime, _     = time.Parse(date.Date_Full_Layout, gconv.String(rv["create_date"]))
 			)
-			createDate = strings.Split(gconv.String(rv["create_date"]), " ")[0]
+			lastDate = common.If(cdTime.Unix() > lastDate, cdTime.Unix(), lastDate).(int64)
+			createDate = common.If(cdStr != "", cdStr, createDate).(string)
 			if ok {
 				contentMap = gconv.Map(content)
 				if contentMap["afterMap"] != nil {
@@ -86,8 +106,9 @@ func (p *ParStage) UpdateStage() {
 							values := gconv.SliceStr(bidStage["value"])
 							if len(values) > 0 {
 								for _, bv := range values {
-									if status == "调整" || recordsMap[fmt.Sprintf("%s(阶段)", bv)].Date == "" {
-										recordsMap[fmt.Sprintf("%s(阶段)", bv)] = &StageInfo{
+									if status == "调整" || recordsMap[bv].Date == "" {
+										recordsMap[bv] = &StageInfo{
+											Name:  fmt.Sprintf("%s(阶段)", bv),
 											Value: state,
 											Date:  createDate,
 										}
@@ -99,6 +120,7 @@ func (p *ParStage) UpdateStage() {
 							value := gconv.String(bidType["value"])
 							if value != "" {
 								recordsMap["投标类型"] = &StageInfo{
+									Name:  "投标类型",
 									Value: value,
 									Date:  createDate,
 								}
@@ -117,6 +139,7 @@ func (p *ParStage) UpdateStage() {
 				//参标后 未被 终止参标
 				if strings.TrimSpace(contentStr) == "参标" {
 					recordsMap["参标状态"] = &StageInfo{
+						Name:  "参标状态",
 						Value: "已参标",
 						Date:  createDate,
 					}
@@ -125,6 +148,7 @@ func (p *ParStage) UpdateStage() {
 				if strings.Contains(contentStr, "终止参标") {
 					if !isParticipate {
 						recordsMap[contentStr] = &StageInfo{
+							Name:  "终止参标",
 							Value: "已终止",
 							Date:  createDate,
 						}
@@ -144,8 +168,23 @@ func (p *ParStage) UpdateStage() {
 		}
 	}
 	if recordsMap != nil {
+		var stages []*StageInfo
+		for _, v := range stageMap {
+			records := recordsMap[v]
+			if records == nil {
+				records = &StageInfo{
+					Name:  v,
+					Value: "-",
+				}
+			}
+			stages = append(stages, &StageInfo{
+				Name:  records.Name,
+				Value: records.Value,
+				Date:  records.Date,
+			})
+		}
 		// 转换结构体数组为JSON字符串
-		jsonData, err := json.Marshal(recordsMap)
+		jsonData, err := json.Marshal(stages)
 		if err != nil {
 			fmt.Println("Failed to marshal struct array to JSON:", err)
 			return
@@ -160,7 +199,7 @@ func (p *ParStage) UpdateStage() {
 			updateSelectSlq = fmt.Sprintf("%s%s", updateSelectSlq, add)
 		}
 		if s := IC.BaseMysql.SelectBySql(updateSelectSlq, p.EntId, p.ProjectId); len(*s) > 0 {
-			updateInsertMap["update_date"] = createDate
+			updateInsertMap["update_date"] = date.FormatDateByInt64(&lastDate, date.Date_Short_Layout)
 			if ok := IC.BaseMysql.Update(ParticipateStage, map[string]interface{}{
 				"id": gconv.Int64((*s)[0]["id"]),
 			}, updateInsertMap); !ok {
@@ -168,7 +207,7 @@ func (p *ParStage) UpdateStage() {
 			}
 		} else {
 			updateInsertMap["create_date"] = date.FormatDate(&now, date.Date_Full_Layout)
-			updateInsertMap["update_date"] = createDate
+			updateInsertMap["update_date"] = date.FormatDateByInt64(&lastDate, date.Date_Short_Layout)
 			if i := IC.BaseMysql.Insert(ParticipateStage, updateInsertMap); i == 0 {
 				log.Println("参标操作记录 插入异常:", updateInsertMap)
 			}