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.

232 lines
10 KiB
Go

package model
import (
"cu-helper/cus-eng-con-sys/cryptokit"
"cu-helper/cus-eng-con-sys/util"
"github.com/mizuki1412/go-core-kit/library/mathkit"
"github.com/spf13/cast"
"reflect"
)
/*
/zjgd/frm/acceptanceComfirmController/pushProcess.action
*/
/*
用途
PushProcess
*/
//tip 工建能写出这么多form参数的的程序员,也是个人才,不能用json吗?我真服了你!
type PushProcess struct {
AccId string `map:"accId"`
Token string `map:"token"`
RemandId string `map:"remandId"`
RemandCode string `map:"remandCode"`
IsSplitedRemand string `map:"isSplitedRemand"`
IsCross string `map:"isCross"`
InvestmentConfigId string `map:"investmentConfigId"`
IsGrid string `map:"isGrid"`
GridId string `map:"gridId"`
AttachGrid string `map:"attachGrid"`
ResourceGridOrg string `map:"resourceGridOrg"`
RemandCreateBy string `map:"remandCreateBy"`
BuildAttr string `map:"buildAttr"`
BussCode string `map:"bussCode"`
Prov string `map:"prov"`
City string `map:"city"`
County string `map:"county"`
LinkCode string `map:"linkCode"`
SpecC string `map:"specC"`
IsBd string `map:"isBd"`
ProcessInstId string `map:"processInstId"`
RemandName string `map:"remandName"`
ProjectName string `map:"projectName"`
ProjectCode string `map:"projectCode"`
RemandCreateName string `map:"remandCreateName"`
RemandTouzi string `map:"remandTouzi"`
ProjectManagerName string `map:"projectManagerName"`
RemandCreatedDate string `map:"remandCreatedDate"`
PdmCreatedName string `map:"pdmCreatedName"`
PdmCreatedDate string `map:"pdmCreatedDate"`
ReplyDate string `map:"replyDate"`
ReplyInvestment string `map:"replyInvestment"`
ActStartDate string `map:"actStartDate"`
ActOrgName string `map:"actOrgName"`
ActFinishDate string `map:"actFinishDate"`
AccApplyDesc string `map:"accApplyDesc"`
EquipCost string `map:"equipCost"`
EnginCost string `map:"enginCost"`
SafetyProdCost string `map:"safetyProdCost"`
SurveyCost string `map:"surveyCost"`
SupervisionCost string `map:"supervisionCost"`
OtherCost string `map:"otherCost"`
AccInvestment string `map:"accInvestment"`
IsInstall string `map:"isInstall"`
PasteCode string `map:"pasteCode"`
OnuLightWane string `map:"onuLightWane"`
WorkAcc string `map:"workAcc"`
MaterialAcc string `map:"materialAcc"`
IsTestSpeed string `map:"isTestSpeed"`
UserRate string `map:"userRate"`
TestSpeedAcc string `map:"testSpeedAcc"`
BuildingNum string `map:"buildingNum"`
PortNum string `map:"portNum"`
InstallNum string `map:"installNum"`
UnconditionalInstall string `map:"unconditionalInstall"`
IsRecordAll string `map:"isRecordAll"`
ResourcesAcc string `map:"resourcesAcc"`
BeamasPlitter string `map:"beamasPlitter"`
OtherNetworkResource string `map:"otherNetworkResource"`
//DoubleExcellent string `map:"doubleExcellent"` //是否双优
IsSupClock string `map:"isSupClock"`
NotClockName string `map:"notClockName"`
NotClockDesc string `map:"notClockDesc"`
PassOrNo string `map:"passOrNo"`
RadioName0 string `map:"radioName_0"`
RecordReason string `map:"recordReason"`
RadioName1 string `map:"radioName_1"`
RadioName2 string `map:"radioName_2"`
RadioName3 string `map:"radioName_3"`
LeavRadio string `map:"leavRadio"`
AccRemainingProb string `map:"accRemainingProb"`
AccConfirmDesc string `map:"accConfirmDesc"`
//最后全部点完后,验收确认多几个参数
TaskDefinitionKey string `map:"taskDefinitionKey"`
BusinessKey string `map:"businessKey"`
Comment string `map:"comment"`
Assignee string `map:"assignee"`
ProcessInstanceId string `map:"processInstanceId"`
TaskId string `map:"taskId"`
HandleType string `map:"handleType"`
Withdraw string `map:"withdraw"`
IndInfo string `map:"indInfo"`
//最后全部点完后,验收确认多几个参数
Ranstr string `map:"ranstr"`
Timestamp string `map:"timestamp"`
}
// NewPushProcess remandId=businessKey
func NewPushProcess(taskId, token, remandId, html1, html2 string) *PushProcess {
pushProcess := new(PushProcess)
pushProcess.AccId = util.RegexpFindFirst(html1, `"accId":"([^"]+)"`)
pushProcess.Token = token
pushProcess.RemandId = remandId
pushProcess.RemandCode = util.RegexpFindFirst(html1, `"remandCode":"([^"]+)"`)
pushProcess.IsSplitedRemand = util.RegexpFindFirst(html1, `"isSplitedRemand":"([^"]+)"`)
pushProcess.IsCross = util.HTMLContentFindFirst(html1, "isCross")
pushProcess.InvestmentConfigId = util.HTMLContentFindFirst(html1, "investmentConfigId")
pushProcess.IsGrid = util.HTMLContentFindFirst(html1, "isGrid")
pushProcess.GridId = util.HTMLContentFindFirst(html1, "gridId")
pushProcess.AttachGrid = util.HTMLContentFindFirst(html1, "attachGrid")
pushProcess.ResourceGridOrg = util.HTMLContentFindFirst(html1, "resourceGridOrg")
pushProcess.RemandCreateBy = util.HTMLContentFindFirst(html1, "remandCreateBy")
pushProcess.BuildAttr = util.HTMLContentFindFirst(html1, "buildAttr")
pushProcess.BussCode = util.HTMLContentFindFirst(html1, "bussCode")
pushProcess.Prov = util.HTMLContentFindFirst(html1, "prov")
pushProcess.City = util.HTMLContentFindFirst(html1, "city")
pushProcess.County = util.HTMLContentFindFirst(html1, "county")
pushProcess.LinkCode = util.HTMLContentFindFirst(html1, "linkCode")
pushProcess.SpecC = util.HTMLContentFindFirst(html1, "specC")
pushProcess.IsBd = util.HTMLContentFindFirst(html1, "isBd")
pushProcess.ProcessInstId = util.HTMLContentFindFirst(html1, "processInstId")
pushProcess.RemandName = util.RegexpFindFirst(html1, `"remandName":"([^"]+)"`)
pushProcess.ProjectName = util.HTMLContentFindFirst(html2, "projectName")
pushProcess.ProjectCode = util.HTMLContentFindFirst(html2, "projectCode")
pushProcess.RemandCreateName = util.HTMLContentFindFirst(html2, "remandCreateName")
pushProcess.RemandTouzi = util.HTMLContentFindFirst(html2, "remandTouzi")
pushProcess.ProjectManagerName = util.HTMLContentFindFirst(html2, "projectManagerName")
pushProcess.RemandCreatedDate = util.HTMLContentFindFirst(html2, "remandCreatedDate")
pushProcess.PdmCreatedName = util.HTMLContentFindFirst(html2, "pdmCreatedName")
pushProcess.PdmCreatedDate = util.HTMLContentFindFirst(html2, "pdmCreatedDate")
pushProcess.ReplyDate = util.HTMLContentFindFirst(html2, "replyDate")
pushProcess.ReplyInvestment = util.HTMLContentFindFirst(html2, "replyInvestment")
pushProcess.ActStartDate = util.HTMLContentFindFirst(html2, "actStartDate")
pushProcess.ActOrgName = util.HTMLContentFindFirst(html2, "actOrgName")
pushProcess.ActFinishDate = util.HTMLContentFindFirst(html2, "actFinishDate")
pushProcess.AccApplyDesc = util.HTMLContentFindFirst(html1, "accApplyDesc")
pushProcess.EquipCost = util.RegexpFindFirst(html1, `"equipCost":(\d+(\.\d+)?)`)
pushProcess.EnginCost = util.RegexpFindFirst(html1, `"enginCost":(\d+(\.\d+)?)`)
pushProcess.SafetyProdCost = util.RegexpFindFirst(html1, `"safetyProdCost":(\d+(\.\d+)?)`)
pushProcess.SurveyCost = util.RegexpFindFirst(html1, `"surveyCost":(\d+(\.\d+)?)`)
pushProcess.SupervisionCost = util.RegexpFindFirst(html1, `"supervisionCost":(\d+(\.\d+)?)`)
pushProcess.OtherCost = util.RegexpFindFirst(html1, `"otherCost":(\d+(\.\d+)?)`)
pushProcess.AccInvestment = cast.ToString(mathkit.FloatRound(cast.ToFloat64(pushProcess.EquipCost)+cast.ToFloat64(pushProcess.EnginCost)+cast.ToFloat64(pushProcess.SafetyProdCost)+cast.ToFloat64(pushProcess.SurveyCost)+cast.ToFloat64(pushProcess.SupervisionCost)+cast.ToFloat64(pushProcess.OtherCost), 2))
pushProcess.IsInstall = "ALL"
pushProcess.PasteCode = "1"
pushProcess.OnuLightWane = "DOWN"
pushProcess.WorkAcc = "1"
pushProcess.MaterialAcc = "1"
pushProcess.IsTestSpeed = "1"
pushProcess.UserRate = "1000"
pushProcess.TestSpeedAcc = "1"
pushProcess.BuildingNum = util.RegexpFindFirst(html1, `"buildingNum":(\d+(\.\d+)?)`)
pushProcess.PortNum = util.RegexpFindFirst(html1, `"portNum":(\d+(\.\d+)?)`)
pushProcess.InstallNum = util.RegexpFindFirst(html1, `"installNum":(\d+(\.\d+)?)`)
pushProcess.UnconditionalInstall = "ALL"
pushProcess.IsRecordAll = "1"
pushProcess.ResourcesAcc = "1"
pushProcess.BeamasPlitter = "1"
pushProcess.OtherNetworkResource = ""
//pushProcess.DoubleExcellent = "0" //是否双优
pushProcess.IsSupClock = "0"
pushProcess.NotClockName = "无需"
pushProcess.NotClockDesc = "无需"
pushProcess.PassOrNo = "1"
pushProcess.RadioName0 = "on"
pushProcess.RecordReason = ""
pushProcess.RadioName1 = "on"
pushProcess.RadioName2 = "on"
pushProcess.RadioName3 = "on"
pushProcess.LeavRadio = "1"
pushProcess.AccRemainingProb = ""
pushProcess.AccConfirmDesc = ""
pushProcess.TaskDefinitionKey = "endevent1"
pushProcess.BusinessKey = util.RegexpFindFirst(html1, `"accId":"([^"]+)"`)
pushProcess.Comment = "完成"
pushProcess.Assignee = ""
pushProcess.ProcessInstanceId = util.HTMLContentFindFirst(html1, "processInstId")
pushProcess.TaskId = taskId
pushProcess.HandleType = "1"
pushProcess.Withdraw = "0"
pushProcess.IndInfo = ""
pushProcess.Ranstr = cryptokit.RandomStr(true, 10, 32)
pushProcess.Timestamp = cryptokit.GetTimeStamp()
return pushProcess
}
// GenReqParam 返回加密后的请求参数
func (th *PushProcess) GenReqParam() map[string]string {
th.encrypt()
return th.structToMap()
}
func (th *PushProcess) 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 *PushProcess) 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()))
}
}
}