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.
109 lines
4.0 KiB
Go
109 lines
4.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"
|
|
)
|
|
|
|
// ReqAccConfirm 验收确认请求
|
|
/*
|
|
验收确认分两个步骤进行
|
|
1、更新ACC信息
|
|
2、提交验收确认
|
|
*/
|
|
|
|
// ReqAccConfirm parenProcInsId=processInstanceId
|
|
func ReqAccConfirm(ctx *model.Ctx) {
|
|
//更新ACC信息
|
|
updateAccInfo(ctx)
|
|
//提交验收确认
|
|
saveProAndStart(ctx)
|
|
}
|
|
|
|
func updateAccInfo(ctx *model.Ctx) {
|
|
remandId := getRemandId(ctx)
|
|
html1 := toAcceptanceConfirm(ctx, remandId)
|
|
token := getToken(ctx.RestyClient)
|
|
html2 := toRemandShowCommon(ctx.RestyClient, 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 := ctx.RestyClient
|
|
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(ctx *model.Ctx) {
|
|
parenProcInsId := ctx.Data.Get("processInstanceId").String()
|
|
client := ctx.RestyClient
|
|
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(client *resty.Client) string {
|
|
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,taskId=id
|
|
func toAcceptanceConfirm(ctx *model.Ctx, businessKey string) string {
|
|
processInstId := ctx.Data.Get("processInstanceId").String()
|
|
taskId := ctx.Data.Get("id").String()
|
|
taskdefinitionKey := ctx.Data.Get("taskdefinitionKey").String()
|
|
client := ctx.RestyClient
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
header := h.GenReqParam()
|
|
query := model.NewCommonFormGetHtml(businessKey, processInstId, taskdefinitionKey, 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(client *resty.Client, remandId string) string {
|
|
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()
|
|
}
|