BAOLH
2025-04-16 d4b1eef914b3be9f444543234dc43d6c841572a9
企微申请对接初版提交
50 files added
28 files modified
5363 ■■■■■ changed files
eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java 68 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/domain/ApproveEvent.java 98 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/domain/Template.java 65 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/domain/TemplateControl.java 101 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/domain/TemplateControlField.java 69 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/listener/ChangeApprovalStatusEventListener.java 269 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/repository/ApproveEventRepository.java 28 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/repository/TemplateControlFieldRepository.java 28 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/repository/TemplateControlRepository.java 28 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/repository/TemplateRepository.java 28 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/ApproveEventController.java 99 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/TemplateControlController.java 87 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/TemplateControlFieldController.java 114 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/TemplateController.java 95 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/ApproveEventService.java 83 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/TemplateControlFieldService.java 106 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/TemplateControlService.java 83 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/TemplateService.java 95 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/ApproveEventDto.java 86 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/ApproveEventQueryCriteria.java 27 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateControlDto.java 86 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateControlFieldDto.java 62 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateControlFieldQueryCriteria.java 38 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateControlQueryCriteria.java 34 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateDto.java 63 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateQueryCriteria.java 38 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/ApproveEventServiceImpl.java 123 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlFieldServiceImpl.java 597 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlServiceImpl.java 118 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateServiceImpl.java 491 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/mapstruct/ApproveEventMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/mapstruct/TemplateControlFieldMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/mapstruct/TemplateControlMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/mapstruct/TemplateMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java 23 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceCardreplacement.java 15 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceGoOut.java 27 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceLeave.java 20 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceOvertime.java 19 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java 7 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelQueryCriteria.java 3 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceCardreplacementDto.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceCardreplacementQueryCriteria.java 3 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutDto.java 7 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutQueryCriteria.java 3 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveDto.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java 3 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceOvertimeDto.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceOvertimeQueryCriteria.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceBusinessTravelServiceImpl.java 49 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java 42 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java 160 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java 256 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceOvertimeServiceImpl.java 50 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Applyer.java 15 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/ApprovalInfo.java 44 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/ApprovalSend.java 30 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Approver.java 12 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/CommentUserInfo.java 12 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Comments.java 24 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Details.java 24 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/NodeList.java 23 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Notifyer.java 12 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/ProcessList.java 14 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/SpRecord.java 20 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/SubNode.java 24 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/UserInfo.java 12 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/template/template.js 35 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/template/templateControlField.js 50 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/components/ApprovalLine/index.vue 243 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/utils/constant.js 21 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceBusinessTravel/index.vue 68 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceCardReplacement/index.vue 53 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceGoOut/index.vue 91 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceLeave/index.vue 52 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceOvertime/index.vue 48 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/template/bind/index.vue 286 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
@@ -45,6 +45,74 @@
        public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true";
    }
    public static class Constant {
        // 审批模版删除判定:普通
        public static final String TEMPLATE_DEL_STATUS_NORMAL = "0";
        // 审批模版删除判定:删除
        public static final String TEMPLATE_DEL_STATUS_DEL = "1";
        // 审批模版语言:中文
        public static final String TEMPLATE_LANG_ZH = "zh_CN";
        // 审批模版语言:英文
        public static final String TEMPLATE_LANG_EN = "en";
        // 审批模版控件类型:文本
        public static final String TEMPLATE_CONTROL_TYPE_TEXT = "Text";
        // 审批模版控件类型:多行文本
        public static final String TEMPLATE_CONTROL_TYPE_TEXTAREA = "Textarea";
        // 审批模版控件类型:数字
        public static final String TEMPLATE_CONTROL_TYPE_NUMBER = "Number";
        // 审批模版控件类型:金额
        public static final String TEMPLATE_CONTROL_TYPE_MONEY = "Money";
        // 审批模版控件类型:日期/日期+时间
        public static final String TEMPLATE_CONTROL_TYPE_DATE = "Date";
        // 审批模版控件类型:单选/多选
        public static final String TEMPLATE_CONTROL_TYPE_SELECTOR = "Selector";
        // 审批模版控件类型:成员/部门
        public static final String TEMPLATE_CONTROL_TYPE_CONTACT = "Contact";
        // 审批模版控件类型:说明文字
        public static final String TEMPLATE_CONTROL_TYPE_TIPS = "Tips";
        // 审批模版控件类型:附件
        public static final String TEMPLATE_CONTROL_TYPE_FILE = "File";
        // 审批模版控件类型:明细
        public static final String TEMPLATE_CONTROL_TYPE_TABLE = "Table";
        // 审批模版控件类型:位置
        public static final String TEMPLATE_CONTROL_TYPE_LOCATION = "Location";
        // 审批模版控件类型:关联审批单
        public static final String TEMPLATE_CONTROL_TYPE_RELATEDAPPROVAL = "RelatedApproval";
        // 审批模版控件类型:公式
        public static final String TEMPLATE_CONTROL_TYPE_FORMULA = "Formula";
        // 审批模版控件类型:时长
        public static final String TEMPLATE_CONTROL_TYPE_DATERANGE = "DateRange";
        // 审批模版控件类型:假勤组件-请假组件
        public static final String TEMPLATE_CONTROL_TYPE_VACATION = "Vacation";
        // 审批模版控件类型:假勤组件-出差/外出/加班组件
        public static final String TEMPLATE_CONTROL_TYPE_ATTENDANCE = "Attendance";
        // 审批模版时长粒度:小时
        public static final String TEMPLATE_DATE_TYPE_HOUR = "hour";
        // 审批模版时长粒度:天
        public static final String TEMPLATE_DATE_TYPE_HALFDAY = "halfday";
    }
    /**
     * 常用枚举
     */
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/domain/ApproveEvent.java
New file
@@ -0,0 +1,98 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import me.zhengjie.base.BaseEntity;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2025-03-17
**/
@Entity
@Data
@Table(name="approve_event")
public class ApproveEvent extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`event_id`")
    @ApiModelProperty(value = "事件ID")
    private Long eventId;
    @Column(name = "`sp_no`")
    @ApiModelProperty(value = "审批编号")
    private String spNo;
    @Column(name = "`sp_name`")
    @ApiModelProperty(value = "审批申请类型名称(审批模板名称)")
    private String spName;
    @Column(name = "`sp_status`")
    @ApiModelProperty(value = "申请单状态")
    private String spStatus;
    @Column(name = "`template_id`")
    @ApiModelProperty(value = "审批模板id")
    private String templateId;
    @Column(name = "`apply_time`")
    @ApiModelProperty(value = "审批申请提交时间")
    private Timestamp applyTime;
    @Column(name = "`applyer_party`")
    @ApiModelProperty(value = "申请人所在部门pid")
    private String applyerParty;
    @Column(name = "`applyer_user_id`")
    @ApiModelProperty(value = "申请人userid")
    private String applyerUserId;
    @Column(name = "`sp_record`")
    @ApiModelProperty(value = "审批流程信息")
    private String spRecord;
    @Column(name = "`notifyer`")
    @ApiModelProperty(value = "抄送信息")
    private String notifyer;
    @Column(name = "`comments`")
    @ApiModelProperty(value = "审批申请备注信息")
    private String comments;
    @Column(name = "`process_list`")
    @ApiModelProperty(value = "审批流程列表")
    private String processList;
    @Column(name = "`status_change_event`")
    @ApiModelProperty(value = "审批申请状态变化类型")
    private String statusChangeEvent;
    public void copy(ApproveEvent source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/domain/Template.java
New file
@@ -0,0 +1,65 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import me.zhengjie.base.BaseEntity;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2025-03-17
**/
@Entity
@Data
@Table(name="template")
public class Template extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "主键ID")
    private Long id;
    @Column(name = "`template_id`")
    @ApiModelProperty(value = "模版ID(企微内)")
    private String templateId;
    @Column(name = "`del_status`")
    @ApiModelProperty(value = "删除判定")
    private String delStatus;
    @Column(name = "`template_name_zh`")
    @ApiModelProperty(value = "模板名称(中文)")
    private String templateNameZh;
    @Column(name = "`template_name_en`")
    @ApiModelProperty(value = "模板名称(英文)")
    private String templateNameEn;
    public void copy(Template source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/domain/TemplateControl.java
New file
@@ -0,0 +1,101 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import me.zhengjie.base.BaseEntity;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2025-03-17
**/
@Entity
@Data
@Table(name="template_control")
public class TemplateControl extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "主键ID")
    private Long id;
    @Column(name = "`template_id`")
    @ApiModelProperty(value = "模版ID")
    private Long templateId;
    @Column(name = "`control_type`")
    @ApiModelProperty(value = "控件类型")
    private String controlType;
    @Column(name = "`control_id`")
    @ApiModelProperty(value = "控件ID")
    private String controlId;
    @Column(name = "`control_param`")
    @ApiModelProperty(value = "控件参数")
    private String controlParam;
    @Column(name = "`control_param_name`")
    @ApiModelProperty(value = "控件参数名称")
    private String controlParamName;
    @Column(name = "`placeholder_text_zh`")
    @ApiModelProperty(value = "占位符文本(中文)")
    private String placeholderTextZh;
    @Column(name = "`placeholder_text_en`")
    @ApiModelProperty(value = "占位符文本(英文)")
    private String placeholderTextEn;
    @Column(name = "`content_require`")
    @ApiModelProperty(value = "是否必填")
    private Integer contentRequire;
    @Column(name = "`content_print`")
    @ApiModelProperty(value = "是否参与打印")
    private Integer contentPrint;
    @Column(name = "`content_config`")
    @ApiModelProperty(value = "控件设定")
    private String contentConfig;
    @Column(name = "`del_status`")
    @ApiModelProperty(value = "删除判定")
    private String delStatus;
    @Column(name = "`title_text_zh`")
    @ApiModelProperty(value = "标题文本(中文)")
    private String titleTextZh;
    @Column(name = "`title_text_en`")
    @ApiModelProperty(value = "标题文本(英文)")
    private String titleTextEn;
    public void copy(TemplateControl source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/domain/TemplateControlField.java
New file
@@ -0,0 +1,69 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import me.zhengjie.base.BaseEntity;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2025-03-17
**/
@Entity
@Data
@Table(name="template_control_field")
public class TemplateControlField extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "主键ID")
    private Long id;
    @Column(name = "`template_id`")
    @ApiModelProperty(value = "模板ID")
    private Long templateId;
    @Column(name = "`control_id`")
    @ApiModelProperty(value = "控件ID")
    private Long controlId;
    @Column(name = "`field_table`")
    @ApiModelProperty(value = "字段表名")
    private String fieldTable;
    @Column(name = "`field_name`")
    @ApiModelProperty(value = "字段名称")
    private String fieldName;
    @Column(name = "`del_status`")
    @ApiModelProperty(value = "删除判定")
    private String delStatus;
    public void copy(TemplateControlField source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/listener/ChangeApprovalStatusEventListener.java
New file
@@ -0,0 +1,269 @@
package me.zhengjie.modules.approval.listener;
import com.google.gson.Gson;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.domain.Template;
import me.zhengjie.modules.approval.domain.TemplateControlField;
import me.zhengjie.modules.approval.repository.ApproveEventRepository;
import me.zhengjie.modules.approval.repository.TemplateControlFieldRepository;
import me.zhengjie.modules.approval.repository.TemplateRepository;
import me.zhengjie.modules.approval.service.dto.TemplateControlFieldQueryCriteria;
import me.zhengjie.modules.approval.service.dto.TemplateQueryCriteria;
import me.zhengjie.modules.attendance.domain.*;
import me.zhengjie.modules.attendance.repository.*;
import me.zhengjie.modules.attendance.service.*;
import me.zhengjie.modules.attendance.service.dto.*;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.temp.domain.WechatSendHistory;
import me.zhengjie.modules.temp.event.ChangeApprovalStatusEvent;
import me.zhengjie.modules.temp.repository.WechatSendHistoryRepository;
import me.zhengjie.modules.temp.service.dto.wecom.ApprovalSend;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.context.event.EventListener;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.util.List;
@Component
@RequiredArgsConstructor
public class ChangeApprovalStatusEventListener {
    private final WechatSendHistoryRepository wechatSendHistoryRepository;
    private final TemplateRepository templateRepository;
    private final TemplateControlFieldRepository templateControlFieldRepository;
    private final ApproveEventRepository approveEventRepository;
    private final AttendanceLeaveService attendanceLeaveService;
    private final AttendanceLeaveRepository attendanceLeaveRepository;
    private final AttendanceGoOutService attendanceGoOutService;
    private final AttendanceGoOutRepository attendanceGoOutRepository;
    private final AttendanceBusinessTravelService attendanceBusinessTravelService;
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final AttendanceOvertimeService attendanceOvertimeService;
    private final AttendanceOvertimeRepository attendanceOvertimeRepository;
    private final AttendanceCardreplacementService attendanceCardreplacementService;
    private final AttendanceCardreplacementRepository attendanceCardreplacementRepository;
    @EventListener
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
    public void handleChangeApprovalStatusEvent(ChangeApprovalStatusEvent event) {
        WechatSendHistory history = wechatSendHistoryRepository.findById(event.getHistoryId()).orElse(new WechatSendHistory());
        Gson gson = new Gson();
        ApprovalSend approvalSend = gson.fromJson(history.getContent(), ApprovalSend.class);
        if (approvalSend.getEvent().equals("sys_approval_change") && StringUtils.isNotBlank(approvalSend.getApprovalInfo().getTemplateId())) {
            TemplateQueryCriteria templateCriteria = new TemplateQueryCriteria();
            templateCriteria.setTemplateId(approvalSend.getApprovalInfo().getTemplateId());
            List<Template> templateList = templateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,templateCriteria,criteriaBuilder), Sort.by(Sort.Direction.DESC, "id"));
            if (templateList.size() > 0) {
                TemplateControlFieldQueryCriteria fieldCriteria = new TemplateControlFieldQueryCriteria();
                fieldCriteria.setTemplateId(templateList.get(0).getId());
                List<TemplateControlField> fieldList = templateControlFieldRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,fieldCriteria,criteriaBuilder), Sort.by(Sort.Direction.DESC, "id"));
                if (fieldList.size() > 0) {
                    // 保存下发事件信息
                    ApproveEvent approveEvent = new ApproveEvent();
                    approveEvent.setSpNo(approvalSend.getApprovalInfo().getSpNo());
                    approveEvent.setSpName(approvalSend.getApprovalInfo().getSpName());
                    approveEvent.setSpStatus(approvalSend.getApprovalInfo().getSpStatus().toString());
                    approveEvent.setTemplateId(approvalSend.getApprovalInfo().getTemplateId());
                    approveEvent.setApplyTime(new Timestamp(Long.parseLong(approvalSend.getApprovalInfo().getApplyTime()) * 1000L));
                    approveEvent.setApplyerParty(approvalSend.getApprovalInfo().getApplyer().getParty());
                    approveEvent.setApplyerUserId(approvalSend.getApprovalInfo().getApplyer().getUserId());
                    approveEvent.setSpRecord(ObjectUtils.isNotEmpty(approvalSend.getApprovalInfo().getSpRecord()) ? gson.toJson(approvalSend.getApprovalInfo().getSpRecord()) : null);
                    approveEvent.setNotifyer(ObjectUtils.isNotEmpty(approvalSend.getApprovalInfo().getNotifyer()) ? gson.toJson(approvalSend.getApprovalInfo().getNotifyer()) : null);
                    approveEvent.setComments(ObjectUtils.isNotEmpty(approvalSend.getApprovalInfo().getComments()) ? gson.toJson(approvalSend.getApprovalInfo().getComments()) : null);
                    approveEvent.setProcessList(ObjectUtils.isNotEmpty(approvalSend.getApprovalInfo().getProcessList()) ? gson.toJson(approvalSend.getApprovalInfo().getProcessList()) : null);
                    approveEvent.setStatusChangeEvent(approvalSend.getApprovalInfo().getStatuChangeEvent().toString());
                    ApproveEvent approveEventSaved = approveEventRepository.save(approveEvent);
                    if (fieldList.get(0).getFieldTable().equals("AttendanceLeave")) {
                        // 请假
                        AttendanceLeaveQueryCriteria leaveCriteria = new AttendanceLeaveQueryCriteria();
                        leaveCriteria.setWecomSpNo(approvalSend.getApprovalInfo().getSpNo());
                        List<AttendanceLeave> leaveList = attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,leaveCriteria,criteriaBuilder), Sort.by(Sort.Direction.DESC, "id"));
                        if (leaveList.size() > 0) {
                            AttendanceLeave leave = leaveList.get(0);
                            leave.setApprovalStatus(switchSpStatusToSysStatus("请假", approvalSend.getApprovalInfo().getSpStatus()));
                            leave.setWecomEventId(approveEventSaved.getEventId());
                            try {
                                attendanceLeaveService.updateApprove(leave);
                            } catch (Exception e) {
                                System.out.println("企微状态下发数据对应数据(请假)更新失败:下发数据ID为" + event.getHistoryId());
                            }
                        } else {
                            System.out.println("企微状态下发数据对应数据(请假)未找到:下发数据ID为" + event.getHistoryId());
                        }
                    } else if (fieldList.get(0).getFieldTable().equals("AttendanceGoOut")) {
                        // 外出
                        AttendanceGoOutQueryCriteria goOutCriteria = new AttendanceGoOutQueryCriteria();
                        goOutCriteria.setWecomSpNo(approvalSend.getApprovalInfo().getSpNo());
                        List<AttendanceGoOut> goOutList = attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,goOutCriteria,criteriaBuilder), Sort.by(Sort.Direction.DESC, "id"));
                        if (goOutList.size() > 0) {
                            AttendanceGoOut goOut = goOutList.get(0);
                            goOut.setApprovalStatus(switchSpStatusToSysStatus("外出", approvalSend.getApprovalInfo().getSpStatus()));
                            goOut.setWecomEventId(approveEventSaved.getEventId());
                            try {
                                attendanceGoOutService.updateApprove(goOut);
                            } catch (Exception e) {
                                System.out.println("企微状态下发数据对应数据(外出)更新失败:下发数据ID为" + event.getHistoryId());
                            }
                        } else {
                            System.out.println("企微状态下发数据对应数据(外出)未找到:下发数据ID为" + event.getHistoryId());
                        }
                    } else if (fieldList.get(0).getFieldTable().equals("AttendanceBusinessTravel")) {
                        // 出差
                        AttendanceBusinessTravelQueryCriteria businessTravelCriteria = new AttendanceBusinessTravelQueryCriteria();
                        businessTravelCriteria.setWecomSpNo(approvalSend.getApprovalInfo().getSpNo());
                        List<AttendanceBusinessTravel> businessTravelList = attendanceBusinessTravelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,businessTravelCriteria,criteriaBuilder), Sort.by(Sort.Direction.DESC, "id"));
                        if (businessTravelList.size() > 0) {
                            AttendanceBusinessTravel businessTravel = businessTravelList.get(0);
                            businessTravel.setApprovalStatus(switchSpStatusToSysStatus("出差", approvalSend.getApprovalInfo().getSpStatus()));
                            businessTravel.setWecomEventId(approveEventSaved.getEventId());
                            try {
                                attendanceBusinessTravelService.updateApprove(businessTravel);
                            } catch (Exception e) {
                                System.out.println("企微状态下发数据对应数据(出差)更新失败:下发数据ID为" + event.getHistoryId());
                            }
                        } else {
                            System.out.println("企微状态下发数据对应数据(出差)未找到:下发数据ID为" + event.getHistoryId());
                        }
                    } else if (fieldList.get(0).getFieldTable().equals("AttendanceOvertime")) {
                        // 换休
                        AttendanceOvertimeQueryCriteria overtimeCriteria = new AttendanceOvertimeQueryCriteria();
                        overtimeCriteria.setWecomSpNo(approvalSend.getApprovalInfo().getSpNo());
                        List<AttendanceOvertime> overtimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,overtimeCriteria,criteriaBuilder), Sort.by(Sort.Direction.DESC, "id"));
                        if (overtimeList.size() > 0) {
                            AttendanceOvertime overtime = overtimeList.get(0);
                            overtime.setApprovalStatus(switchSpStatusToSysStatus("换休", approvalSend.getApprovalInfo().getSpStatus()));
                            overtime.setWecomEventId(approveEventSaved.getEventId());
                            try {
                                attendanceOvertimeService.updateApprove(overtime);
                            } catch (Exception e) {
                                System.out.println("企微状态下发数据对应数据(换休)更新失败:下发数据ID为" + event.getHistoryId());
                            }
                        } else {
                            System.out.println("企微状态下发数据对应数据(换休)未找到:下发数据ID为" + event.getHistoryId());
                        }
                    } else if (fieldList.get(0).getFieldTable().equals("AttendanceCardreplacement")) {
                        // 补卡
                        AttendanceCardreplacementQueryCriteria cardreplacementCriteria = new AttendanceCardreplacementQueryCriteria();
                        cardreplacementCriteria.setWecomSpNo(approvalSend.getApprovalInfo().getSpNo());
                        List<AttendanceCardreplacement> cardreplacementList = attendanceCardreplacementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,cardreplacementCriteria,criteriaBuilder), Sort.by(Sort.Direction.DESC, "id"));
                        if (cardreplacementList.size() > 0) {
                            AttendanceCardreplacement cardreplacement = cardreplacementList.get(0);
                            cardreplacement.setApprovalStatus(switchSpStatusToSysStatus("补卡", approvalSend.getApprovalInfo().getSpStatus()));
                            cardreplacement.setWecomEventId(approveEventSaved.getEventId());
                            try {
                                attendanceCardreplacementService.updateApprove(cardreplacement);
                            } catch (Exception e) {
                                System.out.println("企微状态下发数据对应数据(补卡)更新失败:下发数据ID为" + event.getHistoryId());
                            }
                        } else {
                            System.out.println("企微状态下发数据对应数据(补卡)未找到:下发数据ID为" + event.getHistoryId());
                        }
                    } else {
                        System.out.println("企微状态下发数据对应模板绑定表名未找到:下发数据ID为" + event.getHistoryId());
                    }
                } else {
                    System.out.println("企微状态下发数据对应模板绑定数据未找到:下发数据ID为" + event.getHistoryId());
                }
            } else {
                System.out.println("企微状态下发数据对应模板未找到:下发数据ID为" + event.getHistoryId());
            }
        } else {
            System.out.println("企微状态下发数据错误:下发数据ID为" + event.getHistoryId());
        }
    }
    private static String switchSpStatusToSysStatus(String type, Integer spStatus) {
        String finalStatus;
        switch (type + "-" + spStatus) {
            // 审批中
            case "请假-1": finalStatus = Constant.APPROVAL_STATUS_UNDER_APPROVAL; break;
            // 已通过
            case "请假-2": finalStatus = Constant.APPROVAL_STATUS_PASSED; break;
            // 已驳回
            case "请假-3": finalStatus = Constant.APPROVAL_STATUS_RETURNED; break;
            // 已撤销
            case "请假-4": finalStatus = Constant.APPROVAL_STATUS_RETURNED; break;
            // 通过后撤销
            case "请假-6": finalStatus = Constant.APPROVAL_STATUS_RETURNED; break;
            // 已删除
            case "请假-7": finalStatus = Constant.APPROVAL_STATUS_RETURNED; break;
            // 已支付
            case "请假-10": finalStatus = Constant.APPROVAL_STATUS_UNDER_APPROVAL; break;
            // 审批中
            case "外出-1": finalStatus = Constant.GOOUT_APPROVE_STATUS_REVIEWED; break;
            // 已通过
            case "外出-2": finalStatus = Constant.GOOUT_APPROVE_STATUS_AGREE; break;
            // 已驳回
            case "外出-3": finalStatus = Constant.GOOUT_APPROVE_STATUS_REFUSE; break;
            // 已撤销
            case "外出-4": finalStatus = Constant.GOOUT_APPROVE_STATUS_REFUSE; break;
            // 通过后撤销
            case "外出-6": finalStatus = Constant.GOOUT_APPROVE_STATUS_REFUSE; break;
            // 已删除
            case "外出-7": finalStatus = Constant.GOOUT_APPROVE_STATUS_REFUSE; break;
            // 已支付
            case "外出-10": finalStatus = Constant.GOOUT_APPROVE_STATUS_REVIEWED; break;
            // 审批中
            case "出差-1": finalStatus = Constant.BUSSINESS_APPROVE_STATUS_REVIEWED; break;
            // 已通过
            case "出差-2": finalStatus = Constant.BUSSINESS_APPROVE_STATUS_AGREE; break;
            // 已驳回
            case "出差-3": finalStatus = Constant.BUSSINESS_APPROVE_STATUS_REFUSE; break;
            // 已撤销
            case "出差-4": finalStatus = Constant.BUSSINESS_APPROVE_STATUS_REFUSE; break;
            // 通过后撤销
            case "出差-6": finalStatus = Constant.BUSSINESS_APPROVE_STATUS_REFUSE; break;
            // 已删除
            case "出差-7": finalStatus = Constant.BUSSINESS_APPROVE_STATUS_REFUSE; break;
            // 已支付
            case "出差-10": finalStatus = Constant.BUSSINESS_APPROVE_STATUS_REVIEWED; break;
            // 审批中
            case "换休-1": finalStatus = Constant.OVERTIME_APPROVAL; break;
            // 已通过
            case "换休-2": finalStatus = Constant.OVERTIME_PASS; break;
            // 已驳回
            case "换休-3": finalStatus = Constant.OVERTIME_RETURN; break;
            // 已撤销
            case "换休-4": finalStatus = Constant.OVERTIME_RETURN; break;
            // 通过后撤销
            case "换休-6": finalStatus = Constant.OVERTIME_RETURN; break;
            // 已删除
            case "换休-7": finalStatus = Constant.OVERTIME_RETURN; break;
            // 已支付
            case "换休-10": finalStatus = Constant.OVERTIME_APPROVAL; break;
            // 审批中
            case "补卡-1": finalStatus = Constant.CARD_APPROVE_STATUS_REVIEWED; break;
            // 已通过
            case "补卡-2": finalStatus = Constant.CARD_APPROVE_STATUS_AGREE; break;
            // 已驳回
            case "补卡-3": finalStatus = Constant.CARD_APPROVE_STATUS_REFUSE; break;
            // 已撤销
            case "补卡-4": finalStatus = Constant.CARD_APPROVE_STATUS_REFUSE; break;
            // 通过后撤销
            case "补卡-6": finalStatus = Constant.CARD_APPROVE_STATUS_REFUSE; break;
            // 已删除
            case "补卡-7": finalStatus = Constant.CARD_APPROVE_STATUS_REFUSE; break;
            // 已支付
            case "补卡-10": finalStatus = Constant.CARD_APPROVE_STATUS_REVIEWED; break;
            // 默认
            default: finalStatus = Constant.APPROVAL_STATUS_UNDER_APPROVAL; break;
        }
        return finalStatus;
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/repository/ApproveEventRepository.java
New file
@@ -0,0 +1,28 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.repository;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
public interface ApproveEventRepository extends JpaRepository<ApproveEvent, Long>, JpaSpecificationExecutor<ApproveEvent> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/repository/TemplateControlFieldRepository.java
New file
@@ -0,0 +1,28 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.repository;
import me.zhengjie.modules.approval.domain.TemplateControlField;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
public interface TemplateControlFieldRepository extends JpaRepository<TemplateControlField, Long>, JpaSpecificationExecutor<TemplateControlField> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/repository/TemplateControlRepository.java
New file
@@ -0,0 +1,28 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.repository;
import me.zhengjie.modules.approval.domain.TemplateControl;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
public interface TemplateControlRepository extends JpaRepository<TemplateControl, Long>, JpaSpecificationExecutor<TemplateControl> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/repository/TemplateRepository.java
New file
@@ -0,0 +1,28 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.repository;
import me.zhengjie.modules.approval.domain.Template;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
public interface TemplateRepository extends JpaRepository<Template, Long>, JpaSpecificationExecutor<Template> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/ApproveEventController.java
New file
@@ -0,0 +1,99 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.rest;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.service.ApproveEventService;
import me.zhengjie.modules.approval.service.dto.ApproveEventQueryCriteria;
import me.zhengjie.modules.temp.event.ChangeApprovalStatusEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "审批变化记录管理")
@RequestMapping("/api/approveEvent")
public class ApproveEventController {
    private final ApproveEventService approveEventService;
    private final ApplicationEventPublisher applicationEventPublisher;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('approveEvent:list')")
    public void exportApproveEvent(HttpServletResponse response, ApproveEventQueryCriteria criteria) throws IOException {
        approveEventService.download(approveEventService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询审批变化记录")
    @ApiOperation("查询审批变化记录")
    @PreAuthorize("@el.check('approveEvent:list')")
    public ResponseEntity<Object> queryApproveEvent(ApproveEventQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(approveEventService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增审批变化记录")
    @ApiOperation("新增审批变化记录")
    @PreAuthorize("@el.check('approveEvent:add')")
    public ResponseEntity<Object> createApproveEvent(@Validated @RequestBody ApproveEvent resources){
        return new ResponseEntity<>(approveEventService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改审批变化记录")
    @ApiOperation("修改审批变化记录")
    @PreAuthorize("@el.check('approveEvent:edit')")
    public ResponseEntity<Object> updateApproveEvent(@Validated @RequestBody ApproveEvent resources){
        approveEventService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除审批变化记录")
    @ApiOperation("删除审批变化记录")
    @PreAuthorize("@el.check('approveEvent:del')")
    public ResponseEntity<Object> deleteApproveEvent(@RequestBody Long[] ids) {
        approveEventService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @AnonymousAccess
    @GetMapping(value = "/test/{id}")
    public ResponseEntity<Object> test(@PathVariable Long id) {
        ChangeApprovalStatusEvent event = new ChangeApprovalStatusEvent(new Object(), id);
        applicationEventPublisher.publishEvent(event);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/TemplateControlController.java
New file
@@ -0,0 +1,87 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.approval.domain.TemplateControl;
import me.zhengjie.modules.approval.service.TemplateControlService;
import me.zhengjie.modules.approval.service.dto.TemplateControlQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "审批模版控件管理")
@RequestMapping("/api/templateControl")
public class TemplateControlController {
    private final TemplateControlService templateControlService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('templateControl:list')")
    public void exportTemplateControl(HttpServletResponse response, TemplateControlQueryCriteria criteria) throws IOException {
        templateControlService.download(templateControlService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询审批模版控件")
    @ApiOperation("查询审批模版控件")
    @PreAuthorize("@el.check('templateControl:list')")
    public ResponseEntity<Object> queryTemplateControl(TemplateControlQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(templateControlService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增审批模版控件")
    @ApiOperation("新增审批模版控件")
    @PreAuthorize("@el.check('templateControl:add')")
    public ResponseEntity<Object> createTemplateControl(@Validated @RequestBody TemplateControl resources){
        return new ResponseEntity<>(templateControlService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改审批模版控件")
    @ApiOperation("修改审批模版控件")
    @PreAuthorize("@el.check('templateControl:edit')")
    public ResponseEntity<Object> updateTemplateControl(@Validated @RequestBody TemplateControl resources){
        templateControlService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除审批模版控件")
    @ApiOperation("删除审批模版控件")
    @PreAuthorize("@el.check('templateControl:del')")
    public ResponseEntity<Object> deleteTemplateControl(@RequestBody Long[] ids) {
        templateControlService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/TemplateControlFieldController.java
New file
@@ -0,0 +1,114 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.approval.domain.TemplateControlField;
import me.zhengjie.modules.approval.service.TemplateControlFieldService;
import me.zhengjie.modules.approval.service.dto.TemplateControlFieldQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "审批控件字段绑定管理")
@RequestMapping("/api/templateControlField")
public class TemplateControlFieldController {
    private final TemplateControlFieldService templateControlFieldService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('templateControlField:list')")
    public void exportTemplateControlField(HttpServletResponse response, TemplateControlFieldQueryCriteria criteria) throws IOException {
        templateControlFieldService.download(templateControlFieldService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询审批控件字段绑定")
    @ApiOperation("查询审批控件字段绑定")
    @PreAuthorize("@el.check('templateControlField:list')")
    public ResponseEntity<Object> queryTemplateControlField(TemplateControlFieldQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(templateControlFieldService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增审批控件字段绑定")
    @ApiOperation("新增审批控件字段绑定")
    @PreAuthorize("@el.check('templateControlField:add')")
    public ResponseEntity<Object> createTemplateControlField(@Validated @RequestBody TemplateControlField resources){
        return new ResponseEntity<>(templateControlFieldService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改审批控件字段绑定")
    @ApiOperation("修改审批控件字段绑定")
    @PreAuthorize("@el.check('templateControlField:edit')")
    public ResponseEntity<Object> updateTemplateControlField(@Validated @RequestBody TemplateControlField resources){
        templateControlFieldService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除审批控件字段绑定")
    @ApiOperation("删除审批控件字段绑定")
    @PreAuthorize("@el.check('templateControlField:del')")
    public ResponseEntity<Object> deleteTemplateControlField(@RequestBody Long[] ids) {
        templateControlFieldService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @GetMapping(value = "/queryByTable")
    @Log("查询与表单绑定的审批控件字段及相关信息")
    @ApiOperation("查询与表单绑定的审批控件字段及相关信息")
    @PreAuthorize("@el.check('templateControlField:list')")
    public ResponseEntity<Object> queryByTable(TemplateControlFieldQueryCriteria criteria){
        return new ResponseEntity<>(templateControlFieldService.queryByTable(criteria), HttpStatus.OK);
    }
    @PostMapping(value = "/bind")
    @Log("审批控件与数据表字段绑定")
    @ApiOperation("审批控件与数据表字段绑定")
    @PreAuthorize("@el.check('templateControlField:add')")
    public ResponseEntity<Object> bindTemplateControlField(@Validated @RequestBody List<TemplateControlField> resources){
        templateControlFieldService.bind(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
    @PostMapping(value = "/editWecomVacationType")
    @Log("更新企微请假类型")
    @ApiOperation("更新企微请假类型")
    @PreAuthorize("@el.check('templateControlField:add')")
    public ResponseEntity<Object> updateWecomVacationType() {
        templateControlFieldService.updateWecomVacationType();
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/TemplateController.java
New file
@@ -0,0 +1,95 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.approval.domain.Template;
import me.zhengjie.modules.approval.service.TemplateService;
import me.zhengjie.modules.approval.service.dto.TemplateQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "审批模版管理")
@RequestMapping("/api/template")
public class TemplateController {
    private final TemplateService templateService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('template:list')")
    public void exportTemplate(HttpServletResponse response, TemplateQueryCriteria criteria) throws IOException {
        templateService.download(templateService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询审批模版")
    @ApiOperation("查询审批模版")
    @PreAuthorize("@el.check('template:list')")
    public ResponseEntity<Object> queryTemplate(TemplateQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(templateService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增审批模版")
    @ApiOperation("新增审批模版")
    @PreAuthorize("@el.check('template:add')")
    public ResponseEntity<Object> createTemplate(@Validated @RequestBody Template resources){
        return new ResponseEntity<>(templateService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改审批模版")
    @ApiOperation("修改审批模版")
    @PreAuthorize("@el.check('template:edit')")
    public ResponseEntity<Object> updateTemplate(@Validated @RequestBody Template resources){
        templateService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除审批模版")
    @ApiOperation("删除审批模版")
    @PreAuthorize("@el.check('template:del')")
    public ResponseEntity<Object> deleteTemplate(@RequestBody Long[] ids) {
        templateService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @PostMapping(value = "/queryWeComTemplate")
    @Log("获取企微审批模版信息")
    @ApiOperation("获取企微审批模版信息")
    @PreAuthorize("@el.check('template:add')")
    public ResponseEntity<Object> queryWeComTemplate(@RequestBody TemplateQueryCriteria criteria) throws Exception {
        return new ResponseEntity<>(templateService.queryWeComTemplate(criteria), HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/ApproveEventService.java
New file
@@ -0,0 +1,83 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.service.dto.ApproveEventDto;
import me.zhengjie.modules.approval.service.dto.ApproveEventQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author baolh
* @date 2025-03-17
**/
public interface ApproveEventService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(ApproveEventQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<ApproveEventDto>
    */
    List<ApproveEventDto> queryAll(ApproveEventQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param eventId ID
     * @return ApproveEventDto
     */
    ApproveEventDto findById(Long eventId);
    /**
    * 创建
    * @param resources /
    * @return ApproveEventDto
    */
    ApproveEventDto create(ApproveEvent resources);
    /**
    * 编辑
    * @param resources /
    */
    void update(ApproveEvent resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<ApproveEventDto> all, HttpServletResponse response) throws IOException;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/TemplateControlFieldService.java
New file
@@ -0,0 +1,106 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service;
import me.zhengjie.modules.approval.domain.TemplateControlField;
import me.zhengjie.modules.approval.service.dto.TemplateControlFieldDto;
import me.zhengjie.modules.approval.service.dto.TemplateControlFieldQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author baolh
* @date 2025-03-17
**/
public interface TemplateControlFieldService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(TemplateControlFieldQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<TemplateControlFieldDto>
    */
    List<TemplateControlFieldDto> queryAll(TemplateControlFieldQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param controlId ID
     * @return TemplateControlFieldDto
     */
    TemplateControlFieldDto findById(Long controlId);
    /**
    * 创建
    * @param resources /
    * @return TemplateControlFieldDto
    */
    TemplateControlFieldDto create(TemplateControlField resources);
    /**
    * 编辑
    * @param resources /
    */
    void update(TemplateControlField resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<TemplateControlFieldDto> all, HttpServletResponse response) throws IOException;
    /**
     * 查询与表单绑定的审批控件字段及相关信息
     * @param criteria 条件参数
     * @return Map<String, Object>
     */
    Map<String, Object> queryByTable(TemplateControlFieldQueryCriteria criteria);
    /**
     * 审批控件与数据表字段绑定
     * @param all 待绑定的数据
     */
    void bind(List<TemplateControlField> all);
    /**
     * 更新企微请假类型
     */
    void updateWecomVacationType();
    /**
     * 提交微信审批
     */
    <R> Map<String, String> createWecomApproval(R data, String userWxId);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/TemplateControlService.java
New file
@@ -0,0 +1,83 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service;
import me.zhengjie.modules.approval.domain.TemplateControl;
import me.zhengjie.modules.approval.service.dto.TemplateControlDto;
import me.zhengjie.modules.approval.service.dto.TemplateControlQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author baolh
* @date 2025-03-17
**/
public interface TemplateControlService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(TemplateControlQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<TemplateControlDto>
    */
    List<TemplateControlDto> queryAll(TemplateControlQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param id ID
     * @return TemplateControlDto
     */
    TemplateControlDto findById(Long id);
    /**
    * 创建
    * @param resources /
    * @return TemplateControlDto
    */
    TemplateControlDto create(TemplateControl resources);
    /**
    * 编辑
    * @param resources /
    */
    void update(TemplateControl resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<TemplateControlDto> all, HttpServletResponse response) throws IOException;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/TemplateService.java
New file
@@ -0,0 +1,95 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service;
import me.zhengjie.modules.approval.domain.Template;
import me.zhengjie.modules.approval.service.dto.TemplateDto;
import me.zhengjie.modules.approval.service.dto.TemplateQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author baolh
* @date 2025-03-17
**/
public interface TemplateService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(TemplateQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<TemplateDto>
    */
    List<TemplateDto> queryAll(TemplateQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param id ID
     * @return TemplateDto
     */
    TemplateDto findById(Long id);
    /**
    * 创建
    * @param resources /
    * @return TemplateDto
    */
    TemplateDto create(Template resources);
    /**
    * 编辑
    * @param resources /
    */
    void update(Template resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<TemplateDto> all, HttpServletResponse response) throws IOException;
    /**
     * 创建
     * @param criteria 条件
     * @return TemplateDto
     */
    TemplateDto queryWeComTemplate(TemplateQueryCriteria criteria) throws Exception;
    /**
     * 获取请假类型对应KEY
     */
    String getVacationKey(String type);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/ApproveEventDto.java
New file
@@ -0,0 +1,86 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import me.zhengjie.base.BaseDTO;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2025-03-17
**/
@Data
public class ApproveEventDto extends BaseDTO implements Serializable {
    /** 事件ID */
    /** 防止精度丢失 */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long eventId;
    /** 审批编号 */
    private String spNo;
    /** 审批申请类型名称(审批模板名称) */
    private String spName;
    /** 申请单状态 */
    private String spStatus;
    /** 审批模板id */
    private String templateId;
    /** 审批申请提交时间 */
    private Timestamp applyTime;
    /** 申请人所在部门pid */
    private String applyerParty;
    /** 申请人userid */
    private String applyerUserId;
    /** 审批流程信息 */
    private String spRecord;
    /** 抄送信息 */
    private String notifyer;
    /** 审批申请备注信息 */
    private String comments;
    /** 审批流程列表 */
    private String processList;
    /** 审批申请状态变化类型 */
    private String statusChangeEvent;
    /** 创建时间 */
    private Timestamp createTime;
    /** 创建人 */
    private String createBy;
    /** 更新时间 */
    private Timestamp updateTime;
    /** 更新人 */
    private String updateBy;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/ApproveEventQueryCriteria.java
New file
@@ -0,0 +1,27 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.dto;
import lombok.Data;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@Data
public class ApproveEventQueryCriteria{
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateControlDto.java
New file
@@ -0,0 +1,86 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.dto;
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2025-03-17
**/
@Data
public class TemplateControlDto extends BaseDTO implements Serializable {
    /** 主键ID */
    private Long id;
    /** 模版ID */
    private Long templateId;
    /** 控件类型 */
    private String controlType;
    /** 控件ID */
    private String controlId;
    /** 控件参数 */
    private String controlParam;
    /** 控件参数名称 */
    private String controlParamName;
    /** 占位符文本(中文) */
    private String placeholderTextZh;
    /** 占位符文本(英文) */
    private String placeholderTextEn;
    /** 是否必填 */
    private Integer contentRequire;
    /** 是否参与打印 */
    private Integer contentPrint;
    /** 控件设定 */
    private String contentConfig;
    /** 删除判定 */
    private String delStatus;
    /** 创建时间 */
    private Timestamp createTime;
    /** 创建人 */
    private String createBy;
    /** 更新时间 */
    private Timestamp updateTime;
    /** 更新人 */
    private String updateBy;
    /** 标题文本(中文) */
    private String titleTextZh;
    /** 标题文本(英文) */
    private String titleTextEn;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateControlFieldDto.java
New file
@@ -0,0 +1,62 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.dto;
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2025-03-17
**/
@Data
public class TemplateControlFieldDto extends BaseDTO implements Serializable {
    /** 主键ID */
    private Long id;
    /** 模板ID */
    private Long templateId;
    /** 控件ID */
    private Long controlId;
    /** 字段表名 */
    private String fieldTable;
    /** 字段名称 */
    private String fieldName;
    /** 删除判定 */
    private String delStatus;
    /** 创建时间 */
    private Timestamp createTime;
    /** 创建人 */
    private String createBy;
    /** 更新时间 */
    private Timestamp updateTime;
    /** 更新人 */
    private String updateBy;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateControlFieldQueryCriteria.java
New file
@@ -0,0 +1,38 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
import me.zhengjie.utils.ElAdminConstant;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@Data
public class TemplateControlFieldQueryCriteria{
    @Query(type = Query.Type.EQUAL)
    private Long templateId;
    @Query(type = Query.Type.EQUAL)
    private String fieldTable;
    @Query(type = Query.Type.EQUAL)
    private String delStatus = ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_NORMAL;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateControlQueryCriteria.java
New file
@@ -0,0 +1,34 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@Data
public class TemplateControlQueryCriteria{
    @Query(type = Query.Type.EQUAL)
    private Long templateId;
    @Query(type = Query.Type.EQUAL)
    private String delStatus;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateDto.java
New file
@@ -0,0 +1,63 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.dto;
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2025-03-17
**/
@Data
public class TemplateDto extends BaseDTO implements Serializable {
    /** 主键ID */
    private Long id;
    /** 模版ID(企微内) */
    private String templateId;
    /** 删除判定 */
    private String delStatus;
    /** 创建时间 */
    private Timestamp createTime;
    /** 创建人 */
    private String createBy;
    /** 更新时间 */
    private Timestamp updateTime;
    /** 更新人 */
    private String updateBy;
    /** 模板名称(中文) */
    private String templateNameZh;
    /** 模板名称(英文) */
    private String templateNameEn;
    /** 审批模版控件列表 */
    private List<TemplateControlDto> templateControls;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/dto/TemplateQueryCriteria.java
New file
@@ -0,0 +1,38 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@Data
public class TemplateQueryCriteria{
    /** 模版ID(企微内) */
    @Query
    private String templateId;
    /** 删除判定 */
    @Query
    private String delStatus;
    private Boolean queryNew = true;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/ApproveEventServiceImpl.java
New file
@@ -0,0 +1,123 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.impl;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.approval.repository.ApproveEventRepository;
import me.zhengjie.modules.approval.service.ApproveEventService;
import me.zhengjie.modules.approval.service.dto.ApproveEventDto;
import me.zhengjie.modules.approval.service.dto.ApproveEventQueryCriteria;
import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author baolh
* @date 2025-03-17
**/
@Service
@RequiredArgsConstructor
public class ApproveEventServiceImpl implements ApproveEventService {
    private final ApproveEventRepository approveEventRepository;
    private final ApproveEventMapper approveEventMapper;
    @Override
    public Map<String,Object> queryAll(ApproveEventQueryCriteria criteria, Pageable pageable){
        Page<ApproveEvent> page = approveEventRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        return PageUtil.toPage(page.map(approveEventMapper::toDto));
    }
    @Override
    public List<ApproveEventDto> queryAll(ApproveEventQueryCriteria criteria){
        return approveEventMapper.toDto(approveEventRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public ApproveEventDto findById(Long eventId) {
        ApproveEvent approveEvent = approveEventRepository.findById(eventId).orElseGet(ApproveEvent::new);
        ValidationUtil.isNull(approveEvent.getEventId(),"ApproveEvent","eventId",eventId);
        return approveEventMapper.toDto(approveEvent);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public ApproveEventDto create(ApproveEvent resources) {
        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
        resources.setEventId(snowflake.nextId());
        return approveEventMapper.toDto(approveEventRepository.save(resources));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(ApproveEvent resources) {
        ApproveEvent approveEvent = approveEventRepository.findById(resources.getEventId()).orElseGet(ApproveEvent::new);
        ValidationUtil.isNull( approveEvent.getEventId(),"ApproveEvent","id",resources.getEventId());
        approveEvent.copy(resources);
        approveEventRepository.save(approveEvent);
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long eventId : ids) {
            approveEventRepository.deleteById(eventId);
        }
    }
    @Override
    public void download(List<ApproveEventDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (ApproveEventDto approveEvent : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("审批编号", approveEvent.getSpNo());
            map.put("审批申请类型名称(审批模板名称)", approveEvent.getSpName());
            map.put("申请单状态", approveEvent.getSpStatus());
            map.put("审批模板id", approveEvent.getTemplateId());
            map.put("审批申请提交时间", approveEvent.getApplyTime());
            map.put("申请人所在部门pid", approveEvent.getApplyerParty());
            map.put("申请人userid", approveEvent.getApplyerUserId());
            map.put("审批流程信息", approveEvent.getSpRecord());
            map.put("抄送信息", approveEvent.getNotifyer());
            map.put("审批申请备注信息", approveEvent.getComments());
            map.put("审批流程列表", approveEvent.getProcessList());
            map.put("审批申请状态变化类型", approveEvent.getStatusChangeEvent());
            map.put("创建时间", approveEvent.getCreateTime());
            map.put("创建人", approveEvent.getCreateBy());
            map.put("更新时间", approveEvent.getUpdateTime());
            map.put("更新人", approveEvent.getUpdateBy());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlFieldServiceImpl.java
New file
@@ -0,0 +1,597 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.impl;
import com.alibaba.fastjson.JSONObject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.oa.WxCpCorpConfInfo;
import me.chanjar.weixin.cp.bean.oa.WxCpOaApplyEventRequest;
import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult;
import me.chanjar.weixin.cp.bean.oa.applydata.ApplyDataContent;
import me.chanjar.weixin.cp.bean.oa.applydata.ContentValue;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.approval.domain.Template;
import me.zhengjie.modules.approval.domain.TemplateControl;
import me.zhengjie.modules.approval.domain.TemplateControlField;
import me.zhengjie.modules.approval.repository.TemplateControlRepository;
import me.zhengjie.modules.approval.repository.TemplateRepository;
import me.zhengjie.modules.approval.service.dto.TemplateControlQueryCriteria;
import me.zhengjie.modules.approval.service.dto.TemplateDto;
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.system.domain.Dict;
import me.zhengjie.modules.system.domain.DictDetail;
import me.zhengjie.modules.system.repository.DictRepository;
import me.zhengjie.modules.system.service.DictDetailService;
import me.zhengjie.modules.system.service.DictService;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.approval.repository.TemplateControlFieldRepository;
import me.zhengjie.modules.approval.service.TemplateControlFieldService;
import me.zhengjie.modules.approval.service.dto.TemplateControlFieldDto;
import me.zhengjie.modules.approval.service.dto.TemplateControlFieldQueryCriteria;
import me.zhengjie.modules.approval.service.mapstruct.TemplateControlFieldMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.stream.Collectors;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author baolh
* @date 2025-03-17
**/
@Service
@RequiredArgsConstructor
public class TemplateControlFieldServiceImpl implements TemplateControlFieldService {
    private final TemplateControlFieldRepository templateControlFieldRepository;
    private final TemplateRepository templateRepository;
    private final TemplateControlRepository templateControlRepository;
    private final TemplateControlFieldMapper templateControlFieldMapper;
    private final TemplateMapper templateMapper;
    private final TemplateControlMapper templateControlMapper;
    private final WxCpService wxCpService;
    private final DictService dictService;
    private final DictRepository dictRepository;
    private final DictDetailService dictDetailService;
    @Override
    public Map<String,Object> queryAll(TemplateControlFieldQueryCriteria criteria, Pageable pageable){
        Page<TemplateControlField> page = templateControlFieldRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        return PageUtil.toPage(page.map(templateControlFieldMapper::toDto));
    }
    @Override
    public List<TemplateControlFieldDto> queryAll(TemplateControlFieldQueryCriteria criteria){
        return templateControlFieldMapper.toDto(templateControlFieldRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public TemplateControlFieldDto findById(Long id) {
        TemplateControlField templateControlField = templateControlFieldRepository.findById(id).orElseGet(TemplateControlField::new);
        ValidationUtil.isNull(templateControlField.getId(),"TemplateControlField","id", id);
        return templateControlFieldMapper.toDto(templateControlField);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public TemplateControlFieldDto create(TemplateControlField resources) {
        return templateControlFieldMapper.toDto(templateControlFieldRepository.save(resources));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(TemplateControlField resources) {
        TemplateControlField templateControlField = templateControlFieldRepository.findById(resources.getId()).orElseGet(TemplateControlField::new);
        ValidationUtil.isNull(templateControlField.getId(),"TemplateControlField","id", resources.getId());
        templateControlField.copy(resources);
        templateControlFieldRepository.save(templateControlField);
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            templateControlFieldRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<TemplateControlFieldDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (TemplateControlFieldDto templateControlField : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("控件ID", templateControlField.getControlId());
            map.put("字段表名", templateControlField.getFieldTable());
            map.put("字段名称", templateControlField.getFieldName());
            map.put("删除判定", templateControlField.getDelStatus());
            map.put("创建时间", templateControlField.getCreateTime());
            map.put("创建人", templateControlField.getCreateBy());
            map.put("更新时间", templateControlField.getUpdateTime());
            map.put("更新人", templateControlField.getUpdateBy());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
    @Override
    public Map<String, Object> queryByTable(TemplateControlFieldQueryCriteria criteria) {
        Map<String, Object> resultMap = new HashMap<>(2);
        if (StringUtils.isNotBlank(criteria.getFieldTable())) {
            // 获取审批控件字段绑定信息
            List<TemplateControlField> templateControlFields = templateControlFieldRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
            if (templateControlFields.size() > 0) {
                // 已绑定
                // 获取审批模版信息
                Template template = templateRepository.findById(templateControlFields.get(0).getTemplateId()).orElseGet(Template::new);
                if (template.getId() != null) {
                    // 获取审批模板控件信息
                    TemplateControlQueryCriteria controlCriteria = new TemplateControlQueryCriteria();
                    controlCriteria.setTemplateId(template.getId());
                    List<TemplateControl> templateControls = templateControlRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,controlCriteria,criteriaBuilder));
                    TemplateDto templateDto = templateMapper.toDto(template);
                    templateDto.setTemplateControls(templateControlMapper.toDto(templateControls));
                    resultMap.put("template", templateDto);
                }
            }
            resultMap.put("templateControlField", templateControlFieldMapper.toDto(templateControlFields));
        }
        return resultMap;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void bind(List<TemplateControlField> all) {
        TemplateControlFieldQueryCriteria criteria = new TemplateControlFieldQueryCriteria();
        criteria.setFieldTable(all.get(0).getFieldTable());
        criteria.setDelStatus(ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_NORMAL);
        List<TemplateControlField> oldRecordList = templateControlFieldRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
        // 删除旧记录(根据表名区分)
        for (TemplateControlField oldRecord : oldRecordList) {
            oldRecord.setDelStatus(ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_DEL);
        }
        templateControlFieldRepository.saveAll(oldRecordList);
        // 保存新记录
        for (TemplateControlField newRecord : all) {
            newRecord.setId(null);
            newRecord.setDelStatus(ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_NORMAL);
        }
        templateControlFieldRepository.saveAll(all);
    }
    @Override
    public void updateWecomVacationType() {
        try {
            // 获取字典信息
            Dict dict = dictRepository.findByName(Constant.WECOM_LEAVE_TYPE);
            // 获取企业微信Token
            wxCpService.getAccessToken();
            // 假勤组件需要获取假期相关配置
            WxCpCorpConfInfo corpConfInfo = wxCpService.getOaService().getCorpConf();
            List<DictDetail> newDictDetails = corpConfInfo.getLists().stream().map(m -> {
                DictDetail dictDetail = new DictDetail();
                dictDetail.setLabel(m.getName());
                dictDetail.setValue(m.getId().toString());
                dictDetail.setDictSort(1);
                return dictDetail;
            }).collect(Collectors.toList());
            // 删除旧记录
            dictService.delete(Collections.singleton(dict.getId()));
            Dict newDict = new Dict();
            newDict.setName(Constant.WECOM_LEAVE_TYPE);
            newDict.setDescription(Constant.WECOM_LEAVE_TYPE_DESCRIPTION);
            Dict savedDict = dictRepository.save(newDict);
            // 保存新纪录
            for (DictDetail dictDetail : newDictDetails) {
                dictDetail.setDict(savedDict);
                dictDetailService.create(dictDetail);
            }
        } catch (WxErrorException wxErrorException) {
            wxErrorException.printStackTrace();
            throw new BadRequestException("数据更新异常");
        }
    }
    @Override
    public <R> Map<String, String> createWecomApproval(R data, String userWxId) {
        TemplateControlFieldQueryCriteria criteria = new TemplateControlFieldQueryCriteria();
        criteria.setFieldTable(data.getClass().getSimpleName());
        criteria.setDelStatus(ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_NORMAL);
        List<TemplateControlField> templateControlFields = templateControlFieldRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
        return this.sendApplyevent(data, templateControlFields, userWxId);
    }
    private <R> Map<String, String> sendApplyevent(R data, List<TemplateControlField> bindData, String userWxId) {
        Map<String, String> resultMap = new HashMap<>(2);
        try {
            // 校验申请人企微ID
            if (StringUtils.isBlank(userWxId)) {
                resultMap.put("error", "申请人企微ID不能为空");
                return resultMap;
            }
            // 验证绑定数据
            if (bindData.size() <= 0) {
                resultMap.put("error", "数据模版未绑定");
                return resultMap;
            }
            // 验证Class名称
            if (!data.getClass().getSimpleName().equals(bindData.get(0).getFieldTable())) {
                resultMap.put("error", "数据源名称不符:" + bindData.get(0).getFieldTable());
                return resultMap;
            }
            // 验证Class字段
            List<Field> fields = QueryHelp.getAllFields(data.getClass(), new ArrayList<>());
            List<String> fieldNames = fields.stream().map(i -> i.getName()).collect(Collectors.toList());
            List<TemplateControlField> nonExistList = bindData.stream().filter(i -> StringUtils.isNotBlank(i.getFieldName()) && !fieldNames.contains(i.getFieldName())).collect(Collectors.toList());
            if (nonExistList.size() > 0) {
                resultMap.put("error", "数据源字段名称不存在:" + nonExistList.stream().map(i -> i.getFieldTable().concat("(").concat(i.getFieldName()).concat(")")).collect(Collectors.joining(",")));
                return resultMap;
            }
            // 获取模版信息
            Template template = templateRepository.findById(bindData.get(0).getTemplateId()).orElseGet(Template::new);
            if (template.getId().equals(null)) {
                resultMap.put("error", "模版数据不存在");
                return resultMap;
            }
            // 获取模版控件信息
            TemplateControlQueryCriteria controlCriteria = new TemplateControlQueryCriteria();
            controlCriteria.setTemplateId(template.getId());
            List<TemplateControl> templateControls = templateControlRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,controlCriteria,criteriaBuilder));
            // 制作控件Map
            Map<Long, TemplateControl> templateControlsMap = templateControls.stream().collect(Collectors.toMap(TemplateControl::getId, i -> i));
            // 制作源数据成员Map
            Map<String, Field> fieldMap = fields.stream().collect(Collectors.toMap(Field::getName, i -> i));
            WxCpOaApplyEventRequest.ApplyData applyData = new WxCpOaApplyEventRequest.ApplyData();
            for (TemplateControlField controlField : bindData) {
                TemplateControl control = templateControlsMap.get(controlField.getControlId());
                if (StringUtils.isNotBlank(controlField.getFieldName()) || control.getContentRequire().equals(1)) {
                    // 获取申请结构信息
                    ApplyDataContent applyDataContent = Optional.ofNullable(applyData.getContents()).flatMap(i -> i.stream().filter(f -> f.getControl().equals(control.getControlType()) && f.getId().equals(control.getControlId())).findFirst()).orElse(new ApplyDataContent());
                    applyDataContent.setControl(control.getControlType());
                    applyDataContent.setId(control.getControlId());
                    ContentValue value = Optional.ofNullable(applyDataContent.getValue()).orElse(new ContentValue());
                    // 获取数据值
                    Field field = fieldMap.get(controlField.getFieldName());
                    boolean accessible = field.isAccessible();
                    // 设置对象的访问权限,保证对private的属性的访
                    field.setAccessible(true);
                    Object object = Optional.ofNullable(field.get(data)).orElse("未填写");
                    if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_TEXT)) {
                        // 文本
                        if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                            value.setText(String.valueOf(object));
                        } else if (field.getType().equals(Timestamp.class)) {
                            value.setText(String.valueOf(object));
                        }
                        value.setText(String.valueOf(object));
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_TEXTAREA)) {
                        // 多行文本
                        if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                            value.setText(String.valueOf(object));
                        } else if (field.getType().equals(Timestamp.class)) {
                            value.setText(String.valueOf(object));
                        }
                        value.setText(String.valueOf(object));
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_NUMBER)) {
                        // 数字
                        if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                            value.setNewNumber(String.valueOf(object));
                        } else if (field.getType().equals(Timestamp.class)) {
                            value.setNewNumber(String.valueOf(object));
                        }
                        value.setNewNumber(String.valueOf(object));
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_MONEY)) {
                        // 金额
                        value.setNewMoney(String.valueOf(object));
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_DATE)) {
                        // 日期/日期+时间
                        ContentValue.Date date = Optional.ofNullable(value.getDate()).orElse(new ContentValue.Date());
                        if (control.getControlParam().equals("date.type")) {
                            date.setType(String.valueOf(object));
                        } else if (control.getControlParam().equals("date.s_timestamp")) {
                            if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                                date.setTimestamp(String.valueOf(object));
                            } else if (field.getType().equals(Timestamp.class)) {
                                Timestamp time = (Timestamp) object;
                                date.setTimestamp(String.valueOf(time.getTime() / 1000));
                            }
                        }
                        value.setDate(date);
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_SELECTOR)) {
                        // 单选/多选 TODO:暂时设定只支持单选
                        ContentValue.Selector selector = Optional.ofNullable(value.getSelector()).orElse(new ContentValue.Selector());
                        if (control.getControlParam().equals("selector.options[].key")) {
                            if (StringUtils.isNotBlank(control.getContentConfig())) {
                                // 根据config设定填写key值
                                WxCpOaApprovalTemplateResult.TemplateConfig config = JSONObject.parseObject(control.getContentConfig(), WxCpOaApprovalTemplateResult.TemplateConfig.class);
                                Map<String, String> optionMap = config.getSelector().getOptions().stream()
                                        .flatMap(opt -> opt.getValue().stream().map(val -> new AbstractMap.SimpleEntry<>(val.getText(), opt.getKey())))
                                        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (existing, replacement) -> existing));
                                selector.setType("single");
                                ContentValue.Selector.Option option = new ContentValue.Selector.Option();
                                option.setKey(optionMap.containsKey(String.valueOf(object)) ? optionMap.get(String.valueOf(object)) : String.valueOf(object));
                                selector.setOptions(Arrays.asList(option));
                            } else {
                                selector.setType("single");
                                ContentValue.Selector.Option option = new ContentValue.Selector.Option();
                                option.setKey(String.valueOf(object));
                                selector.setOptions(Arrays.asList(option));
                            }
                        }
                        value.setSelector(selector);
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_CONTACT)) {
                        // 成员控件 TODO:1、与部门控件类型相同,如何区分待验证。2、暂时设定只支持一条。
                        ContentValue.Member member = Optional.ofNullable(value.getMembers()).map(i -> i.get(0)).orElse(new ContentValue.Member());
                        if (control.getControlParam().equals("members[].userid")) {
                            member.setUserId(String.valueOf(object));
                        } else if (control.getControlParam().equals("members[].name")) {
                            member.setName(String.valueOf(object));
                        }
                        value.setMembers(Arrays.asList(member));
                        // 部门控件 TODO:1、与成员控件类型相同,如何区分待验证。2、暂时设定只支持一条。
                        ContentValue.Department department = Optional.ofNullable(value.getDepartments()).map(i -> i.get(0)).orElse(new ContentValue.Department());
                        if (control.getControlParam().equals("departments[].openapi_id")) {
                            department.setOpenApiId(String.valueOf(object));
                        } else if (control.getControlParam().equals("departments[].name")) {
                            department.setName(String.valueOf(object));
                        }
                        value.setDepartments(Arrays.asList(department));
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_FILE)) {
                        // 附件 TODO:暂时设定只支持一条。
                        ContentValue.File file = Optional.ofNullable(value.getFiles()).map(i -> i.get(0)).orElse(new ContentValue.File());
                        if (control.getControlParam().equals("files[].file_id")) {
                            file.setFileId(String.valueOf(object));
                        } else if (control.getControlParam().equals("files[].file_name")) {
                            file.setFileName(String.valueOf(object));
                        } else if (control.getControlParam().equals("files[].file_url")) {
                            file.setFileUrl(String.valueOf(object));
                        }
                        value.setFiles(Arrays.asList(file));
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_TABLE)) {
                        // 明细 TODO:因结构复杂,暂时设定不提供支持
                        value.setChildren(null);
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_LOCATION)) {
                        // 位置
                        ContentValue.Location location = Optional.ofNullable(value.getLocation()).orElse(new ContentValue.Location());
                        if (control.getControlParam().equals("location.latitude")) {
                            location.setLatitude(new BigDecimal(String.valueOf(object)));
                        } else if (control.getControlParam().equals("location.longitude")) {
                            location.setLongitude(new BigDecimal(String.valueOf(object)));
                        } else if (control.getControlParam().equals("location.title")) {
                            location.setTitle(String.valueOf(object));
                        } else if (control.getControlParam().equals("location.address")) {
                            location.setAddress(String.valueOf(object));
                        } else if (control.getControlParam().equals("location.time")) {
                            if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                                location.setTime(Long.valueOf(String.valueOf(object)));
                            } else if (field.getType().equals(Timestamp.class)) {
                                Timestamp time = (Timestamp) object;
                                location.setTime(time.getTime() / 1000);
                            } else {
                                location.setTime((Long.valueOf(String.valueOf(object))));
                            }
                        }
                        value.setLocation(location);
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_RELATEDAPPROVAL)) {
                        // 关联审批单 TODO:按照文档暂时仅支持审批单绑定,但RelatedApproval貌似不止仅支持该功能
                        ContentValue.RelatedApproval relatedApproval = Optional.ofNullable(value.getRelatedApproval()).map(i -> i.get(0)).orElse(new ContentValue.RelatedApproval());
                        if (control.getControlParam().equals("related_approval[].sp_no")) {
                            relatedApproval.setSpNo(String.valueOf(object));
                        }
                        value.setRelatedApproval(Arrays.asList(relatedApproval));
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_FORMULA)) {
                        // 公式
                        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)) {
                        // 时长
                        ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(value.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                        if (control.getControlParam().equals("date_range.type")) {
                            dateRange.setType(String.valueOf(object));
                        } else if (control.getControlParam().equals("date_range.new_begin")) {
                            if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                                dateRange.setBegin(Long.parseLong(String.valueOf(object)));
                            } else if (field.getType().equals(Timestamp.class)) {
                                Timestamp time = (Timestamp) object;
                                dateRange.setBegin(Long.valueOf(time.getTime() / 1000));
                            }
                        } 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)));
                            } else if (field.getType().equals(Timestamp.class)) {
                                Timestamp time = (Timestamp) object;
                                dateRange.setBegin(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)) {
                                dateRange.setDuration(Long.parseLong(String.valueOf(object)));
                            } else {
                                dateRange.setDuration(Long.parseLong(String.valueOf(object)));
                            }
                        }
                        value.setDateRange(dateRange);
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_VACATION)) {
                        // 假勤组件-请假组件
                        ContentValue.Vacation vacation = Optional.ofNullable(value.getVacation()).orElse(new ContentValue.Vacation());
                        if (control.getControlParam().equals("vacation.selector.options[].key")) {
                            ContentValue.Selector selector = Optional.ofNullable(vacation.getSelector()).orElse(new ContentValue.Selector());
                            // 假勤组件固定单选
                            selector.setType("single");
                            ContentValue.Selector.Option option = new ContentValue.Selector.Option();
                            option.setKey(String.valueOf(object));
                            selector.setOptions(Arrays.asList(option));
                            vacation.setSelector(selector);
                        } else if (control.getControlParam().equals("vacation.attendance.date_range.type")) {
                            ContentValue.Attendance attendance = Optional.ofNullable(vacation.getAttendance()).orElse(new ContentValue.Attendance());
                            ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(attendance.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                            dateRange.setType(String.valueOf(object));
                            attendance.setDateRange(dateRange);
                            vacation.setAttendance(attendance);
                        } else if (control.getControlParam().equals("vacation.attendance.date_range.new_begin")) {
                            ContentValue.Attendance attendance = Optional.ofNullable(vacation.getAttendance()).orElse(new ContentValue.Attendance());
                            ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(attendance.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                            if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                                dateRange.setBegin(Long.parseLong(String.valueOf(object)));
                            } else if (field.getType().equals(Timestamp.class)) {
                                Timestamp time = (Timestamp) object;
                                dateRange.setBegin(Long.valueOf(time.getTime() / 1000));
                            }
                            attendance.setDateRange(dateRange);
                            vacation.setAttendance(attendance);
                        } else if (control.getControlParam().equals("vacation.attendance.date_range.new_end")) {
                            ContentValue.Attendance attendance = Optional.ofNullable(vacation.getAttendance()).orElse(new ContentValue.Attendance());
                            ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(attendance.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                            if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                                dateRange.setEnd(Long.parseLong(String.valueOf(object)));
                            } else if (field.getType().equals(Timestamp.class)) {
                                Timestamp time = (Timestamp) object;
                                dateRange.setEnd(Long.valueOf(time.getTime() / 1000));
                            }
                            attendance.setDateRange(dateRange);
                            vacation.setAttendance(attendance);
                        } else if (control.getControlParam().equals("vacation.attendance.date_range.new_duration")) {
                            ContentValue.Attendance attendance = Optional.ofNullable(vacation.getAttendance()).orElse(new ContentValue.Attendance());
                            ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(attendance.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                            dateRange.setDuration(Long.parseLong(String.valueOf(object)));
                            attendance.setDateRange(dateRange);
                            vacation.setAttendance(attendance);
                        }
                        value.setVacation(vacation);
                    } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_ATTENDANCE)) {
                        ContentValue.Attendance attendance = Optional.ofNullable(value.getAttendance()).orElse(new ContentValue.Attendance());
                        if (control.getControlParam().equals("attendance.date_range.type")) {
                            ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(attendance.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                            dateRange.setType(String.valueOf(object));
                            attendance.setDateRange(dateRange);
                        } else if (control.getControlParam().equals("attendance.date_range.new_begin")) {
                            ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(attendance.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                            if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                                dateRange.setBegin(Long.parseLong(String.valueOf(object)));
                            } else if (field.getType().equals(Timestamp.class)) {
                                Timestamp time = (Timestamp) object;
                                dateRange.setBegin(Long.valueOf(time.getTime() / 1000));
                            }
                            attendance.setDateRange(dateRange);
                        } else if (control.getControlParam().equals("attendance.date_range.new_end")) {
                            ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(attendance.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                            if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) {
                                dateRange.setEnd(Long.parseLong(String.valueOf(object)));
                            } else if (field.getType().equals(Timestamp.class)) {
                                Timestamp time = (Timestamp) object;
                                dateRange.setEnd(Long.valueOf(time.getTime() / 1000));
                            }
                            attendance.setDateRange(dateRange);
                        } else if (control.getControlParam().equals("attendance.date_range.new_duration")) {
                            ContentValue.Attendance.DataRange dateRange = Optional.ofNullable(attendance.getDateRange()).orElse(new ContentValue.Attendance.DataRange());
                            dateRange.setDuration(Long.parseLong(String.valueOf(object)));
                            attendance.setDateRange(dateRange);
                        } else if (control.getControlParam().equals("attendance.type")) {
                            attendance.setType(Integer.parseInt(String.valueOf(object)));
                        }
                        value.setAttendance(attendance);
                    }
                    field.setAccessible(accessible);
                    // 保存数据
                    applyDataContent.setValue(value);
                    List<ApplyDataContent> applyDataContents = Optional.ofNullable(applyData.getContents()).orElse(new ArrayList<>());
                    if (!applyDataContents.isEmpty() && applyDataContents.stream().anyMatch(m -> m.getControl().equals(control.getControlType()) && m.getId().equals(control.getControlId()))) {
                        applyDataContents = applyDataContents.stream().map(m -> m.getControl().equals(control.getControlType()) && m.getId().equals(control.getControlId()) ? applyDataContent : m).collect(Collectors.toList());
                    } else {
                        applyDataContents.add(applyDataContent);
                    }
                    applyData.setContents(applyDataContents);
                }
            }
            // 获取企业微信Token
            wxCpService.getAccessToken();
            // 初始化参数
            WxCpOaApplyEventRequest eventRequest = new WxCpOaApplyEventRequest();
            // 申请人userid
            eventRequest.setCreatorUserId(userWxId);
            // 模板id
            eventRequest.setTemplateId(template.getTemplateId());
            // 审批人模式
            eventRequest.setUseTemplateApprover(1);
            // 提单者提单部门id,不填默认为主部门
            eventRequest.setChooseDepartment(null);
            // 审批申请数据
            eventRequest.setApplyData(applyData);
            // 摘要信息
            eventRequest.setSummaryList(new ArrayList<>(0));
            // 发送申请请求
            String spNo = wxCpService.getOaService().apply(eventRequest);
            resultMap.put("spNo", spNo);
        } catch (WxErrorException wxErrorException) {
            // 通信失败
            wxErrorException.printStackTrace();
            resultMap.put("error", "通信失败");
        } catch (IllegalAccessException illegalAccessException) {
            // 解析后数据获取失败
            illegalAccessException.printStackTrace();
            resultMap.put("error", "解析类成员数据获取失败");
        } catch (Exception e) {
            // 处理异常
            e.printStackTrace();
            resultMap.put("error", "处理异常");
        }
        return resultMap;
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlServiceImpl.java
New file
@@ -0,0 +1,118 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.impl;
import me.zhengjie.modules.approval.domain.TemplateControl;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.approval.repository.TemplateControlRepository;
import me.zhengjie.modules.approval.service.TemplateControlService;
import me.zhengjie.modules.approval.service.dto.TemplateControlDto;
import me.zhengjie.modules.approval.service.dto.TemplateControlQueryCriteria;
import me.zhengjie.modules.approval.service.mapstruct.TemplateControlMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author baolh
* @date 2025-03-17
**/
@Service
@RequiredArgsConstructor
public class TemplateControlServiceImpl implements TemplateControlService {
    private final TemplateControlRepository templateControlRepository;
    private final TemplateControlMapper templateControlMapper;
    @Override
    public Map<String,Object> queryAll(TemplateControlQueryCriteria criteria, Pageable pageable){
        Page<TemplateControl> page = templateControlRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        return PageUtil.toPage(page.map(templateControlMapper::toDto));
    }
    @Override
    public List<TemplateControlDto> queryAll(TemplateControlQueryCriteria criteria){
        return templateControlMapper.toDto(templateControlRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public TemplateControlDto findById(Long id) {
        TemplateControl templateControl = templateControlRepository.findById(id).orElseGet(TemplateControl::new);
        ValidationUtil.isNull(templateControl.getId(),"TemplateControl","id",id);
        return templateControlMapper.toDto(templateControl);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public TemplateControlDto create(TemplateControl resources) {
        return templateControlMapper.toDto(templateControlRepository.save(resources));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(TemplateControl resources) {
        TemplateControl templateControl = templateControlRepository.findById(resources.getId()).orElseGet(TemplateControl::new);
        ValidationUtil.isNull( templateControl.getId(),"TemplateControl","id",resources.getId());
        templateControl.copy(resources);
        templateControlRepository.save(templateControl);
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            templateControlRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<TemplateControlDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (TemplateControlDto templateControl : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put(" 模版ID", templateControl.getTemplateId());
            map.put("控件类型", templateControl.getControlType());
            map.put("控件ID", templateControl.getControlId());
            map.put("占位符文本(中文)", templateControl.getPlaceholderTextZh());
            map.put("占位符文本(英文)", templateControl.getPlaceholderTextEn());
            map.put("是否必填", templateControl.getContentRequire());
            map.put("是否参与打印", templateControl.getContentPrint());
            map.put("控件设定", templateControl.getContentConfig());
            map.put("删除判定", templateControl.getDelStatus());
            map.put("创建时间", templateControl.getCreateTime());
            map.put("创建人", templateControl.getCreateBy());
            map.put("更新时间", templateControl.getUpdateTime());
            map.put("更新人", templateControl.getUpdateBy());
            map.put("标题文本(中文)", templateControl.getTitleTextZh());
            map.put("标题文本(英文)", templateControl.getTitleTextEn());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateServiceImpl.java
New file
@@ -0,0 +1,491 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.impl;
import com.alibaba.fastjson.JSONObject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.oa.WxCpCorpConfInfo;
import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateTitle;
import me.zhengjie.modules.approval.domain.Template;
import me.zhengjie.modules.approval.domain.TemplateControl;
import me.zhengjie.modules.approval.repository.TemplateControlRepository;
import me.zhengjie.modules.approval.service.dto.TemplateControlDto;
import me.zhengjie.modules.approval.service.dto.TemplateControlQueryCriteria;
import me.zhengjie.modules.approval.service.mapstruct.TemplateControlMapper;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.system.service.DictDetailService;
import me.zhengjie.modules.system.service.dto.DictDetailDto;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.approval.repository.TemplateRepository;
import me.zhengjie.modules.approval.service.TemplateService;
import me.zhengjie.modules.approval.service.dto.TemplateDto;
import me.zhengjie.modules.approval.service.dto.TemplateQueryCriteria;
import me.zhengjie.modules.approval.service.mapstruct.TemplateMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.*;
import java.io.IOException;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author baolh
* @date 2025-03-17
**/
@Service
@RequiredArgsConstructor
public class TemplateServiceImpl implements TemplateService {
    private final TemplateRepository templateRepository;
    private final TemplateControlRepository templateControlRepository;
    private final TemplateMapper templateMapper;
    private final TemplateControlMapper templateControlMapper;
    private final WxCpService wxCpService;
    private final DictDetailService dictDetailService;
    @Override
    public Map<String,Object> queryAll(TemplateQueryCriteria criteria, Pageable pageable){
        Page<Template> page = templateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        return PageUtil.toPage(page.map(templateMapper::toDto));
    }
    @Override
    public List<TemplateDto> queryAll(TemplateQueryCriteria criteria){
        return templateMapper.toDto(templateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public TemplateDto findById(Long id) {
        Template template = templateRepository.findById(id).orElseGet(Template::new);
        ValidationUtil.isNull(template.getId(),"Template","id",id);
        return templateMapper.toDto(template);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public TemplateDto create(Template resources) {
        return templateMapper.toDto(templateRepository.save(resources));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(Template resources) {
        Template template = templateRepository.findById(resources.getId()).orElseGet(Template::new);
        ValidationUtil.isNull( template.getId(),"Template","id",resources.getId());
        template.copy(resources);
        templateRepository.save(template);
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            templateRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<TemplateDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (TemplateDto template : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("模版ID(企微内)", template.getTemplateId());
            map.put("删除判定", template.getDelStatus());
            map.put("创建时间", template.getCreateTime());
            map.put("创建人", template.getCreateBy());
            map.put("更新时间", template.getUpdateTime());
            map.put("更新人", template.getUpdateBy());
            map.put("模板名称(中文)", template.getTemplateNameZh());
            map.put("模板名称(英文)", template.getTemplateNameEn());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public TemplateDto queryWeComTemplate(TemplateQueryCriteria criteria) throws Exception {
        if (StringUtils.isNotBlank(criteria.getTemplateId())) {
            try {
                if (criteria.getQueryNew()) {
                    // 获取企业微信Token
                    wxCpService.getAccessToken();
                    // 获取指定模版详细信息
                    WxCpOaApprovalTemplateResult templateResult = wxCpService.getOaService().getTemplateDetail(criteria.getTemplateId());
                    if (templateResult.getErrCode().equals(0)) {
                        // 保存模版信息
                        Template template = new Template();
                        // 模版唯一标识
                        template.setTemplateId(criteria.getTemplateId());
                        // 多语言标题
                        for (TemplateTitle templateTitle : templateResult.getTemplateNames()) {
                            if (templateTitle.getLang().equals(ElAdminConstant.Constant.TEMPLATE_LANG_ZH)) {
                                template.setTemplateNameZh(templateTitle.getText());
                            } else if (templateTitle.getLang().equals(ElAdminConstant.Constant.TEMPLATE_LANG_EN)) {
                                template.setTemplateNameEn(templateTitle.getText());
                            }
                        }
                        template.setDelStatus(ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_NORMAL);
                        TemplateDto savedTemplateDto = templateMapper.toDto(templateRepository.save(template));
                        List<TemplateControlDto> templateControlDtos = new ArrayList<>();
                        // 保存控件信息
                        for (WxCpOaApprovalTemplateResult.TemplateControls controls : templateResult.getTemplateContent().getControls()) {
                            if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_TEXT)) {
                                // 文本内容
                                TemplateControl text = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                text.setControlParam("text");
                                text.setControlParamName("文本内容");
                                TemplateControlDto textSaved = templateControlMapper.toDto(templateControlRepository.save(text));
                                templateControlDtos.add(textSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_TEXTAREA)) {
                                // 文本内容
                                TemplateControl text = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                text.setControlParam("text");
                                text.setControlParamName("文本内容");
                                TemplateControlDto textSaved = templateControlMapper.toDto(templateControlRepository.save(text));
                                templateControlDtos.add(textSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_NUMBER)) {
                                // 数字内容
                                TemplateControl newNumber = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                newNumber.setControlParam("new_number");
                                newNumber.setControlParamName("数字内容");
                                TemplateControlDto newNumberSaved = templateControlMapper.toDto(templateControlRepository.save(newNumber));
                                templateControlDtos.add(newNumberSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_MONEY)) {
                                // 金额内容
                                TemplateControl newMoney = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                newMoney.setControlParam("new_money");
                                newMoney.setControlParamName("金额内容");
                                TemplateControlDto newMoneySaved = templateControlMapper.toDto(templateControlRepository.save(newMoney));
                                templateControlDtos.add(newMoneySaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_DATE)) {
                                // 时间展示类型:day-日期;hour-日期+时间
                                TemplateControl dateType = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateType.setControlParam("date.type");
                                dateType.setControlParamName("时间展示类型");
                                TemplateControlDto dateTypeSaved = templateControlMapper.toDto(templateControlRepository.save(dateType));
                                templateControlDtos.add(dateTypeSaved);
                                // 时间戳-字符串类型
                                TemplateControl dateSTimestamp = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateSTimestamp.setControlParam("date.s_timestamp");
                                dateSTimestamp.setControlParamName("时间戳");
                                TemplateControlDto dateSTimestampSaved = templateControlMapper.toDto(templateControlRepository.save(dateSTimestamp));
                                templateControlDtos.add(dateSTimestampSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_SELECTOR)) {
                                // 选项key
                                TemplateControl selectorOptionsKey = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                selectorOptionsKey.setControlParam("selector.options[].key");
                                selectorOptionsKey.setControlParamName("选项KEY");
                                TemplateControlDto selectorOptionsKeySaved = templateControlMapper.toDto(templateControlRepository.save(selectorOptionsKey));
                                templateControlDtos.add(selectorOptionsKeySaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_CONTACT)) {
                                // 所选成员的userid
                                TemplateControl membersUserid = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                membersUserid.setControlParam("members[].userid");
                                membersUserid.setControlParamName("成员USERID");
                                TemplateControlDto membersUseridSaved = templateControlMapper.toDto(templateControlRepository.save(membersUserid));
                                templateControlDtos.add(membersUseridSaved);
                                // 成员名
                                TemplateControl membersName = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                membersName.setControlParam("members[].name");
                                membersName.setControlParamName("成员名");
                                TemplateControlDto savedNameTemplateControlDto = templateControlMapper.toDto(templateControlRepository.save(membersName));
                                templateControlDtos.add(savedNameTemplateControlDto);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_CONTACT)) {
                                // 所选部门id
                                TemplateControl departmentsOpenapiId = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                departmentsOpenapiId.setControlParam("departments[].openapi_id");
                                departmentsOpenapiId.setControlParamName("部门ID");
                                TemplateControlDto departmentsOpenapiIdSaved = templateControlMapper.toDto(templateControlRepository.save(departmentsOpenapiId));
                                templateControlDtos.add(departmentsOpenapiIdSaved);
                                // 所选部门名
                                TemplateControl departmentsName = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                departmentsName.setControlParam("departments[].name");
                                departmentsName.setControlParamName("部门名");
                                TemplateControlDto departmentsNameSaved = templateControlMapper.toDto(templateControlRepository.save(departmentsName));
                                templateControlDtos.add(departmentsNameSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_FILE)) {
                                // 文件id
                                TemplateControl filesFileId = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                filesFileId.setControlParam("files[].file_id");
                                filesFileId.setControlParamName("文件ID");
                                TemplateControlDto filesFileIdSaved = templateControlMapper.toDto(templateControlRepository.save(filesFileId));
                                templateControlDtos.add(filesFileIdSaved);
                                // 文件名称
                                TemplateControl filesFileName = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                filesFileName.setControlParam("files[].file_name");
                                filesFileName.setControlParamName("文件名称");
                                filesFileName.setContentRequire(0);
                                TemplateControlDto filesFileNameSaved = templateControlMapper.toDto(templateControlRepository.save(filesFileName));
                                templateControlDtos.add(filesFileNameSaved);
                                // 文件大小
                                TemplateControl filesFileSize = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                filesFileSize.setControlParam("files[].file_size");
                                filesFileSize.setControlParamName("文件大小");
                                filesFileSize.setContentRequire(0);
                                TemplateControlDto filesFileSizeSaved = templateControlMapper.toDto(templateControlRepository.save(filesFileSize));
                                templateControlDtos.add(filesFileSizeSaved);
                                // 文件类型
                                TemplateControl filesFileType = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                filesFileType.setControlParam("files[].file_type");
                                filesFileType.setControlParamName("文件类型");
                                filesFileType.setContentRequire(0);
                                TemplateControlDto filesFileTypeSaved = templateControlMapper.toDto(templateControlRepository.save(filesFileType));
                                templateControlDtos.add(filesFileTypeSaved);
                                // 文件地址
                                TemplateControl filesFileUrl = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                filesFileUrl.setControlParam("files[].file_url");
                                filesFileUrl.setControlParamName("文件地址");
                                filesFileUrl.setContentRequire(0);
                                TemplateControlDto filesFileUrlSaved = templateControlMapper.toDto(templateControlRepository.save(filesFileUrl));
                                templateControlDtos.add(filesFileUrlSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_TABLE)) {
                                // 明细内容
                                TemplateControl children = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                children.setControlParam("children");
                                children.setControlParamName("明细内容");
                                TemplateControlDto childrenSaved = templateControlMapper.toDto(templateControlRepository.save(children));
                                templateControlDtos.add(childrenSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_LOCATION)) {
                                // 纬度
                                TemplateControl locationLatitude = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                locationLatitude.setControlParam("location.latitude");
                                locationLatitude.setControlParamName("纬度");
                                TemplateControlDto locationLatitudeSaved = templateControlMapper.toDto(templateControlRepository.save(locationLatitude));
                                templateControlDtos.add(locationLatitudeSaved);
                                // 经度
                                TemplateControl locationLongitude = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                locationLongitude.setControlParam("location.longitude");
                                locationLongitude.setControlParamName("经度");
                                TemplateControlDto locationLongitudeSaved = templateControlMapper.toDto(templateControlRepository.save(locationLongitude));
                                templateControlDtos.add(locationLongitudeSaved);
                                // 地点标题
                                TemplateControl locationTitle = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                locationTitle.setControlParam("location.title");
                                locationTitle.setControlParamName("地点标题");
                                TemplateControlDto locationTitleSaved = templateControlMapper.toDto(templateControlRepository.save(locationTitle));
                                templateControlDtos.add(locationTitleSaved);
                                // 地点详情地址
                                TemplateControl locationAddress = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                locationAddress.setControlParam("location.address");
                                locationAddress.setControlParamName("详情地址");
                                TemplateControlDto locationAddressSaved = templateControlMapper.toDto(templateControlRepository.save(locationAddress));
                                templateControlDtos.add(locationAddressSaved);
                                // 选择地点的时间
                                TemplateControl locationTime = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                locationTime.setControlParam("location.time");
                                locationTime.setControlParamName("选择时间");
                                TemplateControlDto locationTimeSaved = templateControlMapper.toDto(templateControlRepository.save(locationTime));
                                templateControlDtos.add(locationTimeSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_RELATEDAPPROVAL)) {
                                // 关联审批单的审批单号
                                TemplateControl relatedApprovalSpNo = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                relatedApprovalSpNo.setControlParam("related_approval[].sp_no");
                                relatedApprovalSpNo.setControlParamName("审批单号");
                                TemplateControlDto relatedApprovalSpNoSaved = templateControlMapper.toDto(templateControlRepository.save(relatedApprovalSpNo));
                                templateControlDtos.add(relatedApprovalSpNoSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_FORMULA)) {
                                // 公式的值
                                TemplateControl formulaValue = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                formulaValue.setControlParam("formula.value");
                                formulaValue.setControlParamName("公式值");
                                TemplateControlDto formulaValueSaved = templateControlMapper.toDto(templateControlRepository.save(formulaValue));
                                templateControlDtos.add(formulaValueSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_DATERANGE)) {
                                // 时长粒度:halfday:按天 hour:按小时
                                TemplateControl dateRangeType = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeType.setControlParam("date_range.type");
                                dateRangeType.setControlParamName("时长粒度");
                                TemplateControlDto dateRangeTypeSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeType));
                                templateControlDtos.add(dateRangeTypeSaved);
                                // 开始时间,unix时间戳
                                TemplateControl dateRangeNewBegin = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewBegin.setControlParam("date_range.new_begin");
                                dateRangeNewBegin.setControlParamName("开始时间");
                                TemplateControlDto dateRangeNewBeginSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewBegin));
                                templateControlDtos.add(dateRangeNewBeginSaved);
                                // 结束时间,unix时间戳
                                TemplateControl dateRangeNewEnd = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewEnd.setControlParam("date_range.new_end");
                                dateRangeNewEnd.setControlParamName("结束时间");
                                TemplateControlDto dateRangeNewEndSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewEnd));
                                templateControlDtos.add(dateRangeNewEndSaved);
                                // 时长范围, 单位秒
                                TemplateControl dateRangeNewDuration = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewDuration.setControlParam("date_range.new_duration");
                                dateRangeNewDuration.setControlParamName("时长范围");
                                TemplateControlDto dateRangeNewDurationSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewDuration));
                                templateControlDtos.add(dateRangeNewDurationSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_VACATION)) {
                                // 假勤组件需要获取假期相关配置
                                WxCpCorpConfInfo corpConfInfo = wxCpService.getOaService().getCorpConf();
                                // 选项key
                                TemplateControl key = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                key.setControlParam("vacation.selector.options[].key");
                                key.setControlParamName("选项KEY");
                                key.setContentConfig(corpConfInfo.getLists().toString());
                                TemplateControlDto keySaved = templateControlMapper.toDto(templateControlRepository.save(key));
                                templateControlDtos.add(keySaved);
    //                            // 选项值
    //                            TemplateControl value = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
    //                            value.setControlParam("vacation.selector.options[].value");
    //                            value.setControlParamName("选项值");
    //                            value.setContentConfig(corpConfInfo.getLists().toString());
    //                            TemplateControlDto valueSaved = templateControlMapper.toDto(templateControlRepository.save(value));
    //                            templateControlDtos.add(valueSaved);
                                // 时长粒度:halfday:按天 hour:按小时
                                TemplateControl dateRangeType = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeType.setControlParam("vacation.attendance.date_range.type");
                                dateRangeType.setControlParamName("时长粒度");
                                dateRangeType.setContentConfig(corpConfInfo.getLists().toString());
                                TemplateControlDto dateRangeTypeSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeType));
                                templateControlDtos.add(dateRangeTypeSaved);
                                // 开始时间戳
                                TemplateControl dateRangeNewBegin = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewBegin.setControlParam("vacation.attendance.date_range.new_begin");
                                dateRangeNewBegin.setControlParamName("开始时间");
                                dateRangeNewBegin.setContentConfig(corpConfInfo.getLists().toString());
                                TemplateControlDto dateRangeNewBeginSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewBegin));
                                templateControlDtos.add(dateRangeNewBeginSaved);
                                // 结束时间戳
                                TemplateControl dateRangeNewEnd = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewEnd.setControlParam("vacation.attendance.date_range.new_end");
                                dateRangeNewEnd.setControlParamName("结束时间");
                                dateRangeNewEnd.setContentConfig(corpConfInfo.getLists().toString());
                                TemplateControlDto dateRangeNewEndSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewEnd));
                                templateControlDtos.add(dateRangeNewEndSaved);
                                // 申请时长
                                TemplateControl dateRangeNewDuration = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewDuration.setControlParam("vacation.attendance.date_range.new_duration");
                                dateRangeNewDuration.setControlParamName("申请时长");
                                dateRangeNewDuration.setContentConfig(corpConfInfo.getLists().toString());
                                TemplateControlDto dateRangeNewDurationSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewDuration));
                                templateControlDtos.add(dateRangeNewDurationSaved);
                            } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_ATTENDANCE)) {
                                // 时长粒度:halfday:按天 hour:按小时
                                TemplateControl dateRangeType = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeType.setControlParam("attendance.date_range.type");
                                dateRangeType.setControlParamName("时长粒度");
                                TemplateControlDto dateRangeTypeSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeType));
                                templateControlDtos.add(dateRangeTypeSaved);
                                // 开始时间戳
                                TemplateControl dateRangeNewBegin = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewBegin.setControlParam("attendance.date_range.new_begin");
                                dateRangeNewBegin.setControlParamName("开始时间");
                                TemplateControlDto dateRangeNewBeginSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewBegin));
                                templateControlDtos.add(dateRangeNewBeginSaved);
                                // 结束时间戳
                                TemplateControl dateRangeNewEnd = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewEnd.setControlParam("attendance.date_range.new_end");
                                dateRangeNewEnd.setControlParamName("结束时间");
                                TemplateControlDto dateRangeNewEndSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewEnd));
                                templateControlDtos.add(dateRangeNewEndSaved);
                                // 申请时长
                                TemplateControl dateRangeNewDuration = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                dateRangeNewDuration.setControlParam("attendance.date_range.new_duration");
                                dateRangeNewDuration.setControlParamName("申请时长");
                                TemplateControlDto dateRangeNewDurationSaved = templateControlMapper.toDto(templateControlRepository.save(dateRangeNewDuration));
                                templateControlDtos.add(dateRangeNewDurationSaved);
                                // 假勤组件类型:1-请假;3-出差;4-外出;5-加班
                                TemplateControl attendanceType = makeDefaultTemplateControl(savedTemplateDto.getId(), controls);
                                attendanceType.setControlParam("attendance.type");
                                attendanceType.setControlParamName("假勤类型");
                                TemplateControlDto attendanceTypeSaved = templateControlMapper.toDto(templateControlRepository.save(attendanceType));
                                templateControlDtos.add(attendanceTypeSaved);
                            }
                        }
                        // 控件信息放入模版
                        savedTemplateDto.setTemplateControls(templateControlDtos);
                        return savedTemplateDto;
                    } else {
                        throw new Exception("数据获取失败");
                    }
                } else {
                    criteria.setDelStatus(ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_NORMAL);
                    List<Template> templateList = templateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder), Sort.by(Sort.Direction.DESC, "id"));
                    if (templateList.size() > 0) {
                        TemplateDto templateDto = templateMapper.toDto(templateList.get(0));
                        TemplateControlQueryCriteria controlCriteria = new TemplateControlQueryCriteria();
                        controlCriteria.setTemplateId(templateDto.getId());
                        List<TemplateControl> templateControlList = templateControlRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,controlCriteria,criteriaBuilder));
                        templateDto.setTemplateControls(templateControlMapper.toDto(templateControlList));
                        return templateDto;
                    } else {
                        throw new Exception("数据不存在");
                    }
                }
            } catch (WxErrorException wxErrorException) {
                wxErrorException.printStackTrace();
                throw new Exception("数据读取失败");
            }
        } else {
            throw new Exception("缺少必要参数");
        }
    }
    private TemplateControl makeDefaultTemplateControl(Long pid, WxCpOaApprovalTemplateResult.TemplateControls controls) {
        TemplateControl templateControl = new TemplateControl();
        templateControl.setTemplateId(pid);
        templateControl.setControlType(controls.getProperty().getControl());
        templateControl.setControlId(controls.getProperty().getId());
        // 多语言标题
        for (TemplateTitle title : controls.getProperty().getTitle()) {
            if (title.getLang().equals(ElAdminConstant.Constant.TEMPLATE_LANG_ZH)) {
                templateControl.setTitleTextZh(title.getText());
            } else if (title.getLang().equals(ElAdminConstant.Constant.TEMPLATE_LANG_EN)) {
                templateControl.setTitleTextEn(title.getText());
            }
        }
        // 多语言填写说明
        for (TemplateTitle placeholder : controls.getProperty().getPlaceholder()) {
            if (placeholder.getLang().equals(ElAdminConstant.Constant.TEMPLATE_LANG_ZH)) {
                templateControl.setPlaceholderTextZh(placeholder.getText());
            } else if (placeholder.getLang().equals(ElAdminConstant.Constant.TEMPLATE_LANG_EN)) {
                templateControl.setPlaceholderTextEn(placeholder.getText());
            }
        }
        templateControl.setContentRequire(controls.getProperty().getRequire());
        templateControl.setContentPrint(controls.getProperty().getUnPrint());
        templateControl.setContentConfig(ObjectUtils.isNotEmpty(controls.getConfig()) ? JSONObject.toJSONString(controls.getConfig()) : null);
        templateControl.setDelStatus(ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_NORMAL);
        return templateControl;
    }
    @Override
    public String getVacationKey(String type) {
        List<DictDetailDto> dictDetailDtos = dictDetailService.getDictByName(Constant.WECOM_LEAVE_TYPE);
        List<String> ids = dictDetailDtos.stream().filter(i -> i.getLabel().equals(type)).map(m -> m.getValue()).collect(Collectors.toList());
        if (ids.size() > 0) {
            return ids.get(0);
        }
        return null;
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/mapstruct/ApproveEventMapper.java
New file
@@ -0,0 +1,32 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.service.dto.ApproveEventDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ApproveEventMapper extends BaseMapper<ApproveEventDto, ApproveEvent> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/mapstruct/TemplateControlFieldMapper.java
New file
@@ -0,0 +1,32 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.approval.domain.TemplateControlField;
import me.zhengjie.modules.approval.service.dto.TemplateControlFieldDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TemplateControlFieldMapper extends BaseMapper<TemplateControlFieldDto, TemplateControlField> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/mapstruct/TemplateControlMapper.java
New file
@@ -0,0 +1,32 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.approval.domain.TemplateControl;
import me.zhengjie.modules.approval.service.dto.TemplateControlDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TemplateControlMapper extends BaseMapper<TemplateControlDto, TemplateControl> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/mapstruct/TemplateMapper.java
New file
@@ -0,0 +1,32 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.approval.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.approval.domain.Template;
import me.zhengjie.modules.approval.service.dto.TemplateDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2025-03-17
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TemplateMapper extends BaseMapper<TemplateDto, Template> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java
@@ -102,6 +102,29 @@
    @ApiModelProperty(value = "备注")
    private String remarks;
    @Column(name = "`wecom_sp_no`")
    @ApiModelProperty(value = "企微审批单号")
    private String wecomSpNo;
    @Column(name = "`wecom_event_id`")
    @ApiModelProperty(value = "企微最新审批变化记录ID")
    private Long wecomEventId;
    @Column(name = "`wecom_location`")
    @ApiModelProperty(value = "企微出差地点")
    private String wecomLocation;
    @Column(name = "`wecom_date_type`")
    @ApiModelProperty(value = "企微时长粒度")
    private String wecomDateType;
    @Column(name = "`wecom_duration`")
    @ApiModelProperty(value = "企微申请时长")
    private String wecomDuration;
    @Column(name = "`wecom_attendance_type`")
    @ApiModelProperty(value = "企微假勤类型(固定值)")
    private String wecomAttendanceType;
    public void copy(AttendanceBusinessTravel source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceCardreplacement.java
@@ -79,6 +79,21 @@
    @ApiModelProperty(value = "备注")
    private String remarks;
    @Column(name = "`wecom_sp_no`")
    @ApiModelProperty(value = "企微审批单号")
    private String wecomSpNo;
    @Column(name = "`wecom_event_id`")
    @ApiModelProperty(value = "企微最新审批变化记录ID")
    private Long wecomEventId;
    @Column(name = "`wecom_date_type`")
    @ApiModelProperty(value = "企微时长粒度")
    private String wecomDateType;
    @Column(name = "`wecom_type_option_val`")
    @ApiModelProperty(value = "企微补卡类型选项值")
    private String wecomTypeOptionVal;
    public void copy(AttendanceCardreplacement source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceGoOut.java
@@ -95,6 +95,33 @@
    @ApiModelProperty(value = "备注")
    private String remarks;
    @Column(name = "`wecom_sp_no`")
    @ApiModelProperty(value = "企微审批单号")
    private String wecomSpNo;
    @Column(name = "`wecom_event_id`")
    @ApiModelProperty(value = "企微最新审批变化记录ID")
    private Long wecomEventId;
    @Column(name = "`wecom_type`")
    @ApiModelProperty(value = "企微外出类型")
    private String wecomType;
    @Column(name = "`wecom_location`")
    @ApiModelProperty(value = "企微外出地点")
    private String wecomLocation;
    @Column(name = "`wecom_date_type`")
    @ApiModelProperty(value = "企微时长粒度")
    private String wecomDateType;
    @Column(name = "`wecom_duration`")
    @ApiModelProperty(value = "企微申请时长")
    private String wecomDuration;
    @Column(name = "`wecom_attendance_type`")
    @ApiModelProperty(value = "企微假勤类型(固定值)")
    private String wecomAttendanceType;
    public void copy(AttendanceGoOut source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceLeave.java
@@ -94,6 +94,26 @@
    @ApiModelProperty(value = "备注")
    private String remarks;
    @Column(name = "`wecom_sp_no`")
    @ApiModelProperty(value = "企微审批单号")
    private String wecomSpNo;
    @Column(name = "`wecom_event_id`")
    @ApiModelProperty(value = "企微最新审批变化记录ID")
    private Long wecomEventId;
    @Column(name = "`wecom_option_key`")
    @ApiModelProperty(value = "企微请假类型KEY")
    private String wecomOptionKey;
    @Column(name = "`wecom_date_type`")
    @ApiModelProperty(value = "企微时长粒度")
    private String wecomDateType;
    @Column(name = "`wecom_duration`")
    @ApiModelProperty(value = "企微申请时长")
    private String wecomDuration;
    public void copy(AttendanceLeave source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceOvertime.java
@@ -86,6 +86,25 @@
    @ApiModelProperty(value = "备注")
    private String remarks;
    @Column(name = "`wecom_sp_no`")
    @ApiModelProperty(value = "企微审批单号")
    private String wecomSpNo;
    @Column(name = "`wecom_event_id`")
    @ApiModelProperty(value = "企微最新审批变化记录ID")
    private Long wecomEventId;
    @Column(name = "`wecom_date_type`")
    @ApiModelProperty(value = "企微时长粒度")
    private String wecomDateType;
    @Column(name = "`wecom_duration`")
    @ApiModelProperty(value = "企微申请时长")
    private String wecomDuration;
    @Column(name = "`wecom_attendance_type`")
    @ApiModelProperty(value = "企微假勤类型(固定值)")
    private String wecomAttendanceType;
    public void copy(AttendanceOvertime source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java
@@ -17,6 +17,7 @@
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import me.zhengjie.modules.approval.service.dto.ApproveEventDto;
import java.sql.Timestamp;
import java.io.Serializable;
@@ -75,4 +76,10 @@
    private String userName;
    private String appUserName;
    /** 企微审批单号 */
    private String wecomSpNo;
    /** 企微最新审批变化记录 */
    private ApproveEventDto event;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelQueryCriteria.java
@@ -54,4 +54,7 @@
    /* 模糊 */
    @Query(propName = "travelEndTime", type = Query.Type.INNER_LIKE)
    private String travelEndTimeLike;
    @Query(type = Query.Type.EQUAL)
    private String wecomSpNo;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceCardreplacementDto.java
@@ -17,6 +17,7 @@
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import me.zhengjie.modules.approval.service.dto.ApproveEventDto;
import java.sql.Timestamp;
import java.io.Serializable;
@@ -63,4 +64,9 @@
    /** 审批人 */
    private String appUserName;
    /** 企微审批单号 */
    private String wecomSpNo;
    /** 企微最新审批变化记录 */
    private ApproveEventDto event;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceCardreplacementQueryCriteria.java
@@ -49,4 +49,7 @@
//    @Query(isOr  = "userId,approvalUserId")
//    private Long approver;
    @Query(type = Query.Type.EQUAL)
    private String wecomSpNo;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutDto.java
@@ -17,6 +17,7 @@
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import me.zhengjie.modules.approval.service.dto.ApproveEventDto;
import java.sql.Timestamp;
import java.io.Serializable;
@@ -69,4 +70,10 @@
    private String userName;
    private String appUserName;
    /** 企微审批单号 */
    private String wecomSpNo;
    /** 企微最新审批变化记录 */
    private ApproveEventDto event;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutQueryCriteria.java
@@ -58,4 +58,7 @@
    /* 模糊 */
    @Query(propName = "outEndTime", type = Query.Type.INNER_LIKE)
    private String outEndTimeLike;
    @Query(type = Query.Type.EQUAL)
    private String wecomSpNo;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveDto.java
@@ -17,6 +17,7 @@
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import me.zhengjie.modules.approval.service.dto.ApproveEventDto;
import java.sql.Timestamp;
import java.io.Serializable;
@@ -72,4 +73,9 @@
    /** 审批用户名 */
    private String appUserName;
    /** 企微审批单号 */
    private String wecomSpNo;
    /** 企微最新审批变化记录 */
    private ApproveEventDto event;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java
@@ -58,4 +58,7 @@
    /* 模糊 */
    @Query(propName = "leaveEndTime", type = Query.Type.INNER_LIKE)
    private String leaveEndTimeLike;
    @Query(type = Query.Type.EQUAL)
    private String wecomSpNo;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceOvertimeDto.java
@@ -17,6 +17,7 @@
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import me.zhengjie.modules.approval.service.dto.ApproveEventDto;
import java.io.Serializable;
import java.sql.Timestamp;
@@ -69,4 +70,9 @@
    /** 审批用户名 */
    private String appUserName;
    /** 企微审批单号 */
    private String wecomSpNo;
    /** 企微最新审批变化记录 */
    private ApproveEventDto event;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceOvertimeQueryCriteria.java
@@ -47,4 +47,6 @@
    @Query(type = Query.Type.BETWEEN, propName = "overtimeEndTime")
    private List<Timestamp> overtimeEndTime;
    @Query(type = Query.Type.EQUAL)
    private String wecomSpNo;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceBusinessTravelServiceImpl.java
@@ -16,11 +16,14 @@
package me.zhengjie.modules.attendance.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.repository.ApproveEventRepository;
import me.zhengjie.modules.approval.service.TemplateControlFieldService;
import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
import me.zhengjie.modules.attendance.domain.*;
import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository;
import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.domain.DictDetail;
import me.zhengjie.modules.system.domain.Role;
@@ -67,12 +70,14 @@
    private final AttendanceBusinessTravelMapper attendanceBusinessTravelMapper;
    private final UserRepository userRepository;
    private final UserService userService;
    private final OpaiDingTalkService opaiDingTalkService;
    private final AttendanceLeaveServiceImpl attendanceLeaveService;
    private final AttendanceLeaveRepository attendanceLeaveRepository;
    private final AttendanceGoOutRepository attendanceGoOutRepository;
    private final ApproveEventRepository approveEventRepository;
    private final ApproveEventMapper approveEventMapper;
    private final DictDetailRepository dictDetailRepository;
    private final WeComServiceImpl weComService;
    private final TemplateControlFieldService templateControlFieldService;
    @Override
    public Map<String, Object> queryAll(AttendanceBusinessTravelQueryCriteria criteria, Pageable pageable) {
@@ -84,12 +89,19 @@
            public AttendanceBusinessTravelDto apply(AttendanceBusinessTravel attendanceBusinessTravel) {
                // 将实体类转换成DTO
                AttendanceBusinessTravelDto attendanceBusinessTravelDto = attendanceBusinessTravelMapper.toDto(attendanceBusinessTravel);
                //查询用户信息
                UserDto user = userService.findById(attendanceBusinessTravelDto.getUserId());
                // 查询用户信息
                User user = userRepository.findById(attendanceBusinessTravelDto.getUserId()).orElseGet(User::new);
                attendanceBusinessTravelDto.setUserName(user.getNickName());
                //查询审批用户名
                UserDto appUser = userService.findById(attendanceBusinessTravelDto.getApprovalUserId());
                // 查询审批用户名
                User appUser = userRepository.findById(attendanceBusinessTravelDto.getApprovalUserId()).orElseGet(User::new);
                attendanceBusinessTravelDto.setAppUserName(appUser.getNickName());
                // 查询企微最新审批变化记录
                if (ObjectUtils.isNotEmpty(attendanceBusinessTravel.getWecomEventId())) {
                    ApproveEvent event = approveEventRepository.findById(attendanceBusinessTravel.getWecomEventId()).orElseGet(ApproveEvent::new);
                    attendanceBusinessTravelDto.setEvent(approveEventMapper.toDto(event));
                }
                return attendanceBusinessTravelDto;
            }
        };
@@ -165,16 +177,29 @@
                c.add(Calendar.MINUTE, 59);
                c.add(Calendar.SECOND, 59);//  加一  天
                attendanceBusinessTravel.setTravelEndTime(new Timestamp(c.getTimeInMillis()));
                // 判断是否提交企微审批
                List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
                if (siteTypes.size() > 0) {
                    // 添加企微申请参数
                    attendanceBusinessTravel.setWecomLocation(String.format("%s -至- %s", Optional.ofNullable(attendanceBusinessTravel.getDepartureCity()).orElse("出发城市"), Optional.ofNullable(attendanceBusinessTravel.getArrivalCity()).orElse("到达城市")));
                    attendanceBusinessTravel.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HALFDAY);
                    attendanceBusinessTravel.setWecomDuration(String.valueOf(new BigDecimal(attendanceBusinessTravel.getTravelDuration()).multiply(new BigDecimal(86400)).longValue()));
                    attendanceBusinessTravel.setWecomAttendanceType("3");
                    // 提交申请
                    String weComId = userRepository.findById(attendanceBusinessTravel.getUserId()).orElse(new User()).getWeComId();
                    Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(attendanceBusinessTravel, weComId);
                    if (approvalResultMap.containsKey("spNo")) {
                        attendanceBusinessTravel.setWecomSpNo(approvalResultMap.get("spNo"));
                    } else {
                        throw new BadRequestException(approvalResultMap.containsKey("error") ? approvalResultMap.get("error") : "企微申请提交失败");
                    }
                }
                i++;
                attendanceBusinessTravelRepository.save(attendanceBusinessTravel);
//                }
            }
            //发送钉钉给审批人
            List<String> sendList = new ArrayList<>();
            //查询审批者信息
            User appUser = userRepository.getOne(resources.getApprovalUserId());
            sendList.add(appUser.getDingding());
            opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了出差审批,请登录PMS系统处理", "card");
        }
        return attendanceBusinessTravelMapper.toDto(resources);
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java
@@ -16,13 +16,16 @@
package me.zhengjie.modules.attendance.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.repository.ApproveEventRepository;
import me.zhengjie.modules.approval.service.TemplateControlFieldService;
import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
import me.zhengjie.modules.attendance.domain.AgreeUpdateRequest;
import me.zhengjie.modules.attendance.domain.Attendance;
import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
import me.zhengjie.modules.attendance.repository.AttendanceRepository;
import me.zhengjie.modules.attendance.service.dto.AttendanceDto;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.system.domain.*;
import me.zhengjie.modules.system.repository.*;
import me.zhengjie.modules.system.service.SysConfigHolidayService;
@@ -46,6 +49,7 @@
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @website https://eladmin.vip
@@ -60,12 +64,14 @@
    private final AttendanceCardreplacementRepository attendanceCardreplacementRepository;
    private final AttendanceCardreplacementMapper attendanceCardreplacementMapper;
    private final UserRepository userRepository;
    private final OpaiDingTalkService opaiDingTalkService;
    private final RoleRepository roleRepository;
    private final AttendanceRepository attendanceRepository;
    private final SysConfigProportionRepository sysConfigProportionRepository;
    private final DictDetailRepository dictDetailRepository;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final ApproveEventRepository approveEventRepository;
    private final ApproveEventMapper approveEventMapper;
    private final TemplateControlFieldService templateControlFieldService;
    @Override
    public Map<String,Object> queryAll(AttendanceCardreplacementQueryCriteria criteria, Pageable pageable){
@@ -85,6 +91,13 @@
                //查询申请人信息
                User appUser = userRepository.findById(attendanceCardreplacementDto.getApprovalUserId()).orElseGet(User::new);
                attendanceCardreplacementDto.setAppUserName(appUser.getNickName());
                // 查询企微最新审批变化记录
                if (ObjectUtils.isNotEmpty(attendanceCardreplacement.getWecomEventId())) {
                    ApproveEvent event = approveEventRepository.findById(attendanceCardreplacement.getWecomEventId()).orElseGet(ApproveEvent::new);
                    attendanceCardreplacementDto.setEvent(approveEventMapper.toDto(event));
                }
                return attendanceCardreplacementDto;
            }
        };
@@ -135,14 +148,23 @@
        resources.setApprovalStatus(Constant.CARD_APPROVE_STATUS_REVIEWED);
        //发送给审批者
        List<String> sendList = new ArrayList<>();
        //查询申请人信息
        User user = userRepository.getOne(resources.getUserId());
        //查询审批者信息
        User appUser = userRepository.getOne(resources.getApprovalUserId());
        sendList.add(appUser.getDingding());
        opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了补卡审批,请登录PMS系统处理", "card");
        // 判断是否提交企微审批
        List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
        if (siteTypes.size() > 0) {
            // 添加企微申请参数
            resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR);
            Map<String, String> cardTypeMap = dictDetailRepository.findByDictName(Constant.CARD_REPLACEMENT_DIFFERENTIATION).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel));
            resources.setWecomTypeOptionVal(cardTypeMap.get(resources.getCardReplacementDistinguish()));
            // 提交申请
            String weComId = userRepository.findById(resources.getUserId()).orElse(new User()).getWeComId();
            Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(resources, weComId);
            if (approvalResultMap.containsKey("spNo")) {
                resources.setWecomSpNo(approvalResultMap.get("spNo"));
            } else {
                throw new BadRequestException(approvalResultMap.containsKey("error") ? approvalResultMap.get("error") : "企微申请提交失败");
            }
        }
        return attendanceCardreplacementMapper.toDto(attendanceCardreplacementRepository.save(resources));
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java
@@ -1,22 +1,26 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.attendance.service.impl;
import lombok.RequiredArgsConstructor;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.repository.ApproveEventRepository;
import me.zhengjie.modules.approval.service.TemplateControlFieldService;
import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
import me.zhengjie.modules.attendance.domain.*;
import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository;
import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository;
@@ -29,8 +33,8 @@
import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutQueryCriteria;
import me.zhengjie.modules.attendance.service.mapstruct.AttendanceGoOutMapper;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.domain.DictDetail;
import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.domain.SysRostering;
import me.zhengjie.modules.system.domain.User;
@@ -56,14 +60,15 @@
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author wcd
* @date 2023-01-04
**/
 * @author wcd
 * @website https://eladmin.vip
 * @description 服务实现
 * @date 2023-01-04
 **/
@Service
@RequiredArgsConstructor
public class AttendanceGoOutServiceImpl implements AttendanceGoOutService {
@@ -75,21 +80,23 @@
    private final AttendanceService attendanceService;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final AttendanceLeaveServiceImpl attendanceLeaveService;
    private final OpaiDingTalkService opaiDingTalkService;
    private final AttendanceRepository attendanceRepository;
    private final AttendanceLeaveRepository attendanceLeaveRepository;
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final ApproveEventRepository approveEventRepository;
    private final ApproveEventMapper approveEventMapper;
    private final DictDetailRepository dictDetailRepository;
    private final WeComServiceImpl weComService;
    private final TemplateControlFieldService templateControlFieldService;
    private final SysConfigHolidayService sysConfigHolidayService;
    @Override
    public Map<String,Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable){
        Page<AttendanceGoOut> page = attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
    public Map<String, Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable) {
        Page<AttendanceGoOut> page = attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
        //将实体转换为Dto(重写)
        Function<AttendanceGoOut, AttendanceGoOutDto> func = new Function<AttendanceGoOut, AttendanceGoOutDto>(){
        Function<AttendanceGoOut, AttendanceGoOutDto> func = new Function<AttendanceGoOut, AttendanceGoOutDto>() {
            @Override
            public AttendanceGoOutDto apply(AttendanceGoOut attendanceGoOut) {
@@ -101,6 +108,13 @@
                //查询审批用户名
                User appUser = userRepository.findById(attendanceGoOutDto.getApprovalUserId()).orElseGet(User::new);
                attendanceGoOutDto.setAppUserName(appUser.getNickName());
                // 查询企微最新审批变化记录
                if (ObjectUtils.isNotEmpty(attendanceGoOut.getWecomEventId())) {
                    ApproveEvent event = approveEventRepository.findById(attendanceGoOut.getWecomEventId()).orElseGet(ApproveEvent::new);
                    attendanceGoOutDto.setEvent(approveEventMapper.toDto(event));
                }
                return attendanceGoOutDto;
            }
        };
@@ -108,7 +122,7 @@
    }
    @Override
    public List<AttendanceGoOutDto> queryAll(AttendanceGoOutQueryCriteria criteria){
    public List<AttendanceGoOutDto> queryAll(AttendanceGoOutQueryCriteria criteria) {
        List<AttendanceGoOutDto> attendanceGoOutDtoList = attendanceGoOutMapper.toDto(attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
        attendanceGoOutDtoList.forEach(attendanceGoOutDto -> {
            //查询用户信息
@@ -125,7 +139,7 @@
    @Transactional
    public AttendanceGoOutDto findById(Long id) {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(id).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull(attendanceGoOut.getId(),"AttendanceGoOut","id",id);
        ValidationUtil.isNull(attendanceGoOut.getId(), "AttendanceGoOut", "id", id);
        return attendanceGoOutMapper.toDto(attendanceGoOut);
    }
@@ -168,19 +182,39 @@
//                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
//                if ((sysConfigHolidayDto == null && !isWeekend) ||
//                        sysConfigHolidayDto != null && Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDto.getDateType())) {
                    AttendanceGoOut attendanceGoOut = new AttendanceGoOut();
                    //resUserId为null说明是添加,反之
                    if (resources.getUserId() == null) {
                        resources.setUserId(user.getId());
                    }
                    resources.setOutStartTime(Timestamp.valueOf(localDate.atTime(startTime)));
                    resources.setOutEndTime(Timestamp.valueOf(localDate.atTime(endTime)));
                AttendanceGoOut attendanceGoOut = new AttendanceGoOut();
                //resUserId为null说明是添加,反之
                if (resources.getUserId() == null) {
                    resources.setUserId(user.getId());
                }
                resources.setOutStartTime(Timestamp.valueOf(localDate.atTime(startTime)));
                resources.setOutEndTime(Timestamp.valueOf(localDate.atTime(endTime)));
                    Double result = getRemainingTime(resources);
                    resources.setOutDuration(result);
                    resources.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED);
                    attendanceGoOut.copy(resources);
                    attendanceGoOutRepository.save(attendanceGoOut);
                Double result = getRemainingTime(resources);
                resources.setOutDuration(result);
                resources.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED);
                // 判断是否提交企微审批
                List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
                if (siteTypes.size() > 0) {
                    // 添加企微申请参数
                    resources.setWecomType(dictDetailRepository.findByDictNameAndValue("go_out_type", resources.getOutOfOfficeType()).getLabel());
                    resources.setWecomLocation("暂无");
                    resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR);
                    resources.setWecomDuration(String.valueOf(new BigDecimal(resources.getOutDuration()).multiply(new BigDecimal(3600)).longValue()));
                    resources.setWecomAttendanceType("4");
                    // 提交申请
                    String weComId = userRepository.findById(resources.getUserId()).orElse(new User()).getWeComId();
                    Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(resources, weComId);
                    if (approvalResultMap.containsKey("spNo")) {
                        resources.setWecomSpNo(approvalResultMap.get("spNo"));
                    } else {
                        throw new BadRequestException(approvalResultMap.containsKey("error") ? approvalResultMap.get("error") : "企微申请提交失败");
                    }
                }
                attendanceGoOut.copy(resources);
                attendanceGoOutRepository.save(attendanceGoOut);
//                }
//                SysConfigHolidayDto sysConfigHolidayDto = sysConfigHolidayService.queryByHolidayDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
@@ -222,12 +256,6 @@
//                    attendanceGoOutRepository.save(attendanceGoOut);
//                }
//            }
            //发送钉钉给审批人
            List<String> sendList = new ArrayList<>();
            //查询审批者信息
            User appUser = userRepository.getOne(resources.getApprovalUserId());
            sendList.add(appUser.getDingding());
            opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了外出审批,请登录PMS系统处理", "card");
        }
        return attendanceGoOutMapper.toDto(resources);
    }
@@ -236,11 +264,11 @@
    @Transactional(rollbackFor = Exception.class)
    public void update(AttendanceGoOut resources) {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId());
        ValidationUtil.isNull(attendanceGoOut.getId(), "AttendanceGoOut", "id", resources.getId());
        attendanceGoOut.copy(resources);
        //审核通过或者退回不能修改
        if(attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)){
        if (attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)) {
            throw new BadRequestException("审核通过或退回的不能进行修改");
        }
@@ -248,8 +276,8 @@
        User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Role role = user1.getRoles().iterator().next();
        //除超管、总经理只能修改自己信息
        if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
        if (role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL) {
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())) {
                throw new BadRequestException("只能修改自己的记录");
            }
        }
@@ -387,21 +415,22 @@
    /**
     * 验证其他状态的表是否有重复
     *
     * @param goStartTime
     * @param goEndTime
     */
    public void repeatValidation(String goStartTime, String goEndTime, Long userId){
    public void repeatValidation(String goStartTime, String goEndTime, Long userId) {
        // 查询请假表(时单位)
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(goStartTime,goEndTime, userId);
        if(attendanceLeaveList.size() > 0){
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(goStartTime, goEndTime, userId);
        if (attendanceLeaveList.size() > 0) {
            AttendanceLeave errorSysAskForLeave = attendanceLeaveList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime())
                    + "已经存在请假记录,请调整时间");
        }
        // 查询出差表
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(goStartTime.substring(0,10),goEndTime.substring(0,10), userId);
        if(attendanceBusinessTravelList.size() > 0){
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(goStartTime.substring(0, 10), goEndTime.substring(0, 10), userId);
        if (attendanceBusinessTravelList.size() > 0) {
            AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("出差时间冲突," + errorFormat.format(errorSysAskForLeave.getTravelStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getTravelEndTime())
@@ -415,7 +444,7 @@
            //根据id查询记录
            Optional<AttendanceGoOut> attendanceGoOut = attendanceGoOutRepository.findById(id);
            //审核通过或者退回不能删除
            if(attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)){
            if (attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)) {
                throw new BadRequestException("审核通过或退回的不能进行删除");
            }
@@ -423,8 +452,8 @@
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            Role role = user.getRoles().iterator().next();
            //除超管、总经理只能删除自己信息
            if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
                if (!Long.valueOf(attendanceGoOut.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
            if (role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL) {
                if (!Long.valueOf(attendanceGoOut.get().getUserId()).equals(SecurityUtils.getCurrentUserId())) {
                    throw new BadRequestException("只能删除自己的记录");
                }
            }
@@ -439,7 +468,7 @@
        for (AttendanceGoOutDto attendanceGoOut : all) {
            String outOfOfficeType = attendanceGoOut.getOutOfOfficeType() != null ? dictDetailRepository.findByDictNameAndValue("go_out_type", attendanceGoOut.getOutOfOfficeType()).getLabel() : "";
            String outDurationUnit = attendanceGoOut.getDurationUnit() != null ? dictDetailRepository.findByDictNameAndValue(Constant.LEAVE_TIME_TYPE, attendanceGoOut.getDurationUnit()).getLabel() : "";
            Map<String,Object> map = new LinkedHashMap<>();
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("申请者", attendanceGoOut.getUserName());
            map.put("审批者", attendanceGoOut.getAppUserName());
            map.put("外出开始时间", attendanceGoOut.getOutStartTime());
@@ -462,6 +491,7 @@
    /**
     * 计算外出时长
     *
     * @param attendanceGoOut
     * @return
     */
@@ -525,27 +555,29 @@
    /**
     * 审核/撤销功能
     *
     * @param resources /
     */
    @Override
    public void updateApprove(AttendanceGoOut resources) throws Exception {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId());
        ValidationUtil.isNull(attendanceGoOut.getId(), "AttendanceGoOut", "id", resources.getId());
        attendanceGoOut.copy(resources);
        attendanceGoOutRepository.save(attendanceGoOut);
        // 调用定时任务修改考勤记录
        List<User> userList = new ArrayList<>();
        if(ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())){
        if (ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())) {
            User user = userRepository.findById(attendanceGoOut.getUserId()).orElseGet(User::new);
            userList.add(user);
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String attendanceDate = df.format(attendanceGoOut.getOutStartTime());
        weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate,userList);
        weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
    }
    /**
     * 批量审核(外出)
     *
     * @param request
     * @throws Exception
     */
@@ -553,8 +585,8 @@
    public void updateAgree(AgreeUpdateRequest request) throws Exception {
        for (Long id : request.getIds()) {
            AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(id).orElseGet(AttendanceGoOut::new);
            ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",id);
            if (request.getNum().equals(Long.valueOf(1))){
            ValidationUtil.isNull(attendanceGoOut.getId(), "AttendanceGoOut", "id", id);
            if (request.getNum().equals(Long.valueOf(1))) {
                attendanceGoOut.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_AGREE);
            } else {
                attendanceGoOut.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REFUSE);
@@ -562,13 +594,13 @@
            attendanceGoOutRepository.save(attendanceGoOut);
            // 调用定时任务修改考勤记录
            List<User> userList = new ArrayList<>();
            if(ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())){
            if (ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())) {
                User user = userRepository.findById(attendanceGoOut.getUserId()).orElseGet(User::new);
                userList.add(user);
            }
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            String attendanceDate = df.format(attendanceGoOut.getOutStartTime());
            weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate,userList);
            weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
        }
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
@@ -1,22 +1,27 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.attendance.service.impl;
import lombok.RequiredArgsConstructor;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.repository.ApproveEventRepository;
import me.zhengjie.modules.approval.service.TemplateControlFieldService;
import me.zhengjie.modules.approval.service.TemplateService;
import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
import me.zhengjie.modules.attendance.domain.*;
import me.zhengjie.modules.attendance.repository.*;
import me.zhengjie.modules.attendance.service.AttendanceLeaveService;
@@ -25,7 +30,6 @@
import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
import me.zhengjie.modules.attendance.service.mapstruct.AttendanceLeaveMapper;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.domain.*;
import me.zhengjie.modules.system.repository.DictDetailRepository;
@@ -49,13 +53,14 @@
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author wcd
* @date 2022-12-16
**/
 * @author wcd
 * @website https://eladmin.vip
 * @description 服务实现
 * @date 2022-12-16
 **/
@Service
@RequiredArgsConstructor
public class AttendanceLeaveServiceImpl implements AttendanceLeaveService {
@@ -66,19 +71,22 @@
    private final AttendanceService attendanceService;
    private final SysUserLevelOtherRepository sysUserLevelOtherRepository;
    private final UserRepository userRepository;
    private final OpaiDingTalkService opaiDingTalkService;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final AttendanceRepository attendanceRepository;
    private final AttendanceGoOutRepository attendanceGoOutRepository;
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final AttendanceOvertimeRepository attendanceOvertimeRepository;
    private final ApproveEventRepository approveEventRepository;
    private final ApproveEventMapper approveEventMapper;
    private final WeComServiceImpl weComService;
    private final TemplateService templateService;
    private final TemplateControlFieldService templateControlFieldService;
    @Override
    public Map<String,Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
        Page<AttendanceLeave> page = attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
    public Map<String, Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable) {
        Page<AttendanceLeave> page = attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
        //将实体转换为Dto(重写)
        Function<AttendanceLeave, AttendanceLeaveDto> func = new Function<AttendanceLeave, AttendanceLeaveDto>(){
        Function<AttendanceLeave, AttendanceLeaveDto> func = new Function<AttendanceLeave, AttendanceLeaveDto>() {
            @Override
            public AttendanceLeaveDto apply(AttendanceLeave attendanceLeave) {
@@ -90,6 +98,13 @@
                //查询审批用户名
                User appUser = userRepository.findById(attendanceLeaveDto.getApprovalUserId()).orElseGet(User::new);
                attendanceLeaveDto.setAppUserName(appUser.getNickName());
                // 查询企微最新审批变化记录
                if (ObjectUtils.isNotEmpty(attendanceLeave.getWecomEventId())) {
                    ApproveEvent event = approveEventRepository.findById(attendanceLeave.getWecomEventId()).orElseGet(ApproveEvent::new);
                    attendanceLeaveDto.setEvent(approveEventMapper.toDto(event));
                }
                return attendanceLeaveDto;
            }
        };
@@ -97,7 +112,7 @@
    }
    @Override
    public List<AttendanceLeaveDto> queryAll(AttendanceLeaveQueryCriteria criteria){
    public List<AttendanceLeaveDto> queryAll(AttendanceLeaveQueryCriteria criteria) {
        List<AttendanceLeaveDto> attendanceLeaveDtoList = attendanceLeaveMapper.toDto(attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
        attendanceLeaveDtoList.forEach(attendanceLeaveDto -> {
            //查询用户信息
@@ -114,7 +129,7 @@
    @Transactional
    public AttendanceLeaveDto findById(Long id) {
        AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(id).orElseGet(AttendanceLeave::new);
        ValidationUtil.isNull(attendanceLeave.getId(),"AttendanceLeave","id",id);
        ValidationUtil.isNull(attendanceLeave.getId(), "AttendanceLeave", "id", id);
        return attendanceLeaveMapper.toDto(attendanceLeave);
    }
@@ -126,17 +141,17 @@
        String LeaStartTime = df.format(resources.getLeaveStartTime());
        String LeaEndTime = df.format(resources.getLeaveEndTime());
        // 如果按天为单位请假拼接请假时间的时分秒,取上下班基准时间
        if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)) {
        if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)) {
            //查询用户的排班时间
            User user = userRepository.getOne(resources.getUserId());
            LeaStartTime = LeaStartTime.substring(0,10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
            LeaEndTime = LeaEndTime.substring(0,10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
            LeaStartTime = LeaStartTime.substring(0, 10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
            LeaEndTime = LeaEndTime.substring(0, 10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
        }
        // 查询其他状态的表是否有重复
//        repeatValidation(LeaStartTime, LeaEndTime, resources.getUserId());
        // 验证请假时间是否冲突
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(LeaStartTime,LeaEndTime, resources.getUserId());
        if(attendanceLeaveList.size() > 0){
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(LeaStartTime, LeaEndTime, resources.getUserId());
        if (attendanceLeaveList.size() > 0) {
            AttendanceLeave errTime = attendanceLeaveList.get(0);
            //LocalDateTime转换为Date
            LocalDateTime strartTime = errTime.getLeaveStartTime().toLocalDateTime();
@@ -151,45 +166,66 @@
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            throw new BadRequestException("请假时间冲突," + errorFormat.format(strTime) + "至" + errorFormat.format(endTim)
                    + "已经存在请假记录,请调整时间");
        }else {
        } else {
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(resources.getUserId());
            List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
            // 查询节假日
            List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
            for(SysConfigHoliday sysConfigHoliday : sysConfigHolidayList){
                if(sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)){
            for (SysConfigHoliday sysConfigHoliday : sysConfigHolidayList) {
                if (sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)) {
                    //工作日
                    isWork.add(sysConfigHoliday.getHolidayDate().toString().substring(0,10));
                }else{
                    holiday.add(sysConfigHoliday.getHolidayDate().toString().substring(0,10));
                    isWork.add(sysConfigHoliday.getHolidayDate().toString().substring(0, 10));
                } else {
                    holiday.add(sysConfigHoliday.getHolidayDate().toString().substring(0, 10));
                }
            }
            // 循环添加开始时间到结束时间的每一天
            List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(),resources.getLeaveEndTime().toLocalDateTime().toString());
            List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(), resources.getLeaveEndTime().toLocalDateTime().toString());
            int i = 0;
            for(String date : dateList){
            for (String date : dateList) {
                LocalDate localDate = LocalDate.parse(date);
                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
                // 不是周末并且节假日表中不存在在创建
                if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
                AttendanceLeave attendanceLeave = getAttendanceLeave(resources,date,user,i,LeaStartTime,LeaEndTime,null);
                i++;
                attendanceLeaveRepository.save(attendanceLeave);
                if ((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))) {
                    AttendanceLeave attendanceLeave = getAttendanceLeave(resources, date, user, i, LeaStartTime, LeaEndTime, null);
                    // 判断是否提交企微审批
                    List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
                    if (siteTypes.size() > 0) {
                        // 添加企微申请参数
                        if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)) {
                            attendanceLeave.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR);
                            attendanceLeave.setWecomDuration(String.valueOf(new BigDecimal(attendanceLeave.getLeaveDuration()).multiply(new BigDecimal(3600)).longValue()));
                        } else {
                            attendanceLeave.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HALFDAY);
                            attendanceLeave.setWecomDuration(String.valueOf(new BigDecimal(attendanceLeave.getLeaveDuration()).multiply(new BigDecimal(86400)).longValue()));
                        }
                        // 添加企微申请参数
                        Map<String, String> leaveTypeMap = dictDetailRepository.findByDictName(Constant.LEAVE_TYPE).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel));
                        attendanceLeave.setWecomOptionKey(templateService.getVacationKey(leaveTypeMap.get(attendanceLeave.getLeaveType())));
                        // 提交申请
                        String weComId = userRepository.findById(resources.getUserId()).orElse(new User()).getWeComId();
                        Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(attendanceLeave, weComId);
                        if (approvalResultMap.containsKey("spNo")) {
                            attendanceLeave.setWecomSpNo(approvalResultMap.get("spNo"));
                        } else {
                            throw new BadRequestException(approvalResultMap.containsKey("error") ? approvalResultMap.get("error") : "企微申请提交失败");
                        }
                    }
                    i++;
                    attendanceLeaveRepository.save(attendanceLeave);
                }
            }
            //发送钉钉给审批人
            List<String> sendList = new ArrayList<>();
            //查询审批者信息
            User appUser = userRepository.getOne(resources.getApprovalUserId());
            sendList.add(appUser.getDingding());
            opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了请假审批,请登录PMS系统处理", "card");
            return attendanceLeaveMapper.toDto(resources);
        }
    }
    /**
     * 添加多条记录
     *
     * @param resources
     * @param date
     * @param user
@@ -198,37 +234,37 @@
     * @param LeaEndTime
     * @return
     */
    public AttendanceLeave getAttendanceLeave(AttendanceLeave resources,String date,User user,int i,String LeaStartTime,String LeaEndTime,Long resUserId){
    public AttendanceLeave getAttendanceLeave(AttendanceLeave resources, String date, User user, int i, String LeaStartTime, String LeaEndTime, Long resUserId) {
        DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        AttendanceLeave attendanceLeave = new AttendanceLeave();
        //resUserId为null说明是添加,反之
        if(resUserId == null){
        if (resUserId == null) {
            resources.setUserId(user.getId());
        }else{
        } else {
            resources.setUserId(resUserId);
        }
        //日期时间单位是小时
        if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)){
        if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)) {
            Calculate calculate = new Calculate();
            String startTime = date + " " + LeaStartTime.substring(11,19);
            String endTime = date + " " + LeaEndTime.substring(11,19);
            String startTime = date + " " + LeaStartTime.substring(11, 19);
            String endTime = date + " " + LeaEndTime.substring(11, 19);
            //请假开始时间结束时间不相等的情况
            if(!LeaStartTime.substring(0,10).equals(LeaEndTime.substring(0,10))){
            if (!LeaStartTime.substring(0, 10).equals(LeaEndTime.substring(0, 10))) {
                //第一次循环用下班基准时间和请假开始时间算时长
                if(i == 0){
                    calculate.setStart(LocalDateTime.parse(startTime,sdf));
                    calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00",sdf));
                if (i == 0) {
                    calculate.setStart(LocalDateTime.parse(startTime, sdf));
                    calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00", sdf));
                    resources.setLeaveStartTime(Timestamp.valueOf(startTime));
                    resources.setLeaveEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
                }else if(date.equals(LeaEndTime.substring(0,10))){
                } else if (date.equals(LeaEndTime.substring(0, 10))) {
                    //最后一次循环
                    calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00",sdf));
                    calculate.setEnd(LocalDateTime.parse(endTime,sdf));
                    calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00", sdf));
                    calculate.setEnd(LocalDateTime.parse(endTime, sdf));
                    resources.setLeaveStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
                    resources.setLeaveEndTime(Timestamp.valueOf(endTime));
                }else{
                    calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00",sdf));
                    calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00",sdf));
                } else {
                    calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00", sdf));
                    calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00", sdf));
                    resources.setLeaveStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
                    resources.setLeaveEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
                }
@@ -236,7 +272,7 @@
                Double result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
                resources.setLeaveDuration(result);
            }
        }else{
        } else {
            String startTime = date + " " + user.getSysRostering().getWorkStartTime() + ":00";
            String endTime = date + " " + user.getSysRostering().getWorkEndTime() + ":00";
            resources.setLeaveStartTime(Timestamp.valueOf(startTime));
@@ -252,11 +288,11 @@
    @Transactional(rollbackFor = Exception.class)
    public void update(AttendanceLeave resources) {
        AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
        ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
        ValidationUtil.isNull(attendanceLeave.getId(), "AttendanceLeave", "id", resources.getId());
        attendanceLeave.copy(resources);
        //审核通过或者退回不能删除
        if(attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)){
        if (attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)) {
            throw new BadRequestException("审核通过或退回的不能进行修改");
        }
@@ -264,8 +300,8 @@
        User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Role role = user1.getRoles().iterator().next();
        //除超管、总经理只能修改自己信息
        if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
        if (role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL) {
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())) {
                throw new BadRequestException("只能修改自己的记录");
            }
        }
@@ -274,11 +310,11 @@
        String LeaStartTime = df.format(resources.getLeaveStartTime());
        String LeaEndTime = df.format(resources.getLeaveEndTime());
        // 如果按天为单位请假拼接请假时间的时分秒,取上下班基准时间
        if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)){
        if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)) {
            //查询用户的排班时间
            User user = userRepository.getOne(resources.getUserId());
            LeaStartTime = LeaStartTime.substring(0,10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
            LeaEndTime = LeaEndTime.substring(0,10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
            LeaStartTime = LeaStartTime.substring(0, 10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
            LeaEndTime = LeaEndTime.substring(0, 10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
        }
        // 查询其他状态的表是否有重复
//        repeatValidation(LeaStartTime, LeaEndTime, resources.getUserId());
@@ -289,9 +325,9 @@
        if (attendanceLeaveList.size() > 0) {
            AttendanceLeave errorSysAskForLeave = attendanceLeaveList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
                throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime())
                        + "已经存在请假记录,请调整时间");
        }else{
            throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime())
                    + "已经存在请假记录,请调整时间");
        } else {
            //暂存userId
            Long resUserId = attendanceLeave.getUserId();
            // 删除以前的记录
@@ -303,23 +339,23 @@
            List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
            // 查询节假日
            List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
            for(SysConfigHoliday sysConfigHoliday : sysConfigHolidayList){
                if(sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)){
            for (SysConfigHoliday sysConfigHoliday : sysConfigHolidayList) {
                if (sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)) {
                    //工作日
                    isWork.add(sysConfigHoliday.getHolidayDate().toString().substring(0,10));
                }else{
                    holiday.add(sysConfigHoliday.getHolidayDate().toString().substring(0,10));
                    isWork.add(sysConfigHoliday.getHolidayDate().toString().substring(0, 10));
                } else {
                    holiday.add(sysConfigHoliday.getHolidayDate().toString().substring(0, 10));
                }
            }
            // 循环添加开始时间到结束时间的每一天
            List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(),resources.getLeaveEndTime().toLocalDateTime().toString());
            List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(), resources.getLeaveEndTime().toLocalDateTime().toString());
            int i = 0;
            for(String date : dateList){
            for (String date : dateList) {
                LocalDate localDate = LocalDate.parse(date);
                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
                // 不是周末并且节假日表中不存在在创建
                if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
                    AttendanceLeave attendanceLeave1 = getAttendanceLeave(resources,date,user,i,LeaStartTime,LeaEndTime,resUserId);
                if ((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))) {
                    AttendanceLeave attendanceLeave1 = getAttendanceLeave(resources, date, user, i, LeaStartTime, LeaEndTime, resUserId);
                    i++;
                    attendanceLeaveRepository.save(attendanceLeave1);
                }
@@ -329,22 +365,23 @@
    /**
     * 验证其他状态的表是否有重复
     *
     * @param startTime
     * @param endTime
     * @param userId
     */
    public void repeatValidation(String startTime, String endTime, Long userId){
    public void repeatValidation(String startTime, String endTime, Long userId) {
        // 查询外出表
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(startTime, endTime, userId);
        if(attendanceGoOutList.size() > 0){
        if (attendanceGoOutList.size() > 0) {
            AttendanceGoOut errorSysAskForLeave = attendanceGoOutList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("外出时间冲突," + errorFormat.format(errorSysAskForLeave.getOutStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getOutEndTime())
                    + "已经存在外出记录,请调整时间");
        }
        // 查询出差表
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(startTime.substring(0,10),endTime.substring(0,10), userId);
        if(attendanceBusinessTravelList.size() > 0){
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(startTime.substring(0, 10), endTime.substring(0, 10), userId);
        if (attendanceBusinessTravelList.size() > 0) {
            AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("出差时间冲突," + errorFormat.format(errorSysAskForLeave.getTravelStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getTravelEndTime())
@@ -355,11 +392,12 @@
    /**
     * 获取两个日期之间的所有日期
     *
     * @param startTime
     * @param endTime
     * @return
     */
    public List<String> getBetweenDate(String startTime, String endTime){
    public List<String> getBetweenDate(String startTime, String endTime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        // 声明保存日期集合
        List<String> list = new ArrayList<String>();
@@ -370,7 +408,7 @@
            //用Calendar 进行日期比较判断
            Calendar calendar = Calendar.getInstance();
            while (startDate.getTime()<=endDate.getTime()){
            while (startDate.getTime() <= endDate.getTime()) {
                // 把日期添加到集合
                list.add(sdf.format(startDate));
                // 设置日期
@@ -378,7 +416,7 @@
                //把日期增加一天
                calendar.add(Calendar.DATE, 1);
                // 获取增加后的日期
                startDate=calendar.getTime();
                startDate = calendar.getTime();
            }
        } catch (ParseException e) {
            e.printStackTrace();
@@ -388,6 +426,7 @@
    /**
     * 计算请假时长
     *
     * @param resources /
     * @return
     * @throws Exception
@@ -398,8 +437,8 @@
        //根据字典名称查询
        List<DictDetail> dictDetailList = dictDetailRepository.findByDictName("leave_type");
        List<String> leaveTypes = new ArrayList<>();
        for(DictDetail dictDetail : dictDetailList){
            if(dictDetail.getValue().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_REPLACE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_COMPASSIONATE_LEAVE)){
        for (DictDetail dictDetail : dictDetailList) {
            if (dictDetail.getValue().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_REPLACE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_COMPASSIONATE_LEAVE)) {
                //事假和年假
                leaveTypes.add(dictDetail.getValue());
            }
@@ -409,11 +448,11 @@
        calculate.setEnd(resources.getLeaveEndTime().toLocalDateTime());
        Double result = new Double(0.00);
        //判断集合是否包含年假或事假,包含计算以时为单位,反之以天为单位进行计算
        if(leaveTypes.contains(resources.getLeaveType())){
        if (leaveTypes.contains(resources.getLeaveType())) {
            Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId());
            result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
            attendanceLeaveDto.setLeaveDurationUnit(Constant.LEAVE_TIME_TYPE_HOUR);
        }else{
        } else {
            Integer days = attendanceService.calculateDays(calculate);
            result = Double.valueOf(new BigDecimal(days).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
            attendanceLeaveDto.setLeaveDurationUnit(Constant.LEAVE_TIME_TYPE_DAY);
@@ -435,7 +474,7 @@
            for (SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList) {
                // 获取今年
                int year = Calendar.getInstance().get(Calendar.YEAR);
                if (!sysUserLevelOther.getYearMonth().isEmpty() && sysUserLevelOther.getYearMonth().substring(0,4).equals(String.valueOf(year))) {
                if (!sysUserLevelOther.getYearMonth().isEmpty() && sysUserLevelOther.getYearMonth().substring(0, 4).equals(String.valueOf(year))) {
                    //年假总时长
                    Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8);
@@ -488,7 +527,6 @@
        LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(4);
        LocalDate localDateEnd = LocalDate.now().plusDays(1);
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateStart.plusMonths(1).withDayOfMonth(1).atStartOfDay());
        if (!attendanceOvertimeList.isEmpty()) {
            surplusYearTime = attendanceOvertimeList.stream()
@@ -507,24 +545,25 @@
    /**
     * 审核功能
     *
     * @param resources /
     */
    @Override
    public void updateApprove(AttendanceLeave resources) throws Exception {
        AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
        ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
        ValidationUtil.isNull(attendanceLeave.getId(), "AttendanceLeave", "id", resources.getId());
        attendanceLeave.copy(resources);
        attendanceLeaveRepository.save(attendanceLeave);
        // 调用定时任务修改考勤记录
        List<User> userList = new ArrayList<>();
        if(ObjectUtils.isNotEmpty(attendanceLeave.getUserId())){
        if (ObjectUtils.isNotEmpty(attendanceLeave.getUserId())) {
            User user = userRepository.findById(attendanceLeave.getUserId()).orElseGet(User::new);
            userList.add(user);
        }
        if (attendanceLeave.getLeaveStartTime().before(new Date())) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            String attendanceDate = df.format(attendanceLeave.getLeaveStartTime());
            weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate,userList);
            weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
        }
    }
@@ -534,7 +573,7 @@
            //根据id查询记录
            Optional<AttendanceLeave> attendanceLeave = attendanceLeaveRepository.findById(id);
            //审核通过或者退回不能删除
            if(attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)){
            if (attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)) {
                throw new BadRequestException("审核通过或退回的不能进行删除");
            }
@@ -544,8 +583,8 @@
            //根据id查询记录
            Optional<AttendanceLeave> attendanceLeave1 = attendanceLeaveRepository.findById(id);
            //除超管、总经理只能删除自己信息
            if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
                if (!Long.valueOf(attendanceLeave1.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
            if (role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL) {
                if (!Long.valueOf(attendanceLeave1.get().getUserId()).equals(SecurityUtils.getCurrentUserId())) {
                    throw new BadRequestException("只能删除自己的记录");
                }
            }
@@ -555,6 +594,7 @@
    /**
     * 批量审核
     *
     * @param request
     */
    @Override
@@ -562,7 +602,7 @@
        // 循环ID列表
        for (Long id : request.getIds()) {
            AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(id).orElseGet(AttendanceLeave::new);
            ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",id);
            ValidationUtil.isNull(attendanceLeave.getId(), "AttendanceLeave", "id", id);
            if (request.getNum().equals(Long.valueOf(1))) {
                attendanceLeave.setApprovalStatus(Constant.APPROVAL_STATUS_PASSED);
            } else {
@@ -571,13 +611,13 @@
            attendanceLeaveRepository.save(attendanceLeave);
            // 调用定时任务修改考勤记录
            List<User> userList = new ArrayList<>();
            if(ObjectUtils.isNotEmpty(attendanceLeave.getUserId())){
            if (ObjectUtils.isNotEmpty(attendanceLeave.getUserId())) {
                User user = userRepository.findById(attendanceLeave.getUserId()).orElseGet(User::new);
                userList.add(user);
            }
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            String attendanceDate = df.format(attendanceLeave.getLeaveStartTime());
            weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate,userList);
            weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
        }
    }
@@ -587,7 +627,7 @@
        for (AttendanceLeaveDto attendanceLeave : all) {
            String leavrType = attendanceLeave.getLeaveType() != null ? dictDetailRepository.findByDictNameAndValue(Constant.LEAVE_TYPE, attendanceLeave.getLeaveType()).getLabel() : "";
            String leaveStatus = attendanceLeave.getApprovalStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.APPROVAL_STATUS, attendanceLeave.getApprovalStatus()).getLabel() : "";
            Map<String,Object> map = new LinkedHashMap<>();
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("申请者", attendanceLeave.getUserName());
            map.put("审批者", attendanceLeave.getAppUserName());
            map.put("请假类型", leavrType);
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceOvertimeServiceImpl.java
@@ -17,6 +17,10 @@
import lombok.RequiredArgsConstructor;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.approval.domain.ApproveEvent;
import me.zhengjie.modules.approval.repository.ApproveEventRepository;
import me.zhengjie.modules.approval.service.TemplateControlFieldService;
import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper;
import me.zhengjie.modules.attendance.domain.*;
import me.zhengjie.modules.attendance.repository.AttendanceOvertimeRepository;
import me.zhengjie.modules.attendance.repository.AttendanceRepository;
@@ -26,11 +30,7 @@
import me.zhengjie.modules.attendance.service.dto.AttendanceOvertimeQueryCriteria;
import me.zhengjie.modules.attendance.service.mapstruct.AttendanceOvertimeMapper;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.domain.SysConfigHoliday;
import me.zhengjie.modules.system.domain.SysRostering;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.domain.*;
import me.zhengjie.modules.system.repository.DictDetailRepository;
import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
import me.zhengjie.modules.system.repository.UserRepository;
@@ -53,6 +53,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @website https://eladmin.vip
@@ -69,8 +70,10 @@
    private final AttendanceRepository attendanceRepository;
    private final DictDetailRepository dictDetailRepository;
    private final UserRepository userRepository;
    private final OpaiDingTalkService opaiDingTalkService;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final ApproveEventRepository approveEventRepository;
    private final ApproveEventMapper approveEventMapper;
    private final TemplateControlFieldService templateControlFieldService;
    @Override
    public Map<String,Object> queryAll(AttendanceOvertimeQueryCriteria criteria, Pageable pageable){
@@ -88,6 +91,13 @@
                //查询审批用户名
                User appUser = userRepository.findById(attendanceOvertimeDto.getApprovalUserId()).orElseGet(User::new);
                attendanceOvertimeDto.setAppUserName(appUser.getNickName());
                // 查询企微最新审批变化记录
                if (ObjectUtils.isNotEmpty(attendanceOvertime.getWecomEventId())) {
                    ApproveEvent event = approveEventRepository.findById(attendanceOvertime.getWecomEventId()).orElseGet(ApproveEvent::new);
                    attendanceOvertimeDto.setEvent(approveEventMapper.toDto(event));
                }
                return attendanceOvertimeDto;
            }
        };
@@ -135,18 +145,24 @@
            resources.setDateType(Constant.DATE_TYPE_WEEKEND);
        }
        resources.setApprovalStatus(Constant.OVERTIME_APPROVAL);
        try {
            //发送给审批者
            List<String> sendList = new ArrayList<>();
            //查询申请人信息
            User user = userRepository.getOne(resources.getUserId());
            //查询审批者信息
            User appUser = userRepository.getOne(resources.getApprovalUserId());
            sendList.add(appUser.getDingding());
            opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了加班审批,请登录PMS系统处理", "card");
        } catch (Exception e) {
            e.printStackTrace();
        // 判断是否提交企微审批
        List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
        if (siteTypes.size() > 0) {
            // 添加企微申请参数
            resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR);
            resources.setWecomDuration(String.valueOf(new BigDecimal(resources.getOvertimeDuration()).multiply(new BigDecimal(3600)).longValue()));
            resources.setWecomAttendanceType("5");
            // 提交申请
            String weComId = userRepository.findById(resources.getUserId()).orElse(new User()).getWeComId();
            Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(resources, weComId);
            if (approvalResultMap.containsKey("spNo")) {
                resources.setWecomSpNo(approvalResultMap.get("spNo"));
            } else {
                throw new BadRequestException(approvalResultMap.containsKey("error") ? approvalResultMap.get("error") : "企微申请提交失败");
            }
        }
        return attendanceOvertimeMapper.toDto(attendanceOvertimeRepository.save(resources));
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -373,4 +373,12 @@
    public static final String RECOVERY_STATUS_NORMAL = "recovery_status_normal";
    // 钱款缴纳状态:放弃
    public static final String RECOVERY_STATUS_ABANDON = "recovery_status_abandon";
    // 企微请假类型
    public static final String WECOM_LEAVE_TYPE = "wecom_leave_type";
    // 企微请假类型描述
    public static final String WECOM_LEAVE_TYPE_DESCRIPTION = "企微请假类型";
    // 申请审核站点
    public static final String APPROVAL_SITE_TYPE = "approval_site_type";
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Applyer.java
New file
@@ -0,0 +1,15 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Applyer {
    @SerializedName("UserId")
    private String userId;
    @SerializedName("Party")
    private String party;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/ApprovalInfo.java
New file
@@ -0,0 +1,44 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class ApprovalInfo {
    @SerializedName("SpStatus")
    private Integer spStatus;
    @SerializedName("ApplyTime")
    private String applyTime;
    @SerializedName("ProcessList")
    private List<ProcessList> processList;
    @SerializedName("StatuChangeEvent")
    private Integer statuChangeEvent;
    @SerializedName("SpRecord")
    private List<SpRecord> spRecord;
    @SerializedName("SpNo")
    private String spNo;
    @SerializedName("SpName")
    private String spName;
    @SerializedName("Applyer")
    private Applyer applyer;
    @SerializedName("TemplateId")
    private String templateId;
    @SerializedName("Notifyer")
    private List<Notifyer> notifyer;
    @SerializedName("Comments")
    private List<Comments> comments;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/ApprovalSend.java
New file
@@ -0,0 +1,30 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ApprovalSend {
    @SerializedName("ApprovalInfo")
    private ApprovalInfo approvalInfo;
    @SerializedName("CreateTime")
    private String createTime;
    @SerializedName("Event")
    private String event;
    @SerializedName("ToUserName")
    private String toUserName;
    @SerializedName("FromUserName")
    private String fromUserName;
    @SerializedName("MsgType")
    private String msgType;
    @SerializedName("AgentID")
    private String agentId;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Approver.java
New file
@@ -0,0 +1,12 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Approver {
    @SerializedName("UserId")
    private String userId;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/CommentUserInfo.java
New file
@@ -0,0 +1,12 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CommentUserInfo {
    @SerializedName("UserId")
    private String userId;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Comments.java
New file
@@ -0,0 +1,24 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Comments {
    @SerializedName("CommentUserInfo")
    private CommentUserInfo commentUserInfo;
    @SerializedName("CommentTime")
    private String commentTime;
    @SerializedName("CommentContent")
    private String commentContent;
    @SerializedName("CommentId")
    private String commentId;
    @SerializedName("Attach")
    private String attach;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Details.java
New file
@@ -0,0 +1,24 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Details {
    @SerializedName("SpStatus")
    private Integer spStatus;
    @SerializedName("Speech")
    private String speech;
    @SerializedName("Approver")
    private Approver approver;
    @SerializedName("SpTime")
    private String spTime;
    @SerializedName("MediaId")
    private String mediaId;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/NodeList.java
New file
@@ -0,0 +1,23 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class NodeList {
    @SerializedName("NodeType")
    private Integer nodeType;
    @SerializedName("SpStatus")
    private Integer spStatus;
    @SerializedName("ApvRel")
    private Integer apvRel;
    @SerializedName("SubNodeList")
    private List<SubNode> subNodeList;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/Notifyer.java
New file
@@ -0,0 +1,12 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Notifyer {
    @SerializedName("UserId")
    private String userId;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/ProcessList.java
New file
@@ -0,0 +1,14 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class ProcessList {
    @SerializedName("NodeList")
    private List<NodeList> nodeList;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/SpRecord.java
New file
@@ -0,0 +1,20 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class SpRecord {
    @SerializedName("SpStatus")
    private Integer spStatus;
    @SerializedName("ApproverAttr")
    private Integer approverAttr;
    @SerializedName("Details")
    private List<Details> details;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/SubNode.java
New file
@@ -0,0 +1,24 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SubNode {
    @SerializedName("Sptime")
    private Integer spTime;
    @SerializedName("Speech")
    private String speech;
    @SerializedName("SpYj")
    private Integer spYj;
    @SerializedName("UserInfo")
    private UserInfo userInfo;
    @SerializedName("MediaIds")
    private String mediaIds;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/wecom/UserInfo.java
New file
@@ -0,0 +1,12 @@
package me.zhengjie.modules.temp.service.dto.wecom;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UserInfo {
    @SerializedName("UserId")
    private String userId;
}
eladmin-web-master/src/api/template/template.js
New file
@@ -0,0 +1,35 @@
import request from '@/utils/request'
export function add(data) {
  return request({
    url: 'api/template',
    method: 'post',
    data
  })
}
export function del(ids) {
  return request({
    url: 'api/template/',
    method: 'delete',
    data: ids
  })
}
export function edit(data) {
  return request({
    url: 'api/template',
    method: 'put',
    data
  })
}
export function queryTemplate(data) {
  return request({
    url: 'api/template/queryWeComTemplate',
    method: 'post',
    data
  })
}
export default { add, edit, del, queryTemplate }
eladmin-web-master/src/api/template/templateControlField.js
New file
@@ -0,0 +1,50 @@
import request from '@/utils/request'
import qs from 'qs'
export function add(data) {
  return request({
    url: 'api/templateControlField',
    method: 'post',
    data
  })
}
export function del(ids) {
  return request({
    url: 'api/templateControlField/',
    method: 'delete',
    data: ids
  })
}
export function edit(data) {
  return request({
    url: 'api/templateControlField',
    method: 'put',
    data
  })
}
export function bind(data) {
  return request({
    url: 'api/templateControlField/bind',
    method: 'post',
    data
  })
}
export function queryByTable(params) {
  return request({
    url: 'api/templateControlField/queryByTable?' + qs.stringify(params, { indices: false }),
    method: 'get'
  })
}
export function editWecomVacationType() {
  return request({
    url: 'api/templateControlField/editWecomVacationType',
    method: 'post'
  })
}
export default { add, edit, del, bind, queryByTable }
eladmin-web-master/src/components/ApprovalLine/index.vue
New file
@@ -0,0 +1,243 @@
<template>
  <div>
    <el-timeline>
      <el-timeline-item v-for="(node, index) in nodeList" :key="index">
        <div v-if="node.NodeType && node.NodeType === 1 && node.SubNodeList" class="flex-column gap-10">
          <div class="flex-row gap-10 weight-600">
            <div class="flex-row align-center">审批人</div>
            <div class="flex-row align-center">
              <span>{{ spStatusMap[node.SpStatus] || '其他' }}</span>
            </div>
            <div>
              <el-tag size="mini">{{ apvRelMap[node.ApvRel] || '其他' }}</el-tag>
            </div>
          </div>
          <div v-for="(subNode, subIndex) in node.SubNodeList" :key="'sub_node_' + index + '_' + subIndex" class="jkl">
            <div v-if="subNode.UserInfo && subNode.UserInfo.UserId">
              <div class="flex-row gap-10 align-center between">
                <div class="flex-row gap-10 align-center">
                  <el-badge is-dot type="success" :hidden="node.ApvRel !== 2 || (node.ApvRel === 2 && node.SpStatus !== subNode.SpYj)">
                    <div class="header">{{ getFirstChar(userNameMap[subNode.UserInfo.UserId] || subNode.UserInfo.UserId) }}</div>
                  </el-badge>
                  <div class="name">{{ userNameMap[subNode.UserInfo.UserId] || subNode.UserInfo.UserId }}</div>
                </div>
                <div class="flex-row gap-10 align-center">
                  <div class="status">{{ node.ApvRel === 2 && node.SpStatus !== subNode.SpYj ? '' : (subSpStatusMap[subNode.SpYj] || '其他') }}</div>
                  <div class="time">{{ subNode.Sptime > 0 ? parseTime(subNode.Sptime, '{y}/{m}/{d} {h}:{i}') : '' }}</div>
                </div>
              </div>
              <div v-show="subNode.Speech && subNode.Speech.length > 0" class="comment">
                <div>{{ subNode.Speech }}</div>
              </div>
            </div>
          </div>
        </div>
        <div v-else-if="node.NodeType && node.NodeType === 2 && node.SubNodeList" class="flex-column gap-10">
          <div class="flex-row gap-10 weight-600">
            <div class="flex-row align-center">抄送人</div>
            <div class="flex-row align-center">
              <span>{{ node.SubNodeList.length > 0 && node.SubNodeList[0].Sptime ? '已抄送' : '' }}</span>
            </div>
          </div>
          <div v-for="(subNode, subIndex) in node.SubNodeList" :key="'sub_node_' + index + '_' + subIndex">
            <div v-if="subNode.UserInfo && subNode.UserInfo.UserId">
              <div class="flex-row gap-10 align-center between">
                <div class="flex-row gap-10 align-center">
                  <div class="header">{{ getFirstChar(userNameMap[subNode.UserInfo.UserId] || subNode.UserInfo.UserId) }}</div>
                  <div class="name">{{ userNameMap[subNode.UserInfo.UserId] || subNode.UserInfo.UserId }}</div>
                </div>
                <div class="flex-row gap-10 align-center">
                  <div class="status">{{ subNode.Sptime ? '已抄送' : '' }}</div>
                  <div class="time">{{ subNode.Sptime > 0 ? parseTime(subNode.Sptime, '{y}/{m}/{d} {h}:{i}') : '' }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div v-else-if="node.NodeType && node.NodeType === 3 && node.SubNodeList" class="flex-column gap-10">
          <div class="flex-row gap-10 weight-600">
            <div class="flex-row align-center">办理人</div>
            <div class="flex-row align-center">
              <span>{{ node.SubNodeList.length > 0 && node.SubNodeList[0].Sptime ? '已办理' : '' }}</span>
            </div>
          </div>
          <div v-for="(subNode, subIndex) in node.SubNodeList" :key="'sub_node_' + index + '_' + subIndex">
            <div v-if="subNode.UserInfo && subNode.UserInfo.UserId">
              <div class="flex-row gap-10 align-center between">
                <div class="flex-row gap-10 align-center">
                  <div class="header">{{ getFirstChar(userNameMap[subNode.UserInfo.UserId] || subNode.UserInfo.UserId) }}</div>
                  <div class="name">{{ userNameMap[subNode.UserInfo.UserId] || subNode.UserInfo.UserId }}</div>
                </div>
                <div class="flex-row gap-10 align-center">
                  <div class="status">{{ subNode.Sptime ? '已办理' : '' }}</div>
                  <div class="time">{{ subNode.Sptime > 0 ? parseTime(subNode.Sptime, '{y}/{m}/{d} {h}:{i}') : '' }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div v-else>暂无</div>
      </el-timeline-item>
    </el-timeline>
  </div>
</template>
<script>
import { parseTime } from '@/utils/index'
export default {
  props: {
    eventData: {
      type: Object,
      default: () => { return {} }
    },
    userList: {
      type: Array,
      default: () => { return [] }
    }
  },
  data() {
    return {
      spStatusMap: {
        1: '审批中',
        2: '已同意',
        3: '已驳回',
        4: '已转审',
        11: '退回至指定审批人',
        12: '加签',
        13: '同意并加签',
        14: '已办理',
        15: '已转交'
      },
      apvRelMap: {
        1: '会签',
        2: '或签',
        3: '依次审批'
      },
      subSpStatusMap: {
        1: '审批中',
        2: '已同意',
        3: '已驳回',
        4: '已转审',
        11: '退回至指定审批人',
        12: '加签',
        13: '同意并加签',
        14: '已办理',
        15: '已转交'
      }
    }
  },
  computed: {
    nodeList() {
      const that = this
      if (that.eventData.processList) {
        const processList = JSON.parse(that.eventData.processList)
        console.log(processList)
        return processList[0].NodeList ? processList[0].NodeList.map((item, index) => {
          if (item.NodeType && item.NodeType === 2) {
            if (index === 0) {
              const subNodeList = item.SubNodeList.map(subItem => {
                return {
                  ...subItem,
                  Sptime: that.eventData.applyTime
                }
              })
              return { ...item, SubNodeList: subNodeList }
            } else {
              let subNodeList = item.SubNodeList
              for (let i = index; i >= 0; i--) {
                if (processList[0].NodeList[i].NodeType && processList[0].NodeList[i].NodeType === 1) {
                  if (processList[0].NodeList[i].SpStatus === 2) {
                    const filterSubNodeList = processList[0].NodeList[i].SubNodeList.filter(subItem => subItem.SpYj === 2)
                    if (filterSubNodeList.length > 0) {
                      subNodeList = item.SubNodeList.map(subItem => {
                        return {
                          ...subItem,
                          Sptime: filterSubNodeList[0].Sptime
                        }
                      })
                    }
                  }
                  break
                } else if (i === 0) {
                  subNodeList = item.SubNodeList.map(subItem => {
                    return {
                      ...subItem,
                      Sptime: that.eventData.applyTime
                    }
                  })
                }
              }
              return { ...item, SubNodeList: subNodeList }
            }
          } else {
            return item
          }
        }) : []
      } else {
        return []
      }
    },
    userNameMap() {
      const that = this
      const userNameMap = {}
      that.userList.forEach(item => {
        if (item.weComId) {
          userNameMap[item.weComId] = item.nickName
        }
      })
      return userNameMap
    }
  },
  methods: {
    parseTime,
    // 获取名称第一个字
    getFirstChar(str) {
      return str ? str.charAt(0) : '无'
    }
  }
}
</script>
<style scoped>
.flex-row {
  display: flex;
  flex-direction: row;
}
.flex-column {
  display: flex;
  flex-direction: column;
}
.between {
  justify-content: space-between;
}
.gap-10 {
  gap: 10px;
}
.weight-600 {
  font-weight: 600;
}
.align-center {
  align-items: center;
}
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #1890ff;
  color: #FFFFFF;
  width: 30px;
  height: 30px;
  border-radius: 5px;
}
.comment {
  padding: 10px;
  background-color: #f0f2f5;
  border-radius: 5px;
  margin-top: 10px;
}
</style>
eladmin-web-master/src/utils/constant.js
@@ -385,6 +385,19 @@
// 钱款缴纳状态
export const RECOVERY_STATUS = 'recovery_status'
// 企微审批字段绑定:请假字段绑定
export const WECOM_BIND_LEAVE = 'AttendanceLeave'
// 企微审批字段绑定:外出字段绑定
export const WECOM_BIND_GOOUT = 'AttendanceGoOut'
// 企微审批字段绑定:出差字段绑定
export const WECOM_BIND_TRAVEL = 'AttendanceBusinessTravel'
// 企微审批字段绑定:换休字段绑定
export const WECOM_BIND_OVERTIME = 'AttendanceOvertime'
// 企微审批字段绑定:补卡字段绑定
export const WECOM_BIND_REPLACEMENT = 'AttendanceCardreplacement'
// 申请审核站点
export const APPROVAL_SITE_TYPE = 'approval_site_type'
export default {
  ROLE_LEVEL_SUPER,
  ROLE_LEVEL_GENERAL,
@@ -559,5 +572,11 @@
  OVERTIME_PASS,
  OVERTIME_RETURN,
  BUSINESS_TRAVEL_CATEGORY,
  RECOVERY_STATUS
  RECOVERY_STATUS,
  WECOM_BIND_LEAVE,
  WECOM_BIND_GOOUT,
  WECOM_BIND_TRAVEL,
  WECOM_BIND_OVERTIME,
  WECOM_BIND_REPLACEMENT,
  APPROVAL_SITE_TYPE
}
eladmin-web-master/src/views/attendance/attendanceBusinessTravel/index.vue
@@ -131,7 +131,7 @@
              clearable
              placeholder="请选择"
              style="width: 340px;"
              :disabled="disabledUser(form)"
              :disabled="disabledUser(form) || form.wecomSpNo !== null"
            >
              <el-option
                v-for="item in users"
@@ -141,7 +141,7 @@
              />
            </el-select>
          </el-form-item>
          <el-form-item label="审批者" prop="approvalUserId">
          <el-form-item label="审批者" prop="approvalUserId" :hidden="form.wecomSpNo !== null || (form.id == null && dict[dictApprovalSiteType].length > 0)">
            <el-select
              v-model="form.approvalUserId"
              filterable
@@ -150,7 +150,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            >
              <el-option
@@ -179,7 +180,8 @@
              }"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
              @change="checkTime"
            />
@@ -202,7 +204,8 @@
              }"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
              @change="checkTime"
            />
@@ -226,7 +229,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            />
          </el-form-item>
@@ -236,7 +240,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            />
          </el-form-item>
@@ -246,7 +251,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            />
          </el-form-item>
@@ -259,7 +265,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            >
              <el-option
@@ -287,7 +294,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            />
          </el-form-item>
@@ -402,7 +410,21 @@
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
            <el-popover
              v-if="scope.row.wecomSpNo && scope.row.event"
              placement="right-start"
              width="600"
              trigger="click"
            >
              <approvalLine :event-data="scope.row.event" :user-list="users" />
              <el-tag slot="reference" effect="dark">
                <i class="el-icon-search" />
                <span>详细</span>
              </el-tag>
            </el-popover>
            <el-tag v-else-if="scope.row.appUserName">{{ scope.row.appUserName }}</el-tag>
            <el-tag v-else>暂无</el-tag>
          </template>
        </el-table-column>
        <el-table-column
@@ -512,7 +534,7 @@
        >
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.approvalUserId === $store.state.user.user.id"
              v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
              v-permission="permission.approve"
              :loading="crud.status.cu === 2"
              size="mini"
@@ -540,7 +562,7 @@
                >确定</el-button>
              </div>
              <el-button
                v-if="scope.row.approvalUserId === $store.state.user.user.id"
                v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
                slot="reference"
                v-permission="permission.approve"
                type="danger"
@@ -552,6 +574,7 @@
              >撤销
              </el-button>
            </el-popover>
            <el-link v-if="scope.row.wecomSpNo" type="primary">请前往企微审核</el-link>
          </template>
        </el-table-column>
        <el-table-column
@@ -568,7 +591,7 @@
          fixed="right"
        >
          <template slot-scope="scope">
            <udOperation :data="scope.row" :permission="permission" />
            <udOperation v-if="!scope.row.wecomSpNo" :data="scope.row" :permission="permission" />
          </template>
        </el-table-column>
      </el-table>
@@ -587,6 +610,7 @@
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import approvalLine from '@/components/ApprovalLine'
import constant from '../../../utils/constant'
const defaultForm = {
@@ -607,11 +631,13 @@
  createBy: null,
  createTime: null,
  updateBy: null,
  updateTime: null
  updateTime: null,
  wecomSpNo: null,
  event: null
}
export default {
  name: 'AttendanceBusinessTravel',
  components: { pagination, crudOperation, rrOperation, udOperation },
  components: { pagination, crudOperation, rrOperation, udOperation, approvalLine },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
@@ -623,7 +649,7 @@
    })
  },
  // 数据字典constant
  dicts: [constant.BUSSINESS_APPROVE_STATUS, constant.LEAVE_TIME_TYPE, constant.BUSINESS_TRAVEL_CATEGORY],
  dicts: [constant.BUSSINESS_APPROVE_STATUS, constant.LEAVE_TIME_TYPE, constant.BUSINESS_TRAVEL_CATEGORY, constant.APPROVAL_SITE_TYPE],
  data() {
    return {
      permission: {
@@ -672,6 +698,7 @@
      dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY,
      dictLeaveTimeType: constant.LEAVE_TIME_TYPE,
      dictBusinessTravelCategory: constant.BUSINESS_TRAVEL_CATEGORY,
      dictApprovalSiteType: constant.APPROVAL_SITE_TYPE,
      makeUpCardVisible: false,
      successLoading: false,
      userRolesLevelMin: null,
@@ -704,6 +731,10 @@
      if (this.userRolesLevelMin > this.roleLevelGenerl) {
        // 表单赋值
        this.form.userId = this.user.id
      }
      if (this.dict[this.dictApprovalSiteType].length > 0) {
        this.form.approvalUserId = 0
      }
    },
    // 禁用
@@ -819,6 +850,9 @@
        // 循环数据
        for (let i = 0; i < data.length; i++) {
          // ID列表
          if (data[i].wecomSpNo) {
            continue
          }
          ids.push(data[i].id)
        }
        crudAttendanceBusinessTravel
eladmin-web-master/src/views/attendance/attendanceCardReplacement/index.vue
@@ -83,7 +83,7 @@
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="申请人" prop="userId">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="disabledUser(form)">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="disabledUser(form) || form.wecomSpNo !== null">
              <el-option
                v-for="item in users"
                :key="item.id"
@@ -92,8 +92,8 @@
              />
            </el-select>
          </el-form-item>
          <el-form-item label="审批者" prop="approvalUserId">
            <el-select v-model="form.approvalUserId" clearable filterable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse">
          <el-form-item label="审批者" prop="approvalUserId" :hidden="form.wecomSpNo !== null || (form.id == null && dict[dictApprovalSiteType].length > 0)">
            <el-select v-model="form.approvalUserId" clearable filterable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse || form.wecomSpNo !== null">
              <el-option
                v-for="item in approvalUsers"
                :key="item.id"
@@ -103,7 +103,7 @@
            </el-select>
          </el-form-item>
          <el-form-item label="补卡区分" prop="cardReplacementDistinguish">
            <el-select v-model="form.cardReplacementDistinguish" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse">
            <el-select v-model="form.cardReplacementDistinguish" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse || form.wecomSpNo !== null">
              <el-option
                v-for="item in dict[dictCardReplacement]"
                :key="item.value"
@@ -122,14 +122,14 @@
              value-format="yyyy-MM-dd HH:mm:ss"
              align="right"
              :default-time="form.cardReplacementDistinguish === 'card_replacement_differentiation_goOn' ? $store.state.user.user.sysRostering.workStartTime + ':00' : $store.state.user.user.sysRostering.workEndTime + ':00'"
              :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse"
              :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse || form.wecomSpNo !== null"
            />
          </el-form-item>
          <el-form-item label="补卡原因">
            <el-input v-model="form.cardReplacementReason" type="textarea" rows="3" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse" />
            <el-input v-model="form.cardReplacementReason" type="textarea" rows="3" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse || form.wecomSpNo !== null" />
          </el-form-item>
          <el-form-item v-if="form.id !== null" label="审批状态" prop="approvalStatus">
            <el-select v-model="form.approvalStatus" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse">
            <el-select v-model="form.approvalStatus" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse || form.wecomSpNo !== null">
              <el-option
                v-for="item in dict[dictCardApproveStatus]"
                :key="item.value"
@@ -142,7 +142,7 @@
            <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 370px;" disabled />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse" />
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 370px;" :disabled="form.approvalStatus == dictCardApproveStatusAgree || form.approvalStatus == dictCardApproveStatusRefuse || form.wecomSpNo !== null" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
@@ -182,7 +182,21 @@
        </el-table-column>
        <el-table-column prop="appUserName" label="审批者" min-width="100" show-overflow-tooltip fixed="left">
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
            <el-popover
              v-if="scope.row.wecomSpNo && scope.row.event"
              placement="right-start"
              width="600"
              trigger="click"
            >
              <approvalLine :event-data="scope.row.event" :user-list="users" />
              <el-tag slot="reference" effect="dark">
                <i class="el-icon-search" />
                <span>详细</span>
              </el-tag>
            </el-popover>
            <el-tag v-else-if="scope.row.appUserName">{{ scope.row.appUserName }}</el-tag>
            <el-tag v-else>暂无</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="cardReplacementTime" label="补卡时间" min-width="140" show-overflow-tooltip />
@@ -205,7 +219,7 @@
        <el-table-column v-if="checkPer(['admin','attendanceCardreplacement:approve'])" label="审核操作" width="180px" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.approvalUserId === $store.state.user.user.id"
              v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
              v-permission="permission.approve"
              :loading="crud.status.cu === 2"
              size="mini"
@@ -225,7 +239,7 @@
                <el-button :loading="crud.status.cu === 2" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button>
              </div>
              <el-button
                v-if="scope.row.approvalUserId === $store.state.user.user.id"
                v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
                slot="reference"
                v-permission="permission.approve"
                type="danger"
@@ -235,11 +249,13 @@
              >撤销
              </el-button>
            </el-popover>
            <el-link v-if="scope.row.wecomSpNo" type="primary">请前往企微审核</el-link>
          </template>
        </el-table-column>
        <el-table-column v-if="checkPer(['admin','attendanceCardreplacement:edit','attendanceCardreplacement:del'])" label="操作" width="150px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              v-if="!scope.row.wecomSpNo"
              :data="scope.row"
              :permission="permission"
            />
@@ -261,15 +277,16 @@
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import approvalLine from '@/components/ApprovalLine'
import constant from '../../../utils/constant'
const defaultForm = { id: null, userId: null, userName: null, approvalUserId: null, cardReplacementTime: null, cardReplacementReason: null, approvalStatus: null, approvalDescription: null, cardReplacementDistinguish: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
const defaultForm = { id: null, userId: null, userName: null, approvalUserId: null, cardReplacementTime: null, cardReplacementReason: null, approvalStatus: null, approvalDescription: null, cardReplacementDistinguish: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, wecomSpNo: null, event: null }
export default {
  name: 'AttendanceCardreplacement',
  components: { pagination, crudOperation, rrOperation, udOperation },
  components: { pagination, crudOperation, rrOperation, udOperation, approvalLine },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  // 数据字典
  dicts: [constant.CARD_REPLACEMENT_DIFFERENTIATION, constant.CARD_APPROVE_STATUS],
  dicts: [constant.CARD_REPLACEMENT_DIFFERENTIATION, constant.CARD_APPROVE_STATUS, constant.APPROVAL_SITE_TYPE],
  cruds() {
    return CRUD({ title: '补卡记录', url: 'api/attendanceCardreplacement', idField: 'id', sort: 'cardReplacementTime,desc', crudMethod: { ...crudAttendanceCardreplacement }})
  },
@@ -309,6 +326,7 @@
      dictCardApproveStatusAgree: constant.CARD_APPROVE_STATUS_AGREE,
      dictCardApproveStatusRefuse: constant.CARD_APPROVE_STATUS_REFUSE,
      dictCardReplacement: constant.CARD_REPLACEMENT_DIFFERENTIATION,
      dictApprovalSiteType: constant.APPROVAL_SITE_TYPE,
      userRolesLevelMin: null,
      // 角色级别:普通用户
      roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY,
@@ -351,6 +369,10 @@
      if (this.userRolesLevelMin > this.roleLevelGenerl) {
        // 表单赋值
        this.form.userId = this.user.id
      }
      if (this.dict[this.dictApprovalSiteType].length > 0) {
        this.form.approvalUserId = 0
      }
    },
    // 禁用
@@ -407,6 +429,9 @@
        // 循环数据
        for (let i = 0; i < data.length; i++) {
          // ID列表
          if (data[i].wecomSpNo) {
            continue
          }
          ids.push(data[i].id)
        }
        crudAttendanceCardreplacement.updateAgree({
eladmin-web-master/src/views/attendance/attendanceGoOut/index.vue
@@ -167,7 +167,7 @@
              clearable
              placeholder="请选择"
              style="width: 340px;"
              :disabled="disabledUser(form)"
              :disabled="disabledUser(form) || form.wecomSpNo !== null"
            >
              <el-option
                v-for="item in users"
@@ -177,7 +177,7 @@
              />
            </el-select>
          </el-form-item>
          <el-form-item label="审批者" prop="approvalUserId">
          <el-form-item label="审批者" prop="approvalUserId" :hidden="form.wecomSpNo !== null || (form.id == null && dict[dictApprovalSiteType].length > 0)">
            <el-select
              v-model="form.approvalUserId"
              filterable
@@ -186,7 +186,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            >
              <el-option
@@ -204,6 +205,7 @@
              clearable
              placeholder="请选择"
              style="width: 340px;"
              :disabled="form.wecomSpNo !== null"
            >
              <el-option
                v-for="item in dict[dictGoOutTypr]"
@@ -234,7 +236,8 @@
              "
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
              @change="checkTime"
            />
@@ -260,7 +263,8 @@
              "
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
              @change="checkTime"
            />
@@ -280,7 +284,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            />
          </el-form-item>
@@ -301,7 +306,8 @@
              style="width: 340px;"
              :disabled="
                form.approvalStatus == dictGoOutAgree ||
                  form.approvalStatus == dictGoOutReturn
                  form.approvalStatus == dictGoOutReturn ||
                  form.wecomSpNo !== null
              "
            />
          </el-form-item>
@@ -413,7 +419,21 @@
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
            <el-popover
              v-if="scope.row.wecomSpNo && scope.row.event"
              placement="right-start"
              width="600"
              trigger="click"
            >
              <approvalLine :event-data="scope.row.event" :user-list="users" />
              <el-tag slot="reference" effect="dark">
                <i class="el-icon-search" />
                <span>详细</span>
              </el-tag>
            </el-popover>
            <el-tag v-else-if="scope.row.appUserName">{{ scope.row.appUserName }}</el-tag>
            <el-tag v-else>暂无</el-tag>
          </template>
        </el-table-column>
        <el-table-column
@@ -515,7 +535,7 @@
        >
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.approvalUserId === $store.state.user.user.id"
              v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
              v-permission="permission.approve"
              :loading="crud.status.cu === 2"
              size="mini"
@@ -543,7 +563,7 @@
                >确定</el-button>
              </div>
              <el-button
                v-if="scope.row.approvalUserId === $store.state.user.user.id"
                v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
                slot="reference"
                v-permission="permission.approve"
                type="danger"
@@ -555,6 +575,7 @@
              >撤销
              </el-button>
            </el-popover>
            <el-link v-if="scope.row.wecomSpNo" type="primary">请前往企微审核</el-link>
          </template>
        </el-table-column>
        <el-table-column
@@ -567,7 +588,7 @@
          fixed="right"
        >
          <template slot-scope="scope">
            <udOperation :data="scope.row" :permission="permission" />
            <udOperation v-if="!scope.row.wecomSpNo" :data="scope.row" :permission="permission" />
          </template>
        </el-table-column>
      </el-table>
@@ -586,6 +607,7 @@
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import approvalLine from '@/components/ApprovalLine'
import constant from '@/utils/constant'
const defaultForm = {
@@ -604,11 +626,13 @@
  createBy: null,
  createTime: null,
  updateBy: null,
  updateTime: null
  updateTime: null,
  wecomSpNo: null,
  event: null
}
export default {
  name: 'AttendanceGoOut',
  components: { pagination, crudOperation, rrOperation, udOperation },
  components: { pagination, crudOperation, rrOperation, udOperation, approvalLine },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
@@ -623,7 +647,8 @@
  dicts: [
    constant.LEAVE_TIME_TYPE,
    constant.GO_OUT_TYPE,
    constant.GO_OUT_APPROVE_STATUS
    constant.GO_OUT_APPROVE_STATUS,
    constant.APPROVAL_SITE_TYPE
  ],
  data() {
    return {
@@ -673,6 +698,7 @@
      dictGoOutAppRev: constant.GO_OUT_APPROVE_STATUS_REVIEWED,
      dictGoOutAgree: constant.GO_OUT_APPROVE_STATUS_AGREE,
      dictGoOutReturn: constant.GO_OUT_APPROVE_STATUS_REFUSE,
      dictApprovalSiteType: constant.APPROVAL_SITE_TYPE,
      makeUpCardVisible: false,
      successLoading: false,
      userRolesLevelMin: null,
@@ -704,6 +730,10 @@
      if (this.userRolesLevelMin > this.roleLevelGenerl) {
        // 表单赋值
        this.form.userId = this.user.id
      }
      if (this.dict[this.dictApprovalSiteType].length > 0) {
        this.form.approvalUserId = 0
      }
    },
    // 禁用
@@ -769,6 +799,9 @@
        // 循环数据
        for (let i = 0; i < data.length; i++) {
          // ID列表
          if (data[i].wecomSpNo) {
            continue
          }
          ids.push(data[i].id)
        }
        crudAttendanceGoOut
@@ -791,22 +824,22 @@
    // 时间同步
    toReflash(data) {
      const ids = []
        // 循环数据
        for (let i = 0; i < data.length; i++) {
          // ID列表
          ids.push(data[i].id)
        }
        crudAttendanceGoOut
          .reflashTime(ids)
          .then(res => {
            // 消息提示
            this.$message({
              type: 'success',
              message: '刷新成功!'
            })
            // 刷新数据
            this.crud.refresh()
      // 循环数据
      for (let i = 0; i < data.length; i++) {
        // ID列表
        ids.push(data[i].id)
      }
      crudAttendanceGoOut
        .reflashTime(ids)
        .then(res => {
          // 消息提示
          this.$message({
            type: 'success',
            message: '刷新成功!'
          })
          // 刷新数据
          this.crud.refresh()
        })
    },
    // 审批页面赋值
eladmin-web-master/src/views/attendance/attendanceLeave/index.vue
@@ -94,7 +94,7 @@
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
          <el-form-item label="申请人" prop="userId">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledUser(form)" @change="checkLeaveTime">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledUser(form) || form.wecomSpNo !== null" @change="checkLeaveTime">
              <el-option
                v-for="item in users"
                :key="item.id"
@@ -103,8 +103,8 @@
              />
            </el-select>
          </el-form-item>
          <el-form-item label="审批者" prop="approvalUserId">
            <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn">
          <el-form-item label="审批者" prop="approvalUserId" :hidden="form.wecomSpNo !== null || (form.id == null && dict[dictApprovalSiteType].length > 0)">
            <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null">
              <el-option
                v-for="item in approvalUsers"
                :key="item.id"
@@ -114,7 +114,7 @@
            </el-select>
          </el-form-item>
          <el-form-item label="请假类型" prop="leaveType">
            <el-select v-model="form.leaveType" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn" @change="checkLeaveTime">
            <el-select v-model="form.leaveType" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null" @change="checkLeaveTime">
              <el-option
                v-for="item in dict[dictLeaveType]"
                :key="item.value"
@@ -137,7 +137,7 @@
                }
              }"
              :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'"
              :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn"
              :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null"
              @change="checkLeaveTime"
            />
          </el-form-item>
@@ -155,7 +155,7 @@
                }
              }"
              :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'"
              :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn"
              :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null"
              @change="checkLeaveTime"
            />
          </el-form-item>
@@ -165,13 +165,13 @@
            </el-input>
          </el-form-item>
          <el-form-item label="请假原因">
            <el-input v-model="form.leaveReason" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn" />
            <el-input v-model="form.leaveReason" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null" />
          </el-form-item>
          <el-form-item label="审批说明">
            <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 340px;" disabled />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn" />
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
@@ -220,7 +220,21 @@
        </el-table-column>
        <el-table-column prop="appUserName" label="审批者" min-width="100" fixed="left" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
            <el-popover
              v-if="scope.row.wecomSpNo && scope.row.event"
              placement="right-start"
              width="600"
              trigger="click"
            >
              <approvalLine :event-data="scope.row.event" :user-list="users" />
              <el-tag slot="reference" effect="dark">
                <i class="el-icon-search" />
                <span>详细</span>
              </el-tag>
            </el-popover>
            <el-tag v-else-if="scope.row.appUserName">{{ scope.row.appUserName }}</el-tag>
            <el-tag v-else>暂无</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="leaveType" label="请假类型" min-width="80" show-overflow-tooltip>
@@ -257,7 +271,7 @@
        <el-table-column v-if="checkPer(['admin','attendanceLeave:approve'])" label="审核操作" width="180px" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.approvalUserId === $store.state.user.user.id"
              v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
              v-permission="permission.approve"
              :loading="crud.status.cu === 2"
              size="mini"
@@ -277,7 +291,7 @@
                <el-button :loading="successLoading" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button>
              </div>
              <el-button
                v-show="scope.row.approvalUserId === $store.state.user.user.id"
                v-show="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
                slot="reference"
                v-permission="permission.approve"
                type="danger"
@@ -287,11 +301,13 @@
              >撤销
              </el-button>
            </el-popover>
            <el-link v-if="scope.row.wecomSpNo" type="primary">请前往企微审核</el-link>
          </template>
        </el-table-column>
        <el-table-column v-if="checkPer(['admin','attendanceLeave:edit','attendanceLeave:del'])" label="操作" width="150px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              v-if="!scope.row.wecomSpNo"
              :data="scope.row"
              :permission="permission"
            />
@@ -313,18 +329,19 @@
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import approvalLine from '@/components/ApprovalLine'
import constant from '@/utils/constant'
const defaultForm = { id: null, userId: null, approvalUserId: null, leaveType: null, leaveStartTime: null, leaveEndTime: null, leaveDuration: null, leaveDurationUnit: null, leaveReason: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
const defaultForm = { id: null, userId: null, approvalUserId: null, leaveType: null, leaveStartTime: null, leaveEndTime: null, leaveDuration: null, leaveDurationUnit: null, leaveReason: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, wecomSpNo: null, event: null }
export default {
  name: 'AttendanceLeave',
  components: { pagination, crudOperation, rrOperation, udOperation },
  components: { pagination, crudOperation, rrOperation, udOperation, approvalLine },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '请假记录', url: 'api/attendanceLeave', idField: 'id', sort: 'leaveStartTime,desc', crudMethod: { ...crudAttendanceLeave }})
  },
  // 数据字典
  dicts: [constant.LEAVE_TYPE, constant.APPROVAL_STATUS, constant.LEAVE_TIME_TYPE],
  dicts: [constant.LEAVE_TYPE, constant.APPROVAL_STATUS, constant.LEAVE_TIME_TYPE, constant.APPROVAL_SITE_TYPE],
  data() {
    return {
      permission: {
@@ -373,6 +390,7 @@
      dictLeaveTimeType: constant.LEAVE_TIME_TYPE,
      dictLeaveTimeTypeHour: constant.LEAVE_TIME_TYPE_HOUR,
      dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY,
      dictApprovalSiteType: constant.APPROVAL_SITE_TYPE,
      yearTimeLenght: null,
      OverTimeLenght: null,
      makeUpCardVisible: false,
@@ -407,6 +425,9 @@
      if (this.userRolesLevelMin > this.roleLevelGenerl) {
        // 表单赋值
        this.form.userId = this.user.id
      }
      if (this.dict[this.dictApprovalSiteType].length > 0) {
        this.form.approvalUserId = 0
      }
    },
    // 钩子:在编辑之前执行
@@ -505,6 +526,9 @@
        // 循环数据
        for (let i = 0; i < data.length; i++) {
          // ID列表
          if (data[i].wecomSpNo) {
            continue
          }
          ids.push(data[i].id)
        }
        crudAttendanceLeave.updateAgree({
eladmin-web-master/src/views/attendance/attendanceOvertime/index.vue
@@ -59,7 +59,7 @@
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="申请人" prop="userId">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledUser(form)">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledUser(form) || form.wecomSpNo !== null">
              <el-option
                v-for="item in users"
                :key="item.id"
@@ -68,8 +68,8 @@
              />
            </el-select>
          </el-form-item>
          <el-form-item label="审批者" prop="approvalUserId">
            <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn">
          <el-form-item label="审批者" prop="approvalUserId" :hidden="form.wecomSpNo !== null || (form.id == null && dict[dictApprovalSiteType].length > 0)">
            <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null">
              <el-option
                v-for="item in approvalUsers"
                :key="item.id"
@@ -92,7 +92,7 @@
                }
              }"
              :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'"
              :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn"
              :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null"
              @change="checkLeaveTime()"
            />
          </el-form-item>
@@ -110,7 +110,7 @@
                }
              }"
              :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'"
              :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn"
              :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null"
              @change="checkLeaveTime()"
            />
          </el-form-item>
@@ -118,10 +118,10 @@
            <el-input v-model="form.overtimeDuration" disabled style="width: 340px;" />
          </el-form-item>
          <el-form-item label="审批说明">
            <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 340px;" />
            <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 340px;" :disabled="form.wecomSpNo !== null" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn" />
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictAppRovalStatusPassed || form.approvalStatus == dictAppRovalStatusReturn || form.wecomSpNo !== null" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
@@ -167,7 +167,21 @@
        </el-table-column>
        <el-table-column prop="appUserName" label="审批者" min-width="100" fixed="left" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
            <el-popover
              v-if="scope.row.wecomSpNo && scope.row.event"
              placement="right-start"
              width="600"
              trigger="click"
            >
              <approvalLine :event-data="scope.row.event" :user-list="users" />
              <el-tag slot="reference" effect="dark">
                <i class="el-icon-search" />
                <span>详细</span>
              </el-tag>
            </el-popover>
            <el-tag v-else-if="scope.row.appUserName">{{ scope.row.appUserName }}</el-tag>
            <el-tag v-else>暂无</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="overtimeStartTime" label="加班开始时间" show-overflow-tooltip />
@@ -190,7 +204,7 @@
        <el-table-column v-if="checkPer(['admin','attendanceOvertime:approve'])" label="审核操作" width="180px" align="center">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.approvalUserId === $store.state.user.user.id"
              v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
              v-permission="permission.approve"
              :loading="crud.status.cu === 2"
              size="mini"
@@ -210,7 +224,7 @@
                <el-button :loading="successLoading" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button>
              </div>
              <el-button
                v-show="scope.row.approvalUserId === $store.state.user.user.id"
                v-show="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo"
                slot="reference"
                v-permission="permission.approve"
                type="danger"
@@ -220,11 +234,13 @@
              >撤销
              </el-button>
            </el-popover>
            <el-link v-if="scope.row.wecomSpNo" type="primary">请前往企微审核</el-link>
          </template>
        </el-table-column>
        <el-table-column v-if="checkPer(['admin','attendanceOvertime:edit','attendanceOvertime:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              v-if="!scope.row.wecomSpNo"
              :data="scope.row"
              :permission="permission"
            />
@@ -245,18 +261,19 @@
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import approvalLine from '@/components/ApprovalLine'
import constant from '@/utils/constant'
import { mapGetters } from 'vuex'
const defaultForm = { id: null, userId: null, approvalUserId: null, overtimeStartTime: null, overtimeEndTime: null, overtimeDuration: null, overtimeDurationUnit: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
const defaultForm = { id: null, userId: null, approvalUserId: null, overtimeStartTime: null, overtimeEndTime: null, overtimeDuration: null, overtimeDurationUnit: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, wecomSpNo: null, event: null }
export default {
  name: 'AttendanceOvertime',
  components: { pagination, crudOperation, rrOperation, udOperation },
  components: { pagination, crudOperation, rrOperation, udOperation, approvalLine },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '考勤加班', url: 'api/attendanceOvertime', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAttendanceOvertime }})
  },
  dicts: [constant.OVERTIME_STATUS],
  dicts: [constant.OVERTIME_STATUS, constant.APPROVAL_SITE_TYPE],
  data() {
    return {
      permission: {
@@ -301,6 +318,7 @@
      dictAppRovalStatusUnderAppover: constant.OVERTIME_APPROVAL,
      dictAppRovalStatusPassed: constant.OVERTIME_PASS,
      dictAppRovalStatusReturn: constant.OVERTIME_RETURN,
      dictApprovalSiteType: constant.APPROVAL_SITE_TYPE,
      successLoading: false,
      makeUpCardVisible: false
    }
@@ -330,6 +348,10 @@
        // 表单赋值
        this.form.userId = this.user.id
      }
      if (this.dict[this.dictApprovalSiteType].length > 0) {
        this.form.approvalUserId = 0
      }
    },
    // 查询员工
    getUsers() {
eladmin-web-master/src/views/template/bind/index.vue
New file
@@ -0,0 +1,286 @@
<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
      <div>
        <el-button
          slot="right"
          size="mini"
          type="primary"
          icon="el-icon-edit"
          class="filter-item"
          @click="refreshWecomVacationType()"
        >
          更新企微请假类型
        </el-button>
      </div>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="cancelBind" :visible.sync="bindParam.visible" :title="bindParam.title" width="600px">
        <div class="query-container">
          <el-input v-model="bindParam.queryTemplateId" placeholder="请输入模版ID查询" style="width: 300px;" />
          <span>
            <el-button icon="el-icon-search" type="primary" size="mini" @click="toQueryTemplate">查新</el-button>
            <el-button icon="el-icon-search" type="primary" size="mini" @click="toQueryTemplate(false)">查旧</el-button>
            <el-button icon="el-icon-refresh-right" type="warning" size="mini" @click="resetTemplate">重置</el-button>
          </span>
        </div>
        <el-divider />
        <el-form ref="form" :model="bindParam.data" :rules="rules" size="small" label-width="180px">
          <el-form-item label="模板ID">
            <el-input v-model="bindParam.data.templateId" disabled style="width: 370px;" />
          </el-form-item>
          <el-form-item label="模版名称">
            <el-input v-model="bindParam.data.templateName" disabled style="width: 370px;" />
          </el-form-item>
          <el-form-item
            v-for="control in bindParam.currentTemplateData.templateControls"
            :key="control.id"
            :label="`${control.titleTextZh || control.titleTextEn}(${control.controlParamName})`"
            :prop="`${control.id}`"
            :rules="[{
              required: control.contentRequire == 1, message: `${control.titleTextZh || control.titleTextEn}(${control.controlParamName})不能为空`, trigger: 'change'
            }]"
          >
            <el-select v-model="bindParam.data[`${control.id}`]" filterable clearable :placeholder="`请选择${control.titleTextZh || control.titleTextEn}(${control.controlParamName})`" style="width: 370px;">
              <el-option v-for="item in bindParam.tableData.fieldNames" :key="control.id + control.controlId + '_' + item.propName" :label="`${item.label}(${item.propName})`" :value="item.propName" />
            </el-select>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="cancelBind">取消</el-button>
          <el-button :loading="bindParam.loading" type="primary" @click="doBind">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="queryLoading" :data="tableInfoData" size="small" style="width: 100%;">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="name" label="绑定类型" />
        <el-table-column prop="fieldTable" label="绑定表名" />
        <el-table-column v-if="checkPer(['admin','templateControlField:edit'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <el-button v-permission="permission.edit" size="mini" type="primary" icon="el-icon-edit" @click="toBind(scope.row)" />
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import { bind, queryByTable, editWecomVacationType } from '@/api/template/templateControlField'
import { queryTemplate } from '@/api/template/template'
import constant from '@utils/constant'
import Vue from 'vue'
export default {
  name: 'TemplateBind',
  data() {
    return {
      // 绑定审批表信息
      tableInfoData: [],
      queryLoading: false,
      bindParam: {
        loading: false,
        visible: false,
        title: '审批模板绑定',
        queryTemplateId: null,
        // 选中表数据
        tableData: null,
        // 当前模板信息
        currentTemplateData: {},
        // 当前控件绑定信息
        currentTemplateControlFieldData: [],
        // 原始模板信息
        originTemplateData: {},
        // 原始控件绑定信息
        originTemplateControlFieldData: [],
        // 绑定表单数据
        data: {}
      },
      permission: {
        add: ['admin', 'templateControlField:add'],
        edit: ['admin', 'templateControlField:edit'],
        del: ['admin', 'templateControlField:del']
      },
      rules: {}
    }
  },
  dicts: [constant.WECOM_BIND_LEAVE, constant.WECOM_BIND_GOOUT, constant.WECOM_BIND_TRAVEL, constant.WECOM_BIND_OVERTIME, constant.WECOM_BIND_REPLACEMENT],
  created() {
    const that = this
    that.queryLoading = true
    that.$on('dictReady', () => {
      const dictData = { ...that.dict }
      // 请假字段绑定信息制作
      const leaveTableDate = { name: '请假', fieldTable: constant.WECOM_BIND_LEAVE, fieldNames: [] }
      dictData[constant.WECOM_BIND_LEAVE].forEach(leave => {
        leaveTableDate.fieldNames.push({ label: leave.label, propName: leave.value })
        return leave
      })
      // 外出字段绑定信息制作
      const goOutTableDate = { name: '外出', fieldTable: constant.WECOM_BIND_GOOUT, fieldNames: [] }
      dictData[constant.WECOM_BIND_GOOUT].forEach(goOut => {
        goOutTableDate.fieldNames.push({ label: goOut.label, propName: goOut.value })
      })
      // 出差字段绑定信息制作
      const travelTableDate = { name: '出差', fieldTable: constant.WECOM_BIND_TRAVEL, fieldNames: [] }
      dictData[constant.WECOM_BIND_TRAVEL].forEach(travel => {
        travelTableDate.fieldNames.push({ label: travel.label, propName: travel.value })
      })
      // 换休字段绑定信息制作
      const overtimeTableDate = { name: '换休', fieldTable: constant.WECOM_BIND_OVERTIME, fieldNames: [] }
      dictData[constant.WECOM_BIND_OVERTIME].forEach(overtime => {
        overtimeTableDate.fieldNames.push({ label: overtime.label, propName: overtime.value })
      })
      // 补卡字段绑定信息制作
      const replacementTableDate = { name: '补卡', fieldTable: constant.WECOM_BIND_REPLACEMENT, fieldNames: [] }
      dictData[constant.WECOM_BIND_REPLACEMENT].forEach(replacement => {
        replacementTableDate.fieldNames.push({ label: replacement.label, propName: replacement.value })
      })
      that.tableInfoData.push(leaveTableDate, goOutTableDate, travelTableDate, overtimeTableDate, replacementTableDate)
      that.queryLoading = false
    })
  },
  methods: {
    // 更新企微请假类型
    refreshWecomVacationType() {
      const that = this
      editWecomVacationType().then(() => {
        that.$message({
          message: '企微请假类型更新成功',
          type: 'success',
          duration: 1500
        })
      })
    },
    // 执行绑定
    toBind(data) {
      const that = this
      // 显示模版绑定弹窗
      that.bindParam.visible = true
      // 显示模版绑定Loading
      that.bindParam.loading = true
      // 绑定数据赋值
      that.bindParam.tableData = data
      // 查询模版绑定信息
      queryByTable({ fieldTable: data.fieldTable }).then(res => {
        if (res) {
          // 源数据赋值
          that.bindParam.originTemplateData = res.template || {}
          that.bindParam.currentTemplateData = res.template || {}
          that.bindParam.originTemplateControlFieldData = res.templateControlField || []
          that.bindParam.currentTemplateControlFieldData = res.templateControlField || []
          if (res.template) {
            Vue.set(that.bindParam.data, 'templateId', res.template.templateId)
            Vue.set(that.bindParam.data, 'templateName', res.template.templateNameZh || res.template.templateNameEn)
          }
          res.templateControlField.forEach(i => {
            Vue.set(that.bindParam.data, `${i.controlId}`, i.fieldName || null)
          })
        }
        // 关闭模版绑定Loading
        that.bindParam.loading = false
      }).catch(() => {
        // 关闭模版绑定Loading
        that.bindParam.loading = false
      })
    },
    // 执行绑定
    doBind() {
      const that = this
      that.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        const finalData = []
        that.bindParam.currentTemplateData.templateControls.forEach(i => {
          const item = {}
          item.templateId = that.bindParam.currentTemplateData.id
          item.controlId = i.id
          item.fieldTable = that.bindParam.tableData.fieldTable
          item.fieldName = that.bindParam.data[`${i.id}`] || null
          finalData.push(item)
        })
        bind(finalData).then(() => {
          that.cancelBind()
        })
      })
    },
    // 获取模版信息
    toQueryTemplate(update = true) {
      const that = this
      if (that.bindParam.queryTemplateId === null || that.bindParam.queryTemplateId === '') {
        return
      }
      queryTemplate({ templateId: that.bindParam.queryTemplateId, queryNew: (!!update) }).then(res => {
        that.bindParam.currentTemplateData = res
        that.bindParam.currentTemplateControlFieldData = []
        that.bindParam.data = {
          templateId: res.templateId,
          templateName: res.templateNameZh || res.templateNameEn
        }
      })
    },
    // 重置模版信息
    resetTemplate() {
      const that = this
      that.bindParam.currentTemplateData = { ...that.bindParam.originTemplateData }
      that.bindParam.currentTemplateControlFieldData = { ...that.bindParam.originTemplateControlFieldData }
      if (that.bindParam.originTemplateData.templateId) {
        that.bindParam.data['templateId'] = that.bindParam.originTemplateData.templateId
        that.bindParam.data['templateName'] = that.bindParam.originTemplateData.templateNameZh || that.bindParam.originTemplateData.templateNameEn
      } else {
        that.bindParam.data['templateId'] = null
        that.bindParam.data['templateName'] = null
      }
      that.bindParam.originTemplateControlFieldData.forEach(i => {
        that.bindParam.data[`${i.controlId}`] = i.fieldName
      })
    },
    // 清空模板绑定数据
    clearTemplateBindData() {
      const that = this
      that.bindParam.currentTemplateData = {}
      that.bindParam.currentTemplateControlFieldData = []
      that.bindParam.originTemplateData = {}
      that.bindParam.originTemplateControlFieldData = []
      that.bindParam.queryTemplateId = null
      that.bindParam.tableData = null
      that.bindParam.data = {}
    },
    // 取消模版绑定
    cancelBind() {
      const that = this
      that.bindParam.visible = false
      that.bindParam.loading = false
      that.clearTemplateBindData()
    }
  }
}
</script>
<style scoped>
  .query-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 10px;
  }
</style>