|
|
package service
|
|
|
|
|
|
import (
|
|
|
"cu-helper/cus-eng-con-sys/config"
|
|
|
"cu-helper/cus-eng-con-sys/cryptokit"
|
|
|
"cu-helper/cus-eng-con-sys/model"
|
|
|
"strings"
|
|
|
|
|
|
"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"
|
|
|
)
|
|
|
|
|
|
// ReqDesignScheme 方案确认请求
|
|
|
/*
|
|
|
验收确认分五个步骤进行
|
|
|
1、通过项目编号找到projectId
|
|
|
2、查项目剩余投资是否符合
|
|
|
3、绑定需求至项目
|
|
|
4、如果是政企零星还要此步骤,因为政企零星直接就工程开工了,需要从goDesignSchemeConfirm获取html信息,再modifyDesignSchemeLogInfo才能提交,不然会报错
|
|
|
5、提交方案确认
|
|
|
*/
|
|
|
|
|
|
func ReqDesignScheme(ctx *model.Ctx) {
|
|
|
projId := getProjectId(ctx)
|
|
|
touzi := checkProjInvest(ctx, projId)
|
|
|
modifyProject(ctx, projId, touzi)
|
|
|
if ctx.Data.Get("processDefinitionKey").String() == config.ProcessLX {
|
|
|
modDesignLogInfo(ctx)
|
|
|
}
|
|
|
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 modDesignLogInfo(ctx *model.Ctx) {
|
|
|
token := getToken(ctx.RestyClient)
|
|
|
remandId := getRemandId(ctx)
|
|
|
html := goDesignSchemeConfirm(ctx, remandId)
|
|
|
stepCode := cryptokit.Encrypt("JSTZ") //todo 零星需要这个 其他还未知
|
|
|
processDefinitionKey := cryptokit.Encrypt(ctx.Data.Get("processDefinitionKey").String())
|
|
|
h := model.NewHeader("application/x-www-form-urlencoded; charset=UTF-8")
|
|
|
header := h.GenReqParam()
|
|
|
f := model.NewModifyDesignSchemeLogInfo(token, html)
|
|
|
form := f.GenReqParam()
|
|
|
client := ctx.RestyClient
|
|
|
resp, err := client.R().
|
|
|
SetHeaders(header).SetFormData(form).Post(config.UrlPrefix + "/zjgd/frm/designSchemeController/modifyDesignSchemeLogInfo?stepCode=" + stepCode + "&processDefinitionKey=" + processDefinitionKey)
|
|
|
if err != nil {
|
|
|
panic(exception.New(err.Error()))
|
|
|
}
|
|
|
dataOri := strings.Trim(resp.String(), `"`)
|
|
|
data := cryptokit.Decrypt(dataOri)
|
|
|
logkit.Info("modDesignLogInfo:" + 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)
|
|
|
}
|
|
|
|
|
|
// businessKey=remandId,taskId=id
|
|
|
func goDesignSchemeConfirm(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/designSchemeController/goDesignSchemeConfirm?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()
|
|
|
}
|