| | |
| | | import me.zhengjie.modules.approval.service.mapstruct.TemplateControlMapper; |
| | | import me.zhengjie.modules.approval.service.mapstruct.TemplateMapper; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl; |
| | | import me.zhengjie.modules.system.domain.Dict; |
| | | import me.zhengjie.modules.system.domain.DictDetail; |
| | | import me.zhengjie.modules.system.repository.DictRepository; |
| | |
| | | private final DictService dictService; |
| | | private final DictRepository dictRepository; |
| | | private final DictDetailService dictDetailService; |
| | | private final WeComServiceImpl weComService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(TemplateControlFieldQueryCriteria criteria, Pageable pageable){ |
| | |
| | | } |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | weComService.sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" + |
| | | "<div class=\"highlight\">请前往API服务查看LOG。</div>", |
| | | "updateWecomVacationType"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | throw new BadRequestException("数据更新异常"); |
| | | } |
| | | } |
| | |
| | | }).collect(Collectors.toList()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | weComService.sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" + |
| | | "<div class=\"highlight\">请前往API服务查看LOG。</div>", |
| | | "uploadWecomMediaFile"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | throw new BadRequestException("文件上传准备异常"); |
| | | } |
| | | } |
| | |
| | | boolean accessible = field.isAccessible(); |
| | | // 设置对象的访问权限,保证对private的属性的访 |
| | | field.setAccessible(true); |
| | | Object object = Optional.ofNullable(field.get(data)).orElse("未填写"); |
| | | Object object = Optional.ofNullable(field.get(data)).orElse(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE); |
| | | |
| | | if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_TEXT)) { |
| | | // 文本 |
| | |
| | | } |
| | | value.setText(String.valueOf(object)); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_NUMBER)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 数字 |
| | | if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) { |
| | | value.setNewNumber(String.valueOf(object)); |
| | |
| | | } |
| | | value.setNewNumber(String.valueOf(object)); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_MONEY)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 金额 |
| | | value.setNewMoney(String.valueOf(object)); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_DATE)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 日期/日期+时间 |
| | | ContentValue.Date date = Optional.ofNullable(value.getDate()).orElse(new ContentValue.Date()); |
| | | |
| | |
| | | } |
| | | value.setDate(date); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_SELECTOR)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 单选/多选 TODO:暂时设定只支持单选,250421添加多选 |
| | | ContentValue.Selector selector = Optional.ofNullable(value.getSelector()).orElse(new ContentValue.Selector()); |
| | | |
| | |
| | | } |
| | | value.setSelector(selector); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_CONTACT)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(control.getContentConfig())) { |
| | | // 根据config设定判断控件属性 |
| | | WxCpOaApprovalTemplateResult.TemplateConfig config = JSONObject.parseObject(control.getContentConfig(), WxCpOaApprovalTemplateResult.TemplateConfig.class); |
| | |
| | | value.setMembers(Arrays.asList(member)); |
| | | } |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_FILE)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 附件 TODO:暂时设定只支持一条。250421添加多条 |
| | | List<ContentValue.File> fileList = Optional.ofNullable(value.getFiles()).orElse(new ArrayList<>()); |
| | | |
| | |
| | | // 明细 TODO:因结构复杂,暂时设定不提供支持 |
| | | value.setChildren(null); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_LOCATION)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 位置 |
| | | ContentValue.Location location = Optional.ofNullable(value.getLocation()).orElse(new ContentValue.Location()); |
| | | |
| | |
| | | } |
| | | value.setLocation(location); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_RELATEDAPPROVAL)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 关联审批单 TODO:按照文档暂时仅支持审批单绑定,但RelatedApproval貌似不止仅支持该功能 |
| | | ContentValue.RelatedApproval relatedApproval = Optional.ofNullable(value.getRelatedApproval()).map(i -> i.get(0)).orElse(new ContentValue.RelatedApproval()); |
| | | |
| | |
| | | } |
| | | value.setRelatedApproval(Arrays.asList(relatedApproval)); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_FORMULA)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 公式 |
| | | ContentValue.Formula formula = new ContentValue.Formula(); |
| | | formula.setValue(String.valueOf(object)); |
| | | value.setFormula(formula); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_DATERANGE)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 时长 |
| | | ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(value.getDateRange()).orElse(new ContentValue.Attendance.DataRange()); |
| | | |
| | |
| | | } |
| | | } else if (control.getControlParam().equals("date_range.new_end")) { |
| | | if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) { |
| | | dateRange.setBegin(Long.parseLong(String.valueOf(object))); |
| | | dateRange.setEnd(Long.parseLong(String.valueOf(object))); |
| | | } else if (field.getType().equals(Timestamp.class)) { |
| | | Timestamp time = (Timestamp) object; |
| | | dateRange.setBegin(Long.valueOf(time.getTime() / 1000)); |
| | | dateRange.setEnd(Long.valueOf(time.getTime() / 1000)); |
| | | } |
| | | } else if (control.getControlParam().equals("date_range.new_duration")) { |
| | | if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) { |
| | |
| | | |
| | | value.setDateRange(dateRange); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_VACATION)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | // 假勤组件-请假组件 |
| | | ContentValue.Vacation vacation = Optional.ofNullable(value.getVacation()).orElse(new ContentValue.Vacation()); |
| | | |
| | |
| | | |
| | | value.setVacation(vacation); |
| | | } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_ATTENDANCE)) { |
| | | if (control.getContentRequire().equals(0) && String.valueOf(object).equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_NULL_VALUE)) { |
| | | // 非必传且未填写则跳过 |
| | | continue; |
| | | } |
| | | |
| | | ContentValue.Attendance attendance = Optional.ofNullable(value.getAttendance()).orElse(new ContentValue.Attendance()); |
| | | |
| | | if (control.getControlParam().equals("attendance.date_range.type")) { |
| | |
| | | } catch (WxErrorException wxErrorException) { |
| | | // 通信失败 |
| | | wxErrorException.printStackTrace(); |
| | | weComService.sendNotice(Arrays.asList("YueYuHuanXiangQinYuFenDou"), "企微通信异常", String.format("<div class=\"normal\">异常方法:%s</div>" + |
| | | "<div class=\"highlight\">请前往API服务查看LOG。</div>", |
| | | "sendApplyEvent"), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | resultMap.put("error", "通信失败"); |
| | | } catch (IllegalAccessException illegalAccessException) { |
| | | // 解析后数据获取失败 |