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.
130 lines
5.0 KiB
Go
130 lines
5.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"
|
|
)
|
|
|
|
// ReqAccConfirm 验收确认请求
|
|
/*
|
|
验收确认分两个步骤进行
|
|
1、更新ACC信息
|
|
2、提交验收确认
|
|
*/
|
|
|
|
// ReqAccConfirm parenProcInsId=processInstanceId
|
|
func ReqAccConfirm(parenProcInsId, id string) {
|
|
//更新ACC信息
|
|
updateAccInfo(parenProcInsId, id)
|
|
//提交验收确认
|
|
saveProAndStart(parenProcInsId)
|
|
}
|
|
|
|
func updateAccInfo(processInstanceId, id string) {
|
|
remandId := getRemandId(processInstanceId, id)
|
|
html1 := toAcceptanceConfirm(remandId, processInstanceId, id)
|
|
token := getToken()
|
|
html2 := toRemandShowCommon(remandId)
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
header := h.GenReqParam()
|
|
f := model.NewUpdateAccInfo(token, remandId, html1, html2)
|
|
form := f.GenReqParam()
|
|
client := resty.New().SetRetryCount(5).SetRetryWaitTime(20 * time.Second)
|
|
resp, err := client.R().
|
|
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/acceptanceController/udpateAccInfo.action")
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
data := strings.Trim(resp.String(), `"`)
|
|
logkit.Info("updateAccInfo:" + cryptokit.Decrypt(data))
|
|
}
|
|
|
|
func saveProAndStart(parenProcInsId string) {
|
|
client := resty.New().SetRetryCount(5).SetRetryWaitTime(60 * time.Second)
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
header := h.GenReqParam()
|
|
f := model.NewSaveProAndStart(parenProcInsId)
|
|
form := f.GenReqParam()
|
|
resp, err := client.R().
|
|
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/saveProAndStart")
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
data := strings.Trim(resp.String(), `"`)
|
|
logkit.Info("saveProAndStart:" + cryptokit.Decrypt(data))
|
|
}
|
|
|
|
func getToken() string {
|
|
client := resty.New().SetRetryCount(5).SetRetryWaitTime(15 * time.Second)
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
header := h.GenReqParam()
|
|
f := model.NewGetToken()
|
|
form := f.GenReqParam()
|
|
resp, err := client.R().
|
|
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/commonController/getToken?T=" + form["timestamp"])
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
data := strings.Trim(resp.String(), `"`)
|
|
decrypt := cryptokit.Decrypt(data)
|
|
token := gjson.Get(decrypt, "token").String()
|
|
logkit.Debug("拿到了Token:" + token)
|
|
return token
|
|
}
|
|
|
|
// businessKey=remandId
|
|
func getRemandId(processInstanceId, id 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()
|
|
f := model.NewGetBusinessKey()
|
|
form := f.GenReqParam()
|
|
resp, err := client.R().
|
|
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/workflowrest/tasktodopath/GkXjGzKrProcess/" + processInstanceId + "/YSQR/" + id + "/ZH_XZ") //ZH_XZ在杭州应该不变化
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
data := strings.Trim(resp.String(), `"`)
|
|
decrypt := cryptokit.Decrypt(data)
|
|
dataRow := gjson.Get(decrypt, "dataRows").Array()
|
|
if len(dataRow) == 0 {
|
|
panic(exception.New("dataRow array len = 0"))
|
|
}
|
|
logkit.Debug("拿到了businessKey/remandId:" + dataRow[0].Get("businessKey").String())
|
|
return dataRow[0].Get("businessKey").String()
|
|
}
|
|
|
|
// businessKey=remandId,taskId=id
|
|
func toAcceptanceConfirm(businessKey, processInstId, taskId 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.NewToAcceptanceConfirm(businessKey, processInstId, taskId)
|
|
resp, err := client.R().
|
|
SetHeaders(header).Get(config.UrlPrefix + "/zjgd/frm/acceptanceComfirmController/toAcceptanceComfirm?businessKey=" + query.BusinessKey + "&processInstanceId=" + query.ProcessInstanceId + "&taskId=" + query.TaskId + "&startLink=" + query.StartLink + "&endLink=" + query.EndLink + "&taskflag=" + query.TaskFlag + "&ranstr=" + query.Ranstr + "×tamp=" + query.Timestamp + "&_=" + query.TimestampPro)
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
return resp.String()
|
|
}
|
|
|
|
func toRemandShowCommon(remandId 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.NewToRemandShowCommon(remandId)
|
|
resp, err := client.R().
|
|
SetHeaders(header).Get(config.UrlPrefix + "/zjgd/frm/remandInfoController/toRemandShowCommon?remandId=" + query.RemandId + "&ranstr=" + query.Ranstr + "×tamp=" + query.Timestamp + "&_=" + query.TimestampPro)
|
|
if err != nil {
|
|
panic(exception.New(err.Error()))
|
|
}
|
|
return resp.String()
|
|
}
|