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.
138 lines
4.9 KiB
Go
138 lines
4.9 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/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)
|
|
}
|