12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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 ProvincialPostStaffAttendance(ctx context.Context, req *v1.ProvincialPostStaffAttendanceRequest)(reply *v1.ProvincialPostStaffAttendanceReply, err error) {
- token, err := Login()
- if err != nil {
- return nil, err
- }
- data := map[string]interface{}{
- "Code":req.Code,
- "TeamSysNo":req.TeamSysNo,
- "TeamName":req.TeamName,
- "WorkerName":req.WorkerName,
- "IDCardType":req.IdCardType,
- "IDCardNumber":req.IdCardNumber,
- "Direction":req.Direction,
- "Date":req.Date,
- }
- 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 add staff attendance %s,%v\n", bytes, err)
- if err != nil {
- s, _ := json.Marshal(param)
- logger.Error("thirdpary provincial add staff attendance",
- 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 add staff attendance",
- 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.ProvincialPostStaffAttendanceReply{}
- return reply, nil
- }
|