1
This commit is contained in:
@@ -162,6 +162,31 @@ func (t *TcpClient) changePrintMsg(data string, orderNo int64, printNo string) (
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//var (
|
||||||
|
// printClient = make(map[string]*TcpClient, 0)
|
||||||
|
// db = dao.GetDB()
|
||||||
|
// offset, pageSize = 0, 100
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//func init() {
|
||||||
|
// go func() {
|
||||||
|
// for {
|
||||||
|
// if time.Now().Unix()%2 != 0 {
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
// for printNo, PrintTcpClient := range printClient {
|
||||||
|
// if !PrintTcpClient.isExistMsg(printNo) {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }()
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
func (t *TcpClient) HandleTcpMessages(printNo string) {
|
func (t *TcpClient) HandleTcpMessages(printNo string) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
@@ -170,10 +195,8 @@ func (t *TcpClient) HandleTcpMessages(printNo string) {
|
|||||||
if !t.isExistMsg(printNo) {
|
if !t.isExistMsg(printNo) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-t.TimeoutMap[printNo]:
|
case <-t.TimeoutMap[printNo]:
|
||||||
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
||||||
@@ -253,13 +276,13 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
|||||||
close(t.TimeoutMap[key])
|
close(t.TimeoutMap[key])
|
||||||
} else {
|
} else {
|
||||||
if c != nil {
|
if c != nil {
|
||||||
encryption := ""
|
//encryption := ""
|
||||||
for _, v := range data {
|
//for _, v := range data {
|
||||||
encryption += fmt.Sprintf("%d", v)
|
// encryption += fmt.Sprintf("%d", v)
|
||||||
}
|
//}
|
||||||
printMsg.ContentEncryption = encryption
|
//printMsg.ContentEncryption = encryption
|
||||||
|
//
|
||||||
dao.UpdateEntity(db, printMsg, "ContentEncryption")
|
//dao.UpdateEntity(db, printMsg, "ContentEncryption")
|
||||||
if _, err = c.Write(data); err != nil {
|
if _, err = c.Write(data); err != nil {
|
||||||
globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err)
|
globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err)
|
||||||
//t.delConn(printMsg.PrintNo)
|
//t.delConn(printMsg.PrintNo)
|
||||||
|
|||||||
@@ -181,6 +181,12 @@ func (t *TcpClient) buildTimeoutMap(key string) {
|
|||||||
t.TimeoutMap[key] = dataChan
|
t.TimeoutMap[key] = dataChan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TcpClient) getTimeOut(key string) bool {
|
||||||
|
t.RLock()
|
||||||
|
defer t.RUnlock()
|
||||||
|
return <-t.TimeoutMap[key]
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TcpClient) buildAllMap(key string) {
|
func (t *TcpClient) buildAllMap(key string) {
|
||||||
t.Lock()
|
t.Lock()
|
||||||
defer t.Unlock()
|
defer t.Unlock()
|
||||||
@@ -402,7 +408,6 @@ func buildMsg(printMsg *model.PrintMsg) (data []byte, err error) {
|
|||||||
lenData := int64(len(str) + len(const1) + len(orderNoHexH) + len(orderNoHexL) + len(printInit) + 2 + 4 + len(printData))
|
lenData := int64(len(str) + len(const1) + len(orderNoHexH) + len(orderNoHexL) + len(printInit) + 2 + 4 + len(printData))
|
||||||
x1, x2 := int2h8l8(lenData / 2)
|
x1, x2 := int2h8l8(lenData / 2)
|
||||||
dataStr := str + x1 + x2 + const1 + orderNoHexH + orderNoHexL + printInit + printData
|
dataStr := str + x1 + x2 + const1 + orderNoHexH + orderNoHexL + printInit + printData
|
||||||
globals.SugarLogger.Debugf("============dataste %s", dataStr)
|
|
||||||
check := getCheckSum(dataStr)
|
check := getCheckSum(dataStr)
|
||||||
return jxutils.Hextob(dataStr + check), err
|
return jxutils.Hextob(dataStr + check), err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user