update: con-eng-con-sys
parent
96323a5305
commit
eb97fb305d
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
type Ctx struct {
|
||||
Data *gjson.Result
|
||||
RestyClient *resty.Client
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"cu-helper/cus-eng-con-sys/cryptokit"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
/*
|
||||
/zjgd/frm/projectServiceResultController/searchProjectList
|
||||
*/
|
||||
|
||||
/*
|
||||
用途
|
||||
1、方案确认之前通过项目编码查找projectId
|
||||
*/
|
||||
|
||||
type SearchProjectList struct {
|
||||
StaffOrgId string `map:"staffOrgId"`
|
||||
ProjectCode string `map:"projectCode"`
|
||||
Ranstr string `map:"ranstr"`
|
||||
Timestamp string `map:"timestamp"`
|
||||
}
|
||||
|
||||
func NewSearchProjectList(projectCode string) *SearchProjectList {
|
||||
searchProjectList := new(SearchProjectList)
|
||||
searchProjectList.StaffOrgId = "3102427"
|
||||
searchProjectList.ProjectCode = projectCode
|
||||
searchProjectList.Ranstr = cryptokit.RandomStr(true, 10, 32)
|
||||
searchProjectList.Timestamp = cryptokit.GetTimeStamp()
|
||||
return searchProjectList
|
||||
}
|
||||
|
||||
// GenReqParam 返回加密后的请求参数
|
||||
func (th *SearchProjectList) GenReqParam() map[string]string {
|
||||
th.encrypt()
|
||||
return th.structToMap()
|
||||
}
|
||||
|
||||
func (th *SearchProjectList) structToMap() map[string]string {
|
||||
result := make(map[string]string)
|
||||
t := reflect.TypeOf(*th)
|
||||
v := reflect.ValueOf(*th)
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
field := t.Field(i)
|
||||
value := v.Field(i)
|
||||
// Use the tag value as the key in the map, if it exists; otherwise, use the field name.
|
||||
tag := field.Tag.Get("map")
|
||||
if tag == "" {
|
||||
tag = field.Name
|
||||
}
|
||||
result[tag] = value.String()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (th *SearchProjectList) encrypt() {
|
||||
v := reflect.ValueOf(th).Elem()
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
field := v.Field(i)
|
||||
if field.CanSet() {
|
||||
field.SetString(cryptokit.Encrypt(field.String()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// businessKey=remandId
|
||||
func getRemandId(ctx *model.Ctx) string {
|
||||
processInstanceId := ctx.Data.Get("processInstanceId").String()
|
||||
id := ctx.Data.Get("id").String()
|
||||
processDefinitionKey := ctx.Data.Get("processDefinitionKey").String()
|
||||
taskDefinitionKey := ctx.Data.Get("taskDefinitionKey").String()
|
||||
businessCode := findLinkBusinessCode(ctx)
|
||||
client := ctx.RestyClient
|
||||
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
||||
header := h.GenReqParam()
|
||||
f := model.NewCommonForm()
|
||||
form := f.GenReqParam()
|
||||
resp, err := client.R().
|
||||
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/workflowrest/tasktodopath/" + processDefinitionKey + "/" + processInstanceId + "/" + taskDefinitionKey + "/" + id + "/" + businessCode)
|
||||
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 projectStartComplete(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/actInfoController/projectStartComplete?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()
|
||||
}
|
||||
|
||||
func findLinkBusinessCode(ctx *model.Ctx) string {
|
||||
processInstanceId := ctx.Data.Get("processInstanceId").String()
|
||||
encryptedProcessInsId := cryptokit.Encrypt(processInstanceId)
|
||||
client := ctx.RestyClient
|
||||
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
||||
header := h.GenReqParam()
|
||||
f := model.NewCommonForm()
|
||||
form := f.GenReqParam()
|
||||
resp, err := client.R().
|
||||
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/workflow/findLinkBusscode?processInstanceId=" + encryptedProcessInsId)
|
||||
if err != nil {
|
||||
panic(exception.New(err.Error()))
|
||||
}
|
||||
data := strings.Trim(resp.String(), `"`)
|
||||
return gjson.Get(cryptokit.Decrypt(data), "BUSS_CODE").String()
|
||||
}
|
||||
@ -0,0 +1,137 @@
|
||||
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/configkit"
|
||||
"github.com/mizuki1412/go-core-kit/service/logkit"
|
||||
"github.com/tidwall/gjson"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ReqDesignScheme 方案确认请求
|
||||
/*
|
||||
验收确认分两个步骤进行
|
||||
1、通过项目编号找到projectId
|
||||
2、查项目剩余投资是否符合
|
||||
3、绑定需求至项目
|
||||
4、提交方案确认
|
||||
*/
|
||||
|
||||
func ReqDesignScheme(ctx *model.Ctx) {
|
||||
projId := getProjectId(ctx)
|
||||
touzi := checkProjInvest(ctx, projId)
|
||||
modifyProject(ctx, projId, touzi)
|
||||
passflow(ctx)
|
||||
}
|
||||
|
||||
func getProjectId(ctx *model.Ctx) string {
|
||||
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
||||
header := h.GenReqParam()
|
||||
f := model.NewSearchProjectList(getDefaultProjCode(ctx))
|
||||
form := f.GenReqParam()
|
||||
client := ctx.RestyClient
|
||||
resp, err := client.R().
|
||||
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/projectServiceResultController/searchProjectList")
|
||||
if err != nil {
|
||||
panic(exception.New(err.Error()))
|
||||
}
|
||||
dataOri := strings.Trim(resp.String(), `"`)
|
||||
data := gjson.Get(cryptokit.Decrypt(dataOri), "data").Array()
|
||||
if len(data) == 0 {
|
||||
panic(exception.New("无该项目信息"))
|
||||
}
|
||||
return data[0].Get("projectId").String()
|
||||
}
|
||||
|
||||
func getDefaultProjCode(ctx *model.Ctx) string {
|
||||
processDefinitionName := ctx.Data.Get("processDefinitionName").String()
|
||||
switch processDefinitionName {
|
||||
case "公众客户宽带扩容":
|
||||
if code := configkit.GetString(config.EngDefaultProjKRCode, ""); code != "" {
|
||||
return code
|
||||
}
|
||||
panic(exception.New("公众客户宽带扩容项目编号未设置"))
|
||||
case "公众客户宽带新建市场":
|
||||
if code := configkit.GetString(config.EngDefaultProjXQCode, ""); code != "" {
|
||||
return code
|
||||
}
|
||||
panic(exception.New("公众客户宽带新建市场(小区新建)项目编号未设置"))
|
||||
case "政企客户接入(本地、省际跨域)":
|
||||
if code := configkit.GetString(config.EngDefaultProjLXCode, ""); code != "" {
|
||||
return code
|
||||
}
|
||||
panic(exception.New("政企客户接入(本地、省际跨域)(零星)项目编号未设置"))
|
||||
case "政企客户覆盖":
|
||||
if code := configkit.GetString(config.EngDefaultProjLYCode, ""); code != "" {
|
||||
return code
|
||||
}
|
||||
panic(exception.New("政企客户覆盖(楼宇新建)项目编号未设置"))
|
||||
default:
|
||||
panic(exception.New("未设置相应专业默认项目编码,无法关联项目!"))
|
||||
}
|
||||
}
|
||||
|
||||
func checkProjInvest(ctx *model.Ctx, projId string) string {
|
||||
remandId := getRemandId(ctx)
|
||||
processDefKey := ctx.Data.Get("processDefinitionKey").String()
|
||||
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
||||
header := h.GenReqParam()
|
||||
f := model.NewGetProjInvest(projId, remandId, processDefKey, getDefaultProjCode(ctx))
|
||||
form := f.GenReqParam()
|
||||
client := ctx.RestyClient
|
||||
resp, err := client.R().
|
||||
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/projectServiceResultController/getProjectSurplseInvestmentByProjectId.action")
|
||||
if err != nil {
|
||||
panic(exception.New(err.Error()))
|
||||
}
|
||||
dataOri := strings.Trim(resp.String(), `"`)
|
||||
data := cryptokit.Decrypt(dataOri)
|
||||
if !gjson.Get(data, "success").Bool() {
|
||||
panic(exception.New("需求投资可能大于项目剩余金额!"))
|
||||
}
|
||||
touzi := gjson.Get(data, "attributes.remandTouzi").String()
|
||||
logkit.Info("checkProjInvest:" + data)
|
||||
return touzi
|
||||
}
|
||||
|
||||
func modifyProject(ctx *model.Ctx, projId, touzi string) {
|
||||
remandId := getRemandId(ctx)
|
||||
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
||||
header := h.GenReqParam()
|
||||
f := model.NewModifyRemandProj(remandId, projId, touzi)
|
||||
form := f.GenReqParam()
|
||||
client := ctx.RestyClient
|
||||
resp, err := client.R().
|
||||
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/projectServiceResultController/modifyRemandProjectIdByRemandId.action")
|
||||
if err != nil {
|
||||
panic(exception.New(err.Error()))
|
||||
}
|
||||
dataOri := strings.Trim(resp.String(), `"`)
|
||||
data := cryptokit.Decrypt(dataOri)
|
||||
if !gjson.Get(data, "success").Bool() {
|
||||
panic(exception.New("项目关联失败!"))
|
||||
}
|
||||
logkit.Info("modifyProject:" + data)
|
||||
}
|
||||
|
||||
func passflow(ctx *model.Ctx) {
|
||||
processInsId := ctx.Data.Get("processInstanceId").String()
|
||||
taskId := ctx.Data.Get("id").String()
|
||||
processDefKey := ctx.Data.Get("processDefinitionKey").String()
|
||||
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
||||
header := h.GenReqParam()
|
||||
f := model.NewDesignSchemePassflow(processInsId, taskId, processDefKey)
|
||||
form := f.GenReqParam()
|
||||
client := ctx.RestyClient
|
||||
resp, err := client.R().
|
||||
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/designSchemeController/passFlow.action")
|
||||
if err != nil {
|
||||
panic(exception.New(err.Error()))
|
||||
}
|
||||
dataOri := strings.Trim(resp.String(), `"`)
|
||||
data := cryptokit.Decrypt(dataOri)
|
||||
logkit.Info("degisnSchemePassflow:" + data)
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
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)
|
||||
}
|
||||
Loading…
Reference in New Issue