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" "github.com/tidwall/gjson" "strings" ) // ReqStartAct 工程开工请求 /* 工程开工分两个步骤进行 1、saveActInfo 2、updateActInfoOrgAndStaff 3、startActProcess */ func ReqStartAct(ctx *model.Ctx) { actId := saveActInfo(ctx) updateActInfoOrgAndStaff(ctx, actId) startActProcess(ctx) } func saveActInfo(ctx *model.Ctx) string { businessKey := getRemandId(ctx) html := projectStartComplete(ctx, businessKey) h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") header := h.GenReqParam() f := model.NewSaveActInfo(html) form := f.GenReqParam() client := ctx.RestyClient resp, err := client.R(). SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/actInfoController/saveActInfo") if err != nil { panic(exception.New(err.Error())) } dataOri := strings.Trim(resp.String(), `"`) data := cryptokit.Decrypt(dataOri) logkit.Info("saveActInfo:" + data) actId := gjson.Get(data, "ans").String() return actId } func updateActInfoOrgAndStaff(ctx *model.Ctx, actId string) { h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") header := h.GenReqParam() f := model.NewUpdateActInfoOrgAndStaff(actId) form := f.GenReqParam() client := ctx.RestyClient resp, err := client.R(). SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/actInfoController/updateActInfoOrgAndStaff") if err != nil { panic(exception.New(err.Error())) } data := strings.Trim(resp.String(), `"`) logkit.Info("updateActInfoOrgAndStaff:" + cryptokit.Decrypt(data)) } func startActProcess(ctx *model.Ctx) { processInsId := ctx.Data.Get("processInstanceId").String() taskId := ctx.Data.Get("id").String() h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8") header := h.GenReqParam() f := model.NewStartActProcess(processInsId, taskId) form := f.GenReqParam() client := ctx.RestyClient resp, err := client.R(). SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/actInfoController/startActProcess") if err != nil { panic(exception.New(err.Error())) } dataOri := strings.Trim(resp.String(), `"`) data := cryptokit.Decrypt(dataOri) logkit.Info("startActProcess:" + data) }