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.

57 lines
2.2 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"
"cu-helper/cus-eng-con-sys/util"
"github.com/go-resty/resty/v2"
"github.com/mizuki1412/go-core-kit/class/exception"
"github.com/mizuki1412/go-core-kit/service/logkit"
"strings"
"time"
)
// ReqAccDelivery 验收确认请求
/*
验收确认分一个步骤进行
1、先获取指定人的deliveryId
2、获取businessKey
3、提交验收确认
*/
func ReqAccDelivery(processInsId, taskId string) {
businessKey := getRemandId(processInsId, taskId)
deliveryId := getDeliveryId(processInsId, taskId, businessKey)
jfPushProcess(processInsId, taskId, deliveryId, businessKey)
}
func jfPushProcess(processInsId, taskId, deliveryId, businessKey string) {
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
header := h.GenReqParam()
f := model.NewJFPushProcess(processInsId, taskId, deliveryId, businessKey)
form := f.GenReqParam()
client := resty.New().SetRetryCount(5).SetRetryWaitTime(18 * time.Second)
resp, err := client.R().
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/jfPushProcess")
if err != nil {
panic(exception.New(err.Error()))
}
data := strings.Trim(resp.String(), `"`)
logkit.Info("jfPushProcess:" + cryptokit.Decrypt(data))
}
func getDeliveryId(processInsId, taskId, businessKey string) string {
client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second)
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
header := h.GenReqParam()
query := model.NewGoAccDeliveryEdit(businessKey, processInsId, taskId)
resp, err := client.R().
SetHeaders(header).Get(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/goAccDeliveryEdit?businessKey=" + query.BusinessKey + "&processInstanceId=" + query.ProcessInstanceId + "&taskId=" + query.TaskId + "&startLink=" + query.StartLink + "&endLink=" + query.EndLink + "&taskflag=" + query.TaskFlag + "&ranstr=" + query.Ranstr + "&timestamp=" + query.Timestamp + "&_=" + query.TimestampPro)
if err != nil {
panic(exception.New(err.Error()))
}
deliveryId := util.HTMLContentFindFirst(resp.String(), "deliveryId")
return deliveryId
}