瀏覽代碼

Merge branch 'master' into V2.0.1

# Conflicts:
#	jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
zhaoxian 3 年之前
父節點
當前提交
27b2f58f7b
共有 53 個文件被更改,包括 1853 次插入134 次删除
  1. 3 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/entity/SysUser.java
  2. 1 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  3. 2 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/JeecgBootFinanceApplication.java
  4. 72 13
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java
  5. 11 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyInfoMapper.java
  6. 78 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml
  7. 10 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsPolicyInfoService.java
  8. 51 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyInfoServiceImpl.java
  9. 53 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementController.java
  10. 10 3
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java
  11. 2 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementInfo.java
  12. 8 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java
  13. 9 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementInfoMapper.java
  14. 89 5
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml
  15. 25 3
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementInfoMapper.xml
  16. 5 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementInfoService.java
  17. 54 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java
  18. 20 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java
  19. 19 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java
  20. 5 0
      jeecg-boot-finance/src/main/resources/application-dev.yml
  21. 5 0
      jeecg-boot-finance/src/main/resources/application-prod.yml
  22. 7 2
      jeecg-boot-finance/src/main/resources/application-test.yml
  23. 0 5
      jeecg-boot-finance/src/main/resources/application.yml
  24. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/ISysUserService.java
  25. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java
  26. 21 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserCompanyServiceImpl.java
  27. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java
  28. 9 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  29. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java
  30. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml
  31. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java
  32. 7 7
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  33. 11 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java
  34. 11 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewPlanReportCtrl.java
  35. 36 23
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouGroupExploreController.java
  36. 246 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouReportDailyExploreController.java
  37. 35 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/NewMonitorController.java
  38. 147 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyExplore.java
  39. 15 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyExploreMapper.java
  40. 49 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java
  41. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyExploreMapper.xml
  42. 164 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml
  43. 5 5
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouGroupExploreService.java
  44. 14 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyExploreService.java
  45. 23 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java
  46. 50 41
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouGroupExploreServiceImpl.java
  47. 19 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyExploreServiceImpl.java
  48. 242 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java
  49. 66 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceNewPlanReportCtrl.java
  50. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml
  51. 10 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceHomepageReportServiceImpl.java
  52. 6 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  53. 111 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

+ 3 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/entity/SysUser.java

@@ -221,4 +221,7 @@ public class SysUser implements Serializable {
     private String leaderName;
 
     private String departId;
+
+    @TableField(exist = false)
+    private String departId2;
 }

+ 1 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -213,6 +213,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ai/projectCreate/*", "anon");
         filterChainDefinitionMap.put("/cwjsPolicyInfo/**", "anon");
         filterChainDefinitionMap.put("/ruleIndicator/**", "anon");
+        filterChainDefinitionMap.put("/explores/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 2 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/JeecgBootFinanceApplication.java

@@ -7,6 +7,7 @@ import org.apache.shiro.spring.boot.autoconfigure.ShiroBeanAutoConfiguration;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 /**
  * zian Y
@@ -16,6 +17,7 @@ import org.springframework.context.annotation.ComponentScan;
 @SpringBootApplication(exclude = {ShiroAnnotationProcessorAutoConfiguration.class, ShiroAutoConfiguration.class, ShiroBeanAutoConfiguration.class})
 @EnableDubbo
 @ComponentScan(basePackages = {"org.jeecg", "cn.com.ctop"})
+@EnableTransactionManagement
 public class JeecgBootFinanceApplication {
 
     public static void main(String[] args) {

+ 72 - 13
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java

@@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
 import cn.com.ctop.common.module.entity.UserCompany;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.mapper.SysUserMapper;
+import cn.com.ctop.common.module.service.ISysUserService;
 import cn.com.ctop.common.module.service.IUserCompanyService;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import com.alibaba.fastjson.JSONArray;
@@ -85,6 +86,8 @@ public class CwjsPolicyInfoController {
 	 CorpWexinUtils corpWexinUtils;
 	 @Resource
 	 MailLogMapper mailLogMapper;
+     @Autowired
+     private ISysUserService sysUserService;
 
 	 @GetMapping(value = "/queryApprovalRejectReason")
 	 public Result<CwjsPolicyApprovalLog> queryApprovalRejectReason(@RequestParam(name="id",required=true) Integer id){
@@ -110,12 +113,31 @@ public class CwjsPolicyInfoController {
 		 Integer companySubjectId= cwjsPolicyInfoEntity.getCompanySubjectId();
 		 CwjsCompanyApprovalUser cwjsCompanyApprovalUser = companyApprovalUserMapper.queryByCompanySubjectIdAndUserId(companySubjectId, userId);
 		 if(type == 1){	//审核提交	等于新增的时候
-//			 cwjsPolicyInfoEntity.setApprovedStatus(1);
-			if(!Check.isNull(cwjsCompanyApprovalUser)){//当前登录的用户所提交的政策是审核链里的人的提交的  直接状态到2给终审的人员
-				cwjsPolicyInfoEntity.setApprovedStatus(2);
-			}else{	//除了销售总监提交的申请都是-待审核
-				cwjsPolicyInfoEntity.setApprovedStatus(1);
-			}
+			 List<CwjsCompanyApprovalUser> cwjsCompanyApprovalUsers = companyApprovalUserMapper.queryByCompanySubjectId(companySubjectId);
+			 if(Check.isNull(cwjsCompanyApprovalUsers)){
+				 return Result.errorMsg("此业务线暂时无审核人员,提交审核无效,请联系开发人员添加此区域主体的审核人员");
+			 }
+			 //普通销售,审核都是1,审核进度的人都是等级为0的审核人id
+			 cwjsCompanyApprovalUsers.forEach(cwjsCompanyApprovalUser2 -> {
+				 if(cwjsCompanyApprovalUser2.getLevel() == 0){
+					 cwjsPolicyInfoEntity.setApprovedStatus(1);
+					 cwjsPolicyInfoEntity.setApprovedProgress(cwjsCompanyApprovalUser2.getApprovalUserId());
+				 }
+			 });
+			 //如果满足有审核人员等于当前创建的人,并且
+			 cwjsCompanyApprovalUsers.forEach(cwjsCompanyApprovalUser2 -> {
+				 if(cwjsCompanyApprovalUser2.getApprovalUserId().equalsIgnoreCase(cwjsPolicyInfoEntity.getCreateUserId())){
+					 CwjsCompanyApprovalUser approvalUserNext = companyApprovalUserMapper.queryByCompanySubjectIdAndLevel(companySubjectId, cwjsCompanyApprovalUser2.getLevel()+1);
+					 if(Check.isNull(approvalUserNext)){
+						 cwjsPolicyInfoEntity.setApprovedStatus(3);
+						 cwjsPolicyInfoEntity.setApprovedProgress(null);
+					 }else{
+						 cwjsPolicyInfoEntity.setApprovedStatus(2);
+						 cwjsPolicyInfoEntity.setApprovedProgress(approvalUserNext.getApprovalUserId());
+					 }
+				 }
+			 });
+
 			 JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId(cwjsPolicyInfoEntity.getApprovedProgress());
 			 StringBuilder text = new StringBuilder();
 			 text.append("您有一条销售政策需要审核,该客户为:");
@@ -258,10 +280,24 @@ public class CwjsPolicyInfoController {
         String roleCode = roleService.getRoleCodeByUserId(userId);
         List<JSONObject> allSaleList;
         if("admin".equalsIgnoreCase(roleCode) || "finance".equalsIgnoreCase(roleCode)){
-            allSaleList = cwjsPolicyInfoService.getAllSale();
+            allSaleList = cwjsPolicyInfoService.getAllSale();   //所有销售角色和管理员
         }else{
             allSaleList = cwjsPolicyInfoService.getAllSaleByUserId(userId);
+            List<JSONObject> allSubordinate = cwjsPolicyInfoService.getAllSubordinate2(userId);
+            if(!Check.isNull(allSubordinate)){
+                allSaleList.addAll(allSubordinate);
+            }
         }
+
+        if(Check.isNull(allSaleList)){
+            allSaleList = new ArrayList<>();
+            SysUser sysUser = sysUserService.getById(userId);
+            JSONObject jo = new JSONObject();
+            jo.put("userId",sysUser.getId());
+            jo.put("userName",sysUser.getRealname());
+
+        }
+
 		return Result.OK(allSaleList);
 	}
 
@@ -298,7 +334,7 @@ public class CwjsPolicyInfoController {
 	public Result<CwjsPolicyInfo> add(@RequestBody CwjsPolicyInfo cwjsPolicyInfo) {
 		Result<CwjsPolicyInfo> result = new Result<>();
 		try {
-			cwjsPolicyInfo.setApprovedStatus(1);	//新增出来的政策全部都是待审核状态
+
 			String companySubjectName = cwjsPolicyInfo.getCompanySubjectName();
 			String areaInfo = cwjsPolicyInfo.getAreaInfo();
 			Integer companySubjectId = companySubjectMapper.queryIdBySubjectNameAndArea(companySubjectName, areaInfo);
@@ -310,11 +346,33 @@ public class CwjsPolicyInfoController {
 			if(Check.isNull(cwjsCompanyApprovalUsers)){
 				return Result.errorMsg("此业务线暂时无审核人员,提交审核无效,请联系开发人员添加此区域主体的审核人员");
 			}
+			//普通销售,新增都是1,审核进度的人都是等级为0的审核人id
 			cwjsCompanyApprovalUsers.forEach(cwjsCompanyApprovalUser -> {
 				if(cwjsCompanyApprovalUser.getLevel() == 0){
+					cwjsPolicyInfo.setApprovedStatus(1);
 					cwjsPolicyInfo.setApprovedProgress(cwjsCompanyApprovalUser.getApprovalUserId());
 				}
 			});
+			//如果满足有审核人员等于当前创建的人,并且
+			cwjsCompanyApprovalUsers.forEach(cwjsCompanyApprovalUser -> {
+				if(cwjsCompanyApprovalUser.getApprovalUserId().equalsIgnoreCase(cwjsPolicyInfo.getCreateUserId())){
+					CwjsCompanyApprovalUser approvalUserNext = companyApprovalUserMapper.queryByCompanySubjectIdAndLevel(companySubjectId, cwjsCompanyApprovalUser.getLevel()+1);
+					if(Check.isNull(approvalUserNext)){
+						cwjsPolicyInfo.setApprovedStatus(3);
+						cwjsPolicyInfo.setApprovedProgress(null);
+					}else{
+						cwjsPolicyInfo.setApprovedStatus(2);
+						cwjsPolicyInfo.setApprovedProgress(approvalUserNext.getApprovalUserId());
+					}
+				}
+			});
+
+			if(cwjsPolicyInfo.getAdvancePay() == 1){
+				cwjsPolicyInfo.setIsDianPay(null);
+				cwjsPolicyInfo.setDianPayCompanyName(null);
+				cwjsPolicyInfo.setDianPayCompanyRebateRate(null);
+			}
+
 			cwjsPolicyInfoService.save(cwjsPolicyInfo);
 			JSONArray products = cwjsPolicyInfo.getPolicyProductName();
 			List<CwjsPolicyProduct> policyProductList = new ArrayList<>();
@@ -376,13 +434,14 @@ public class CwjsPolicyInfoController {
 				policyProductList.add(policyProduct);
 			});
 			cwjsPolicyProductService.saveBatch(policyProductList);
-
-			boolean ok = cwjsPolicyInfoService.updateById(cwjsPolicyInfo);
-			if(ok) {
-				result.success("修改成功!");
+			if(cwjsPolicyInfo.getAdvancePay() == 1){
+				cwjsPolicyInfo.setIsDianPay(null);
+				cwjsPolicyInfo.setDianPayCompanyName(null);
+				cwjsPolicyInfo.setDianPayCompanyRebateRate(null);
 			}
+			cwjsPolicyInfoService.updatePolicyInfoById(cwjsPolicyInfo);
+			result.success("修改成功!");
 		}
-
 		return result;
 	}
 

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

@@ -1,6 +1,7 @@
 package org.jeecg.ctop.finance.policy.mapper;
 
 import java.util.List;
+import java.util.Map;
 
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
@@ -18,5 +19,15 @@ public interface CwjsPolicyInfoMapper extends BaseMapper<CwjsPolicyInfo> {
 
     List<JSONObject> getAllSale();
 
+    List<JSONObject> getAllSaleAndMeidaManager();
+
+    /**
+     * 查询所有 运营
+     * @return
+     */
+    List<Map<String,Object>> getAllOperationUser();
+
     List<JSONObject> getAllSaleByUserId(String userId);
+
+    void updatePolicyInfoById(CwjsPolicyInfo policyInfo);
 }

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

@@ -23,8 +23,12 @@
         <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;= #{endTime}</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))
+        </if>
         order by t2.create_time desc
     </select>
 
@@ -46,16 +50,88 @@
             , 'saleAssistant'
             , 'salesSupportManager'
             , 'saleAm'
+            ,'admin'
             )
 
     </select>
 
+    <!-- 查询所有销售和 媒介 -->
+    <select id="getAllSaleAndMeidaManager" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t1.user_id AS 'id',
+	LEFT (t1.company_name, 2) AS 'companyName',
+	t3.role_name AS 'ruleName',
+	t1.user_name AS 'realname'
+        FROM
+            user_company t1
+            LEFT JOIN sys_user_role t2
+        ON t1.user_id = t2.user_id
+            LEFT JOIN sys_role t3 ON t2.role_id = t3.id
+        WHERE
+            t3.role_code IN (
+            'externalSale'
+            , 'saleDirector'
+            , 'sale'
+            , 'saleAssistant'
+            , 'salesSupportManager'
+            , 'saleAm'
+            ,'admin'
+            ,'meidaManager'
+            )
+
+    </select>
+
+    <!-- 查询所有运营 -->
+    <select id="getAllOperationUser" resultType="java.util.LinkedHashMap">
+
+        SELECT
+            t1.id AS 'id',
+            t3.role_name AS 'roleName',
+            t1.realname AS 'realName',
+            t3.role_code AS roleCode
+        FROM
+            sys_user t1,
+            sys_user_role t2,
+            sys_role t3
+        WHERE
+            t1.id = t2.user_id
+          AND t2.role_id = t3.id
+          AND t1.STATUS = 1
+          AND t1.del_flag = 0
+          AND t3.role_code LIKE '%peration%'
+
+    </select>
+
     <select id="getAllSaleByUserId" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT t1.create_user_id AS 'userId',
+        SELECT distinct t1.create_user_id AS 'userId',
 	           t1.create_user_name AS 'userName'
         FROM
             ctop_cwjs_policy_info t1
         WHERE
             t1.approved_progress = #{userId} or t1.create_user_id = #{userId}
     </select>
+
+    <update id="updatePolicyInfoById">
+        update ctop_cwjs_policy_info set
+            company_name = #{companyName},
+             advertiser_name = #{advertiserName},
+             media_type = #{mediaType},
+             company_subject_id = #{companySubjectId},
+             group_abbreviation = #{groupAbbreviation},
+             approved_progress = #{approvedProgress},
+             advance_pay = #{advancePay},
+             accounting_period = #{accountingPeriod},
+             rebate_type = #{rebateType},
+             rebate_rate = #{rebateRate},
+             is_dian_pay = #{isDianPay},
+             dian_pay_company_name = #{dianPayCompanyName},
+             dian_pay_company_rebate_rate = #{dianPayCompanyRebateRate},
+             promotion_type = #{promotionType},
+             policy_start_date = #{policyStartDate},
+             policy_end_date = #{policyEndDate},
+             remarks = #{remarks},
+             create_user_id = #{createUserId},
+             create_user_name = #{createUserName}
+        where id = #{id}
+    </update>
+
 </mapper>

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

@@ -7,6 +7,7 @@ import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 政策信息表
@@ -18,8 +19,17 @@ public interface ICwjsPolicyInfoService extends IService<CwjsPolicyInfo> {
     List<CwjsPolicyInfo> queryPageList(CwjsPolicyInfo policyInfo);
 
     List<JSONObject> getAllSale();
+    List<JSONObject> getAllSaleAndMeidaManager();
+
+    List<Map<String,Object>> getAllOperationUser();
 
     List<JSONObject> getAllSaleByUserId(String userId);
 
     List<String> getAllSubordinate(String userId);
+
+    List<JSONObject> getAllSubordinate2(String userId);
+
+    boolean isExistCwjsPolicyInfo(CwjsPolicyInfo policyInfo);
+
+    void updatePolicyInfoById(CwjsPolicyInfo policyInfo);
 }

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

@@ -71,6 +71,20 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     }
 
     @Override
+    public List<JSONObject> getAllSaleAndMeidaManager(){
+        return policyInfoMapper.getAllSaleAndMeidaManager();
+    }
+
+    /**
+     * 查询 所有 运营
+     * @return
+     */
+    @Override
+    public List<Map<String,Object>> getAllOperationUser(){
+        return policyInfoMapper.getAllOperationUser();
+    }
+
+    @Override
     public List<JSONObject> getAllSaleByUserId(String userId){
         return policyInfoMapper.getAllSaleByUserId(userId);
     }
@@ -79,6 +93,21 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     @Autowired
     private SysUserMapper userMapper;
     @Override
+    public List<JSONObject> getAllSubordinate2(String userId){
+        List<SysUser> allList = userMapper.selectAllUser();
+        List<SysUser> mulUserList = treeCategoryData(allList, userId);
+        List<JSONObject> users = new ArrayList<>();
+        mulUserList.forEach(mulUser -> {
+            JSONObject jo = new JSONObject();
+            jo.put("userId",mulUser.getId());
+            jo.put("userName",mulUser.getRealname());
+            users.add(jo);
+        });
+        return users;
+    }
+
+
+    @Override
     public List<String> getAllSubordinate(String userId){
         List<SysUser> allList = userMapper.selectAllUser();
         List<SysUser> mulUserList = treeCategoryData(allList, userId);
@@ -98,4 +127,26 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
         return mapList;
 
     }
+
+    @Override
+    public boolean isExistCwjsPolicyInfo(CwjsPolicyInfo policyInfo){
+        CwjsPolicyInfo cwjsPolicyInfoEntity = new CwjsPolicyInfo();
+        cwjsPolicyInfoEntity.setAdvertiserName(policyInfo.getAdvertiserName());
+        cwjsPolicyInfoEntity.setProductName(policyInfo.getProductName());
+        cwjsPolicyInfoEntity.setMediaType(policyInfo.getMediaType());
+        cwjsPolicyInfoEntity.setCreateUserId(policyInfo.getCreateUserId());
+        cwjsPolicyInfoEntity.setPolicyStartDate(policyInfo.getPolicyStartDate());
+        cwjsPolicyInfoEntity.setPolicyEndDate(policyInfo.getPolicyEndDate());
+        List<CwjsPolicyInfo> cwjsPolicyInfos = policyInfoMapper.selectPolicyInfos(policyInfo);
+        if(Check.isNull(cwjsPolicyInfos)){
+            return false;
+        }else {
+            return true;
+        }
+    }
+
+    @Override
+    public void updatePolicyInfoById(CwjsPolicyInfo policyInfo){
+        policyInfoMapper.updatePolicyInfoById(policyInfo);
+    }
 }

+ 53 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementController.java

@@ -1,8 +1,12 @@
 package org.jeecg.ctop.finance.settlement.controller;
 
+import cn.com.ctop.common.module.service.impl.SysUserServiceImpl;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
+import org.jeecg.ctop.finance.policy.service.impl.CwjsPolicyInfoServiceImpl;
 import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
 
@@ -15,6 +19,8 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 
@@ -78,7 +84,6 @@ public class SettlementController {
     @ApiOperation(value="财务结算-上传账户", notes="财务结算-上传账户")
     @PostMapping("/settlementAccountImport")
     public Result settlementAccountImport(ctopCwjsSettlementInfo settlementInfo,@RequestParam("file") MultipartFile files) {
-
         if (files.isEmpty()){
             return Result.errorMsg("附件不能为空!");
         }
@@ -86,4 +91,51 @@ public class SettlementController {
     }
 
 
+    @Autowired
+    private CwjsPolicyInfoServiceImpl cwjsPolicyInfoService;
+
+
+    @ApiOperation(value="财务结算-获取负责人下拉列表", notes="财务结算-获取负责人下拉列表")
+    @GetMapping("/getResponsibleUserByIds")
+    public Result getResponsibleUserByIds(@RequestParam("userId") String userId) {
+        //查询用户角色
+        String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+        //普通用户
+        Set<String> ids = new HashSet<String>(){{
+            add(userId);
+        }};
+        if ("admin".equals(roleCode)){
+            //查询所有销售 && 媒介
+            List allSaleList = cwjsPolicyInfoService.getAllSaleAndMeidaManager();
+            return Result.successMsg("查询所有销售和媒介用户。",allSaleList);
+
+        }else if ("saleDirector".equals(roleCode) || //销售总监
+                "kuaishou_operations_director".equals(roleCode) || //快手运营总监
+                "toutiao_operations_manager".equals(roleCode) || // 头条运营经理
+                "externalOperationManager".equals(roleCode) || //外部运营经理
+                "genera_manager_of_operations".equals(roleCode) || //运营总经理
+                "toutiao_operations_director".equals(roleCode) || //头条运营总监
+                "kuaishou_operations_manager".equals(roleCode) //快手运营经理
+         ){
+            //查询所有包含自己的下级
+            ids = materialReportOverViewService.recursiveQuerySubordinate(userId);
+        }
+        List<Map<String,Object>> list = settlementInfoService.getUserByIds(ids);
+        return Result.successMsg("查询用户!",list);
+    }
+
+
+
+    @ApiOperation(value="财务结算-获取所有运营人员", notes="财务结算-获取所有运营人员")
+    @GetMapping("/getAllOperationUser")
+    public Result getAllOperationUser() {
+        List<Map<String,Object>> list = cwjsPolicyInfoService.getAllOperationUser();
+        return Result.successMsg("查询运营用户列表!",list);
+    }
+
+
+
+
+
+
 }

+ 10 - 3
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java

@@ -53,11 +53,18 @@ public class SettlementFileController {
         //查询用户角色
         String roleCode = sysRoleService.getRoleCodeByUserId(paramsVo.getCreateUserId());
 
-        if ("admin".equals(roleCode)){
+        //管理员 || 财务
+        if ("admin".equals(roleCode) || "finance".equals(roleCode)){
             paramsVo.setOperatorUserIds(null);
             paramsVo.setSaleUserIds(null);
-         //运营经理   touTiaoOperationManager-头条运营经理   kuaishouOperationManager-快手运营经理
-        }else if (roleCode.contains("OperationManager")){
+         //运营经理
+        }else if ("kuaishou_operations_director".equals(roleCode) || //快手运营总监
+                "toutiao_operations_manager".equals(roleCode) || // 头条运营经理
+                "externalOperationManager".equals(roleCode) || //外部运营经理
+                "genera_manager_of_operations".equals(roleCode) || //运营总经理
+                "toutiao_operations_director".equals(roleCode) || //头条运营总监
+                "kuaishou_operations_manager".equals(roleCode)) //快手运营经理
+         {
             //查询所有包含自己的下级
             Set<String> operatorUserIds= materialReportOverViewService.recursiveQuerySubordinate(paramsVo.getCreateUserId());
             paramsVo.setOperatorUserIds(operatorUserIds);

+ 2 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementInfo.java

@@ -102,9 +102,11 @@ public class ctopCwjsSettlementInfo implements Serializable {
     /**
      * 更新时间
      */
+    @TableField(exist = false)
     private Date updateTime;
 
 
+    @TableField(exist = false)
     private Set<String> userIds;
 
 }

+ 8 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java

@@ -42,4 +42,12 @@ public interface SettlementFileInfoMapper extends BaseMapper<ctopCwjsSettlementF
      * @return
      */
     Map<String,String> getAccountNumAndImgNum(SettlementFileParamsVo paramsVo);
+
+
+    /**
+     * 查询该账户是否已绑定 或开户
+     * @param accountId
+     * @return
+     */
+    Map<String,String> getSettlementAccount(String accountId);
 }

+ 9 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementInfoMapper.java

@@ -5,6 +5,8 @@ import io.lettuce.core.dynamic.annotation.Param;
 import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 
 /**
@@ -37,4 +39,11 @@ public interface SettlementInfoMapper extends BaseMapper<ctopCwjsSettlementInfo>
      */
     void deleteSettlementById(@Param("id") Long id);
 
+    /**
+     * 查询多个用户名称
+     * @param userIds
+     * @return
+     */
+    List<Map<String,Object>> getUserByIds(@Param("userIds") Set userIds);
+
 }

+ 89 - 5
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.ctop.finance.settlement.mapper.SettlementFileInfoMapper">
 
-    <!-- 查询 财务结算-结算单列表-->
+    <!-- 查询 财务结算-结算单列表
     <select id="getSettlementSheetList" resultType="java.util.LinkedHashMap">
         SELECT
            t.*,
@@ -53,9 +53,6 @@
             <if test="accountName !=null and accountName != ''">
                 AND accountName like concat ('%',#{accountName},'%')
             </if>
-            <if test="createUserId !=null and createUserId != ''">
-                AND saleUserId = #{createUserId}
-            </if>
             <if test="mediaId !=null and mediaId != ''">
                 AND media_id = #{mediaId}
             </if>
@@ -89,6 +86,78 @@
         ORDER BY imageCreateTIme DESC
 
     </select>
+-->
+
+    <!-- 查询 财务结算-结算单列表-->
+    <select id="getSettlementSheetList" resultType="java.util.LinkedHashMap">
+        SELECT * FROM
+        (
+        SELECT
+        f.id,
+        f.upload_years as uploadYears,
+        f.media_id as mediaId,
+        f.advertiser_id as advertiserId,
+        ( SELECT ad.NAME FROM ctop_advertiser ad WHERE ad.id = cwjs.advertiser_id LIMIT 1 ) advertiserName,
+        f.product_id as productId,
+        ( SELECT cp.product_name FROM ctop_product cp WHERE cp.id = cwjs.product_id LIMIT 1 ) productName,
+        cwjs.project_id as projectId,
+        ( SELECT project.project_name FROM ctop_project project WHERE project.id = cwjs.project_id LIMIT 1 ) projectName,
+        cwjs.account_id as accountId,
+        cwjs.account_name as accountName,
+        f.del_flag,
+        cwjs.create_user_id as saleUserId,
+        ( SELECT su.realname FROM sys_user su WHERE su.id = cwjs.create_user_id LIMIT 1 ) saleUserName,
+        f.create_user_id as operateUserId,
+        ( SELECT su.realname FROM sys_user su WHERE su.id = f.create_user_id LIMIT 1 ) operateUserName
+        FROM ctop_cwjs_settlement_file_info f
+        LEFT JOIN ctop_cwjs_settlement_info cwjs on f.account_id = cwjs.account_id
+        where f.del_flag = 0
+        GROUP BY f.account_id,f.upload_years,f.create_user_id
+        ORDER BY f.upload_years DESC
+        ) t
+        <where>
+            <if test="advertiserName !=null and advertiserName != ''">
+                AND advertiserName like concat ('%',#{advertiserName},'%')
+            </if>
+            <if test="productName !=null and productName != ''">
+                AND productName like concat ('%',#{productName},'%')
+            </if>
+            <if test="projectName !=null and projectName != ''">
+                AND projectName like concat ('%',#{projectName},'%')
+            </if>
+            <if test="accountName !=null and accountName != ''">
+                AND accountName like concat ('%',#{accountName},'%')
+            </if>
+            <if test="mediaId !=null and mediaId != ''">
+                AND mediaId = #{mediaId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND uploadYears &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND uploadYears &lt;= #{endTime}
+            </if>
+            <if test="createUserName !=null and createUserName != ''">
+                AND operateUserId like concat ('%',#{createUserName},'%')
+            </if>
+            <if test="operatorUserIds !=null and operatorUserIds != ''">
+                AND operateUserId in
+                <foreach collection="operatorUserIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="saleUserIds !=null and saleUserIds != ''">
+                AND saleUserId in
+                <foreach collection="saleUserIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+        </where>
+    </select>
 
 
 
@@ -98,6 +167,7 @@
         SET del_flag = 1
         WHERE advertiser_id = #{advertiserId}
           and product_id = #{productId}
+          and account_id = #{accountId}
           and media_id = #{mediaId}
           and upload_years = #{uploadYears}
           and create_user_id = #{createUserId}
@@ -138,12 +208,26 @@
                             AND media_id = #{mediaId}
                         </if>
                      ) t2
+    </select>
 
 
 
-    </select>
 
+    <!-- 查询该账户是否已绑定 或开户-->
+    <select id="getSettlementAccount" resultType="java.util.Map">
+        SELECT
+            u.account_id AS accountId,
+            u.auth_name AS accountName
+        FROM
+            ctop_cwjs_settlement_info f,
+            ctop_user_allocation u
+        WHERE
+            f.account_id = u.account_id
+          AND u.account_status = 0
+          AND u.account_id = #{accountId}
+            LIMIT 1
 
+    </select>
 
 
 

+ 25 - 3
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementInfoMapper.xml

@@ -39,7 +39,7 @@
                 AND projectName like concat ('%',#{projectName},'%')
             </if>
             <if test="accountName !=null and accountName != ''">
-                AND accountName like concat ('%',#{accountName},'%')
+                AND account_name like concat ('%',#{accountName},'%')
             </if>
             <if test="createUserName !=null and createUserName != ''">
                 AND createUserName like concat ('%',#{createUserName},'%')
@@ -48,10 +48,10 @@
                 AND media_id = #{mediaId}
             </if>
             <if test="startTime !=null and startTime != ''">
-                AND create_time &gt;= #{startTime}
+                AND DATE_FORMAT(create_time,'%Y-%m-%d') &gt;= #{startTime}
             </if>
             <if test="endTime !=null and endTime != ''">
-                AND create_time &lt;= #{endTime}
+                AND DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= #{endTime}
             </if>
             <if test="userIds !=null and userIds != ''">
                 AND create_user_id in
@@ -61,6 +61,7 @@
                 </foreach>
             </if>
         </where>
+        ORDER BY create_time DESC
     </select>
 
     <!-- 修改财务结算账户状态 -->
@@ -82,4 +83,25 @@
 
 
 
+    <!-- 查询多个用户信息 -->
+    <select id="getUserByIds" resultType="java.util.LinkedHashMap">
+        SELECT
+            id,realname
+        from sys_user
+        where status = 1
+          and del_flag = 0
+
+              <if test="userIds !=null and userIds != ''">
+                  AND id in
+                  <foreach collection="userIds" item="item" separator=","
+                           open="(" close=")">
+                      #{item}
+                  </foreach>
+              </if>
+
+
+    </select>
+
+
+
 </mapper>

+ 5 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementInfoService.java

@@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 public interface ISettlementInfoService extends IService<ctopCwjsSettlementInfo> {
 
@@ -18,4 +20,7 @@ public interface ISettlementInfoService extends IService<ctopCwjsSettlementInfo>
 
     Result settlementAccountImport(ctopCwjsSettlementInfo settlementInfo,MultipartFile file);
 
+
+    List<Map<String,Object>> getUserByIds(Set userIds);
+
 }

+ 54 - 4
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java

@@ -28,6 +28,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mapping.AccessOptions;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -56,7 +58,7 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
-    @Override
+   /* @Override
     public Result<PageInfo<Map<String,String>>> getSettlementSheetList(SettlementFileParamsVo paramsVo, Integer pageNo, Integer pageSize) {
         Set accountSet = new HashSet();
         Set imageSet = new HashSet();
@@ -110,6 +112,46 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
         PageInfo<Map<String,String>> pageInfo = new PageInfo<>(list);
         return Result.successMsg("财务结算-结算单列表查询成功。", pageInfo);
     }
+*/
+
+    /**
+     *
+     * @description: 查询 财务结算-结算单列表
+     *
+     * @param paramsVo
+     * @param pageNo
+     * @param pageSize
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result<PageInfo<Map<String,String>>> getSettlementSheetList(SettlementFileParamsVo paramsVo, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<Map<String,String>> list = settlementFileInfoMapper.getSettlementSheetList(paramsVo);
+        for (Map<String, String> map : list) {
+            //图片数量
+            QueryWrapper<ctopCwjsSettlementFileInfo> settlementFileInfoQw = new QueryWrapper<>();
+            //广告主id
+            settlementFileInfoQw.eq("advertiser_id",map.get("advertiserId"));
+            //产品id
+            settlementFileInfoQw.eq("product_id",map.get("productId"));
+
+            settlementFileInfoQw.eq("account_id",map.get("accountId"));
+            //媒体类型 1-头条 2-快手 3-头条内广 4-快手内广
+            settlementFileInfoQw.eq("media_id",map.get("mediaId"));
+            //上传人 (运营)
+            settlementFileInfoQw.eq("create_user_id",map.get("operateUserId"));
+            //(0,正常,1已删除)
+            settlementFileInfoQw.eq("del_flag",0);
+            List<ctopCwjsSettlementFileInfo> settlementFileList =  settlementFileInfoMapper.selectList(settlementFileInfoQw);
+            map.put("imgNum",Check.isNull(settlementFileList) ? "0" : String.valueOf(settlementFileList.size()));
+
+        }
+
+
+        PageInfo<Map<String,String>> pageInfo = new PageInfo<>(list);
+        return Result.successMsg("财务结算-结算单列表查询成功。", pageInfo);
+    }
 
 
     /**
@@ -134,13 +176,21 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
      * @author: zianY
      */
     @Override
+    @Transactional
     public Result insertAccountImages(ctopCwjsSettlementFileInfo settlementFileInfo) {
-        settlementFileInfo.getSettlementList().forEach(settlement -> {
+
+        for (ctopCwjsSettlementFileInfo settlement : settlementFileInfo.getSettlementList()) {
+
             settlement.setAccountId(SettlementUtil.subAccountName(settlement.getFileName()));
-            //BeanUtils.copyProperties(settlementFileInfo,settlement,true,CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
+
+            Map<String,String> map = settlementFileInfoMapper.getSettlementAccount(settlement.getFileName());
+            if (Check.isNull(map)){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return Result.errorMsg("无法查询到账户【"+settlement.getAccountId()+"】开户信息,请联系销售绑定账户。");
+            }
             BeanUtils.copyProperties(settlementFileInfo,settlement,SettlementUtil.getNullPropertyNames(settlementFileInfo));
             settlementFileInfoMapper.insert(settlement);
-        });
+        }
         return Result.successMsg("账户截图上传成功。",null);
     }
 

+ 20 - 4
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java

@@ -21,7 +21,10 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 
 @Slf4j
@@ -93,15 +96,13 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
 
             try {
                 LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-                //settlementInfo.setCreateUserId(user.getId());
-                settlementInfo.setCreateUserId("b161b7d9793942f980dbfe8c931cd1b0");
+                settlementInfo.setCreateUserId(user.getId());
+                //settlementInfo.setCreateUserId("b161b7d9793942f980dbfe8c931cd1b0");
                 ImportParams importParams = new ImportParams();
                 //表格标题行数
                 importParams.setTitleRows(1);
                 //表头行数
                 importParams.setHeadRows(1);
-                //校验数据
-                importParams.setNeedVerfiy(true);
 
                 //校验表头 头条
                 if (StringUtils.equals("1",String.valueOf(settlementInfo.getMediaId()))){
@@ -110,6 +111,7 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
                 }else if (StringUtils.equals("2",String.valueOf(settlementInfo.getMediaId()))){
                     importParams.setImportFields(new String[]{"快手ID","账户ID","账户名称"});
                 }
+                //校验excel的标题列顺序
                 importParams.setNeedCheckOrder(true);
                 ExcelImportResult<AccountImportVo> importResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AccountImportVo.class,importParams);
                 if (importResult.getList().size() < 1){
@@ -127,4 +129,18 @@ public class SettlementInfoServiceImpl extends ServiceImpl<SettlementInfoMapper,
             return Result.successMsg("账户数据上传成功。",null);
         }
 
+
+    /**
+     *
+     * @description: 查询多个用户信息
+     *
+     * @param userIds
+     * @return: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
+     * @author: zianY
+     */
+    @Override
+    public List<Map<String,Object>> getUserByIds(Set userIds) {
+        return settlementInfoMapper.getUserByIds(userIds);
+    }
+
 }

+ 19 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java

@@ -1,5 +1,6 @@
 package org.jeecg.ctop.finance.utils;
 
+import org.jeecg.ctop.finance.policy.utils.Check;
 import org.springframework.beans.BeanWrapper;
 import org.springframework.beans.BeanWrapperImpl;
 
@@ -20,6 +21,16 @@ import java.util.Set;
 public class SettlementUtil {
 
 
+    public static String getFileNameNoEx(String filename) {
+        if ((filename != null) && (filename.length() > 0)) {
+            int dot = filename.lastIndexOf('.');
+            if ((dot >-1) && (dot < (filename.length()))) {
+                return filename.substring(0, dot);
+            }
+        }
+        return filename;
+    }
+
     /**
      * 格式:123456-1
      * 截取 账户 id
@@ -27,7 +38,14 @@ public class SettlementUtil {
      * @return
      */
     public static String subAccountName(String str){
-        return str.substring(0, str.indexOf("-"));
+        if (!Check.isNull(str)){
+            if (str.contains("-")){
+                return str.substring(0, str.indexOf("-"));
+            }
+        }
+        return getFileNameNoEx(str);
+
+
     }
 
     /**

+ 5 - 0
jeecg-boot-finance/src/main/resources/application-dev.yml

@@ -16,6 +16,11 @@ management:
    exposure:
     include: metrics,httptrace
 spring:
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        service: jeecg-cloud-finance
   servlet:
      multipart:
         max-file-size: 10MB

+ 5 - 0
jeecg-boot-finance/src/main/resources/application-prod.yml

@@ -16,6 +16,11 @@ management:
    exposure:
     include: metrics,httptrace
 spring:
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 172.30.0.7:8848
+        service: jeecg-cloud-finance
   servlet:
      multipart:
         max-file-size: 10MB

+ 7 - 2
jeecg-boot-finance/src/main/resources/application-test.yml

@@ -12,6 +12,11 @@ management:
       exposure:
         include: metrics,httptrace
 spring:
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 139.186.134.115:8848
+        service: jeecg-cloud-finance
   servlet:
     multipart:
       max-file-size: -1
@@ -242,7 +247,7 @@ bytedance:
     advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
 ai:
   callback:
-    callback-unit-url: http://192.168.1.193:31012/ai_callback_add_group
-    callback-creative-url: http://192.168.1.193:31012/ai_callback_add_creative
+    callback-unit-url: http://139.186.165.84::31012/ai_callback_add_group
+    callback-creative-url: http://139.186.165.84::31012/ai_callback_add_creative
 xxl-job:
   requestUrl: http://jiaoyangapi.shyouteng.com.cn

+ 0 - 5
jeecg-boot-finance/src/main/resources/application.yml

@@ -8,10 +8,5 @@ spring:
     name: jeecg-cloud-finance
   profiles:
     active: @activatedProperties@
-  cloud:
-    nacos:
-      discovery:
-        server-addr: 127.0.0.1:8848
-        service: jeecg-cloud-finance
   main:
     allow-bean-definition-overriding: true

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/ISysUserService.java

@@ -292,4 +292,6 @@ public interface ISysUserService extends IService<SysUser> {
 
     /** userId转为username */
     List<String> userIdToUsername(Collection<String> userIdList);
+
+    List<SysUser> queryAdminPageList(SysUser user);
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java

@@ -650,4 +650,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         List<SysUser> userList = super.list(queryWrapper);
         return userList.stream().map(SysUser::getUsername).collect(Collectors.toList());
     }
+
+    @Override
+    public List<SysUser> queryAdminPageList(SysUser user) {
+        return userMapper.queryPageList(user);
+    }
 }

+ 21 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserCompanyServiceImpl.java

@@ -59,6 +59,27 @@ public class UserCompanyServiceImpl extends ServiceImpl<UserCompanyMapper, UserC
                     userCompany.setUserName(user.getRealname());
                     userCompany.setCompanyId(depart.getId());
                     userCompany.setCompanyName(depart.getDepartName());
+                    String departName = depart.getDepartName();
+                    if(!Check.isNull(departName)){
+                        if(departName.trim().contains("北京汇创思拓数字科技有限公司")){
+                            userCompany.setNickName("华北,石家庄");
+                        }
+                        if(departName.trim().contains("上海汇创思拓数字科技有限公司")){
+                            userCompany.setNickName("华东");
+                        }
+                        if(departName.trim().contains("北京骄阳")){
+                            userCompany.setNickName("骄阳");
+                        }
+                        if(departName.trim().contains("广州汇创思拓数字科技有限公司")){
+                            userCompany.setNickName("华南");
+                        }
+                        if(departName.trim().contains("北京次元像素")){
+                            userCompany.setNickName("华北,石家庄");
+                        }
+                        if(departName.trim().contains("杭州妙构思数字科技有限公司")){
+                            userCompany.setNickName("杭州");
+                        }
+                    }
                     QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper();
                     userCompanyQueryWrapper.eq("user_id", user.getId());
                     userCompanyQueryWrapper.last("limit 1");

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAdvertiserStrategy.java

@@ -318,7 +318,7 @@ public class AiKuaishouAdvertiserStrategy {
     /**
      * 安卓下载中间页ID
      */
-    private Integer siteId;
+    private String siteId;
     /**
      * 第三方点击检测链接
      */

+ 9 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -749,7 +749,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         programJson.put("cover_image_tokens", coverImageTokens);
 
         if (!Check.isNull(strategy.getSiteId())) {
-            programJson.put("site_id", strategy.getSiteId());
+            if (!strategy.getSiteId().equals("-1") ) {
+                programJson.put("site_id", strategy.getSiteId());
+            }
+
         }
         if (!Check.isNull(strategy.getStickerTitle())) {
             programJson.put("sticker_styles", strategy.getStickerTitle());
@@ -1447,12 +1450,14 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             creativeParams.put("expose_tag", strategy.getExposeTag());
         }
         // 广告标签2期
-        if (Check.isNull(strategy.getNewExposeTag())) {
+        if (!Check.isNull(strategy.getNewExposeTag())) {
             creativeParams.put("new_expose_tag", JSON.parseArray(strategy.getNewExposeTag()));
         }
         // 安卓下载中间页ID
-        if (Check.isNull(strategy.getSiteId())) {
-            creativeParams.put("site_id", strategy.getSiteId());
+        if (!Check.isNull(strategy.getSiteId())) {
+            if (!strategy.getSiteId().equals("-1") ) {
+                creativeParams.put("site_id", strategy.getSiteId());
+            }
         }
         if (null != strategy.getClickTrackUrl() && !"".equals(strategy.getClickTrackUrl())) {
             creativeParams.put("click_track_url", strategy.getClickTrackUrl());

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java

@@ -210,7 +210,7 @@ public class KuaiShouGroupTemplate {
     private String creativeName;
     private String actionBarText;
     private String description;
-    private Long siteId;
+    private String siteId;
     private Integer createCreativeCount;
     private Integer creativeStatus;
     private String creativeReviewDetail;

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

@@ -915,7 +915,7 @@
 	    sum(t1.form_count) AS 'formCount',
 	    round(
 		sum(
-			t1.play_3s_ratio * t1.photo_show
+			t1.play_3s_ratio * t1.aclick
 		)
 	    ) AS play3sCount
         FROM

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

@@ -117,7 +117,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         String creative_name = requestJson.getString("creativeName");
         String action_bar_text = requestJson.getString("actionBarText");
         String description = requestJson.getString("description");
-        Long site_id = requestJson.getLong("siteId");
+        String site_id = requestJson.getString("siteId");
         String schema_uri = requestJson.getString("schemaUri");
         Integer startNumber = 0;
         if (unitName.contains("{{序号}}")) {

+ 7 - 7
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -1890,13 +1890,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNullMap(dataJson)) {
                         JSONObject returnJson = new JSONObject();
-                        returnJson.put("isAdWatch5times",dataJson.getInteger("is_ad_watch_5_times"));
-                        returnJson.put("isAdWatch20times",dataJson.getInteger("is_ad_watch_20_times"));
-                        returnJson.put("isAdWatch10Times",dataJson.getInteger("is_ad_watch_10_times"));
-                        returnJson.put("isSevenDayRoi",dataJson.getInteger("is_seven_day_roi"));
-                        returnJson.put("isAppointJumpClick",dataJson.getInteger("is_appoint_jump_click"));
-                        returnJson.put("isEventWeekPayTimes",dataJson.getInteger("is_event_week_pay_times"));
-                        returnJson.put("isAppointForm",dataJson.getInteger("is_appoint_form"));
+                        returnJson.put("isAdWatch5times", dataJson.getInteger("is_ad_watch_5_times"));
+                        returnJson.put("isAdWatch20times", dataJson.getInteger("is_ad_watch_20_times"));
+                        returnJson.put("isAdWatch10Times", dataJson.getInteger("is_ad_watch_10_times"));
+                        returnJson.put("isSevenDayRoi", dataJson.getInteger("is_seven_day_roi"));
+                        returnJson.put("isAppointJumpClick", dataJson.getInteger("is_appoint_jump_click"));
+                        returnJson.put("isEventWeekPayTimes", dataJson.getInteger("is_event_week_pay_times"));
+                        returnJson.put("isAppointForm", dataJson.getInteger("is_appoint_form"));
                         returnJson.put("isActivate", dataJson.getInteger("is_activate"));
                         returnJson.put("isFormSubmit", dataJson.getInteger("is_form_submit"));
                         returnJson.put("isCreditGrant", dataJson.getInteger("is_credit_grant"));

+ 11 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java

@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.report.service.IKsNewGroupReportService;
 import cn.com.ctop.kuaishou.modules.report.service.IKsNewPlanReportService;
+import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
@@ -38,6 +39,9 @@ public class KsNewGroupReportCtrl {
     @Autowired
     IKsNewPlanReportService newPlanReportService;
 
+    @Autowired
+    NewMonitorService newMonitorService;
+
     /**
      * 新建计划、有效计划 chart数据
      */
@@ -67,6 +71,9 @@ public class KsNewGroupReportCtrl {
             JSONObject sumData = newGroupReportService.getSumNewGroupBy(accountIds, startDate, endDate);
             List<JSONObject> chartData = newGroupReportService.getKsNewGroupGroupByStatDate(accountIds, startDate, endDate);
             List<JSONObject> listData = newGroupReportService.getKsNewGroupGroupByAccount(accountIds, startDate, endDate, target, order);
+           /* List<JSONObject> chartData = newMonitorService.getKuaiShouGroupMessageGroup(accountIds, startDate, endDate);
+            JSONObject sumData = newMonitorService.getKuaiShouGroupSum(accountIds, startDate, endDate);
+            List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);*/
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -101,6 +108,7 @@ public class KsNewGroupReportCtrl {
         }
         return result;
     }
+
     @PostMapping("/report/excel")
     public void getExcelReport(@RequestBody JSONObject requestBody,
                                HttpServletRequest request,
@@ -123,7 +131,7 @@ public class KsNewGroupReportCtrl {
         String endDate = requestBody.getString("endDate");
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
-        List<JSONObject> listData = newGroupReportService.getKsNewGroupGroupByAccount(accountIds, startDate, endDate, target, order);
+        List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);
 
         List<List<Object>> excelList = new ArrayList<>();
         listData.forEach(data -> {
@@ -137,7 +145,7 @@ public class KsNewGroupReportCtrl {
             excelList.add(temp);
         });
         try {
-            String[] headers = {"账户名称","账户ID","账户所属人","新上推广组","有效推广组","最近上新时间"};
+            String[] headers = {"账户名称", "账户ID", "账户所属人", "新上推广组", "有效推广组", "最近上新时间"};
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
             XSSFWorkbook workbook = new XSSFWorkbook();
@@ -150,6 +158,7 @@ public class KsNewGroupReportCtrl {
             log.error(e.getMessage());
         }
     }
+
     /**
      * 查询所有的快手运营
      */

+ 11 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewPlanReportCtrl.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.report.controller;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.report.service.IKsNewPlanReportService;
+import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
@@ -34,6 +35,9 @@ public class KsNewPlanReportCtrl {
     @Autowired
     IKsNewPlanReportService newPlanReportService;
 
+    @Autowired
+    NewMonitorService newMonitorService;
+
     /**
      * 新建计划、有效计划 chart数据
      */
@@ -59,9 +63,12 @@ public class KsNewPlanReportCtrl {
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
-            JSONObject sumData = newPlanReportService.getSumNewPlanBy(accountIds, startDate, endDate);
-            List<JSONObject> chartData = newPlanReportService.getKsNewPlanGroupByStatDate(accountIds, startDate, endDate);
-            List<JSONObject> listData = newPlanReportService.getKsNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
+            //JSONObject sumData = newPlanReportService.getSumNewPlanBy(accountIds, startDate, endDate);
+            JSONObject sumData = newMonitorService.getPlanSum(accountIds, startDate, endDate, "1");
+            //List<JSONObject> chartData = newPlanReportService.getKsNewPlanGroupByStatDate(accountIds, startDate, endDate);
+            List<JSONObject> chartData = newMonitorService.getPlanMessageGroup(accountIds, startDate, endDate, "1");
+            //List<JSONObject> listData = newPlanReportService.getKsNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
+            List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "1");
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -122,7 +129,7 @@ public class KsNewPlanReportCtrl {
         String endDate = requestBody.getString("endDate");
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
-        List<JSONObject> listData = newPlanReportService.getKsNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
+        List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "1");
 
         List<List<Object>> excelList = new ArrayList<>();
         listData.forEach(data -> {

+ 36 - 23
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouGroupExploreController.java

@@ -1,3 +1,4 @@
+
 package cn.com.ctop.kuaishou.modules.report.controller;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
@@ -11,11 +12,19 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
 
+
 /**
  * 广告组的加速探索报表
  *
@@ -23,14 +32,16 @@ import java.util.Arrays;
  * @version V1.0
  * @date 2021-02-02
  */
+
 @Slf4j
 @Api(tags = "广告组的加速探索报表")
 @RestController
-@RequestMapping("/explore")
+@RequestMapping("/explores")
 public class KuaishouGroupExploreController {
     @Autowired
     private IKuaishouGroupExploreService kuaishouGroupExploreService;
 
+
     /**
      * 分页列表查询
      *
@@ -40,6 +51,7 @@ public class KuaishouGroupExploreController {
      * @param req
      * @return
      */
+
     @GetMapping(value = "/list")
     public Result<IPage<KuaishouGroupExplore>> queryPageList(KuaishouGroupExplore kuaishouGroupExplore,
                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@@ -54,76 +66,71 @@ public class KuaishouGroupExploreController {
         return result;
     }
 
+
     /**
      * 查询加速探索信息接口
      *
      * @param data
      * @return
      */
+
     @PostMapping(value = "/unitExploreInfoGet")
     public Result<Object> unitExploreInfoGet(@RequestBody JSONObject data) {
         try {
-            return kuaishouGroupExploreService.unitExploreInfoGet(data);
+            return kuaishouGroupExploreService.unitExploreInfoGet(data.getLong("accountId"), data.getLong("unitId"));
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             return Result.error("操作失败");
         }
     }
 
-    /**
-     * 广告组的加速探索预算设置接口
-     *
-     * @param data
-     * @return
-     */
+
     @PostMapping(value = "/unitExploreBudgetUpdate")
     public Result<Object> unitExploreBudgetUpdate(@RequestBody JSONObject data) {
         try {
-            return kuaishouGroupExploreService.unitExploreBudgetUpdate(data);
+            return kuaishouGroupExploreService.unitExploreBudgetUpdate(data.getLong("accountId"), data.getLong("unitId"), data.getLong("exploreBudget"));
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             return Result.error("操作失败");
         }
     }
 
-    /**
-     * 暂停广告组的加速探索预算接口
-     *
-     * @param data
-     * @return
-     */
-    @PostMapping(value = "/unitExploreStatusPause")
-    public Result<Object> unitExploreStatusPause(@RequestBody JSONObject data) {
+    @PostMapping(value = "/querySpeedExploreReport")
+    public Result<Object> querySpeedExploreReport(@RequestBody JSONObject data) {
         try {
-            return kuaishouGroupExploreService.unitExploreStatusPause(data);
+            return kuaishouGroupExploreService.querySpeedExploreReport(data.getLong("accountId"), data.getLong("unitId"), data.getInteger("exploreBudget"), data.getLong("max_explore_budget"));
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             return Result.error("操作失败");
         }
     }
 
+
     /**
-     * 查询广告组的加速探索报表接口
+     * 暂停广告组的加速探索预算接口
      *
      * @param data
      * @return
      */
-    @PostMapping(value = "/querySpeedExploreReport")
-    public Result<Object> querySpeedExploreReport(@RequestBody JSONObject data) {
+
+    @PostMapping(value = "/unitExploreStatusPause")
+    public Result<Object> unitExploreStatusPause(@RequestBody JSONObject data) {
         try {
-            return kuaishouGroupExploreService.querySpeedExploreReport(data);
+            return kuaishouGroupExploreService.unitExploreStatusPause(data);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             return Result.error("操作失败");
         }
     }
 
+
     /**
      * 辅助探索
      *
      * @param data
      * @return
      */
+
     @PostMapping(value = "/adUnitExploreSupport")
     public Result<Object> adUnitExploreSupport(@RequestBody JSONObject data) {
         try {
@@ -141,6 +148,7 @@ public class KuaishouGroupExploreController {
      * @param kuaishouGroupExplore
      * @return
      */
+
     @PostMapping(value = "/add")
     public Result<KuaishouGroupExplore> add(@RequestBody KuaishouGroupExplore kuaishouGroupExplore) {
         Result<KuaishouGroupExplore> result = new Result<>();
@@ -160,6 +168,7 @@ public class KuaishouGroupExploreController {
      * @param kuaishouGroupExplore
      * @return
      */
+
     @PutMapping(value = "/edit")
     public Result<KuaishouGroupExplore> edit(@RequestBody KuaishouGroupExplore kuaishouGroupExplore) {
         Result<KuaishouGroupExplore> result = new Result<KuaishouGroupExplore>();
@@ -176,12 +185,14 @@ public class KuaishouGroupExploreController {
         return result;
     }
 
+
     /**
      * 通过id删除
      *
      * @param id
      * @return
      */
+
     @DeleteMapping(value = "/delete")
     public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
         try {
@@ -199,6 +210,7 @@ public class KuaishouGroupExploreController {
      * @param ids
      * @return
      */
+
     @DeleteMapping(value = "/deleteBatch")
     public Result<KuaishouGroupExplore> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
         Result<KuaishouGroupExplore> result = new Result<>();
@@ -217,6 +229,7 @@ public class KuaishouGroupExploreController {
      * @param id
      * @return
      */
+
     @GetMapping(value = "/queryById")
     public Result<KuaishouGroupExplore> queryById(@RequestParam(name = "id", required = true) String id) {
         Result<KuaishouGroupExplore> result = new Result<>();

+ 246 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouReportDailyExploreController.java

@@ -0,0 +1,246 @@
+package cn.com.ctop.kuaishou.modules.report.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyExplore;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyExploreService;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 广告组加速探索报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-08-18
+ */
+@Slf4j
+@Api(tags = "广告组加速探索报表")
+@RestController
+@RequestMapping("/kuaishouReportDailyExplore")
+public class KuaishouReportDailyExploreController {
+    @Autowired
+    private IKuaishouReportDailyExploreService kuaishouReportDailyExploreService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouReportDailyExplore
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "广告组加速探索报表-分页列表查询", notes = "广告组加速探索报表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouReportDailyExplore>> queryPageList(KuaishouReportDailyExplore kuaishouReportDailyExplore,
+                                                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                   HttpServletRequest req) {
+        Result<IPage<KuaishouReportDailyExplore>> result = new Result<>();
+        QueryWrapper<KuaishouReportDailyExplore> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouReportDailyExplore, req.getParameterMap());
+        Page<KuaishouReportDailyExplore> page = new Page<KuaishouReportDailyExplore>(pageNo, pageSize);
+        IPage<KuaishouReportDailyExplore> pageList = kuaishouReportDailyExploreService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouReportDailyExplore
+     * @return
+     */
+    @ApiOperation(value = "广告组加速探索报表-添加", notes = "广告组加速探索报表-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouReportDailyExplore> add(@RequestBody KuaishouReportDailyExplore kuaishouReportDailyExplore) {
+        Result<KuaishouReportDailyExplore> result = new Result<>();
+        try {
+            kuaishouReportDailyExploreService.save(kuaishouReportDailyExplore);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouReportDailyExplore
+     * @return
+     */
+    @ApiOperation(value = "广告组加速探索报表-编辑", notes = "广告组加速探索报表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouReportDailyExplore> edit(@RequestBody KuaishouReportDailyExplore kuaishouReportDailyExplore) {
+        Result<KuaishouReportDailyExplore> result = new Result<KuaishouReportDailyExplore>();
+        KuaishouReportDailyExplore kuaishouReportDailyExploreEntity = kuaishouReportDailyExploreService.getById(kuaishouReportDailyExplore.getId());
+        if (kuaishouReportDailyExploreEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouReportDailyExploreService.updateById(kuaishouReportDailyExplore);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "广告组加速探索报表-通过id删除", notes = "广告组加速探索报表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id") String id) {
+        try {
+            kuaishouReportDailyExploreService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "广告组加速探索报表-批量删除", notes = "广告组加速探索报表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouReportDailyExplore> deleteBatch(@RequestParam(name = "ids") String ids) {
+        Result<KuaishouReportDailyExplore> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouReportDailyExploreService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "广告组加速探索报表-通过id查询", notes = "广告组加速探索报表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouReportDailyExplore> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouReportDailyExplore> result = new Result<>();
+        KuaishouReportDailyExplore kuaishouReportDailyExplore = kuaishouReportDailyExploreService.getById(id);
+        if (kuaishouReportDailyExplore == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouReportDailyExplore);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouReportDailyExplore> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouReportDailyExplore kuaishouReportDailyExplore = JSON.parseObject(deString, KuaishouReportDailyExplore.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouReportDailyExplore, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouReportDailyExplore> pageList = kuaishouReportDailyExploreService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "广告组加速探索报表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouReportDailyExplore.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("广告组加速探索报表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouReportDailyExplore> listKuaishouReportDailyExplores = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouReportDailyExplore.class, params);
+                kuaishouReportDailyExploreService.saveBatch(listKuaishouReportDailyExplores);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouReportDailyExplores.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 35 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/NewMonitorController.java

@@ -0,0 +1,35 @@
+package cn.com.ctop.kuaishou.modules.report.controller;
+
+import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description: 新上监控
+ * @Author: zzy
+ * @Date: 2021-08-13
+ * @Version: V1.0
+ */
+@RestController
+@RequestMapping("/newMonitor")
+public class NewMonitorController {
+
+    @Autowired
+    NewMonitorService newMonitorService;
+
+    /**
+     *
+     *
+     * @param type
+     * @return
+     */
+    @GetMapping("/synchronousMonitor")
+    public Result synchronousMonitor(@Param("type") String type) {
+        return newMonitorService.synchronousMonitor(type);
+    }
+}

+ 147 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyExplore.java

@@ -0,0 +1,147 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+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 org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 广告组加速探索报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-08-18
+ */
+@Data
+@TableName("ctop_kuaishou_report_daily_explore")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_report_daily_explore对象", description = "广告组加速探索报表")
+public class KuaishouReportDailyExplore {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 计划ID
+     */
+    @Excel(name = "计划ID", width = 15)
+    @ApiModelProperty(value = "计划ID")
+    private Long campaignId;
+    /**
+     * 计划名称
+     */
+    @Excel(name = "计划名称", width = 15)
+    @ApiModelProperty(value = "计划名称")
+    private String campaignName;
+    /**
+     * 组ID
+     */
+    @Excel(name = "组ID", width = 15)
+    @ApiModelProperty(value = "组ID")
+    private Long unitId;
+    /**
+     * 组名称
+     */
+    @Excel(name = "组名称", width = 15)
+    @ApiModelProperty(value = "组名称")
+    private String unitName;
+    /**
+     * 探索预算
+     */
+    @Excel(name = "探索预算", width = 15)
+    @ApiModelProperty(value = "探索预算")
+    private java.math.BigDecimal exploreBudget;
+    /**
+     * 优化目标
+     */
+    @Excel(name = "优化目标", width = 15)
+    @ApiModelProperty(value = "优化目标")
+    private Integer ocpxActionType;
+    /**
+     * 总消耗
+     */
+    @Excel(name = "总消耗", width = 15)
+    @ApiModelProperty(value = "总消耗")
+    private java.math.BigDecimal totalCharge;
+    /**
+     * 封面曝光数
+     */
+    @Excel(name = "封面曝光数", width = 15)
+    @ApiModelProperty(value = "封面曝光数")
+    private Long impression;
+    /**
+     * 封面点击数
+     */
+    @Excel(name = "封面点击数", width = 15)
+    @ApiModelProperty(value = "封面点击数")
+    private Long photoClick;
+    /**
+     * 素材曝光数
+     */
+    @Excel(name = "素材曝光数", width = 15)
+    @ApiModelProperty(value = "素材曝光数")
+    private Long click;
+    /**
+     * 转化数
+     */
+    @Excel(name = "转化数", width = 15)
+    @ApiModelProperty(value = "转化数")
+    private Long unifiedConversion;
+    /**
+     * 转化成本
+     */
+    @Excel(name = "转化成本", width = 15)
+    @ApiModelProperty(value = "转化成本")
+    private java.math.BigDecimal unitfiedConversionCost;
+    /**
+     * 记录日期
+     */
+    @Excel(name = "记录日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "记录日期")
+    private Date statDate;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+    /**
+     * 加速探索状态 0:默认;1:加速探索2:加速探索手动暂停;3:探索金额完成;4:时间到达截止时间,默认开启后只探索 6 小时
+     */
+    private Integer exploreStatus;
+    /**
+     * 可设置的最大加速探索预算,单位:里
+     */
+    private Long maxExploreBudget;
+}

+ 15 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyExploreMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyExplore;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 广告组加速探索报表
+ *
+ * @author jeecg-boot
+ * 2021-08-18
+ * @version V1.0
+ */
+public interface KuaishouReportDailyExploreMapper extends BaseMapper<KuaishouReportDailyExplore> {
+
+}

+ 49 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java

@@ -0,0 +1,49 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface NewMonitorMapper {
+
+    List<Map> getKuaiShouGroup(@Param("date")String date);
+
+    List<Map> getKuaiShouCampaign(@Param("date")String date);
+
+    List<Map> getTouTiaoCampaign(@Param("date")String date);
+
+    String getGroupCharge(@Param("unitId")String unitId,@Param("afterDate")String afterDate);
+
+    String getCampaignCharge(@Param("campaignId")String campaignId,@Param("afterDate")String afterDate);
+
+    String getCampaignChargeTouTiao(@Param("campaignId")String campaignId,@Param("afterDate")String afterDate);
+
+    void saveMonitorGroup(@Param("accountId")String accountId,@Param("accountName")String accountName,@Param("operatingName")String operatingName,@Param("unitId")String unitId,@Param("createTime")String createTime,@Param("projectType")String projectType,@Param("effective")String effective);
+
+    void saveMonitorCampaign(@Param("accountId")String accountId,@Param("accountName")String accountName,@Param("operatingName")String operatingName,@Param("campaignId")String campaignId,@Param("createTime")String createTime,@Param("projectType")String projectType,@Param("effective")String effective);
+
+    String  getMonitorGroupByUnitId(@Param("unitId")String unitId);
+
+    String  getMonitorPlanByCampaignId(@Param("campaignId")String campaignId);
+
+    void  updateMonitorGroupByUnitId(@Param("unitId")String unitId,@Param("effective")String effective);
+
+    void  updateMonitorPlanByCampaignId(@Param("campaignId")String campaignId,@Param("effective")String effective);
+
+    List<JSONObject> getKuaiShouGroupMessage(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    JSONObject getKuaiShouGroupSum(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    List<JSONObject> getKuaiShouGroupMessageGroup(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("group")String group);
+
+    List<JSONObject> getPlanMessage(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("project")String project);
+
+    JSONObject getPlanSum(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("project")String project);
+
+    List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate")String startDate, @Param("endDate")String endDate,@Param("group")String group,@Param("project")String project);
+}

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyExploreMapper.xml

@@ -0,0 +1,5 @@
+<?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="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyExploreMapper">
+
+</mapper>

+ 164 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml

@@ -0,0 +1,164 @@
+<?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="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper">
+
+    <select id="getKuaiShouGroup" resultType="Map">
+    SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.unit_id as 'unitId',t.group_create_time as 'groupCreatTime',DATE_FORMAT(DATE_ADD(t.group_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
+     from ctop_user_allocation t1 LEFT JOIN  ctop_kuaishou_group t on t1.account_id=t.account_id
+     <where>
+         <choose>
+             <when test="date!= null and date!=''">
+                 and  t.group_create_time &gt;= DATE_SUB(#{date},INTERVAL 7 DAY)
+             </when>
+             <otherwise>
+                 t.group_create_time &gt;= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
+             </otherwise>
+         </choose>
+     </where>
+    </select>
+
+    <select id="getKuaiShouCampaign" resultType="Map">
+        SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.campaign_id as 'campaignId',t.put_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.put_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
+        from ctop_user_allocation t1 LEFT JOIN  ctop_kuaishou_campaign t on t1.account_id=t.account_id
+        <where>
+            <choose>
+                <when test="date != null and date !=''">
+                    and  t.put_create_time &gt;= DATE_SUB(#{date},INTERVAL 7 DAY)
+                </when>
+                <otherwise>
+                    t.put_create_time &gt;= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
+                </otherwise>
+            </choose>
+        </where>
+    </select>
+
+    <select id="getTouTiaoCampaign" resultType="Map">
+        SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.id as 'campaignId',t.ad_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.ad_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
+        from ctop_user_allocation t1 LEFT JOIN  ctop_bytedance_advertise_plan t on t1.account_id=t.account_id
+        <where>
+            <choose>
+                <when test="date != null and date !=''">
+                    and  t.ad_create_time &gt;= DATE_SUB(#{date},INTERVAL 7 DAY)
+                </when>
+                <otherwise>
+                    t.ad_create_time &gt;= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
+                </otherwise>
+            </choose>
+        </where>
+    </select>
+
+    <select id="getGroupCharge" resultType="String">
+
+        select sum(charge) from ctop_kuaishou_report_daily_group t where t.stat_date &lt; #{afterDate} and t.unit_id=#{unitId}
+    </select>
+
+    <select id="getCampaignCharge" resultType="String">
+
+        select sum(charge) from ctop_kuaishou_report_daily_campaign t where t.stat_date &lt; #{afterDate} and t.campaign_id=#{campaignId}
+    </select>
+
+    <select id="getCampaignChargeTouTiao" resultType="String">
+
+        select sum(cost) from ctop_bytedance_report_plan_daily t where t.stat_datetime &lt; #{afterDate} and t.ad_id=#{campaignId}
+    </select>
+
+    <insert id="saveMonitorGroup">
+        insert into  ctop_new_monitor_group(account_id,account_name,operating_name,unit_id,create_time,project_type,effective) values
+        (#{accountId},#{accountName},#{operatingName},#{unitId},#{createTime},#{projectType},#{effective})
+    </insert>
+
+    <insert id="saveMonitorCampaign">
+        insert into ctop_new_monitor_campaign (account_id,account_name,operating_name,campaign_id,create_time,project_type,effective) values
+        (#{accountId},#{accountName},#{operatingName},#{campaignId},#{createTime},#{projectType},#{effective})
+    </insert>
+
+    <select id="getMonitorGroupByUnitId" resultType="int" >
+        select  t.effective from ctop_new_monitor_group t where t.unit_id=#{unitId}
+    </select>
+
+    <select id="getMonitorPlanByCampaignId" resultType="int" >
+        select  t.effective from ctop_new_monitor_campaign t where t.campaign_id=#{campaignId}
+    </select>
+
+    <update id="updateMonitorGroupByUnitId" >
+        update ctop_new_monitor_group  t set t.effective=#{effective} where  t.unit_id=#{unitId}
+    </update>
+
+    <update id="updateMonitorPlanByCampaignId" >
+        update ctop_new_monitor_campaign  t set t.effective=#{effective} where  t.campaign_id=#{campaignId}
+    </update>
+
+    <select id="getKuaiShouGroupMessage" resultType="com.alibaba.fastjson.JSONObject">
+        select account_id as 'accountId',account_name as 'authName',MAX(create_time) as 'maxCreateTime',COUNT(IF(effective ='1', TRUE, NULL))  as 'valid',count(effective) as 'new',operating_name as 'userName','' as 'projectName'
+         from ctop_new_monitor_group  where ( create_time between #{startDate}  and #{endDate})
+        and account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+               #{item}
+        </foreach>
+        GROUP BY account_id
+
+    </select>
+
+
+    <select id="getPlanMessage" resultType="com.alibaba.fastjson.JSONObject">
+        select account_id as 'accountId',account_name as 'authName',MAX(create_time) as 'maxCreateTime',COUNT(IF(effective ='1', TRUE, NULL))  as 'valid',count(effective) as 'new',operating_name as 'userName','' as 'projectName'
+        from ctop_new_monitor_campaign  where ( create_time between #{startDate}  and #{endDate}) and project_type=#{project}
+        and account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+        GROUP BY account_id
+
+    </select>
+
+    <select id="getKuaiShouGroupSum" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective)  as 'new' from ctop_new_monitor_group t
+        where  create_time between #{startDate}  and #{endDate}
+        and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getPlanSum" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective)  as 'new' from ctop_new_monitor_campaign t
+        where  (create_time between #{startDate}  and #{endDate}) and project_type=#{project}
+        and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getKuaiShouGroupMessageGroup" resultType="com.alibaba.fastjson.JSONObject" >
+    SELECT DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL))  as 'valid' from ctop_new_monitor_group t
+     where  (create_time between #{startDate}  and #{endDate}) and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+        <choose>
+            <when test='group=="1"'>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m')
+            </when>
+            <otherwise>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m-%d')
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="getPlanMessageGroup" resultType="com.alibaba.fastjson.JSONObject" >
+        SELECT DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL))  as 'valid' from ctop_new_monitor_campaign t
+        where project_type=#{project} and  (create_time between #{startDate}  and #{endDate}) and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+        <choose>
+            <when test='group=="1"'>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m')
+            </when>
+            <otherwise>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m-%d')
+            </otherwise>
+        </choose>
+    </select>
+
+</mapper>

+ 5 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouGroupExploreService.java

@@ -11,20 +11,20 @@ import java.math.BigDecimal;
 /**
  * @Description: 广告组的加速探索报表
  * @Author: jeecg-boot
- * @Date:   2021-02-02
+ * @Date: 2021-02-02
  * @Version: V1.0
  */
 public interface IKuaishouGroupExploreService extends IService<KuaishouGroupExplore> {
 
-    Result<Object> unitExploreInfoGet(JSONObject data);
+    Result<Object> unitExploreInfoGet(Long accountId, Long unitId);
 
-    Result<Object> unitExploreBudgetUpdate(JSONObject data);
+    Result<Object> unitExploreBudgetUpdate(Long accountId, Long unitId, Long exploreBudget);
 
     Result<Object> unitExploreStatusPause(JSONObject data);
 
-    Result<Object> querySpeedExploreReport(JSONObject data);
+    Result<Object> querySpeedExploreReport(Long accountId, Long unitId, Integer exploreStatus, Long maxExploreBudget);
 
-    void unitOpenSpeedExplore(Long accountId, Long unitId, BigDecimal groupAccount,Long accountExploreId);
+    void unitOpenSpeedExplore(Long accountId, Long unitId, BigDecimal groupAccount, Long accountExploreId);
 
     void getReportByAccount(CtopOauthToken token);
 

+ 14 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyExploreService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyExplore;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 广告组加速探索报表
+ * @author jeecg-boot
+ * 2021-08-18
+ * @version V1.0
+ */
+public interface IKuaishouReportDailyExploreService extends IService<KuaishouReportDailyExplore> {
+
+}

+ 23 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.List;
+
+public interface NewMonitorService {
+    public Result synchronousMonitor(String type);
+
+    List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate,String target);
+
+    JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate);
+
+    List<JSONObject> getKuaiShouGroupMessageGroup(JSONArray array, String startDate, String endDate);
+
+    List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate,String target,String project);
+
+    JSONObject getPlanSum(JSONArray array, String startDate, String endDate,String project);
+
+    List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate,String project);
+}

+ 50 - 41
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouGroupExploreServiceImpl.java

@@ -2,12 +2,20 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouGroupSpeedExploreLogService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyExplore;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouGroupExploreMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyExploreService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -18,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -35,25 +44,23 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
     private ICtopOauthTokenService tokenService;
     @Autowired
     private IKuaishouGroupSpeedExploreLogService groupSpeedExploreLogService;
+    @Autowired
+    private IKuaishouReportDailyExploreService dailyExploreService;
+
+    @Autowired
+    private IKuaiShouGroupService kuaiShouGroupService;
 
     /**
-     * 查询加速探索信息
+     * 查询加速探索状态、预算
      *
      * @param
+     * @return
      * @throws
      * @author ZHAOXA
      */
     @Override
-    public Result<Object> unitExploreInfoGet(JSONObject data) {
+    public Result<Object> unitExploreInfoGet(Long accountId, Long unitId) {
         try {
-            Long accountId = data.getLong("accountId");
-            if (Check.isNull(accountId)) {
-                return Result.error("请选择广告主");
-            }
-            Long unitId = data.getLong("unitId");
-            if (Check.isNull(unitId)) {
-                return Result.error("请选择广告组");
-            }
             CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_INFO_GET;
             Map<String, String> header = new HashMap<>();
@@ -80,27 +87,16 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
     }
 
     /**
-     * 广告组加速探索预算设置
+     * 开启广告组加速探索
      *
      * @param
      * @throws
      * @author ZHAOXA
      */
     @Override
-    public Result<Object> unitExploreBudgetUpdate(JSONObject data) {
+    public Result<Object> unitExploreBudgetUpdate(Long accountId, Long unitId, Long exploreBudget) {
+        String msg = null;
         try {
-            Long accountId = data.getLong("accountId");
-            if (Check.isNull(accountId)) {
-                return Result.error("请选择广告主");
-            }
-            Long unitId = data.getLong("unitId");
-            if (Check.isNull(unitId)) {
-                return Result.error("请选择广告组");
-            }
-            Long exploreBudget = data.getLong("exploreBudget");
-            if (Check.isNull(exploreBudget)) {
-                return Result.error("请填写加速探索预算");
-            }
             CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_BUDGET_UPDATE;
             Map<String, String> header = new HashMap<>();
@@ -115,6 +111,21 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
+                    Result<Object> result1 = this.unitExploreInfoGet(accountId, unitId);
+                    if (result1.getCode() == 200) {
+                        JSONObject resultData = (JSONObject) result1.getResult();
+                        Integer exploreStatus = resultData.getInteger("explore_status");
+                        Long maxExploreBudget = resultData.getLong("max_explore_budget");
+                        KuaiShouGroup kuaiShouGroup = new KuaiShouGroup();
+
+                        KuaishouReportDailyExplore kuaishouGroupExplore = new KuaishouReportDailyExplore();
+                        kuaishouGroupExplore.setAccountId(accountId);
+                        kuaishouGroupExplore.setUnitId(unitId);
+                        kuaishouGroupExplore.setStatDate(new Date());
+                        kuaishouGroupExplore.setMaxExploreBudget(maxExploreBudget);
+                        kuaishouGroupExplore.setExploreStatus(exploreStatus);
+                        dailyExploreService.save(kuaishouGroupExplore);
+                    }
                     return Result.ok(resultJson.getJSONObject("data"));
                 } else {
                     log.info("广告组的加速探索预算设置失败,accountId:{},返回信息:{}", accountId, resultJson);
@@ -122,7 +133,7 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
                 }
             }
         } catch (Exception e) {
-            log.error("广告组的加速探索预算设置失败", e);
+            log.error("广告组({})启动加速探索失败", unitId, e);
         }
         return Result.error("广告组的加速探索预算设置失败");
     }
@@ -178,16 +189,8 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
      * @author ZHAOXA
      */
     @Override
-    public Result<Object> querySpeedExploreReport(JSONObject data) {
+    public Result<Object> querySpeedExploreReport(Long accountId, Long unitId, Integer exploreStatus, Long maxExploreBudget) {
         try {
-            Long accountId = data.getLong("accountId");
-            if (Check.isNull(accountId)) {
-                return Result.error("请选择广告主");
-            }
-            Long unitId = data.getLong("unitId");
-            if (Check.isNull(unitId)) {
-                return Result.error("请选择广告组");
-            }
             CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.QUERY_SPEED_EXPLORE_REPORT;
             Map<String, String> header = new HashMap<>();
@@ -202,19 +205,25 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
                     JSONObject exploreJson = resultJson.getJSONObject("data");
-                    KuaishouGroupExplore kuaishouGroupExplore = JSONObject.toJavaObject(exploreJson, KuaishouGroupExplore.class);
+                    KuaishouReportDailyExplore kuaishouGroupExplore = JSONObject.toJavaObject(exploreJson, KuaishouReportDailyExplore.class);
                     if (Check.isNull(kuaishouGroupExplore)) {
                         return Result.error("查询失败,结果为空");
                     }
-                    QueryWrapper<KuaishouGroupExplore> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("unit_id", kuaishouGroupExplore.getUnitId());
-                    KuaishouGroupExplore one = this.getOne(queryWrapper);
+                    QueryWrapper<KuaishouReportDailyExplore> queryWrapper = new QueryWrapper<>();
+                    queryWrapper.eq("unit_id", unitId);
+                    queryWrapper.eq("account_id", accountId);
+                    KuaishouReportDailyExplore one = dailyExploreService.getOne(queryWrapper);
                     if (!Check.isNull(one)) {
                         kuaishouGroupExplore.setId(one.getId());
                     }
                     kuaishouGroupExplore.setAccountId(accountId);
-                    this.saveOrUpdate(kuaishouGroupExplore);
-                    return Result.ok("添加成功");
+                    kuaishouGroupExplore.setExploreStatus(exploreStatus);
+                    kuaishouGroupExplore.setMaxExploreBudget(maxExploreBudget);
+                    kuaishouGroupExplore.setStatDate(new Date());
+                    boolean b = dailyExploreService.saveOrUpdate(kuaishouGroupExplore);
+                    if (b) {
+                        return Result.ok("添加成功");
+                    }
                 } else {
                     log.info("查询广告组的加速探索报表失败,accountId:{},返回信息:{}", accountId, resultJson);
                     return Result.error("查询广告组的加速探索报表失败," + resultJson.getString("message"));

+ 19 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyExploreServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyExplore;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyExploreMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyExploreService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 广告组加速探索报表
+ *
+ * @author jeecg-boot
+ * 2021-08-18
+ * @version V1.0
+ */
+@Service
+public class KuaishouReportDailyExploreServiceImpl extends ServiceImpl<KuaishouReportDailyExploreMapper, KuaishouReportDailyExplore> implements IKuaishouReportDailyExploreService {
+
+}

+ 242 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java

@@ -0,0 +1,242 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper;
+import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@Service
+@Slf4j
+public class NewMonitorServiceImpl implements NewMonitorService {
+
+    @Resource
+    NewMonitorMapper newMonitorMapper;
+
+    /**
+     * 同步新上监控数据
+     *
+     * @param
+     * @return
+     */
+    public Result synchronousMonitor(String type) {
+        Result result = new Result();
+        List<Map> kuaiShouGroup = new ArrayList<>();
+        List<Map> kuaiShouCampaign = new ArrayList<>();
+        List<Map> TouTiaoCampaign = new ArrayList<>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        /*--------------------快手广告组-----------------------*/
+        if (type.equals("0")) {
+            //查询创建不满7天的快手组信息
+            kuaiShouGroup = newMonitorMapper.getKuaiShouGroup(sdf.format(new Date()));
+        } else {
+            //查询全量快手组信息
+            kuaiShouGroup = newMonitorMapper.getKuaiShouGroup(null);
+        }
+        //处理快手组数据
+        if (!kuaiShouGroup.isEmpty()) {
+            kuaiShouGroup.stream().forEach(obj -> {
+                if (obj != null) {
+                    String unitId = obj.get("unitId") == null ? null : String.valueOf(obj.get("unitId"));
+                    String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                    String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                    String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                    String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                    String groupCreatTime = obj.get("groupCreatTime") == null ? null : (String) obj.get("groupCreatTime");
+                    if (unitId != null && afterTime != null) {
+                        String groupCharge = newMonitorMapper.getGroupCharge(unitId, afterTime);
+                        //大于500为有效广告组
+                        String effective = "0";
+                        if (groupCharge != null && Long.parseLong(groupCharge) > 500) {
+                            //有效
+                            effective = "1";
+                        }
+                        String effectiveResult = newMonitorMapper.getMonitorGroupByUnitId(unitId);
+                        //判断是否存在
+                        if (effectiveResult != null) {
+                            if (!effectiveResult.equals(effective)) {
+                                //存在更新
+                                newMonitorMapper.updateMonitorGroupByUnitId(unitId, effective);
+                            }
+
+                        } else {
+                            //不存在插入
+                            newMonitorMapper.saveMonitorGroup(accountId, accountName, userName, unitId, groupCreatTime, "1", effective);
+                        }
+                    }
+                }
+            });
+        }
+
+
+        /*---------------快手广告计划------------------*/
+        if (type.equals("0")) {
+            //查询创建不满7天的快手广告计划
+            kuaiShouCampaign = newMonitorMapper.getKuaiShouCampaign(sdf.format(new Date()));
+        } else {
+            //查询全量快手广告计划
+            kuaiShouCampaign = newMonitorMapper.getKuaiShouCampaign(null);
+        }
+        //处理快手广告计划数据
+        if (!kuaiShouCampaign.isEmpty()) {
+            kuaiShouCampaign.stream().forEach(obj -> {
+                if (obj != null) {
+                    String campaignId = obj.get("campaignId") == null ? null : String.valueOf(obj.get("campaignId"));
+                    String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                    String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                    String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                    String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                    String campaignCreatTime = obj.get("campaignCreatTime") == null ? null : (String) obj.get("campaignCreatTime");
+                    if (campaignId != null && afterTime != null) {
+                        String campaignCharge = newMonitorMapper.getCampaignCharge(campaignId, afterTime);
+                        //大于500为有效广告计划
+                        String effective = "0";
+                        if (campaignCharge != null && Long.parseLong(campaignCharge) > 500) {
+                            //有效
+                            effective = "1";
+                        }
+                        String effectiveResult = newMonitorMapper.getMonitorPlanByCampaignId(campaignId);
+                        //判断是否存在
+                        if (effectiveResult != null) {
+                            if (!effectiveResult.equals(effective)) {
+                                //存在更新
+                                newMonitorMapper.updateMonitorPlanByCampaignId(campaignId, effective);
+                            }
+                        } else {
+                            //不存在插入
+                            newMonitorMapper.saveMonitorCampaign(accountId, accountName, userName, campaignId, campaignCreatTime, "1", effective);
+                        }
+                    }
+                }
+            });
+        }
+
+        /*---------------头条广告计划------------------*/
+        if (type.equals("0")) {
+            //查询创建不满7天的头条广告计划
+            TouTiaoCampaign = newMonitorMapper.getTouTiaoCampaign(sdf.format(new Date()));
+        } else {
+            //查询全量头条广告计划
+            TouTiaoCampaign = newMonitorMapper.getTouTiaoCampaign(null);
+        }
+        //处理快手广告计划数据
+        if (!TouTiaoCampaign.isEmpty()) {
+            TouTiaoCampaign.stream().forEach(obj -> {
+                if (obj != null) {
+                    String campaignId = obj.get("campaignId") == null ? null : String.valueOf(obj.get("campaignId"));
+                    String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                    String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                    String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                    String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                    String campaignCreatTime = obj.get("campaignCreatTime") == null ? null : (String) obj.get("campaignCreatTime");
+                    if (campaignId != null && afterTime != null) {
+                        String campaignCharge = newMonitorMapper.getCampaignChargeTouTiao(campaignId, afterTime);
+                        //大于500为有效广告计划
+                        String effective = "0";
+                        if (campaignCharge != null && Long.parseLong(campaignCharge) > 500) {
+                            //有效
+                            effective = "1";
+                        }
+                        String effectiveResult = newMonitorMapper.getMonitorPlanByCampaignId(campaignId);
+                        //判断是否存在
+                        if (effectiveResult != null) {
+                            if (!effectiveResult.equals(effective)) {
+                                //存在更新
+                                newMonitorMapper.updateMonitorPlanByCampaignId(campaignId, effective);
+                            }
+                        } else {
+                            //不存在插入
+                            newMonitorMapper.saveMonitorCampaign(accountId, accountName, userName, campaignId, campaignCreatTime, "0", effective);
+                        }
+                    }
+                }
+            });
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 查询快手组信息
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate, String target) {
+        return  newMonitorMapper.getKuaiShouGroupMessage(array,startDate,endDate);
+    }
+    /**
+     * 查询快手组新上和有效数量
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate) {
+        return newMonitorMapper.getKuaiShouGroupSum(array,startDate,endDate);
+    }
+    /**
+     * 查询快手组时间轴数据
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public List<JSONObject> getKuaiShouGroupMessageGroup(JSONArray array, String startDate, String endDate) {
+        String group="0";
+        List<JSONObject> kuaiShouGroupMessageGroup=new ArrayList<>();
+        try {
+            if(DateUtils.isMoreSixMonth(startDate,endDate)){
+                group="1";
+            }
+            kuaiShouGroupMessageGroup= newMonitorMapper.getKuaiShouGroupMessageGroup(array, startDate, endDate, group);
+        }catch (Exception e){
+            log.info("查询数据错误:{}",e.toString());
+        }
+
+        return kuaiShouGroupMessageGroup;
+    }
+
+    @Override
+    public List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate, String target, String project) {
+        return newMonitorMapper.getPlanMessage(array,startDate,endDate,project);
+    }
+    /**
+     * 查询快手广告计划 新上和有效数量
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public JSONObject getPlanSum(JSONArray array, String startDate, String endDate, String project) {
+        return newMonitorMapper.getPlanSum(array,startDate,endDate,project);
+    }
+
+    @Override
+    public List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project) {
+        String group="0";
+        List<JSONObject> planGroupMessageGroup=new ArrayList<>();
+        try {
+            if(DateUtils.isMoreSixMonth(startDate,endDate)){
+                group="1";
+            }
+            planGroupMessageGroup= newMonitorMapper.getPlanMessageGroup(array, startDate, endDate, group,project);
+        }catch (Exception e){
+            log.info("查询数据错误:{}",e.toString());
+        }
+
+        return planGroupMessageGroup;
+    }
+}

+ 66 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceNewPlanReportCtrl.java

@@ -1,9 +1,13 @@
 package cn.com.ctop.toutiao.modules.report.controller;
 
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceNewPlanReportService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -11,6 +15,11 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -26,6 +35,9 @@ public class BytedanceNewPlanReportCtrl {
     @Autowired
     IBytedanceNewPlanReportService newPlanReportService;
 
+    @Autowired
+    NewMonitorService newMonitorService;
+
     /**
      * 新建计划、有效计划 chart数据
      */
@@ -54,6 +66,10 @@ public class BytedanceNewPlanReportCtrl {
             JSONObject sumData = newPlanReportService.getSumNewPlanBy(accountIds, startDate, endDate);
             List<JSONObject> chartData = newPlanReportService.getBytedanceNewPlanGroupByStatDate(accountIds, startDate, endDate);
             List<JSONObject> listData = newPlanReportService.getBytedanceNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
+
+          /*  JSONObject sumData = newMonitorService.getPlanSum(accountIds, startDate, endDate, "0");
+            List<JSONObject> chartData = newMonitorService.getPlanMessageGroup(accountIds, startDate, endDate, "0");
+            List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "0");*/
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -66,6 +82,56 @@ public class BytedanceNewPlanReportCtrl {
         return resultBody;
     }
 
+    @PostMapping("/report/excel")
+    public void getExcelReport(@RequestBody JSONObject requestBody,
+                               HttpServletRequest request,
+                               HttpServletResponse response) {
+
+        JSONArray accountIds = requestBody.getJSONArray("accountIds");
+        String userId = requestBody.getString("userId");
+        //TODO 没有维护快手事业部负责人角色,增加判断
+        if ("6b4c821adc414dc8b7718ab63ccbfcaf".equals(userId)) {
+            accountIds = newPlanReportService.getAccountIdsByMedia();
+        } else {
+            if (!userId.isEmpty()) {
+                accountIds = newPlanReportService.getAccountIdsByUserId(userId);
+            }
+            if (accountIds.isEmpty()) {
+                return;
+            }
+        }
+        String startDate = requestBody.getString("startDate");
+        String endDate = requestBody.getString("endDate");
+        String target = requestBody.getString("target");
+        String order = requestBody.getString("order");
+        List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "0");
+
+        List<List<Object>> excelList = new ArrayList<>();
+        listData.forEach(data -> {
+            List<Object> temp = new ArrayList<>();
+            temp.add(data.getString("authName"));
+            temp.add(data.getLong("accountId"));
+            temp.add(data.getString("userName"));
+            temp.add(data.getLong("new"));
+            temp.add(data.getLong("valid"));
+            temp.add(data.getString("maxCreateTime"));
+            excelList.add(temp);
+        });
+        try {
+            String[] headers = {"账户名称", "账户ID", "账户所属人", "新上计划数", "有效计划数", "最近上新时间"};
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            eeu.exportExcel(workbook, 0, "头条新上计划数", headers, excelList);
+            HttpUtils.setResponseHeader(response, "头条新上计划数.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+
     /**
      * 查询素材报表表格数据
      */

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml

@@ -75,7 +75,7 @@
                sum(show_num)                          showNum,
                sum(click)                             click,
                CASE
-                   WHEN sum(click)>=0 and um(show_num)>0 THEN CONCAT(ROUND(sum(click) / sum(show_num) * 100,2) ,'%')
+                   WHEN sum(click)>=0 and sum(show_num)>0 THEN CONCAT(ROUND(sum(click) / sum(show_num) * 100,2) ,'%')
                    else '0%' end AS   'clickRate',
                CASE
                    WHEN (sum(cost) / sum(show_num)) IS NULL THEN

+ 10 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceHomepageReportServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceHomepageMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceHomepageReportService;
 import cn.com.ctop.toutiao.modules.report.utils.LinkUtils;
@@ -32,12 +33,21 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
         //本周汇总数据
         JSONObject weekSumData = bytedanceHomepageMapper.querySumByStartEndDate(nowDate,
                 DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, nowDate, -7));
+        if(Check.isNull(weekSumData)){
+            return result;
+        }
         //上周汇总数据
         JSONObject weekBeforeSumData = bytedanceHomepageMapper.querySumByStartEndDate(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, nowDate, -7),
                 DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, nowDate, -14));
+        if(Check.isNull(weekBeforeSumData)){
+            return result;
+        }
         //一周内每日数据汇总
         List<JSONObject> weekDetailData = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
                 DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, nowDate, -7));
+        if(Check.isNull(weekDetailData)){
+            return result;
+        }
         //一周内cost top数据
         List<JSONObject> costTop = bytedanceHomepageMapper.queryTopCost(nowDate, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, nowDate, -7), 7);
         JSONObject top = new JSONObject();

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

@@ -234,6 +234,12 @@ public class ProjectController {
         if (!Check.isNull(projectName)) {
             queryWrapper.like("project_name", projectName);
         }
+
+        //媒体类型 1、3 头条   2、4 快手
+        if (!Check.isNull(project.getMediaId())){
+            queryWrapper.in("media_id",Arrays.asList(project.getMediaId().split(",")));
+        }
+
         queryWrapper.orderByDesc("create_time");
         IPage<Project> pageList = projectService.page(page, queryWrapper);
         List<Project> records = pageList.getRecords();

+ 111 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
@@ -1629,4 +1630,114 @@ public class SysUserController {
         return result;
     }
 
+
+
+    /**
+     * 获取用户列表数据
+     *
+     * @param user
+     * @param pageNo
+     * @param pageSize
+     * @param
+     * @return
+     */
+    @ApiOperation(value="用户管理(运营)", notes="用户管理(运营)")
+    @RequestMapping(value = "/listV2", method = RequestMethod.GET)
+    public Result<Object> queryPageListV2(SysUser user, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+
+            String userId = user.getId();
+            String roleCode = roleService.getRoleCodeByUserId(userId);
+            if (Check.isNull(roleCode)){
+                return Result.errorMsg("请输入正确的用户id。");
+            }
+            //角色为 管理员并且projectId是空表示:全量查询
+
+            if (!"admin".equals(roleCode)) {
+                List<SysUser> list = sysUserService.queryPageList(user);
+                //1.根据搜索框过滤数据
+                if(!Check.isNull(user.getUsername())){
+                    Iterator<SysUser> it = list.iterator();
+                    while(it.hasNext()){
+                        if(!it.next().getUsername().contains(user.getUsername())) {
+                            it.remove();
+                        }
+                    }
+                }
+                if(!Check.isNull(user.getRealname())){
+                    Iterator<SysUser> it = list.iterator();
+                    while(it.hasNext()){
+                        if(!it.next().getRealname().contains(user.getRealname())) {
+                            it.remove();
+                        }
+                    }
+                }
+                if(!Check.isNull(user.getLeaderName())){
+                    Iterator<SysUser> it = list.iterator();
+                    while(it.hasNext()){
+                        if(!it.next().getLeaderName().contains(user.getLeaderName())) {
+                            it.remove();
+                        }
+                    }
+                }
+                if(!Check.isNull(user.getRoleName())){
+                    Iterator<SysUser> it = list.iterator();
+                    while(it.hasNext()){
+                        if(!it.next().getRoleName().contains(user.getRoleName())) {
+                            it.remove();
+                        }
+                    }
+                }
+                if(!Check.isNull(user.getDepartId())){
+                    Iterator<SysUser> it = list.iterator();
+                    while(it.hasNext()){
+                        SysUser user2 = it.next();
+                        if(Check.isNull(user2.getDepartId2()) || !user2.getDepartId2().equals(user.getDepartId())) {
+                            it.remove();
+                        }
+                    }
+                }
+                if(!Check.isNull(user.getEmail())){
+                    Iterator<SysUser> it = list.iterator();
+                    while(it.hasNext()){
+                        if(!it.next().getEmail().contains(user.getEmail())) {
+                            it.remove();
+                        }
+                    }
+                }
+                if(!Check.isNull(user.getStatus())){
+                    Iterator<SysUser> it = list.iterator();
+                    while(it.hasNext()){
+                        if(!it.next().getStatus().equals(user.getStatus())) {
+                            it.remove();
+                        }
+                    }
+                }
+                //2.根据分页页数和条数来筛选数据
+                int total = list.size();
+                int beginIndex = (pageNo - 1) * pageSize + 1;
+                int endIndex = beginIndex + pageSize;
+                if(list.size() > beginIndex){
+                    list = list.subList(beginIndex-1,list.size() > endIndex ? endIndex : list.size());
+                }
+
+                PageInfo<SysUser> pageInfo = new PageInfo<>(list);
+                pageInfo.setTotal(total);
+                return Result.ok(pageInfo);
+            }else{
+                user.setId(null);
+                PageHelper.startPage(pageNo, pageSize);
+                List<SysUser> list = sysUserService.queryAdminPageList(user);
+                PageInfo<SysUser> pageInfo = new PageInfo<>(list);
+                return Result.ok(pageInfo);
+            }
+
+
+        } catch (Exception e) {
+            log.error("获取用户列表数据-分页列表查询异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
 }