Selaa lähdekoodia

Merge branch 'master' of 192.168.30.132:MTP2.0/MTP20_IF

zhou.xiaoning 4 vuotta sitten
vanhempi
commit
5d3787d5f7

+ 7 - 0
controllers/other/cmdline.go

@@ -14,8 +14,10 @@ type CmdLine struct {
 
 // IsInit 是否初始化某项, item 某项, 如 oracle
 func (r *CmdLine) IsInit(item string) bool {
+	bInitFlag := false
 	for i, v := range r.OriCmd {
 		if v == "init" {
+			bInitFlag = true
 			// k := i + 1, 从init位置之后找参数
 			for k := i + 1; k < len(r.OriCmd); k++ {
 				if r.OriCmd[k] == item {
@@ -24,5 +26,10 @@ func (r *CmdLine) IsInit(item string) bool {
 			}
 		}
 	}
+
+	if !bInitFlag {
+		return true
+	}
+
 	return false
 }

+ 2 - 0
controllers/other/logfilelist.go

@@ -30,6 +30,8 @@ func LogList(c *gin.Context) {
 
 	const templateText = `
 <h1>go查询服务信息</h1>
+<a href="{{.host}}/debug/update" title="点击后从自动构建服务拉取版本升级并重启GO服务, 请谨慎点击" target="_blank">点击升级到最新版本</a>
+<p>===========================</p>
 version : {{.version}}<br>
 git hash: {{.githash}}<br>
 oracle : {{.db}} <br>

+ 84 - 0
controllers/other/update.go

@@ -0,0 +1,84 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/10/20 15:20
+* @Modify  : 2021/10/20 15:20
+* @Note    : 生成用于内网升级的.sh脚本
+ */
+
+package other
+
+import (
+	"github.com/gin-gonic/gin"
+	"net/http"
+	"os"
+	"os/exec"
+	"path/filepath"
+	"runtime"
+	"strings"
+)
+
+var IsUpdateing = false
+
+// MakeUpdateScript 生成脚本
+func MakeUpdateScript(c *gin.Context) {
+	if IsUpdateing {
+		c.String(http.StatusOK, "正在升级中...")
+		return
+	}
+
+	if runtime.GOOS == "windows" {
+		c.String(http.StatusOK, "windows不支持, 仅支持linux下执行")
+		return
+	}
+	IsUpdateing = true
+	defer func() {
+		IsUpdateing = false
+	}()
+
+	if createsh() {
+		c.String(http.StatusOK, "正在执行update.sh, 升级会保留原有的config.xml和cfg.json,且重启服务。稍后请在日志页面查看版本信息, 请勿刷新本页面。")
+		_ = exec.Command("sh", "./update.sh").Run()
+	} else {
+		c.String(http.StatusBadRequest, "创建脚本失败, 可能是权限不足")
+	}
+}
+
+// 生成update.sh文件
+func createsh() bool {
+	dir := ""
+	if str, err := filepath.Abs(filepath.Dir(os.Args[0])); err == nil {
+		dir = strings.Replace(str, "\\", "/", -1)
+	} else {
+		return false
+	}
+
+	sh :=
+		"# author : zyb\n" +
+			"# note   : 在程序运行目录执行此脚本, 升级go服务到最新构建的版本。升级完成自动重启go服务\n" +
+			"# --------------------------------------------------------------------\n" +
+			"\n" +
+			"mkdir -p upmtpgo\n" +
+			"cd upmtpgo\n" +
+			"rm -f console\n" +
+			"wget -c http://192.168.30.153:8080/view/mtp2.0_release/job/mtp2.0_QueryService_linux/label=192.168.31.56/lastBuild/console\n" +
+			"filename=`grep -o -w -m1 mtp2.*zip console`\n" +
+			"wget -c http://192.168.30.153/share/build/mtp2.0_release/$filename\n" +
+			"rm -rf queryservice\n" +
+			"unzip $filename -d queryservice\n" +
+			"cp ../config/config.xml ./queryservice/config/config.xml\n" +
+			"cp ../config/cfg.json ./queryservice/config/cfg.json\n" +
+			"cp -rf ./queryservice/* ../\n" +
+			"cd ..\n" +
+			"rm -rf upmtpgo\n" +
+			"pkill QueryService\n" +
+			"nohup `pwd`/QueryService &"
+
+	// 创建文件
+	if f, err := os.OpenFile(dir+"/update.sh", os.O_RDWR|os.O_CREATE, 0666); err == nil {
+		_, err = f.Write([]byte(sh))
+		f.Close()
+	} else {
+		return false
+	}
+	return true
+}

+ 17 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -618,3 +618,20 @@ func QueryWrPerformanceStepType(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryWrUserReceiptInfo
+// @Summary 查询发票信息
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int false "用户id"
+// @Param receipttype query int false "发票类型 - 1:个人 2:企业"
+// @Success 200 {array} models.WrUserReceiptInfo
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryWrUserReceiptInfo [get]
+// @Tags 仓单贸易v2
+func QueryWrUserReceiptInfo(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrUserReceiptInfo{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 96 - 0
docs/docs.go

@@ -13727,6 +13727,53 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QueryWrUserReceiptInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询发票信息",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户id",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "发票类型 - 1:个人 2:企业",
+                        "name": "receipttype",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrUserReceiptInfo"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/ZJ/GetBankTip": {
             "get": {
                 "produces": [
@@ -36199,6 +36246,55 @@ var doc = `{
                 }
             }
         },
+        "models.WrUserReceiptInfo": {
+            "type": "object",
+            "properties": {
+                "address": {
+                    "description": "地址[发票类型:企业]",
+                    "type": "string"
+                },
+                "autoid": {
+                    "description": "AutoID",
+                    "type": "integer"
+                },
+                "contactinfo": {
+                    "description": "联系方式",
+                    "type": "string"
+                },
+                "idnum": {
+                    "description": "身份证号码[发票类型:个人]",
+                    "type": "string"
+                },
+                "isdefault": {
+                    "description": "是否默认地址 - 0:否 1:是",
+                    "type": "integer"
+                },
+                "receiptaccount": {
+                    "description": "发票帐号[发票类型:企业]",
+                    "type": "string"
+                },
+                "receiptbank": {
+                    "description": "发票开户行[发票类型:企业]",
+                    "type": "string"
+                },
+                "receipttype": {
+                    "description": "发票类型 - 1:个人 2:企业",
+                    "type": "integer"
+                },
+                "taxpayerid": {
+                    "description": "纳税人识别号",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "户名(个人姓名或企业名称)",
+                    "type": "string"
+                }
+            }
+        },
         "models.XHBRAND": {
             "type": "object",
             "properties": {

+ 96 - 0
docs/swagger.json

@@ -13711,6 +13711,53 @@
                 }
             }
         },
+        "/WrTrade2/QueryWrUserReceiptInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询发票信息",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户id",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "发票类型 - 1:个人 2:企业",
+                        "name": "receipttype",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrUserReceiptInfo"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/ZJ/GetBankTip": {
             "get": {
                 "produces": [
@@ -36183,6 +36230,55 @@
                 }
             }
         },
+        "models.WrUserReceiptInfo": {
+            "type": "object",
+            "properties": {
+                "address": {
+                    "description": "地址[发票类型:企业]",
+                    "type": "string"
+                },
+                "autoid": {
+                    "description": "AutoID",
+                    "type": "integer"
+                },
+                "contactinfo": {
+                    "description": "联系方式",
+                    "type": "string"
+                },
+                "idnum": {
+                    "description": "身份证号码[发票类型:个人]",
+                    "type": "string"
+                },
+                "isdefault": {
+                    "description": "是否默认地址 - 0:否 1:是",
+                    "type": "integer"
+                },
+                "receiptaccount": {
+                    "description": "发票帐号[发票类型:企业]",
+                    "type": "string"
+                },
+                "receiptbank": {
+                    "description": "发票开户行[发票类型:企业]",
+                    "type": "string"
+                },
+                "receipttype": {
+                    "description": "发票类型 - 1:个人 2:企业",
+                    "type": "integer"
+                },
+                "taxpayerid": {
+                    "description": "纳税人识别号",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "户名(个人姓名或企业名称)",
+                    "type": "string"
+                }
+            }
+        },
         "models.XHBRAND": {
             "type": "object",
             "properties": {

+ 65 - 0
docs/swagger.yaml

@@ -16709,6 +16709,42 @@ definitions:
         description: 用户id
         type: integer
     type: object
+  models.WrUserReceiptInfo:
+    properties:
+      address:
+        description: 地址[发票类型:企业]
+        type: string
+      autoid:
+        description: AutoID
+        type: integer
+      contactinfo:
+        description: 联系方式
+        type: string
+      idnum:
+        description: 身份证号码[发票类型:个人]
+        type: string
+      isdefault:
+        description: 是否默认地址 - 0:否 1:是
+        type: integer
+      receiptaccount:
+        description: 发票帐号[发票类型:企业]
+        type: string
+      receiptbank:
+        description: 发票开户行[发票类型:企业]
+        type: string
+      receipttype:
+        description: 发票类型 - 1:个人 2:企业
+        type: integer
+      taxpayerid:
+        description: 纳税人识别号
+        type: string
+      userid:
+        description: 用户ID
+        type: integer
+      username:
+        description: 户名(个人姓名或企业名称)
+        type: string
+    type: object
   models.XHBRAND:
     properties:
       brandid:
@@ -27499,6 +27535,35 @@ paths:
       summary: 查询我的朋友
       tags:
       - 仓单贸易v2
+  /WrTrade2/QueryWrUserReceiptInfo:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: userid
+        type: integer
+      - description: 发票类型 - 1:个人 2:企业
+        in: query
+        name: receipttype
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrUserReceiptInfo'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询发票信息
+      tags:
+      - 仓单贸易v2
   /ZJ/GetBankTip:
     get:
       produces:

+ 1 - 1
models/ermcp3.go

@@ -2810,7 +2810,7 @@ select t.goodsid,
     on t.goodunitid = e.enumitemname
    and e.enumdiccode = 'goodsunit'
  where 1 = 1
-   and t.goodsstatus not in (4, 5, 6)
+   and t.goodsstatus not in (4, 5, 6, 7)
    and t.goodsgroupid in
        (select srcgoodsgroupid from ermcp_ggconvertconfig)
 `

+ 49 - 0
models/wrTrade2.go

@@ -3540,3 +3540,52 @@ func (r *WrPerformanceStepType) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// WrUserReceiptInfo 发票信息
+type WrUserReceiptInfo struct {
+	AUTOID         int64  `json:"autoid"  xorm:"AUTOID" form:"autoid"`                // AutoID
+	USERID         int64  `json:"userid"  xorm:"USERID" form:"userid"`                // 用户ID
+	RECEIPTTYPE    int32  `json:"receipttype"  xorm:"RECEIPTTYPE" form:"receipttype"` // 发票类型 - 1:个人 2:企业
+	USERNAME       string `json:"username"  xorm:"USERNAME"`                          // 户名(个人姓名或企业名称)
+	TAXPAYERID     string `json:"taxpayerid"  xorm:"TAXPAYERID" form:"taxpayerid"`    // 纳税人识别号
+	CONTACTINFO    string `json:"contactinfo"  xorm:"CONTACTINFO"`                    // 联系方式
+	RECEIPTBANK    string `json:"receiptbank"  xorm:"RECEIPTBANK"`                    // 发票开户行[发票类型:企业]
+	RECEIPTACCOUNT string `json:"receiptaccount"  xorm:"RECEIPTACCOUNT"`              // 发票帐号[发票类型:企业]
+	ADDRESS        string `json:"address"  xorm:"ADDRESS"`                            // 地址[发票类型:企业]
+	IDNUM          string `json:"idnum"  xorm:"IDNUM"`                                // 身份证号码[发票类型:个人]
+	ISDEFAULT      int32  `json:"isdefault"  xorm:"'ISDEFAULT'"`                      // 是否默认地址 - 0:否 1:是
+}
+
+func (r *WrUserReceiptInfo) calc() {
+
+}
+
+func (r *WrUserReceiptInfo) buildSql() string {
+	var sqlId utils.SQLVal = `
+SELECT t.AUTOID,
+       t.USERID,
+       t.RECEIPTTYPE,
+       t.USERNAME,
+       t.TAXPAYERID,
+       t.CONTACTINFO,
+       t.RECEIPTBANK,
+       t.RECEIPTACCOUNT,
+       t.ADDRESS,
+       t.IDNUM
+  FROM USERRECEIPTINFO t
+ WHERE 1 = 1
+`
+	sqlId.AndEx("t.USERID", r.USERID, r.USERID > 0)
+	sqlId.AndEx("t.USERID", r.RECEIPTTYPE, r.RECEIPTTYPE > 0)
+	return sqlId.String()
+}
+
+// GetDataEx 获取发票信息
+func (r *WrUserReceiptInfo) GetDataEx() (interface{}, error) {
+	sData := make([]WrUserReceiptInfo, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 20 - 0
res/sh/upmtpgo.sh

@@ -0,0 +1,20 @@
+# author : zyb
+# create : 2021-10-20
+# note   : 在程序运行目录执行此脚本, 升级go服务到最新构建的版本。升级完成自动重启go服务
+# --------------------------------------------------------------------
+
+mkdir -p upmtpgo
+cd upmtpgo
+rm -f console
+wget -c http://192.168.30.153:8080/view/mtp2.0_release/job/mtp2.0_QueryService_linux/label=192.168.31.56/lastBuild/console
+filename=`grep -o -w -m1 mtp2.*zip console`
+wget -c http://192.168.30.153/share/build/mtp2.0_release/$filename
+rm -rf queryservice
+unzip $filename -d queryservice
+cp ../config/config.xml ./queryservice/config/config.xml
+cp ../config/cfg.json ./queryservice/config/cfg.json
+cp -rf ./queryservice/* ../
+cd ..
+rm -rf upmtpgo
+pkill QueryService
+nohup `pwd`/QueryService &

+ 2 - 0
routers/router.go

@@ -56,6 +56,7 @@ func InitRouter() *gin.Engine {
 		r.GET("/debug/log", other.LogList)
 		r.GET("/debug/log/view", other.LogView)
 		r.GET("/debug/download", other.DownloadFile)
+		r.GET("/debug/update", other.MakeUpdateScript)
 	}
 	// 终端配置
 	r.GET("/cfg", cfg.QueryCfg)
@@ -573,6 +574,7 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QueryPermancePlanTmp", wrTrade2.QueryPermancePlanTmp)
 		wrTrade2R.GET("QueryWrTradeBargainApply", wrTrade2.QueryWrTradeBargainApply)
 		wrTrade2R.GET("QueryWrPerformanceStepType", wrTrade2.QueryWrPerformanceStepType)
+		wrTrade2R.GET("QueryWrUserReceiptInfo", wrTrade2.QueryWrUserReceiptInfo)
 	}
 
 	// **************************天津麦顿*************************