Compare commits

..

No commits in common. "e2f4afc79988738a5062d25e3e55f201f147d82f" and "8ec2db4f58ab60bd10d2a3dda2ad0d2c58bd84f5" have entirely different histories.

6 changed files with 33 additions and 38 deletions

View File

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

View File

@ -19,8 +19,7 @@ type Option struct {
} `yaml:"uDesk"`
VolumePath string `yaml:"volumePath"`
FileServer struct {
Address string `yaml:"address"`
Preservation int `yaml:"preservation"`
Address string `yaml:"address"`
} `yaml:"fileServer"`
ModelConf struct {
API string `yaml:"api"`
@ -71,7 +70,6 @@ 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

@ -1,8 +1,8 @@
uDesk:
filters:
- filter7d: "16523464"
- filter14d: "16523814"
macros:
filters:
- filter7d: "16523464"
- filter14d: "16523814"
macros:
- "您好,我们的客服已尝试就此问题联系您,但尚未收到您的回复,如需进一步帮助,请您及时联系我们,谢谢。"
- "您好,您反馈的问题正在处理当中,有任何进展这边第一时间跟您同步,请您耐心等待,十分感谢。"
- "您好,您反馈的问题已分配任务给工程师,请您耐心等待,稍后工程师将尽快进行处理,感谢您的等待与理解。"
@ -19,8 +19,7 @@ uDesk:
- "您好非常抱歉当前工单处于排队处理状态已与您沟通XX点处理该问题感谢您的理解请您耐心等待~"
volumePath: "/data/"
fileServer:
address: "http://43.143.245.135:233/"
preservation: 4
address: "http://10.0.8.7:233/"
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, int) {
func Id2CloudId(id string) string {
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, int) {
}
jsonData := string(body)
cloudId := gjson.Get(jsonData, "ticket.custom_fields.TextField_219254").String()
return cloudId, resp.StatusCode
return cloudId
}
//获取上周到上上周的工单

View File

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

View File

@ -81,29 +81,23 @@ func (e *Excel) SetReplyContent() *Excel {
repliesContentSlice := tools.ReverseSlice(s)
repliesContentSlice = tools.RemoveNewlineElements(repliesContentSlice)
//跳过没有回复内容的工单。
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
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 {
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])
}
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
}
log.Printf("goroutine%v结束\n", j)
@ -128,7 +122,7 @@ func (e *Excel) CreateNewExcel() { // 示例的 map
}
// 在第一行,第一列写入标题
err = f.SetCellValue("Sheet1", "A1", "工单id或UDeskid")
err = f.SetCellValue("Sheet1", "A1", "工单id")
if err != nil {
log.Println("写入A1标题失败错误是", err)
return
@ -160,11 +154,11 @@ func (e *Excel) CreateNewExcel() { // 示例的 map
f.SetActiveSheet(index)
// 保存 Excel 文件
if err := f.SaveAs(e.ExcelName); err != nil {
if err := f.SaveAs(ExcelName); err != nil {
log.Fatal(err)
}
wd, _ := os.Getwd()
relPath := filepath.Join(wd, e.ExcelName)
relPath := filepath.Join(wd, ExcelName)
absPath, err := filepath.Abs(relPath)
if err != nil {
log.Printf("获取excel路径失败错误是:%v", err)