You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.0 KiB
Go
65 lines
2.0 KiB
Go
package service
|
|
|
|
import (
|
|
"cu-helper/cus-eng-con-sys/config"
|
|
"cu-helper/cus-eng-con-sys/cryptokit"
|
|
"cu-helper/cus-eng-con-sys/model"
|
|
"github.com/go-resty/resty/v2"
|
|
"github.com/mizuki1412/go-core-kit/class/exception"
|
|
"github.com/mizuki1412/go-core-kit/service/logkit"
|
|
"github.com/tidwall/gjson"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// AssignScrap 取消交付
|
|
/*
|
|
取消交付分两个步骤进行
|
|
1、searchAccSendList获取deliveryId
|
|
2、assignScrap
|
|
*/
|
|
|
|
func ReqWithdrawAssign(parenProcInsId string) {
|
|
list := searchAccSendList(parenProcInsId)
|
|
assignScrap(list, parenProcInsId)
|
|
}
|
|
|
|
func searchAccSendList(parenProcInsId string) []string {
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
header := h.GenReqParam()
|
|
f := model.NewSearchAccSendList(parenProcInsId)
|
|
form := f.GenReqParam()
|
|
client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second)
|
|
resp, err := client.R().
|
|
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/searchAccSendList")
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
data := strings.Trim(resp.String(), `"`)
|
|
decrypt := cryptokit.Decrypt(data)
|
|
ok := gjson.Get(decrypt, "data").Array()
|
|
var deliveryIdList []string
|
|
for _, v := range ok {
|
|
deliveryId := gjson.Get(v.String(), "deliveryId").String()
|
|
deliveryIdList = append(deliveryIdList, deliveryId)
|
|
}
|
|
return deliveryIdList
|
|
}
|
|
|
|
func assignScrap(deliveryIdList []string, parenProcInsId string) {
|
|
client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second)
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
header := h.GenReqParam()
|
|
for _, v := range deliveryIdList {
|
|
f := model.NewAssignScrap(v, parenProcInsId)
|
|
form := f.GenReqParam()
|
|
resp, err := client.R().
|
|
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/assignScrap")
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
data := strings.Trim(resp.String(), `"`)
|
|
logkit.Info("assignScarp:" + cryptokit.Decrypt(data))
|
|
}
|
|
}
|