瀏覽代碼

规范打印日志

yumeng 5 年之前
父節點
當前提交
1068f53939

+ 0 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/kuaishou/service/impl/KuaiShouCreateServiceImpl.java

@@ -321,16 +321,12 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     returnMap.put("message", "请选择上传的视频");
                     return returnMap;
                 }
-
-                long startTime = System.currentTimeMillis();
-                log.info("开始上传视频");
                 Map<String, Object> videoMap = kuaishouInterfaceService.videoUpload(accountId, accessToken, videoUrl); // 上传视频到快手后台
                 if ((Integer) videoMap.get("code") != 0) {
                     log.error("上传视频失败,accountId:{}", accountId);
                     return videoMap;
                 }
                 createJson.put("photo_id", videoMap.get("photoId"));
-                log.info("上传信息流广告视频完成,共耗时:{} ms", System.currentTimeMillis() - startTime);
                 if (!Check.isNull(requestJson.getString("clickTrackUrl"))) {
                     createJson.put("click_track_url", requestJson.getString("clickTrackUrl"));
                 }
@@ -413,14 +409,11 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                             return returnMap;
                         }
 
-                        long startTime = System.currentTimeMillis();
-                        log.info("开始上传视频");
                         Map<String, Object> videoMap = kuaishouInterfaceService.videoUpload(accountId, accessToken, havaVideoUrl); // 上传视频到快手后台
                         if ((Integer) videoMap.get("code") != 0) {
                             log.error("后贴片素材上传视频失败,accountId:{}", accountId);
                             return videoMap;
                         }
-                        log.info("上传贴片视频完成,共耗时:{} ms", System.currentTimeMillis() - startTime);
                         createJson.put("photo_id", videoMap.get("photoId"));
 
                         if (haveSinglePicVideoUrlArr.size() == 1) {

+ 4 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/kuaishou/service/impl/KuaiShouImageServiceImpl.java

@@ -4,20 +4,19 @@ import cn.com.ctop.common.utils.Check;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import constant.KuaishouInterfaceConstant;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.encryption.AesEncryptUtil;
 import org.jeecg.modules.ctop.entity.CtopOauthToken;
 import org.jeecg.modules.ctop.service.ICtopOauthTokenService;
 import org.jeecg.modules.kuaishou.entity.KuaiShouImage;
-import org.jeecg.modules.kuaishou.entity.KuaiShouVideo;
 import org.jeecg.modules.kuaishou.mapper.KuaiShouImageMapper;
 import org.jeecg.modules.kuaishou.service.IKuaiShouImageService;
 import org.jeecg.modules.kuaishou.service.IKuaishouInterfaceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import java.util.List;
 
 /**
@@ -26,6 +25,7 @@ import java.util.List;
  * @Date: 2019-08-14
  * @Version: V1.0
  */
+@Slf4j
 @Service
 public class KuaiShouImageServiceImpl extends ServiceImpl<KuaiShouImageMapper, KuaiShouImage> implements IKuaiShouImageService {
 
@@ -73,6 +73,7 @@ public class KuaiShouImageServiceImpl extends ServiceImpl<KuaiShouImageMapper, K
                 Thread thread = new Thread() {
                     @Override
                     public void run() {
+                        log.info("快手开始上传图片,accountId:{}", accountId);
                         interfaceService.imageUpload(accountId, accessToken, imageUrlStr, 0);
                     }
                 };

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/kuaishou/service/impl/KuaiShouVideoServiceImpl.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import constant.KuaishouInterfaceConstant;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.encryption.AesEncryptUtil;
 import org.jeecg.modules.ctop.entity.CtopOauthToken;
 import org.jeecg.modules.ctop.service.ICtopOauthTokenService;
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
  * @Date: 2019-08-14
  * @Version: V1.0
  */
+@Slf4j
 @Service
 public class KuaiShouVideoServiceImpl extends ServiceImpl<KuaiShouVideoMapper, KuaiShouVideo> implements IKuaiShouVideoService {
     @Autowired
@@ -71,6 +73,7 @@ public class KuaiShouVideoServiceImpl extends ServiceImpl<KuaiShouVideoMapper, K
                 Thread thread = new Thread() {
                     @Override
                     public void run() {
+                        log.info("快手开始上传视频,accountId:{}", accountId);
                         interfaceService.videoUpload(accountId, accessToken, urlStr);
                     }
                 };

+ 12 - 11
jeecg-boot-module-system/src/main/java/org/jeecg/modules/kuaishou/service/impl/KuaishouInterfaceServiceImpl.java

@@ -454,6 +454,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             headers.put("Content-Type", " application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
+            log.info("快手创建广告组返回,accountId:{},返回结果:{}", advertiserId, resultJson);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
@@ -467,14 +468,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     }
 
                 } else {
-                    log.error("创建广告信息失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
+                    log.error("创建广告信息失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
                     returnMap.put("code", -1);
                     returnMap.put("message", resultJson.getString("message"));
                     returnMap.put("desc", "创建广告组失败");
                     returnMap.put("success", false);
                 }
             } else {
-                log.error("快手创建广告计划返回内容为空,advertiser_id:{}", advertiserId);
+                log.error("快手创建广告计划返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
                 returnMap.put("code", -1);
                 returnMap.put("message", "创建广告组异常");
                 returnMap.put("desc", "result is null");
@@ -945,7 +946,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), header);
             JSONObject resultJson = JSONObject.parseObject(result);
-            log.info("快手创建创意返回信息:{}", resultJson);
+            log.info("快手创建创意返回:accountId:{},返回结果{}", advertiserId, resultJson);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
@@ -970,14 +971,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("success", true);
                     }
                 } else {
-                    log.error("创建广告创意失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
+                    log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
                     returnMap.put("code", -1);
                     returnMap.put("message", resultJson.getString("message"));
                     returnMap.put("desc", "上传图片失败");
                     returnMap.put("success", false);
                 }
             } else {
-                log.error("快手创建广告创意返回内容为空,advertiser_id:{}", advertiserId);
+                log.error("快手创建广告创意返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
                 returnMap.put("code", -1);
                 returnMap.put("message", "上传图片异常");
                 returnMap.put("desc", "result is null");
@@ -998,7 +999,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     @Override
     public Map<String, Object> videoUpload(Long advertiserId, String accessToken, String videoUrl) {
-        log.info("开始上传视频");
         Map<String, Object> returnMap = new HashMap<>();
         try {
             QueryWrapper<KuaiShouVideoUpload> wrapper = new QueryWrapper<>();
@@ -1017,6 +1017,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", videoUrl, advertiserId);
                 throw new Exception("下载文件到本地失败");
             }
+            Long startTime = System.currentTimeMillis();
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_UPLOAD;
             JSONObject requestJson = new JSONObject();
             requestJson.put("advertiser_id", advertiserId);
@@ -1049,7 +1050,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         queryWrapper.eq("local_url", videoUrl);
                         int y = kuaiShouVideoMapper.update(video, queryWrapper);
                         if (y > 0) {
-                            log.info("更新快手视频状态成功.accountId:{}", advertiserId);
+                            log.info("更新快手视频状态成功.accountId:{},上传耗时:{} ms", advertiserId, System.currentTimeMillis() - startTime);
                         }
 
                         returnMap.put("code", 0);
@@ -1245,7 +1246,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      */
     @Override
     public Map<String, Object> imageUpload(Long advertiserId, String accessToken, String filePath, Integer type) {
-        log.info("上传快手图片");
         Map<String, Object> returnMap = new HashMap<>();
         try {
             QueryWrapper<KuaiShouImageUploand> queryWrapper = new QueryWrapper<>();
@@ -1264,6 +1264,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", filePath, advertiserId);
                 throw new Exception("下载文件到本地失败");
             }
+            Long startTime = System.currentTimeMillis();
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
             JSONObject requestJson = new JSONObject();
             requestJson.put("advertiser_id", advertiserId);
@@ -1290,7 +1291,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         imageUploand.setWidth(dataJson.getLong("width"));
                         int i = imageUploandMapper.insert(imageUploand);
                         if (i > 0) {
-                            log.info("快手-图片上传成功");
+                            log.info("快手-图片上传成功,共耗时:{} ms", System.currentTimeMillis() - startTime);
                         }
                         returnMap.put("code", 0);
                         returnMap.put("desc", "上传图片完成");
@@ -1364,6 +1365,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             Map<String, String> header = new HashMap<String, String>();
             header.put("Content-Type", "multipart/form-data");
             header.put("Access-Token", accessToken);
+            Long startTime = System.currentTimeMillis();
             String result = exceptInfoForRestTemplate(url, requestJson, header, localUrl);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(result)) {
@@ -1385,7 +1387,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         appCreate.setUploadTime(new Date().toString());
                         int i = appCreateMapper.insert(appCreate);
                         if (i > 0) {
-                            log.info("快手创建应用成功");
+                            log.info("快手创建应用成功,共耗时:{} ms", System.currentTimeMillis() - startTime);
                         }
                         returnMap.put("appId", dataJson.getLong("app_id"));
                         returnMap.put("success", true);
@@ -1672,7 +1674,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 }
                 HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<MultiValueMap<String, Object>>(param, headers);
                 ResponseEntity<String> responseEntity = rest.exchange(url, HttpMethod.POST, httpEntity, String.class);
-                System.err.println(responseEntity.getBody());
                 return responseEntity.getBody();
             }
         } catch (Exception e) {