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.

80 lines
3.0 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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/mizuki1412/go-core-kit/class/exception"
"github.com/mizuki1412/go-core-kit/service/logkit"
"strings"
)
// PdmEntrust 设计委托请求
/*
设计委托分三个步骤进行
1、判断是否change监理先省略看看有没有问题
2、先获取信息再更新表单信息新建可以省略零星不建议走
3、提交设计委托
*/
func ReqPdmEntrust(ctx *model.Ctx) {
if ctx.Data.Get("processDefinitionName").String() == "公众客户宽带扩容" {
//扩容单
updatePdmProduction(ctx)
}
pdmPushProcess(ctx)
}
func updatePdmProduction(ctx *model.Ctx) {
touzi := ctx.Data.Get("touzi").String()
taskTitle := ctx.Data.Get("tasktitle").String()
remandId := getRemandId(ctx)
html := goPdmEntrustEdit(ctx, remandId)
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
header := h.GenReqParam()
f := model.NewUpdatePdmProduction(touzi, remandId, html, taskTitle)
form := f.GenReqParam()
client := ctx.RestyClient
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(ctx *model.Ctx) {
processInstanceId := ctx.Data.Get("processInstanceId").String()
taskId := ctx.Data.Get("id").String()
taskTitle := ctx.Data.Get("tasktitle").String()
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
header := h.GenReqParam()
f := model.NewPDMPushProcess(processInstanceId, taskId, taskTitle)
form := f.GenReqParam()
client := ctx.RestyClient
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(ctx *model.Ctx, businessKey string) string {
processInstId := ctx.Data.Get("processInstanceId").String()
taskId := ctx.Data.Get("id").String()
client := ctx.RestyClient
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 + "&timestamp=" + query.Timestamp + "&_=" + query.TimestampPro)
if err != nil {
panic(exception.New(err.Error()))
}
return resp.String()
}