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

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
#	jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties
#	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
syh 4 роки тому
батько
коміт
b5fdc4373f
43 змінених файлів з 2247 додано та 143 видалено
  1. 33 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/GeneralConstant.java
  2. 139 3
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  3. 36 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  4. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  5. 107 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  6. 4 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml
  7. 7 2
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  8. 26 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  9. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  10. 15 12
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  11. 16 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  12. 99 34
      module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  13. 52 0
      module-common/src/main/java/com/xxl/job/core/enums/NoEn.java
  14. 12 0
      module-job-bytedance/pom.xml
  15. 45 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/WechatApproveAttendanceJob.java
  16. 43 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/WechatAttendanceJob.java
  17. 99 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouRealTimeController.java
  18. 9 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouRealTimeDataService.java
  19. 110 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouRealTimeDataServiceImpl.java
  20. 3 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/constant/QYWxConstant.java
  21. 27 16
      module-oa/src/main/java/cn/com/ctop/oa/modules/controller/WechatCheckinDataController.java
  22. 28 1
      module-oa/src/main/java/cn/com/ctop/oa/modules/controller/WechatDepartmentController.java
  23. 368 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/controller/WechatNoListController.java
  24. 65 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatAttendance.java
  25. 15 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatCheckinData.java
  26. 67 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatNoList.java
  27. 63 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/enums/SpNoEnum.java
  28. 6 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/WechatCheckinDataMapper.java
  29. 3 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/WechatDepartmentMapper.java
  30. 23 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/WechatNoListMapper.java
  31. 65 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatCheckinDataMapper.xml
  32. 6 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatDepartmentMapper.xml
  33. 89 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatNoListMapper.xml
  34. 5 1
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatCheckinDataService.java
  35. 4 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatDepartmentService.java
  36. 49 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatNoListService.java
  37. 11 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatTokenService.java
  38. 0 1
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatUserListService.java
  39. 70 35
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatCheckinDataServiceImpl.java
  40. 5 11
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatDepartmentServiceImpl.java
  41. 388 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatNoListServiceImpl.java
  42. 30 7
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatTokenServiceImpl.java
  43. 0 14
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatUserListServiceImpl.java

+ 33 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/GeneralConstant.java

@@ -0,0 +1,33 @@
+package org.jeecg.common.constant;
+
+/**
+ * 项目中一般字符串常量
+ *
+ * @ClassName GeneralConstant
+ * @Author ZHAOXA
+ * @date 2020-09-29 10:33
+ */
+public class GeneralConstant {
+
+    /**
+     * code
+     */
+    public static final String CODE = "code";
+    public static final String MESSAGE = "message";
+    public static final String ERR_CODE = "errcode";
+    public static final String DAY_BEGIN = " 00:00:00";
+    public static final String DAY_END = " 23:59:59";
+    public static final String PAGE_NO = "pageNo";
+    public static final String PAGE_SIZE = "pageSize";
+    public static final String API_START_TIME = "starttime";
+    public static final String API_END_TIME = "endtime";
+    public static final String START_TIME = "startTime";
+    public static final String STOP_TIME = "stopTime";
+    public static final String ACCESS_TOKEN = "accessToken";
+    public static final String TYPE = "type";
+    public static final String VALUE = "value";
+
+
+
+
+}

+ 139 - 3
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -10,7 +10,14 @@ import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * 类描述:时间操作定义类
@@ -71,6 +78,21 @@ public class DateUtils extends PropertyEditorSupport {
     private static final long HOUR_IN_MILLIS = 3600 * 1000L;
     private static final long MINUTE_IN_MILLIS = 60 * 1000L;
     private static final long SECOND_IN_MILLIS = 1000L;
+    /**
+     * 格式常量
+     */
+    public final static String SHORT_FORMAT = "yyyyMMdd";
+    public final static String LONG_FORMAT = "yyyyMMddHHmmss";
+    public final static String YEARHOUR_FORMAT = "yyyyMMddHH";
+    public final static String WEB_FORMAT = "yyyy-MM-dd";
+    public final static String TIME_FORMAT = "HHmmss";
+    public final static String COLON_TIME_FORMAT = "HH:mm:ss";
+    public final static String CHINESEDT_FORMAT = "yyyy年MM月dd日";
+    public final static String NEW_FORMAT = "yyyy-MM-dd HH:mm:ss";
+    public final static String WEB_FORMAT_ALL = "yyyy MM dd HH mm ss";
+    public final static String SECOND_FORMAT = "yyyy-MM-dd HH";
+    public final static String GREGORIAN_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
+    public final static String NOMS_GREGORIAN_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
 
     public static String getNowHour(Date date) {
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
@@ -731,9 +753,79 @@ public class DateUtils extends PropertyEditorSupport {
         return temp;
     }
 
+    private static Calendar zeroFromHour(long milliseconds) {
+        Calendar calendar = Calendar.getInstance(); // 获得一个日历
+
+        calendar.setTimeInMillis(completMilliseconds(milliseconds));
+        zeroFromHour(calendar);
+        return calendar;
+    }
+
+    private static long completMilliseconds(long milliseconds) {
+        String milStr = Long.toString(milliseconds);
+        if (milStr.length() == 10) {
+            milliseconds = milliseconds * 1000;
+        }
+        return milliseconds;
+    }
+
+    private static void zeroFromHour(Calendar calendar) {
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+    }
+
+
+    public static String getWhatDay(long timeStamp) {
+        Calendar cal = zeroFromHour(timeStamp);
+        String whatDay = "";
+        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
+            whatDay = "星期六";
+        }
+        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
+            whatDay = "星期日";
+        }
+        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
+            whatDay = "星期一";
+        }
+        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY) {
+            whatDay = "星期二";
+        }
+        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) {
+            whatDay = "星期三";
+        }
+        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY) {
+            whatDay = "星期四";
+        }
+        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) {
+            whatDay = "星期五";
+        }
+        return whatDay;
+    }
+
+    /* //日期转换为时间戳 */
+    public static long timeToStamp(String timers) {
+        Date d = new Date();
+        long timeStemp = 0;
+        try {
+            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            d = sf.parse(timers);// 日期转换为时间戳
+        } catch (ParseException e) {
+
+            e.printStackTrace();
+        }
+        timeStemp = d.getTime();
+        return timeStemp / 1000;
+    }
+
+
     public static void main(String[] args) throws ParseException {
-        Date date = stampToTime(1599524171L);
-        System.err.println(date);
+        /*Date date = stampToTime(1599458521L);
+        String s = formatDate(date);
+        System.err.println(s);*/
+        Long s1 = timeToStamp("2020-09-23 21:30:00");
+        System.err.println(s1);
     }
 
     /**
@@ -1409,6 +1501,50 @@ public class DateUtils extends PropertyEditorSupport {
         return lDate;
     }
 
+    /**
+     * 获取前一天的日期
+     *
+     * @param
+     * @return java.lang.String
+     * @throws
+     * @author ZHAOXA
+     */
+    public static String getLastDay(String time) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = Calendar.getInstance();
+        Date date = null;
+        try {
+            date = sdf.parse(time);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        calendar.setTime(date);
+        int day = calendar.get(Calendar.DATE);
+        //                      此处修改为+1则是获取后一天
+        calendar.set(Calendar.DATE, day - 1);
+
+        String lastDay = sdf.format(calendar.getTime());
+        return lastDay;
+    }
+
+    /**
+     * 获取当月1号零时零分的时间
+     *
+     * @param
+     * @return java.lang.String
+     * @throws
+     * @author ZHAOXA
+     */
+    public static String initDateByMonth() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sdf.format(calendar.getTime());
+    }
 }
 
 

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

@@ -5,7 +5,9 @@ import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.enums.MaterialSupplierEnum;
 import cn.com.ctop.common.module.service.*;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.JsonUtil;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -27,7 +29,10 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
-import java.util.*;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 素材信息
@@ -187,6 +192,7 @@ public class MaterialInfoController {
         result.setResult(pageList);
         return result;
     }
+
     @Autowired
     private ISysRoleService roleService;
 
@@ -292,7 +298,10 @@ public class MaterialInfoController {
                 } else {
                     material.setWhetherUnaudited(true);
                 }
+
             }
+
+
         }
 
         result.setSuccess(true);
@@ -496,6 +505,28 @@ public class MaterialInfoController {
                 url = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
             }
             materialInfo.setUrl(url);
+            MaterialCutFrame cutFrame = materialCutFrameService.getCutFrameByCode(materialInfo.getCode());
+            if (Check.isNull(cutFrame)) {
+                String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
+                String loadImage = "cutFrame/" + materialInfo.getCode() + "/zero.jpg";
+                String coverUrl = CloudVideoProcessUtil.videoCutPictureHandle(videoUrl, loadImage);
+                materialInfo.setCoverUrl(coverUrl);
+                Thread thread = new Thread() {
+                    @Override
+                    public void run() {
+                        try {
+                            log.info("开始抽帧,code:{}", materialInfo.getCode());
+                            materialCutFrameService.getTencentCutFrame(videoUrl, materialInfo.getCode(), coverUrl);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                };
+                thread.start();
+            } else {
+                materialInfo.setCoverUrl(cutFrame.getUrl());
+            }
+
         }
 
         //  修改素材库 相关联code
@@ -675,7 +706,7 @@ public class MaterialInfoController {
     }
 
     /**
-     *  adlab 新加查询素材库接口
+     * adlab 新加查询素材库接口
      */
     @PostMapping(value = "/listByAccountIds")
     public Result<IPage<MaterialInfo>> listByAccountIds(@RequestBody JSONObject requestBody) {
@@ -683,13 +714,13 @@ public class MaterialInfoController {
         Result<IPage<MaterialInfo>> result = new Result<>();
         QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
         if (!Check.isNull(requestBody.getString("userId"))) {
-            queryWrapper.eq("user_id",requestBody.getString("userId"));
+            queryWrapper.eq("user_id", requestBody.getString("userId"));
             List<Long> projects = memberService.getProjectByAccountIds(requestBody.getJSONArray("accountIds"));
             if (!Check.isNull(projects)) {
                 queryWrapper.in("project_id", projects);
             }
         }
-        queryWrapper.orderByDesc(true,"create_time");
+        queryWrapper.orderByDesc(true, "create_time");
         Page<MaterialInfo> page = new Page<>(requestBody.getInteger("pageNo"), requestBody.getInteger("pageSize"));
         IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
         result.setSuccess(true);

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

@@ -330,6 +330,7 @@ public class ProjectController {
                 projectMemberService.removeByMap(map);
                 ProjectMember member = new ProjectMember();
                 member.setProjectId(id);
+                member.setProjectName(project.getProjectName());
                 member.setUserId(userId);
                 member.setUserName(userName);
                 String roleCode = sysRoleService.getRoleCodeByUserId(userId);

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

@@ -2,14 +2,19 @@ package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleExtService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.StringUtils;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -29,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 用户分配
@@ -55,6 +61,14 @@ public class UserAllocationController {
     @Autowired
     private IProjectMemberService projectMemberService;
 
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
+
+
     @GetMapping(value = "/accountTurnProject")
     public Result<Object> getAccountList(Long accountId, Long projectId) {
         Result<Object> result = new Result<>();
@@ -196,6 +210,99 @@ public class UserAllocationController {
     }
 
 
+    @GetMapping(value = "/updateAuthName")
+    public Result<UserAllocation> updateAuthName(Long accountId, String mediaId) {
+        Result<UserAllocation> result = new Result<>();
+        try {
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            String authName = null;
+            if (mediaId.equals("2") || mediaId.equals("4")) {
+                Map<String, Object> advertiseBaseInfoMap = kuaishouInterfaceService.advertiserInfo(accountId, oauthToken.getAccessToken());
+                Integer code = (Integer) advertiseBaseInfoMap.get("code");
+                if (code != 0) {
+                    throw new Exception("更新授权名称失败");
+
+                }
+                authName = (String) advertiseBaseInfoMap.get("userName");
+            } else if (mediaId.equals("1") || mediaId.equals("3")) {
+                Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(String.valueOf(accountId), oauthToken.getAccessToken());
+                Integer code = (Integer) advertiserDataMap.get("code");
+                if (code != 0) {
+                    throw new Exception("更新授权名称失败");
+
+                }
+                authName = (String) advertiserDataMap.get("name");
+            }
+            UserAllocation allocation = new UserAllocation();
+            allocation.setAuthName(authName);
+
+            QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("account_id", accountId);
+            queryWrapper.eq("media_id", mediaId);
+
+            boolean update = userAllocationService.update(allocation, queryWrapper);
+            if (update) {
+                result.setSuccess(true);
+            } else {
+                result.setSuccess(false);
+            }
+
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+
+    }
+
+
+    /**
+     * 统计报表 查看所有账号
+     *
+     * @param projectId
+     * @return
+     */
+    @GetMapping(value = "/getUserIdListByProjectId")
+    public Result<List<JSONObject>> getUserIdListByProjectId(Long projectId) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            if (Check.isNull(projectId)) {
+                throw new Exception("请选择项目id");
+            }
+            List<JSONObject> userIdList = userAllocationService.getUserIdListByProjectId(projectId);
+            result.setSuccess(true);
+            result.setResult(userIdList);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success(e.getMessage());
+        }
+        return result;
+    }
+
+
+    @GetMapping(value = "/getAccountIdListByUserId")
+    public Result<List<JSONObject>> getAccountIdListByUserId(Long userId) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请选择快手id");
+            }
+            List<JSONObject> accountIdList = userAllocationService.getAccountIdListByUserId(userId);
+            result.setSuccess(true);
+            result.setResult(accountIdList);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success(e.getMessage());
+        }
+        return result;
+    }
+
+
     /**
      * 分页列表查询
      *

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

@@ -112,7 +112,10 @@
     <select id="queryProjectMemberByUserId" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
         select
         distinct b.project_id as projectId,
-        b.project_name as projectName,
+         (
+         select project_name  from ctop_project
+         where id = b.project_id
+        )as projectName,
         a.advertiser_id as advertiserId,
         (
         select name from ctop_advertiser where id = a.advertiser_id

+ 7 - 2
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -14,8 +14,13 @@ import java.util.List;
  * @Version: V1.0
  */
 public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
-    List<UserAllocation> selectAccountListByProjectId(@Param("projectId")Long projectId);
-    String queryAdvertiserId(@Param("accountId")Long accountId);
+    List<UserAllocation> selectAccountListByProjectId(@Param("projectId") Long projectId);
+
+    String queryAdvertiserId(@Param("accountId") Long accountId);
 
     List<JSONObject> getAccountListByProject(@Param("projectId") Long projectId);
+
+    List<JSONObject> getUserIdListByProjectId(@Param("projectId") Long projectId);
+
+    List<JSONObject> getAccountIdListByUserId(@Param("userId") Long userId);
 }

+ 26 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -31,4 +31,30 @@
        where project_id = #{projectId}
        order by create_time desc
     </select>
+
+    <select id="getUserIdListByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+   SELECT t1.user_id as 'userId',
+    t1.account_id as 'accountId',
+    t1.user_name  as 'userName'
+    from  ctop_kuaishou_advertiser_base_info t1  LEFT JOIN
+    ctop_user_allocation  t2
+    ON t1.account_id = t2.account_id
+    WHERE t2.project_id = #{projectId}
+    GROUP BY t1.user_id;
+    </select>
+
+
+    <select id="getAccountIdListByUserId" resultType="com.alibaba.fastjson.JSONObject">
+    SELECT
+    t1.account_id as 'accountId',
+    t1.auth_name  as 'authName',
+    t1.user_name as 'userName'
+    from ctop_user_allocation   t1  LEFT JOIN
+    ctop_kuaishou_advertiser_base_info t2
+    ON t1.account_id = t2.account_id
+    WHERE t2.user_id = #{userId}
+    AND t1.account_status = 0
+    </select>
+
+
 </mapper>

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -28,4 +28,8 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     String getAdvertiserIdByAccountId(Long accountId);
 
     List<JSONObject> getAccountListByProject(Long projectId);
+
+    List<JSONObject> getUserIdListByProjectId(Long projectId);
+
+    List<JSONObject> getAccountIdListByUserId(Long userId);
 }

+ 15 - 12
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -518,7 +518,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             MaterialInfo info = new MaterialInfo();
             Long projectId = json.getLong("projectId");
             String code = json.getString("code");
-            info.setId(code + projectId);
+            info.setId(code + "_" + projectId);
             info.setCode(code);
             if (!Check.isNull(json.getString("watermarkUrl"))) {
                 info.setWatermarkUrl(json.getString("watermarkUrl"));
@@ -547,13 +547,15 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                 String coverUrl = CloudVideoProcessUtil.videoCutPictureHandle(videoUrl, loadImage);
                 info.setCoverUrl(coverUrl);
                 Thread thread = new Thread() {
-                        @Override
-                        public void run() { try {
+                    @Override
+                    public void run() {
+                        try {
                             log.info("开始抽帧,code:{}", code);
                             materialCutFrameService.getTencentCutFrame(videoUrl, code, coverUrl);
                         } catch (Exception e) {
                             e.printStackTrace();
-                        } }
+                        }
+                    }
                 };
                 thread.start();
             } else {
@@ -587,13 +589,13 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             }
             materialTagInfoService.deleteByCode(code);
             JSONArray modalityTagList = json.getJSONArray("modalityTagList");
-            insertTagList(code,userId,modalityTagList);
+            insertTagList(code, userId, modalityTagList);
             JSONArray contentTagList = json.getJSONArray("contentTagList");
-            insertTagList(code,userId,contentTagList);
+            insertTagList(code, userId, contentTagList);
             JSONArray senceTagList = json.getJSONArray("senceTagList");
-            insertTagList(code,userId,senceTagList);
+            insertTagList(code, userId, senceTagList);
             JSONArray modTagList = json.getJSONArray("modTagList");
-            insertTagList(code,userId,modTagList);
+            insertTagList(code, userId, modTagList);
             getFile(info, project.getMediaId());
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
         } catch (Exception e) {
@@ -603,17 +605,18 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         return resultMap;
     }
 
-    private void insertTagList(String code,String userId,JSONArray tagList){
-        if(null!=tagList&&!tagList.isEmpty()){
-            for(int m=0;m<tagList.size();m++){
+    private void insertTagList(String code, String userId, JSONArray tagList) {
+        if (null != tagList && !tagList.isEmpty()) {
+            for (int m = 0; m < tagList.size(); m++) {
                 Long tagId = tagList.getLong(m);
                 TagInfo tagInfo = tagInfoService.getById(tagId);
-                MaterialTagInfo setTag= new MaterialTagInfo(code,tagInfo,userId);
+                MaterialTagInfo setTag = new MaterialTagInfo(code, tagInfo, userId);
                 setTag.setCategoryId(tagInfo.getTagCategoryId());
                 materialTagInfoService.save(setTag);
             }
         }
     }
+
     @Autowired
     private ITagInfoService tagInfoService;
     @Autowired

+ 16 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -103,4 +103,20 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     public List<JSONObject> getAccountListByProject(Long projectId) {
         return userAllocationMapper.getAccountListByProject(projectId);
     }
+
+    /**
+     * 获取项目下的所有userId
+     *
+     * @param projectId
+     * @return
+     */
+    @Override
+    public List<JSONObject> getUserIdListByProjectId(Long projectId) {
+        return userAllocationMapper.getUserIdListByProjectId(projectId);
+    }
+
+    @Override
+    public List<JSONObject> getAccountIdListByUserId(Long userId) {
+        return userAllocationMapper.getAccountIdListByUserId(userId);
+    }
 }

+ 99 - 34
module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -1,8 +1,18 @@
 package cn.com.ctop.common.module.utils;
 
 
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFFont;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -92,8 +102,94 @@ public class ExportExcelUtils {
         }
     }
 
+
+    public void exportExcelForAttendance(XSSFWorkbook workbook, int sheetNum, String sheetTitle, String[] headers, List<List<Object>> result) {
+        // 生成一个表格
+        XSSFSheet sheet = workbook.createSheet();
+        workbook.setSheetName(sheetNum, sheetTitle);
+        // 设置表格默认列宽度为20个字节
+        sheet.setDefaultColumnWidth((short) 20);
+        // 生成一个样式
+        XSSFCellStyle style = workbook.createCellStyle();
+        XSSFCellStyle style2 = workbook.createCellStyle();
+        XSSFCellStyle style3 = workbook.createCellStyle();
+        // 设置这些样式
+        style.setFillForegroundColor(IndexedColors.PALE_BLUE.index);
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setBorderTop(BorderStyle.THIN);
+        // style.setAlignment(HorizontalAlignment.CENTER);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
+        // 生成一个字体
+        XSSFFont font = workbook.createFont();
+        font.setColor(IndexedColors.BLACK.index);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        // 把字体应用到当前的样式
+        style.setFont(font);
+
+        // 指定当单元格内容显示不下时自动换行
+        style.setWrapText(true);
+        //迟到时间超过15分钟的考勤记录样式(标黄)
+        style2.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.index);
+        style2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style2.setBorderBottom(BorderStyle.THIN);
+        style2.setBorderLeft(BorderStyle.THIN);
+        style2.setBorderRight(BorderStyle.THIN);
+        style2.setBorderTop(BorderStyle.THIN);
+        // 产生表格标题行
+        XSSFRow row = sheet.createRow(0);
+        for (int i = 0; i < headers.length; i++) {
+            XSSFCell cell = row.createCell((short) i);
+            cell.setCellStyle(style);
+            XSSFRichTextString text = new XSSFRichTextString(headers[i]);
+            cell.setCellValue(text.toString());
+        }
+        // 遍历集合数据,产生数据行
+        if (result != null) {
+            int index = 1;
+            for (List<Object> m : result) {
+                row = sheet.createRow(index);
+                int cellIndex = 0;
+                //迟到时间超过15分钟的考勤记录判断
+                boolean changeColor = false;
+                if (m.contains("迟到")) {
+                    String duration = String.valueOf(m.get(m.size() - 2));
+                    if (!Check.isNull(duration) && Integer.valueOf(duration.replace(" min", "")) - 15 > 0) {
+                        changeColor = true;
+                    }
+                }
+                for (Object obj : m) {
+                    XSSFCell cell = row.createCell((short) cellIndex);
+                    if (!Check.isNull(obj)) {
+                        if (changeColor) {
+                            cell.setCellStyle(style2);
+                        }
+                        if (obj instanceof String) {
+                            cell.setCellValue((String) obj);
+                        } else if (obj instanceof Double) {
+                            cell.setCellValue((Double) obj);
+                        } else if (obj instanceof BigDecimal) {
+                            BigDecimal bigDecimal = (BigDecimal) obj;
+                            cell.setCellValue(bigDecimal.doubleValue());
+                        } else if (obj instanceof Long) {
+                            cell.setCellValue(String.valueOf(obj));
+                        } else {
+                            cell.setCellValue(obj.toString());
+                        }
+                    }
+                    cellIndex++;
+                }
+                index++;
+            }
+        }
+    }
+
     public void exportExcelForMediaReport(XSSFWorkbook workbook, int sheetNum,
-                            String sheetTitle, String[] headers, List<List<Object>> result) {
+                                          String sheetTitle, String[] headers, List<List<Object>> result) {
         // 生成一个表格
         XSSFSheet sheet = workbook.createSheet();
         workbook.setSheetName(sheetNum, sheetTitle);
@@ -180,35 +276,4 @@ public class ExportExcelUtils {
     }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 }

+ 52 - 0
module-common/src/main/java/com/xxl/job/core/enums/NoEn.java

@@ -0,0 +1,52 @@
+package com.xxl.job.core.enums;
+
+/**
+ * 项目中0~25数字字符串枚举
+ *
+ * @ClassName GeneralConstant
+ * @Author ZHAOXA
+ * @date 2020-09-29 10:33
+ */
+public enum NoEn {
+    NO0("0", 0),
+    NO1("1", 1),
+    NO2("2", 2),
+    NO3("3", 3),
+    NO4("4", 4),
+    NO5("5", 5),
+    NO6("6", 6),
+    NO7("7", 7),
+    NO8("8", 8),
+    NO9("9", 9),
+    NO10("10", 10),
+    NO11("11", 11),
+    NO12("12", 12),
+    NO13("13", 13),
+    NO14("14", 14),
+    NO15("15", 15),
+    NO16("16", 16),
+    NO17("17", 17),
+    NO18("18", 18),
+    NO19("19", 19),
+    NO20("20", 20),
+    NO21("21", 21),
+    NO22("22", 21),
+    NO23("23", 23),
+    NO24("24", 24),
+    NO25("25", 25);
+    private final String strValue;
+    private final int intValue;
+
+    private NoEn(String strValue, int intValue) {
+        this.strValue = strValue;
+        this.intValue = intValue;
+    }
+
+    public String valueStr() {
+        return strValue;
+    }
+
+    public int valueInt() {
+        return intValue;
+    }
+}

+ 12 - 0
module-job-bytedance/pom.xml

@@ -79,6 +79,12 @@
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>cn.com.ctop</groupId>
+            <artifactId>module-oa</artifactId>
+            <version>2.0.2</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>com.aliyun.oss</groupId>
             <artifactId>aliyun-sdk-oss</artifactId>
             <version>3.5.0</version>
@@ -139,6 +145,12 @@
             <artifactId>module-check</artifactId>
             <version>2.0.2</version>
         </dependency>
+        <dependency>
+            <groupId>cn.com.ctop</groupId>
+            <artifactId>module-oa</artifactId>
+            <version>2.0.2</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <dependencyManagement>

+ 45 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/WechatApproveAttendanceJob.java

@@ -0,0 +1,45 @@
+package cn.com.ctop.job.bytedance.handler;
+
+
+import cn.com.ctop.oa.modules.service.IWechatNoListService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 异常考勤审批数据入库
+ *
+ * @param
+ * @author ZHAOXA
+ * @return
+ * @throws
+ */
+@Component
+public class WechatApproveAttendanceJob {
+    @Autowired
+    private IWechatNoListService wechatNoListService;
+
+    /**
+     * 异常考勤审批数据入库
+     * 频率:每月2日凌晨2点同步审批数据 cron:0 0 2 2 * ?
+     * 审批状态表
+     * starttime 统计开始时间,上个月1号零时零分的时间 例:2020-08-01 00:00:00;
+     * endtime 统计结束时间,本月1号零时零分的时间 例:2020-09-01 00:00:00;
+     *
+     * @author ZHAOXA
+     */
+    @XxlJob("wechatApproveAttendanceJob")
+    public ReturnT<String> execute() throws Exception {
+        XxlJobLogger.log("--------异常考勤审批数据入库 start ");
+        String initMonth = DateUtils.initDateByMonth();
+        long starttime = DateUtils.timeToStamp(DateUtils.getMonthBefore(DateUtils.NEW_FORMAT, initMonth, -1));
+        long endtime = DateUtils.timeToStamp(initMonth);
+        //更新审批状态表
+        wechatNoListService.getNoDateByNo(String.valueOf(starttime), String.valueOf(endtime));
+        XxlJobLogger.log("--------异常考勤审批数据入库 end ");
+        return ReturnT.SUCCESS;
+    }
+}

+ 43 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/WechatAttendanceJob.java

@@ -0,0 +1,43 @@
+package cn.com.ctop.job.bytedance.handler;
+
+
+import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
+import cn.com.ctop.oa.modules.service.IWechatUserListService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class WechatAttendanceJob {
+    @Autowired
+    private IWechatCheckinDataService wechatCheckinDataService;
+    @Autowired
+    private IWechatUserListService wechatUserInfoService;
+
+    /**
+     * 考勤数据入库
+     * 员工打卡明细表 每日凌晨2点统计前一天的考勤数据 cron:0 0 2 * * ?
+     * <p>
+     * 人员信息表 每日凌晨2点统计前一天的人员数据 cron:0 0 2 * * ?
+     *
+     * @author ZHAOXA
+     */
+    @XxlJob("wechatAttendanceJob")
+    public ReturnT<String> execute(String params) throws Exception {
+        XxlJobLogger.log("--------考勤数据入库 start ");
+        String beforeDay = DateUtils.getLastDay(DateUtils.formatDate(new Date()));
+        long starttime = DateUtils.timeToStamp(beforeDay + " 00:00:00");
+        long endtime = DateUtils.timeToStamp(beforeDay + " 23:59:59");
+        //更新员工打卡明细表
+        wechatCheckinDataService.getCheckinData(String.valueOf(starttime), String.valueOf(endtime));
+        //更新人员信息表
+        wechatUserInfoService.getUserList();
+        XxlJobLogger.log("--------考勤数据入库 end ");
+        return ReturnT.SUCCESS;
+    }
+}

+ 99 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouRealTimeController.java

@@ -0,0 +1,99 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouRealTimeDataService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+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;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description: 广告组-app信息
+ * @Author: jeecg-boot
+ * @Date: 2019-07-23
+ * @Version: V1.0
+ */
+@Slf4j
+@RestController
+@RequestMapping("/kuaishou/realTime")
+public class KuaiShouRealTimeController {
+    @Autowired
+    private IKuaishouRealTimeDataService realTimeDataService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+
+    @PostMapping(value = "/getCampaignDate")
+    public Result<JSONArray> getCampaignDate(@RequestBody JSONObject requestJson) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请传入账户id");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            Long campaignId = requestJson.getLong("campaignId");
+            if (Check.isNull(campaignId)) {
+                throw new Exception("请传入计划id");
+            }
+            String startDate = requestJson.getString("startDate");
+            String endDate = requestJson.getString("endDate");
+            if (Check.isNull(startDate) || Check.isNull(endDate)) {
+                throw new Exception("请选择开始、结束查询时间");
+            }
+            JSONArray campaignDate = realTimeDataService.getCampaignDate(accountId, oauthToken.getAccessToken(), campaignId, startDate, endDate);
+            result.setSuccess(true);
+            result.setResult(campaignDate);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    @PostMapping(value = "/getUnitDate")
+    public Result<JSONArray> getUnitDate(@RequestBody JSONObject requestJson) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请传入账户id");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            Long unitId = requestJson.getLong("unitId");
+            if (Check.isNull(unitId)) {
+                throw new Exception("请传入组id");
+            }
+            String startDate = requestJson.getString("startDate");
+            String endDate = requestJson.getString("endDate");
+            if (Check.isNull(startDate) || Check.isNull(endDate)) {
+                throw new Exception("请选择开始、结束查询时间");
+            }
+            JSONArray unitData = realTimeDataService.getUnitDate(accountId, oauthToken.getAccessToken(), unitId, startDate, endDate);
+            result.setSuccess(true);
+            result.setResult(unitData);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+}

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

@@ -0,0 +1,9 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import com.alibaba.fastjson.JSONArray;
+
+public interface IKuaishouRealTimeDataService {
+    JSONArray getCampaignDate(Long accountId, String token, Long campaignId, String startDate, String endDate);
+
+    JSONArray getUnitDate(Long accountId, String token, Long unitId, String startDate, String endDate);
+}

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

@@ -0,0 +1,110 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouRealTimeDataService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class KuaishouRealTimeDataServiceImpl implements IKuaishouRealTimeDataService {
+    /**
+     * 获取计划实时数据
+     *
+     * @param accountId
+     * @param token
+     * @param campaignId
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @Override
+    public JSONArray getCampaignDate(Long accountId, String token, Long campaignId, String startDate, String endDate) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", startDate);
+        param.put("end_date", endDate);
+        param.put("advertiser_id", accountId);
+        param.put("temporal_granularity", "DAILY");
+        param.put("page_size", 2000);
+        param.put("page", 1);
+
+        JSONArray array = new JSONArray();
+        array.add(campaignId);
+        param.put("campaign_ids", array);
+        try {
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            System.err.println(result);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            if (!Check.isNull(jsonObject)) {
+                Integer code = jsonObject.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        return data.getJSONArray("details");
+                    }
+
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 获取组实时数据
+     *
+     * @param accountId
+     * @param token
+     * @param unitId
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @Override
+    public JSONArray getUnitDate(Long accountId, String token, Long unitId, String startDate, String endDate) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", startDate);
+        param.put("end_date", endDate);
+        param.put("advertiser_id", accountId);
+        param.put("temporal_granularity", "DAILY");
+        param.put("page_size", 2000);
+        param.put("page", 1);
+
+        JSONArray array = new JSONArray();
+        array.add(unitId);
+        param.put("unit_ids", array);
+        try {
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            if (!Check.isNull(jsonObject)) {
+                Integer code = jsonObject.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        return data.getJSONArray("details");
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 3 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/constant/QYWxConstant.java

@@ -8,6 +8,7 @@ public class QYWxConstant {
 
     public static final Integer QYWX_OA_AGENT_ID = 3010011;
     public static final String QYWX_OA_CORP_SECRET = "MDeiFSCwIlcmcR1zrYvmjNlsoYFGl8I770uuUezWgGE";
+    public static final String QYWX_APPROVA_CORP_SECRET = "qlk4nSc1vjxy0AHyX1f5bnGh7y2WtqN9lR__0WJA6zM";
 
 
     public static final String QYWX_API_URL = "https://qyapi.weixin.qq.com";  //企业微信api域名
@@ -15,6 +16,8 @@ public class QYWxConstant {
     public static final String QYWX_GET_TOKEN = "/cgi-bin/gettoken";  //获取token
     public static final String QYWX_USER_SIMPLELIST = "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist";  //获取部门下员工简单信息
     public static final String QYWX_CHECKIN_DATA = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata";  //获取部门下员工简单信息
+    public static final String APP_ROVAL_INFO = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovalinfo";  //批量获取审批单号
+    public static final String APP_ROVAL_DETAIL = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovaldetail";  //获取审批申请详情
 
 
 }

+ 27 - 16
module-oa/src/main/java/cn/com/ctop/oa/modules/controller/WechatCheckinDataController.java

@@ -1,12 +1,12 @@
 package cn.com.ctop.oa.modules.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.oa.modules.entity.WechatCheckinData;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 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 com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -19,7 +19,15 @@ 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.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
@@ -57,22 +65,25 @@ public class WechatCheckinDataController {
      * @param req
      * @return
      */
-    @AutoLog(value = "企业微信用户-分页列表查询")
-    @ApiOperation(value = "企业微信用户-分页列表查询", notes = "企业微信用户-分页列表查询")
-    @GetMapping(value = "/list")
-    public Result<IPage<WechatCheckinData>> queryPageList(WechatCheckinData wechatCheckinData,
-                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                          HttpServletRequest req) {
-        Result<IPage<WechatCheckinData>> result = new Result<>();
-        QueryWrapper<WechatCheckinData> queryWrapper = QueryGenerator.initQueryWrapper(wechatCheckinData, req.getParameterMap());
-        Page<WechatCheckinData> page = new Page<WechatCheckinData>(pageNo, pageSize);
-        IPage<WechatCheckinData> pageList = wechatCheckinDataService.page(page, queryWrapper);
-        result.setSuccess(true);
-        result.setResult(pageList);
+    @AutoLog(value = "考勤打卡明细-分页列表查询")
+    @ApiOperation(value = "考勤打卡明细-分页列表查询", notes = "考勤打卡明细-分页列表查询")
+    @PostMapping(value = "/queryPageList")
+    public Result<PageInfo<WechatCheckinData>> queryPageList(@RequestBody Map<String, Object> paramsMap) {
+        Result<PageInfo<WechatCheckinData>> result = new Result<>();
+        try {
+            PageInfo<WechatCheckinData> pageData = wechatCheckinDataService.selectPageList(paramsMap);
+            if (!Check.isNull(pageData)) {
+                result.setResult(pageData);
+                result.setSuccess(true);
+            }
+        } catch (Exception e) {
+            log.error("考勤打卡明细-分页列表查询 error ", e);
+            result.error500("操作失败");
+        }
         return result;
     }
 
+
     /**
      * 添加
      *

+ 28 - 1
module-oa/src/main/java/cn/com/ctop/oa/modules/controller/WechatDepartmentController.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.oa.modules.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.oa.modules.entity.WechatDepartment;
 import cn.com.ctop.oa.modules.service.IWechatDepartmentService;
 import com.alibaba.fastjson.JSON;
@@ -19,7 +20,15 @@ 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.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
@@ -73,6 +82,24 @@ public class WechatDepartmentController {
         return result;
     }
 
+    @AutoLog(value = "部门列表List-列表查询")
+    @ApiOperation(value = "部门列表List-列表查询", notes = "部门列表List-列表查询")
+    @PostMapping(value = "/queryList")
+    public Result<List<WechatDepartment>> queryList() {
+        Result<List<WechatDepartment>> result = new Result<>();
+        try {
+            List<WechatDepartment> pageList = wechatDepartmentService.queryList();
+            if (!Check.isNull(pageList)) {
+                result.setResult(pageList);
+                result.setSuccess(true);
+            }
+        } catch (Exception e) {
+            log.error("部门列表List-列表查询 error ", e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
     /**
      * 添加
      *

+ 368 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/controller/WechatNoListController.java

@@ -0,0 +1,368 @@
+package cn.com.ctop.oa.modules.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.oa.modules.entity.WechatAttendance;
+import cn.com.ctop.oa.modules.entity.WechatNoList;
+import cn.com.ctop.oa.modules.service.IWechatNoListService;
+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 com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+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.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+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.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 审批信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-23
+ */
+@Slf4j
+@Api(tags = "审批信息")
+@RestController
+@RequestMapping("/oa/wechatNoList")
+public class WechatNoListController {
+    @Autowired
+    private IWechatNoListService wechatNoListService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param wechatNoList
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "审批信息-分页列表查询")
+    @ApiOperation(value = "审批信息-分页列表查询", notes = "审批信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<WechatNoList>> queryPageList(WechatNoList wechatNoList,
+                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                     HttpServletRequest req) {
+        Result<IPage<WechatNoList>> result = new Result<>();
+        QueryWrapper<WechatNoList> queryWrapper = QueryGenerator.initQueryWrapper(wechatNoList, req.getParameterMap());
+        Page<WechatNoList> page = new Page<WechatNoList>(pageNo, pageSize);
+        IPage<WechatNoList> pageList = wechatNoListService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param wechatNoList
+     * @return
+     */
+    @AutoLog(value = "审批信息-添加")
+    @ApiOperation(value = "审批信息-添加", notes = "审批信息-添加")
+    @PostMapping(value = "/add")
+    public Result<WechatNoList> add(@RequestBody WechatNoList wechatNoList) {
+        Result<WechatNoList> result = new Result<>();
+        try {
+            wechatNoListService.save(wechatNoList);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param wechatNoList
+     * @return
+     */
+    @AutoLog(value = "审批信息-编辑")
+    @ApiOperation(value = "审批信息-编辑", notes = "审批信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<WechatNoList> edit(@RequestBody WechatNoList wechatNoList) {
+        Result<WechatNoList> result = new Result<WechatNoList>();
+        WechatNoList wechatNoListEntity = wechatNoListService.getById(wechatNoList.getId());
+        if (wechatNoListEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = wechatNoListService.updateById(wechatNoList);
+            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 {
+            wechatNoListService.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<WechatNoList> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<WechatNoList> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.wechatNoListService.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<WechatNoList> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<WechatNoList> result = new Result<>();
+        WechatNoList wechatNoList = wechatNoListService.getById(id);
+        if (wechatNoList == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(wechatNoList);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<WechatNoList> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                WechatNoList wechatNoList = JSON.parseObject(deString, WechatNoList.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(wechatNoList, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<WechatNoList> pageList = wechatNoListService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "审批信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, WechatNoList.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("审批信息列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return AbnormalAttendance
+     */
+    @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<WechatNoList> listWechatNoLists = ExcelImportUtil.importExcel(file.getInputStream(), WechatNoList.class, params);
+                wechatNoListService.saveBatch(listWechatNoLists);
+                return Result.ok("文件导入成功!数据行数:" + listWechatNoLists.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("文件导入失败!");
+    }
+
+    /**
+     * 考勤异常记录 导出数据
+     *
+     * @param requestBody
+     * @param response
+     */
+    @PostMapping("/excel")
+    public void getExcelReport(HttpServletResponse response, @RequestBody Map<String, Object> paramsMap) {
+
+        List<WechatAttendance> excelData = wechatNoListService.queryAttendanceData(paramsMap);
+        List<WechatAttendance> overtimeData = wechatNoListService.queryOverTimeData(paramsMap);
+        try {
+            List<List<Object>> excelList = new ArrayList<>();
+            List<List<Object>> overtimeExcelList = new ArrayList<>();
+            if (!excelData.isEmpty()) {
+                excelData.forEach(data -> {
+                    List<Object> temp = new ArrayList<>();
+                    temp.add(data.getUserName());
+                    temp.add(data.getDepartName());
+                    temp.add(data.getCheckinDate());
+                    temp.add(data.getCheckinType());
+                    temp.add(data.getExceptionType());
+                    temp.add(data.getCheckinTime());
+                    temp.add(data.getType());
+                    temp.add(data.getStateDuration());
+                    if (!Check.isNull(data.getStatus())) {
+                        temp.add("1".equals(data.getStatus()) ? "审批中" : "已通过");
+                    } else {
+                        temp.add("");
+                    }
+                    excelList.add(temp);
+                });
+            }
+            if (!overtimeData.isEmpty()) {
+                overtimeData.forEach(data -> {
+                    List<Object> temp = new ArrayList<>();
+                    temp.add(data.getUserName());
+                    temp.add(data.getDepartName());
+                    temp.add(data.getCheckinDate());
+                    temp.add(data.getOvertime());
+                    overtimeExcelList.add(temp);
+                });
+            }
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            String[] titles = {"姓名", "部门", "考勤日期", "考勤类型", "考勤状态", "考勤时间", "审核状态", "状态时长", "审批状态"};
+            String[] overtimeTitles = {"姓名", "部门", "加班日期", "加班时长"};
+            eeu.exportExcelForAttendance(workbook, 0, "异常考勤", titles, excelList);
+            eeu.exportExcel(workbook, 1, "加班考勤", overtimeTitles, overtimeExcelList);
+            HttpUtils.setResponseHeader(response, "考勤记录.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    /**
+     * 考勤异常数据查询(分页)
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "异常考勤数据-分页列表查询")
+    @PostMapping(value = "/selectNoListPage")
+    public Result<PageInfo<WechatAttendance>> selectNoListPage(@RequestBody Map<String, Object> paramsMap) {
+        Result<PageInfo<WechatAttendance>> result = new Result<>();
+        try {
+            PageInfo<WechatAttendance> pageData = wechatNoListService.selectNoListPage(paramsMap);
+            if (!Check.isNull(pageData)) {
+                result.setResult(pageData);
+                result.setSuccess(true);
+            }
+        } catch (Exception e) {
+            log.error("异常考勤数据-分页列表查询 error ", e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 加班考勤数据查询(分页)
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "加班考勤数据-分页列表查询")
+    @PostMapping(value = "/selectOverTimePage")
+    public Result<PageInfo<WechatAttendance>> selectOverTimePage(@RequestBody Map<String, Object> paramsMap) {
+        Result<PageInfo<WechatAttendance>> result = new Result<>();
+        try {
+            PageInfo<WechatAttendance> pageData = wechatNoListService.selectOverTimePage(paramsMap);
+            if (!Check.isNull(pageData)) {
+                result.setResult(pageData);
+                result.setSuccess(true);
+            }
+        } catch (Exception e) {
+            log.error("加班考勤数据-分页列表查询 error ", e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+}

+ 65 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatAttendance.java

@@ -0,0 +1,65 @@
+package cn.com.ctop.oa.modules.entity;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 考勤异常统计数据
+ *
+ * @ClassName WechatAttendance
+ * @Author ZHAOXA
+ * @date 2020-09-24 21:00
+ */
+@Data
+public class WechatAttendance {
+    /**
+     * 员工Id
+     */
+    private String userId;
+    /**
+     * 员工名
+     */
+    private String userName;
+    /**
+     * 部门名
+     */
+    private String departName;
+    /**
+     * 审批状态 1-审批中;2-已通过;
+     */
+    private String status;
+    /**
+     * 部门编号
+     */
+    private String departId;
+    /**
+     * 签到日期
+     */
+    private String checkinDate;
+    /**
+     * 打卡类型
+     */
+    private String checkinType;
+    /**
+     * 异常打卡状态
+     */
+    private String exceptionType;
+    /**
+     * 考勤时间
+     */
+    private String checkinTime;
+    /**
+     * 异常考勤状态
+     */
+    private String type;
+    /**
+     * 状态时长
+     */
+    private String stateDuration;
+    /**
+     * 加班时长
+     */
+    private String overtime;
+
+}

+ 15 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatCheckinData.java

@@ -121,6 +121,12 @@ public class WechatCheckinData {
     @Excel(name = "打卡设备id", width = 15)
     @ApiModelProperty(value = "打卡设备id")
     private String deviceid;
+
+
+    private Integer overtimeOrNot; // 是否加班
+    private Double overtime; // 加班时长
+
+
     /**
      * createTime
      */
@@ -131,4 +137,13 @@ public class WechatCheckinData {
      */
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
+
+    /**
+     * 员工名
+     */
+    private String userName;
+    /**
+     * 部门名
+     */
+    private String departName;
 }

+ 67 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatNoList.java

@@ -0,0 +1,67 @@
+package cn.com.ctop.oa.modules.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   2020-09-23
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_wechat_no_list")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_wechat_no_list对象", description="审批信息")
+public class WechatNoList {
+    
+	/**id*/
+	@TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+	private String id;
+	/**单号*/
+	@Excel(name = "单号", width = 15)
+    @ApiModelProperty(value = "单号")
+	private String spNo;
+	/**单号*/
+	@Excel(name = "1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付", width = 15)
+    @ApiModelProperty(value = "1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付")
+	private String status;
+	/**成员id*/
+	@Excel(name = "成员id", width = 15)
+    @ApiModelProperty(value = "成员id")
+	private String userId;
+	/**type时长*/
+	@Excel(name = "type时长", width = 15)
+    @ApiModelProperty(value = "type时长")
+	private String newDuration;
+	/**1-请假;2-补卡;3-出差;4-外出;5-加班*/
+	@Excel(name = "1-请假;2-补卡;3-出差;4-外出;5-加班", width = 15)
+    @ApiModelProperty(value = "1-请假;2-补卡;3-出差;4-外出;5-加班")
+	private String type;
+	/**开始时间*/
+    @ApiModelProperty(value = "开始时间")
+	private Date newBegin;
+	/**结束时间*/
+    @ApiModelProperty(value = "结束时间")
+	private Date newEnd;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 63 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/enums/SpNoEnum.java

@@ -0,0 +1,63 @@
+package cn.com.ctop.oa.modules.enums;
+
+
+import cn.com.ctop.common.module.utils.Check;
+
+public enum SpNoEnum {
+
+
+    control1("Attendance", "假勤"),
+    control2("Vacation", "请假"),
+    control3("PunchCorrection", "补卡"),
+    type1("1", "请假"),
+    type2("2", "补卡"),
+    type3("3", "出差"),
+    type4("4", "外出"),
+    type5("5", "加班"),
+    vacation1("101","年假"),
+    vacation2("102","事假"),
+    vacation3("103","病假"),
+    vacation4("104","调休"),
+    vacation5("105","婚假"),
+    vacation6("106","产假"),
+    vacation7("107","陪产假"),
+    vacation8("108","其他"),
+    vacation9("109","丧假");
+    private String code;
+    private String name;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static SpNoEnum getSpNoEnum(String code) {
+        if (Check.isNull(code)) {
+            return null;
+        }
+        for (SpNoEnum value : SpNoEnum.values()) {
+            if (value.code.equals(code)) {
+                return value;
+            }
+        }
+        return null;
+    }
+
+
+    private SpNoEnum(String code, String name) {
+        this.code = code;
+        this.name = name;
+
+    }
+}

+ 6 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/WechatCheckinDataMapper.java

@@ -3,6 +3,9 @@ package cn.com.ctop.oa.modules.mapper;
 import cn.com.ctop.oa.modules.entity.WechatCheckinData;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 企业微信用户
  *
@@ -12,4 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface WechatCheckinDataMapper extends BaseMapper<WechatCheckinData> {
 
+    WechatCheckinData queryEntityByMap(Map<String, Object> paramsMap);
+
+    List<WechatCheckinData> selectPageList(Map<String, Object> paramsMap);
 }

+ 3 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/WechatDepartmentMapper.java

@@ -3,6 +3,8 @@ package cn.com.ctop.oa.modules.mapper;
 import cn.com.ctop.oa.modules.entity.WechatDepartment;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * 部门列表
  *
@@ -12,4 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface WechatDepartmentMapper extends BaseMapper<WechatDepartment> {
 
+    List<WechatDepartment> queryList();
 }

+ 23 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/WechatNoListMapper.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.oa.modules.mapper;
+
+import cn.com.ctop.oa.modules.entity.WechatAttendance;
+import cn.com.ctop.oa.modules.entity.WechatNoList;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 审批信息
+ *
+ * @author: jeecg-boot
+ * @date: 2020-09-23
+ * @cersion: V1.0
+ */
+public interface WechatNoListMapper extends BaseMapper<WechatNoList> {
+
+    List<WechatAttendance> queryAttendanceData(Map<String, Object> paramsMap);
+
+    List<WechatAttendance> queryOverTimeData(Map<String, Object> paramsMap);
+
+}

+ 65 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatCheckinDataMapper.xml

@@ -1,5 +1,70 @@
 <?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.oa.modules.mapper.WechatCheckinDataMapper">
+    <select id="queryEntityByMap" resultType="cn.com.ctop.oa.modules.entity.WechatCheckinData">
+        SELECT
+        *
+        FROM ctop_wechat_checkin_data
+        <where>
+            <if test="userId != null and userId != '' ">
+                and user_id = #{userId}
+            </if>
+            <if test="departId != null and departId != '' ">
+                and depart_id = #{departId}
+            </if>
+            <if test="checkinType != null">
+                and checkin_type = #{checkinType}
+            </if>
+            <if test="checkinDate != null ">
+                and checkin_time like concat(#{checkinDate},"%")
+            </if>
+        </where>
+    </select>
 
+
+    <select id="selectPageList" resultType="cn.com.ctop.oa.modules.entity.WechatCheckinData">
+        SELECT
+        ck.id,
+        ck.depart_id,
+        ck.user_id,
+        us.user_name,
+        dpt.depart_name,
+        ck.group_name,
+        ck.checkin_type,
+        ck.exception_type,
+        ck.checkin_time,
+        ck.location_title,
+        ck.location_detail,
+        ck.wifiname,
+        ck.notes,
+        ck.wifimac,
+        ck.mediaids,
+        ck.lat,
+        ck.lng,
+        ck.deviceid,
+        ck.overtime_or_not,
+        ck.overtime,
+        ck.create_time,
+        ck.update_time
+        FROM ctop_wechat_checkin_data as ck
+        LEFT JOIN ctop_wechat_user_list as us ON ck.user_id = us.user_id
+        LEFT JOIN ctop_wechat_department as dpt ON dpt.depart_id = us.depart_id
+        <where>
+            <if test="userId != null and userId != '' ">
+                and ck.user_id = #{userId}
+            </if>
+            <if test="departId != null and departId != '' ">
+                and ck.depart_id = #{departId}
+            </if>
+            <if test="userName != null ">
+                and us.user_name like concat(#{userName},"%")
+            </if>
+            <if test="startTime != null">
+                and ck.checkin_time &gt;= #{startTime}
+            </if>
+            <if test="stopTime != null ">
+                and ck.checkin_time &lt;= #{stopTime}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 6 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatDepartmentMapper.xml

@@ -2,4 +2,10 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.oa.modules.mapper.WechatDepartmentMapper">
 
+
+    <select id="queryList" resultType="cn.com.ctop.oa.modules.entity.WechatDepartment">
+        SELECT
+            *
+        FROM ctop_wechat_department
+    </select>
 </mapper>

+ 89 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatNoListMapper.xml

@@ -0,0 +1,89 @@
+<?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.oa.modules.mapper.WechatNoListMapper">
+
+    <select id="queryAttendanceData" resultType="cn.com.ctop.oa.modules.entity.WechatAttendance">
+        SELECT DISTINCT
+        us.user_id AS userId,
+        us.user_name AS userName,
+        dpt.depart_id AS departId,
+        dpt.depart_name AS departName,
+        DATE_FORMAT(ck.checkin_time,'%Y-%m-%d') AS checkinDate,
+        ck.checkin_type AS checkinType,
+        ck.exception_type AS exceptionType,
+        nl.status as status,
+        DATE_FORMAT(ck.checkin_time, '%Y-%m-%d %H:%i:%s') AS checkinTime,
+        case when nl.type !='' THEN nl.type
+        when ck.checkin_type ='上班打卡' AND exception_type ='时间异常' then '迟到'
+        when ck.checkin_type ='下班打卡' AND exception_type ='时间异常' then '早退'
+        end AS type,
+        case when nl.type!=''and nl.type !='补卡' then CONCAT(nl.new_duration,' h')
+        when ck.checkin_type ='上班打卡'and ck.exception_type ='时间异常' then
+        CONCAT(TIMESTAMPDIFF(MINUTE,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d '),'09:30:00'),'%Y-%m-%d
+        %H:%i:%s'),ck.checkin_time),' min')
+        when ck.checkin_type ='下班打卡'and ck.exception_type ='时间异常' then
+        CONCAT(TIMESTAMPDIFF(MINUTE,ck.checkin_time,DATE_FORMAT(CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d
+        '),'19:00:00'),'%Y-%m-%d %H:%i:%s')),' min')
+        end AS stateDuration
+        FROM ctop_wechat_user_list AS us
+        LEFT JOIN ctop_wechat_department AS dpt ON us.depart_id = dpt.depart_id
+        LEFT JOIN ctop_wechat_checkin_data AS ck ON ck.user_id = us.user_id
+        LEFT JOIN ctop_wechat_no_list AS nl ON nl.user_id = us.user_id and
+        nl.new_begin Like CONCAT(DATE_FORMAT(ck.checkin_time,'%Y-%m-%d'),'%')
+        WHERE ck.exception_type!='' and ISNULL(ck.exception_type)= 0
+        <if test="userId != null and userId != '' ">
+            and us.user_id = #{userId}
+        </if>
+        <if test="userName != null and userName != '' ">
+            and us.user_Name LIKE CONCAT("%",#{userName},"%")
+        </if>
+        <if test="departId != null and departId != '' ">
+            and dpt.depart_id = #{departId}
+        </if>
+        <if test="departName != null and departName != '' ">
+            and dpt.depart_name LIKE CONCAT("%",#{departName},"%")
+        </if>
+        <if test="startTime != null">
+            and ck.checkin_time &gt;= #{startTime}
+        </if>
+        <if test="stopTime != null ">
+            and ck.checkin_time &lt;= #{stopTime}
+        </if>
+        order by us.depart_id,us.user_name ,ck.checkin_time
+    </select>
+
+
+    <select id="queryOverTimeData" resultType="cn.com.ctop.oa.modules.entity.WechatAttendance">
+        SELECT
+        us.user_id AS userId,
+        us.user_name AS userName,
+        dpt.depart_id AS departId,
+        dpt.depart_name AS departName,
+        DATE_FORMAT(ck.checkin_time,'%Y-%m-%d') AS checkinDate,
+        CONCAT(ck.overtime,' h') AS overtime
+        FROM ctop_wechat_checkin_data as ck
+        LEFT JOIN ctop_wechat_user_list as us ON ck.user_id = us.user_id
+        LEFT JOIN ctop_wechat_department as dpt ON dpt.depart_id = us.depart_id
+        WHERE ck.overtime_or_not = 1
+        <if test="userId != null and userId != '' ">
+            and us.user_id = #{userId}
+        </if>
+        <if test="userName != null and userName != '' ">
+            and us.user_Name LIKE CONCAT("%",#{userName},"%")
+        </if>
+        <if test="departId != null and departId != '' ">
+            and dpt.depart_id = #{departId}
+        </if>
+        <if test="departName != null and departName != '' ">
+            and dpt.depart_name LIKE CONCAT("%",#{departName},"%")
+        </if>
+        <if test="startTime != null">
+            and ck.checkin_time &gt;= #{startTime}
+        </if>
+        <if test="stopTime != null ">
+            and ck.checkin_time &lt;= #{stopTime}
+        </if>
+        order by us.depart_id,us.user_name ,ck.checkin_time
+    </select>
+
+</mapper>

+ 5 - 1
module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatCheckinDataService.java

@@ -2,6 +2,9 @@ package cn.com.ctop.oa.modules.service;
 
 import cn.com.ctop.oa.modules.entity.WechatCheckinData;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+
+import java.util.Map;
 
 /**
  * @Description: 企业微信用户
@@ -10,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @Version: V1.0
  */
 public interface IWechatCheckinDataService extends IService<WechatCheckinData> {
-    void getCheckinData();
+    void getCheckinData(String starttime, String endtime);
 
+    PageInfo<WechatCheckinData> selectPageList(Map<String, Object> paramsMap);
 }

+ 4 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatDepartmentService.java

@@ -3,6 +3,8 @@ package cn.com.ctop.oa.modules.service;
 import cn.com.ctop.oa.modules.entity.WechatDepartment;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * @Description: 部门列表
  * @Author: jeecg-boot
@@ -11,4 +13,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IWechatDepartmentService extends IService<WechatDepartment> {
     void getDepartment();
+
+    List<WechatDepartment> queryList();
 }

+ 49 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatNoListService.java

@@ -0,0 +1,49 @@
+package cn.com.ctop.oa.modules.service;
+
+import cn.com.ctop.oa.modules.entity.WechatAttendance;
+import cn.com.ctop.oa.modules.entity.WechatNoList;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 审批信息
+ * @Author: jeecg-boot
+ * @Date: 2020-09-23
+ * @Version: V1.0
+ */
+public interface IWechatNoListService extends IService<WechatNoList> {
+    /**
+     * 批量获取审批单号,单号!
+     *
+     * @param page      查询起始数,分页查询游标,默认为0
+     * @param starttime 审批单提交的时间范围,开始时间,UNix时间戳
+     * @param endtime   批单提交的时间范围,结束时间,Unix时间戳
+     * @return com.alibaba.fastjson.JSONObject
+     * @throws
+     * @author ZHAOXA
+     */
+    JSONObject getNoList(Integer page, String starttime, String endtime);
+
+    /**
+     * 审批申请数据入库
+     *
+     * @param starttime 审批单提交的时间范围,开始时间,UNix时间戳
+     * @param endtime   批单提交的时间范围,结束时间,Unix时间戳
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void getNoDateByNo(String starttime, String endtime);
+
+    List<WechatAttendance> queryAttendanceData(Map<String, Object> paramsMap);
+
+    List<WechatAttendance> queryOverTimeData(Map<String, Object> paramsMap);
+
+    PageInfo<WechatAttendance> selectNoListPage(Map<String, Object> paramsMap);
+
+    PageInfo<WechatAttendance> selectOverTimePage(Map<String, Object> paramsMap);
+}

+ 11 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatTokenService.java

@@ -4,5 +4,16 @@ import java.util.Map;
 
 public interface IWechatTokenService {
     Map<String, Object> getQYWXAccessToken();
+
     Map<String, Object> getOAAccessToken();
+
+    /**
+     * 审批token
+     *
+     * @return java.util.Map<java.lang.String, java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     * @Param []
+     */
+    Map<String, Object> getApprovaAccessToken();
 }

+ 0 - 1
module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatUserListService.java

@@ -11,5 +11,4 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IWechatUserListService extends IService<WechatUserList> {
     void getUserList();
-
 }

+ 70 - 35
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatCheckinDataServiceImpl.java

@@ -12,16 +12,22 @@ import cn.com.ctop.oa.modules.service.IWechatUserListService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.xxl.job.core.enums.NoEn;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import static org.jeecg.common.constant.GeneralConstant.*;
+
 /**
- * 企业微信用户
+ * 员工考勤
  *
  * @author jeecg-boot
  * @version V1.0
@@ -34,86 +40,115 @@ public class WechatCheckinDataServiceImpl extends ServiceImpl<WechatCheckinDataM
     private IWechatTokenService tokenService;
     @Autowired
     private IWechatUserListService userListService;
+    @Autowired
+    private WechatCheckinDataMapper wechatCheckinDataMapper;
 
     @Override
-    public void getCheckinData() {
+    public void getCheckinData(String starttime, String endtime) {
         try {
             Map<String, Object> qywxAccessToken = tokenService.getOAAccessToken();
-            System.err.println(qywxAccessToken);
-            if ((Integer) qywxAccessToken.get("code") != 0) {
-                log.error("企业微信获取token失败,返回信息:{}", qywxAccessToken.get("message"));
-                throw new Exception("企业微信获取token失败");
+            if ((Integer) qywxAccessToken.get(CODE) != 0) {
+                log.error("员工考勤获取token失败,返回信息:{}", qywxAccessToken.get(MESSAGE));
+                throw new Exception("员工考勤获取token失败");
             }
-
             List<WechatUserList> list = userListService.list();
             if (Check.isNull(list)) {
                 return;
             }
-
-
-            //  params.put("access_token", (String) qywxAccessToken.get("accessToken"));
             for (WechatUserList userList : list) {
-                // params.remove("useridlist");
                 JSONObject params = new JSONObject();
-
                 String userId = userList.getUserId();
                 String departId = userList.getDepartId();
                 params.put("opencheckindatatype", 3);
-
                 JSONArray userArr = new JSONArray();
-
                 userArr.add(userId);
                 params.put("useridlist", userArr);
-                params.put("starttime", 1598889600);
-                params.put("endtime", 1600099200);
-
-
-                String resultStr = HttpUtils.httpPostRequestTest(QYWxConstant.QYWX_CHECKIN_DATA + "?access_token=" + qywxAccessToken.get("accessToken"), params.toJSONString(), null);
+                params.put(API_START_TIME, starttime);
+                params.put(API_END_TIME, endtime);
+                String resultStr = HttpUtils.httpPostRequestTest(QYWxConstant.QYWX_CHECKIN_DATA + "?access_token=" + qywxAccessToken.get(ACCESS_TOKEN), params.toJSONString(), null);
                 JSONObject resultJson = JSONObject.parseObject(resultStr);
-                System.err.println(resultJson);
-                Integer errcode = resultJson.getInteger("errcode");
-                if (errcode == 0) {
+                if (resultJson.getInteger(ERR_CODE) == 0) {
                     JSONArray checkindata = resultJson.getJSONArray("checkindata");
                     if (!Check.isNull(checkindata)) {
+                        StringBuffer buf = null;
+                        String checkinType = "";
+                        String checkinTypeCode = "";
                         for (int i = 0; i < checkindata.size(); i++) {
                             JSONObject jsonObject = checkindata.getJSONObject(i);
+                            if ("JiLei".equals(userId)) {
+                                System.out.println(jsonObject);
+                            }
                             if (!Check.isNull(jsonObject)) {
                                 WechatCheckinData checkinData = new WechatCheckinData();
+                                checkinType = jsonObject.getString("checkin_type");
+                                //1上班,2下班
+                                checkinTypeCode = "上班打卡".equals(checkinType) ? NoEn.NO1.valueStr() : NoEn.NO2.valueStr();
+                                //下班打卡时间
+                                Long checkinTimeStamp = jsonObject.getLong("checkin_time");
+                                Date checkDate = DateUtils.stampToTime(checkinTimeStamp);
+                                String dateStr = DateUtils.formatDate(checkDate);
+                                long dateLong = DateUtils.timeToStamp(dateStr + DAY_BEGIN);
+                                buf = new StringBuffer();
+                                String id = buf.append(userId).append("_").append(checkinTypeCode).append("_").append(dateLong).toString();
+                                checkinData.setId(id);
                                 checkinData.setDepartId(departId);
                                 checkinData.setUserId(userId);
-                                java.util.Date checkDate = DateUtils.stampToTime(jsonObject.getLong("checkin_time"));
+                                checkinData.setCheckinType(checkinType);
                                 checkinData.setCheckinTime(checkDate);
+                                Long dateStamp = DateUtils.timeToStamp(dateStr + " 21:30:00"); // 每天九点半时间戳
+                                if (checkinTimeStamp >= dateStamp) {
+                                    checkinData.setOvertimeOrNot(1);
+                                    String overtimeStr = DateUtils.formatDate(checkDate) + " 19:00:00";
+                                    Long overtimeStamp = DateUtils.timeToStamp(overtimeStr); // 每天九点半时间戳
+                                    Double overtime = Double.valueOf(checkinTimeStamp - overtimeStamp) / 3600;
+                                    checkinData.setOvertime(overtime);
+                                }
                                 checkinData.setWifiname(jsonObject.getString("wifiname"));
                                 checkinData.setNotes(jsonObject.getString("notes"));
                                 checkinData.setLat(jsonObject.getString("lng"));
                                 checkinData.setLocationDetail(jsonObject.getString("location_detail"));
                                 checkinData.setGroupName(jsonObject.getString("groupname"));
                                 checkinData.setDeviceid(jsonObject.getString("deviceid"));
-                                checkinData.setCheckinType(jsonObject.getString("checkin_type"));
                                 checkinData.setExceptionType(jsonObject.getString("exception_type"));
                                 checkinData.setLocationTitle(jsonObject.getString("location_title"));
                                 checkinData.setWifimac(jsonObject.getString("wifimac"));
                                 checkinData.setMediaids(jsonObject.getJSONArray("mediaids").toJSONString());
                                 checkinData.setLat(jsonObject.getString("lat"));
-                                this.save(checkinData);
-
+                                this.saveOrUpdate(checkinData);
                             }
                         }
-
                     }
-
-
                 } else {
-                    //     throw new Exception("企业微信获取部门列表");
-
+                    log.error("获取打卡数据异常");
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("员工考勤入库异常,", e);
         }
-
-
     }
 
-
+    @Override
+    public PageInfo<WechatCheckinData> selectPageList(Map<String, Object> paramsMap) {
+        Integer pageNo = (Integer) paramsMap.get(PAGE_NO);
+        if (null == pageNo || pageNo == 0) {
+            pageNo = 1;
+        }
+        Integer pageSize = (Integer) paramsMap.get(PAGE_SIZE);
+        if (null == pageSize || pageSize == 0) {
+            pageSize = 10;
+        }
+        String startTime = (String) paramsMap.get(START_TIME);
+        if (!Check.isNull(startTime)) {
+            startTime += DAY_BEGIN;
+            paramsMap.put(START_TIME, startTime);
+        }
+        String stopTime = (String) paramsMap.get(STOP_TIME);
+        if (!Check.isNull(stopTime)) {
+            stopTime += DAY_END;
+            paramsMap.put(STOP_TIME, stopTime);
+        }
+        PageHelper.startPage(pageNo, pageSize);
+        List<WechatCheckinData> list = wechatCheckinDataMapper.selectPageList(paramsMap);
+        return new PageInfo<>(list);
+    }
 }

+ 5 - 11
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatDepartmentServiceImpl.java

@@ -16,6 +16,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;
 import java.util.TreeMap;
 
@@ -34,7 +35,6 @@ public class WechatDepartmentServiceImpl extends ServiceImpl<WechatDepartmentMap
     @Autowired
     private WechatDepartmentMapper wechatDepartmentMapper;
 
-
     @Override
     public void getDepartment() {
         try {
@@ -43,11 +43,8 @@ public class WechatDepartmentServiceImpl extends ServiceImpl<WechatDepartmentMap
                 log.error("企业微信获取token失败,返回信息:{}", qywxAccessToken.get("message"));
                 throw new Exception("企业微信获取token失败");
             }
-
-
             TreeMap<String, Object> params = new TreeMap<>();
             params.put("access_token", qywxAccessToken.get("accessToken"));
-
             String resultStr = HttpUtils.httpGetRequest(QYWxConstant.QYWX_DEPART_LIST, null, params);
             JSONObject resultJson = JSONObject.parseObject(resultStr);
             System.err.println(resultJson);
@@ -71,22 +68,19 @@ public class WechatDepartmentServiceImpl extends ServiceImpl<WechatDepartmentMap
                             depart.setParentId(departJson.getString("parentid"));
                             depart.setDepartOrder(departJson.getString("order"));
                             wechatDepartmentMapper.insert(depart);
-
                         }
-
                     }
-
                 }
-
-
             } else {
                 throw new Exception("企业微信获取部门列表");
-
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
+    }
 
-
+    @Override
+    public List<WechatDepartment> queryList() {
+        return wechatDepartmentMapper.queryList();
     }
 }

+ 388 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatNoListServiceImpl.java

@@ -0,0 +1,388 @@
+package cn.com.ctop.oa.modules.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.oa.modules.constant.QYWxConstant;
+import cn.com.ctop.oa.modules.entity.WechatAttendance;
+import cn.com.ctop.oa.modules.entity.WechatCheckinData;
+import cn.com.ctop.oa.modules.entity.WechatNoList;
+import cn.com.ctop.oa.modules.enums.SpNoEnum;
+import cn.com.ctop.oa.modules.mapper.WechatCheckinDataMapper;
+import cn.com.ctop.oa.modules.mapper.WechatNoListMapper;
+import cn.com.ctop.oa.modules.service.IWechatNoListService;
+import cn.com.ctop.oa.modules.service.IWechatTokenService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.xxl.job.core.enums.NoEn;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.jeecg.common.constant.GeneralConstant.*;
+
+/**
+ * 审批信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-23
+ */
+@Service
+@Slf4j
+public class WechatNoListServiceImpl extends ServiceImpl<WechatNoListMapper, WechatNoList> implements IWechatNoListService {
+    @Autowired
+    private IWechatTokenService tokenService;
+    @Autowired
+    private WechatNoListMapper wechatNoListMapper;
+    @Autowired
+    private WechatCheckinDataMapper wechatCheckinDataMapper;
+
+    /**
+     * 获取审批token
+     *
+     * @return java.lang.String
+     * @throws
+     * @author ZHAOXA
+     * @Param []
+     */
+    private String getToken() throws Exception {
+        Map<String, Object> approvaAccessToken = tokenService.getApprovaAccessToken();
+        if ((Integer) approvaAccessToken.get("code") != 0) {
+            log.error("企业微信获取token失败,返回信息:{}", approvaAccessToken.get("message"));
+            throw new Exception("企业微信获取token失败");
+        }
+        return approvaAccessToken.get("accessToken").toString();
+    }
+
+    @Override
+    public JSONObject getNoList(Integer page, String starttime, String endtime) {
+        try {
+            JSONObject params = new JSONObject();
+            params.put("starttime", starttime);
+            params.put("endtime", endtime);
+            params.put("cursor", page);
+            params.put("size", 100);
+            StringBuffer buf = new StringBuffer();
+            //批量获取审批单号 URL
+            buf.append(QYWxConstant.APP_ROVAL_INFO).append("?access_token=").append(getToken());
+            System.err.println(buf.toString());
+            String resultStr = HttpUtils.httpPostRequestTest(buf.toString(), params.toJSONString(), null);
+            JSONObject resultJson = JSONObject.parseObject(resultStr);
+            System.err.println(resultJson);
+            Integer errcode = resultJson.getInteger("errcode");
+            if (errcode == 0) {
+                return resultJson;
+            } else {
+                throw new Exception("批量获取审批单号");
+            }
+        } catch (Exception e) {
+            log.error("批量获取审批单号异常", e);
+        }
+        return new JSONObject();
+    }
+
+    //递归获取审批数据
+    private JSONArray getAllNoList(Integer page, JSONArray spNoList, String starttime, String endtime) {
+        JSONObject data = getNoList(page, starttime, endtime);
+        spNoList.addAll(data.getJSONArray("sp_no_list"));
+        Integer nextCursor = data.getInteger("next_cursor");
+        if (!Check.isNull(nextCursor)) {
+            return getAllNoList(nextCursor, spNoList, starttime, endtime);
+        }
+        return spNoList;
+    }
+
+    @Override
+    public void getNoDateByNo(String starttime, String endtime) {
+        Map<String, Object> returnMap = new HashMap<>();
+        try {
+            Integer page = 0;
+            JSONArray noList = getAllNoList(page, new JSONArray(), starttime, endtime);
+            boolean sleep = false;
+            if (noList.size() > 600) {
+                sleep = true;
+            }
+            if (!Check.isNull(noList)) {
+                StringBuffer buf = new StringBuffer();
+                //获取审批申请详情 URL;
+                buf.append(QYWxConstant.APP_ROVAL_DETAIL).append("?access_token=").append(getToken());
+                String userId = null;
+                Map<String, String> parameterMap = null;
+                for (Object spNo : noList) {
+                    parameterMap = new HashMap<>();
+                    //接口频率限制 600次/分钟
+                    if (sleep) {
+                        Thread.sleep(100);
+                    }
+                    JSONObject params = new JSONObject();
+                    params.put("sp_no", spNo);
+                    String resultStr = HttpUtils.httpPostRequestTest(buf.toString(), params.toJSONString(), null);
+                    JSONObject resultJson = JSONObject.parseObject(resultStr);
+                    Integer errcode = resultJson.getInteger("errcode");
+                    if (errcode == 0) {
+                        JSONObject info = resultJson.getJSONObject("info");
+                        String spStatus = info.getString("sp_status");
+                        String spName = info.getString("sp_name");
+                        /**申请单状态:1-审批中;2-已通过,只记录这两种状态数据
+                         * 而且只记录请假、打卡补卡类型
+                         **/
+                        boolean statusisOK = "2".equals(spStatus) || "1".equals(spStatus);
+                        boolean typeisOK = spName.contains("打卡补卡") || spName.contains("请假") || spName.contains("外出") || spName.contains("出差");
+                        if (statusisOK && typeisOK) {
+                            JSONObject applyer = info.getJSONObject("applyer");
+                            if (!Check.isNull(applyer)) {
+                                userId = applyer.getString("userid");
+                                if ("LiuJing".equals(userId)) {
+                                    System.out.println(info);
+                                }
+                            }
+                            //审批申请数据
+                            JSONObject applyData = info.getJSONObject("apply_data");
+                            //获取审批状态数据
+                            getParameterMap(applyData, parameterMap);
+                            WechatNoList noEntity = new WechatNoList();
+                            noEntity.setUserId(userId);
+                            noEntity.setSpNo(spNo.toString());
+                            noEntity.setStatus(spStatus);
+                            if (!Check.isNull(parameterMap.get("newBegin"))) {
+                                noEntity.setNewBegin(DateUtils.stampToTime(Long.valueOf(parameterMap.get("newBegin"))));
+                            }
+                            if (!Check.isNull(parameterMap.get("newEnd"))) {
+                                noEntity.setNewEnd(DateUtils.stampToTime(Long.valueOf(parameterMap.get("newEnd"))));
+                            }
+                            noEntity.setType(parameterMap.get(TYPE));
+                            noEntity.setNewDuration(parameterMap.get("newDuration"));
+                            wechatNoListMapper.insert(noEntity);
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            returnMap.put("code", -1);
+            returnMap.put("message", "系统错误");
+            log.error("审批异常", e);
+        }
+    }
+
+    /**
+     * 获取审批状态数据
+     *
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     * @Param [applyData, parameterMap]
+     */
+    private void getParameterMap(JSONObject applyData, Map<String, String> parameterMap) {
+        String control = null;
+        if (!Check.isNull(applyData)) {
+            //审批申请详情,由多个表单控件及其内容组成
+            JSONArray contents = applyData.getJSONArray("contents");
+            if (!Check.isNull(contents)) {
+                for (int i = 0; i < contents.size(); i++) {
+                    //获取content 对象数据
+                    JSONObject contentEntity = contents.getJSONObject(i);
+                    if (!Check.isNull(contentEntity)) {
+                        control = contentEntity.getString("control");
+                        //如果补卡组件为PunchCorrection,直接判断为补卡
+                        if (SpNoEnum.control3.getCode().equals(control)) {
+                            JSONObject value = contentEntity.getJSONObject(VALUE);
+                            if (!Check.isNull(value)) {
+                                JSONObject punch = value.getJSONObject("punch_correction");
+                                if (!Check.isNull(punch)) {
+                                    parameterMap.put(TYPE, SpNoEnum.type2.getName());
+                                    parameterMap.put("newBegin", punch.getString("time"));
+                                    parameterMap.put("newEnd", punch.getString("time"));
+                                }
+                            }
+                            //假勤组件-请假组件 Vacation
+                        } else if (SpNoEnum.control2.getCode().equals(control)) {
+                            JSONObject value = contentEntity.getJSONObject(VALUE);
+                            if (!Check.isNull(value)) {
+                                JSONObject vacation = value.getJSONObject("vacation");
+                                if (!Check.isNull(vacation)) {
+                                    JSONObject selector = vacation.getJSONObject("selector");
+                                    if (!Check.isNull(selector)) {
+                                        getVacation(selector, parameterMap);
+                                    }
+                                    JSONObject attendance = vacation.getJSONObject("attendance");
+                                    if (!Check.isNull(attendance)) {
+                                        getTimeData(attendance, parameterMap);
+                                    }
+                                }
+                            }
+                            //假勤组件-出差/外出/加班组件Attendance
+                        } else if (SpNoEnum.control1.getCode().equals(control)) {
+                            JSONObject value = contentEntity.getJSONObject(VALUE);
+                            if (!Check.isNull(value)) {
+                                JSONObject attendance = value.getJSONObject("attendance");
+                                if (!Check.isNull(attendance)) {
+                                    getTimeData(attendance, parameterMap);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 获取组件中的假勤类型,假勤开始、结束时间以及时长。
+     *
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     * @Param [attendance, parameterMap]
+     */
+    private void getTimeData(JSONObject attendance, Map<String, String> parameterMap) {
+        String type = attendance.getString(TYPE);
+        //假勤类型,排除类型为1的请假,因为有具体的请假类型,例如:年假,事假等具体类型
+        if (!NoEn.NO1.valueStr().equals(type)) {
+            parameterMap.put(TYPE, SpNoEnum.getSpNoEnum(type).getName());
+        }
+        JSONObject dateRange = attendance.getJSONObject("date_range");
+        if (!Check.isNull(dateRange)) {
+            parameterMap.put("newBegin", dateRange.getString("new_begin"));
+            parameterMap.put("newEnd", dateRange.getString("new_end"));
+            BigDecimal duration = dateRange.getBigDecimal("new_duration");
+            if (!Check.isNull(duration)) {
+                //除以3600,取小时数
+                BigDecimal second = new BigDecimal(3600);
+                parameterMap.put("newDuration", String.valueOf(duration.divide(second, 1, 4)));
+            }
+        }
+    }
+
+    /**
+     * 获取假期类型
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void getVacation(JSONObject selector, Map<String, String> parameterMap) {
+        JSONArray options = selector.getJSONArray("options");
+        if (!Check.isNull(options)) {
+            for (int j = 0; j < options.size(); j++) {
+                JSONObject option = options.getJSONObject(j);
+                JSONArray values = option.getJSONArray(VALUE);
+                if (!Check.isNull(values)) {
+                    for (int k = 0; k < values.size(); k++) {
+                        JSONObject val = values.getJSONObject(k);
+                        parameterMap.put(TYPE, val.getString("text"));
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public List<WechatAttendance> queryAttendanceData(Map<String, Object> paramsMap) {
+        finishingTime(paramsMap);
+        List<WechatAttendance> list = wechatNoListMapper.queryAttendanceData(paramsMap);
+        if (!Check.isNull(list)) {
+            checkOverTimeData(list);
+        }
+        return list;
+    }
+
+    /**
+     * 整理时间
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void finishingTime(Map<String, Object> paramsMap) {
+        String startTime = (String) paramsMap.get(START_TIME);
+        if (!Check.isNull(startTime)) {
+            startTime += DAY_BEGIN;
+            paramsMap.put(START_TIME, startTime);
+        }
+        String stopTime = (String) paramsMap.get(STOP_TIME);
+        if (!Check.isNull(stopTime)) {
+            stopTime += DAY_END;
+            paramsMap.put(STOP_TIME, stopTime);
+        }
+    }
+
+    @Override
+    public List<WechatAttendance> queryOverTimeData(Map<String, Object> paramsMap) {
+        finishingTime(paramsMap);
+        return wechatNoListMapper.queryOverTimeData(paramsMap);
+    }
+
+    @Override
+    public PageInfo<WechatAttendance> selectNoListPage(Map<String, Object> paramsMap) {
+        finishingTime(paramsMap);
+        Integer pageNo = (Integer) paramsMap.get(PAGE_NO);
+        if (null == pageNo || pageNo == 0) {
+            pageNo = NoEn.NO1.valueInt();
+        }
+        Integer pageSize = (Integer) paramsMap.get(PAGE_SIZE);
+        if (null == pageSize || pageSize == 0) {
+            pageSize = NoEn.NO10.valueInt();
+        }
+        PageHelper.startPage(pageNo, pageSize);
+        List<WechatAttendance> list = wechatNoListMapper.queryAttendanceData(paramsMap);
+        if (!Check.isNull(list)) {
+            checkOverTimeData(list);
+        }
+        return new PageInfo<>(list);
+    }
+
+    /**
+     * 筛选10:30以后打卡的迟到数据,判断前一天是否加班,更新迟到时长
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private void checkOverTimeData(List<WechatAttendance> list) {
+        for (WechatAttendance attendance : list) {
+            if ("迟到".equals(attendance.getType())) {
+                Integer dur = Integer.valueOf(attendance.getStateDuration().replace(" min", ""));
+                if (dur - 60 >= 0) {
+                    String checkinDate = attendance.getCheckinDate();
+                    String lastDay = DateUtils.getLastDay(checkinDate);
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("userId", attendance.getUserId());
+                    map.put("checkinDate", lastDay);
+                    map.put("checkinType", "下班打卡");
+                    WechatCheckinData data = wechatCheckinDataMapper.queryEntityByMap(map);
+                    if (!Check.isNull(data) && 1 == data.getOvertimeOrNot()) {
+                        attendance.setStateDuration((dur - 60) + " min");
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public PageInfo<WechatAttendance> selectOverTimePage(Map<String, Object> paramsMap) {
+        finishingTime(paramsMap);
+        Integer pageNo = (Integer) paramsMap.get("pageNo");
+        if (null == pageNo || pageNo == 0) {
+            pageNo = 1;
+        }
+        Integer pageSize = (Integer) paramsMap.get("pageSize");
+        if (null == pageSize || pageSize == 0) {
+            pageSize = 10;
+        }
+        PageHelper.startPage(pageNo, pageSize);
+        List<WechatAttendance> list = wechatNoListMapper.queryOverTimeData(paramsMap);
+        return new PageInfo<>(list);
+    }
+}

+ 30 - 7
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatTokenServiceImpl.java

@@ -14,7 +14,6 @@ import java.util.TreeMap;
 public class WechatTokenServiceImpl implements IWechatTokenService {
     public Map<String, Object> getQYWXAccessToken() {
         Map<String, Object> returnMap = new HashMap<>();
-
         try {
             TreeMap<String, Object> params = new TreeMap<>();
             params.put("corpid", QYWxConstant.QYWX_CORP_ID);
@@ -26,8 +25,6 @@ public class WechatTokenServiceImpl implements IWechatTokenService {
             if (errcode == 0) {
                 returnMap.put("code", 0);
                 returnMap.put("accessToken", resultJson.getString("access_token"));
-
-
             } else {
                 returnMap.put("code", errcode);
                 returnMap.put("message", resultJson.getString("errmsg"));
@@ -36,13 +33,11 @@ public class WechatTokenServiceImpl implements IWechatTokenService {
             returnMap.put("code", -1);
             returnMap.put("message", "系统错误");
         }
-
         return returnMap;
     }
 
     public Map<String, Object> getOAAccessToken() {
         Map<String, Object> returnMap = new HashMap<>();
-
         try {
             TreeMap<String, Object> params = new TreeMap<>();
             params.put("corpid", QYWxConstant.QYWX_CORP_ID);
@@ -54,8 +49,6 @@ public class WechatTokenServiceImpl implements IWechatTokenService {
             if (errcode == 0) {
                 returnMap.put("code", 0);
                 returnMap.put("accessToken", resultJson.getString("access_token"));
-
-
             } else {
                 returnMap.put("code", errcode);
                 returnMap.put("message", resultJson.getString("errmsg"));
@@ -64,7 +57,37 @@ public class WechatTokenServiceImpl implements IWechatTokenService {
             returnMap.put("code", -1);
             returnMap.put("message", "系统错误");
         }
+        return returnMap;
+    }
 
+    /**
+     * @return java.util.Map<java.lang.String, java.lang.Object>
+     * @throws 获取审批
+     * @author ZHAOXA
+     * @Param []
+     */
+    @Override
+    public Map<String, Object> getApprovaAccessToken() {
+        Map<String, Object> returnMap = new HashMap<>();
+        try {
+            TreeMap<String, Object> params = new TreeMap<>();
+            params.put("corpid", QYWxConstant.QYWX_CORP_ID);
+            params.put("corpsecret", QYWxConstant.QYWX_APPROVA_CORP_SECRET);
+            String resultStr = HttpUtils.httpGetRequest(QYWxConstant.QYWX_API_URL + QYWxConstant.QYWX_GET_TOKEN, null, params);
+            //System.out.println(resultStr);
+            JSONObject resultJson = JSONObject.parseObject(resultStr);
+            Integer errcode = resultJson.getInteger("errcode");
+            if (errcode == 0) {
+                returnMap.put("code", 0);
+                returnMap.put("accessToken", resultJson.getString("access_token"));
+            } else {
+                returnMap.put("code", errcode);
+                returnMap.put("message", resultJson.getString("errmsg"));
+            }
+        } catch (Exception e) {
+            returnMap.put("code", -1);
+            returnMap.put("message", "系统错误");
+        }
         return returnMap;
     }
 

+ 0 - 14
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatUserListServiceImpl.java

@@ -30,7 +30,6 @@ import java.util.TreeMap;
 @Service
 @Slf4j
 public class WechatUserListServiceImpl extends ServiceImpl<WechatUserListMapper, WechatUserList> implements IWechatUserListService {
-
     @Autowired
     private IWechatTokenService tokenService;
     @Autowired
@@ -44,17 +43,12 @@ public class WechatUserListServiceImpl extends ServiceImpl<WechatUserListMapper,
                 log.error("企业微信获取token失败,返回信息:{}", qywxAccessToken.get("message"));
                 throw new Exception("企业微信获取token失败");
             }
-
-
             TreeMap<String, Object> params = new TreeMap<>();
             params.put("access_token", qywxAccessToken.get("accessToken"));
-
-
             List<WechatDepartment> list = departmentService.list();
             if (Check.isNull(list)) {
                 return;
             }
-
             for (WechatDepartment department : list) {
                 params.remove("department_id");
                 String departId = department.getDepartId();
@@ -77,20 +71,12 @@ public class WechatUserListServiceImpl extends ServiceImpl<WechatUserListMapper,
                                 userList.setUserName(userJson.getString("name"));
                                 this.saveOrUpdate(userList);
                             }
-
                         }
-
                     }
-
-
                 } else {
                     throw new Exception("企业微信获取用户列表失败");
-
                 }
-
             }
-
-
         } catch (Exception e) {
             e.printStackTrace();
         }