- 修复处理飞鹅打印机错误消息的BUG

This commit is contained in:
gazebo
2019-07-17 09:32:58 +08:00
parent 05668962da
commit a05aefcef2

View File

@@ -158,21 +158,25 @@ func (a *API) PrinterAddList(printerList []*PrinterInfo) (ok, no map[string]stri
})
if err == nil {
resultMap := result.(map[string]interface{})
return interface2PrinterResultList4Add(resultMap["ok"]), interface2PrinterResultList4Add(resultMap["no"]), nil
return interface2PrinterResultList4Add(resultMap["ok"], true), interface2PrinterResultList4Add(resultMap["no"], false), nil
}
return nil, nil, err
}
func interface2PrinterResultList4Add(value interface{}) (printerResultMap map[string]string) {
func interface2PrinterResultList4Add(value interface{}, isOk bool) (printerResultMap map[string]string) {
printerResultMap = make(map[string]string)
for _, v := range value.([]interface{}) {
strList := strings.Split(v.(string), "#")
if len(strList) == 4 {
strList2 := strings.Split(strList[3], " ")
if len(strList2) == 1 {
strList2 = append(strList2, "")
if isOk {
strList2 := strings.Split(strList[3], " ")
if len(strList2) == 1 {
strList2 = append(strList2, "")
}
printerResultMap[strList[0]] = strList2[1]
} else {
printerResultMap[strList[0]] = strList[3]
}
printerResultMap[strList[0]] = strList2[1]
}
}
return printerResultMap