zhaoxian 4 年之前
父节点
当前提交
c6dbde1659
共有 17 个文件被更改,包括 1059 次插入80 次删除
  1. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 3 3
      jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties
  3. 31 17
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  4. 99 34
      module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  5. 3 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/constant/QYWxConstant.java
  6. 303 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/controller/WechatNoListController.java
  7. 57 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatAttendance.java
  8. 67 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/entity/WechatNoList.java
  9. 63 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/enums/SpNoEnum.java
  10. 21 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/WechatNoListMapper.java
  11. 47 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/mapper/xml/WechatNoListMapper.xml
  12. 43 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatNoListService.java
  13. 11 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatTokenService.java
  14. 1 14
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatCheckinDataServiceImpl.java
  15. 279 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatNoListServiceImpl.java
  16. 30 7
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatTokenServiceImpl.java
  17. 0 5
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatUserListServiceImpl.java

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

@@ -174,6 +174,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/rest/script/*", "anon");
         filterChainDefinitionMap.put("/ctop/checkTaskList/*", "anon");
         filterChainDefinitionMap.put("/ctop/report/bytedance/*", "anon");
+        filterChainDefinitionMap.put("/oa/wechatNoList/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 3 - 3
jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties

@@ -1,8 +1,8 @@
 #mysql
 diver_name=com.mysql.jdbc.Driver
-url=jdbc:mysql://127.0.0.1:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8
-username=root
-password=123456
+url=jdbc:mysql://139.186.31.213:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8
+username=hcst
+password=hcst2020
 database_name=jeecg-boot
 #oracle
 #diver_name=oracle.jdbc.driver.OracleDriver

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

@@ -8,15 +8,21 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UReportSubscriber;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
-import cn.com.ctop.common.module.service.*;
+import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IUReportExportService;
+import cn.com.ctop.common.module.service.IUReportService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import cn.com.ctop.oa.modules.entity.WechatAttendance;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatDepartmentService;
+import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatUserListService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
@@ -32,10 +38,10 @@ import org.springframework.test.context.junit4.SpringRunner;
 
 import java.io.File;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -69,25 +75,33 @@ public class SampleTest {
     @Autowired
     private IWechatCheckinDataService wechatCheckinDataService;
     @Autowired
+    private IWechatNoListService wechatNoListService;
+    @Autowired
     private ICtopOauthTokenService tokenService;
 
 
     @Test
     public void getDepartment() throws ParseException {
-        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        Date parse1 = simpleDateFormat.parse("2020-09-12");
-        Date parse2 = simpleDateFormat.parse("2020-09-17");
-        for (CtopOauthToken token : tokens) {
-
-            kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, parse1, parse2);
+//        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+//        Date parse1 = simpleDateFormat.parse("2020-09-12");
+//        Date parse2 = simpleDateFormat.parse("2020-09-17");
+//        for (CtopOauthToken token : tokens) {
+//
+//            kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, parse1, parse2);
+//
+//        }
 
-        }
+//        wechatDepartment.getDepartment();
+//        wechatUserInfoService.getUserList();
+//        wechatCheckinDataService.getCheckinData();
+//        wechatNoListService.getNoDateByNo("1598889600","1600927780");
 
-    //    wechatCheckinDataService.getCheckinData();
-        //  wechatUserInfoService.getUserList();
-        // wechatDepartment.getDepartment();
-        // kuaishouInterfaceService.getSuZaoList("a34853c230e1b949eddbe569023dbc40", 7022550L, 1, "2020-09-15", "2020-09-16");
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("departId", "9");
+        List<WechatAttendance> wechatAttendances = wechatNoListService.queryAttendanceData( map);
+        System.out.println(wechatAttendances);
+        //         kuaishouInterfaceService.getSuZaoList("a34853c230e1b949eddbe569023dbc40", 7022550L, 1, "2020-09-15", "2020-09-16");
 
     }
 
@@ -97,10 +111,10 @@ public class SampleTest {
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("media_id", 2);
         List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
-         for (CtopOauthToken token : list) {
-        kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-20", "2020-09-20", "daily");
+        for (CtopOauthToken token : list) {
+            kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-20", "2020-09-20", "daily");
 
-         }
+        }
 
     }
 

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

+ 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";  //获取审批申请详情
 
 
 }

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

@@ -0,0 +1,303 @@
+package cn.com.ctop.oa.modules.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+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 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.HashMap;
+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
+     */
+    @GetMapping("/excel")
+    public void getExcelReport(HttpServletResponse response) {
+        Map<String, Object> paramsMap = new HashMap<>();
+        List<WechatAttendance> excelData = wechatNoListService.queryAttendanceData(paramsMap);
+        if (excelData.isEmpty()) {
+            return;
+        }
+        String[] titles = {"姓名", "部门", "考勤日期", "考勤类型", "考勤状态", "考勤时间", "审核状态", "状态时长"};
+        List<List<Object>> excelList = new ArrayList<>();
+        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());
+            excelList.add(temp);
+        });
+        try {
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            eeu.exportExcelForAttendance(workbook, 0, "考勤", titles, excelList);
+            HttpUtils.setResponseHeader(response, "考勤异常记录.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
+    }
+}

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

@@ -0,0 +1,57 @@
+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;
+    /**
+     * 部门编号
+     */
+    private String departId;
+    /**
+     * 签到日期
+     */
+    private String checkinDate;
+    /**
+     * 打卡类型
+     */
+    private String checkinType;
+    /**
+     * 异常打卡状态
+     */
+    private String exceptionType;
+    /**
+     * 考勤时间
+     */
+    private String checkinTime;
+    /**
+     * 异常考勤状态
+     */
+    private String type;
+    /**
+     * 状态时长
+     */
+    private String stateDuration;
+
+}

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

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

@@ -0,0 +1,21 @@
+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 org.jeecg.common.api.vo.Result;
+
+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);
+}

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

@@ -0,0 +1,47 @@
+<?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,
+           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="departId != null and departId != '' " >
+            and dpt.depart_id = #{departId}
+        </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>

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

@@ -0,0 +1,43 @@
+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 org.jeecg.common.api.vo.Result;
+
+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);
+}

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

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

@@ -39,38 +39,26 @@ public class WechatCheckinDataServiceImpl extends ServiceImpl<WechatCheckinDataM
     public void getCheckinData() {
         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失败");
             }
-
             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);
-
-
+                params.put("endtime", 1600927780);
                 String resultStr = HttpUtils.httpPostRequestTest(QYWxConstant.QYWX_CHECKIN_DATA + "?access_token=" + qywxAccessToken.get("accessToken"), params.toJSONString(), null);
                 JSONObject resultJson = JSONObject.parseObject(resultStr);
-                System.err.println(resultJson);
                 Integer errcode = resultJson.getInteger("errcode");
                 if (errcode == 0) {
                     JSONArray checkindata = resultJson.getJSONArray("checkindata");
@@ -96,7 +84,6 @@ public class WechatCheckinDataServiceImpl extends ServiceImpl<WechatCheckinDataM
                                 checkinData.setMediaids(jsonObject.getJSONArray("mediaids").toJSONString());
                                 checkinData.setLat(jsonObject.getString("lat"));
                                 this.save(checkinData);
-
                             }
                         }
 

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

@@ -0,0 +1,279 @@
+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.WechatNoList;
+import cn.com.ctop.oa.modules.enums.SpNoEnum;
+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 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;
+
+/**
+ * 审批信息
+ *
+ * @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;
+
+    /**
+     * 获取审批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("请假");
+                        if (statusisOK && typeisOK) {
+                            JSONObject applyer = info.getJSONObject("applyer");
+                            if (!Check.isNull(applyer)) {
+                                userId = applyer.getString("userid");
+                            }
+                            //审批申请数据
+                            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");
+        if (!"1".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)) {
+                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) {
+        return wechatNoListMapper.queryAttendanceData(paramsMap);
+    }
+}

+ 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 - 5
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatUserListServiceImpl.java

@@ -44,17 +44,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();