瀏覽代碼

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

xuzuoyun 5 年之前
父節點
當前提交
9e67470481
共有 47 個文件被更改,包括 1948 次插入800 次删除
  1. 208 1
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 10 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  4. 152 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ImageDownloadController.java
  5. 0 248
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MailLogController.java
  6. 42 10
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  7. 8 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/EffiVideoJob.java
  8. 59 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountWarningLoadJob.java
  9. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java
  10. 4 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java
  11. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml
  12. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java
  13. 5 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  14. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  15. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysRoleMapper.xml
  16. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IPerformanceService2.java
  17. 482 434
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/PerformanceServiceImpl2.java
  18. 6 17
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  19. 6 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/MailLog.java
  20. 13 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java
  21. 4 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MailLogMapper.java
  22. 3 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MailLogMapper.xml
  23. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMailLogService.java
  24. 4 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MailLogServiceImpl.java
  25. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IAccountWarningService.java
  26. 174 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java
  27. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  28. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportHourlyAccountMapper.java
  29. 20 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportHourlyAccountMapper.xml
  30. 26 6
      module-report/src/main/java/cn/com/ctop/bytedance/controller/AccountReportController.java
  31. 52 12
      module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java
  32. 50 14
      module-report/src/main/java/cn/com/ctop/bytedance/controller/MaterialReportController.java
  33. 19 1
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml
  34. 35 7
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/AccountReportServiceImpl.java
  35. 6 6
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java
  36. 8 8
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/MaterialReportServiceImpl.java
  37. 9 9
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  38. 243 0
      performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/controller/PlaneProjectCostController.java
  39. 69 0
      performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/entity/PlaneProjectCost.java
  40. 17 0
      performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/mapper/PlaneProjectCostMapper.java
  41. 5 0
      performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/mapper/xml/PlaneProjectCostMapper.xml
  42. 14 0
      performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/service/IPlaneProjectCostService.java
  43. 19 0
      performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/service/impl/PlaneProjectCostServiceImpl.java
  44. 25 0
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/UserDto2.java
  45. 8 0
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/UserEfficientVideoMap.java
  46. 14 6
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java
  47. 86 0
      performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

+ 208 - 1
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -911,7 +911,7 @@ public class DateUtils extends PropertyEditorSupport {
         Calendar cal = Calendar.getInstance();
         cal.setTime(date);
         //获取当前月份
-        int month = cal.get(Calendar.MONDAY) + 1;
+        int month = cal.get(Calendar.MONTH) + 1;
         if(month<=3){
             return 1;
         }else if(month <=6){
@@ -925,5 +925,212 @@ public class DateUtils extends PropertyEditorSupport {
         return 0;
     }
 
+    /**
+     * 获取【所在周】周五的时间(周五为一周第一天,周四为一周最后一天)
+     * @param date
+     */
+    public static Date getFriday(Date date){
+        Calendar calendar = new GregorianCalendar();
+        calendar.setTime(date);
+        calendar.setFirstDayOfWeek(Calendar.FRIDAY);
+        calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+        System.out.println(df.format(calendar.getTime()));
+        return calendar.getTime();
+    }
+
+    /**
+     * 获取传入时间的年、月份和季度(周五为每周第一天,周四为每周最后一天)
+     * 获取的是所属年、月、季度,因为很多月份的第一周或最后 一周会包括上一个月或者下一个月的部分日期
+     */
+    public static Map<String,Integer> getYearQuarter(Date date){
+        Map<String,Integer> dateMap = new HashMap<>();
+
+        Calendar calendar = new GregorianCalendar();
+        calendar.setTime(date);
+        int originYear = calendar.get(Calendar.YEAR);
+        int originMonth = calendar.get(Calendar.MONTH);
+        int originQuarter = DateUtils.getQuarter(date); //本月所在季度(按照日期来的)
+
+        Calendar calendar1 = new GregorianCalendar();
+        calendar1.setTime(date);
+        calendar1.setFirstDayOfWeek(Calendar.FRIDAY);
+        //1.判断当天所在周第一天是否跨月
+        calendar1.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
+        int fridayYear = calendar1.get(Calendar.YEAR);
+        int fridayMonth = calendar1.get(Calendar.MONTH);
+        int fridayQuarter = DateUtils.getQuarter(calendar1.getTime());
+
+        //2.判断当天所在周的最后一天是否跨月
+        Calendar calendar2 = new GregorianCalendar();
+        calendar2.setTime(date);
+        calendar2.setFirstDayOfWeek(Calendar.FRIDAY);
+        calendar2.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
+        int thursdayYear = calendar2.get(Calendar.YEAR);
+        int thursdayMonth = calendar2.get(Calendar.MONTH);
+        int thursdayQuarter = DateUtils.getQuarter(calendar2.getTime());
+
+        //如果本周第一天(周五)和当前天不在一个月内,说明周跨月了
+        if(fridayMonth == originMonth && thursdayMonth == originMonth){
+            dateMap.put("year", originYear);
+            dateMap.put("month", originMonth + 1);  //最后一个月是11,应该+1
+            dateMap.put("quarter", originQuarter);
+            return dateMap;
+        }else if(fridayYear < originYear || (fridayYear ==originYear && fridayMonth < originMonth) ){
+            //判断本周有几天在本月,如果是(5,6,7)则就是本月本季度
+            //int lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+            calendar1.set(Calendar.DATE, calendar1.getActualMaximum(Calendar.DATE));
+            int lastDateWeek = calendar1.get(Calendar.DAY_OF_WEEK);
+            //判断如果本周所在上个月的最后一天是周五、周六、周日的话,说明本周归属于本月(周五是第一天);否则本周归属于上个季度
+            if(lastDateWeek ==6 || lastDateWeek ==7 || lastDateWeek ==1 ){
+                dateMap.put("year", originYear);
+                dateMap.put("month", originMonth + 1);
+                dateMap.put("quarter",originQuarter);
+            }else{
+                //判断如果本周属于上个月,判断是否跨年
+                if(originYear == fridayYear){
+                    dateMap.put("year", originYear);
+                    dateMap.put("month", originMonth);
+                    //判断是否跨季
+                    if(originQuarter == fridayQuarter){
+                        dateMap.put("quarter",originQuarter);
+                    }else{
+                        dateMap.put("quarter",fridayQuarter);
+                    }
+                }else{
+                    //跨年的话说明这周上年的12月(第四季度)
+                    dateMap.put("year", originYear-1);
+                    dateMap.put("month", 12); //??查看是11,还是12
+                    dateMap.put("quarter",4);
+                }
+            }
+            return dateMap;
+        }else if(originYear < thursdayYear || (originYear == thursdayYear && originMonth < thursdayMonth) ){
+            calendar2.set(Calendar.DATE, 1);
+            int firstDateWeek = calendar2.get(Calendar.DAY_OF_WEEK);
+            //如果跨月的第一天是周二周三周四的话说明这周不跨月,否在进入下个月(季度、年需要再判断)
+            if( firstDateWeek==3 || firstDateWeek==4 || firstDateWeek==5){
+                dateMap.put("year", originYear);
+                dateMap.put("month", originMonth+1);
+                dateMap.put("quarter",originQuarter);
+            }else{
+                if( originYear == thursdayYear ){
+                    dateMap.put("year", originYear);
+                    dateMap.put("month", originMonth + 1 + 1);
+                    //判断是否跨季
+                    if(originQuarter == thursdayQuarter){
+                        dateMap.put("quarter",originQuarter);
+                    }else{
+                        dateMap.put("quarter",thursdayQuarter);
+                    }
+                }else{
+                    //跨年的话说明这周属于明年的1月(第一季度)
+                    dateMap.put("year", originYear+1);
+                    dateMap.put("month", 1);
+                    dateMap.put("quarter",1);
+                }
+            }
+            return dateMap;
+        }
+        return dateMap;
+    }
+
+    /**
+     * 计算季度开始、结束时间
+     * 原则:周五为本周的第一天,下一周的周四为本周的最后一天
+     * @param year
+     * @param quarter
+     */
+    public static Map<String,String> quarterStartEndDate(int year, int quarter){
+        Map<String,String> quarterStartEndDateMap = new HashMap<>();
+
+        Date startDate = null;
+        Date endDate = null;
+
+        int startMonth = 0;
+        int endMonth = 0;
+
+        if(quarter == 1){
+            startMonth = 1;
+            endMonth = 3;
+        }else if(quarter == 2){
+            startMonth = 4;
+            endMonth = 6;
+        }else if(quarter == 3){
+            startMonth = 7;
+            endMonth = 9;
+        }else{
+            startMonth = 10;
+            endMonth = 12;
+        }
+
+        //判断季度第一天的时间(以周为单位,有可能是上个月,也有可能是本月的非1号)
+        Calendar calendar1 = new GregorianCalendar();
+        calendar1.set(Calendar.YEAR,year);
+        calendar1.set(Calendar.MONTH,startMonth-1);
+        calendar1.set(Calendar.DATE,1);
+        calendar1.setFirstDayOfWeek(Calendar.FRIDAY);
+
+        //如果季度第一个月的第一天是周二周三周四,那么这周应该归属于上个季度,否则这周(包括上个月的时间)归属于这个季度
+        int firstDateWeek = calendar1.get(Calendar.DAY_OF_WEEK);
+        if(firstDateWeek ==5 || firstDateWeek ==3 || firstDateWeek ==4 ){
+            calendar1.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
+            startDate = DateUtils.addDay(calendar1.getTime(),1);
+        }else{
+            calendar1.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
+            startDate = calendar1.getTime();
+        }
+
+        //判断季度最后一天的时间(以周为单位,有可能是下个月,也有可能是本月的非最后一天)
+        Calendar calendar2 = new GregorianCalendar();
+        calendar2.set(Calendar.YEAR,year);
+        calendar2.set(Calendar.MONTH,endMonth-1);
+        calendar2.set(Calendar.DATE,1);
+        calendar2.setFirstDayOfWeek(Calendar.FRIDAY);
+
+        //如果一个季度最后一个月最后一天是周五、周六、周日,则这个月最后一周属于下个季度
+        calendar2.set(Calendar.DATE, calendar2.getActualMaximum(Calendar.DATE));
+        int lastDateWeek = calendar2.get(Calendar.DAY_OF_WEEK);
+        if(lastDateWeek ==1 || lastDateWeek ==7 || lastDateWeek ==6){
+            calendar2.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
+            endDate = DateUtils.addDay(calendar2.getTime(),-1);
+        }else{
+            calendar2.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
+            endDate = calendar2.getTime();
+        }
+
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        quarterStartEndDateMap.put("startDate", sdf.format(startDate));
+        quarterStartEndDateMap.put("endDate", sdf.format(endDate));
+        return quarterStartEndDateMap;
+    }
+
+    public static void main(String[] args) throws ParseException {
+        //SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+        //Date friDay = DateUtils.getFriday(new Date());
+        //Date effiCalcStart = DateUtils.addDay(friDay,  -14);
+        //System.out.println(sdf.format(effiCalcStart));
+        //Date effiCalcEnd = DateUtils.addDay(friDay,  -1);
+        //System.out.println(sdf.format(effiCalcEnd));
+        //
+        //Date effiEnd = DateUtils.addDay(friDay,  -21);
+        //System.out.println(sdf.format(effiEnd));
+        //Date effiStart = DateUtils.addDay(friDay,  -15);
+        //System.out.println(sdf.format(effiStart));
+
+        Map<String,Integer> map1 = DateUtils.getYearQuarter(DateUtils.parseDate("2020-04-01","yyyy-MM-dd"));
+
+        Map<String,String> map2 = DateUtils.quarterStartEndDate(2019,1);
+
+        for(String key:map2.keySet()){
+            System.out.println(key + ":" + map2.get(key));
+        }
+
+
+
+    }
 
 }
+
+
+

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -137,6 +137,7 @@ public class ShiroConfig {
 		filterChainDefinitionMap.put("/report/kuaishouReportDailyAgent/get","anon");
 
 		filterChainDefinitionMap.put("/appium/appiumTask/run/login", "anon");
+		filterChainDefinitionMap.put("/zip/download", "anon");
 		//爬虫接口
 		filterChainDefinitionMap.put("/graphql/video", "anon");
 		filterChainDefinitionMap.put("/ks/web/test", "anon");

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

@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -152,6 +153,8 @@ public class CallbackController {
                     //创建人
                     String userId = json.getString("userId");
                     Long projectId = json.getLong("projectId");
+                    BigDecimal WarningProportion = json.getBigDecimal("WarningProportion");
+                    BigDecimal WarningAmount = json.getBigDecimal("WarningAmount");
 
                     CtopOauthToken topOauthToken = new CtopOauthToken();
                     topOauthToken.setId(String.valueOf(accountId));
@@ -195,6 +198,9 @@ public class CallbackController {
                     userAllocation.setAccountId(accountId);
                     userAllocation.setProjectId(projectId);
                     userAllocation.setProjectName(projectName);
+                    userAllocation.setWarningProportion(WarningProportion);
+                    userAllocation.setWarningAmount(WarningAmount);
+
                     userAllocation.setCreateTime(new Date());
                     userAllocation.setUpdateTime(new Date());
                     allocationMapper.deleteById(userAllocation.getId());
@@ -281,6 +287,8 @@ public class CallbackController {
             String userName = json.getString("userName");
             Long projectId = json.getLong("projectId");
             String projectName = json.getString("projectName");
+            BigDecimal WarningProportion = json.getBigDecimal("WarningProportion");
+            BigDecimal WarningAmount = json.getBigDecimal("WarningAmount");
 
             JSONObject data = resultObject.getJSONObject("data");
             CtopOauthToken token = new CtopOauthToken(advertiserId, data);
@@ -315,6 +323,8 @@ public class CallbackController {
             userAllocation.setProjectName(projectName);
             userAllocation.setAuthName((String) advertiserDataMap.get("name"));
             userAllocation.setAdvertiserId(advertiserId);
+            userAllocation.setWarningProportion(WarningProportion);
+            userAllocation.setWarningAmount(WarningAmount);
             userAllocation.setCreateTime(new Date());
             userAllocation.setUpdateTime(new Date());
             allocationMapper.deleteById(userAllocation.getId());

文件差異過大導致無法顯示
+ 152 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ImageDownloadController.java


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

@@ -1,248 +0,0 @@
-package org.jeecg.modules.ctop.controller;
-
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.aspect.annotation.AutoLog;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.ctop.entity.MailLog;
-import org.jeecg.modules.ctop.service.IMailLogService;
-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 javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 邮箱记录表
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2019-12-08
- */
-@Slf4j
-@Api(tags = "邮箱记录表")
-@RestController
-@RequestMapping("/top/mailLog")
-public class MailLogController {
-    @Autowired
-    private IMailLogService mailLogService;
-
-    /**
-     * 分页列表查询
-     *
-     * @param mailLog
-     * @param pageNo
-     * @param pageSize
-     * @param req
-     * @return
-     */
-    @AutoLog(value = "邮箱记录表-分页列表查询")
-    @ApiOperation(value = "邮箱记录表-分页列表查询", notes = "邮箱记录表-分页列表查询")
-    @GetMapping(value = "/list")
-    public Result<IPage<MailLog>> queryPageList(MailLog mailLog,
-                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                HttpServletRequest req) {
-        Result<IPage<MailLog>> result = new Result<IPage<MailLog>>();
-        QueryWrapper<MailLog> queryWrapper = QueryGenerator.initQueryWrapper(mailLog, req.getParameterMap());
-        Page<MailLog> page = new Page<MailLog>(pageNo, pageSize);
-        IPage<MailLog> pageList = mailLogService.page(page, queryWrapper);
-        result.setSuccess(true);
-        result.setResult(pageList);
-        return result;
-    }
-
-    /**
-     * 添加
-     *
-     * @param mailLog
-     * @return
-     */
-    @AutoLog(value = "邮箱记录表-添加")
-    @ApiOperation(value = "邮箱记录表-添加", notes = "邮箱记录表-添加")
-    @PostMapping(value = "/add")
-    public Result<MailLog> add(@RequestBody MailLog mailLog) {
-        Result<MailLog> result = new Result<MailLog>();
-        try {
-            mailLogService.save(mailLog);
-            result.success("添加成功!");
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            result.error500("操作失败");
-        }
-        return result;
-    }
-
-    /**
-     * 编辑
-     *
-     * @param mailLog
-     * @return
-     */
-    @AutoLog(value = "邮箱记录表-编辑")
-    @ApiOperation(value = "邮箱记录表-编辑", notes = "邮箱记录表-编辑")
-    @PutMapping(value = "/edit")
-    public Result<MailLog> edit(@RequestBody MailLog mailLog) {
-        Result<MailLog> result = new Result<MailLog>();
-        MailLog mailLogEntity = mailLogService.getById(mailLog.getId());
-        if (mailLogEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            boolean ok = mailLogService.updateById(mailLog);
-            if (ok) {
-                result.success("修改成功!");
-            }
-        }
-
-        return result;
-    }
-
-    /**
-     * 通过id删除
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "邮箱记录表-通过id删除")
-    @ApiOperation(value = "邮箱记录表-通过id删除", notes = "邮箱记录表-通过id删除")
-    @DeleteMapping(value = "/delete")
-    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
-        try {
-            mailLogService.removeById(id);
-        } catch (Exception e) {
-            log.error("删除失败", e.getMessage());
-            return Result.error("删除失败!");
-        }
-        return Result.ok("删除成功!");
-    }
-
-    /**
-     * 批量删除
-     *
-     * @param ids
-     * @return
-     */
-    @AutoLog(value = "邮箱记录表-批量删除")
-    @ApiOperation(value = "邮箱记录表-批量删除", notes = "邮箱记录表-批量删除")
-    @DeleteMapping(value = "/deleteBatch")
-    public Result<MailLog> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        Result<MailLog> result = new Result<MailLog>();
-        if (ids == null || "".equals(ids.trim())) {
-            result.error500("参数不识别!");
-        } else {
-            this.mailLogService.removeByIds(Arrays.asList(ids.split(",")));
-            result.success("删除成功!");
-        }
-        return result;
-    }
-
-    /**
-     * 通过id查询
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "邮箱记录表-通过id查询")
-    @ApiOperation(value = "邮箱记录表-通过id查询", notes = "邮箱记录表-通过id查询")
-    @GetMapping(value = "/queryById")
-    public Result<MailLog> queryById(@RequestParam(name = "id", required = true) String id) {
-        Result<MailLog> result = new Result<MailLog>();
-        MailLog mailLog = mailLogService.getById(id);
-        if (mailLog == null) {
-            result.error500("未找到对应实体");
-        } else {
-            result.setResult(mailLog);
-            result.setSuccess(true);
-        }
-        return result;
-    }
-
-    /**
-     * 导出excel
-     *
-     * @param request
-     * @param response
-     */
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
-        // Step.1 组装查询条件
-        QueryWrapper<MailLog> queryWrapper = null;
-        try {
-            String paramsStr = request.getParameter("paramsStr");
-            if (oConvertUtils.isNotEmpty(paramsStr)) {
-                String deString = URLDecoder.decode(paramsStr, "UTF-8");
-                MailLog mailLog = JSON.parseObject(deString, MailLog.class);
-                queryWrapper = QueryGenerator.initQueryWrapper(mailLog, request.getParameterMap());
-            }
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-
-        //Step.2 AutoPoi 导出Excel
-        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
-        List<MailLog> pageList = mailLogService.list(queryWrapper);
-        //导出文件名称
-        mv.addObject(NormalExcelConstants.FILE_NAME, "邮箱记录表列表");
-        mv.addObject(NormalExcelConstants.CLASS, MailLog.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<MailLog> listMailLogs = ExcelImportUtil.importExcel(file.getInputStream(), MailLog.class, params);
-                mailLogService.saveBatch(listMailLogs);
-                return Result.ok("文件导入成功!数据行数:" + listMailLogs.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("文件导入失败!");
-    }
-
-}

+ 42 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -4,6 +4,7 @@ package org.jeecg.modules.ctop.controller;
 import cn.com.ctop.common.module.entity.MaterialInfo;
 import cn.com.ctop.common.module.service.IMaterialInfoService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -20,6 +21,7 @@ import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -89,6 +91,9 @@ public class MaterialInfoController {
      * @param req
      * @return
      */
+    @Autowired
+    private IProjectMemberService memberService;
+
     @AutoLog(value = "素材信息-分页列表查询")
     @ApiOperation(value = "素材信息-分页列表查询", notes = "素材信息-分页列表查询")
     @GetMapping(value = "/list")
@@ -98,24 +103,43 @@ public class MaterialInfoController {
                                                      HttpServletRequest req) {
 
         Result<IPage<MaterialInfo>> result = new Result<>();
+        QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
         Object createTime = materialInfo.getCreateTime();
         materialInfo.setCreateTime(null);
         if (!Check.isNull(materialInfo.getUserId())) {
             String roleCode = materialInfoService.getRoleCodeByUserId(materialInfo.getUserId());
-            if ("admin".equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode)) {
+            if ("admin".equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode)) {
                 materialInfo.setUserId(null);
+                queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
+            } else if ("designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode) || "plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode)) {
+                String userId = materialInfo.getUserId();
+                materialInfo.setUserId(null);
+                queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
+                if (Check.isNull(materialInfo.getProjectId())) {
+                    List<Long> projects = memberService.selectProjectsByUserId(userId);
+                    if (!Check.isNull(projects)) {
+                        queryWrapper.in("project_id", projects);
+                    } else {
+                        result.setSuccess(true);
+                        result.setResult(null);
+                        return result;
+                    }
+                }
+
+            } else {
+                queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
             }
-        }
-        QueryWrapper<MaterialInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
-        if (!Check.isNull(createTime)) {
-            try {
-                Map<String, Object> map = DateUtils.getStartEndTime(createTime.toString());
-                queryWrapper.ge("create_time", map.get("start"));
-                queryWrapper.lt("create_time", map.get("end"));
-            } catch (ParseException e) {
-                e.printStackTrace();
+            if (!Check.isNull(createTime)) {
+                try {
+                    Map<String, Object> map = DateUtils.getStartEndTime(createTime.toString());
+                    queryWrapper.ge("create_time", map.get("start"));
+                    queryWrapper.lt("create_time", map.get("end"));
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
             }
         }
+
         Page<MaterialInfo> page = new Page<>(pageNo, pageSize);
         IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
         result.setSuccess(true);
@@ -192,6 +216,14 @@ public class MaterialInfoController {
         if (materialInfoEntity == null) {
             result.error500("未找到对应实体");
         } else {
+            String url = materialInfo.getUrl();
+            if (!Check.isNull(url)) {
+                if (!url.contains(KuaishouInterfaceConstant.HTTPS_PREFIX)) {
+                    url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
+                }
+                materialInfo.setUrl(url);
+            }
+
             boolean ok = materialInfoService.updateById(materialInfo);
             if (ok) {
                 result.success("修改成功!");

+ 8 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/EffiVideoJob.java

@@ -1,12 +1,17 @@
 package org.jeecg.modules.ctop.job;
 
 
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.system.service.IPerformanceService2;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 public class EffiVideoJob implements Job {
     @Autowired
     private IPerformanceService2 performanceService;
@@ -19,7 +24,8 @@ public class EffiVideoJob implements Job {
      */
     @Override
     public void execute(JobExecutionContext jobExecutionContext) {
-        performanceService.efficientVideoTask(2);
-        performanceService.efficientVideoTask(1);
+        //有效视频定时任务,默认跑前一天的
+        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        performanceService.efficientVideoTask(sdf.format(DateUtils.addDay(new Date(), -1)));
     }
 }

+ 59 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountWarningLoadJob.java

@@ -0,0 +1,59 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IAccountWarningService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+import static org.jeecg.common.util.DateUtils.getAnotherDay;
+
+/**
+ * 获取广告主分时报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouHourlyAccountWarningLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IAccountWarningService accountWarningService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                log.info("开始时段消耗预警定时任务");
+                long l = System.currentTimeMillis();
+                try {
+                    List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                    if (null == tokens || tokens.size() <= 0) {
+                        log.info("定时获取头条数据异常:未获取到可用的token");
+                        return;
+                    }
+                    String statDate = DateUtils.getDate("yyyy-MM-dd");
+                    String anotherDay = getAnotherDay("yyyy-MM-dd", statDate, -1);
+
+                    for (CtopOauthToken token : tokens) {
+                        accountWarningService.accountWarning(token.getAccountId(), statDate, anotherDay);
+                    }
+                    log.info("开始时段消耗预警定时任务执行完毕,耗时:{} ms", System.currentTimeMillis() - l);
+
+                } catch (Exception e) {
+                    e.printStackTrace();
+
+                }
+            }
+        };
+        thread.start();
+    }
+}

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java

@@ -51,7 +51,7 @@ public class KuaishouHourlyCreativeReportLoadJob implements Job {
                     log.info("定时获取头条数据异常:为获取到可用的token");
                     return;
                 }
-                executorService = Executors.newFixedThreadPool(5);
+                executorService = Executors.newFixedThreadPool(3);
                 countDownLatch = new CountDownLatch(tokens.size());
                 Date finalGetDate = getDate;
                 tokens.forEach(token -> {

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java

@@ -1,8 +1,11 @@
 package org.jeecg.modules.ctop.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 
+import java.util.List;
+
 /**
  * 项目成员
  *
@@ -12,4 +15,5 @@ import org.jeecg.modules.ctop.entity.ProjectMember;
  */
 public interface ProjectMemberMapper extends BaseMapper<ProjectMember> {
 
+    List<Long> selectProjectsByUserId(@Param("userId") String userId);
 }

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml

@@ -2,4 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.ctop.mapper.ProjectMemberMapper">
 
+    <select id="selectProjectsByUserId" resultType="java.lang.Long">
+        select
+        DISTINCT(project_id)
+         from ctop_project_member
+        where user_id = #{userId}
+    </select>
+
 </mapper>

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java

@@ -5,6 +5,8 @@ import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.system.entity.SysUser;
 
+import java.util.List;
+
 /**
  * 项目成员
  *
@@ -15,4 +17,5 @@ import org.jeecg.modules.system.entity.SysUser;
 public interface IProjectMemberService extends IService<ProjectMember> {
     void addMember(SysUser sysUser, Project project);
 
+    List<Long> selectProjectsByUserId(String userId);
 }

+ 5 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java

@@ -1,6 +1,8 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.common.module.entity.MailLog;
 import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CorpWexinUtils;
@@ -10,9 +12,7 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.entity.MailLog;
 import org.jeecg.modules.ctop.entity.Project;
-import org.jeecg.modules.ctop.mapper.MailLogMapper;
 import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.service.IBidWarningService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -80,16 +80,15 @@ public class BidWarningServiceImpl implements IBidWarningService {
     private void sendMessage(Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
 
         String createTime = DateUtils.getNowDate("yyyy-MM-dd");
-        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime);
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime, 1);
         StringBuilder text = new StringBuilder();
 
-
         String s = "";
         for (int i = 0; i < unitWarning.size(); i++) {
             s += unitWarning.get(i) + "," + "<br/>";
 
         }
-        text.append("您的项目:").append(projectName + ",").append("<br/>")
+        text.append("项目出价预警").append("<br/>").append("您的项目:").append(projectName + ",").append("<br/>")
                 .append("授权名称为:" + authName + " 下的,").append("<br/>").append(s)
                 .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
         if (count < 3) {
@@ -99,6 +98,7 @@ public class BidWarningServiceImpl implements IBidWarningService {
                 SendMailUtil.sendMail(mailList, subject, text.toString());
                 MailLog mailLog = new MailLog();
                 mailLog.setAccountId(accountId);
+                mailLog.setMailType(1);
                 mailLog.setContent(text.toString());
                 mailLog.setSendEmil(JSON.toJSONString(mailList));
                 mailLog.setSubject(subject);

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -26,6 +27,8 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
 
     @Autowired
     private MaterialReportMapper materialReportMapper;
+    @Autowired
+    private ProjectMemberMapper memberMapper;
 
     @Override
     public void addMember(SysUser sysUser, Project project) {
@@ -44,4 +47,15 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
         }
         this.save(member);
     }
+
+    /**
+     * 查询所有项目
+     *
+     * @param userId
+     * @return
+     */
+    @Override
+    public List<Long> selectProjectsByUserId(String userId) {
+        return memberMapper.selectProjectsByUserId(userId);
+    }
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysRoleMapper.xml

@@ -8,7 +8,7 @@
 			a.id as userId,
 			a.realname,
 			c.id as roleId,
-			c.role_name
+			c.role_name as roleName
 		from
 		sys_user a
 		left join sys_user_role b on a.id = b.user_id

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IPerformanceService2.java

@@ -15,7 +15,7 @@ import java.util.Map;
  * @date 2019-12-10
  */
 public interface IPerformanceService2 extends IService<Performance> {
-    void efficientVideoTask(int days);
+    void efficientVideoTask(String calcDateStr);
 
     //平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效
     public Map<String,Object> getPerformanceInfo();

文件差異過大導致無法顯示
+ 482 - 434
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/PerformanceServiceImpl2.java


+ 6 - 17
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,12 +1,10 @@
 package org.jeecg;
 
-import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils2;
-import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IAccountWarningService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.jeecg.modules.ctop.service.IBidWarningService;
@@ -25,10 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
@@ -153,19 +148,13 @@ public class SampleTest {
     @Autowired
     private IBidWarningService bidWarningService;
 
+    @Autowired
+    private IAccountWarningService accountWarningService;
+
     @Test
     public void testMa() throws Exception {
-        //String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_advertiser_info");
-        String url = "https://ad.oceanengine.com/open_api/2/advertiser/public_info/";
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Content-Type", "application/json");
-        headers.put("Access-Token", "7827db33fe53348e935706250a991461e7cffda2");
-        TreeMap<String, Object> params = new TreeMap<>();
-        //TODO jsonArray
-        params.put("advertiser_ids", "[" + 111463131228L+ "]");
-        String result = HttpUtils.httpGetRequest(url, headers, params);
-        JSONObject jsonObject = JSONObject.parseObject(result);
-        System.err.println(jsonObject);
+       // accountWarningService.accountWarning(23212L);
+
     }
 
 

+ 6 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/MailLog.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.ctop.entity;
+package cn.com.ctop.common.module.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -56,6 +56,11 @@ public class MailLog {
     @Excel(name = "内容", width = 15)
     @ApiModelProperty(value = "内容")
     private String content;
+
+
+    private Integer mailType;
+    private Integer hour;
+
     /**
      * 创建时间
      */

+ 13 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java

@@ -12,6 +12,7 @@ import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -81,6 +82,18 @@ public class UserAllocation {
     @Excel(name = "输入账号  --登陆", width = 15)
     @ApiModelProperty(value = "输入账号  --登陆")
     private String accountName;
+
+
+    /**
+     * 预警 金额
+     */
+    private BigDecimal warningAmount;
+
+    /**
+     * 预警 比例
+     */
+    private BigDecimal warningProportion;
+
     /**
      * 创建时间
      */

+ 4 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MailLogMapper.java

@@ -1,8 +1,8 @@
-package org.jeecg.modules.ctop.mapper;
+package cn.com.ctop.common.module.mapper;
 
+import cn.com.ctop.common.module.entity.MailLog;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
-import org.jeecg.modules.ctop.entity.MailLog;
 
 import java.util.List;
 
@@ -15,9 +15,10 @@ import java.util.List;
  */
 public interface MailLogMapper extends BaseMapper<MailLog> {
 
-    Integer selectCountByAccountIdAndDate(@Param("accountId") Long accountId, @Param("createTime") String createTime);
+    Integer selectCountByAccountIdAndDate(@Param("accountId") Long accountId, @Param("createTime") String createTime, @Param("type") Integer type);
 
     List<String> selectMailList(@Param("projectId") Long projectId);
 
     List<String> selectWeiXinIdList(@Param("projectId") Long projectId);
+
 }

+ 3 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MailLogMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.jeecg.modules.ctop.mapper.MailLogMapper">
+<mapper namespace="cn.com.ctop.common.module.mapper.MailLogMapper">
 
 
     <select id="selectCountByAccountIdAndDate" resultType="java.lang.Integer">
@@ -11,6 +11,7 @@
         ctop_mail_log
         where account_id = #{accountId}
         and DATE_FORMAT(create_time,'%Y-%m-%d') = #{createTime}
+        and mail_type = #{type}
 
 
     </select>
@@ -38,4 +39,5 @@
     </select>
 
 
+
 </mapper>

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMailLogService.java

@@ -1,7 +1,7 @@
-package org.jeecg.modules.ctop.service;
+package cn.com.ctop.common.module.service;
 
+import cn.com.ctop.common.module.entity.MailLog;
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.modules.ctop.entity.MailLog;
 
 /**
  * 邮箱记录表

+ 4 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MailLogServiceImpl.java

@@ -1,9 +1,9 @@
-package org.jeecg.modules.ctop.service.impl;
+package cn.com.ctop.common.module.service.impl;
 
+import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.service.IMailLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.ctop.entity.MailLog;
-import org.jeecg.modules.ctop.mapper.MailLogMapper;
-import org.jeecg.modules.ctop.service.IMailLogService;
 import org.springframework.stereotype.Service;
 
 /**

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

@@ -0,0 +1,5 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+public interface IAccountWarningService {
+    void accountWarning(Long account, String statDate, String anotherDay);
+}

+ 174 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java

@@ -0,0 +1,174 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.MailLog;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.common.module.utils.SendMailUtil;
+import cn.com.ctop.kuaishou.modules.batch.service.IAccountWarningService;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyAccountMapper;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.List;
+
+@Service
+public class AccountWarningServiceImpl implements IAccountWarningService {
+    @Autowired
+    private KuaishouReportHourlyAccountMapper hourlyAccountMapper;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+
+
+    /**
+     * 账户 出价预警
+     *
+     * @param accountId
+     */
+    @Override
+    public void accountWarning(Long accountId, String statDate, String anotherDay) {
+        try {
+
+
+            Integer maxHour = hourlyAccountMapper.selectMaxHour(accountId, statDate);
+            if (Check.isNull(maxHour)) {
+                return;
+            }
+
+            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+            userAllocationQueryWrapper.eq("account_id", accountId);
+            userAllocationQueryWrapper.eq("media_id", 2);
+            userAllocationQueryWrapper.orderByDesc("create_time");
+            userAllocationQueryWrapper.last("limit 1");
+            UserAllocation userAllocation = userAllocationMapper.selectOne(userAllocationQueryWrapper);
+            if (Check.isNull(userAllocation)) {
+                return;
+
+            }
+            BigDecimal warningAmount = userAllocation.getWarningAmount();
+            BigDecimal warningProportion = userAllocation.getWarningProportion();
+            BigDecimal nowCost = hourlyAccountMapper.getCost(accountId, maxHour, statDate);
+            if (maxHour != 0) {
+                if (!Check.isNull(nowCost) && nowCost.compareTo(new BigDecimal(0)) != 0) {
+                    BigDecimal lastHourCost = hourlyAccountMapper.getCost(accountId, maxHour - 1, statDate);
+                    if (!Check.isNull(lastHourCost) && lastHourCost.compareTo(new BigDecimal(0)) != 0) {
+                        if (!Check.isNull(userAllocation)) {
+                            BigDecimal subtract = nowCost.subtract(lastHourCost);
+                            BigDecimal divide = nowCost.divide(lastHourCost, 2, RoundingMode.HALF_UP);
+                            if (subtract.compareTo(warningAmount) > -1 && divide.compareTo(warningProportion) > -1) {
+                                sendMessage(accountId, userAllocation.getAuthName(), maxHour, nowCost, userAllocation.getProjectId());
+                            }
+                        }
+
+                    }
+
+                }
+            }
+
+
+            if (!Check.isNull(nowCost) && nowCost.compareTo(new BigDecimal(0)) != 0) {
+                BigDecimal yesterdayHourCost = hourlyAccountMapper.getCost(accountId, maxHour, anotherDay);
+                if (!Check.isNull(yesterdayHourCost) && yesterdayHourCost.compareTo(new BigDecimal(0)) != 0) {
+                    BigDecimal subtract = nowCost.subtract(yesterdayHourCost);
+                    BigDecimal divide = nowCost.divide(yesterdayHourCost, 2, RoundingMode.HALF_UP);
+                    if (subtract.compareTo(warningAmount) > -1 && divide.compareTo(warningProportion) > -1) {
+                        sendYesterdayMessage(accountId, userAllocation.getAuthName(), maxHour, nowCost, userAllocation.getProjectId());
+                    }
+                }
+
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    private void sendYesterdayMessage(Long accountId, String authName, Integer maxHour, BigDecimal nowCost, Long projectId) {
+
+        StringBuilder text = new StringBuilder();
+        text.append("较昨日同时段消耗预警").append("<br/>").append("您的账号:").append(accountId + ",").append("<br/>")
+                .append("授权名称为:" + authName + "相较于昨日").append(maxHour + "时").append("<br/>")
+                .append("出现消耗暴涨,").append("消耗金额为:" + nowCost).append("<br/>")
+                .append("请您及时查看!");
+
+
+        QueryWrapper<MailLog> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("hour", maxHour);
+        queryWrapper.eq("mail_type", 3);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        MailLog checkMailLog = mailLogMapper.selectOne(queryWrapper);
+        if (Check.isNull(checkMailLog)) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject = "较昨日同时段账户消耗预警";
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(3);
+                mailLog.setHour(maxHour);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+            CorpWexinUtils.sendMessage(wexinIds, text.toString());
+        }
+
+
+    }
+
+
+    private void sendMessage(Long accountId, String authName, Integer hour, BigDecimal amount, Long projectId) {
+
+        StringBuilder text = new StringBuilder();
+        text.append("较上时段消耗预警").append("<br/>").append("您的账号:").append(accountId + ",").append("<br/>")
+                .append("授权名称为:" + authName + ",").append(hour + " 时").append("相较于 " + (hour - 1) + " 时").append("<br/>")
+                .append("出现消耗暴涨,").append("消耗金额为:" + amount).append("<br/>")
+                .append("请您及时查看!");
+
+
+        QueryWrapper<MailLog> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("hour", hour);
+        queryWrapper.eq("mail_type", 2);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        MailLog checkMailLog = mailLogMapper.selectOne(queryWrapper);
+        if (Check.isNull(checkMailLog)) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject = "账户消耗预警";
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setMailType(2);
+                mailLog.setHour(hour);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+
+    }
+
+
+}

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

@@ -147,6 +147,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaishouReportHourlyAccount.setUpdateTime(new Date());
             hourlyAccountService.saveOrUpdate(kuaishouReportHourlyAccount);
         }
+
+
     }
 
     /**

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportHourlyAccountMapper.java

@@ -2,6 +2,12 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyAccount;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
 
 public interface KuaishouReportHourlyAccountMapper extends BaseMapper<KuaishouReportHourlyAccount> {
+    Integer selectMaxHour(@Param("accountId") Long accountId, @Param("statDate") String statDate);
+
+    BigDecimal getCost(@Param("accountId") Long accountId, @Param("statHour") Integer statHour, @Param("statDate") String statDate);
 }

+ 20 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportHourlyAccountMapper.xml

@@ -2,4 +2,24 @@
 <!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.KuaishouReportHourlyAccountMapper">
 
+    <select id="selectMaxHour" resultType="java.lang.Integer">
+        select max(stat_hour)
+        from
+        ctop_kuaishou_report_hourly_account
+        where account_id = #{accountId}
+        and stat_date = #{statDate}
+
+    </select>
+
+    <select id="getCost" resultType="java.math.BigDecimal">
+        select charge
+        from
+        ctop_kuaishou_report_hourly_account
+        where
+        account_id = #{accountId}
+        and stat_date = #{statDate}
+        and stat_hour = #{statHour}
+
+    </select>
+
 </mapper>

+ 26 - 6
module-report/src/main/java/cn/com/ctop/bytedance/controller/AccountReportController.java

@@ -56,17 +56,37 @@ public class AccountReportController {
     }
 
     @PostMapping("/getReportList")
-    public JSONObject getReportList(@RequestBody JSONObject json) {
-        JSONObject summaryJson = accountReportService.getSummaryReport(json);
-        return summaryJson;
+    public Result<JSONObject> getReportList(@RequestBody JSONObject json) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            JSONObject summaryJson = accountReportService.getSummaryReport(json);
+            result.setResult(summaryJson);
+            result.setSuccess(true);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
 
     }
 
 
     @PostMapping("/getStatistics")
-    public JSONObject getStatistics(@RequestBody JSONObject json) {
-        JSONObject statisticsJson = accountReportService.getStatistics(json);
-        return statisticsJson;
+    public Result<JSONObject> getStatistics(@RequestBody JSONObject json) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            JSONObject statisticsJson = accountReportService.getStatistics(json);
+            result.setResult(statisticsJson);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+
+        }
+
+        return result;
 
     }
 

+ 52 - 12
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java

@@ -3,6 +3,7 @@ package cn.com.ctop.bytedance.controller;
 import cn.com.ctop.bytedance.service.IBytedanceReportService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -24,32 +25,71 @@ public class BytedanceReportController {
      * @return
      */
     @RequestMapping(value = "/accountReport")
-    public JSONObject getAccountReport() {
-        JSONObject json = bytedanceReportService.getAccountReport("e9ca23d68d884d4ebb19d07889727dae");
-        return json;
+    public Result<JSONObject> getAccountReport() {
+        Result<JSONObject> result = new Result<>();
+
+        try {
+            JSONObject json = bytedanceReportService.getAccountReport("e9ca23d68d884d4ebb19d07889727dae");
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
     }
 
 
     @PostMapping("/kuaiShou/accountReport")
-    public JSONObject getKuaiShouAccountReport(@RequestBody JSONObject requestJson) {
-        JSONObject json = bytedanceReportService.getKuaiShouAccountReport(requestJson);
-        return json;
+    public Result<JSONObject> getKuaiShouAccountReport(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            JSONObject json = bytedanceReportService.getKuaiShouAccountReport(requestJson);
+            result.setResult(json);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
 
     }
 
 
     @PostMapping("/kuaiShou/accountDetailReport")
-    public List<JSONObject> getKuaiShouAccountDetailReport(@RequestBody JSONObject requestJson) {
-        List<JSONObject> kuaiShouAccounDetailtReport = bytedanceReportService.getKuaiShouAccounDetailtReport(requestJson);
-        return kuaiShouAccounDetailtReport;
+    public Result<List<JSONObject>> getKuaiShouAccountDetailReport(@RequestBody JSONObject requestJson) {
+
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            List<JSONObject> kuaiShouAccounDetailtReport = bytedanceReportService.getKuaiShouAccounDetailtReport(requestJson);
+            result.setResult(kuaiShouAccounDetailtReport);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
 
     }
 
 
     @PostMapping("/kuaiShou/getReportList")
-    public List<JSONObject> getReportList(@RequestBody JSONObject requestJson) {
-        List<JSONObject> kuaiShouAccounDetailtReport = bytedanceReportService.getReportList(requestJson);
-        return kuaiShouAccounDetailtReport;
+    public Result<List<JSONObject>> getReportList(@RequestBody JSONObject requestJson) {
+
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            List<JSONObject> kuaiShouAccounDetailtReport = bytedanceReportService.getReportList(requestJson);
+            result.setResult(kuaiShouAccounDetailtReport);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+
+        }
+        return result;
 
     }
 

+ 50 - 14
module-report/src/main/java/cn/com/ctop/bytedance/controller/MaterialReportController.java

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -23,36 +24,71 @@ public class MaterialReportController {
 
 
     @PostMapping(value = "/getKuaiShouMaterialMarket")
-    public List<JSONObject> getKuaiShouMaterialMarket(@RequestBody JSONObject json) {
-        List<JSONObject> marketJson = materialReportService.getKuaiShouMaterialMarket(json);
-        return marketJson;
+    public Result<List<JSONObject>> getKuaiShouMaterialMarket(@RequestBody JSONObject json) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            List<JSONObject> marketJson = materialReportService.getKuaiShouMaterialMarket(json);
+            result.setResult(marketJson);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
     }
 
 
     @PostMapping(value = "/getKuaiShouChainRatio")
-    public JSONObject getKuaiShouChainRatio(@RequestBody JSONObject json) {
-        JSONObject marketJson = materialReportService.getKuaiShouChainRatio(json);
-        return marketJson;
+    public Result<JSONObject> getKuaiShouChainRatio(@RequestBody JSONObject json) {
+
+        Result<JSONObject> result = new Result<>();
+        try {
+            JSONObject marketJson = materialReportService.getKuaiShouChainRatio(json);
+            result.setResult(marketJson);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
 
     }
 
 
     @PostMapping(value = "/getMaterialAccount")
-    public List<UserAllocation> getKuaiShouChainRatio(@RequestBody String userId) {
-        if (Check.isNull(userId)) {
-            return null;
+    public Result<List<UserAllocation>> getKuaiShouChainRatio(@RequestBody String userId) {
+        Result<List<UserAllocation>> result = new Result<>();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("用户id为空");
+            }
+            List<UserAllocation> accountIdList = materialReportService.selectAccountIds(userId);
+            result.setResult(accountIdList);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+
         }
-        List<UserAllocation> accountIdList = materialReportService.selectAccountIds(userId);
-        return accountIdList;
+        return result;
 
     }
 
 
     @PostMapping(value = "/getMaterialReportByAccount")
-    public List<JSONObject> getMaterialReportByAccount(@RequestBody JSONObject json) {
+    public Result<List<JSONObject>> getMaterialReportByAccount(@RequestBody JSONObject json) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            List<JSONObject> reportList = materialReportService.selectReportByAccountIds(json);
+            result.setResult(reportList);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            result.setSuccess(false);
+        }
 
-        List<JSONObject> reportList = materialReportService.selectReportByAccountIds(json);
-        return reportList;
+        return result;
 
     }
 

+ 19 - 1
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/AccountReportMapper.xml

@@ -18,7 +18,16 @@
         ((sum(charge) / sum(form_count)) / #{discount}) afterFormPrice, -- 表单提交单价
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
-        ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice -- 激活单价
+        ((sum(charge) / sum(activation)) / #{discount}) afterActivationPrice, -- 激活单价
+        sum(event_register) eventRegister, -- 注册数
+
+        (case
+        when sum(event_register) != 0
+        then (sum(charge) / sum(event_register))
+        else 0
+        end
+        ) eventRegisterCost -- 注册成本
+
         from
         ctop_kuaishou_report_hourly_account
         where stat_date = #{date}
@@ -105,6 +114,15 @@
         (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
         sum(activation) activationCount, -- 激活数
         (sum(charge) / sum(activation)) activationPrice, -- 激活单价
+        sum(event_register) eventRegister, -- 注册数
+
+        (case
+        when sum(event_register) != 0
+        then (sum(charge) / sum(event_register))
+        else 0
+        end
+        ) eventRegisterCost, -- 注册成本
+
         account_id accountId,
         (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
         from

+ 35 - 7
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/AccountReportServiceImpl.java

@@ -200,11 +200,11 @@ public class AccountReportServiceImpl implements IAccountReportService {
                 accountJson = accountReportMapper.selectDayReport(anotherDay, accountIds);
                 detail = accountReportMapper.selectReportDetail(anotherDay, accountIds);
             } else if (type == 3) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -6);
                 accountJson = accountReportMapper.selectByDate(anotherDay, endDate, accountIds);
                 detail = accountReportMapper.selectDayDetailByDate(anotherDay, endDate, accountIds);
             } else if (type == 4) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -14);
                 accountJson = accountReportMapper.selectByDate(anotherDay, endDate, accountIds);
                 detail = accountReportMapper.selectDayDetailByDate(anotherDay, endDate, accountIds);
             } else if (type == 5) {
@@ -480,7 +480,6 @@ public class AccountReportServiceImpl implements IAccountReportService {
                             chainRatioJson.put("beforeActivationPriceProportion", 0);
                         }
 
-
                         // 转化提交单价
                         BigDecimal nowAfterActivationPrice = nowAccountSummary.getBigDecimal("afterActivationPrice");
                         BigDecimal yesterdayAfterActivationPrice = yesterdayAccountSummary.getBigDecimal("afterActivationPrice");
@@ -495,8 +494,39 @@ public class AccountReportServiceImpl implements IAccountReportService {
                         } else {
                             chainRatioJson.put("afterActivationPriceProportion", 0);
                         }
+
+
+                        BigDecimal nowEventRegisterCost = nowAccountSummary.getBigDecimal("eventRegisterCost");  // 今日注册成本
+                        BigDecimal yesterdayEventRegisterCost = yesterdayAccountSummary.getBigDecimal("eventRegisterCost"); // 昨日注册成本
+                        if (!Check.isNull(nowEventRegisterCost) && !Check.isNull(yesterdayEventRegisterCost)) {
+                            if (yesterdayEventRegisterCost.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal eventRegisterCostProportion = (nowEventRegisterCost.subtract(yesterdayEventRegisterCost)).divide(yesterdayEventRegisterCost, 4, RoundingMode.HALF_UP);
+                                chainRatioJson.put("eventRegisterCostProportion", eventRegisterCostProportion);
+                            } else {
+                                chainRatioJson.put("eventRegisterCostProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("eventRegisterCostProportion", 0);
+                        }
+
+
+                        BigDecimal nowEventRegister = nowAccountSummary.getBigDecimal("eventRegister");  // 今日注册数
+                        BigDecimal yesterdayEventRegister = yesterdayAccountSummary.getBigDecimal("eventRegister"); // 昨日注册数
+                        if (!Check.isNull(nowEventRegister) && !Check.isNull(yesterdayEventRegister)) {
+                            if (yesterdayEventRegister.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal eventRegisterProportion = (nowEventRegister.subtract(yesterdayEventRegister)).divide(yesterdayEventRegister, 4, RoundingMode.HALF_UP);
+                                chainRatioJson.put("eventRegisterProportion", eventRegisterProportion);
+                            } else {
+                                chainRatioJson.put("eventRegisterProportion", 0);
+                            }
+                        } else {
+                            chainRatioJson.put("eventRegisterProportion", 0);
+                        }
+
+
                         returnJson.put("chainRatio", chainRatioJson);
                     }
+
                 }
             } else if (type == 2) {
                 queryMap.put("statDate", anotherDay);
@@ -516,7 +546,7 @@ public class AccountReportServiceImpl implements IAccountReportService {
 
                 returnJson.put("ratioJson", ratioJson);
             } else if (type == 3) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -6);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
                 statDate = endDate + " ~ " + anotherDay;
 
@@ -527,7 +557,7 @@ public class AccountReportServiceImpl implements IAccountReportService {
 
 
             } else if (type == 4) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -14);
                 accountDetail = accountReportMapper.selectAccountReportByDate(anotherDay, endDate, accountIds, discount);
                 statDate = endDate + " ~ " + anotherDay;
                 queryMap.put("startDate", endDate);
@@ -581,6 +611,4 @@ public class AccountReportServiceImpl implements IAccountReportService {
         }
         return returnJson;
     }
-
-
 }

+ 6 - 6
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java

@@ -283,10 +283,10 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             } else if (type == 2) {
                 accountJson = reportMapper.selectDayReport(anotherDay);
             } else if (type == 3) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -6);
                 accountJson = reportMapper.selectByDate(anotherDay, endDate);
             } else if (type == 4) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -14);
                 accountJson = reportMapper.selectByDate(anotherDay, endDate);
             } else if (type == 5) {
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
@@ -440,10 +440,10 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             } else if (type == 2) {
                 detail = reportMapper.selectReportDetail(anotherDay);
             } else if (type == 3) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -6);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
             } else if (type == 4) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -14);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
             } else if (type == 5) {
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
@@ -580,10 +580,10 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             } else if (type == 2) {
                 reportList = reportMapper.selectReportDetail(anotherDay);
             } else if (type == 3) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -6);
                 reportList = reportMapper.selectDayDetailByDate(anotherDay, endDate);
             } else if (type == 4) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -14);
                 reportList = reportMapper.selectDayDetailByDate(anotherDay, endDate);
             } else if (type == 5) {
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);

+ 8 - 8
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/MaterialReportServiceImpl.java

@@ -86,13 +86,13 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
                 marketJsonList = materialReportMapper.selectByMap(paramsMap);
 
             } else if (type == 3) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -6);
                 paramsMap.put("startDate", anotherDay);
                 paramsMap.put("endDate", endDate);
                 marketJsonList = materialReportMapper.selectDailyByMap(paramsMap);
 
             } else if (type == 4) {
-                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -14);
                 paramsMap.put("startDate", anotherDay);
                 paramsMap.put("endDate", endDate);
                 marketJsonList = materialReportMapper.selectDailyByMap(paramsMap);
@@ -190,25 +190,25 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
 
             } else if (type == 3) {
                 // 近一周数据
-                contrastStartDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                contrastStartDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -6);
                 paramsMap.put("startDate", contrastStartDate);
                 paramsMap.put("endDate", anotherDay);
                 contrastJson = materialReportMapper.selectDailyChainRatioByMap(paramsMap);
                 if (!Check.isNull(contrastJson)) {
                     beContrastEndDate = DateUtils.getAnotherDay("yyyy-MM-dd", contrastStartDate, -1);
-                    beContrastStartDate = DateUtils.getAnotherDay("yyyy-MM-dd", beContrastEndDate, -7);
+                    beContrastStartDate = DateUtils.getAnotherDay("yyyy-MM-dd", beContrastEndDate, -6);
                     paramsMap.put("endDate", beContrastEndDate);
                     paramsMap.put("startDate", beContrastStartDate);
                     beContrastJson = materialReportMapper.selectDailyChainRatioByMap(paramsMap);
                 }
             } else if (type == 4) {
-                contrastStartDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                contrastStartDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -14);
                 paramsMap.put("startDate", contrastStartDate);
                 paramsMap.put("endDate", anotherDay);
                 contrastJson = materialReportMapper.selectDailyChainRatioByMap(paramsMap);
                 if (!Check.isNull(contrastJson)) {
                     beContrastEndDate = DateUtils.getAnotherDay("yyyy-MM-dd", contrastStartDate, -1);
-                    beContrastStartDate = DateUtils.getAnotherDay("yyyy-MM-dd", beContrastEndDate, -15);
+                    beContrastStartDate = DateUtils.getAnotherDay("yyyy-MM-dd", beContrastEndDate, -14);
                     paramsMap.put("endDate", beContrastEndDate);
                     paramsMap.put("startDate", beContrastStartDate);
                     beContrastJson = materialReportMapper.selectDailyChainRatioByMap(paramsMap);
@@ -480,12 +480,12 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
                 paramsMap.put("endDate", anotherDay);
                 marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
             } else if (type == 3) {
-                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -6);
                 paramsMap.put("startDate", startDate);
                 paramsMap.put("endDate", anotherDay);
                 marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
             } else if (type == 4) {
-                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -14);
                 paramsMap.put("startDate", startDate);
                 paramsMap.put("endDate", anotherDay);
                 marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);

+ 9 - 9
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -81,17 +81,19 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
 
     public void getAd(String accountId, int pageNum, String ids, String date) {
         CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
-        String[] idString = ids.split(StringUtils.COMMA);
-        JSONArray getIds = new JSONArray();
-        if (null != idString && idString.length > 0) {
-            for (int i = 0; i < idString.length; i++) {
-                Long getId = Long.parseLong(idString[i]);
-                getIds.add(getId);
+        JSONArray getIds = null;
+        if (null != ids && !ids.equals("")) {
+            String[] idString = ids.split(StringUtils.COMMA);
+            if (null != idString && idString.length > 0) {
+                for (int i = 0; i < idString.length; i++) {
+                    Long getId = Long.parseLong(idString[i]);
+                    getIds.add(getId);
+                }
             }
         }
 
         // 请求地址
-        String url = "https://ad.toutiao.com/open_api/2/ad/get/";
+        String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
         // 请求参数
         Map<String, Object> filtering = new HashMap<>();
         if (null != getIds && getIds.size() > 0) {
@@ -106,9 +108,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         param.put("page", pageNum);
         param.put("page_size", 100);
         param.put("filtering", filtering);
-        log.info("查询广告计划信息参数:{}", param.toJSONString());
         JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
-        log.info("获取公告计划信息返回数据:{}", resultObject.toJSONString());
         Integer code = resultObject.getInteger("code");
         if (null == code || !code.equals(0)) {
             log.error("获取广告计划信息接口异常==》accountId:{},message:{}", accountId, resultObject.getString("message"));

+ 243 - 0
performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/controller/PlaneProjectCostController.java

@@ -0,0 +1,243 @@
+package cn.com.ctop.planeprojectcost.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 org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.util.oConvertUtils;
+import cn.com.ctop.planeprojectcost.entity.PlaneProjectCost;
+import cn.com.ctop.planeprojectcost.service.IPlaneProjectCostService;
+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
+ * @date   2019-12-28
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="平面设计项目消耗表")
+@RestController
+@RequestMapping("/planeprojectcost/planeProjectCost")
+public class PlaneProjectCostController {
+	@Autowired
+	private IPlaneProjectCostService planeProjectCostService;
+	
+	/**
+	  * 分页列表查询
+	 * @param planeProjectCost
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "平面设计项目消耗表-分页列表查询")
+	@ApiOperation(value="平面设计项目消耗表-分页列表查询", notes="平面设计项目消耗表-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<PlaneProjectCost>> queryPageList(PlaneProjectCost planeProjectCost,
+									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+									  HttpServletRequest req) {
+		Result<IPage<PlaneProjectCost>> result = new Result<IPage<PlaneProjectCost>>();
+		QueryWrapper<PlaneProjectCost> queryWrapper = QueryGenerator.initQueryWrapper(planeProjectCost, req.getParameterMap());
+		Page<PlaneProjectCost> page = new Page<PlaneProjectCost>(pageNo, pageSize);
+		IPage<PlaneProjectCost> pageList = planeProjectCostService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+	
+	/**
+	  *   添加
+	 * @param planeProjectCost
+	 * @return
+	 */
+	@AutoLog(value = "平面设计项目消耗表-添加")
+	@ApiOperation(value="平面设计项目消耗表-添加", notes="平面设计项目消耗表-添加")
+	@PostMapping(value = "/add")
+	public Result<PlaneProjectCost> add(@RequestBody PlaneProjectCost planeProjectCost) {
+		Result<PlaneProjectCost> result = new Result<PlaneProjectCost>();
+		try {
+			planeProjectCostService.save(planeProjectCost);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+	
+	/**
+	  *  编辑
+	 * @param planeProjectCost
+	 * @return
+	 */
+	@AutoLog(value = "平面设计项目消耗表-编辑")
+	@ApiOperation(value="平面设计项目消耗表-编辑", notes="平面设计项目消耗表-编辑")
+	@PutMapping(value = "/edit")
+	public Result<PlaneProjectCost> edit(@RequestBody PlaneProjectCost planeProjectCost) {
+		Result<PlaneProjectCost> result = new Result<PlaneProjectCost>();
+		PlaneProjectCost planeProjectCostEntity = planeProjectCostService.getById(planeProjectCost.getId());
+		if(planeProjectCostEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = planeProjectCostService.updateById(planeProjectCost);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+		
+		return result;
+	}
+	
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "平面设计项目消耗表-通过id删除")
+	@ApiOperation(value="平面设计项目消耗表-通过id删除", notes="平面设计项目消耗表-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			planeProjectCostService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+	
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "平面设计项目消耗表-批量删除")
+	@ApiOperation(value="平面设计项目消耗表-批量删除", notes="平面设计项目消耗表-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<PlaneProjectCost> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<PlaneProjectCost> result = new Result<PlaneProjectCost>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.planeProjectCostService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+	
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "平面设计项目消耗表-通过id查询")
+	@ApiOperation(value="平面设计项目消耗表-通过id查询", notes="平面设计项目消耗表-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<PlaneProjectCost> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<PlaneProjectCost> result = new Result<PlaneProjectCost>();
+		PlaneProjectCost planeProjectCost = planeProjectCostService.getById(id);
+		if(planeProjectCost==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(planeProjectCost);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<PlaneProjectCost> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              PlaneProjectCost planeProjectCost = JSON.parseObject(deString, PlaneProjectCost.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(planeProjectCost, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<PlaneProjectCost> pageList = planeProjectCostService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "平面设计项目消耗表列表");
+      mv.addObject(NormalExcelConstants.CLASS, PlaneProjectCost.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<PlaneProjectCost> listPlaneProjectCosts = ExcelImportUtil.importExcel(file.getInputStream(), PlaneProjectCost.class, params);
+              planeProjectCostService.saveBatch(listPlaneProjectCosts);
+              return Result.ok("文件导入成功!数据行数:" + listPlaneProjectCosts.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("文件导入失败!");
+  }
+
+}

+ 69 - 0
performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/entity/PlaneProjectCost.java

@@ -0,0 +1,69 @@
+package cn.com.ctop.planeprojectcost.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 平面设计项目消耗表
+ * @author jeecg-boot
+ * @date   2019-12-28
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_plane_project_cost")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_plane_project_cost对象", description="平面设计项目消耗表")
+public class PlaneProjectCost {
+
+	/**id*/
+	@TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+	private Integer id;
+	/**ctop_project的id*/
+	@Excel(name = "ctop_project的id", width = 15)
+    @ApiModelProperty(value = "ctop_project的id")
+	private Long projectId;
+	/**sys_user的id*/
+	@Excel(name = "sys_user的id", width = 15)
+    @ApiModelProperty(value = "sys_user的id")
+	private String userId;
+	/**项目消耗*/
+	@Excel(name = "项目消耗", width = 15)
+    @ApiModelProperty(value = "项目消耗")
+	private java.math.BigDecimal projectCost;
+	/**1_快手2_抖音*/
+	@Excel(name = "1_快手2_抖音", width = 15)
+    @ApiModelProperty(value = "1_快手2_抖音")
+	private Integer appType;
+	/**项目总消耗*/
+	@Excel(name = "项目总消耗", width = 15)
+    @ApiModelProperty(value = "项目总消耗")
+	private java.math.BigDecimal projectTotalCost;
+	/**所属年*/
+	@Excel(name = "所属年", width = 15)
+    @ApiModelProperty(value = "所属年")
+	private Integer year;
+	/**所属季度*/
+	@Excel(name = "所属季度", width = 15)
+    @ApiModelProperty(value = "所属季度")
+	private Integer quarter;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 17 - 0
performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/mapper/PlaneProjectCostMapper.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.planeprojectcost.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import cn.com.ctop.planeprojectcost.entity.PlaneProjectCost;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 平面设计项目消耗表
+ * @author: jeecg-boot
+ * @date:   2019-12-28
+ * @cersion: V1.0
+ */
+public interface PlaneProjectCostMapper extends BaseMapper<PlaneProjectCost> {
+
+}

+ 5 - 0
performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/mapper/xml/PlaneProjectCostMapper.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.planeprojectcost.mapper.PlaneProjectCostMapper">
+
+</mapper>

+ 14 - 0
performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/service/IPlaneProjectCostService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.planeprojectcost.service;
+
+import cn.com.ctop.planeprojectcost.entity.PlaneProjectCost;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 平面设计项目消耗表
+ * @author jeecg-boot
+ * @date   2019-12-28
+ * @version V1.0
+ */
+public interface IPlaneProjectCostService extends IService<PlaneProjectCost> {
+
+}

+ 19 - 0
performance-appraisal/src/main/java/cn/com/ctop/planeprojectcost/service/impl/PlaneProjectCostServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.planeprojectcost.service.impl;
+
+import cn.com.ctop.planeprojectcost.entity.PlaneProjectCost;
+import cn.com.ctop.planeprojectcost.mapper.PlaneProjectCostMapper;
+import cn.com.ctop.planeprojectcost.service.IPlaneProjectCostService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 平面设计项目消耗表
+ * @author jeecg-boot
+ * @date   2019-12-28
+ * @version V1.0
+ */
+@Service
+public class PlaneProjectCostServiceImpl extends ServiceImpl<PlaneProjectCostMapper, PlaneProjectCost> implements IPlaneProjectCostService {
+
+}

+ 25 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/UserDto2.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.userefficientvideomap.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class UserDto2 implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String userId;
+
+    private String realname;
+
+    private String roleId;
+
+    private String roleName;
+
+    private BigDecimal effiRate;
+
+    private String depId;
+
+}

+ 8 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/UserEfficientVideoMap.java

@@ -52,6 +52,14 @@ public class UserEfficientVideoMap {
 	@Excel(name = "年", width = 15)
     @ApiModelProperty(value = "年")
 	private Integer year;
+	/**年*/
+	@Excel(name = "月", width = 15)
+	@ApiModelProperty(value = "月")
+	private Integer month;
+	/**计算日期_按照此日期进行所属年月季度的计算的*/
+	@Excel(name = "计算日期", width = 15)
+	@ApiModelProperty(value = "计算日期")
+	private Date calcDate;
 	/**媒体类型1_快手2_头条*/
 	@Excel(name = "媒体类型1_快手2_头条", width = 15)
     @ApiModelProperty(value = "媒体类型1_快手2_头条")

+ 14 - 6
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java

@@ -1,9 +1,6 @@
 package cn.com.ctop.userefficientvideomap.mapper;
 
-import cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo;
-import cn.com.ctop.userefficientvideomap.entity.EffiVideoDTO;
-import cn.com.ctop.userefficientvideomap.entity.ProjectDTO;
-import cn.com.ctop.userefficientvideomap.entity.UserEfficientVideoMap;
+import cn.com.ctop.userefficientvideomap.entity.*;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
@@ -20,9 +17,9 @@ import java.util.List;
 @Component
 public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVideoMap> {
 
-    List<EffiVideoDTO> getUserVideoMap(@Param("startDate")String startDate, @Param("endDate")String endDate);
+    List<EffiVideoDTO> getUserVideoMap(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("startCalcDate")String startCalcDate, @Param("endCalcDate")String endCalcDate);
 
-    int getEffiVideoCountBySignature(@Param("signature")String signature);
+    int getEffiVideoCountBySignature(@Param("signature")String signature, @Param("appType")Integer appType);
 
     int getEffiVideoCountByUserId(@Param("year")int year, @Param("quarter")int quarter, @Param("userId")String userId);
 
@@ -48,5 +45,16 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     List<DesignMaterialInfo> getMaterialAccountInfoByMaterialId(@Param("materialId")String materialId, @Param("startDate")String startDate, @Param("endDate")String endDate);
 
+    List<ProjectDTO> getProjects(@Param("mediaId")String mediaId);
 
+    BigDecimal getProjectQuarterCostById(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+
+    List<UserDto2> getPlaneByProjectId(@Param("projectId")Long projectId);
+
+    List<UserDto2> getKuaishouDesignLeaderList();
+
+    List<String> getClip(@Param("depId")String depId);
+
+    BigDecimal getClipQuarterCost(@Param("appType")Integer appType, @Param("quarter")int quarter, @Param("year")int year, @Param("userId")String userId);
 }
+

+ 86 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

@@ -25,6 +25,8 @@
         where a.signature is not null and b.id is not null
         and DATE_FORMAT(b.create_time,'%Y-%m-%d') &gt;= #{startDate}
         and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
+        and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &gt;= #{startCalcDate}
+        and DATE_FORMAT(a.stat_date,'%Y-%m-%d') &lt;= #{endCalcDate}
         group by a.signature
         having sum(a.charge) >= 5000
     </select>
@@ -35,6 +37,7 @@
             count(1)
         from ctop_user_efficient_video_map
         where efficient_video_signature = #{signature}
+        and app_type = #{appType}
     </select>
 
     <!-- 根据年、季度、userId获取有效视频数量 -->
@@ -235,5 +238,88 @@
          and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
     </select>
 
+    <!-- 获取这个人所在的所有项目 -->
+    <select id="getProjects" resultType="cn.com.ctop.userefficientvideomap.entity.ProjectDTO">
+        select
+        project_id as projectId,
+        project_name as projectName
+        from
+        ctop_project
+        where
+        media_id = #{mediaId}
+    </select>
+
+    <!-- 根据projectId计算项目总消耗 -->
+    <select id="getProjectQuarterCostById" resultType="java.math.BigDecimal">
+            select
+            sum(dailiAccount.charge) as charge
+            from
+            ctop_kuaishou_report_daily_account dailiAccount
+            left join
+            ctop_user_allocation allocation on dailiAccount.account_id = allocation.account_id
+        where
+        dailiAccount.project_id = #{projectId}
+        AND
+        dailiAccount.stat_date &gt;= #{startDate}
+        AND
+        dailiAccount.stat_date &lt; #{endDate}
+    </select>
+
+    <select id="getPlaneByProjectId" resultType="cn.com.ctop.userefficientvideomap.entity.UserDto2">
+        select
+        a.user_id as userId,
+        a.user_name as userName,
+        b.id as roleId,
+        b.role_name as roleName
+        from
+        ctop_project_member a
+        left join sys_role b on a.role_code = b.role_code
+        where
+        a.project_id = #{projectId}
+        a.role_code in ('planeLeader','plane')
+    </select>
+
+    <!-- 获取快手设计师leader的信息 -->
+    <select id="getKuaishouDesignLeaderList" resultType="cn.com.ctop.userefficientvideomap.entity.UserDto2">
+            select
+            a.user_id as userId,
+            c.realname as userName,
+            '8d3e2ed58bdedf17716f698ea674da27' as roleId,
+            '设计组长' as roleName,
+            a.dep_id as depId
+        FROM sys_user_depart a
+        left join sys_user c on a.user_id = c.id
+        left join sys_depart b on a.dep_id = b.id
+                    WHERE a.user_id in(
+                        select
+                        user_id
+                        from sys_user_role
+                        WHERE role_id = '8d3e2ed58bdedf17716f698ea674da27'   <!-- 设计师 -->
+                        )
+        and b.parent_id = '4e939124a5f541c88838e49d2a3ea72b'  <!-- 快手设计部 -->
+    </select>
+
+    <!-- 根据部门id -->
+    <select id="getClip" resultType="string">
+        select
+        user_id
+        from
+        sys_user_depart a
+        left join sys_user_role b on a.user_id = b.user_id
+        where a.dep_id = #{depId}
+        and b.role_code = 'clip'
+    </select>
+
+    <select id="getClipQuarterCost" resultType="java.math.BigDecimal">
+            select
+            total_cost
+        from
+        ctop_performance
+        where
+        app_type = #{appType}
+        and quarter = #{quarter}
+        and year = #{year}
+        and user_id = #{userId}
+    </select>
 
 </mapper>