Selaa lähdekoodia

修改线上文件下载路径

songyh 3 vuotta sitten
vanhempi
commit
deb1479475

+ 4 - 6
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java

@@ -125,13 +125,11 @@ public class MaterialInfo implements Serializable {
      * createTime
      */
     @ApiModelProperty(value = "createTime")
-    // @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
     private Date createTime;
     /**
      * updateTime
      */
     @ApiModelProperty(value = "updateTime")
-    // @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
     private Date updateTime;
 
     //判断是否为头条有效素材0否_1是
@@ -178,16 +176,16 @@ public class MaterialInfo implements Serializable {
     private Boolean whetherUnaudited;
 
     @TableField(exist = false)
-    private String mediaId;  // 是否有未审核封面
+    private String mediaId;
 
     @TableField(exist = false)
-    private String projectName;  // 是否有未审核封面
+    private String projectName;
 
     @TableField(exist = false)
-    private String startDate;  // 是否有未审核封面
+    private String startDate;
 
     @TableField(exist = false)
-    private String endDate;  // 是否有未审核封面
+    private String endDate;
 
     //视频关联广告语信息--头条
     @TableField(exist = false)

+ 0 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageInfoServiceImpl.java

@@ -48,11 +48,9 @@ public class MaterialImageInfoServiceImpl extends ServiceImpl<MaterialImageInfoM
     @Override
     public void insertImage(JSONObject imageJson) {
         try {
-
             String videoId = imageJson.getString("videoId");
             if (Check.isNull(videoId)) {
                 log.error("视频id不能为空");
-
             }
             String userId = imageJson.getString("userId");
             JSONArray imageArr = imageJson.getJSONArray("imageArr");

+ 57 - 80
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -55,7 +55,6 @@ import static cn.com.ctop.common.module.utils.CloudVideoProcessUtil.videoWaterma
 public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, MaterialInfo> implements IMaterialInfoService {
 
     private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
-
     @Resource
     private ITencentWatermarkTemplateService tencentWatermarkTemplateService;
     @Resource
@@ -72,8 +71,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     private IMaterialCutFrameService materialCutFrameService;
     @Autowired
     private ISupplierWatermarkService supplierWatermarkService;
-    @Resource
-    private IProductService productService;
     @Value("${oss.replace.download}")
     private String downloadUrl;
 
@@ -317,9 +314,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                 }
             }
         }
-
         getFile(info);
-
     }
 
 
@@ -397,73 +392,66 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             @Override
             public void run() {
                 log.info("获取素材基本信息,code:{}", materialInfo.getCode());
-                if (!Check.isNull(materialInfo)) {
-                    long l = System.currentTimeMillis();
-                    String url = materialInfo.getUrl();
-                    log.info("replaceUrl:{}", url);
-                    String localUrl = null;
-                    MultimediaInfo m = null;
-                    FileInputStream fis = null;
-                    try {
-                        localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
-                        File file = new File(localUrl);
-                        it.sauronsoftware.jave.Encoder encoder = new Encoder();
-                        m = encoder.getInfo(file);
-                        long duration = m.getDuration();
-                        long secondDuration = duration / 1000;
-                        MaterialParameter materialParameter = new MaterialParameter();
-                        materialParameter.setMaterialId(materialInfo.getCode());
-                        // 视频秒数
-                        materialParameter.setSecond(secondDuration);
-                        // 视频格式
-                        materialParameter.setFormat(m.getFormat());
-                        // 视频宽
-                        String width = String.valueOf(m.getVideo().getSize().getWidth());
-                        materialParameter.setWidth(width);
-                        // 视频高
-                        String height = String.valueOf(m.getVideo().getSize().getHeight());
-                        materialParameter.setHeight(height);
-
-                        fis = new FileInputStream(file);
-                        FileChannel fc = fis.getChannel();
-                        BigDecimal fileSize = new BigDecimal(fc.size());
-                        String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
-                        materialParameter.setSize(size);
-                        materialParameter.setUpdateTime(new Date());
-
-                        Map<String, Object> deleteMap = new HashMap<>();
-                        deleteMap.put("material_id", materialInfo.getId());
-                        materialParameterMapper.deleteByMap(deleteMap);
-                        int insert = materialParameterMapper.insert(materialParameter);
-                        if (insert > 0) {
-                            log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
-                        }
-                        // 默认抽帧 素造供应商
-                        Long templateId = MaterialSupplierEnum.getTemplateIdBySize(Integer.valueOf(width), Integer.valueOf(height));
-                        if (!Check.isNull(templateId)) {
-                            Thread thread = new Thread() {
+
+                long l = System.currentTimeMillis();
+                String url = materialInfo.getUrl();
+                log.info("replaceUrl:{}", url);
+                String localUrl = null;
+                MultimediaInfo m = null;
+                FileInputStream fis = null;
+                try {
+                    localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
+                    File file = new File(localUrl);
+                    it.sauronsoftware.jave.Encoder encoder = new Encoder();
+                    m = encoder.getInfo(file);
+                    long duration = m.getDuration();
+                    long secondDuration = duration / 1000;
+                    MaterialParameter materialParameter = new MaterialParameter();
+                    materialParameter.setMaterialId(materialInfo.getCode());
+                    // 视频秒数
+                    materialParameter.setSecond(secondDuration);
+                    // 视频格式
+                    materialParameter.setFormat(m.getFormat());
+                    // 视频宽
+                    String width = String.valueOf(m.getVideo().getSize().getWidth());
+                    materialParameter.setWidth(width);
+                    // 视频高
+                    String height = String.valueOf(m.getVideo().getSize().getHeight());
+                    materialParameter.setHeight(height);
+                    fis = new FileInputStream(file);
+                    FileChannel fc = fis.getChannel();
+                    BigDecimal fileSize = new BigDecimal(fc.size());
+                    String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+                    materialParameter.setSize(size);
+                    materialParameter.setUpdateTime(new Date());
+
+                    Map<String, Object> deleteMap = new HashMap<>();
+                    deleteMap.put("material_id", materialInfo.getId());
+                    materialParameterMapper.deleteByMap(deleteMap);
+                    int insert = materialParameterMapper.insert(materialParameter);
+                    if (insert > 0) {
+                        log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
+                    }
+                    // 默认抽帧 素造供应商
+                    Long templateId = MaterialSupplierEnum.getTemplateIdBySize(Integer.valueOf(width), Integer.valueOf(height));
+                    if (!Check.isNull(templateId)) {
+                        Thread thread = new Thread() {
                                 @Override
-                                public void run() {
-                                    watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId);
-                                }
-                            };
-                            thread.start();
+                                public void run() { watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId); }
+                        };
+                        thread.start();
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    try {
+                        if (fis != null) {
+                            fis.close();
                         }
-                    } catch (FileNotFoundException e) {
-                        e.printStackTrace();
                     } catch (IOException e) {
                         e.printStackTrace();
-                    } catch (EncoderException e) {
-                        e.printStackTrace();
-                    } finally {
-                        try {
-                            if (fis != null) {
-                                fis.close();
-                            }
-                        } catch (IOException e) {
-                            e.printStackTrace();
-                        }
                     }
+                    LoadFileUtil.delFile(localUrl);
                 }
             }
         });
@@ -956,7 +944,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, materialName, code, startDate, endDate, userId, projectIds, ascription, clipId, shotId, planId,leaderName, offlineFlag);
         List<MaterialInfo> setList = new ArrayList<>();
         PageInfo<MaterialInfo> pageInfo = new PageInfo<>(dailyList);
-        if (null != dailyList && !dailyList.isEmpty()) {
+        if (!dailyList.isEmpty()) {
             for (MaterialInfo info : dailyList) {
                 MaterialInfo materialInfo = materialInfoMapper.selectById(info.getId());
                 materialInfo.setSlogansCount(info.getSlogansCount());
@@ -1001,18 +989,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                 imageInfoQueryWrapper.eq("video_id", info.getCode());
                 imageInfoQueryWrapper.eq("status", 0);
                 List<MaterialImageInfo> imageInfoList = materialImageInfoService.list(imageInfoQueryWrapper);
-                if (Check.isNull(imageInfoList)) {
-                    materialInfo.setWhetherUnaudited(false);
-                } else {
-                    materialInfo.setWhetherUnaudited(true);
-                }
-                //统计广告语数量
-//                List<BytedanceVideoSlogenInfo> slogenInfos = slogenInfoService.listByParams(materialInfo.getCode(), 1);
-//                JSONArray slogenArray = new JSONArray();
-//                if (null != slogenInfos && !slogenInfos.isEmpty()) {
-//                    slogenArray.addAll(slogenInfos);
-//                }
-//                materialInfo.setSlogans(slogenArray);
+                materialInfo.setWhetherUnaudited(!Check.isNull(imageInfoList));
                 setList.add(materialInfo);
             }
         }

+ 0 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -29,10 +29,6 @@ import static java.lang.Integer.valueOf;
 @Slf4j
 @Service
 public class BatchServiceImpl implements IBatchService {
-
-    @Value("${oss.replace.download}")
-    private String downloadUrl;
-
     @Autowired
     private BatchMapper batchMapper;
     @Autowired

+ 0 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouMaterialUploadServiceImpl.java

@@ -33,10 +33,8 @@ import java.util.Map;
 @Slf4j
 @Service
 public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploadService {
-
     @Value("${oss.replace.download}")
     private String downloadUrl;
-
     @Autowired
     private IKuaiShouImageGetService iKuaiShouImageGetService;
     @Autowired

+ 0 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java

@@ -39,10 +39,8 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     private IMaterialCutFrameService materialCutFrameService;
     @Value("${oss.replace.download}")
     private String downloadUrl;
-
     @Autowired
     private IKuaiShouVideoLastTimeService lastTimeService;
-
     @Override
     public void replaceBatch(List<KuaiShouVideoGet> videoGets) {
         videoGetMapper.replaceBatch(videoGets);

+ 0 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadImageServiceImpl.java

@@ -37,10 +37,6 @@ import java.util.concurrent.Executors;
 @Service
 public class MaterialUploadImageServiceImpl implements IMaterialUploadImageService {
     static ExecutorService executorService = Executors.newFixedThreadPool(15);
-
-    @Value("${oss.replace.download}")
-    private String downloadUrl;
-
     @Autowired
     private IMaterialImageInfoService materialImageInfoService;
     @Autowired

+ 10 - 24
jeecg-boot-module-system/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -101,12 +101,11 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
             try {
                 String url = "";
                 if (Check.isNull(materialInfo)) {
-                    url = (String) materialImageInfo.getUrl();
+                    url = materialImageInfo.getUrl();
                 } else {
                     url = materialInfo.getUrl();
                 }
                 String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
-
                 for (int i = 0; i < accountArray.size(); i++) {
                     Long accountId = accountArray.getLong(i);
                     if (Check.isNull(accountId)) {
@@ -120,10 +119,10 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                 log.info("头条文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
                                 if (materialInfo != null && "VIDEO".equals(materialInfo.getType())) {
                                     fileInfoService.uploadVideoToBytedance(String.valueOf(accountId), localUrl, userId, materialInfo.getMaterialName());
-
                                 } else if ("IMAGE".equals(materialImageInfo.getType())) {
                                     fileInfoService.uploadImageToBytedance(String.valueOf(accountId), finalUrl);
                                 }
+                                LoadFileUtil.delFile(localUrl);
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }
@@ -148,7 +147,6 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
             }
             try {
                 String url = materialInfo.getUrl();
-                log.info("replaceUrl:{}", url);
                 String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
                 FileSystemResource resource = new FileSystemResource(new File(localUrl));
                 Map<String, String> headerMap = new HashMap<>();
@@ -175,11 +173,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                 }
                 for (int i = 0; i < accountArray.size(); i++) {
                     Long accountId = accountArray.getLong(i);
-                    QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
-                    tokenQueryWrapper.eq("account_id", accountId);
-                    tokenQueryWrapper.orderByDesc("create_time");
-                    tokenQueryWrapper.last("limit 1");
-                    CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(tokenQueryWrapper);
+                    CtopOauthToken ctopOauthToken = oauthTokenMapper.selectByAccountId(accountId);
                     if (Check.isNull(ctopOauthToken)) {
                         continue;
                     }
@@ -195,7 +189,6 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                 JSONObject resultJson = JSONObject.parseObject(result);
                                 if (!Check.isNull(resultJson)) {
                                     KuaiShouAdvertiserBaseInfo baseInfo = advertiserBaseInfoService.getBaseInfo(accountId);
-
                                     if (resultJson.getInteger("code") == 0) {
                                         JSONObject dataJson = resultJson.getJSONObject("data");
                                         if (!Check.isNull(dataJson)) {
@@ -207,19 +200,15 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                             Project project = projectService.getById(allocation.getProjectId());
                                             String message = messageTemplate.getMaterialSyncSucessTemplate(project.getProjectName(), baseInfo.getUserId(), baseInfo.getUserName(), materialInfo.getMaterialName(), resultJson.getString("message"));
                                             sendMessageService.sendMessage(userId, message);
-
-                                            /**
-                                             * 异步获取视频信息
-                                             */
                                             Thread thread = new Thread() {
                                                 @Override
                                                 public void run() {
-                                                    try {
-                                                        Thread.sleep(2 * 1000L);
-                                                        kuaishouInterfaceService.getVideoInfo(ctopOauthToken.getAccessToken(), ctopOauthToken.getAccountId(), dataJson.getString("photo_id"));
-                                                    } catch (InterruptedException e) {
-                                                        e.printStackTrace();
-                                                    }
+                                                try {
+                                                    Thread.sleep(2 * 1000L);
+                                                    kuaishouInterfaceService.getVideoInfo(ctopOauthToken.getAccessToken(), ctopOauthToken.getAccountId(), dataJson.getString("photo_id"));
+                                                } catch (InterruptedException e) {
+                                                    e.printStackTrace();
+                                                }
                                                 }
                                             };
                                             thread.start();
@@ -234,18 +223,17 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                         sendMessageService.sendMessage(userId, message);
                                     }
                                 }
+                                LoadFileUtil.delFile(localUrl);
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }
                         }
                     });
-
                 }
             } catch (Exception e) {
                 e.printStackTrace();
             }
         }
-
     }
 
     private String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) {
@@ -276,6 +264,4 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
         }
         return null;
     }
-
-
 }

+ 1 - 1
jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-prod.yml

@@ -220,7 +220,7 @@ oss:
   replace:
     replace-value: oss-cn-beijing-internal
     replace-old-value: oss-cn-beijing
-    download: /data/image/
+    download: /data/upload/image/
 zip:
   local:
     download-path: /data/