浏览代码

新增请假相关接口

chenjun 1 年之前
父节点
当前提交
27575bfe5a

+ 12 - 0
zjugis-business/pom.xml

@@ -58,6 +58,18 @@
             <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
         </dependency>
 
+        <!-- 依赖服务 -->
+        <dependency>
+            <groupId>com.zjugis.cloud</groupId>
+            <artifactId>zjugis-module-system-api</artifactId>
+            <version>${revision}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.zjugis.cloud</groupId>
+            <artifactId>zjugis-module-adm-api</artifactId>
+            <version>${revision}</version>
+        </dependency>
+
         <!-- Config 配置中心相关 -->
         <dependency>
             <groupId>com.alibaba.cloud</groupId>

+ 33 - 0
zjugis-business/src/main/java/com/zjugis/business/converter/SelectConvert.java

@@ -0,0 +1,33 @@
+package com.zjugis.business.converter;
+
+import com.zjugis.framework.workflow.utils.Select;
+import com.zjugis.module.system.api.dict.dto.DictDataRespDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.Mappings;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+
+/**
+ * @Author 陈俊
+ * @Date 2023/11/20 17:27
+ * @Version 1.0
+ */
+@Mapper
+public interface SelectConvert {
+
+    SelectConvert INSTANCE = Mappers.getMapper(SelectConvert.class);
+
+    @Mappings({
+            @Mapping(source = "label", target = "text"),
+            @Mapping(source = "value", target = "value"),
+    })
+    Select convert(DictDataRespDTO bean);
+
+    @Mappings({
+            @Mapping(source = "label", target = "text"),
+            @Mapping(source = "value", target = "value"),
+    })
+    List<Select> convertList(List<DictDataRespDTO> bean);
+}

+ 39 - 0
zjugis-business/src/main/java/com/zjugis/business/flow/leave/controller/LeaveController.java

@@ -0,0 +1,39 @@
+package com.zjugis.business.flow.leave.controller;
+
+import com.alibaba.fastjson2.JSON;
+import com.zjugis.business.converter.SelectConvert;
+import com.zjugis.framework.workflow.model.BaseController;
+import com.zjugis.framework.workflow.utils.Select;
+import com.zjugis.framework.workflow.workflow.WorkFlow;
+import com.zjugis.module.system.api.dict.DictDataApi;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author 陈俊
+ * @Date 2023/11/20 16:26
+ * @Version 1.0
+ */
+@RestController
+@RequestMapping("/Leave")
+public class LeaveController extends BaseController {
+
+    @Resource
+    private DictDataApi dictDataApi;
+
+    @WorkFlow(isReceiveMaterial = true, isReceiveOpinion = true)
+    @ResponseBody
+    @RequestMapping("/index")
+    public String index(String activityTemplateId, String flowInstanceId, String userId) throws Exception {
+        Map<String, Object> map = new HashMap<>();
+        List<Select> leaveTypeList = SelectConvert.INSTANCE.convertList(dictDataApi.getDictDataList("WF_LEAVE_TYPE").getCheckedData());
+        map.put("leaveTypeJSON", JSON.toJSONString(leaveTypeList));
+        return resultPage(map);
+    }
+}

+ 80 - 0
zjugis-business/src/main/java/com/zjugis/business/flow/leave/entity/Leave.java

@@ -0,0 +1,80 @@
+package com.zjugis.business.flow.leave.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.zjugis.business.mybatis.entity.BaseEntity;
+import lombok.Data;
+
+import java.time.LocalDate;
+
+/**
+ * @Author 陈俊
+ * @Date 2023/11/20 15:00
+ * @Version 1.0
+ */
+@Data
+@TableName(value = "WF_LEAVE")
+public class Leave extends BaseEntity {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 流程实例ID
+     */
+    private String instanceId;
+
+    /**
+     * 流程状态
+     */
+    private Integer flowStatus;
+
+    /**
+     * 流程完成时间
+     */
+    private LocalDate flowFinishtime;
+
+    /**
+     * 用户ID
+     */
+    private String userId;
+
+    /**
+     * 用户昵称
+     */
+    private String userNickname;
+
+    /**
+     * 部门ID
+     */
+    private String deptId;
+
+    /**
+     * 部门名称
+     */
+    private String deptName;
+
+    /**
+     * 请假单号
+     */
+    private String leaveNo;
+
+    /**
+     * 请假类型
+     */
+    private Integer leaveType;
+
+    /**
+     * 请假天数
+     */
+    private Integer leaveDays;
+
+    /**
+     * 请假小时
+     */
+    private Double leaveHours;
+}

+ 45 - 0
zjugis-business/src/main/java/com/zjugis/business/flow/leave/entity/LeaveTime.java

@@ -0,0 +1,45 @@
+package com.zjugis.business.flow.leave.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.zjugis.business.mybatis.entity.BaseEntity;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * @Author 陈俊
+ * @Date 2023/11/20 15:34
+ * @Version 1.0
+ */
+@Data
+@TableName(value = "WF_LEAVE_TIME")
+public class LeaveTime extends BaseEntity {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.ASSIGN_UUID)
+    private String id;
+
+    /**
+     * 请假表ID
+     */
+    private String leaveId;
+
+    /**
+     * 起始时间
+     */
+    private LocalDateTime startTime;
+
+    /**
+     * 结束时间
+     */
+    private LocalDateTime endTime;
+
+    /**
+     * 哺乳假类型(1:早上一小时;2:下午一小时)
+     */
+    private Integer breastfeedingType;
+}

+ 17 - 0
zjugis-business/src/main/java/com/zjugis/business/framework/rpc/config/RpcSystemConfiguration.java

@@ -0,0 +1,17 @@
+package com.zjugis.business.framework.rpc.config;
+
+import com.zjugis.module.system.api.dept.DeptApi;
+import com.zjugis.module.system.api.dict.DictDataApi;
+import com.zjugis.module.system.api.user.AdminUserApi;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Author 陈俊
+ * @Date 2023/11/20 17:04
+ * @Version 1.0
+ */
+@Configuration(proxyBeanMethods = false)
+@EnableFeignClients(clients = {AdminUserApi.class, DeptApi.class, DictDataApi.class})
+public class RpcSystemConfiguration {
+}

+ 111 - 0
zjugis-business/src/main/resources/static/index.html

@@ -0,0 +1,111 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+	<meta charset="UTF-8">
+	<title>首页</title>
+	<!-- jQuery:操作 dom、发起请求等 -->
+	<script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/2.1.2/jquery.min.js" type="application/javascript"></script>
+
+	<script type="application/javascript">
+
+    /**
+     * 跳转单点登录
+     */
+    function passwordLogin() {
+      window.location.href = '/login.html'
+    }
+
+    /**
+     * 刷新令牌
+     */
+    function refreshToken() {
+      const refreshToken = localStorage.getItem('REFRESH-TOKEN');
+      if (!refreshToken) {
+        alert("获取不到刷新令牌");
+        return;
+      }
+      $.ajax({
+        url: "http://127.0.0.1:48081/admin-api/system/oauth2/refresh-token?refreshToken=" + refreshToken,
+        method: 'POST',
+        success: function (result) {
+          if (result.code !== 0) {
+            alert('刷新访问令牌失败,原因:' + result.msg)
+            return;
+          }
+          alert('更新访问令牌成功!');
+          $('#accessTokenSpan').html(result.data.access_token);
+
+          // 设置到 localStorage 中
+          localStorage.setItem('ACCESS-TOKEN', result.data.access_token);
+          localStorage.setItem('REFRESH-TOKEN', result.data.refresh_token);
+        }
+      });
+    }
+
+    /**
+     * 登出,删除访问令牌
+     */
+    function logout() {
+      const accessToken = localStorage.getItem('ACCESS-TOKEN');
+      if (!accessToken) {
+        location.reload();
+        return;
+      }
+      $.ajax({
+        url: "http://127.0.0.1:48080/admin-api/system/oauth2/logout",
+        method: 'POST',
+        headers: {
+          'Authorization': 'Bearer ' + accessToken
+        },
+        success: function (result) {
+          if (result.code !== 0) {
+            alert('退出登录失败,原因:' + result.msg)
+            return;
+          }
+          alert('退出登录成功!');
+          // 删除 localStorage 中
+          localStorage.removeItem('ACCESS-TOKEN');
+          localStorage.removeItem('REFRESH-TOKEN');
+
+          location.reload();
+        }
+      });
+    }
+
+    $(function () {
+      const accessToken = localStorage.getItem('ACCESS-TOKEN');
+      // 情况一:未登录
+      if (!accessToken) {
+        $('#noLoginDiv').css("display", "block");
+        return;
+      }
+
+      // 情况二:已登录
+      $('#yesLoginDiv').css("display", "block");
+      $('#accessTokenSpan').html(accessToken);
+    })
+	</script>
+</head>
+<body>
+<!-- 情况一:未登录:1)跳转 ruoyi-vue-pro 的 SSO 登录页 -->
+<div id="noLoginDiv" style="display: none">
+	您未登录,点击 <a href="#" onclick="passwordLogin()">跳转 </a> 账号密码登录
+</div>
+
+<!-- 情况二:已登录:1)展示用户信息;2)刷新访问令牌;3)退出登录 -->
+<div id="yesLoginDiv" style="display: none">
+	您已登录!<button onclick="logout()">退出登录</button> <br />
+	访问令牌:<span id="accessTokenSpan"> 加载中... </span> <button onclick="refreshToken()">刷新令牌</button> <br />
+</div>
+</body>
+<style>
+    body { /** 页面居中 */
+        border-radius: 20px;
+        height: 350px;
+        position: absolute;
+        left: 50%;
+        top: 50%;
+        transform: translate(-50%,-50%);
+    }
+</style>
+</html>

+ 79 - 0
zjugis-business/src/main/resources/static/login.html

@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>登录</title>
+    <!-- jQuery:操作 dom、发起请求等 -->
+    <script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/2.1.2/jquery.min.js"
+            type="application/javascript"></script>
+
+    <script type="application/javascript">
+
+        /**
+         * 账号密码登录
+         */
+        function login() {
+            const clientId = 'workflow'; // 可以改写成,你的 clientId
+            const clientSecret = 'workflow_zdww'; // 可以改写成,你的 clientSecret
+            const grantType = 'password'; // 密码模式
+
+            // 账号 + 密码
+            const username = $('#username').val();
+            const password = $('#password').val();
+            if (username.length === 0 || password.length === 0) {
+                alert('账号或密码未输入');
+                return;
+            }
+
+            // 发起请求
+            $.ajax({
+                url: "http://127.0.0.1:48081/admin-api/system/oauth2/token?"
+                    // 客户端
+                    + "client_id=" + clientId
+                    + "&client_secret=" + clientSecret
+                    // 密码模式的参数
+                    + "&grant_type=" + grantType
+                    + "&username=" + username
+                    + "&password=" + password
+                    + '&scope=user.read user.write',
+                method: 'POST',
+                headers: {},
+                success: function (result) {
+                    if (result.code !== 0) {
+                        alert('登录失败,原因:' + result.msg)
+                        return;
+                    }
+                    var a = {};
+                    a.v = result.data.access_token;
+                    var r = {};
+                    r.v = result.data.refresh_token;
+                    // 设置到 localStorage 中
+                    localStorage.setItem('ACCESS-TOKEN', result.data.access_token);
+                    localStorage.setItem('REFRESH-TOKEN', result.data.refresh_token);
+                    localStorage.setItem('ACCESS_TOKEN', '"' + JSON.stringify(a) + '"');
+                    localStorage.setItem('REFRESH_TOKEN', '"' + JSON.stringify(r) + '"');
+
+                    // 提示登录成功
+                    alert('登录成功!点击确认,跳转回首页');
+                    window.location.href = '/index.html';
+                }
+            });
+        }
+    </script>
+</head>
+<body>
+账号:<input id="username" value="admin"/> <br/>
+密码:<input id="password" value="admin123"> <br/>
+<button style="float: right; margin-top: 5px;" onclick="login()">登录</button>
+</body>
+<style>
+    body { /** 页面居中 */
+        border-radius: 20px;
+        height: 350px;
+        position: absolute;
+        left: 50%;
+        top: 50%;
+        transform: translate(-50%, -50%);
+    }
+</style>
+</html>

+ 67 - 0
zjugis-business/src/main/resources/templates/Leave/index.ftl

@@ -0,0 +1,67 @@
+<@w.workFlow javascripts=['/Leave/js/index.js']>
+    <div class="z-form-wrap" name="demoForm2">
+        <div class="z-form-row z-subtitle text-info z-border-title">
+            <strong>基本信息</strong>
+        </div>
+        <div class="z-form-row">
+            <div class="z-form-group z-col-30">
+                <div class="z-form-label z-col-30">请假人</div>
+                <div class="z-form-control z-col-70">
+                    <div class="z-comp-input z-readonly" name="demoForm2$field1">
+                        <input type="text" value="陈俊">
+                    </div>
+                </div>
+            </div>
+            <div class="z-form-group z-col-40">
+                <div class="z-form-label z-col-30">所在部门</div>
+                <div class="z-form-control z-col-70">
+                    <div class="z-comp-input z-readonly" name="demoForm2$field2">
+                        <input type="text" value="自然资源产品部">
+                    </div>
+                </div>
+            </div>
+            <div class="z-form-group z-col-30">
+                <div class="z-form-label z-col-30">请假单号</div>
+                <div class="z-form-control z-col-70">
+                    <div class="z-comp-input z-readonly" name="demoForm2$field2">
+                        <input type="text" value="TEST1234">
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="z-form-row">
+            <div class="z-form-group z-col-30">
+                <div class="z-form-label z-col-30">申请时间</div>
+                <div class="z-form-control z-col-70">
+                    <div class="z-comp-date z-readonly" name="demoForm2$field8">
+                        <input type="text" value="2023-10-10">
+                    </div>
+                </div>
+            </div>
+            <div class="z-form-group z-col-40">
+                <div class="z-form-label z-col-30">请假类型</div>
+                <div class="z-form-control z-col-70">
+                    <div class="z-comp-inputselect" name="demoForm2$field14"
+                         data='${leaveTypeJSON!}'>
+                        <div class="z-inputselect-bar">
+                            <input type="text" placeholder="请假类型"><i></i>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="z-form-group z-col-30">
+                <div class="z-form-label z-col-30">请假天数</div>
+                <div class="z-form-control z-col-70">
+                    <div class="z-comp-input z-readonly" name="demoForm2$field2">
+                        <input type="text" value="0">
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="z-form-row z-subtitle text-info z-border-title">
+            <strong>请假时间信息</strong>
+            <a class="btn btn-success pull-right" name="ydqkAdd">新增</a>
+        </div>
+        <div name="leave_time_list"></div>
+    </div>
+</@w.workFlow>

+ 84 - 0
zjugis-business/src/main/resources/templates/Leave/js/index.js

@@ -0,0 +1,84 @@
+(function () {
+    window.onload = function (ex) {
+        bindEvents();
+        initLeaveTimeGrid();
+    }
+
+    //初始化请假时间列表
+    function initLeaveTimeGrid() {
+        var leaveId = $("[name='ywNzyzp$id']").val();
+        var postData = {entity: {leaveId: leaveId}};
+        z.ui.jqgrid("[name=leave_time_list]").init({
+            pagination: false,
+            height: 40,
+            rowList: [10, 20, 50],
+            shrinkToFit: true,//设置表格自适应
+            url: '',//组件创建完成之后请求数据的url
+            postData: z.ui.form.childStringify(postData),
+            colModel: [
+                {name: "id", hidden: true, key: true},
+                {name: "leaveId", hidden: true},
+                {
+                    label: '序号',
+                    name: "ypzpcmc",
+                    align: "center",
+                    width: 160,
+                    editable: true
+                },
+                {
+                    label: '起始时间',
+                    name: "pzwh",
+                    align: "center",
+                    width: 160,
+                    editable: true,
+                },
+                {
+                    label: '截止时间',
+                    name: "nzyzsqkmc",
+                    align: "center",
+                    width: 160,
+                    editable: true,
+                },
+                {
+                    label: '备注',
+                    name: "nzymj",
+                    align: "center",
+                    width: 160,
+                    editable: true,
+                },
+                {
+                    label: "操作",
+                    name: 'action',
+                    align: "center",
+                    width: 60,
+                    buttons: [
+                        {
+                            label: "删除",
+                            className: "btn btn-danger",
+                            onClick: function (rowObject, rowindex, link) {
+                                z.ui.confirm("confirm").init({
+                                    content: '确定删除当前行吗?',
+                                    onCancel: function () {
+
+                                    },
+                                    onConfirm: function () {
+                                        deleteYdqk(rowObject.id);
+                                        var rowid = $(this).attr("rowid");
+                                        z.ui.jqgrid("[name=ydqk_list]").delRowData(rowid);
+                                    },
+                                })
+                            }
+                        }
+                    ]
+                }
+            ]
+        });
+    }
+
+    //注册业务保存事件
+    function bindEvents() {
+
+    }
+
+
+}());