Pārlūkot izejas kodu

添加打印日志

夏文涛 1 gadu atpakaļ
vecāks
revīzija
9308f0fa19

+ 4 - 0
src/main/java/com/sqx/modules/printInfo/controller/PrintInfoController.java

@@ -18,6 +18,7 @@ import com.sqx.modules.utils.fieYun.FeiYunUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -37,6 +38,7 @@ import java.util.stream.Collectors;
 @RestController
 @Api(value = "管理端-打印模板信息", tags = {"管理端-打印模板信息"})
 @RequestMapping("/admin/printInfo/")
+@Slf4j
 public class PrintInfoController {
     @Autowired
     private PrintInfoService printInfoService;
@@ -543,7 +545,9 @@ public class PrintInfoController {
     @GetMapping("testPrintInfo")
     @ApiOperation("测试打印功能")
     public Result testPrintInfo(String sn) {
+        log.info("进入打印:sn"+sn);
         FeiYunUtils.testPrint(sn);
+        log.info("打印结束:sn"+sn);
         return Result.success();
     }
 }

+ 29 - 3
src/main/java/com/sqx/modules/utils/fieYun/FeiYunUtils.java

@@ -1334,6 +1334,8 @@ public class FeiYunUtils {
             //拼凑订单内容时可参考如下格式
             //根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
 
+            log.info("utils方法打印开始");
+
             //region 以前的代码
             String content = "<CB>测试打印</CB><BR>";
             content += "名称      单价  数量 金额<BR>";
@@ -1354,9 +1356,9 @@ public class FeiYunUtils {
             content += "订餐时间:2016-08-08 08:08:08<BR>";
             content += "<QR>http://www.dzist.com</QR>";
             //endregion
-
+            log.info("utils方法打印开始1");
             StringBuilder stringBuilder = new StringBuilder();
-
+            log.info("utils方法打印开始2");
             //region 以前的代码
             /*stringBuilder.append("<BR>").append("<BR>").append("<BR>");
             stringBuilder.append("<CB>").append(tbOrder.getShopName()).append("</CB><BR>");
@@ -1422,43 +1424,64 @@ public class FeiYunUtils {
             stringBuilder.append("订餐时间:").append(tbOrder.getPayTime()).append("<BR>");*/
             //endregion
 
+            log.info("utils方法打印开始3");
             //通过POST请求,发送打印信息到服务器
             RequestConfig requestConfig = RequestConfig.custom()
                     .setSocketTimeout(30000)//读取超时
                     .setConnectTimeout(30000)//连接超时
                     .build();
 
+            log.info("utils方法打印开始4");
             CloseableHttpClient httpClient = HttpClients.custom()
                     .setDefaultRequestConfig(requestConfig)
                     .build();
+            log.info("utils方法打印开始5");
             String URL = commonInfoService.findOne(325).getValue();
+            log.info("utils方法打印开始6");
             String USER = commonInfoService.findOne(326).getValue();
+            log.info("utils方法打印开始7");
             String UKEY = commonInfoService.findOne(327).getValue();
+            log.info("utils方法打印开始8");
             HttpPost post = new HttpPost(URL);
+            log.info("utils方法打印开始9");
             List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+            log.info("utils方法打印开始10");
             nvps.add(new BasicNameValuePair("user", USER));
+            log.info("utils方法打印开始11");
             String STIME = String.valueOf(System.currentTimeMillis() / 1000);
+            log.info("utils方法打印开始12");
             nvps.add(new BasicNameValuePair("stime", STIME));
             nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME)));
             nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));//固定值,不需要修改
             nvps.add(new BasicNameValuePair("sn", sn));
             nvps.add(new BasicNameValuePair("content", content));
             nvps.add(new BasicNameValuePair("times", "1"));//打印联数
-
+            log.info("utils方法打印开始13");
             CloseableHttpResponse response = null;
             String result = null;
+            log.info("utils方法打印开始14");
             try {
+                log.info("utils方法打印开始15");
                 post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
+                log.info("utils方法打印开始16");
                 response = httpClient.execute(post);
+                log.info("utils方法打印开始17");
                 int statecode = response.getStatusLine().getStatusCode();
+                log.info("utils方法打印开始18");
                 if (statecode == 200) {
+                    log.info("utils方法打印开始19");
                     HttpEntity httpentity = response.getEntity();
+                    log.info("utils方法打印开始20");
                     if (httpentity != null) {
+                        log.info("utils方法打印开始21");
                         //服务器返回的JSON字符串,建议要当做日志记录起来
                         result = EntityUtils.toString(httpentity);
+                        log.info("utils方法打印开始22");
                     }
+                    log.info("utils方法打印开始23");
                 }
             } catch (Exception e) {
+                log.info("utils方法打印开始24"+e.getMessage());
                 e.printStackTrace();
             } finally {
                 try {
@@ -1466,16 +1489,19 @@ public class FeiYunUtils {
                         response.close();
                     }
                 } catch (IOException e) {
+                    log.info("utils方法打印开始25"+e.getMessage());
                     e.printStackTrace();
                 }
                 try {
                     post.abort();
                 } catch (Exception e) {
+                    log.info("utils方法打印开始26"+e.getMessage());
                     e.printStackTrace();
                 }
                 try {
                     httpClient.close();
                 } catch (IOException e) {
+                    log.info("utils方法打印开始27"+e.getMessage());
                     e.printStackTrace();
                 }
             }

+ 2 - 2
src/main/resources/application-prod.yml

@@ -3,9 +3,9 @@ spring:
         type: com.alibaba.druid.pool.DruidDataSource
         druid:
             driver-class-name: com.mysql.cj.jdbc.Driver
-            url: jdbc:mysql://223.84.177.126:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
+            url: jdbc:mysql://172.16.20.111:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
             username: root
-            password: chuanghai_2024.
+            password: 111111
             initial-size: 10
             max-active: 100
             min-idle: 10

+ 2 - 2
src/main/resources/application.yml

@@ -19,7 +19,7 @@ spring:
     allow-circular-references: true
   # 环境 dev|test|prod
   profiles:
-    active: dev
+    active: prod
   # jackson时间格式化
   jackson:
     time-zone: GMT+8
@@ -85,4 +85,4 @@ sqx:
     secret: f4e2e52034348f86b67cde581c0f9eb5
     # token有效时长,7天,单位秒
     expire: 2592000
-    header: token
+    header: token