package model import ( "cu-helper/cus-eng-con-sys/config" "cu-helper/cus-eng-con-sys/cryptokit" "reflect" ) /* /zjgd/frm/actInfoController/startActFinishProcess */ /* 用途:完工确认 */ type FinishActProcess struct { ProcessInstanceId string `map:"processInstanceId"` TaskId string `map:"taskId"` TaskDefinitionKey string `map:"taskDefinitionKey"` Assignee string `map:"assignee"` Comment string `map:"comment"` HandleType string `map:"handleType"` Withdraw string `map:"withdraw"` Ranstr string `map:"ranstr"` Timestamp string `map:"timestamp"` } func NewFinishActProcess(proInsId, taskId, assigneeId, processDefinitionKey string) *FinishActProcess { finishActProcess := new(FinishActProcess) finishActProcess.ProcessInstanceId = proInsId finishActProcess.TaskId = taskId switch processDefinitionKey { case config.ProcessHouse: finishActProcess.TaskDefinitionKey = "ZYLR" finishActProcess.Assignee = "3106207" //张滋豪 写死 finishActProcess.Comment = "请进行资源录入" case config.ProcessLX: finishActProcess.TaskDefinitionKey = "YSSQ" finishActProcess.Assignee = assigneeId finishActProcess.Comment = "请发起验收申请" } finishActProcess.HandleType = "1" finishActProcess.Withdraw = "0" finishActProcess.Ranstr = cryptokit.RandomStr(true, 10, 32) finishActProcess.Timestamp = cryptokit.GetTimeStamp() return finishActProcess } // GenReqParam 返回加密后的请求参数 func (th *FinishActProcess) GenReqParam() map[string]string { th.encrypt() return th.structToMap() } func (th *FinishActProcess) 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 *FinishActProcess) 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())) } } }