From c5dfc09145e4e10f99dbf388a4a1433b5c2973e5 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Tue, 10 Nov 2026 01:40:38 +0000
Subject: [PATCH] 适应高版本Nodejs对应修改(二)

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlFieldServiceImpl.java |   77 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlFieldServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlFieldServiceImpl.java
index 2b02d30..5416f08 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlFieldServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlFieldServiceImpl.java
@@ -37,6 +37,7 @@
 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;
@@ -85,6 +86,7 @@
     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){
@@ -227,6 +229,9 @@
             }
         } 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("数据更新异常");
         }
     }
@@ -314,6 +319,9 @@
             }).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("文件上传准备异常");
         }
     }
@@ -376,7 +384,7 @@
                     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)) {
                         // 文本
@@ -395,6 +403,11 @@
                         }
                         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));
@@ -403,9 +416,19 @@
                         }
                         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());
 
@@ -431,6 +454,11 @@
                         }
                         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());
 
@@ -475,6 +503,11 @@
                         }
                         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);
@@ -509,6 +542,11 @@
                             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<>());
 
@@ -557,6 +595,11 @@
                         // 明细 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());
 
@@ -580,6 +623,11 @@
                         }
                         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());
 
@@ -588,11 +636,21 @@
                         }
                         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());
 
@@ -607,10 +665,10 @@
                             }
                         } 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)) {
@@ -622,6 +680,11 @@
 
                         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());
 
@@ -671,6 +734,11 @@
 
                         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")) {
@@ -742,6 +810,9 @@
         } 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) {
             // 解析后数据获取失败

--
Gitblit v1.9.3