From 6caebfd3c8d3bce8f074250e626f6c108edd6dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E7=A3=8A?= <45566618@qq.com> Date: Fri, 6 Feb 2026 16:52:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=98=E5=B7=A5=E7=AE=A1=E7=90=86-=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E7=AE=A1=E7=90=86=EF=BC=8C=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=AF=AD=E5=8F=A5=E8=B0=83=E6=95=B4=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AE=A1=E6=A0=B8=E5=8E=86=E5=8F=B2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EmployeesApplyController.java | 39 +++++--- .../mapper/EmployeesApplyMapper.java | 6 ++ .../mapper/xml/EmployeesApplyMapper.xml | 80 ++++++++++++++++ .../service/IEmployeesApplyService.java | 7 ++ .../impl/EmployeesApplyServiceImpl.java | 92 ++++++++++++++++++- 5 files changed, 210 insertions(+), 14 deletions(-) diff --git a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/controller/EmployeesApplyController.java b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/controller/EmployeesApplyController.java index 2c4bbc38..b776bdc6 100644 --- a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/controller/EmployeesApplyController.java +++ b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/controller/EmployeesApplyController.java @@ -1,6 +1,8 @@ package com.nu.modules.employeesapply.controller; +import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -30,10 +32,9 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.lang.reflect.Field; +import java.text.SimpleDateFormat; +import java.util.*; /** * @Description: 员工申请 @@ -80,6 +81,15 @@ public class EmployeesApplyController extends JeecgController> listPage(EmployeesApply employeesApply, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(employeesApply, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = employeesApplyService.listPage(page, queryWrapper); + return Result.OK(pageList); + } + /** * 添加 * @@ -106,18 +116,14 @@ public class EmployeesApplyController extends JeecgController edit(@RequestBody EmployeesApply employeesApply) { - if (StringUtils.isNotBlank(employeesApply.getStatusVal())) { + if (StringUtils.isNotBlank(employeesApply.getStatus())) { //有值则说明是正在进行审批 - if ("auditPass".equals(employeesApply.getStatusVal())) { - employeesApply.setStatus("2"); + if ("2".equals(employeesApply.getStatus())) { employeesApply.setAuditContent("审批通过"); } - if ("auditFaild".equals(employeesApply.getStatusVal())) { - employeesApply.setStatus("3"); - } } employeesApplyService.updateById(employeesApply); - if (StringUtils.isNotBlank(employeesApply.getStatusVal())) { + if (StringUtils.isNotBlank(employeesApply.getStatus())) { JSONObject deptInfo = sysBaseAPI.getDeptInfo(); //入职时间 @@ -125,7 +131,7 @@ public class EmployeesApplyController extends JeecgController qw = new QueryWrapper<>(); qw.eq("id", employeesApply.getEmployeeId()); BizEmployeesInfo one = employeesInfoService.getOne(qw); @@ -146,7 +152,7 @@ public class EmployeesApplyController extends JeecgController>> getModifyHistoryInfo(@RequestBody EmployeesApply employeesApply) { + return Result.OK(employeesApplyService.getModifyHistoryInfo(employeesApply)); + } + } diff --git a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/mapper/EmployeesApplyMapper.java b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/mapper/EmployeesApplyMapper.java index 992c13f2..6291b37e 100644 --- a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/mapper/EmployeesApplyMapper.java +++ b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/mapper/EmployeesApplyMapper.java @@ -1,5 +1,9 @@ package com.nu.modules.employeesapply.mapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import com.nu.modules.employeesapply.entity.EmployeesApply; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -12,5 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface EmployeesApplyMapper extends BaseMapper { + IPage listPage(Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); + int cleanErrorInvided(@Param("employeeId") String employeeId); } diff --git a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/mapper/xml/EmployeesApplyMapper.xml b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/mapper/xml/EmployeesApplyMapper.xml index 8a3edbaf..125308ae 100644 --- a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/mapper/xml/EmployeesApplyMapper.xml +++ b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/mapper/xml/EmployeesApplyMapper.xml @@ -2,6 +2,86 @@ + + delete from nu_biz_employees_apply where employee_id = #{employeeId} and iz_history = 'N' and apply_type = '1' diff --git a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/service/IEmployeesApplyService.java b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/service/IEmployeesApplyService.java index d3c08402..faeebf54 100644 --- a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/service/IEmployeesApplyService.java +++ b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/service/IEmployeesApplyService.java @@ -1,6 +1,9 @@ package com.nu.modules.employeesapply.service; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.nu.modules.employeesapply.entity.EmployeesApply; import com.baomidou.mybatisplus.extension.service.IService; @@ -15,6 +18,8 @@ import java.util.Map; */ public interface IEmployeesApplyService extends IService { + IPage listPage(Page page, QueryWrapper queryWrapper); + void cleanErrorInvided(String employeeId); List> getModifyInfo(EmployeesApply employeesApply); @@ -22,4 +27,6 @@ public interface IEmployeesApplyService extends IService { void audit(EmployeesApply employeesApply); void initialization(JSONObject j); + + List> getModifyHistoryInfo(EmployeesApply employeesApply); } diff --git a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/service/impl/EmployeesApplyServiceImpl.java b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/service/impl/EmployeesApplyServiceImpl.java index 746ed06a..7d3d75d6 100644 --- a/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/service/impl/EmployeesApplyServiceImpl.java +++ b/nursing-unit-employee/nu-employee-biz/src/main/java/com/nu/modules/employeesapply/service/impl/EmployeesApplyServiceImpl.java @@ -4,6 +4,8 @@ import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.nu.dto.EmployeesApplyMQDto; import com.nu.entity.SysUserEntity; import com.nu.modules.employeesInfo.entity.BizEmployeesInfo; @@ -58,6 +60,11 @@ public class EmployeesApplyServiceImpl extends ServiceImpl listPage(Page page, QueryWrapper queryWrapper) { + return baseMapper.listPage(page, queryWrapper); + } + @Override public void cleanErrorInvided(String employeeId) { //删掉已保存的错误数据 @@ -201,12 +208,12 @@ public class EmployeesApplyServiceImpl extends ServiceImpl> getModifyHistoryInfo(EmployeesApply employeesApply) { + // 1. 查询变更后数据 + EmployeesApply modifyData = baseMapper.selectById(employeesApply.getId()); + + // 2. 查询当前使用中数据 + QueryWrapper usingQW = new QueryWrapper<>(); + usingQW.eq("employee_id", modifyData.getEmployeeId()); + usingQW.eq("status", "2"); + usingQW.lt("create_time", modifyData.getCreateTime()); + usingQW.last("limit 1"); + EmployeesApply usingData = baseMapper.selectOne(usingQW); + if(usingData == null || usingData.getId() == null){ + usingData = modifyData; + } + + // 3. 准备结果列表 + List> result = new ArrayList<>(); + + // 4. 获取 ConfigSuppliersInfo 所有字段(用于遍历) + Field[] infoFields = EmployeesApply.class.getDeclaredFields(); + + // 5. 遍历每个字段,从两个对象中分别取值比较 + for (Field usingField : infoFields) { + try { + String fieldName = usingField.getName(); + + // 跳过序列化ID 和 @TableField(exist = false) 的字段 + if ("serialVersionUID".equals(fieldName)) { + continue; + } + TableField tableField = usingField.getAnnotation(TableField.class); + if (tableField != null && !tableField.exist()) { + continue; + } + + // 设置可访问 + usingField.setAccessible(true); + + // 获取 ElderInfo 中对应的字段(必须同名) + Field modifyField = null; + try { + modifyField = EmployeesApply.class.getDeclaredField(fieldName); + modifyField.setAccessible(true); + } catch (NoSuchFieldException e) { + // 如果员工信息表中没有这个字段,跳过 + continue; + } + + // 获取两个对象中该字段的值 + Object modifyValue = modifyField.get(modifyData); + Object usingValue = usingField.get(usingData); + + // 处理日期类型 + if (usingField.getType() == Date.class) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + modifyValue = modifyValue != null ? sdf.format((Date) modifyValue) : null; + usingValue = usingValue != null ? sdf.format((Date) usingValue) : null; + } + +// if(StringUtils.equals(fieldName,"suppliersNature")){ +// usingValue = usingValue != null ? dictUtils.translateDictValue("suppliers_nature", usingValue.toString()) : null; +// modifyValue = modifyValue != null ? dictUtils.translateDictValue("suppliers_nature", modifyValue.toString()) : null; +// } + // 创建结果项 + Map fieldMap = new HashMap<>(); + fieldMap.put("id", IdUtil.simpleUUID()); + fieldMap.put("d1", fieldName); // 字段名 + fieldMap.put("d2", usingValue); // 原始值 + fieldMap.put("d3", modifyValue); // 修改值 + fieldMap.put("d4", Objects.equals(usingValue, modifyValue) ? "相同" : "不同"); // 比较结果 + + result.add(fieldMap); + + } catch (IllegalAccessException e) { + // 忽略访问失败或字段不存在的情况 + continue; + } + } + + return result; + } }