package model import ( "cu-helper/cus-eng-con-sys/config" "cu-helper/cus-eng-con-sys/cryptokit" "cu-helper/cus-eng-con-sys/util" "reflect" ) /* /zjgd/frm/acceptanceController/pushProcess.action */ /* 用途 验收申请流程推送 */ //tip 工建能写出这么多form参数的的程序员,也是个人才,不能用json吗?我真服了你! type AccApplyPushProcess struct { AccId string `map:"accId"` Token string `map:"token"` RemandId string `map:"remandId"` IsSplitedRemand string `map:"isSplitedRemand"` AccRecordId string `map:"accRecordId"` BuildModel string `map:"buildModel"` DisType string `map:"disType"` SpecC string `map:"specC"` IsBd string `map:"isBd"` IsGKOrder string `map:"isGKOrder"` 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"` 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"` Back string `map:"back"` Ranstr string `map:"ranstr"` Timestamp string `map:"timestamp"` } // NewAccApplyPushProcess remandId=businessKey func NewAccApplyPushProcess(token, remandId, processInstanceId, taskId, html1, html2, assignee, processDefinitionKey string) *AccApplyPushProcess { accApplyPushProcess := new(AccApplyPushProcess) accApplyPushProcess.AccId = util.RegexpFindFirst(html1, `"accId":"([^"]+)"`) accApplyPushProcess.Token = token accApplyPushProcess.RemandId = remandId accApplyPushProcess.IsSplitedRemand = util.RegexpFindFirst(html1, `"isSplitedRemand":"([^"]+)"`) accApplyPushProcess.AccRecordId = util.HTMLContentFindFirst(html1, "accRecordId") accApplyPushProcess.BuildModel = util.RegexpFindFirst(html1, `"buildModel":"([^"]+)"`) accApplyPushProcess.DisType = util.RegexpFindFirst(html1, `"disType":"([^"]+)"`) accApplyPushProcess.SpecC = util.HTMLContentFindFirst(html1, "specC") accApplyPushProcess.IsBd = util.HTMLContentFindFirst(html1, "isBd") switch processDefinitionKey { case config.ProcessHouse: accApplyPushProcess.IsGKOrder = util.HTMLContentFindFirst(html1, "isGKOrder") case config.ProcessLX: //零星没有这个参数 } accApplyPushProcess.RemandName = util.RegexpFindFirst(html1, `"remandName":"([^"]+)"`) accApplyPushProcess.ProjectName = util.HTMLContentFindFirst(html2, "projectName") accApplyPushProcess.ProjectCode = util.HTMLContentFindFirst(html2, "projectCode") accApplyPushProcess.RemandCreateName = util.HTMLContentFindFirst(html2, "remandCreateName") accApplyPushProcess.RemandTouzi = util.HTMLContentFindFirst(html2, "remandTouzi") accApplyPushProcess.ProjectManagerName = util.HTMLContentFindFirst(html2, "projectManagerName") accApplyPushProcess.RemandCreatedDate = util.HTMLContentFindFirst(html2, "remandCreatedDate") accApplyPushProcess.PdmCreatedName = util.HTMLContentFindFirst(html2, "pdmCreatedName") accApplyPushProcess.PdmCreatedDate = util.HTMLContentFindFirst(html2, "pdmCreatedDate") accApplyPushProcess.ReplyDate = util.HTMLContentFindFirst(html2, "replyDate") accApplyPushProcess.ReplyInvestment = util.HTMLContentFindFirst(html2, "replyInvestment") accApplyPushProcess.ActStartDate = util.HTMLContentFindFirst(html2, "actStartDate") accApplyPushProcess.ActOrgName = util.HTMLContentFindFirst(html2, "actOrgName") accApplyPushProcess.ActFinishDate = util.HTMLContentFindFirst(html2, "actFinishDate") accApplyPushProcess.AccApplyDesc = util.HTMLContentFindFirst(html1, "accApplyDesc") accApplyPushProcess.TaskDefinitionKey = "YSQR" accApplyPushProcess.BusinessKey = accApplyPushProcess.AccId accApplyPushProcess.Comment = "请确认" accApplyPushProcess.Assignee = assignee accApplyPushProcess.ProcessInstanceId = processInstanceId accApplyPushProcess.TaskId = taskId accApplyPushProcess.HandleType = "1" accApplyPushProcess.Withdraw = "1" accApplyPushProcess.Back = "0" accApplyPushProcess.Ranstr = cryptokit.RandomStr(true, 10, 32) accApplyPushProcess.Timestamp = cryptokit.GetTimeStamp() return accApplyPushProcess } // GenReqParam 返回加密后的请求参数 func (th *AccApplyPushProcess) GenReqParam() map[string]string { th.encrypt() return th.structToMap() } func (th *AccApplyPushProcess) 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 *AccApplyPushProcess) 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())) } } }