Ver código fonte

Merge branch 'test' of http://39.106.184.70:3000/ctop/adsp-boot into test

jiequan.bi 5 anos atrás
pai
commit
f44e2f94c8
18 arquivos alterados com 495 adições e 160 exclusões
  1. 17 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/system/vo/LoginUser.java
  2. 26 3
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  3. 46 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
  4. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java
  5. 28 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml
  6. 96 84
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java
  7. 6 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
  8. 2 2
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  9. 82 21
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  10. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  11. 25 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  12. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java
  13. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/ConvertVo.java
  14. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  15. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  16. 32 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  17. 49 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  18. 26 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

+ 17 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/system/vo/LoginUser.java

@@ -80,4 +80,21 @@ public class LoginUser {
      */
     private String activitiSync;
 
+	@Override
+	public String toString() {
+		return "LoginUser{" +
+				"id='" + id + '\'' +
+				", username='" + username + '\'' +
+				", realname='" + realname + '\'' +
+				", orgCode='" + orgCode + '\'' +
+				", avatar='" + avatar + '\'' +
+				", birthday=" + birthday +
+				", sex=" + sex +
+				", email='" + email + '\'' +
+				", phone='" + phone + '\'' +
+				", status=" + status +
+				", delFlag='" + delFlag + '\'' +
+				", activitiSync='" + activitiSync + '\'' +
+				'}';
+	}
 }

+ 26 - 3
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -20,7 +20,7 @@ import java.util.*;
  */
 public class DateUtils extends PropertyEditorSupport {
 
-    private static Logger logger= LoggerFactory.getLogger(DateUtils.class);
+    private static Logger logger = LoggerFactory.getLogger(DateUtils.class);
 
     /**
      * 以毫秒表示的时间
@@ -1227,7 +1227,7 @@ public class DateUtils extends PropertyEditorSupport {
             e.printStackTrace();
         }
         //得到相差的天数 betweenDate
-        return  (endDate.getTime() - startDate.getTime())/(60*60*24*1000);
+        return (endDate.getTime() - startDate.getTime()) / (60 * 60 * 24 * 1000);
     }
 
     /***
@@ -1313,8 +1313,31 @@ public class DateUtils extends PropertyEditorSupport {
         return calendar.getTime();
     }
 
+
+    public static List<Date> findDates(Date dBegin, Date dEnd) {
+        List<Date> lDate = new ArrayList<Date>();
+        lDate.add(dBegin);
+        Calendar calBegin = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calBegin.setTime(dBegin);
+        Calendar calEnd = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calEnd.setTime(dEnd);
+        // 测试此日期是否在指定日期之后
+        while (dEnd.after(calBegin.getTime())) {
+            // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
+            calBegin.add(Calendar.DAY_OF_MONTH, 1);
+            lDate.add(calBegin.getTime());
+        }
+        return lDate;
+    }
+
+
     public static void main(String[] args) throws ParseException {
-        System.out.println(calDiffMonth(DateUtils.parseDate("2019-04-01", "yyyy-MM-dd"), new Date()));
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String s = DateUtils.addDay(nowDate, -180);
+        System.err.println(nowDate);
+        System.err.println(s);
     }
 
 }

+ 46 - 19
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -25,10 +25,8 @@ import org.jeecg.common.util.RedisUtil;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
-import org.jeecg.modules.system.entity.SysDepart;
-import org.jeecg.modules.system.entity.SysUser;
-import org.jeecg.modules.system.entity.SysUserDepart;
-import org.jeecg.modules.system.entity.SysUserRole;
+import org.jeecg.modules.system.entity.*;
+import org.jeecg.modules.system.mapper.UserCompanyMapper;
 import org.jeecg.modules.system.model.DepartIdModel;
 import org.jeecg.modules.system.model.SysUserDepartsVO;
 import org.jeecg.modules.system.service.*;
@@ -105,25 +103,28 @@ public class SysUserController {
         return result;
     }
 
+    @Autowired
+    private UserCompanyMapper userCompanyMapper;
 
     @RequestMapping(value = "/getAllUserListByCompany", method = RequestMethod.GET)
-    public Result<List<SysUserVo>> getAllUserListByCompany(String userId) {
+    public Result<List<SysUserVo>> getAllUserListByCompany() {
         Result<List<SysUserVo>> result = new Result<>();
         try {
-            /*List<SysUserVo> userList = new ArrayList<>();
-            String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
-            if (!"admin".equals(roleCode)) {
-                QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
-                userCompanyQueryWrapper.eq("user_id", userId);
-                userCompanyQueryWrapper.orderByDesc("create_time");
-                userCompanyQueryWrapper.last("limit 1");
-                UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
-                userList = sysUserService.getUserListByCompany(userCompany.getCompanyId());
-            } else {
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
+            userCompanyQueryWrapper.eq("user_id", user.getId());
+            userCompanyQueryWrapper.orderByDesc("create_time");
+            userCompanyQueryWrapper.last("limit 1");
+            UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
+            String companyId = userCompany.getCompanyId();
+            List<SysUserVo> userList;
+            if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
                 userList = sysUserService.getAllUser();
+            } else {
+                userList = sysUserService.getUserListByCompany(companyId);
             }
-*/
-            List<SysUserVo> userList = sysUserService.getAllUser();
+
+
             result.setSuccess(true);
             result.setResult(userList);
         } catch (Exception e) {
@@ -140,7 +141,19 @@ public class SysUserController {
     public Result<List<SysUserVo>> getAllList() {
         Result<List<SysUserVo>> result = new Result<>();
         try {
-            List<SysUserVo> userList = sysUserService.getAllUser();
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
+            userCompanyQueryWrapper.eq("user_id", user.getId());
+            userCompanyQueryWrapper.orderByDesc("create_time");
+            userCompanyQueryWrapper.last("limit 1");
+            UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
+            String companyId = userCompany.getCompanyId();
+            List<SysUserVo> userList;
+            if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
+                userList = sysUserService.getAllUser();
+            } else {
+                userList = sysUserService.getUserListByCompany(companyId);
+            }
             result.setSuccess(true);
             result.setResult(userList);
         } catch (Exception e) {
@@ -155,7 +168,21 @@ public class SysUserController {
     public Result<List<SysUserVo>> getSaleList() {
         Result<List<SysUserVo>> result = new Result<>();
         try {
-            List<SysUserVo> userList = sysUserService.getAllSales();
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            List<SysUserVo> userList;
+            QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
+            userCompanyQueryWrapper.eq("user_id", user.getId());
+            userCompanyQueryWrapper.orderByDesc("create_time");
+            userCompanyQueryWrapper.last("limit 1");
+            UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
+            String companyId = userCompany.getCompanyId();
+            if ("4b10089775c040119e139087517aed88".equals(companyId) || "6608ed13c0dd42de93c790dbdf124234".equals(companyId) || "d57fecdcf7a94d009736d9c850731582".equals(companyId)) {
+                userList = sysUserService.getAllSales();
+            } else {
+                userList = sysUserService.getAllSalesByCompanyId(companyId);
+            }
+
+
             result.setSuccess(true);
             result.setResult(userList);
         } catch (Exception e) {

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java

@@ -80,4 +80,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
     List<SysUserVo> getUserListByCompany(@Param("companyId") String companyId);
 
     List<SysUserVo> getAllSale();
+
+    List<SysUserVo> getAllSalesByCompanyId(@Param("companyId") String companyId);
 }

+ 28 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml

@@ -94,15 +94,34 @@ SELECT
     WHERE t1.company_id = #{companyId}
     </select>
     <select id="getAllSale" resultType="cn.com.ctop.common.module.vo.SysUserVo">
-        SELECT
-            t1.id userId,
-            t1.username userName,
-            t1.realname realName,
-            t3.role_name as  roleName
-        FROM sys_user t1
-        LEFT JOIN sys_user_role t2 on t1.id = t2.user_id
-        left join sys_role t3 on t3.id = t2.role_id
-        where t3.role_name like '销售%';
+       SELECT
+	t2.id userId,
+	t2.username userName,
+	t2.realname realName,
+   t4.role_name AS roleName
+    FROM
+	user_company t1
+    LEFT JOIN sys_user t2 ON t1.user_id = t2.id
+    LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
+    LEFT JOIN sys_role t4 ON t3.role_id = t4.id
+    WHERE
+	t4.role_name LIKE '%销售%';
+    </select>
+
+
+    <select id="getAllSalesByCompanyId" resultType="cn.com.ctop.common.module.vo.SysUserVo">
+       SELECT
+	t2.id userId,
+	t2.username userName,
+	t2.realname realName,
+    t4.role_name AS roleName
+  FROM
+	user_company t1
+    LEFT JOIN sys_user t2 ON t1.user_id = t2.id
+    LEFT JOIN sys_user_role t3 ON t2.id = t3.user_id
+    LEFT JOIN sys_role t4 ON t3.role_id = t4.id
+    WHERE t1.company_id = #{companyId}
+	and t4.role_name LIKE '%销售%';
     </select>
 
 

+ 96 - 84
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java

@@ -22,115 +22,127 @@ import java.util.Set;
  */
 public interface ISysUserService extends IService<SysUser> {
 
-	public SysUser getUserByName(String username);
+    public SysUser getUserByName(String username);
+
+    /**
+     * 添加用户和用户角色关系
+     *
+     * @param user
+     * @param roles
+     */
+    public void addUserWithRole(SysUser user, String roles);
 
-	/**
-	 * 添加用户和用户角色关系
-	 * @param user
-	 * @param roles
-	 */
-	public void addUserWithRole(SysUser user,String roles);
 
+    /**
+     * 修改用户和用户角色关系
+     *
+     * @param user
+     * @param roles
+     */
+    public void editUserWithRole(SysUser user, String roles);
 
     /**
-	 * 修改用户和用户角色关系
-	 * @param user
-	 * @param roles
-	 */
-	public void editUserWithRole(SysUser user,String roles);
-
-	/**
-	 * 获取用户的授权角色
-	 * @param username
-	 * @return
-	 */
-	public List<String> getRole(String username);
+     * 获取用户的授权角色
+     *
+     * @param username
+     * @return
+     */
+    public List<String> getRole(String username);
 
     /**
-	  * 查询用户信息包括 部门信息
-	 * @param username
-	 * @return
-	 */
-	public SysUserCacheInfo getCacheUser(String username);
-
-	/**
-	 * 根据部门Id查询
-	 * @param
-	 * @return
-	 */
-	public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username);
-
-	/**
-	 * 根据角色Id查询
-	 * @param
-	 * @return
-	 */
-	public IPage<SysUser> getUserByRoleId(Page<SysUser> page,String roleId, String username);
-
-	/**
-	 * 通过用户名获取用户角色集合
-	 *
-	 * @param username 用户名
-	 * @return 角色集合
-	 */
-	Set<String> getUserRolesSet(String username);
-
-	/**
-	 * 通过用户名获取用户权限集合
-	 *
-	 * @param username 用户名
-	 * @return 权限集合
-	 */
-	Set<String> getUserPermissionsSet(String username);
+     * 查询用户信息包括 部门信息
+     *
+     * @param username
+     * @return
+     */
+    public SysUserCacheInfo getCacheUser(String username);
 
     /**
-	 * 根据用户名设置部门ID
-	 * @param username
-	 * @param orgCode
-	 */
-	void updateUserDepart(String username,String orgCode);
+     * 根据部门Id查询
+     *
+     * @param
+     * @return
+     */
+    public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username);
 
     /**
-	 * 根据手机号获取用户名和密码
-	 */
-	public SysUser getUserByPhone(String phone);
+     * 根据角色Id查询
+     *
+     * @param
+     * @return
+     */
+    public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username);
 
+    /**
+     * 通过用户名获取用户角色集合
+     *
+     * @param username 用户名
+     * @return 角色集合
+     */
+    Set<String> getUserRolesSet(String username);
 
-	/**
-	 * 根据邮箱获取用户
-	 */
-	public SysUser getUserByEmail(String email);
+    /**
+     * 通过用户名获取用户权限集合
+     *
+     * @param username 用户名
+     * @return 权限集合
+     */
+    Set<String> getUserPermissionsSet(String username);
 
+    /**
+     * 根据用户名设置部门ID
+     *
+     * @param username
+     * @param orgCode
+     */
+    void updateUserDepart(String username, String orgCode);
 
-	/**
-	 * 添加用户和用户部门关系
-	 * @param user
-	 * @param selectedParts
-	 */
-	void addUserWithDepart(SysUser user, String selectedParts);
+    /**
+     * 根据手机号获取用户名和密码
+     */
+    public SysUser getUserByPhone(String phone);
 
-	/**
-	 * 编辑用户和用户部门关系
-	 * @param user
-	 * @param departs
-	 */
-	void editUserWithDepart(SysUser user, String departs);
 
     /**
-	   * 校验用户是否有效
-	 * @param sysUser
-	 * @return
-	 */
-	Result checkUserIsEffective(SysUser sysUser);
+     * 根据邮箱获取用户
+     */
+    public SysUser getUserByEmail(String email);
+
+
+    /**
+     * 添加用户和用户部门关系
+     *
+     * @param user
+     * @param selectedParts
+     */
+    void addUserWithDepart(SysUser user, String selectedParts);
+
+    /**
+     * 编辑用户和用户部门关系
+     *
+     * @param user
+     * @param departs
+     */
+    void editUserWithDepart(SysUser user, String departs);
+
+    /**
+     * 校验用户是否有效
+     *
+     * @param sysUser
+     * @return
+     */
+    Result checkUserIsEffective(SysUser sysUser);
 
     Map<String, Object> queryRoleCode(String userId);
 
     List<SysUserVo> getAllUser();
 
 
-	List<SysUserVo> getUserListByCompany(String companyId);
+    List<SysUserVo> getUserListByCompany(String companyId);
 
     List<SysUser> getUserListByRoleId(String roleId);
 
     List<SysUserVo> getAllSales();
+
+    List<SysUserVo> getAllSalesByCompanyId(String companyId);
 }

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java

@@ -289,5 +289,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         return userMapper.getAllSale();
     }
 
+    @Override
+    public List<SysUserVo> getAllSalesByCompanyId(String companyId) {
+        return userMapper.getAllSalesByCompanyId(companyId);
+
+    }
+
 
 }

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-prod.yml

@@ -33,8 +33,8 @@ spring:
             enable: true
             required: true
   ## quartz定时任务,采用数据库方式
-#  quartz:
-#    job-store-type: jdbc
+  quartz:
+    job-store-type: jdbc
   #json 时间戳统一转换
   jackson:
     date-format:   yyyy-MM-dd HH:mm:ss

+ 82 - 21
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,17 +1,28 @@
 package org.jeecg;
 
 import cn.com.ctop.common.module.entity.BindAccountLogin;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -24,10 +35,57 @@ import java.util.concurrent.Executors;
 public class SampleTest {
     @Autowired
     private IOceanEngineService oceanEngineService;
+    @Autowired
+    private IKuaishouInterfaceService interfaceService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+    @Autowired
+    private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
     @Test
-    public void testOceanEngineJob(){
-        String account="3248395570@qq.com";
-        String password = "Ydxq-704127411";
+    public void testOceanEngineJob() {
+
+
+
+
+        try {
+            CtopOauthToken byId = oauthTokenService.getById(303094936123368L);
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String endDate = DateUtils.addDay(nowDate, -180);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date start = simpleDateFormat.parse(nowDate);
+            Date end = simpleDateFormat.parse(endDate);
+            List<Date> dates = DateUtils.findDates(end,start);
+            for (int i = 0; i < dates.size(); i++) {
+                String formatDate = simpleDateFormat.format(dates.get(i));
+                int code = bytedanceReportService.bytedanceMaterialReport(byId, formatDate, formatDate);
+                //如果成功的话跑视频清洗数据方法,失败会进入重试库,重试成功后再清洗数据
+                if (code == 200 || code == 1) {
+                    byteDanceVideoReportDailyService.videoInfoListByAccountId(formatDate, formatDate, byId.getAccountId());
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+/*
+        List list = new ArrayList();
+        list.add(1);
+        list.add(2);
+        list.add(3);
+        list.add(7);
+        for (int i = 0; i < list.size(); i++) {
+            Integer o = (Integer) list.get(i);
+            List<ConvertVo> convertList = interfaceService.getConvertList(6435317L, "42761e184c6e966236fcfd167375a875", o);
+            System.err.println(convertList);
+        }*/
+
+
+
+        String account = "3248395570@qq.com";
+       /* String password = "Ydxq-704127411";
         oceanEngineService.login(account,password);
         oceanEngineService.douyinHotHandler(1,1);
         oceanEngineService.effectCaseHandler(1);
@@ -36,45 +94,48 @@ public class SampleTest {
         oceanEngineService.hotMaterialHandler(1,1,"西瓜");
         oceanEngineService.hotMaterialHandler(1,3,"火山");
         oceanEngineService.hotMaterialHandler(1,9,"穿山甲");
-        log.info("巨量创意抓取完成");
+        log.info("巨量创意抓取完成");*/
     }
 
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+
     @Test
-    public void kuaishouLogin(){
-        Long start =System.currentTimeMillis();
-        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
-        if(list!=null&&!list.isEmpty()){
-            for (BindAccountLogin login:list) {
-                if(null==login.getCookie()||"".equals(login.getCookie().trim())){
+    public void kuaishouLogin() {
+        Long start = System.currentTimeMillis();
+        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
+        if (list != null && !list.isEmpty()) {
+            for (BindAccountLogin login : list) {
+                if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
                     kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
                 }
             }
         }
         Long end = System.currentTimeMillis();
-        log.info("总用时:{}毫秒",end-start);
+        log.info("总用时:{}毫秒", end - start);
     }
+
     static ExecutorService executorService = null;
     static CountDownLatch countDownLatch = null;
+
     @Test
-    public void kuaishouCommentDelete(){
-        Long start =System.currentTimeMillis();
-        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
-        if(list!=null&&!list.isEmpty()){
+    public void kuaishouCommentDelete() {
+        Long start = System.currentTimeMillis();
+        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
+        if (list != null && !list.isEmpty()) {
             executorService = Executors.newFixedThreadPool(10);
             countDownLatch = new CountDownLatch(list.size());
             list.forEach(login -> {
-                executorService.submit(()->{
+                executorService.submit(() -> {
                     try {
-                        if(null!=login.getCookie()&&!"".equals(login.getCookie().trim())){
-                            kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login);
+                        if (null != login.getCookie() && !"".equals(login.getCookie().trim())) {
+                            kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
                         }
-                    }catch (Exception e){
+                    } catch (Exception e) {
 
-                    }finally {
+                    } finally {
                         countDownLatch.countDown();
                     }
                 });
@@ -86,7 +147,7 @@ public class SampleTest {
             e.printStackTrace();
         }
         Long end = System.currentTimeMillis();
-        log.info("总用时:{}毫秒",end-start);
+        log.info("总用时:{}毫秒", end - start);
     }
 //    @Autowired
 //    private PangolinLoginService pangolinLoginService;

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -109,6 +109,11 @@ public class KuaishouInterfaceConstant {
      */
     public static final String APP_SEARCH = "/rest/openapi/v1/tool/app/search";
 
+    /**
+     * 获取可选的应用定向
+     */
+    public static final String CONVERT_LIST = "/rest/openapi/v1/tool/convert/list";
+
 
     /**
      * 获取定向标签

+ 25 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.utils.BigDecimalUtil;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.RandomUtil;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.SpendVo;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
@@ -1811,4 +1812,28 @@ public class BatchController {
     }
 
 
+    @GetMapping(value = "/getConvertList")
+    public Result<List<ConvertVo>> getConvertList(Long accountId, Integer type) {
+        Result result = new Result<>();
+        try {
+            if (Check.isNull(accountId) || Check.isNull(type)) {
+                throw new Exception("必填参数不能为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            List<ConvertVo> convertList = iKuaishouInterfaceService.getConvertList(accountId, oauthToken.getAccessToken(), type);
+            result.setResult(convertList);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
 }

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java

@@ -159,6 +159,7 @@ public class KuaiShouGroup {
 
 
     private Long convertId; // 转化目标
+    private Integer useAppMarket; // 转化目标
     private String groupCreateTime;
     private String groupUpdateTime;
 

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/ConvertVo.java

@@ -0,0 +1,36 @@
+package cn.com.ctop.kuaishou.modules.batch.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Date;
+
+@Data
+public class ConvertVo implements Serializable {
+    @JsonProperty("app_name")
+    private String appName;
+    @JsonProperty("convert_target")
+    private Integer convertTarget;
+    @JsonProperty("convert_name")
+    private String convertName;
+    @JsonProperty("deep_conversion_count")
+    private Long deepConversionCount;
+    @JsonProperty("deep_conversion_type")
+    private Integer deepConversionType;
+    @JsonProperty("type")
+    private Integer type;
+    @JsonProperty("app_id")
+    private Long appId;
+    @JsonProperty("convert_id")
+    private Long convertId;
+    @JsonProperty("convert_count")
+    private Long convertCount;
+    @JsonProperty("click_url")
+    private String clickUrl;
+    @JsonProperty("create_time")
+    private String createTime;
+    @JsonProperty("update_time")
+    private String updateTime;
+
+}

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml

@@ -31,6 +31,7 @@
         app_id,
         app_icon_url,
         convert_id,
+        use_app_market,
         group_create_time,
         group_update_time,
         create_time,
@@ -66,6 +67,7 @@
             #{getGroup.appId},
             #{getGroup.appIconUrl},
             #{getGroup.convertId},
+            #{getGroup.useAppMarket},
             #{getGroup.groupCreateTime},
             #{getGroup.groupUpdateTime},
             #{getGroup.createTime},

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.report.entity.*;
@@ -10,6 +11,7 @@ import com.alibaba.fastjson.JSONObject;
 
 import java.text.ParseException;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -480,6 +482,18 @@ public interface IKuaishouInterfaceService {
      */
 
     void getAsyncCreativeList(Long accountId, String accessToken, Long campaignId);
+
+
+    /**
+     * 获取转化目标
+     *
+     * @param accountId
+     * @param accessToken
+     * @param type
+     * @return
+     */
+    List<ConvertVo> getConvertList(Long accountId, String accessToken, Integer type);
+
 }
 
 

+ 32 - 20
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -58,6 +58,18 @@ public class BatchServiceImpl implements IBatchService {
     private KuaiShouGroupMapper groupMapper;
     @Autowired
     private KuaiShouCreativeMapper creativeMapper;
+    @Autowired
+    private KuaiShouGroupMapper kuaiShouGroupMapper;
+    @Autowired
+    private KuaiShouGroupTargetMapper targetMapper;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private RestTemplate rest;
 
 
     /**
@@ -133,8 +145,7 @@ public class BatchServiceImpl implements IBatchService {
      * @param unitName
      * @return
      */
-    @Autowired
-    private KuaiShouGroupMapper kuaiShouGroupMapper;
+
 
     @Override
     public Boolean checkUnitName(Long campaignId, String unitName) {
@@ -157,11 +168,6 @@ public class BatchServiceImpl implements IBatchService {
      * @param requestJson
      * @return
      */
-    @Autowired
-    private ICtopOauthTokenService oauthTokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
     @Override
     public JSONObject createUnit(JSONObject requestJson) throws Exception {
         Long accountId = requestJson.getLong("accountId");
@@ -197,6 +203,16 @@ public class BatchServiceImpl implements IBatchService {
             unitJson.put("unit_type", requestJson.getInteger("unitType"));
         }
 
+        // 转化目标id
+        if (!Check.isNull(requestJson.getInteger("convertId"))) {
+            unitJson.put("convert_id", requestJson.getInteger("convertId"));
+        }
+
+        // 优先从系统应用商店下载
+        if (!Check.isNull(requestJson.getInteger("useAppMarket"))) {
+            unitJson.put("use_app_market", requestJson.getInteger("useAppMarket"));
+        }
+
         //投放开始时间
         if (!Check.isNull(requestJson.getString("beginTime"))) {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
@@ -447,9 +463,6 @@ public class BatchServiceImpl implements IBatchService {
      * @throws Exception
      */
 
-    @Autowired
-    private KuaiShouGroupTargetMapper targetMapper;
-
 
     @Override
     public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId) {
@@ -489,6 +502,15 @@ public class BatchServiceImpl implements IBatchService {
                     }
 
                 }
+
+                // 优先从系统应用商店下载
+                if (!Check.isNull(group.getUseAppMarket())) {
+                    unitJson.put("use_app_market", group.getUseAppMarket());
+                }
+                // 转化目标id
+                if (!Check.isNull(group.getConvertId())) {
+                    unitJson.put("convert_id", group.getConvertId());
+                }
                 // 投放结束时间
                 if (!Check.isNull(group.getEndTime())) {
                     unitJson.put("end_time", group.getEndTime());
@@ -807,10 +829,6 @@ public class BatchServiceImpl implements IBatchService {
      * @param requestJson
      * @return
      */
-    @Autowired
-    private IKuaiShouImageGetService imageGetService;
-
-
     @Override
     public JSONObject createCreative(JSONObject requestJson) throws Exception {
         if (Check.isNull(requestJson)) {
@@ -1167,9 +1185,6 @@ public class BatchServiceImpl implements IBatchService {
      * @param requestJson
      * @return
      */
-    @Autowired
-    private IKuaiShouImageGetService iKuaiShouImageGetService;
-
     @Override
     public JSONObject updateCreative(JSONObject requestJson) throws Exception {
         if (Check.isNull(requestJson)) {
@@ -1249,9 +1264,6 @@ public class BatchServiceImpl implements IBatchService {
     }
 
 
-    @Autowired
-    private RestTemplate rest;
-
     private String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) throws ParseException {
         try {
             MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();

+ 49 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -8,6 +8,7 @@ import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
 import cn.com.ctop.kuaishou.modules.batch.mapper.*;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
@@ -16,7 +17,6 @@ import cn.com.ctop.kuaishou.modules.report.entity.*;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.service.*;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -1178,7 +1178,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
         if (Check.isNull(details)) {
-
             return;
         }
         addGroup(token.getAccountId(), details);
@@ -1281,6 +1280,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     group.setGroupCreateTime(detail.getString("create_time"));
                     group.setGroupUpdateTime(detail.getString("update_time"));
                     group.setConvertId(detail.getLong("convert_id"));
+                    group.setUseAppMarket(detail.getInteger("use_app_market"));
                     group.setCreateTime(new Date());
                     group.setUpdateTime(new Date());
                     groups.add(group);
@@ -3163,5 +3163,52 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
+    /**
+     * 获取转化目标
+     *
+     * @param accountId
+     * @param accessToken
+     * @param type
+     * @return
+     */
+    @Override
+    public List<ConvertVo> getConvertList(Long accountId, String accessToken, Integer type) {
+        List<ConvertVo> convertVoList = new ArrayList<>();
+        try {
+
+            log.info("获取转化目标:accountId:{}", accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CONVERT_LIST;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", "application/json");
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", accountId);
+            requestJson.put("type", type);
+
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject data = resultJson.getJSONObject("data");
+                if (!Check.isNull(data)) {
+                    JSONArray details = data.getJSONArray("details");
+                    if (!Check.isNull(details)) {
+                        for (int i = 0; i < details.size(); i++) {
+                            ConvertVo convertVo = JsonUtil.jsonToObj(details.getJSONObject(i), ConvertVo.class);
+                            convertVoList.add(convertVo);
+                        }
+
+                    }
+
+                }
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return convertVoList;
+    }
+
 
 }

+ 26 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -247,6 +248,11 @@ public class ReportServiceImpl implements IReportService {
 
     @Autowired
     private BytedanceReportMaterialDailyMapper materialDailyMapper;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+    @Autowired
+    private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
+
     @Override
     public void loadBytedanceHistoryData(CtopOauthToken token) {
         for (int i = 1; i < 180; i++) {
@@ -255,6 +261,26 @@ public class ReportServiceImpl implements IReportService {
             this.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
             this.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         }
+
+        try {
+            log.info("获取历史素材报表:accountId:{}", token.getAccountId());
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String endDate = DateUtils.addDay(nowDate, -180);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date end = simpleDateFormat.parse(nowDate);
+            Date start = simpleDateFormat.parse(endDate);
+            List<Date> dates = DateUtils.findDates(start, end);
+            for (int i = 0; i < dates.size(); i++) {
+                String formatDate = simpleDateFormat.format(dates.get(i));
+                int code = bytedanceReportService.bytedanceMaterialReport(token, formatDate, formatDate);
+                //如果成功的话跑视频清洗数据方法,失败会进入重试库,重试成功后再清洗数据
+                if (code == 200 || code == 1) {
+                    byteDanceVideoReportDailyService.videoInfoListByAccountId(formatDate, formatDate, token.getAccountId());
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     private ByteDanceAdvertiserReportDTO getReportDTO(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {