From f95d55a8d23aabd392df7301bcd6f71d9e90ec8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 8 Jan 2024 10:35:33 +0800 Subject: [PATCH] 1 --- business/jxstore/cms/api_print.go | 28 +----------- business/jxstore/cms/temp.go | 76 +++++++++++++++++++++++++++++++ business/jxutils/jxutils_cms.go | 8 ++++ business/model/dao/dao_print.go | 2 - controllers/job_controller.go | 2 +- 5 files changed, 87 insertions(+), 29 deletions(-) diff --git a/business/jxstore/cms/api_print.go b/business/jxstore/cms/api_print.go index ad8b71b55..72c41ca0b 100644 --- a/business/jxstore/cms/api_print.go +++ b/business/jxstore/cms/api_print.go @@ -333,7 +333,7 @@ func DelPrinterSeq(appID int, printNo string) (err error) { if printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0); len(printers) == 0 { return fmt.Errorf("该应用下未找到该打印机!print_no : %v", printNo) } else { - printMsgs, _ := dao.GetPrintMsgs(db, printNo, "", model.PrintMsgAll, model.PrintMsgSuccess) + printMsgs, _ := dao.GetPrintMsgs2(db, printNo, "", model.PrintMsgAll, model.PrintMsgSuccess) for _, v := range printMsgs { v.DeletedAt = time.Now() if _, err = dao.UpdateEntity(db, v, "DeletedAt"); err != nil { @@ -399,7 +399,7 @@ func GetPrintMsg(appID int, msgID string) (printMsg *GetPrintMsgResult, err erro var ( db = dao.GetDB() ) - if printMsgs, _ := dao.GetPrintMsgs(db, "", msgID, model.PrintMsgAll, model.PrintMsgAll); len(printMsgs) > 0 { + if printMsgs, _ := dao.GetPrintMsgs2(db, "", msgID, model.PrintMsgAll, model.PrintMsgAll); len(printMsgs) > 0 { result := printMsgs[0] printMsg = &GetPrintMsgResult{ MsgID: result.MsgID, @@ -441,27 +441,3 @@ func GetPrinterStatus(appID int, printNo string) (status int, err error) { //return status, nil } } - -func connHandler(c net.Conn, printInfo *PrintInfo) (status int) { - defer c.Close() - //缓冲 - buf := make([]byte, 1024) - data, _ := json.Marshal(printInfo) - //写入数据 - c.Write(data) - //服务器端返回的数据写入buf - n, _ := c.Read(buf) - status = utils.Str2Int(string(buf[:n])) - //服务器端回传的信息 - fmt.Println("server response:", string(buf[:n])) - return status -} - -//#region 打印机拼装模板 - -// QueryPrinterSetting 查询用户设置 -func QueryPrinterSetting() { - -} - -//#endregion 打印机 diff --git a/business/jxstore/cms/temp.go b/business/jxstore/cms/temp.go index 5d2ac294f..073261f6c 100644 --- a/business/jxstore/cms/temp.go +++ b/business/jxstore/cms/temp.go @@ -1 +1,77 @@ package cms + +import ( + "encoding/json" + "fmt" + "git.rosy.net.cn/baseapi/utils" + "net" + "os" +) + +var ( + textChan chan string +) + +func TestTemp2() { + server := "127.0.0.1:8000" + tcpAddr, err := net.ResolveTCPAddr("tcp4", server) + if err != nil { + fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error()) + os.Exit(1) + } + conn, err := net.DialTCP("tcp", nil, tcpAddr) + if err != nil { + fmt.Println("Dial err:", err) + return + } + textChan = make(chan string, 10) + connHandler2(conn) +} + +func connHandler2(c net.Conn) { + //接收终端输入 + //reader := bufio.NewReader(os.Stdin) + //缓冲 + //buf := make([]byte, 1024) + fmt.Println("Please input data...") + go func() { + for { + //读取终端输入直到读取到\n + //input, err := reader.ReadString('\n') + //if err != nil { + // fmt.Println("ReadString err:", err) + // return + //} + s := <-textChan + //写入数据 + n, err := c.Write([]byte(s)) + if err != nil { + fmt.Println("Write err:", err, n) + return + } + //服务器端返回的数据写入buf + //cnt, err := c.Read(buf) + //if err != nil { + // fmt.Println("Read err:", err) + // return + //} + //服务器端回传的信息 + //fmt.Println("server response:", string(buf[0:cnt])) + } + }() +} + +func connHandler(c net.Conn, printInfo *PrintInfo) (status int) { + defer c.Close() + //缓冲 + buf := make([]byte, 1024) + data, _ := json.Marshal(printInfo) + //写入数据 + c.Write(data) + //服务器端返回的数据写入buf + n, _ := c.Read(buf) + status = utils.Str2Int(string(buf[:n])) + //服务器端回传的信息 + fmt.Println("server response:", string(buf[:n])) + return status +} diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index 86233cf57..421ee3999 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -461,3 +461,11 @@ func CalcPolygonAreaAutonavi(points [][2]float64) (area float64) { d += eee*point[1]*c - k*g2 return 0.5 * math.Abs(d) / float64(1000000) } + +func BuildErr(errs []error) (err error) { + var errStr = strings.Builder{} + for _, v := range errs { + errStr.WriteString(v.Error()) + } + return fmt.Errorf(errStr.String()) +} diff --git a/business/model/dao/dao_print.go b/business/model/dao/dao_print.go index 785274315..c7e8900ec 100644 --- a/business/model/dao/dao_print.go +++ b/business/model/dao/dao_print.go @@ -2,7 +2,6 @@ package dao import ( "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/globals" "time" @@ -63,7 +62,6 @@ func GetPrintMsg2(db *DaoDB, printNo, msgID string, status, statusNeq int) (prin FROM print_msg WHERE 1 = 1 AND deleted_at = ? ` - jxutils.CallMsgHandler() sqlParams := []interface{}{ utils.DefaultTimeValue, } diff --git a/controllers/job_controller.go b/controllers/job_controller.go index 389d97479..88d46e624 100644 --- a/controllers/job_controller.go +++ b/controllers/job_controller.go @@ -561,7 +561,7 @@ func (c *JobController) TempJob() { // @router /TempJobTest [post] func (c *JobController) TempJobTest() { c.callTempJobTest(func(params *tJobTempJobTestParams) (retVal interface{}, errCode string, err error) { - cms.TestTemp2(params.Data) + cms.TestTemp2() return retVal, "", err }) }