소스 검색

Merge remote-tracking branch 'origin/test' into test

zhaoxian 3 년 전
부모
커밋
d4a95b23a0
13개의 변경된 파일594개의 추가작업 그리고 182개의 파일을 삭제
  1. 53 103
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java
  2. 14 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsPolicyInfo.java
  3. 10 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyInfoMapper.java
  4. 84 11
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml
  5. 10 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyInfoServiceImpl.java
  6. 10 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/KuaiShouMaterialStareController.java
  7. 1 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateAccountVo.java
  8. 1 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateProjectVo.java
  9. 6 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java
  10. 114 68
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml
  11. 3 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/MaterialStareService.java
  12. 159 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java
  13. 129 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/utils/LinkUtil.java

+ 53 - 103
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java

@@ -28,10 +28,7 @@ import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.ctop.finance.policy.entity.*;
-import org.jeecg.ctop.finance.policy.mapper.CwjsCompanyApprovalUserMapper;
-import org.jeecg.ctop.finance.policy.mapper.CwjsCompanySubjectMapper;
-import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyApprovalLogMapper;
-import org.jeecg.ctop.finance.policy.mapper.CwjsSaleAssistantInfoMapper;
+import org.jeecg.ctop.finance.policy.mapper.*;
 import org.jeecg.ctop.finance.policy.service.*;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
@@ -80,6 +77,8 @@ public class CwjsPolicyInfoController {
 	 @Resource
 	 CwjsCompanyApprovalUserMapper companyApprovalUserMapper;
 	 @Resource
+	 CwjsPolicyInfoMapper cwjsPolicyInfoMapper;
+	 @Resource
 	 CwjsCompanySubjectMapper companySubjectMapper;
 	 @Autowired
 	 ICwjsCompanySubjectService companySubjectService;
@@ -265,7 +264,7 @@ public class CwjsPolicyInfoController {
 	 */
 	@ApiOperation(value="政策信息表-分页列表查询", notes="政策信息表-分页列表查询")
 	@GetMapping(value = "/list")
-	public Result<PageInfo<CwjsPolicyInfo>> queryPageList(CwjsPolicyInfo cwjsPolicyInfo,
+	public Result queryPageList(CwjsPolicyInfo cwjsPolicyInfo,
 									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
 									  @RequestParam(name="userId") String userId,
@@ -273,114 +272,77 @@ public class CwjsPolicyInfoController {
 
 		//查询用户角色
         String roleCode = roleService.getRoleCodeByUserId(userId);
-        //查看用户是否为审核人员
-        List<CwjsCompanyApprovalUser> cwjsCompanyApprovalUserList = companyApprovalUserMapper.queryByUserId(userId);
-        //查询政策
-		List<CwjsPolicyInfo> cwjsPolicyInfoList = cwjsPolicyInfoService.queryPageList(cwjsPolicyInfo);
-		if(Check.isNull(cwjsPolicyInfoList)){
-			PageInfo<CwjsPolicyInfo> pageInfo = new PageInfo<>(cwjsPolicyInfoList);
-			return Result.successMsg("目前没有政策。",pageInfo);
-		}
-        /**如果是管理员,就全部看,该搜索搜索,不搜索就全看*/
 
-		List<String> res = new ArrayList<>();
+
+		List<String> userIds = new ArrayList<>();
 		if ("admin".equalsIgnoreCase(roleCode) || "finance".equalsIgnoreCase(roleCode) ){
 
 		}else if("saleDirector".equalsIgnoreCase(roleCode)){
 			//总监 看下属
-			res = cwjsPolicyInfoService.getAllSubordinate(userId);
-			// 与自己有 关联的人员
-			//List<String> sale = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(userId);
-			// 自己部门下的所有人员
-			//List <CwjsSaleAssistantInfo> saleList = cwjsSaleAssistantInfoMapper.getSaleListByUserDepart(userId);
-			//List<String> sale = saleList.stream().map(CwjsSaleAssistantInfo::getSaleId).collect(Collectors.toList());
-			//res.addAll(sale);
+			userIds = cwjsPolicyInfoService.getAllSubordinate(userId);
+
+		//法务
+		}else if("legalAffairs".equalsIgnoreCase(roleCode)){
+			//法务 查看 华北
+			cwjsPolicyInfo.setCompanySubjectId(1);
 		}else {
 			//查询 对应的销售或 助理
-			res = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(userId);
-			if (Check.isNull(res)){
-				res.add(userId);
+			userIds = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(userId);
+			if (Check.isNull(userIds)){
+				userIds.add(userId);
 			}
+
 		}
+		cwjsPolicyInfo.setSaleIds(userIds);
 
-		List<String> userIds = new ArrayList<>();
 
-		userIds.addAll(res);
-
-        /**如果不是管理员,也不是审核人员。
-		 * (看自己和自己下属的所有政策)  修改为 销售-助理 关联关系查看。
-		 * */
-        if(!"admin".equalsIgnoreCase(roleCode) && !"finance".equalsIgnoreCase(roleCode) && Check.isNull(cwjsCompanyApprovalUserList)){
-			//Set<String> userIds= materialReportOverViewService.recursiveQuerySubordinate(userId);
-			//List<String> userIds = cwjsPolicyInfoService.getAllSubordinate(userId);
-			List<CwjsPolicyInfo> removeList = new ArrayList<>();
-            cwjsPolicyInfoList.forEach(cwjsPolicy -> {
-                if(!userIds.contains(cwjsPolicy.getCreateUserId())){
-                    removeList.add(cwjsPolicy);
-                }
-            });
-            cwjsPolicyInfoList.removeAll(removeList);
-        }
-        /**如果不是管理员,是审核人员。看自己创建的和自己下属的所有政策、和该自己审核。*/
-        if(!"admin".equalsIgnoreCase(roleCode) && !"finance".equalsIgnoreCase(roleCode) && !Check.isNull(cwjsCompanyApprovalUserList)){
-//			Set<String> userIds= materialReportOverViewService.recursiveQuerySubordinate(userId);
-			//List<String> userIds = cwjsPolicyInfoService.getAllSubordinate(userId);
-			List<CwjsPolicyInfo> removeList = new ArrayList<>();
-			List<String> subList = cwjsCompanyApprovalUserList.stream().map(CwjsCompanyApprovalUser::getCompanySubjectId).collect(Collectors.toList());
-            //政策的主体 不是 审核人的主体 过滤 只保留 和审核人 是一样的主体的 政策
-			cwjsPolicyInfoList.forEach(cwjsPolicy -> {
-                //if(!userIds.contains(cwjsPolicy.getCreateUserId()) && !userId.equalsIgnoreCase(cwjsPolicy.getApprovedProgress())){
-                if(!subList.contains(String.valueOf(cwjsPolicy.getCompanySubjectId())) && !userIds.contains(cwjsPolicy.getCreateUserId())){
-                    removeList.add(cwjsPolicy);
-                }
-            });
-            cwjsPolicyInfoList.removeAll(removeList);
-        }
+        //查询政策
+		List<CwjsPolicyInfo> cwjsPolicyInfoList = cwjsPolicyInfoService.queryPageList(cwjsPolicyInfo);
+		if(Check.isNull(cwjsPolicyInfoList)){
+			return Result.successMsg("没有符合条件的政策,请重新选择。",null);
+		}
+
 
-		cwjsPolicyInfoList.sort((CwjsPolicyInfo o1, CwjsPolicyInfo o2) -> o2.getCreateTime().after(o1.getCreateTime()) ? 1 : -1 );
 		List<CwjsPolicyInfo> cwjsPolicyInfos = ListPageUtil.page(cwjsPolicyInfoList, pageSize, pageNo);
 
 		cwjsPolicyInfos.forEach(cwjsPolicy ->{
 			CwjsPolicyApprovalLog log = policyApprovalLogMapper.getOneByPolicyId(cwjsPolicy.getId(),1);	// 查询 被拒 审核意见 最新的一条
-			if(!Check.isNull(log)){
-				cwjsPolicy.setApprovalContent(log.getApprovalContent());
-			}
+			cwjsPolicy.setApprovalContent(Check.isNull(log) ? "暂无被拒意见" : log.getApprovalContent());
+
 			CwjsPolicyApprovalLog bossContent = policyApprovalLogMapper.getOneByPolicyId(cwjsPolicy.getId(),2);	// 查询 转发领导的 审核意见 最新的一条
-			cwjsPolicy.setTheBossContent(Check.isNull(bossContent) ? "" : bossContent.getApprovalContent());
+			cwjsPolicy.setTheBossContent(Check.isNull(bossContent) ? "暂无老板审核意见" : bossContent.getApprovalContent());
 
-			//根据主体查询 最后一个审核人员
-			CwjsCompanyApprovalUser approvalUser = companyApprovalUserMapper.getEndApprovalUserBySub(cwjsPolicy.getCompanySubjectId());
-			//政策当前审核人 = 最后一个审核人 = 当前用户   && 状态不为3 审核通过  && 状态不为4 审核拒绝  ||  当前用户 不是老板
-			// 则显示 转领导审批
-
-			if(cwjsPolicy.getApprovedStatus() != 3 && cwjsPolicy.getApprovedStatus() != 4){
-				if (cwjsPolicy.getApprovedProgress().equals(approvalUser.getApprovalUserId()) && approvalUser.getApprovalUserId().equals(userId)
-						&& !"4aba62011120ac565c7f2b9f8f4aa96b".equals(userId)){
-					cwjsPolicy.setTheBossRight("yes");
-				}
-			}else {
-				cwjsPolicy.setTheBossRight("no");
-			}
+			CwjsPolicyApprovalLog legalContent = policyApprovalLogMapper.getOneByPolicyId(cwjsPolicy.getId(),11);	// 查询 法务 审核意见 最新的一条
+			cwjsPolicy.setLegalAffairsContent(Check.isNull(legalContent) ? "暂无法务审核意见" : legalContent.getApprovalContent());
 
 
+			String directorUserId = "";
+			//主体为1 为 华北
+			if (cwjsPolicy.getCompanySubjectId() == 1){
+				//查询 该销售 所属的审核人员
+				//华北审核人员 - 法务==>销售总监(销售上级)==>手动转领导/自动转领导
+				directorUserId = cwjsPolicyInfoMapper.getUserLeaderAndDirectorByRoleName(userId,"法务").getString("leaderId");
 
+			}else {
+				//查询 该销售 所属的审核人员
+				//华南审核人员 - 销售总监(销售上级) ==> 分公司经理 ==>转领导
+				directorUserId = cwjsPolicyInfoMapper.getUserLeaderAndDirectorByRoleName(userId,"分公司总经理").getString("directorId");
+
+			}
+
+				//政策当前审核人 = 最后一个审核人 = 当前用户   && 状态不为3 审核通过  && 状态不为4 审核拒绝  ||  当前用户 不是老板
+				// 则显示 转领导审批
+				if(cwjsPolicy.getApprovedStatus() != 3 && cwjsPolicy.getApprovedStatus() != 4){
+					if (cwjsPolicy.getApprovedProgress().equals(directorUserId) && directorUserId.equals(userId)
+							&& !"80e747cdea6f41dbbc8cde23046fd4e0".equals(userId)){
+						cwjsPolicy.setTheBossRight("yes");
+					}
+				}else {
+					cwjsPolicy.setTheBossRight("no");
+				}
 
-			//所有人只要能看到就能有查看的按钮
-          /*  cwjsPolicy.setOperation("查看");
 
-			//查询 对应的销售或 助理
-			List <String> assistantList = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(cwjsPolicy.getCreateUserId());
-			if((assistantList.contains(userId) || assistantList.contains(cwjsPolicy.getCreateUserId())) && cwjsPolicy.getApprovedStatus() == 4){ //创建人是自己且状态是审核拒绝的
-                cwjsPolicy.setOperation("查看|编辑|提交审核");
-            }
 
-			if(userId.equals(cwjsPolicy.getApprovedProgress()) && (cwjsPolicy.getApprovedStatus() == 1 || cwjsPolicy.getApprovedStatus() == 2)){
-                cwjsPolicy.setOperation("查看|审核通过|审核拒绝");
-            }
-			if(userId.equals(cwjsPolicy.getApprovedProgress()) && cwjsPolicy.getApprovedStatus() == 4 && !userId.equals(cwjsPolicy.getCreateUserId())){
-                cwjsPolicy.setOperation("查看");
-            }
-*/
 			StringBuilder stringBuilder = new StringBuilder();
 
 			//审核拒绝
@@ -388,7 +350,7 @@ public class CwjsPolicyInfoController {
 				//有 销售-助理 关联的人员 都可以编辑
 				if(!"admin".equalsIgnoreCase(roleCode) && !"finance".equalsIgnoreCase(roleCode)){
 					List <String> saleOrAssis = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(userId);
-					if(saleOrAssis.contains(cwjsPolicy.getCreateUserId())){
+					if(saleOrAssis.contains(cwjsPolicy.getSaleId())){
 						stringBuilder.append("编辑").append("|").append("提交审核").append("|");
 					}
 				}
@@ -399,24 +361,12 @@ public class CwjsPolicyInfoController {
 					stringBuilder.append("审核通过").append("|").append("审核拒绝").append("|");
 				}
 			}
-		//审核通过
-			/*if (cwjsPolicy.getApprovedStatus() == 3){
-					stringBuilder.append("查看");
-			}*/
+
 			stringBuilder.append("查看").append("|");
 			cwjsPolicy.setOperation(stringBuilder.deleteCharAt(stringBuilder.lastIndexOf("|")).toString());
 
 
 
-			// 用户 公司
-			UserCompany userCompany = userCompanyService.getByUserId(cwjsPolicy.getCreateUserId());
-			if(!Check.isNull(userCompany) && Check.isNull(cwjsPolicy.getCreateUserName())){
-				cwjsPolicy.setCreateUserName(userCompany.getUserName());
-			}
-			//主体 以及 区域
-			CwjsCompanySubject cwjsCompanySubject = companySubjectService.getById(cwjsPolicy.getCompanySubjectId());
-			cwjsPolicy.setCompanySubjectName(cwjsCompanySubject.getCompanySubjectName());
-			cwjsPolicy.setAreaInfo(cwjsCompanySubject.getAreaInfo());
 		});
 		PageInfo<CwjsPolicyInfo> pageInfo = new PageInfo<>(cwjsPolicyInfos);
 		pageInfo.setTotal(cwjsPolicyInfoList.size());

+ 14 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsPolicyInfo.java

@@ -116,6 +116,17 @@ public class CwjsPolicyInfo implements Serializable{
 	@Excel(name = "创建人名字", width = 15)
 	@ApiModelProperty(value = "创建人名字")
 	private String createUserName;
+
+
+	@ApiModelProperty(value = "销售id")
+	private String saleId;
+	@TableField(exist = false)
+	private List<String> saleIds;
+
+	@TableField(exist = false)
+	@ApiModelProperty(value = "销售姓名")
+	private String saleName;
+
 	/**创建时间*/
     @ApiModelProperty(value = "创建时间")
 	private Date createTime;
@@ -157,4 +168,7 @@ public class CwjsPolicyInfo implements Serializable{
 	/* 给老板审核的理由*/
 	@TableField(exist = false)
 	private String theBossContent;
+	/* 法务审核意见*/
+	@TableField(exist = false)
+	private String legalAffairsContent;
 }

+ 10 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyInfoMapper.java

@@ -15,6 +15,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @version V1.0
  */
 public interface CwjsPolicyInfoMapper extends BaseMapper<CwjsPolicyInfo> {
+
+    //查看政策列表
     List<CwjsPolicyInfo> selectPolicyInfos(CwjsPolicyInfo policyInfo);
 
     List<JSONObject> getAllSale();
@@ -32,4 +34,12 @@ public interface CwjsPolicyInfoMapper extends BaseMapper<CwjsPolicyInfo> {
     void updatePolicyInfoById(CwjsPolicyInfo policyInfo);
 
     CwjsPolicyInfo getPolicyInfo(CwjsPolicyInfo policyInfo);
+
+
+
+
+    //查询用户所属公司及区域 以及 上级领导 和 分公司负责人
+    JSONObject getUserLeaderAndDirectorByRoleName(@Param("userId") String userId,@Param("roleName") String roleName);
+
+
 }

+ 84 - 11
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml

@@ -1,8 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper">
+
+
+    <!-- 查看政策列表 -->
     <select id="selectPolicyInfos" resultType="org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo">
-        select t1.policy_product_name as productName,t2.* from ctop_cwjs_policy_product t1 LEFT JOIN ctop_cwjs_policy_info t2 on t1.policy_id = t2.id
+        select t1.policy_product_name as productName,t2.* ,
+               (select u.realname from sys_user u where u.id = t2.sale_id) as saleName,
+                sub.company_subject_name CompanySubjectName
+        from ctop_cwjs_policy_product t1
+            LEFT JOIN ctop_cwjs_policy_info t2 on t1.policy_id = t2.id
+        LEFT JOIN ctop_cwjs_company_subject sub on sub.id = t2.company_subject_id
         where t1.del_flag = 0 and t2.del_flag = 0
         <if test="companyName != null and companyName != ''">and t2.company_name like concat(concat('%',#{companyName}),'%')</if>
         <if test="advertiserName != null and advertiserName != ''">and t2.advertiser_name like concat(concat('%',#{advertiserName}),'%')</if>
@@ -10,21 +18,36 @@
         <if test="dianPayCompanyName != null and dianPayCompanyName != ''">and t2.dian_pay_company_name like concat(concat('%',#{dianPayCompanyName}),'%')</if>
         <if test="mediaType != null">and t2.media_type = #{mediaType}</if>
         <if test="rebateType != null">and t2.rebate_type = #{rebateType}</if>
-        <if test="createUserId != null and createUserId != ''">and t2.create_user_id = #{createUserId}</if>
-        <if test="createUserName != null and createUserName != ''">and t2.create_user_name = #{createUserName}</if>
-        <if test="createUserIds != null and createUserIds != ''">and  t2.create_user_id in
-         <foreach item="item" index="index" collection="createUserIds" open="(" separator="," close=")">
-            #{item}
-        </foreach></if>
-        <if test="companySubjectIds != null and companySubjectIds != ''">and  t2.company_subject_id in
-            <foreach item="item" index="index" collection="companySubjectIds" open="(" separator="," close=")">
+
+
+        <if test="saleIds != null and saleIds.size() > 0">
+            and  (t2.sale_id in
+            <foreach item="item" index="index" collection="saleIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            or  t2.create_user_id in
+            <foreach item="item" index="index" collection="saleIds" open="(" separator="," close=")">
                 #{item}
-            </foreach></if>
+            </foreach>
+                )
+        </if>
+
+        <if test="approvedProgress != null and approvedProgress != ''">
+          and t2.approved_progress = #{approvedProgress}
+        </if>
+
+        <if test="companySubjectId != null and companySubjectId != ''">
+          and t2.company_subject_id = #{companySubjectId}
+        </if>
+
+
         <if test="promotionType != null">and t2.promotion_type = #{promotionType}</if>
         <if test="approvedStatus != null and approvedStatus != ''">and t2.approved_status = #{approvedStatus}</if>
         <if test="startTime != null and startTime != ''">and t2.create_time &gt;= #{startTime}</if>
         <if test="endTime != null and endTime != ''">and t2.create_time &lt;= concat(#{endTime},' 23:59:59')</if>
-        <if test="approvedProgress != null and approvedProgress != ''">and t2.approved_progress = #{approvedProgress}</if>
+
+
+
         <if test="policyStartDate != null and policyStartDate != '' and policyEndDate != null and policyEndDate != ''">
         and ((#{policyStartDate} &lt;= t2.policy_start_date and #{policyEndDate} &gt;= t2.policy_start_date)
         or (#{policyStartDate} &gt;= t2.policy_start_date and #{policyStartDate} &lt;= t2.policy_end_date))
@@ -129,6 +152,7 @@
              policy_start_date = #{policyStartDate},
              policy_end_date = #{policyEndDate},
              remarks = #{remarks},
+             sale_id = #{saleId},
              create_user_id = #{createUserId},
              create_user_name = #{createUserName}
         where id = #{id}
@@ -215,6 +239,55 @@
 
 
 
+    <!-- 查询用户所属公司及区域 以及 上级领导 和 分公司负责人 -->
+    <select id="getUserLeaderAndDirectorByRoleName" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            a.company_id companyId,
+            a.company_name companyName,
+            a.nick_name areaName,
+            a.leader_id leaderId,
+            a.leader_name leaderName,
+            b.realname directorName,
+            b.role_code directorRoleCode,
+            b.user_id directorId
+        FROM
+            (
+                SELECT
+                    c.company_id,
+                    c.company_name,
+                    c.nick_name,
+                    u.leader_id,
+                    u.leader_name
+                FROM
+                    `user_company` c
+                        LEFT JOIN sys_user u on c.user_id = u.id
+                WHERE
+                    user_id = #{userId}
+            ) a LEFT JOIN
+            (
+                SELECT
+                    sr.role_name,
+                    sr.role_code,
+                    sur.user_id ,
+                    su.realname,
+                    uc.company_id,
+                    uc.company_name,
+                    uc.nick_name
+                FROM
+                    sys_user_role sur
+                        LEFT JOIN sys_role sr ON sur.role_id = sr.id
+                        LEFT JOIN user_company uc on uc.user_id = sur.user_id
+                        LEFT JOIN sys_user su on su.id = uc.user_id
+                WHERE
+                    sr.role_name = #{roleName}
+            )b
+            on a.company_id = b.company_id
+            limit 1
+    </select>
+
+
+
+
 
 
 

+ 10 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyInfoServiceImpl.java

@@ -28,6 +28,16 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     @Resource
     CwjsPolicyInfoMapper policyInfoMapper;
 
+    /**
+     *
+     * @description: 查看政策列表
+     *  已通过的政策 按照 产品名称 拆分多条
+     *
+     * @param policyInfo
+     * @return: java.util.List<org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo>
+     * @author: zianY
+     * @time: 2022/3/29
+     */
     @Override
     public List<CwjsPolicyInfo> queryPageList(CwjsPolicyInfo policyInfo){
 

+ 10 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/KuaiShouMaterialStareController.java

@@ -282,6 +282,16 @@ public class KuaiShouMaterialStareController {
     }
 
 
+    @GetMapping("/realTime/getUnitDateInfo")
+    public Result<JSONObject> kuaiShouOperateDateTotalPersonal(@RequestParam(name="accountId") long accountId,
+                                                               @RequestParam(name="pageNum") Integer pageNum,
+                                                               @RequestParam(name="pageSize") Integer pageSize) {
+
+        return materialStareService.kuaiShouRealTimeUnitDateInfo(accountId, pageNum, pageSize);
+    }
+
+
+
 
     /**
      * 获取用户下级的项目以及账户信息

+ 1 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateAccountVo.java

@@ -25,6 +25,7 @@ public class KuaiShouOperateAccountVo {
 
     @ApiModelProperty(value = "运营姓名")
     private String userName;
+    private String userId;
 
     @ApiModelProperty(value = "预算")
     private Double warningAmount;

+ 1 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateProjectVo.java

@@ -25,6 +25,7 @@ public class KuaiShouOperateProjectVo {
 
     @ApiModelProperty(value = "用户数量")
     private Integer userNum;
+    private String userId;
 
     @ApiModelProperty(value = "激活数")
     private Integer activation;

+ 6 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -43,6 +43,9 @@ public interface MaterialStareMapper {
     //快手-查询账户数据信息
     List<KuaiShouOperateVo> getKuaiShouOperateInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
 
+    //查看 快手 有效 计划 组
+    JSONObject getKuaiShouAccountBaseByUserId(@Param("userId")String userId,@Param("projectId")String projectId,@Param("accountId")String accountId,@Param("startDate")Long startDate, @Param("endDate")Long endDate);
+
     //快手 -查询 项目 数据信息
     List<KuaiShouOperateProjectVo> getKuaiShouOperateProjectInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
 
@@ -75,6 +78,9 @@ public interface MaterialStareMapper {
     //快手 账户饼图图-分性别
     List<KuaiShouAccountPieVo> getKuaiShouAccountPieGender(@Param("accountId")Long accountId, @Param("startDate")Long startDate, @Param("endDate")Long endDate,@Param("type")String type);
 
+    //快手组实时数据查询-当天创建的组+当天有消耗的组
+    List<JSONObject> kuaiShouRealTimeUnitDateInfo(@Param("accountId")Long accountId, @Param("nowDate")Long nowDate);
+
 
     //快手 账户 框返 激励 消耗
     JSONObject getKuaiShouAccountCharged(@Param("startDate")Long startDate, @Param("endDate")Long endDate,@Param("list")Set<String> operatorUserIds);

+ 114 - 68
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -143,6 +143,36 @@
         </if>
     </select>
 
+    <!-- 查看 快手 有效 计划 组-->
+    <select id="getKuaiShouAccountBaseByUserId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT abi.account_id ,
+        SUM(abi.new_effect_num) as newEffectNum,
+        SUM(abi.new_campaign_num) as newCampaignNum,
+        SUM(abi.new_unit_num) as newUnitNum,
+        SUM( abi.new_video_num ) AS newVideoNum,
+        SUM( abi.new_hot_num ) AS newHotNum
+        from application.app_kuaishou_account_base_info_d abi,
+        `jeecg-boot`.ctop_user_allocation u
+        WHERE abi.account_id = u.account_id
+        and u.account_status = 0
+        <if test="startDate != null and startDate != '' ">
+            and abi.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and abi.stat_date &lt;= #{endDate}
+        </if>
+        <if test="userId != null and userId != '' ">
+            and abi.user_id = #{userId}
+        </if>
+        <if test="projectId != null and projectId != '' ">
+            and abi.project_id = #{projectId}
+        </if>
+        <if test="accountId != null and accountId != '' ">
+            and abi.account_id = #{accountId}
+        </if>
+
+    </select>
+
 
 
     <!-- 快手 快手-查询账户数据信息 -->
@@ -151,32 +181,13 @@
         SUM( d.charge ) totalCost,
         COUNT(DISTINCT d.account_id) accountNum,
         d.user_id as userId,
-        (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName,
-        IFNULL(m.newEffectNum,0) as newEffectNum,
-        IFNULL(m.newCampaignNum,0) as newCampaignNum,
-        IFNULL(m.newUnitNum,0) as newUnitNum
+        (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
         FROM
         application.kuaishou_account_report_daily_dw d
-        LEFT JOIN
-        (
-        SELECT abi.account_id ,
-        SUM(abi.new_effect_num) as newEffectNum,
-        SUM(abi.new_campaign_num) as newCampaignNum,
-        SUM(abi.new_unit_num) as newUnitNum
-        from application.app_kuaishou_account_base_info_d abi
-            <where>
-                <if test="startDate != null and startDate != '' ">
-                    and abi.stat_date &gt;= #{startDate}
-                </if>
-                <if test="endDate != null and endDate != '' ">
-                    and abi.stat_date &lt;= #{endDate}
-                </if>
-            </where>
-            GROUP BY abi.account_id
-        ) m
-        on d.account_id = m.account_id
+        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.charge > 0
+        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -201,6 +212,7 @@
         COUNT( DISTINCT d.account_id ) AS accountNum,
         d.project_id AS projectId,
         d.project_name AS projectName,
+        d.user_id AS userId,
         COUNT( DISTINCT d.user_id ) AS userNum,
         IFNULL(SUM( d.activation ),0)  AS activation,
         IF(SUM( d.charge ) / SUM( d.activation ) > 0.0001,ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ),0) AS activationPrice,
@@ -221,33 +233,13 @@
         IFNULL(SUM( d.event_pay_purchase_amount_first_day ),0)  AS eventPayPurchaseAmountFirstDay,
         IFNULL(SUM( d.event_pay_first_day_roi ),0)  AS eventPayFirstDayRoi,
         IFNULL(SUM( d.form_count ),0) AS formCount,
-        IFNULL(ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ),0) AS formCountPrice,
-        IFNULL(m.newEffectNum,0) AS newEffectNum,
-        IFNULL(m.newVideoNum,0) AS newVideoNum,
-        IFNULL(m.newHotNum,0) AS newHotNum
+        IFNULL(ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ),0) AS formCountPrice
         FROM
         application.kuaishou_account_report_daily_dw d
-        LEFT JOIN (
-            SELECT
-            abi.account_id,
-            SUM( abi.new_effect_num ) AS newEffectNum,
-            SUM( abi.new_video_num ) AS newVideoNum,
-            SUM( abi.new_hot_num ) AS newHotNum
-            FROM
-            application.app_kuaishou_account_base_info_d abi
-            <where>
-                    <if test="startDate != null and startDate != '' ">
-                        and abi.stat_date &gt;= #{startDate}
-                    </if>
-                    <if test="endDate != null and endDate != '' ">
-                        and abi.stat_date &lt;= #{endDate}
-                    </if>
-                </where>
-                GROUP BY abi.account_id
-        ) m
-        on d.account_id = m.account_id
+        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.charge > 0
+        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -278,6 +270,7 @@
         d.account_name as accountName,
         d.project_id AS projectId,
         d.project_name AS projectName,
+        d.user_id AS userId,
         COUNT( DISTINCT d.user_id ) AS userNum,
         ( SELECT u.realname FROM `jeecg-boot`.sys_user u WHERE u.id = d.user_id ) AS userName,
         (SELECT u.warning_amount FROM `jeecg-boot`.ctop_user_allocation u where u.account_id = d.account_id) as warningAmount,
@@ -303,33 +296,13 @@
         IFNULL(SUM( d.form_count ),0) AS formCount,
         IFNULL(ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ),0) AS formCountPrice,
         IFNULL(SUM(d.`show`),0) as photoShow,
-        IFNULL(SUM(d.photo_click),0) as photoClick,
-        IFNULL(m.newEffectNum,0) AS newEffectNum,
-        IFNULL(m.newVideoNum,0) AS newVideoNum,
-        IFNULL(m.newHotNum,0) AS newHotNum
+        IFNULL(SUM(d.photo_click),0) as photoClick
         FROM
         application.kuaishou_account_report_daily_dw d
-        LEFT JOIN (
-            SELECT
-            abi.account_id,
-            SUM( abi.new_effect_num ) AS newEffectNum,
-            SUM( abi.new_video_num ) AS newVideoNum,
-            SUM( abi.new_hot_num ) AS newHotNum
-            FROM
-            application.app_kuaishou_account_base_info_d abi
-            <where>
-                    <if test="startDate != null and startDate != '' ">
-                        and abi.stat_date &gt;= #{startDate}
-                    </if>
-                    <if test="endDate != null and endDate != '' ">
-                        and abi.stat_date &lt;= #{endDate}
-                    </if>
-                </where>
-                GROUP BY abi.account_id
-        ) m
-        on d.account_id = m.account_id
+        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.charge > 0
+        and u.account_status = 0
         <if test="startDate != null and startDate != '' ">
             and d.stat_date &gt;= #{startDate}
         </if>
@@ -963,6 +936,79 @@
     </select>
 
 
+    <!-- 快手组实时数据查询-当天创建的组+当天有消耗的组 -->
+    <select id="kuaiShouRealTimeUnitDateInfo" resultType="com.alibaba.fastjson.JSONObject">
+
+    SELECT t.*,
+           l.bid_type bidType,
+           l.bid,
+           l.cpa_bid cpaBid,
+           l.put_status putStatus
+    from (
+        SELECT IFNULL(a.advertiser_id,b.dAccountId) accountId,
+               IFNULL(a.uid,b.dunit_id) unit_id,
+                a.*,b.*
+        from (
+            SELECT
+            ad.advertiser_id as advertiser_id,
+            ad.unit_id uid,
+            ad.ocpx_action_type
+            FROM
+            media_api.kuaishou_ad_unit_list ad
+            WHERE
+            ad.advertiser_id = #{accountId}
+            AND DATE_FORMAT( ad.create_time, "%Y%m%d" ) = #{nowDate}
+            ) a RIGHT JOIN
+            (
+            SELECT
+            d.advertiser_id dAccountId,
+            d.campaign_id campaignId,
+            d.campaign_name campaignName,
+            d.unit_id dunit_id,
+            d.unit_name unitName,
+            IFNULL( SUM( d.charge ), 0 ) AS charge,
+            IFNULL( SUM( d.activation ), 0 ) AS activation,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ), 0 ) AS activationPrice,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ), 0 ) AS activationCost,
+            IF(SUM( d.event_next_day_stay ) / SUM( d.activation ) > 0.0001,CONCAT( ROUND( SUM( d.event_next_day_stay ) / SUM( d.activation ) * 100, 2 ), '%' ),0 ) AS `leave`,
+            IFNULL( SUM( d.event_pay ), 0 ) AS eventPay,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_pay ), 2 ), 0 ) AS eventPayCost,
+            IF(SUM( d.event_pay ) / (SUM( d.activation ) + SUM( d.form_count )) > 0.0001,CONCAT(ROUND( SUM( d.event_pay ) / ( SUM( d.activation ) + SUM( d.form_count )) * 100, 2),'%'),0 ) AS eventPayRate,
+            IFNULL( SUM( d.event_new_user_pay ), 0 ) AS eventNewUserPay,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_new_user_pay ), 2 ), 0 ) AS eventNewUserPayCost,
+            IFNULL( ROUND( SUM( d.event_new_user_pay ) / ( SUM( d.activation ) + SUM( d.form_count )), 2 ), 0 ) AS eventNewUserPayRate,
+            IFNULL( SUM( d.event_app_invoked ), 0 ) AS eventAppInvoked,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_app_invoked ), 2 ), 0 ) AS eventAppInvokedCost,
+            IFNULL( SUM( d.event_register ), 0 ) AS eventRegister,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_register ), 2 ), 0 ) AS eventRegisterCost,
+            IFNULL( SUM( d.key_action ), 0 ) AS keyAction,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.key_action ), 2 ), 0 ) AS keyActionCost,
+            IF(SUM( d.key_action )/ SUM( d.activation ) > 0.0001,CONCAT( ROUND( SUM( d.key_action )/ SUM( d.activation ) * 100, 2 ), '%' ),0) AS keyActionRate,
+            IFNULL( SUM( d.event_pay_purchase_amount_first_day ), 0 ) AS eventPayPurchaseAmountFirstDay,
+            IFNULL( SUM( d.event_pay_first_day_roi ), 0 ) AS eventPayFirstDayRoi,
+            IFNULL( SUM( d.form_count ), 0 ) AS formCount,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ), 0 ) AS formCountPrice,
+            SUM(d.bclick) bClick
+            FROM
+            media_api.kuaishou_unit_report_hourly d
+            WHERE
+            d.advertiser_id = #{accountId}
+            AND d.stat_date = #{nowDate}
+            GROUP BY
+            d.unit_id
+            ) b
+        on a.uid = b.dunit_id
+        ) t
+        LEFT JOIN media_api.kuaishou_ad_unit_list l
+        on l.unit_id = t.unit_id
+        WHERE l.advertiser_id = #{accountId}
+
+
+
+    </select>
+
+
+
 
 
 

+ 3 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/MaterialStareService.java

@@ -37,6 +37,9 @@ public interface MaterialStareService {
     Result getKuaiShouAccountPieChar(long accountId,String startTime, String endTime,String type);
 
 
+    Result kuaiShouRealTimeUnitDateInfo(long accountId,Integer pageNum,Integer pageSize);
+
+
     Result getCompanyAllSubordinateByUserId(String userId);
 
 

+ 159 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java

@@ -6,6 +6,7 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -19,6 +20,7 @@ import org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo;
 import org.jeecg.ctop.material.mapper.MaterialStareMapper;
 import org.jeecg.ctop.material.service.MaterialStareService;
 import org.jeecg.ctop.material.utils.FeidNotNullUtils;
+import org.jeecg.ctop.material.utils.LinkUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -365,6 +367,13 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         //查询运营数据
         List<KuaiShouOperateVo> listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
         for (KuaiShouOperateVo operate : listOperate) {
+
+            //查询 有效 上新计划 上新组
+            JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operate.getUserId(),null,null,startDate,entDate);
+            operate.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+            operate.setNewCampaignNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newCampaignNum"));//计划
+            operate.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+
             Set<String> userSet = new HashSet<String>(){{
                 add(operate.getUserId());
             }};
@@ -402,6 +411,13 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         //查询运营数据
         List<KuaiShouOperateVo> listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
         for (KuaiShouOperateVo operate : listOperate) {
+
+            //查询 有效 上新计划 上新组
+            JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operate.getUserId(),null,null,startDate,entDate);
+            operate.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+            operate.setNewCampaignNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newCampaignNum"));//计划
+            operate.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+
             Set<String> userSet = new HashSet<String>(){{
                 add(operate.getUserId());
             }};
@@ -468,6 +484,14 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             //查询运营数据-项目维度
             List<KuaiShouOperateProjectVo> listOperate = materialStareMapper.getKuaiShouOperateProjectInfo(startDate,entDate,null,operatorUserIds);
             for (KuaiShouOperateProjectVo projectInfo : listOperate) {
+
+                //查询 有效 上新视频 爆款视频
+                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(null,projectInfo.getProjectId(),null,startDate,entDate);
+                projectInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+                projectInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
+                projectInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
+
+
                 String projectId = projectInfo.getProjectId();
                 List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getKuaiShouOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
                 //环比 = (当前 - 上阶段 ) / 上阶段
@@ -542,6 +566,13 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             //查询运营数据-账户 维度
             List<KuaiShouOperateAccountVo> listOperate = materialStareMapper.getKuaiShouOperateAccountInfo(startDate,entDate,projectId,null,operatorUserIds);
             for (KuaiShouOperateAccountVo accountInfo : listOperate) {
+
+                //查询 有效 上新视频 爆款视频
+                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(null,null,String.valueOf(accountInfo.getAccountId()),startDate,entDate);
+                accountInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+                accountInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
+                accountInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
+
                 long accountId = accountInfo.getAccountId();
                 List<KuaiShouOperateAccountVo> accountYearOnYearInfo = materialStareMapper.getKuaiShouOperateAccountInfo(lastTimeStart,lastTimeEnd,projectId,accountId,operatorUserIds);
                 //环比 = (当前 - 上阶段 ) / 上阶段
@@ -701,6 +732,134 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         return Result.successMsg("查询饼图数据成功。",resultMap);
     }
 
+    @Override
+    public Result kuaiShouRealTimeUnitDateInfo(long accountId, Integer pageNum, Integer pageSize) {
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+        // ==>> 20220202
+        String now = sdf.format(new Date());
+        long nowDate = Long.valueOf(now);
+
+        PageHelper.startPage(pageNum,pageSize);
+        List<JSONObject> ListUnit = materialStareMapper.kuaiShouRealTimeUnitDateInfo(accountId,nowDate);
+        for (JSONObject unitVo : ListUnit) {
+
+            //优化目标
+           Integer conver = Check.isNull(unitVo.getInteger("ocpx_action_type")) ? 0 : unitVo.getInteger("ocpx_action_type");
+
+            //优化目标: 激活,  付费,  行为,  表单提交,  注册,  唤起应用,  关键行为
+            //对应转化数 激活数,付费数,行为数,表单提交数,注册数,唤起应用次数,关键行为数
+            //优化目标id 来源---ctop_kuaishou_ocpx_action_type_config
+            unitVo.put("converNum",0);//默认
+            //激活
+            if (conver == 180) {
+                unitVo.put("converNum",unitVo.getInteger("activation"));
+            }
+            //付费
+            if (conver == 190) {
+                unitVo.put("converNum",unitVo.getInteger("eventPay"));
+            }
+            //行为
+            if (conver == 2) {
+                unitVo.put("converNum",unitVo.getInteger("bClick"));
+            }
+            //表单提交
+            if (conver == 53) {
+                unitVo.put("converNum",unitVo.getInteger("formCount"));
+            }
+            //注册
+            if (conver == 396) {
+                unitVo.put("converNum",unitVo.getInteger("eventRegister"));
+            }
+            //唤起应用
+            if (conver == 324) {
+                unitVo.put("converNum",unitVo.getInteger("eventAppInvoked"));
+            }
+            //关键行为
+            if (conver == 773) {
+                unitVo.put("converNum",unitVo.getInteger("keyAction"));
+            }
+
+            //转化成本 = 花费 / 转化数
+            double converCost = unitVo.getInteger("converNum") == 0 ? 0 : unitVo.getDouble("charge") / unitVo.getInteger("converNum");
+            unitVo.put("converCost",converCost);
+
+
+            //操作建议
+
+            //消耗
+            Double charge = unitVo.getDoubleValue("charge");
+
+            //出价 单位:厘
+            long bid = new Long("1000");
+            //2:CPC
+            if (unitVo.getInteger("bidType") == 2){
+                bid = unitVo.getLong("bid");
+            //10:OCPM
+            }else if(unitVo.getInteger("bidType") == 10){
+                bid = unitVo.getLong("cpaBid");
+            }
+            Double price = new Double(bid/1000).doubleValue();
+
+            //转化数量
+            Integer converNum = unitVo.getInteger("converNum");
+
+            unitVo.put("operationAgree","暂无");
+            unitVo.put("operationContent","暂无");
+            unitVo.put("operationAgreeInfo","暂无");
+
+            //1. 转化成本大于出价×120%,消耗大于500元:
+            if ((converCost > price * 1.2) && (charge > 500)) {
+                unitVo.put("operationAgree","高成本 | 有消耗");
+                unitVo.put("operationContent","建议限制预算");
+                unitVo.put("operationAgreeInfo","当前广告组转化成本偏高且消耗大于500,建议限制预算;");
+            }
+            //2.  转化成本大于出价×120%,转化数大于10小于等于50:
+            if (converCost > price * 1.2 && LinkUtil.isInTheInterval(String.valueOf(converNum), "(10,50)")) {
+
+                unitVo.put("operationAgree","高成本 | 有转化");
+                unitVo.put("operationContent","建议限制预算");
+                unitVo.put("operationAgreeInfo","当前广告组成本大于出价×120%且转化数介于10-50之间;");
+            }
+            //3. 转化成本大于出价×120%,转化数大于50
+            if (converCost > price * 1.2 && LinkUtil.isInTheInterval(String.valueOf(converNum), "(50,∞)")) {
+                unitVo.put("operationAgree","高成本 | 有转化");
+                unitVo.put("operationContent","建议降低出价");
+                unitVo.put("operationAgreeInfo","当前转化成本大于出价×120%,转化数大于50,建议降低出价;");
+            }
+            //4.  转化成本小于等于出价×120%,转化数大于10小于等于50
+            if (converCost <= price * 1.2 && LinkUtil.isInTheInterval(String.valueOf(converNum), "(10,50]")) {
+                unitVo.put("operationAgree","成本合理 | 有转化");
+                unitVo.put("operationContent","建议复制推广组或放开预算");
+                unitVo.put("operationAgreeInfo","当前转化成本小于等于出价×120%,转化数大于10小于等于50,建议复制推广组或放开预算;");
+            }
+            //5.  消耗大于0小于等于100,转化数大于0小于等于10:
+            if (LinkUtil.isInTheInterval(String.valueOf(charge), "(0,100]") && LinkUtil.isInTheInterval(String.valueOf(converNum), "(0,10]")) {
+                unitVo.put("operationAgree","消耗少 | 转化少");
+                unitVo.put("operationContent","建议启用加速探索");
+                unitVo.put("operationAgreeInfo","当前广告组消耗大于0小于等于100,转化数大于0小于等于10,建议加速探索;");
+            }
+            //6.  消耗大于等于500,转化数等于0:
+            if (charge >= 500 && converNum == 0) {
+                unitVo.put("operationAgree","有消耗 | 无转化");
+                unitVo.put("operationContent","建议暂停广告组");
+                unitVo.put("operationAgreeInfo","当前广告组消耗大于等于500且转化数等于0,建议暂停推广组;");
+            }
+            //7.   消耗大于100小于等于500
+            if (LinkUtil.isInTheInterval(String.valueOf(charge), "(100,500]")) {
+                unitVo.put("operationAgree","有一定消耗");
+                unitVo.put("operationContent","建议继续观察");
+                unitVo.put("operationAgreeInfo","当前广告组消耗大于100小于等于500,建议继续观察;");
+            }
+        }
+
+
+
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(ListUnit);
+        return Result.successMsg("查询快手组当天实时数据成功。",pageInfo);
+
+    }
+
 
 //===========================================查询下级员工========================
 

+ 129 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/utils/LinkUtil.java

@@ -0,0 +1,129 @@
+package org.jeecg.ctop.material.utils;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+
+/**
+ * zian Y
+ * 2022/3/24
+ **/
+public class LinkUtil {
+
+
+
+    /**
+     * 判断data_value是否在interval区间范围内
+     * @param data_value 数值类型的
+     * @param interval 正常的数学区间,包括无穷大等,如:(1,3)、>5%、(-∞,6]、(125%,135%)U(70%,80%)
+     * @return true:表示data_value在区间interval范围内,false:表示data_value不在区间interval范围内
+     */
+    public static boolean isInTheInterval(String data_value,String interval) {
+        //将区间和data_value转化为可计算的表达式
+        String formula = getFormulaByAllInterval(data_value,interval,"||");
+        ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");
+        try {
+            //计算表达式
+            return (Boolean) jse.eval(formula);
+        } catch (Exception t) {
+            return false;
+        }
+    }
+
+
+
+    /**
+     * 将所有阀值区间转化为公式:如
+     * [75,80) =》 date_value < 80 && date_value >= 75
+     * (125%,135%)U(70%,80%) =》 (date_value < 1.35 && date_value > 1.25) || (date_value < 0.8 && date_value > 0.7)
+     * @param date_value
+     * @param interval 形式如:(125%,135%)U(70%,80%)
+     * @param connector 连接符 如:") || ("
+     */
+    private static String getFormulaByAllInterval(String date_value, String interval, String connector) {
+        StringBuffer buff = new StringBuffer();
+        for(String limit:interval.split("U")){//如:(125%,135%)U (70%,80%)
+            buff.append("(").append(getFormulaByInterval(date_value, limit," && ")).append(")").append(connector);
+        }
+        String allLimitInvel = buff.toString();
+        int index = allLimitInvel.lastIndexOf(connector);
+        allLimitInvel = allLimitInvel.substring(0,index);
+        return allLimitInvel;
+    }
+
+    /**
+     * 将整个阀值区间转化为公式:如
+     * 145) =》 date_value < 145
+     * [75,80) =》 date_value < 80 && date_value >= 75
+     * @param date_value
+     * @param interval 形式如:145)、[75,80)
+     * @param connector 连接符 如:&&
+     */
+    private static String getFormulaByInterval(String date_value, String interval, String connector) {
+        StringBuffer buff = new StringBuffer();
+        for(String halfInterval:interval.split(",")){//如:[75,80)、≥80
+            buff.append(getFormulaByHalfInterval(halfInterval, date_value)).append(connector);
+        }
+        String limitInvel = buff.toString();
+        int index = limitInvel.lastIndexOf(connector);
+        limitInvel = limitInvel.substring(0,index);
+        return limitInvel;
+    }
+
+
+    /**
+     * 将半个阀值区间转化为公式:如
+     * 145) =》 date_value < 145
+     * ≥80% =》 date_value >= 0.8
+     * [130 =》 date_value >= 130
+     * <80% =》 date_value < 0.8
+     * @param halfInterval 形式如:145)、≥80%、[130、<80%
+     * @param date_value
+     * @return date_value < 145
+     */
+    private static String getFormulaByHalfInterval(String halfInterval, String date_value) {
+        halfInterval = halfInterval.trim();
+        if(halfInterval.contains("∞")){//包含无穷大则不需要公式
+            return "1 == 1";
+        }
+        StringBuffer formula = new StringBuffer();
+        String data = "";
+        String opera = "";
+        if(halfInterval.matches("^([<>≤≥\\[\\(]{1}(-?\\d+.?\\d*\\%?))$")){//表示判断方向(如>)在前面 如:≥80%
+            opera = halfInterval.substring(0,1);
+            data = halfInterval.substring(1);
+        }else{//[130、145)
+            opera = halfInterval.substring(halfInterval.length()-1);
+            data = halfInterval.substring(0,halfInterval.length()-1);
+        }
+        double value = dealPercent(data);
+        formula.append(date_value).append(" ").append(opera).append(" ").append(value);
+        String a = formula.toString();
+        //转化特定字符
+        return a.replace("[", ">=").replace("(", ">").replace("]", "<=").replace(")", "<").replace("≤", "<=").replace("≥", ">=");
+    }
+
+
+    /**
+     * 去除百分号,转为小数
+     * @param str 可能含百分号的数字
+     * @return
+     */
+    private static double dealPercent(String str){
+        double d = 0.0;
+        if(str.contains("%")){
+            str = str.substring(0,str.length()-1);
+            d = Double.parseDouble(str)/100;
+        }else{
+            d = Double.parseDouble(str);
+        }
+        return d;
+    }
+
+
+    public static void main(String[] args) {
+
+        System.out.println(LinkUtil.isInTheInterval("7", "(-1,9]"));
+    }
+
+
+}