Compare commits

...

2 Commits

Author SHA1 Message Date
Your Name e2f4afc799 BUG 2024-06-01 23:48:32 +08:00
Your Name e89aab5d6a BUG 2024-06-01 23:48:00 +08:00
6 changed files with 39 additions and 34 deletions

View File

@ -46,7 +46,8 @@ _/ ____\______ ____ _____ _____ ____ __ _ _______ ____ ____
}
func job() error {
excel := reply.NewExcelObj()
ExcelName := "weeklyReport" + time.Now().Format("2006-01-02") + "_" + time.Now().Format("15-04-05") + ".xlsx"
excel := reply.NewExcelObj(ExcelName)
excel.SetReplyContent().CreateNewExcel()
err := reply.CopyFile(excel.ExcelPath, option.VOLUMEPATH+excel.ExcelName)
if err != nil {
@ -61,15 +62,14 @@ func job() error {
if err != nil {
return err
}
if fileCount > 4 {
if fileCount > option.PRESERVATION {
cleanFile := tools.ReadFilename(option.VOLUMEPATH)
err := os.Remove(option.VOLUMEPATH + cleanFile)
if err != nil {
return err
}
}
remainder := fmt.Sprintf("文件同步完成,地址是%v稍后将发送ai分析结果%v", "http://43.143.245.135:233/"+excel.ExcelName, ">_<~")
remainder := fmt.Sprintf("文件同步完成,地址是%v稍后将发送ai分析结果%v", option.FILESERVER_ADDRESS+excel.ExcelName, ">_<~")
notifer.SendWechat(remainder)
result := aichat.NewAiReq(excel.ExcelAddress).StartChat(option.MODEL_API).PrepareWechatBody()

View File

@ -20,6 +20,7 @@ type Option struct {
VolumePath string `yaml:"volumePath"`
FileServer struct {
Address string `yaml:"address"`
Preservation int `yaml:"preservation"`
} `yaml:"fileServer"`
ModelConf struct {
API string `yaml:"api"`
@ -70,6 +71,7 @@ var (
UDSK_FILTER14D = loadALLOption().UDesk.Filters[1].Filter14D
UDESK_MACROS = loadALLOption().UDesk.Macros
FILESERVER_ADDRESS = loadALLOption().FileServer.Address
PRESERVATION = loadALLOption().FileServer.Preservation
VOLUMEPATH = loadALLOption().VolumePath
MODEL_API = loadALLOption().ModelConf.API
MODEL_TOKEN = loadALLOption().ModelConf.Token

View File

@ -19,7 +19,8 @@ uDesk:
- "您好非常抱歉当前工单处于排队处理状态已与您沟通XX点处理该问题感谢您的理解请您耐心等待~"
volumePath: "/data/"
fileServer:
address: "http://10.0.8.7:233/"
address: "http://43.143.245.135:233/"
preservation: 4
modelConf:
api: "http://10.0.8.7:8000/v1/chat/completions"
token: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyLWNlbnRlciIsImV4cCI6MTcyMzYyMTk1NywiaWF0IjoxNzE1ODQ1OTU3LCJqdGkiOiJjcDJybWg5a3FxNGxraGNqbTVtZyIsInR5cCI6InJlZnJlc2giLCJzdWIiOiJjbzU4anJxbG5sOTZlanF1czVnMCIsInNwYWNlX2lkIjoiY281OGpycWxubDk2ZWpxdXM1ZmciLCJhYnN0cmFjdF91c2VyX2lkIjoiY281OGpycWxubDk2ZWpxdXM1ZjAifQ.WNq2OH5egQKlnnuM4ygY2MjjmgsjhEOwHJdV7oQA66_mrHgGKluilcBuMZ5dMpClpAOnVY6wJ021dYHajzuInQ"

View File

@ -79,7 +79,7 @@ func LoopGetTicketId(totalPages *int64, filterId string) ([]string, error) {
//把udeskid转换为cloudid
func Id2CloudId(id string) string {
func Id2CloudId(id string) (string, int) {
detailUrl := auth.Geturlstring("https://servicecenter-alauda.udesk.cn/open_api_v1/tickets/detail?") + "&id=" + id
resp, err := http.Get(detailUrl)
if err != nil {
@ -96,7 +96,7 @@ func Id2CloudId(id string) string {
}
jsonData := string(body)
cloudId := gjson.Get(jsonData, "ticket.custom_fields.TextField_219254").String()
return cloudId
return cloudId, resp.StatusCode
}
//获取上周到上上周的工单

View File

@ -1,7 +1,5 @@
package reply
import "time"
//定义回复结构体。
type Reply struct {
@ -15,11 +13,9 @@ type Excel struct {
Reply //继承回复
}
var ExcelName = "weeklyReport" + time.Now().Format("2006-01-02") + ".xlsx"
// 创建新的回复结构体对象。
func NewExcelObj() *Excel {
func NewExcelObj(ExcelName string) *Excel {
return &Excel{
ExcelName: ExcelName,
ExcelPath: "",

View File

@ -81,10 +81,20 @@ func (e *Excel) SetReplyContent() *Excel {
repliesContentSlice := tools.ReverseSlice(s)
repliesContentSlice = tools.RemoveNewlineElements(repliesContentSlice)
//跳过没有回复内容的工单。
if len(repliesContentSlice) == 0 {
return
}
repliesContentSlice = tools.AddNewlineToEachElement(repliesContentSlice)
//工单id转换为cloudid
cloudId := filter.Id2CloudId(v)
L1:
cloudId, httpCode := filter.Id2CloudId(v)
if httpCode != http.StatusOK {
time.Sleep(time.Second * 10)
goto L1
} else {
if cloudId == "" {
contentMap[v] = repliesContentSlice
log.Printf("goroutine%v:回复内容处理完成工单id(非cloudid是%v\n)", j, v)
@ -94,10 +104,6 @@ func (e *Excel) SetReplyContent() *Excel {
log.Printf("goroutine%v:回复内容处理完成工单id(cloudid是%v\n)", j, cloudId)
log.Printf("goroutine%v:cloudId为%v,内容为:%v\n", j, cloudId, contentMap[cloudId])
}
//跳过没有回复内容的工单。
if len(repliesContentSlice) == 0 {
return
}
log.Printf("goroutine%v结束\n", j)
@ -122,7 +128,7 @@ func (e *Excel) CreateNewExcel() { // 示例的 map
}
// 在第一行,第一列写入标题
err = f.SetCellValue("Sheet1", "A1", "工单id")
err = f.SetCellValue("Sheet1", "A1", "工单id或UDeskid")
if err != nil {
log.Println("写入A1标题失败错误是", err)
return
@ -154,11 +160,11 @@ func (e *Excel) CreateNewExcel() { // 示例的 map
f.SetActiveSheet(index)
// 保存 Excel 文件
if err := f.SaveAs(ExcelName); err != nil {
if err := f.SaveAs(e.ExcelName); err != nil {
log.Fatal(err)
}
wd, _ := os.Getwd()
relPath := filepath.Join(wd, ExcelName)
relPath := filepath.Join(wd, e.ExcelName)
absPath, err := filepath.Abs(relPath)
if err != nil {
log.Printf("获取excel路径失败错误是:%v", err)