|
|
@@ -20,11 +20,11 @@ import (
|
|
|
)
|
|
|
|
|
|
type ActivitiService struct {
|
|
|
- BaseUrl string
|
|
|
- AposeUrl string
|
|
|
- OriginUrl string
|
|
|
- Username string
|
|
|
- Password string
|
|
|
+ BaseUrl string
|
|
|
+ AposeUrl string
|
|
|
+ OriginUrl string
|
|
|
+ Username string
|
|
|
+ Password string
|
|
|
ServiceBase
|
|
|
}
|
|
|
|
|
|
@@ -32,12 +32,12 @@ func GetActivitiService(xormEngine *xorm.Engine) *ActivitiService {
|
|
|
s := new(ActivitiService)
|
|
|
s.DBE = xormEngine
|
|
|
//s.BaseUrl = "http://123.56.168.26:8080/activiti-rest/service"
|
|
|
- //s.BaseUrl = "http://192.168.0.167:8081/api/acti"
|
|
|
- s.BaseUrl = "http://47.92.212.59:8080/acti-api/api/acti"
|
|
|
+ //s.BaseUrl = "http://192.168.0.120:8081/api/acti"
|
|
|
+ s.BaseUrl = utils.Cfg.MustValue("workflow", "BaseUrl")
|
|
|
//s.BaseUrl = "http://localhost:8081/api/acti"
|
|
|
- s.AposeUrl = "http://47.92.212.59:8080/acti-api/api/apose"
|
|
|
+ s.AposeUrl = utils.Cfg.MustValue("workflow", "AposeUrl")
|
|
|
//s.OriginUrl = "http://localhost:8081/api"
|
|
|
- s.OriginUrl = "http://47.92.212.59:8080/acti-api/api"
|
|
|
+ s.OriginUrl = utils.Cfg.MustValue("workflow", "OriginUrl")
|
|
|
//s.AposeUrl = "http://localhost:8081/api/apose"
|
|
|
//s.AposeUrl = "http://192.168.0.171:8081/api/apose"
|
|
|
s.Username = "leader"
|
|
|
@@ -117,6 +117,31 @@ func (this *ActivitiService) StartProcess(processKey string, formEntityId string
|
|
|
return string(p)
|
|
|
}
|
|
|
|
|
|
+func (this *ActivitiService) StartProcess2(processKey, formEntityId, userNames, result, supplierType, supplierName string) string {
|
|
|
+ /*vars := make(map[string]string)
|
|
|
+ vars["processDefinitionKey"] = processKey
|
|
|
+ vars["formEntityId"] = formEntityId*/
|
|
|
+ /*params := "processDefinitionKey="+processKey+"&formEntityId"+formEntityId*/
|
|
|
+ var ActiProcess ActiProcessVM
|
|
|
+ ActiProcess.ProcessKey = processKey
|
|
|
+ ActiProcess.BusinessKey = formEntityId
|
|
|
+ ActiProcess.UserNames = userNames
|
|
|
+ ActiProcess.Result = result
|
|
|
+ ActiProcess.WfType = supplierType
|
|
|
+ ActiProcess.SupplierName = supplierName
|
|
|
+
|
|
|
+ json, err := json.Marshal(ActiProcess)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(json)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/start-process-bytype", params, "")
|
|
|
+ p, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ return string(p)
|
|
|
+}
|
|
|
+
|
|
|
func (this *ActivitiService) TaskComplete(processKey string, formEntityId string, userNames string, userId string, result string, remarks string) string {
|
|
|
|
|
|
var ActiComplete ActiCompleteVM
|
|
|
@@ -138,6 +163,46 @@ func (this *ActivitiService) TaskComplete(processKey string, formEntityId string
|
|
|
return string(p)
|
|
|
}
|
|
|
|
|
|
+func (this *ActivitiService) TaskComplete2(ActiComplete ActiCompleteVM) string {
|
|
|
+
|
|
|
+ jsonParams, err := json.Marshal(ActiComplete)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParams)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/task-complete", params, "")
|
|
|
+ p, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ return string(p)
|
|
|
+}
|
|
|
+
|
|
|
+/*func (this *ActivitiService) MultiTaskComplete(processKey string, formEntityId string, userNames string, multiOrgAudits []MultiOrgAuditVM, userId string, result string, remarks string, callbackUrl string) string {
|
|
|
+
|
|
|
+var ActiComplete MultiActiCompleteVM
|
|
|
+ActiComplete.ProcessKey = processKey
|
|
|
+ActiComplete.BusinessKey = formEntityId
|
|
|
+ActiComplete.UserNames = userNames
|
|
|
+ActiComplete.MultiOrgAudits = multiOrgAudits
|
|
|
+ActiComplete.UserId = userId
|
|
|
+ActiComplete.Result = result
|
|
|
+ActiComplete.Remarks = remarks
|
|
|
+ActiComplete.CallbackUrl = callbackUrl*/
|
|
|
+
|
|
|
+func (this *ActivitiService) MultiTaskComplete(ActiComplete MultiActiCompleteVM) string {
|
|
|
+
|
|
|
+ jsonParams, err := json.Marshal(ActiComplete)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParams)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/multi-task-complete", params, "")
|
|
|
+ p, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ return string(p)
|
|
|
+}
|
|
|
+
|
|
|
func (this *ActivitiService) GetMyTasks(processKey string, userId string) string {
|
|
|
var ActiMyTasks ActiMyTasksVM
|
|
|
ActiMyTasks.ProcessKey = processKey
|
|
|
@@ -155,6 +220,91 @@ func (this *ActivitiService) GetMyTasks(processKey string, userId string) string
|
|
|
return string(p)
|
|
|
}
|
|
|
|
|
|
+func (this *ActivitiService) GetMyTasksWithTime(processKey string, userId string) []ActiMyTasksRetWithTimeVM {
|
|
|
+ var ActiMyTasks ActiMyTasksVM
|
|
|
+ ActiMyTasks.ProcessKey = processKey
|
|
|
+ ActiMyTasks.UserId = userId
|
|
|
+ jsonParam, err := json.Marshal(ActiMyTasks)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParam)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/my-tasks-with-time", params, "")
|
|
|
+
|
|
|
+ p, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ myTasksRetWithTimes := make([]ActiMyTasksRetWithTimeVM, 0)
|
|
|
+ json.Unmarshal(p, &myTasksRetWithTimes)
|
|
|
+ return myTasksRetWithTimes
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (this *ActivitiService) GetMyFinishedTasksWithTime(processKey string, userId string) []ActiMyTasksRetWithTimeVM {
|
|
|
+ var ActiMyTasks ActiMyTasksVM
|
|
|
+ ActiMyTasks.ProcessKey = processKey
|
|
|
+ ActiMyTasks.UserId = userId
|
|
|
+ jsonParam, err := json.Marshal(ActiMyTasks)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParam)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/my-finished-tasks-with-time", params, "")
|
|
|
+
|
|
|
+ p, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ myTasksRetWithTimes := make([]ActiMyTasksRetWithTimeVM, 0)
|
|
|
+ json.Unmarshal(p, &myTasksRetWithTimes)
|
|
|
+ return myTasksRetWithTimes
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ActivitiService) GetMyAllTypePagingTasksWithTime(userId string, PageIndex, PageSize int64, wfName, wfType, supplierName string) ActiMyPagingResultVM {
|
|
|
+ var myPagingTasks ActiMyPagingTasksVM
|
|
|
+ myPagingTasks.UserId = userId
|
|
|
+ myPagingTasks.PageIndex = PageIndex
|
|
|
+ myPagingTasks.PageSize = PageSize
|
|
|
+ myPagingTasks.WfName = wfName
|
|
|
+ myPagingTasks.WfType = wfType
|
|
|
+ myPagingTasks.SupplierName = supplierName
|
|
|
+ jsonParam, err := json.Marshal(myPagingTasks)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParam)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/my-all-type-paging-tasks-with-time", params, "")
|
|
|
+
|
|
|
+ p, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ var myTasksRetWithTimes ActiMyPagingResultVM
|
|
|
+ json.Unmarshal(p, &myTasksRetWithTimes)
|
|
|
+ return myTasksRetWithTimes
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ActivitiService) GetMyAllTypePagingFinishedTasksWithTime(userId string, PageIndex, PageSize int64, wfName, wfType, supplierName string) ActiMyPagingResultVM {
|
|
|
+ var myPagingTasks ActiMyPagingTasksVM
|
|
|
+ myPagingTasks.UserId = userId
|
|
|
+ myPagingTasks.PageIndex = PageIndex
|
|
|
+ myPagingTasks.PageSize = PageSize
|
|
|
+ myPagingTasks.WfName = wfName
|
|
|
+ myPagingTasks.WfType = wfType
|
|
|
+ myPagingTasks.SupplierName = supplierName
|
|
|
+ jsonParam, err := json.Marshal(myPagingTasks)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParam)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/my-all-type-paging-finished-tasks-with-time", params, "")
|
|
|
+
|
|
|
+ p, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ var myTasksRetWithTimes ActiMyPagingResultVM
|
|
|
+ json.Unmarshal(p, &myTasksRetWithTimes)
|
|
|
+ return myTasksRetWithTimes
|
|
|
+}
|
|
|
+
|
|
|
func (this *ActivitiService) GetHistoricTasks(processKey string, businessKey string, processInstanceId string) []ActiHistoricTask {
|
|
|
var ActiProcess ActiProcessVM
|
|
|
ActiProcess.ProcessKey = processKey
|
|
|
@@ -175,6 +325,26 @@ func (this *ActivitiService) GetHistoricTasks(processKey string, businessKey str
|
|
|
return historicTasks
|
|
|
}
|
|
|
|
|
|
+func (this *ActivitiService) GetHistoricMultiTasks(processKey string, businessKey string, processInstanceId string) []ActiHistoricTask {
|
|
|
+ var ActiProcess ActiProcessVM
|
|
|
+ ActiProcess.ProcessKey = processKey
|
|
|
+ ActiProcess.BusinessKey = businessKey
|
|
|
+ ActiProcess.ProcessInstanceId = processInstanceId
|
|
|
+ jsonParam, err := json.Marshal(ActiProcess)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParam)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/historic-multi-tasks", params, "")
|
|
|
+ jsonblob, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ // var historicTasks []ActiHistoricTask
|
|
|
+ historicTasks := make([]ActiHistoricTask, 0)
|
|
|
+ json.Unmarshal(jsonblob, &historicTasks)
|
|
|
+ return historicTasks
|
|
|
+}
|
|
|
+
|
|
|
func (this *ActivitiService) GetActivitiProccessImage(processInstanceId string) []byte {
|
|
|
var ActiProcess ActiProcessVM
|
|
|
ActiProcess.ProcessInstanceId = processInstanceId
|
|
|
@@ -206,6 +376,24 @@ func (this *ActivitiService) GetHistoryMyTasks(processKey string, userId string)
|
|
|
return string(p)
|
|
|
}
|
|
|
|
|
|
+func (this *ActivitiService) GetAllMyTasks(processKey string, userId string) string {
|
|
|
+ var ActiMyTasks ActiMyTasksVM
|
|
|
+ ActiMyTasks.ProcessKey = processKey
|
|
|
+ ActiMyTasks.UserId = userId
|
|
|
+ json, err := json.Marshal(ActiMyTasks)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(json)
|
|
|
+ fmt.Println(params)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post("/my-tasks-finished", params, "")
|
|
|
+ p, _ := ioutil.ReadAll(retVal.Body)
|
|
|
+ retVal2 := this.Post("/my-tasks", params, "")
|
|
|
+ p2, _ := ioutil.ReadAll(retVal2.Body)
|
|
|
+ return string(p) + "," + string(p2)
|
|
|
+}
|
|
|
+
|
|
|
func (this *ActivitiService) ExcelToPdf(addressUrl string) string {
|
|
|
var aposeVM AposeVM
|
|
|
aposeVM.AddressUrl = addressUrl
|
|
|
@@ -300,6 +488,53 @@ func (this *ActivitiService) WordToPdf(addressUrl string) string {
|
|
|
return retDocUrl
|
|
|
}
|
|
|
|
|
|
+func (this *ActivitiService) WordToPdfWithWatermark(wartermark, addressUrl string) string {
|
|
|
+ var aposeVM AposeVM
|
|
|
+ aposeVM.AddressUrl = addressUrl
|
|
|
+ aposeVM.Watermark = wartermark
|
|
|
+ fmt.Println("==addressUrl===", addressUrl)
|
|
|
+ jsonParam, err := json.Marshal(aposeVM)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParam)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.Post2("/word-to-pdf-watermark", params, "")
|
|
|
+ if retVal.StatusCode != 200 {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ //pdfByte, err := ioutil.ReadAll(retVal.Body)
|
|
|
+ //ioutil.WriteFile("E:\aa.pdf", pdfByte, 777)
|
|
|
+ //模板下载到服务器
|
|
|
+ _dir := utils.Cfg.MustValue("file", "tmplateDir") + "pdf"
|
|
|
+ utils.CreatePath(_dir)
|
|
|
+ _dir += "/tmp_" + strconv.Itoa(int(time.Now().Unix())) + ".pdf"
|
|
|
+ raw := retVal.Body
|
|
|
+ defer raw.Close()
|
|
|
+
|
|
|
+ file, err := os.Create(_dir)
|
|
|
+ defer file.Close()
|
|
|
+ writer := bufio.NewWriter(file)
|
|
|
+ defer writer.Flush()
|
|
|
+ body, err := ioutil.ReadAll(raw)
|
|
|
+ writer.Write(body)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ var sw *Seaweed
|
|
|
+ var filer []string
|
|
|
+ if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
|
|
|
+ filer = []string{_filer}
|
|
|
+ }
|
|
|
+ sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
|
|
|
+ //_, fID, err := sw.Upload(retVal.Body, "tmp.pdf", int64(len(pdfByte)), "", "")
|
|
|
+ _, _, fID, err := sw.UploadFile(_dir, "", "")
|
|
|
+ retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
|
|
|
+ os.Remove(_dir)
|
|
|
+ fmt.Println("==retDocUrl==", retDocUrl)
|
|
|
+ return retDocUrl
|
|
|
+}
|
|
|
|
|
|
func (this *ActivitiService) FillWordTemplate(datas map[string]interface{}, templateUrl string, fileName string) string {
|
|
|
var wordTempVM WordTemplateVM
|
|
|
@@ -349,3 +584,55 @@ func (this *ActivitiService) FillWordTemplate(datas map[string]interface{}, temp
|
|
|
fmt.Println("==retDocUrl==", retDocUrl)
|
|
|
return retDocUrl
|
|
|
}
|
|
|
+
|
|
|
+// 带水印
|
|
|
+func (this *ActivitiService) FillWordWatermarkTemplate(datas map[string]interface{}, templateUrl string, fileName,watermark string) string {
|
|
|
+ var wordTempVM WordTemplateWatermarkVM
|
|
|
+ wordTempVM.Datas = datas
|
|
|
+ wordTempVM.TemplateUrl = templateUrl
|
|
|
+ wordTempVM.FileName = fileName
|
|
|
+ wordTempVM.Watermark = watermark
|
|
|
+
|
|
|
+ fmt.Println("==templateWatermarkUrl===", templateUrl)
|
|
|
+ jsonParam, err := json.Marshal(wordTempVM)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err, "生成json字符串错误")
|
|
|
+ }
|
|
|
+ params := string(jsonParam)
|
|
|
+ //token = Authorization(this.Username, this.Password)
|
|
|
+ retVal := this.PostOrigin("/word/fill-word-watermark", params, "")
|
|
|
+ if retVal.StatusCode != 200 {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ //pdfByte, err := ioutil.ReadAll(retVal.Body)
|
|
|
+ //ioutil.WriteFile("E:\aa.pdf", pdfByte, 777)
|
|
|
+ //模板下载到服务器
|
|
|
+ _dir := utils.Cfg.MustValue("file", "tmplateDir") + "word"
|
|
|
+ utils.CreatePath(_dir)
|
|
|
+ _dir += "/tmp_" + strconv.Itoa(int(time.Now().Unix())) + ".docx"
|
|
|
+ raw := retVal.Body
|
|
|
+ defer raw.Close()
|
|
|
+
|
|
|
+ file, err := os.Create(_dir)
|
|
|
+ defer file.Close()
|
|
|
+ writer := bufio.NewWriter(file)
|
|
|
+ defer writer.Flush()
|
|
|
+ body, err := ioutil.ReadAll(raw)
|
|
|
+ writer.Write(body)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ var sw *Seaweed
|
|
|
+ var filer []string
|
|
|
+ if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
|
|
|
+ filer = []string{_filer}
|
|
|
+ }
|
|
|
+ sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
|
|
|
+ //_, fID, err := sw.Upload(retVal.Body, "tmp.pdf", int64(len(pdfByte)), "", "")
|
|
|
+ _, _, fID, err := sw.UploadFile(_dir, "", "")
|
|
|
+ retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
|
|
|
+ os.Remove(_dir)
|
|
|
+ fmt.Println("==retDocWatermarkUrl==", retDocUrl)
|
|
|
+ return retDocUrl
|
|
|
+}
|