| | |
| | | import me.zhengjie.modules.treatment.repository.UserLevelWageRepository; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | import me.zhengjie.utils.StringUtils; |
| | | import me.zhengjie.weixin.cp.api.WxCpOaWeDocSmartsheetService; |
| | | import me.zhengjie.weixin.cp.bean.smartsheet.field.*; |
| | | import me.zhengjie.weixin.cp.bean.smartsheet.record.*; |
| | | import me.zhengjie.weixin.cp.bean.smartsheet.sheet.*; |
| | | import me.zhengjie.modules.weixin.cp.api.WxCpOaWeDocSmartsheetService; |
| | | import me.zhengjie.modules.weixin.cp.bean.smartsheet.field.*; |
| | | import me.zhengjie.modules.weixin.cp.bean.smartsheet.record.*; |
| | | import me.zhengjie.modules.weixin.cp.bean.smartsheet.sheet.*; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.commons.lang3.SerializationUtils; |
| | | import org.springframework.data.domain.Sort; |
| | |
| | | public void getWeComAttendanceListOfNoon(String attendDate, List attUser) throws Exception { |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(true); |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 获取参数日期类 |
| | | Calendar calAttendDate = Calendar.getInstance(); |
| | |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" + |
| | | "<div class=\"highlight\">请前往API服务查看LOG。</div>", |
| | | "getWeComAttendanceListOfNoon"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | } |
| | | } |
| | | |
| | |
| | | public void getWeComAttendanceListOfNight(String attendDate, List attUser) throws Exception { |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(true); |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 获取参数日期类 |
| | | Calendar calAttendDate = Calendar.getInstance(); |
| | |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" + |
| | | "<div class=\"highlight\">请前往API服务查看LOG。</div>", |
| | | "getWeComAttendanceListOfNight"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | } |
| | | } |
| | | |
| | |
| | | if (userWeComIdList.size() > 0) { |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(true); |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 编辑消息 |
| | | WxCpMessage wxCpMessage = new WxCpMessage(); |
| | |
| | | wxCpService.getMessageService().send(wxCpMessage); |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | // sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" + |
| | | // "<div class=\"highlight\">请前往API服务查看LOG。</div>", |
| | | // "sendNotice"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | } |
| | | } |
| | | } |
| | |
| | | projectQueryCriteria.setProjectStatusIn(Arrays.asList(Constant.PROJECT_STATUS_NOT_STARTED, Constant.PROJECT_STATUS_UNDER_WAY)); |
| | | List<Long> projectIds = projectRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, projectQueryCriteria, criteriaBuilder)).stream().map(p -> p.getId()).collect(Collectors.toList()); |
| | | toWeComSheetPushProjectReport(projectIds); |
| | | |
| | | try { |
| | | // 获取企微机器人参数 |
| | | Map<String, String> robotParamMap = dictDetailRepository.findByDictName(Constant.WECOM_ROBOT_PARAM).stream().collect(Collectors.toMap(DictDetail::getLabel, DictDetail::getValue)); |
| | | if (robotParamMap.containsKey(Constant.REMIND_REPORT_WEBHOOK_KEY) && robotParamMap.containsKey(Constant.REMIND_REPORT_SUCCESS_MSG)) { |
| | | // 发送周报生成成功消息 |
| | | WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl(); |
| | | wxCpDefaultConfig.setWebhookKey(robotParamMap.get(Constant.REMIND_REPORT_WEBHOOK_KEY)); |
| | | wxCpService.setWxCpConfigStorage(wxCpDefaultConfig); |
| | | wxCpService.getGroupRobotService().sendText(robotParamMap.get(Constant.REMIND_REPORT_SUCCESS_MSG), Arrays.asList("@all"), Arrays.asList()); |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(true); |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 查询现有子表信息 |
| | | WxCpSheetQueryRequest sheetQueryRequest = new WxCpSheetQueryRequest(); |
| | |
| | | // 制作项目周报数据 |
| | | Map<String, List<Record>> filterRecordMap = daliyMongoDtoList.stream().map(item -> { |
| | | Record record = recordInfo.getRecords().stream().filter(r -> { |
| | | if (ObjectUtils.isEmpty(r.getValues().get("项目名称")) || StringUtils.isBlank(r.getValues().get("项目名称").toString())) { |
| | | return false; |
| | | } |
| | | LocalDate createDate = Instant.ofEpochMilli(Long.parseLong(r.getValues().get("提交日期").toString())).atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | RecordOption projectNameRecord = ((List<?>) r.getValues().get("项目名称")).stream().map(o -> RecordOption.fromJson(gson.toJson(o))).findFirst().orElseGet(RecordOption::new); |
| | | RecordCellUserValue submitterRecord = ((List<?>) r.getValues().get("提交人")).stream().map(o -> RecordCellUserValue.fromJson(gson.toJson(o))).findFirst().orElseGet(RecordCellUserValue::new); |
| | |
| | | record.setValues(values); |
| | | return record; |
| | | }).collect(Collectors.groupingBy(record -> StringUtils.isNotBlank(record.getRecordId()) ? "EDIT" : "CREATE")); |
| | | // 待删除记录 |
| | | List<Record> recordDeleteList = recordInfo.getRecords().stream().filter(r -> ObjectUtils.isEmpty(r.getValues().get("项目名称")) || StringUtils.isBlank(r.getValues().get("项目名称").toString())).collect(Collectors.toList()); |
| | | |
| | | // 创建新纪录 |
| | | List<Record> recordCreateList = filterRecordMap.getOrDefault("CREATE", Collections.emptyList()); |
| | |
| | | recordEditRequest.setRecords(recordEditList); |
| | | // 提交记录 |
| | | wxCpOaWeDocSmartsheetService.recordEdit(recordEditRequest); |
| | | } |
| | | |
| | | // 删除记录(仅限空数据) |
| | | if (recordDeleteList.size() > 0) { |
| | | List<String> recordIdDeleteList = recordDeleteList.stream().map(r -> r.getRecordId()).collect(Collectors.toList()); |
| | | wxCpOaWeDocSmartsheetService.recordDelete(reportParamMap.get(Constant.WEEKLY_REPORT_DOC_ID), weeklyReportProjectSheet.getSheetId(), recordIdDeleteList); |
| | | } |
| | | } else { |
| | | System.out.println("项目周报子表不存在"); |
| | |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" + |
| | | "<div class=\"highlight\">请前往API服务查看LOG。</div>", |
| | | "toWecomSheetPushWeeklyReport"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(true); |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 查询现有子表信息 |
| | | WxCpSheetQueryRequest sheetQueryRequest = new WxCpSheetQueryRequest(); |
| | |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" + |
| | | "<div class=\"highlight\">请前往API服务查看LOG。</div>", |
| | | "toWeComSheetPushProjectReport"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |