123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package provincial_department
- import (
- "context"
- "encoding/json"
- "fmt"
- "github.com/tidwall/gjson"
- "go.uber.org/zap"
- "smart-provincial/errors"
- "smart-provincial/pb/v1"
- "smart-provincial/thirdparty"
- "strings"
- "smart-provincial/parser"
- "github.com/jaryhe/gopkgs/logger"
- )
- func ProvincialPostProject(ctx context.Context, req *v1.ProvincialPostProjectRequest)(reply *v1.ProvincialPostProjectReply, err error) {
- token, err := Login()
- if err != nil {
- return nil, err
- }
- data := map[string]interface{}{
- "Code":req.ProjectCode,
- "Name":req.ProjectName,
- "Category":req.ProjectCategory,
- //"OwnerName":req.OwnerName,
- "ConstructType":req.ConstructType,
- "InvestType":req.InvestType,
- //"BuildCorporationCode":req.BuildCorporationCode,
- "BuildingArea":req.BuildingArea,
- "AreaCode":req.AreaCode,
- "Address":req.Address,
- "Invest":req.Invest,
- "Scale":req.Scale,
- //"PrjSize":req.PrjSize,
- "StartDate":req.StartDate,
- //"CompleteDate":req.CompleteDate,
- //"PrjStatus":req.PrjStatus,
- }
- datas := []map[string]interface{}{}
- datas = append(datas, data)
- param := map[string]interface{}{
- "type":"项目基本信息",
- "datas":datas,
- }
- bytes, err := thirdparty.ProvincialPost(parser.Conf.ThirdParty.Provincial.ProjectUploadApi, token, param)
- fmt.Printf("provincial project add: %s,%v\n", bytes, err)
- if err != nil {
- s, _ := json.Marshal(param)
- logger.Error("thirdpary provincial project add",
- zap.String("call", parser.Conf.ThirdParty.Provincial.ProjectUploadApi),
- zap.String("param", string(s)),
- zap.String("error", err.Error()))
- return nil, errors.ProvincialProjectUploadError
- }
- ack := gjson.GetBytes(bytes, "ack_code").String()
- if strings.ToUpper(ack) != "SUCCESS" {
- s, _ := json.Marshal(param)
- logger.Error("thirdpary provincial project add",
- zap.String("call", parser.Conf.ThirdParty.Provincial.ProjectUploadApi),
- zap.String("param", string(s)),
- zap.String("error",string(bytes)))
- return nil, errors.ProvincialProjectUploadError
- }
- id := gjson.GetBytes(bytes, "ID").String()
- reply.Id = id
- reply = &v1.ProvincialPostProjectReply{}
- return reply, nil
- }
|