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" ) /* http://10.202.2.108:8086/zjgd/frm/acceptanceController/udpateAccInfo.action */ /* 用途 1、updateAccInfo入参 */ //tip 工建能写出这么多form参数的的程序员,也是个人才,不能用json吗?我真服了你! type UpdateAccInfo 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"` Ranstr string `map:"ranstr"` Timestamp string `map:"timestamp"` } // NewUpdateAccInfo remandId=businessKey func NewUpdateAccInfo(token, remandId, html1, html2 string) *UpdateAccInfo { updateAccInfo := new(UpdateAccInfo) updateAccInfo.AccId = util.RegexpFindFirst(html1, `"accId":"([^"]+)"`) updateAccInfo.Token = token updateAccInfo.RemandId = remandId updateAccInfo.RemandCode = util.RegexpFindFirst(html1, `"remandCode":"([^"]+)"`) updateAccInfo.IsSplitedRemand = util.RegexpFindFirst(html1, `"isSplitedRemand":"([^"]+)"`) updateAccInfo.IsCross = util.HTMLContentFindFirst(html1, "isCross") updateAccInfo.InvestmentConfigId = util.HTMLContentFindFirst(html1, "investmentConfigId") updateAccInfo.IsGrid = util.HTMLContentFindFirst(html1, "isGrid") updateAccInfo.GridId = util.HTMLContentFindFirst(html1, "gridId") updateAccInfo.AttachGrid = util.HTMLContentFindFirst(html1, "attachGrid") updateAccInfo.ResourceGridOrg = util.HTMLContentFindFirst(html1, "resourceGridOrg") updateAccInfo.RemandCreateBy = util.HTMLContentFindFirst(html1, "remandCreateBy") updateAccInfo.BuildAttr = util.HTMLContentFindFirst(html1, "buildAttr") updateAccInfo.BussCode = util.HTMLContentFindFirst(html1, "bussCode") updateAccInfo.Prov = util.HTMLContentFindFirst(html1, "prov") updateAccInfo.City = util.HTMLContentFindFirst(html1, "city") updateAccInfo.County = util.HTMLContentFindFirst(html1, "county") updateAccInfo.LinkCode = util.HTMLContentFindFirst(html1, "linkCode") updateAccInfo.SpecC = util.HTMLContentFindFirst(html1, "specC") updateAccInfo.IsBd = util.HTMLContentFindFirst(html1, "isBd") updateAccInfo.ProcessInstId = util.HTMLContentFindFirst(html1, "processInstId") updateAccInfo.RemandName = util.RegexpFindFirst(html1, `"remandName":"([^"]+)"`) updateAccInfo.ProjectName = util.HTMLContentFindFirst(html2, "projectName") updateAccInfo.ProjectCode = util.HTMLContentFindFirst(html2, "projectCode") updateAccInfo.RemandCreateName = util.HTMLContentFindFirst(html2, "remandCreateName") updateAccInfo.RemandTouzi = util.HTMLContentFindFirst(html2, "remandTouzi") updateAccInfo.ProjectManagerName = util.HTMLContentFindFirst(html2, "projectManagerName") updateAccInfo.RemandCreatedDate = util.HTMLContentFindFirst(html2, "remandCreatedDate") updateAccInfo.PdmCreatedName = util.HTMLContentFindFirst(html2, "pdmCreatedName") updateAccInfo.PdmCreatedDate = util.HTMLContentFindFirst(html2, "pdmCreatedDate") updateAccInfo.ReplyDate = util.HTMLContentFindFirst(html2, "replyDate") updateAccInfo.ReplyInvestment = util.HTMLContentFindFirst(html2, "replyInvestment") updateAccInfo.ActStartDate = util.HTMLContentFindFirst(html2, "actStartDate") updateAccInfo.ActOrgName = util.HTMLContentFindFirst(html2, "actOrgName") updateAccInfo.ActFinishDate = util.HTMLContentFindFirst(html2, "actFinishDate") updateAccInfo.AccApplyDesc = util.HTMLContentFindFirst(html1, "accApplyDesc") updateAccInfo.EquipCost = util.RegexpFindFirst(html1, `"equipCost":(\d+(\.\d+)?)`) updateAccInfo.EnginCost = util.RegexpFindFirst(html1, `"enginCost":(\d+(\.\d+)?)`) updateAccInfo.SafetyProdCost = util.RegexpFindFirst(html1, `"safetyProdCost":(\d+(\.\d+)?)`) updateAccInfo.SurveyCost = util.RegexpFindFirst(html1, `"surveyCost":(\d+(\.\d+)?)`) updateAccInfo.SupervisionCost = util.RegexpFindFirst(html1, `"supervisionCost":(\d+(\.\d+)?)`) updateAccInfo.OtherCost = util.RegexpFindFirst(html1, `"otherCost":(\d+(\.\d+)?)`) updateAccInfo.AccInvestment = cast.ToString(mathkit.FloatRound(cast.ToFloat64(updateAccInfo.EquipCost)+cast.ToFloat64(updateAccInfo.EnginCost)+cast.ToFloat64(updateAccInfo.SafetyProdCost)+cast.ToFloat64(updateAccInfo.SurveyCost)+cast.ToFloat64(updateAccInfo.SupervisionCost)+cast.ToFloat64(updateAccInfo.OtherCost), 2)) updateAccInfo.IsInstall = "ALL" updateAccInfo.PasteCode = "1" updateAccInfo.OnuLightWane = "DOWN" updateAccInfo.WorkAcc = "1" updateAccInfo.MaterialAcc = "1" updateAccInfo.IsTestSpeed = "1" updateAccInfo.UserRate = "1000" updateAccInfo.TestSpeedAcc = "1" updateAccInfo.BuildingNum = util.RegexpFindFirst(html1, `"buildingNum":(\d+(\.\d+)?)`) updateAccInfo.PortNum = util.RegexpFindFirst(html1, `"portNum":(\d+(\.\d+)?)`) updateAccInfo.InstallNum = util.RegexpFindFirst(html1, `"installNum":(\d+(\.\d+)?)`) updateAccInfo.UnconditionalInstall = "ALL" updateAccInfo.IsRecordAll = "1" updateAccInfo.ResourcesAcc = "1" updateAccInfo.BeamasPlitter = "1" updateAccInfo.OtherNetworkResource = "" //updateAccInfo.DoubleExcellent = "0" //是否双优 updateAccInfo.IsSupClock = "0" updateAccInfo.NotClockName = "无需" updateAccInfo.NotClockDesc = "无需" updateAccInfo.PassOrNo = "1" updateAccInfo.RadioName0 = "on" updateAccInfo.RecordReason = "" updateAccInfo.RadioName1 = "on" updateAccInfo.RadioName2 = "on" updateAccInfo.RadioName3 = "on" updateAccInfo.LeavRadio = "1" updateAccInfo.AccRemainingProb = "" updateAccInfo.AccConfirmDesc = "" updateAccInfo.Ranstr = cryptokit.RandomStr(true, 10, 32) updateAccInfo.Timestamp = cryptokit.GetTimeStamp() return updateAccInfo } // GenReqParam 返回加密后的请求参数 func (th *UpdateAccInfo) GenReqParam() map[string]string { th.encrypt() return th.structToMap() } func (th *UpdateAccInfo) 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 *UpdateAccInfo) 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())) } } }