Преглед изворни кода

Merge branch 'test'

# Conflicts:
#	jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java
songyh пре 4 година
родитељ
комит
070708b75c

+ 38 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/enums/BytedanceCreativeMatTypeEnum.java

@@ -1,5 +1,11 @@
 package org.jeecg.modules.bytedance.advertise.enums;
 
+import org.jeecg.common.util.DateUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
 public enum BytedanceCreativeMatTypeEnum {
     /**
      * 创意素材类型
@@ -131,4 +137,36 @@ public enum BytedanceCreativeMatTypeEnum {
         return "";
     }
 
+
+
+
+    /**
+     *查询相应的素材信息  时间点
+     * @param type 类型
+     * 1-上新 当天
+     * 2-高质量 前5天 花费大于500
+     * 3-遗漏
+     * 4-打捞 前7天
+     * @return
+     */
+    public static Map<String,String> getCreativeStartTime(String type){
+        Map<String,String> map = new HashMap();
+        Long timeStart = BytedanceCreativeMatTypeEnum.getStartTimeByType(type);
+        Long timeEnd = BytedanceCreativeMatTypeEnum.getEndTimeByType(type);
+        Long now = System.currentTimeMillis();
+        long zero = now / (1000*3600*24)*(1000*3600*24) - TimeZone.getDefault().getRawOffset();//今天零点零分零秒的毫秒数
+        long twelve = zero + 24*60*60*1000 - 1;//今天23点59分59秒的毫秒数
+        String startTime = DateUtils.formatDateTime(zero);
+        String endTime = DateUtils.formatDateTime(twelve);
+        if(timeStart != 0){
+            startTime = DateUtils.formatDateTime(zero + timeStart * 60 * 1000L);
+        }
+        if(timeEnd != 0){
+            endTime = DateUtils.formatDateTime(twelve + timeEnd * 60 * 1000L);
+        }
+        map.put("startTime",startTime);
+        map.put("endTime",endTime);
+        return map;
+    }
+
 }

+ 6 - 6
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceVideoInfoMapper.xml

@@ -84,7 +84,7 @@
         and material_upload_time &gt;= #{startTime}
         and material_upload_time &lt;= #{endTime}
         having creativeCnt &lt;= #{creativeCnt} and slogens >0 and creativeNum = 0
-        order by material_upload_time desc
+        order by material_upload_time
         limit #{videoCnt}
     </select>
     <select id="topMatByParams" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo">
@@ -112,7 +112,7 @@
         having creativeCnt &lt;= 100
            and creativeNum = 0
         and slogens >0
-        order by a.material_id desc
+        order by material_upload_time
         limit #{videoCnt}
     </select>
 
@@ -141,7 +141,7 @@
         having creativeCnt &lt; 20
            and creativeNum = 0
            and slogens >0
-        order by a.material_id desc
+        order by material_upload_time
             limit #{videoCnt}
     </select>
 
@@ -172,7 +172,7 @@
         and image.image_create_time &lt;= #{endTime}
         having creativeCnt &lt;= #{creativeCnt}
         and creativeNum = 0
-        order by image.image_create_time desc
+        order by image.image_create_time
             limit #{videoCnt}
     </select>
 
@@ -213,7 +213,7 @@
         and a.totalCost &gt; 500
         having creativeCnt &lt;= 100
         and creativeNum = 0
-        order by a.material_id desc
+        order by image_create_time
             limit #{videoCnt}
     </select>
 
@@ -255,7 +255,7 @@
         and a.totalCost &lt;= 100
         having creativeCnt &lt; 20
         and creativeNum = 0
-        order by a.material_id desc
+        order by image_create_time
             limit #{videoCnt}
     </select>
 

+ 5 - 6
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/entity/BytedanceOperationLog.java

@@ -1,19 +1,18 @@
 package org.jeecg.modules.bytedance.common.entity;
 
-import java.io.Serializable;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 /**
  * 操作日志
@@ -31,7 +30,7 @@ public class BytedanceOperationLog {
 	/**id*/
 	@TableId(type = IdType.UUID)
     @ApiModelProperty(value = "id")
-	private Integer id;
+	private String id;
 	/**原始数据*/
 	@Excel(name = "原始数据", width = 15)
     @ApiModelProperty(value = "原始数据")

+ 6 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/mapper/UserAllocationMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.bytedance.common.entity.UserAllocation;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * @Description: 用户分配
@@ -41,4 +42,9 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     List<UserAllocation> listByMediaId(@Param("mediaId")String mediaId, @Param("accountStatus")Integer accountStatus);
 
     List<JSONObject> getAccountListByProjectList(@Param("list") List list);
+
+
+    Set<String> recursiveQuerySubordinateByLeader(@Param("leaderId") String leaderId);
+    Set<String> recursiveQuerySubordinateByLeaders(@Param("leaderIds") Set<String> leaderId);
+
 }

+ 26 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/mapper/xml/UserAllocationMapper.xml

@@ -150,4 +150,30 @@
     </select>
 
 
+
+
+    <select id="recursiveQuerySubordinateByLeader" resultType="java.lang.String">
+        SELECT distinct id
+        FROM sys_user
+        WHERE leader_id = #{leaderId}
+          and status = 1
+          and del_flag = 0
+    </select>
+
+    <select id="recursiveQuerySubordinateByLeaders" resultType="java.lang.String">
+        SELECT distinct id
+        FROM sys_user
+        WHERE
+        status = 1
+        and del_flag = 0
+        and leader_id in
+        <foreach collection="leaderIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+
+
+
 </mapper>

+ 5 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/IUserAllocationService.java

@@ -6,6 +6,7 @@ import org.jeecg.modules.bytedance.common.entity.UserAllocation;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * @Description: 用户分配
@@ -40,4 +41,8 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     List<Long> getAccountsByDeleteComment();
 
     Map<Long, List<JSONObject>> getAccountListByProjectList(List<JSONObject> projectList);
+
+
+    //递归查询下级
+    Set<String> recursiveQuerySubordinate(String userId);
 }

+ 31 - 4
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/common/service/impl/UserAllocationServiceImpl.java

@@ -9,10 +9,7 @@ import org.jeecg.modules.bytedance.common.service.IUserAllocationService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @Description: 用户分配
@@ -139,4 +136,34 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         }
         return map;
     }
+
+
+
+    @Override
+    public Set<String> recursiveQuerySubordinate(String userId) {
+        Set<String> result;
+        //查询当前用户是否存在下级
+        Set<String> subordinate = userAllocationMapper.recursiveQuerySubordinateByLeader(userId);
+        if (subordinate.isEmpty()) {
+            subordinate.add(userId);
+            return subordinate;
+        } else {
+            result = querySubordinate(subordinate, subordinate);
+            result.add(userId);
+        }
+        return result;
+    }
+
+    //递归查询
+    private Set<String> querySubordinate(Set<String> leaderIds, Set<String> result) {
+        if (leaderIds.isEmpty()) {
+            return result;
+        }
+        Set<String> temp = userAllocationMapper.recursiveQuerySubordinateByLeaders(leaderIds);
+        result.addAll(temp);
+        querySubordinate(temp, result);
+        return result;
+    }
+
+
 }

+ 27 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/AiBytedanceAdvertiserStrategyController.java

@@ -20,10 +20,13 @@ import org.jeecg.modules.bytedance.advertise.vo.AdConvertQueryVo;
 import org.jeecg.modules.bytedance.advertise.vo.AdGroupSearchVo;
 import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
 import org.jeecg.modules.bytedance.common.constant.BytedanceConstant;
+import org.jeecg.modules.bytedance.common.entity.BytedanceOperationLog;
 import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
 import org.jeecg.modules.bytedance.common.entity.MaterialImageInfo;
 import org.jeecg.modules.bytedance.common.service.ICtopOauthTokenService;
 import org.jeecg.modules.bytedance.common.service.IMaterialImageInfoService;
+import org.jeecg.modules.bytedance.common.service.IUserAllocationService;
+import org.jeecg.modules.bytedance.common.service.impl.BytedanceOperationLogServiceImpl;
 import org.jeecg.modules.bytedance.common.utils.*;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -63,6 +66,11 @@ public class AiBytedanceAdvertiserStrategyController {
 	@Autowired
 	private ICtopOauthTokenService tokenService;
 
+	@Autowired
+	private IUserAllocationService userAllocationService;
+
+	@Autowired
+	private BytedanceOperationLogServiceImpl bytedanceOperationLogService;
 
 	/**
 	  * 分页列表查询
@@ -82,8 +90,13 @@ public class AiBytedanceAdvertiserStrategyController {
 		QueryWrapper<AiBytedanceAdvertiserStrategy> queryWrapper = QueryGenerator.initQueryWrapper(aiBytedanceAdvertiserStrategy, req.getParameterMap());
 		//获取用户角色code
 		String roleCode = sysRoleService.getRoleCodeByUserId(aiBytedanceAdvertiserStrategy.getLoginUserId());
-		if(null != roleCode && !BytedanceConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)){
-			queryWrapper.eq("user_id", aiBytedanceAdvertiserStrategy.getLoginUserId());
+		if (Check.isNull(roleCode)){
+			return Result.errorMsg("无法查询到该用户角色信息。");
+		}
+		if(!BytedanceConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)){
+			//查询所有包含自己的下级
+			Set<String> operatorUserIds= userAllocationService.recursiveQuerySubordinate(aiBytedanceAdvertiserStrategy.getLoginUserId());
+			queryWrapper.in("user_id", operatorUserIds);
 		}
 		queryWrapper.orderByDesc("create_time");
 		Page<AiBytedanceAdvertiserStrategy> page = new Page<AiBytedanceAdvertiserStrategy>(pageNo, pageSize);
@@ -173,6 +186,9 @@ public class AiBytedanceAdvertiserStrategyController {
 			}
 		}
 
+		//当前修改用户id -添加操作日志使用
+		String operationUserId = aiBytedanceAdvertiserStrategy.getUserId();
+
 		//不修改用户id
 		aiBytedanceAdvertiserStrategy.setUserId(null);
 		//商品卖点
@@ -199,6 +215,15 @@ public class AiBytedanceAdvertiserStrategyController {
 				return Result.errorMsg(resultBudget.getMessage());
 			}*/
 
+			//添加修改记录
+			BytedanceOperationLog bytedanceOperationLog = new BytedanceOperationLog();
+			bytedanceOperationLog.setOldData(aiBytedanceAdvertiserStrategyEntity.toString());
+			bytedanceOperationLog.setNewData(aiBytedanceAdvertiserStrategy.toString());
+			bytedanceOperationLog.setOperationType("头条账户配置-修改");
+			bytedanceOperationLog.setOperationContent("修改账户配置:"+aiBytedanceAdvertiserStrategy.getAccountId());
+			bytedanceOperationLog.setCreateById(operationUserId);
+			bytedanceOperationLog.setCreateTime(new Date());
+			bytedanceOperationLogService.save(bytedanceOperationLog);
 		}
 		return Result.successMsg("修改成功!", null);
 

+ 32 - 14
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/MaterialInfoController.java

@@ -1,15 +1,21 @@
 package org.jeecg.modules.bytedance.advertise.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
 import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.UUID;
 
 /**
  * 头条智能投放账户配置信息表
@@ -26,30 +32,42 @@ public class MaterialInfoController {
 	private IMaterialInfoService materialInfoService;
 
 
-
-	@ApiOperation(value="素材下线", notes="素材下线")
+	@ApiOperation(value = "素材下线", notes = "素材下线")
 	@GetMapping(value = "/updMaterialOfflineById")
 	public Result updMaterialOfflineById(@RequestParam("id") String id,
-								  		@RequestParam("offlineFlag") Integer offlineFlag) {
+										 @RequestParam("offlineFlag") Integer offlineFlag) {
 		try {
 			List<String> listIds = Arrays.asList(id.split(","));
-			if (listIds.size() > 8){
+			if (listIds.size() > 8) {
 				return Result.errorMsg("已选视频素材最多支持8个。");
 			}
-			return materialInfoService.updMaterialOfflineById(listIds,offlineFlag);
-		}catch (Exception e){
-			log.error("素材下线异常",e);
+			return materialInfoService.updMaterialOfflineById(listIds, offlineFlag);
+		} catch (Exception e) {
+			log.error("素材下线异常", e);
 			return Result.error("请求失败,请联系开发人员!");
 		}
 	}
 
 
-
-
-
-
-
-
+	/**
+	 * ============================================================================================================
+	 * 2021-09-23  zianY
+	 * describe: 该项目 淘宝特价版-拉活-头条 (1740895)  中 素材名称 包含 ‘0元购’ 同步素材数据到 头条-淘特-拉活-0元购素材项目(4380885)
+	 */
+	@GetMapping(value = "/initMaterialInfoDate")
+	public Result initMaterialInfoDate() {
+		QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
+		queryWrapper.eq("project_id", 1740895);
+		queryWrapper.like("material_name", "%0元购%");
+		List<MaterialInfo> list = materialInfoService.list(queryWrapper);
+		for (MaterialInfo materialInfo : list) {
+			materialInfo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
+			materialInfo.setProjectId(4380885L);
+			materialInfoService.save(materialInfo);
+		}
+		return Result.successMsg("成功", null);
+	}
+//* ============================================================================================================