|
@@ -11,6 +11,10 @@ import (
|
11
|
11
|
"github.com/astaxie/beego"
|
12
|
12
|
)
|
13
|
13
|
|
|
14
|
+// 二维码不多次获取, 只获取一次即可
|
|
15
|
+// 临时的解决方案是放到全局单例对象中
|
|
16
|
+var qrCodes map[string]string
|
|
17
|
+
|
14
|
18
|
// BodyCheckController 商品
|
15
|
19
|
type BodyCheckController struct {
|
16
|
20
|
serv *bodycheck.BodyCheckServ
|
|
@@ -30,14 +34,19 @@ func (c *BodyCheckController) GetQrcodeURL() {
|
30
|
34
|
qrcodePrefix := beego.AppConfig.String("qrcodePrefix")
|
31
|
35
|
org := c.Context.Get("org").(model.SysOrg)
|
32
|
36
|
|
33
|
|
- qrcode, err := utils.WxClientFor(org.OrgId).GetTempStrQRCode(qrcodePrefix + EquipmentID)
|
34
|
|
- if err != nil {
|
35
|
|
- utils.LogError("获取二维码失败: " + err.Error())
|
36
|
|
- // c.ResponseError(err)
|
37
|
|
- c.ResponseOtherEndPoint(map[string]interface{}{
|
38
|
|
- "Status": false,
|
39
|
|
- "Message": "获取二维码失败: " + err.Error(),
|
40
|
|
- })
|
|
37
|
+ qrcode, has := qrCodes[qrcodePrefix+EquipmentID]
|
|
38
|
+ if !has {
|
|
39
|
+ var err error
|
|
40
|
+ qrcode, err = utils.WxClientFor(org.OrgId).GetTempStrQRCode(qrcodePrefix + EquipmentID)
|
|
41
|
+ if err != nil {
|
|
42
|
+ utils.LogError("获取二维码失败: " + err.Error())
|
|
43
|
+ // c.ResponseError(err)
|
|
44
|
+ c.ResponseOtherEndPoint(map[string]interface{}{
|
|
45
|
+ "Status": false,
|
|
46
|
+ "Message": "获取二维码失败: " + err.Error(),
|
|
47
|
+ })
|
|
48
|
+ }
|
|
49
|
+ qrCodes[qrcodePrefix+EquipmentID] = qrcode
|
41
|
50
|
}
|
42
|
51
|
|
43
|
52
|
c.ResponseOtherEndPoint(map[string]interface{}{
|
|
@@ -86,3 +95,7 @@ func (c *BodyCheckController) PostCheckResult() {
|
86
|
95
|
"Message": "",
|
87
|
96
|
})
|
88
|
97
|
}
|
|
98
|
+
|
|
99
|
+func init() {
|
|
100
|
+ qrCodes = make(map[string]string)
|
|
101
|
+}
|