package model import ( "cu-helper/cus-eng-con-sys/cryptokit" "cu-helper/cus-eng-con-sys/util" "github.com/mizuki1412/go-core-kit/service/logkit" "reflect" ) /* http://10.202.2.108:8086/zjgd/frm/pdmProductionController/updatePdmProduction.action */ /* 用途 1、updatePdmProduction入参 */ type UpdatePdmProduction struct { RemandTouzi string `map:"remandTouzi"` RemandId string `map:"remandId"` BuildAttr string `map:"buildAttr"` PdmServiceProviderId string `map:"pdmServiceProviderId"` PdmProjReceiverId string `map:"pdmProjReceiverId"` BuildModel string `map:"buildModel"` GovEnterpId string `map:"govEnterpId"` ResourceType string `map:"resourceType"` IsNewNational string `map:"isNewNational"` SupervisorProviderId string `map:"supervisorProviderId"` SupervisorReceiverId string `map:"supervisorReceiverId"` Ranstr string `map:"ranstr"` Timestamp string `map:"timestamp"` } func NewUpdatePdmProduction(touzi, remandId, html, taskTitle string) *UpdatePdmProduction { updatePdmProduction := new(UpdatePdmProduction) remandTouzi := "" //json里没有投资数据,说明是主动发起的扩容,需要去正则匹配 if touzi == "" { remandTouzi = util.RegexpFindFirst(html, `(?:投资|约|大约)\s*(\d+(?:\.\d+)?)\s*元`) } else { remandTouzi = touzi } updatePdmProduction.RemandTouzi = remandTouzi updatePdmProduction.RemandId = remandId updatePdmProduction.BuildAttr = "PT" updatePdmProduction.PdmServiceProviderId = "1538321" //设计(可修改) updatePdmProduction.PdmProjReceiverId = "3083564" //设计(可修改) updatePdmProduction.BuildModel = "ZJ" updatePdmProduction.GovEnterpId = "" updatePdmProduction.ResourceType = "undefined" updatePdmProduction.IsNewNational = "0" updatePdmProduction.SupervisorProviderId = "309320681" //监理(可修改) updatePdmProduction.SupervisorReceiverId = "3098707" //监理(可修改) updatePdmProduction.Ranstr = cryptokit.RandomStr(true, 10, 32) updatePdmProduction.Timestamp = cryptokit.GetTimeStamp() logkit.Info(taskTitle + " 投资:" + remandTouzi + "元") return updatePdmProduction } // GenReqParam 返回加密后的请求参数 func (th *UpdatePdmProduction) GenReqParam() map[string]string { th.encrypt() return th.structToMap() } func (th *UpdatePdmProduction) 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 *UpdatePdmProduction) 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())) } } }