Переглянути джерело

Merge remote-tracking branch 'origin/master'

yumeng 4 роки тому
батько
коміт
b2940a8dd4
37 змінених файлів з 1298 додано та 53 видалено
  1. 3 0
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/entity/SysUser.java
  2. 2 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/JeecgBootFinanceApplication.java
  3. 72 13
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java
  4. 11 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyInfoMapper.java
  5. 78 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml
  6. 10 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsPolicyInfoService.java
  7. 51 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyInfoServiceImpl.java
  8. 53 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementController.java
  9. 10 3
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java
  10. 2 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementInfo.java
  11. 8 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java
  12. 9 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementInfoMapper.java
  13. 89 5
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml
  14. 25 3
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementInfoMapper.xml
  15. 5 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/ISettlementInfoService.java
  16. 54 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java
  17. 20 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementInfoServiceImpl.java
  18. 19 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java
  19. 5 0
      jeecg-boot-finance/src/main/resources/application-dev.yml
  20. 5 0
      jeecg-boot-finance/src/main/resources/application-prod.yml
  21. 5 0
      jeecg-boot-finance/src/main/resources/application-test.yml
  22. 0 5
      jeecg-boot-finance/src/main/resources/application.yml
  23. 2 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/ISysUserService.java
  24. 5 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/SysUserServiceImpl.java
  25. 21 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserCompanyServiceImpl.java
  26. 11 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java
  27. 11 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewPlanReportCtrl.java
  28. 35 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/NewMonitorController.java
  29. 49 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java
  30. 164 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml
  31. 23 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java
  32. 242 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java
  33. 71 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceNewPlanReportCtrl.java
  34. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml
  35. 10 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceHomepageReportServiceImpl.java
  36. 6 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  37. 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;
 }

+ 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

+ 5 - 0
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

+ 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");

+ 11 - 4
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数据
      */
@@ -64,9 +68,12 @@ public class KsNewGroupReportCtrl {
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
-            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);
+            //JSONObject sumData = newGroupReportService.getSumNewGroupBy(accountIds, startDate, endDate);
+            JSONObject sumData = newMonitorService.getKuaiShouGroupSum(accountIds, startDate, endDate);
+            //List<JSONObject> chartData = newGroupReportService.getKsNewGroupGroupByStatDate(accountIds, startDate, endDate);
+            List<JSONObject> chartData = newMonitorService.getKuaiShouGroupMessageGroup(accountIds, startDate, endDate);
+            //List<JSONObject> listData = newGroupReportService.getKsNewGroupGroupByAccount(accountIds, startDate, endDate, target, order);
+            List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -123,7 +130,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 -> {

+ 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 -> {

+ 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);
+    }
+}

+ 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);
+}

+ 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>

+ 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);
+}

+ 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;
+    }
+}

+ 71 - 3
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数据
      */
@@ -51,9 +63,15 @@ public class BytedanceNewPlanReportCtrl {
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
-            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 = 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 +84,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("查询失败");
+    }
+
 }