Browse Source

修改素材查询逻辑

yumeng 3 years ago
parent
commit
310b321cbf

+ 8 - 1
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -573,6 +573,13 @@ public class DateUtils extends PropertyEditorSupport {
         return getSDFormat(pattern).format(date);
     }
 
+    public static String formatDate(String date, String pattern) throws ParseException {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+        Date parse = simpleDateFormat.parse(date);
+        return simpleDateFormat.format(parse);
+    }
+
+
     // ////////////////////////////////////////////////////////////////////////////
     // formatTime
     // 将日期按照一定的格式转化为字符串
@@ -919,7 +926,7 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
     public static Date getStartDate(String date) {
-       String temp =  date + " 00:00:00";
+        String temp = date + " 00:00:00";
         try {
             return format1.parse(temp);
         } catch (Exception e) {

+ 135 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouVideoGetController.java

@@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -127,7 +128,6 @@ public class KuaiShouVideoGetController {
             if (Check.isNull(orderBy)) {
                 throw new Exception("请传入排序方式");
             }
-
             List<KuaiShouVideoGetVo> list = new ArrayList<>();
             PageHelper.startPage(pageNo, pageSize);
             Map<String, Object> requestMap = new HashMap<>();
@@ -167,6 +167,140 @@ public class KuaiShouVideoGetController {
     }
 
 
+    @GetMapping(value = "/getBatchV2VideoList")
+    public Result<PageInfo<KuaiShouVideoGetVo>> getBatchV2VideoList(Long accountId,
+                                                                    String startDate,
+                                                                    String endDate,
+                                                                    String signatures,
+                                                                    Long photoId,
+                                                                    String photoName,
+                                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                    HttpServletRequest req) {
+        Result<PageInfo<KuaiShouVideoGetVo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("请传入账户id");
+            }
+            PageHelper.startPage(pageNo, pageSize);
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("accountId", accountId);
+
+            if (!Check.isNull(signatures)) {
+                String[] signatureArray = signatures.split(",");
+                requestMap.put("signatureList", signatureArray);
+            }
+
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                requestMap.put("startDate", startDate);
+                requestMap.put("endDate", endDate);
+            }
+
+            if (!Check.isNull(photoId)) {
+                requestMap.put("photoId", photoId);
+            }
+
+            if (!Check.isNull(photoName)) {
+                requestMap.put("photoName", photoName);
+            }
+            List<KuaiShouVideoGetVo> list = kuaiShouReportDailyMaterialService.getBatchV2VideoList(requestMap);
+            PageInfo<KuaiShouVideoGetVo> pageInfo = new PageInfo<>(list);
+            result.setSuccess(true);
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    @GetMapping(value = "/getVideoListByCostType")
+    public Result<PageInfo<KuaiShouVideoGetVo>> getBatchV2VideoList(Long accountId,
+                                                                    Long photoId,
+                                                                    String photoName,
+                                                                    Integer costType,
+                                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                    HttpServletRequest req) {
+        Result<PageInfo<KuaiShouVideoGetVo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("请传入账户id");
+            }
+
+            if (Check.isNull(costType)) {
+                throw new Exception("请传入数据类型");
+            }
+
+            PageHelper.startPage(pageNo, pageSize);
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("accountId", accountId);
+
+            if (!Check.isNull(photoId)) {
+                requestMap.put("photoId", photoId);
+            }
+
+            if (!Check.isNull(photoName)) {
+                requestMap.put("photoName", photoName);
+            }
+            List<KuaiShouVideoGetVo> list = new ArrayList<>();
+            if (costType == 1) {  // 昨日数据
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+                Integer date = Integer.valueOf(anotherDay.replace("-", ""));
+                requestMap.put("date", date);
+                list = kuaiShouReportDailyMaterialService.getYesterdayVideo(requestMap);
+            } else if (costType == 2) { // 近七天
+                list = kuaiShouReportDailyMaterialService.get7dayVideo(requestMap);
+            } else if (costType == 3) { // 近14天
+                list = kuaiShouReportDailyMaterialService.get14dayVideo(requestMap);
+            } else if (costType == 4) { // 近30天
+                list = kuaiShouReportDailyMaterialService.get30dayVideo(requestMap);
+            } else if (costType == 5) { // 近3个月
+                String endMonth = DateUtils.getNowDate("yyyy-MM");
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String startMonthStr = DateUtils.addMonth(nowDate, -2);
+                String startMonth = DateUtils.formatDate(startMonthStr, "yyyy-MM");
+                requestMap.put("startMonth", Integer.valueOf(startMonth.replace("-", "")));
+                requestMap.put("endMonth", Integer.valueOf(endMonth.replace("-", "")));
+                kuaiShouReportDailyMaterialService.get3MonthVideo(requestMap);
+            } else if (costType == 6) { // 近6个月
+                String endMonth = DateUtils.getNowDate("yyyy-MM");
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String startMonthStr = DateUtils.addMonth(nowDate, -5);
+                String startMonth = DateUtils.formatDate(startMonthStr, "yyyy-MM");
+                requestMap.put("startMonth", Integer.valueOf(startMonth.replace("-", "")));
+                requestMap.put("endMonth", Integer.valueOf(endMonth.replace("-", "")));
+                kuaiShouReportDailyMaterialService.get3MonthVideo(requestMap);
+            } else if (costType == 7) { // 近12个月
+                String endMonth = DateUtils.getNowDate("yyyy-MM");
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                String startMonthStr = DateUtils.addMonth(nowDate, -11);
+                String startMonth = DateUtils.formatDate(startMonthStr, "yyyy-MM");
+                requestMap.put("startMonth", Integer.valueOf(startMonth.replace("-", "")));
+                requestMap.put("endMonth", Integer.valueOf(endMonth.replace("-", "")));
+                kuaiShouReportDailyMaterialService.get3MonthVideo(requestMap);
+            } else if (costType == 8) { // 全部
+                kuaiShouReportDailyMaterialService.get3MonthVideo(requestMap);
+            }
+
+
+            PageInfo<KuaiShouVideoGetVo> pageInfo = new PageInfo<>(list);
+            result.setSuccess(true);
+            result.setResult(pageInfo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
     public static Map<String, Object> parseJSON2Map(String jsonStr) {
         Map<String, Object> map = new HashMap<String, Object>();
         JSONObject json = JSONObject.parseObject(jsonStr);

+ 20 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/KuaiShouVideoGetVo.java

@@ -31,6 +31,8 @@ public class KuaiShouVideoGetVo implements Serializable {
     @Excel(name = "视频预览链接", width = 15)
     @ApiModelProperty(value = "视频预览链接")
     private String url;
+    private String photoName;
+    private Integer channelType;
     /**
      * 视频首帧图片链接
      */
@@ -77,6 +79,22 @@ public class KuaiShouVideoGetVo implements Serializable {
         this.url = url;
     }
 
+    public String getPhotoName() {
+        return photoName;
+    }
+
+    public void setPhotoName(String photoName) {
+        this.photoName = photoName;
+    }
+
+    public Integer getChannelType() {
+        return channelType;
+    }
+
+    public void setChannelType(Integer channelType) {
+        this.channelType = channelType;
+    }
+
     public String getCoverUrl() {
         return coverUrl;
     }
@@ -108,6 +126,8 @@ public class KuaiShouVideoGetVo implements Serializable {
                 ", statDate='" + statDate + '\'' +
                 ", photoId='" + photoId + '\'' +
                 ", url='" + url + '\'' +
+                ", photoName='" + photoName + '\'' +
+                ", channelType=" + channelType +
                 ", coverUrl='" + coverUrl + '\'' +
                 ", signature='" + signature + '\'' +
                 ", materialType=" + materialType +

+ 12 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java

@@ -47,4 +47,16 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
     JSONObject labelMaterialAll(@Param("companyId") String companyId, @Param("realname") String realname, @Param("roleCode") String roleCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
     List<EtlKuaishouAccountMaterialReportDaily> getReportList(@Param("accountId") Long accountId,@Param("statDate") String statDate,@Param("projectId") Long projectId, @Param("projectName") String projectName);
+
+    List<KuaiShouVideoGetVo> getBatchV2VideoList(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> getYesterdayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get7dayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get14dayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get30dayVideo(Map<String, Object> requestMap);
+
+    void get3MonthVideo(Map<String, Object> requestMap);
 }

+ 159 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml

@@ -873,7 +873,8 @@
         ORDER BY k1.zhenren_charge DESC,k3.zhizuo_charge DESC
         )t
     </select>
-    <select id="getReportList" resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAccountMaterialReportDaily">
+    <select id="getReportList"
+            resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouAccountMaterialReportDaily">
         SELECT
         #{projectId} as 'projectId',
         #{projectName} as 'projectName',
@@ -926,5 +927,162 @@
         GROUP BY
 	    t1.photo_id;
     </select>
+    <select id="getBatchV2VideoList"
+            resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+        SELECT
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'url',
+        t1.cover_url AS 'coverUrl',
+        t1.signature AS 'signature',
+        t1.stat_date as 'statDate',
+        t1.photo_name as 'photoName',
+        t1.channel_type as 'channelType'
+        FROM
+        ctop_kuaishou_video_get t1
+        where t1.account_id = #{accountId}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+
+        <if test="startDate != null and startDate != '' ">
+            and t1.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and t1.stat_date &lt;= #{endDate}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.photo_name like CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        <if test="signatureList != null and signatureList != '' ">
+            and t1.signature in
+            <foreach collection="signatureList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        order by t1.stat_date desc
+    </select>
+    <select id="getYesterdayVideo"
+            resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+
+        SELECT
+        t1.signature as 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        t1.charge AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoName'
+        FROM
+        `application`.kuaishou_material_video_report_daily_dw t1 t1
+        WHERE
+        t1.account_id = #{accountId}
+        AND t1.stat_date = #{date}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        ORDER BY t1.charge DESC
+    </select>
+    <select id="get7dayVideo" resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+        SELECT
+        t1.signature as 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        t1.charge AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoName'
+        FROM
+        `application`.app_kuaishou_video_report_busi_7d t1
+        WHERE
+        t1.account_id = #{accountId}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        ORDER BY t1.charge DESC
+    </select>
+    <select id="get14dayVideo" resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+        SELECT
+        t1.signature as 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        t1.charge AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoName'
+        FROM
+        `application`.app_kuaishou_video_report_busi_14d t1
+        WHERE
+        t1.account_id = #{accountId}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        ORDER BY t1.charge DESC
+    </select>
+    <select id="get30dayVideo" resultType="cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo">
+        SELECT
+        t1.signature as 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        t1.charge AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoName'
+        FROM
+        `application`.app_kuaishou_video_report_busi_30d t1
+        WHERE
+        t1.account_id = #{accountId}
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        ORDER BY t1.charge DESC
+    </select>
+    <select id="get3MonthVideo">
+        SELECT
+        t.*
+        FROM
+        (
+        SELECT
+        t1.signature AS 'signature',
+        t1.photo_id AS 'photoId',
+        t1.photo_url AS 'photoUrl',
+        t1.cover_url AS 'coverUrl',
+        sum( t1.charge ) AS 'charge',
+        t1.channel_type AS 'channelType',
+        t1.video_name AS 'photoNaem'
+        FROM
+        `application`.app_kuaishou_video_report_busi_m t1
+        WHERE
+        t1.account_id = #{accountId}
+        <if test="startMonth != null and startMonth != '' ">
+            and t1.stat_mon &gt;= #{startMonth}
+        </if>
+        <if test="endMonth != null and endMonth != '' ">
+            and t1.stat_mon &lt;= #{endMonth}
+        </if>
+        <if test="photoId != null and photoId != '' ">
+            AND t1.photo_id = #{photoId}
+        </if>
+        <if test="photoName != null and photoName != '' ">
+            AND t1.video_name LIKE CONCAT(CONCAT('%', #{photoName}), '%')
+        </if>
+        GROUP BY
+        t1.photo_id
+        ) t
+        ORDER BY
+        t.charge DESC
+    </select>
 </mapper>
 

+ 12 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouReportDailyMaterialService.java

@@ -32,4 +32,16 @@ public interface IKuaiShouReportDailyMaterialService extends IService<KuaiShouRe
     Result<Object> labelMaterialList(String companyId,String realname, String roleCode, String startTime, String endTime, Integer pageNo, Integer pageSize);
 
     List<EtlKuaishouAccountMaterialReportDaily> getReportList(Long accountId, String statDate, Long projectId, String projectName);
+
+    List<KuaiShouVideoGetVo> getBatchV2VideoList(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> getYesterdayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get7dayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get14dayVideo(Map<String, Object> requestMap);
+
+    List<KuaiShouVideoGetVo> get30dayVideo(Map<String, Object> requestMap);
+
+    void get3MonthVideo(Map<String, Object> requestMap);
 }

+ 30 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java

@@ -15,7 +15,6 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -148,6 +147,36 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
     }
 
     @Override
+    public List<KuaiShouVideoGetVo> getBatchV2VideoList(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.getBatchV2VideoList(requestMap);
+    }
+
+    @Override
+    public List<KuaiShouVideoGetVo> getYesterdayVideo(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.getYesterdayVideo(requestMap);
+    }
+
+    @Override
+    public List<KuaiShouVideoGetVo> get7dayVideo(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.get7dayVideo(requestMap);
+    }
+
+    @Override
+    public List<KuaiShouVideoGetVo> get14dayVideo(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.get14dayVideo(requestMap);
+    }
+
+    @Override
+    public List<KuaiShouVideoGetVo> get30dayVideo(Map<String, Object> requestMap) {
+        return dailyMaterialMapper.get30dayVideo(requestMap);
+    }
+
+    @Override
+    public void get3MonthVideo(Map<String, Object> requestMap) {
+        dailyMaterialMapper.get3MonthVideo(requestMap);
+    }
+
+    @Override
     public List<KuaiShouReportDailyMaterial> getSignatureByDate(String date) {
         return dailyMaterialMapper.getSignatureByDate(date);
     }

+ 33 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -684,6 +684,39 @@ public class MaterialInfoController {
 
     }
 
+
+    // 批量修改状态
+    @PostMapping(value = "/batchEditStatus")
+    public Result<MaterialInfo> batchEditStatus(@RequestBody JSONObject requestJson) {
+        Result<MaterialInfo> result = new Result<>();
+
+        Integer status = requestJson.getInteger("status");
+
+        JSONArray ids = requestJson.getJSONArray("ids");
+        if (Check.isNull(ids)) {
+            result.setCode(-1);
+            result.setMessage("请选择素材");
+            return result;
+
+        }
+        int successNum = 0;
+        for (int i = 0; i < ids.size(); i++) {
+            String id = ids.getString(i);
+            MaterialInfo materialInfo = new MaterialInfo();
+            materialInfo.setId(id);
+            materialInfo.setStatus(status);
+            boolean b = materialInfoService.updateById(materialInfo);
+            if (b) {
+                successNum++;
+            }
+
+        }
+        result.setCode(0);
+        result.setMessage("批量通过" + successNum + "个视频");
+        return result;
+
+    }
+
     /**
      * 通过id删除
      *