Compare commits
2 Commits
8ec2db4f58
...
e2f4afc799
Author | SHA1 | Date |
---|---|---|
Your Name | e2f4afc799 | |
Your Name | e89aab5d6a |
|
@ -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()
|
||||
|
|
|
@ -19,7 +19,8 @@ type Option struct {
|
|||
} `yaml:"uDesk"`
|
||||
VolumePath string `yaml:"volumePath"`
|
||||
FileServer struct {
|
||||
Address string `yaml:"address"`
|
||||
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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
uDesk:
|
||||
filters:
|
||||
- filter7d: "16523464"
|
||||
- filter14d: "16523814"
|
||||
macros:
|
||||
filters:
|
||||
- filter7d: "16523464"
|
||||
- filter14d: "16523814"
|
||||
macros:
|
||||
- "您好,我们的客服已尝试就此问题联系您,但尚未收到您的回复,如需进一步帮助,请您及时联系我们,谢谢。"
|
||||
- "您好,您反馈的问题正在处理当中,有任何进展这边第一时间跟您同步,请您耐心等待,十分感谢。"
|
||||
- "您好,您反馈的问题已分配任务给工程师,请您耐心等待,稍后工程师将尽快进行处理,感谢您的等待与理解。"
|
||||
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
//获取上周到上上周的工单
|
||||
|
|
|
@ -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: "",
|
||||
|
|
|
@ -81,24 +81,30 @@ func (e *Excel) SetReplyContent() *Excel {
|
|||
|
||||
repliesContentSlice := tools.ReverseSlice(s)
|
||||
repliesContentSlice = tools.RemoveNewlineElements(repliesContentSlice)
|
||||
repliesContentSlice = tools.AddNewlineToEachElement(repliesContentSlice)
|
||||
|
||||
//工单id转换为cloudid
|
||||
cloudId := filter.Id2CloudId(v)
|
||||
if cloudId == "" {
|
||||
contentMap[v] = repliesContentSlice
|
||||
log.Printf("goroutine%v:回复内容处理完成,工单id(非cloudid是%v\n)", j, v)
|
||||
log.Printf("goroutine%v:UdeskId为:%v,内容为:%v\n", j, v, contentMap[v])
|
||||
} else {
|
||||
contentMap[cloudId] = repliesContentSlice
|
||||
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
|
||||
}
|
||||
repliesContentSlice = tools.AddNewlineToEachElement(repliesContentSlice)
|
||||
|
||||
//工单id转换为cloudid
|
||||
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)
|
||||
log.Printf("goroutine%v:UdeskId为:%v,内容为:%v\n", j, v, contentMap[v])
|
||||
} else {
|
||||
contentMap[cloudId] = repliesContentSlice
|
||||
log.Printf("goroutine%v:回复内容处理完成,工单id(cloudid是%v\n)", j, cloudId)
|
||||
log.Printf("goroutine%v:cloudId为:%v,内容为:%v\n", j, cloudId, contentMap[cloudId])
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("goroutine%v结束\n", j)
|
||||
}(v, 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)
|
||||
|
|
Loading…
Reference in New Issue