yumeng 3 سال پیش
والد
کامیت
025043f79a

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

@@ -10,7 +10,6 @@ import cn.com.ctop.common.module.mapper.MaterialTagMapper;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.common.module.vo.ResFileDTO;
-import cn.com.ctop.kuaishou.modules.label.entity.MaterialLabelInfo;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -22,13 +21,6 @@ import it.sauronsoftware.jave.Encoder;
 import it.sauronsoftware.jave.MultimediaInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
-import org.elasticsearch.index.query.BoolQueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.search.aggregations.AggregationBuilder;
-import org.elasticsearch.search.aggregations.AggregationBuilders;
-import org.elasticsearch.search.builder.SearchSourceBuilder;
-import org.elasticsearch.search.collapse.CollapseBuilder;
-import org.elasticsearch.search.sort.SortOrder;
 import org.jeecg.common.system.entity.SysUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.MD5Util;
@@ -46,8 +38,6 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URLDecoder;
 import java.nio.channels.FileChannel;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -85,9 +75,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     private ISupplierWatermarkService supplierWatermarkService;
     @Value("${oss.replace.download}")
     private String downloadUrl;
-    @Resource
-    ElasticsearchUtil elasticsearchUtil;
-
 
     @Override
     public void watermarkVideo(String materialId, Long videoWatermarkTemplateId, String userId) {
@@ -957,7 +944,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
 
     @Override
     public Map<String, Object> getListByParams(String tagCode, String type, Integer status, String materialName, List<Long> projectIds, String code, String startDate, String endDate, String userId, String clipId, String shotId, String planId, String leaderName, Integer offlineFlag, Integer pageNo, Integer pageSize) {
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Map<String, Object> result = new HashMap<>();
         PageHelper.startPage(pageNo, pageSize);
 
@@ -974,151 +960,60 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         if (!Check.isNull(endDate)) {
             endDate = endDate + " 23:59:59";
         }
-        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
-        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
-        if (tagCode != null) {
-            boolQueryBuilder.filter(QueryBuilders.wildcardQuery("tagCode", "*"+tagCode+"*"));
-        }
-        if (clipId != null) {
-            boolQueryBuilder.filter(QueryBuilders.matchPhraseQuery("clipId", clipId));
-        }
-        if (shotId != null) {
-            boolQueryBuilder.filter(QueryBuilders.matchPhraseQuery("shotId", shotId));
-        }
-        if (planId != null) {
-            boolQueryBuilder.filter(QueryBuilders.matchPhraseQuery("planId", planId));
-        }
-        if (status != null) {
-            boolQueryBuilder.filter(QueryBuilders.matchPhraseQuery("status", status));
-        }
-        if (userId != null) {
-            boolQueryBuilder.filter(QueryBuilders.matchPhraseQuery("userId", userId));
-        }
-        if (code != null) {
-            boolQueryBuilder.filter(QueryBuilders.matchPhraseQuery("code", code));
-        }
-        if (materialName != null) {
-            boolQueryBuilder.filter(QueryBuilders.wildcardQuery("materialName", "*"+materialName+"*"));
-        }
-        if (projectIds != null && !projectIds.isEmpty()) {
-            boolQueryBuilder.must(QueryBuilders.matchPhraseQuery("projectId", projectIds));
-        }
-        if (startDate != "" && startDate != null && endDate != "" && endDate != null) {
-            Calendar cal = Calendar.getInstance();
-            Calendar calAfter = Calendar.getInstance();
-            try {
-                Date startTime = sdf.parse(startDate);
-                Date endTime = sdf.parse(endDate);
-                cal.setTime(startTime);
-                calAfter.setTime(endTime);
-                cal.add(Calendar.HOUR_OF_DAY, -8);
-                calAfter.add(Calendar.HOUR_OF_DAY, -8);
-                log.info(sdf.format(cal.getTime()));
-                log.info(sdf.format(calAfter.getTime()));
-                boolQueryBuilder.must(QueryBuilders.rangeQuery("createTime").from(startTime).to(endTime));
-            } catch (ParseException e) {
-                log.info("搜索日期转换错误");
-            }
-        }
-        if (offlineFlag != null) {
-            boolQueryBuilder.must(QueryBuilders.matchPhraseQuery("offlineFlag", offlineFlag));
-        }
-        if (status != null && status.equals("1")) {
-            searchSourceBuilder.sort("confirmTime", SortOrder.DESC);
-        } else {
-            searchSourceBuilder.sort("createTime", SortOrder.DESC);
 
-        }
-        searchSourceBuilder.query(boolQueryBuilder);
-
-//       AggregationBuilder aggregation = AggregationBuilders.cardinality("count").field("code");
-//        searchSourceBuilder.aggregation(aggregation);
-//        searchSourceBuilder.collapse(new CollapseBuilder("code"));
-
-        searchSourceBuilder.from((pageNo - 1) * pageSize);
-        searchSourceBuilder.size(pageSize);
-        searchSourceBuilder.sort("createTime");
-        PageInfo<MaterialLabelInfo> search = new PageInfo<>();
-        int total = 0;
-
-        try {
-            search = elasticsearchUtil.search(searchSourceBuilder, pageNo, pageSize, MaterialLabelInfo.class);
-            total = (int) search.getTotal();
-            log.info("查询数据成功:{}", search.getTotal());
-        } catch (Exception e) {
-            log.info("查询数据错误:{}", e.toString());
-            e.printStackTrace();
-        }
-        //List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, materialName, code, startDate, endDate, userId, projectIds, ascription, clipId, shotId, planId, leaderName, offlineFlag);
+        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<>();
-        if (null != search.getList() && !search.getList().isEmpty()) {
-            for (MaterialLabelInfo info : search.getList()) {
+        PageInfo<MaterialInfo> pageInfo = new PageInfo<>(dailyList);
+        if (!dailyList.isEmpty()) {
+            for (MaterialInfo info : dailyList) {
                 MaterialInfo materialInfo = materialInfoMapper.selectById(info.getId());
-                if (materialInfo != null) {
-                    if (info.getSlogansCount() != null) {
-                        materialInfo.setSlogansCount(Integer.parseInt(info.getSlogansCount()));
-                    }
-                    if (info.getOfflineFlag() != null) {
-                        materialInfo.setOfflineFlag(Integer.parseInt(info.getOfflineFlag()));
-                    }
-                    try {
-                        if (info.getConfirmTime() != null) {
-                            materialInfo.setConfirmTime(info.getConfirmTime());
-                        }
-                    } catch (Exception e) {
-                        log.info("日期转换失败");
-                    }
-                    //素材名称为空 则使用素材id 同步失败
-                    materialInfo.setMaterialName(Check.isNull(materialInfo.getMaterialName()) ? materialInfo.getId() : materialInfo.getMaterialName());
-                    //判断是否已经同步到快手平台
-                    Integer kuaishouMaterialUpCount = this.getKuaishouUpVideoCount(info.getCode());
-                    if (kuaishouMaterialUpCount > 0) {
-                        materialInfo.setKuaishouVideoIsUp(1);
-                    } else {
-                        materialInfo.setKuaishouVideoIsUp(0);
-                    }
-                    //判断是否已经同步到抖音平台
-                    Integer toutiaoMaterialUpCount = this.getToutiaoUpVideoCount(info.getCode());
-                    if (toutiaoMaterialUpCount > 0) {
-                        materialInfo.setToutiaoVideoIsUp(1);
-                    } else {
-                        materialInfo.setToutiaoVideoIsUp(0);
-                    }
-                    //统计快手总消耗数据
-                    JSONObject kuaishous = materialParameterMapper.getMaterialTotalCharge(info.getCode());
-                    if (!Check.isNull(kuaishous)) {
-                        materialInfo.setCost(kuaishous.getBigDecimal("charges"));
-                    } else {
-                        materialInfo.setCost(new BigDecimal(0));
-                    }
-                    //统计抖音总消耗数据
-                    JSONObject bytedances = materialParameterMapper.getByteDanceMaterialTotalCharge(info.getCode());
-                    if (!Check.isNull(bytedances)) {
-                        materialInfo.setBytedanceCost(bytedances.getBigDecimal("charges"));
-                    } else {
-                        materialInfo.setBytedanceCost(new BigDecimal(0));
-                    }
-                    Project project = projectService.getById(info.getProjectId());
-                    if (!Check.isNull(project)) {
-                        materialInfo.setMediaId(project.getMediaId());
-                        materialInfo.setProjectName(project.getProjectName());
-                    }
-                    QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
-                    imageInfoQueryWrapper.eq("video_id", info.getCode());
-                    imageInfoQueryWrapper.eq("status", 0);
-                    List<MaterialImageInfo> imageInfoList = materialImageInfoService.list(imageInfoQueryWrapper);
-                    materialInfo.setWhetherUnaudited(!Check.isNull(imageInfoList));
-                    setList.add(materialInfo);
+                materialInfo.setSlogansCount(info.getSlogansCount());
+                materialInfo.setOfflineFlag(info.getOfflineFlag());
+                materialInfo.setConfirmTime(info.getConfirmTime());
+                //素材名称为空 则使用素材id 同步失败
+                materialInfo.setMaterialName(Check.isNull(materialInfo.getMaterialName()) ? materialInfo.getId() : materialInfo.getMaterialName());
+                //判断是否已经同步到快手平台
+                Integer kuaishouMaterialUpCount = this.getKuaishouUpVideoCount(info.getCode());
+                if (kuaishouMaterialUpCount > 0) {
+                    materialInfo.setKuaishouVideoIsUp(1);
+                } else {
+                    materialInfo.setKuaishouVideoIsUp(0);
+                }
+                //判断是否已经同步到抖音平台
+                Integer toutiaoMaterialUpCount = this.getToutiaoUpVideoCount(info.getCode());
+                if (toutiaoMaterialUpCount > 0) {
+                    materialInfo.setToutiaoVideoIsUp(1);
+                } else {
+                    materialInfo.setToutiaoVideoIsUp(0);
+                }
+                //统计快手总消耗数据
+                JSONObject kuaishous = materialParameterMapper.getMaterialTotalCharge(info.getCode());
+                if (!Check.isNull(kuaishous)) {
+                    materialInfo.setCost(kuaishous.getBigDecimal("charges"));
+                } else {
+                    materialInfo.setCost(new BigDecimal(0));
+                }
+                //统计抖音总消耗数据
+                JSONObject bytedances = materialParameterMapper.getByteDanceMaterialTotalCharge(info.getCode());
+                if (!Check.isNull(bytedances)) {
+                    materialInfo.setBytedanceCost(bytedances.getBigDecimal("charges"));
+                } else {
+                    materialInfo.setBytedanceCost(new BigDecimal(0));
+                }
+                Project project = projectService.getById(info.getProjectId());
+                if (!Check.isNull(project)) {
+                    materialInfo.setMediaId(project.getMediaId());
+                    materialInfo.setProjectName(project.getProjectName());
                 }
+                QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
+                imageInfoQueryWrapper.eq("video_id", info.getCode());
+                imageInfoQueryWrapper.eq("status", 0);
+                List<MaterialImageInfo> imageInfoList = materialImageInfoService.list(imageInfoQueryWrapper);
+                materialInfo.setWhetherUnaudited(!Check.isNull(imageInfoList));
+                setList.add(materialInfo);
             }
         }
         pageInfo.setList(setList);
-        pageInfo.setPageNum(pageNo);
-        pageInfo.setTotal(search.getTotal());
-        pageInfo.setPageSize(search.getPageSize());
-        pageInfo.setPages(total == 0 ? 0 : (total % pageSize == 0 ? total / pageSize : (total / pageSize) + 1));
-        pageInfo.setHasNextPage(pageNo < search.getPages());
         result.put("data", pageInfo);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;