|  | @@ -10,6 +10,7 @@ import (
 | 
	
		
			
				|  |  |  	"kpt-tmr-group/pkg/xerr"
 | 
	
		
			
				|  |  |  	operationPb "kpt-tmr-group/proto/go/backend/operation"
 | 
	
		
			
				|  |  |  	"net/http"
 | 
	
		
			
				|  |  | +	"sort"
 | 
	
		
			
				|  |  |  	"strconv"
 | 
	
		
			
				|  |  |  	"strings"
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -237,60 +238,57 @@ func (s *StoreEntry) UserMaterialsStatisticsExcelExport(ctx context.Context, req
 | 
	
		
			
				|  |  |  		return nil, xerr.WithStack(err)
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	// 表头
 | 
	
		
			
				|  |  | -	excelValuesList := map[string][]interface{}{}
 | 
	
		
			
				|  |  | -	/*"A1": {
 | 
	
		
			
				|  |  | -		"饲料名称", "需加料", nil, "Y国产燕麦草55", nil, "自制高产Ⅱ精补料1#", nil, "Y苜蓿M150", nil, "自制酵贮康1#", nil,
 | 
	
		
			
				|  |  | -		"Y麸皮^大片", nil, "Y甜菜粕颗粒", nil, "3Y青贮玉米", nil, "围产牛补充预混合饲料1#", nil, "5Y青贮玉米", nil, "Y羊草", nil,
 | 
	
		
			
				|  |  | -		"Y国产燕麦草60", nil, "Y苜蓿M170", nil, "Y苜蓿Z130", nil, "1Y青贮玉米", nil, "水", nil, "自制干奶精补料1#", nil,
 | 
	
		
			
				|  |  | -		"自制初产精补料1#", nil, "自制高产精补料1#", nil, "自制低产精补料1#", nil, "Y青贮玉米^棒子", nil, "Y压片玉米", nil,
 | 
	
		
			
				|  |  | -		"自制围产精补料1#", nil, "自制青年精补料1#", nil, "合计",
 | 
	
		
			
				|  |  | -	},*/
 | 
	
		
			
				|  |  | +	// 表数据
 | 
	
		
			
				|  |  | +	excelValuesList := map[int][]interface{}{}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	cProp := make([]string, 0)
 | 
	
		
			
				|  |  |  	for _, data2 := range userMaterialsList.Data2 {
 | 
	
		
			
				|  |  | -		excelValuesList["A1"] = append(excelValuesList["A1"], data2.Label)
 | 
	
		
			
				|  |  | +		excelValuesList[1] = append(excelValuesList[1], data2.Label)
 | 
	
		
			
				|  |  |  		for _, c := range data2.Children {
 | 
	
		
			
				|  |  | -			excelValuesList["A2"] = append(excelValuesList["A2"], c.Label)
 | 
	
		
			
				|  |  | +			excelValuesList[2] = append(excelValuesList[2], c.Label)
 | 
	
		
			
				|  |  | +			cProp = append(cProp, c.Prop)
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	for _, data2 := range userMaterialsList.Data2 {
 | 
	
		
			
				|  |  | -		for i, data1 := range userMaterialsList.Data1 {
 | 
	
		
			
				|  |  | -			index := fmt.Sprintf("A%d", i+3)
 | 
	
		
			
				|  |  | -			//value := tool.GetTargetByValueForTag(data1, c.Prop, "json")
 | 
	
		
			
				|  |  | -			data1Map, ok := data1.(map[string]interface{})
 | 
	
		
			
				|  |  | -			fmt.Println("======excelValuesList======", ok, data1Map, index, data2)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -			// excelValuesList[index] = append(excelValuesList[index], data1Map[c.Prop])
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -	vv, _ := json.Marshal(excelValuesList)
 | 
	
		
			
				|  |  | -	fmt.Println("======excelValuesList======", string(vv))
 | 
	
		
			
				|  |  | -	/*for cell, values := range excelValuesList {
 | 
	
		
			
				|  |  | -		if err = streamWriter.SetRow(cell, values); err != nil {
 | 
	
		
			
				|  |  | +	for cell, values := range excelValuesList {
 | 
	
		
			
				|  |  | +		if err = streamWriter.SetRow(fmt.Sprintf("A%d", cell), values); err != nil {
 | 
	
		
			
				|  |  |  			return nil, xerr.WithStack(err)
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | +		delete(excelValuesList, cell)
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	for i, data1 := range userMaterialsList.Data1 {
 | 
	
		
			
				|  |  | +		data1Map, ok := data1.(map[string]interface{})
 | 
	
		
			
				|  |  | +		if ok {
 | 
	
		
			
				|  |  | +			for _, prop := range cProp {
 | 
	
		
			
				|  |  | +				newValue := ""
 | 
	
		
			
				|  |  | +				if value, yes := data1Map[prop]; yes {
 | 
	
		
			
				|  |  | +					if value != nil {
 | 
	
		
			
				|  |  | +						switch v := value.(type) {
 | 
	
		
			
				|  |  | +						case string:
 | 
	
		
			
				|  |  | +							newValue = v
 | 
	
		
			
				|  |  | +						case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
 | 
	
		
			
				|  |  | +							newValue = fmt.Sprintf("%d", v)
 | 
	
		
			
				|  |  | +						default:
 | 
	
		
			
				|  |  | +							newValue = fmt.Sprintf("%v", v)
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					excelValuesList[i+3] = append(excelValuesList[i+3], newValue)
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	hvCell := map[string]string{
 | 
	
		
			
				|  |  | -		"B1": "C1",
 | 
	
		
			
				|  |  | -		"D1": "E1",
 | 
	
		
			
				|  |  | -		"F1": "G1",
 | 
	
		
			
				|  |  | -		"H1": "R1",
 | 
	
		
			
				|  |  | -		"J1": "K1",
 | 
	
		
			
				|  |  | -		"L1": "M1",
 | 
	
		
			
				|  |  | -		"N1": "O1",
 | 
	
		
			
				|  |  | -		"P1": "Q1",
 | 
	
		
			
				|  |  | -		"R1": "S1",
 | 
	
		
			
				|  |  | -		"T1": "U1",
 | 
	
		
			
				|  |  | -		"V1": "W1",
 | 
	
		
			
				|  |  | -		"Z1": "AA1",
 | 
	
		
			
				|  |  | +	excelValuesKeys := make([]int, 0)
 | 
	
		
			
				|  |  | +	for k, _ := range excelValuesList {
 | 
	
		
			
				|  |  | +		excelValuesKeys = append(excelValuesKeys, k)
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	// 合并单元格
 | 
	
		
			
				|  |  | -	for h, v := range hvCell {
 | 
	
		
			
				|  |  | -		if err = streamWriter.MergeCell(h, v); err != nil {
 | 
	
		
			
				|  |  | +	sort.Ints(excelValuesKeys)
 | 
	
		
			
				|  |  | +	for _, v := range excelValuesKeys {
 | 
	
		
			
				|  |  | +		if err = streamWriter.SetRow(fmt.Sprintf("A%d", v), excelValuesList[v]); err != nil {
 | 
	
		
			
				|  |  |  			return nil, xerr.WithStack(err)
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -	}*/
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	if err = streamWriter.Flush(); err != nil {
 | 
	
		
			
				|  |  |  		return nil, xerr.WithStack(err)
 | 
	
	
		
			
				|  | @@ -535,6 +533,74 @@ func (s *StoreEntry) SearchProcessAnalysis(ctx context.Context, req *operationPb
 | 
	
		
			
				|  |  |  	return response, nil
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +// GetTrainNumber 获取班次
 | 
	
		
			
				|  |  | +func (s *StoreEntry) GetTrainNumber(ctx context.Context, req *operationPb.TrainNumberRequest) (*operationPb.TrainNumberResponse, error) {
 | 
	
		
			
				|  |  | +	body := &model.PastureCommonRequest{
 | 
	
		
			
				|  |  | +		Name:       req.ApiName,
 | 
	
		
			
				|  |  | +		Page:       req.Pagination.Page,
 | 
	
		
			
				|  |  | +		Offset:     req.Pagination.PageOffset,
 | 
	
		
			
				|  |  | +		PageCount:  req.Pagination.PageSize,
 | 
	
		
			
				|  |  | +		ReturnType: "Map",
 | 
	
		
			
				|  |  | +		ParamMaps: &model.TrainNumberParams{
 | 
	
		
			
				|  |  | +			PastureId: fmt.Sprintf("%d", req.PastureId),
 | 
	
		
			
				|  |  | +			InfoRName: req.InfoName,
 | 
	
		
			
				|  |  | +		},
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	response := &model.PastureCommonResponse{Data: &model.PastureCommonData{}}
 | 
	
		
			
				|  |  | +	if err := s.PastureHttpClient(ctx, model.UrlDataByName, int64(req.PastureId), body, response); err != nil {
 | 
	
		
			
				|  |  | +		return nil, xerr.WithStack(err)
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	result := &operationPb.TrainNumberResponse{
 | 
	
		
			
				|  |  | +		Code: http.StatusOK,
 | 
	
		
			
				|  |  | +		Msg:  "ok",
 | 
	
		
			
				|  |  | +		Data: &operationPb.TrainNumberData{List: make([]*operationPb.FormulaOptionEnum, 0)},
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if response.Data.List == nil {
 | 
	
		
			
				|  |  | +		return result, nil
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	b, _ := json.Marshal(response.Data.List)
 | 
	
		
			
				|  |  | +	trainNumberList := make([]*model.TrainNumberList, 0)
 | 
	
		
			
				|  |  | +	if err := json.Unmarshal(b, &trainNumberList); err != nil {
 | 
	
		
			
				|  |  | +		return nil, xerr.WithStack(err)
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	formulaOption := make([]*operationPb.FormulaOptionEnum, 0)
 | 
	
		
			
				|  |  | +	if len(trainNumberList) > 0 {
 | 
	
		
			
				|  |  | +		infoValue := trainNumberList[0].InfoValue
 | 
	
		
			
				|  |  | +		switch infoValue {
 | 
	
		
			
				|  |  | +		case "1":
 | 
	
		
			
				|  |  | +			formulaOption = append(formulaOption, &operationPb.FormulaOptionEnum{
 | 
	
		
			
				|  |  | +				Value: 1,
 | 
	
		
			
				|  |  | +				Label: "第一班",
 | 
	
		
			
				|  |  | +			})
 | 
	
		
			
				|  |  | +		case "2":
 | 
	
		
			
				|  |  | +			formulaOption = append(formulaOption, &operationPb.FormulaOptionEnum{
 | 
	
		
			
				|  |  | +				Value: 1,
 | 
	
		
			
				|  |  | +				Label: "第一班",
 | 
	
		
			
				|  |  | +			}, &operationPb.FormulaOptionEnum{
 | 
	
		
			
				|  |  | +				Value: 2,
 | 
	
		
			
				|  |  | +				Label: "第二班",
 | 
	
		
			
				|  |  | +			})
 | 
	
		
			
				|  |  | +		case "3":
 | 
	
		
			
				|  |  | +			formulaOption = append(formulaOption, &operationPb.FormulaOptionEnum{
 | 
	
		
			
				|  |  | +				Value: 1,
 | 
	
		
			
				|  |  | +				Label: "第一班",
 | 
	
		
			
				|  |  | +			}, &operationPb.FormulaOptionEnum{
 | 
	
		
			
				|  |  | +				Value: 2,
 | 
	
		
			
				|  |  | +				Label: "第二班",
 | 
	
		
			
				|  |  | +			}, &operationPb.FormulaOptionEnum{
 | 
	
		
			
				|  |  | +				Value: 3,
 | 
	
		
			
				|  |  | +				Label: "第三班",
 | 
	
		
			
				|  |  | +			})
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	result.Data.List = formulaOption
 | 
	
		
			
				|  |  | +	return result, nil
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  func (s *StoreEntry) SearchAnalysisAccuracy(ctx context.Context, req *operationPb.SearchAnalysisAccuracyRequest) (*model.SearchAnalysisAccuracyResponse, error) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	dataList := &model.CommonValueRatio{
 |