|
|
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"
|
|
|
)
|
|
|
|
|
|
// PdmEntrust 设计委托
|
|
|
/*
|
|
|
设计委托分三个步骤进行
|
|
|
1、判断是否change监理(先省略,看看有没有问题)
|
|
|
2、(先获取信息)再更新表单信息
|
|
|
3、提交设计委托
|
|
|
*/
|
|
|
|
|
|
func ReqPdmEntrust(processInsId, taskId, taskTitle string) {
|
|
|
updatePdmProduction(processInsId, taskId, taskTitle)
|
|
|
pdmPushProcess(processInsId, taskId, taskTitle)
|
|
|
}
|
|
|
|
|
|
func updatePdmProduction(processInsId, taskId, taskTitle string) {
|
|
|
remandId := getRemandIdSJKR(processInsId, taskId)
|
|
|
html := goPdmEntrustEdit(remandId, processInsId, taskId)
|
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
|
header := h.GenReqParam()
|
|
|
f := model.NewUpdatePdmProduction(remandId, html, taskTitle)
|
|
|
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/pdmProductionController/updatePdmProduction.action")
|
|
|
if err != nil {
|
|
|
panic(exception.New(err.Error()))
|
|
|
}
|
|
|
data := strings.Trim(resp.String(), `"`)
|
|
|
logkit.Info("updatePdmProduction:" + cryptokit.Decrypt(data))
|
|
|
}
|
|
|
|
|
|
func pdmPushProcess(processInsId, taskId, taskTitle string) {
|
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
|
header := h.GenReqParam()
|
|
|
f := model.NewPDMPushProcess(processInsId, taskId, taskTitle)
|
|
|
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/pdmEntrustController/pushProcess.action")
|
|
|
if err != nil {
|
|
|
panic(exception.New(err.Error()))
|
|
|
}
|
|
|
data := strings.Trim(resp.String(), `"`)
|
|
|
logkit.Info("pdmPushProcess:" + cryptokit.Decrypt(data))
|
|
|
}
|
|
|
|
|
|
// businessKey=remandId,taskId=id
|
|
|
func goPdmEntrustEdit(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.NewGoPdmEntrustEdit(businessKey, processInstId, taskId)
|
|
|
resp, err := client.R().
|
|
|
SetHeaders(header).Get(config.UrlPrefix + "/zjgd/frm/pdmEntrustController/goPdmEntrustEdit?businessKey=" + query.BusinessKey + "&processInstanceId=" + query.ProcessInstanceId + "&taskDefinitionKey=" + query.TaskDefinitionKey + "&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()
|
|
|
}
|
|
|
|
|
|
// businessKey=remandId
|
|
|
func getRemandIdSJKR(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 + "/JSFAWT/" + id + "/ZH_KR") //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()
|
|
|
}
|