From 94928ed3a2e23bbc9604ff0c8bb967018a1e5ec8 Mon Sep 17 00:00:00 2001 From: zhangrui Date: Mon, 30 Mar 2026 18:27:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=9A=20=E4=BD=93=E6=A3=80=E7=AE=A1=E7=90=86->=E4=BD=93?= =?UTF-8?q?=E6=A3=80=E9=A1=B9=E7=9B=AE=EF=BC=9A=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E4=BD=93=E6=A3=80=E5=A5=97=E9=A4=90=E6=8C=89?= =?UTF-8?q?=E9=9C=80=E4=BF=9D=E5=AD=98=20=E6=96=B0=E5=A2=9E=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=20=E4=BD=93=E6=A3=80=E7=AE=A1=E7=90=86->?= =?UTF-8?q?=E4=BD=93=E6=A3=80=E5=90=8D=E5=8D=95=EF=BC=9A=201=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD=E5=B9=B6?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E6=9D=83=E9=99=90=EF=BC=88=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E3=80=81=E6=A0=A1=E5=B7=A5=E4=BC=9A?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E3=80=81=E6=A0=A1=E5=B7=A5=E4=BC=9A?= =?UTF-8?q?=E4=B8=BB=E5=B8=AD=E3=80=81=E5=88=86=E5=B7=A5=E4=BC=9A=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E3=80=81=E5=88=86=E5=B7=A5=E4=BC=9A=E4=B8=BB?= =?UTF-8?q?=E5=B8=AD=EF=BC=89=202=E3=80=81=E5=AF=BC=E5=85=A5=E5=90=8D?= =?UTF-8?q?=E5=8D=95=E6=8E=A7=E5=88=B6=E6=9D=83=E9=99=90=EF=BC=88=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=AE=A1=E7=90=86=E5=91=98=E3=80=81=E6=A0=A1=E5=B7=A5?= =?UTF-8?q?=E4=BC=9A=E7=AE=A1=E7=90=86=E5=91=98=E3=80=81=E6=A0=A1=E5=B7=A5?= =?UTF-8?q?=E4=BC=9A=E4=B8=BB=E5=B8=AD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthCheckupListController.java | 154 ++++++++++-------- .../HealthCheckupProjectSubjectMoney.java | 6 + .../impl/HealthCheckupProjectServiceImpl.java | 2 +- .../healthCheckup/listMange/index.html | 22 ++- .../healthCheckup/projectMange/index.html | 22 ++- 5 files changed, 133 insertions(+), 73 deletions(-) diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/controller/HealthCheckupListController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/controller/HealthCheckupListController.java index 86b9b611..4f20b88b 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/controller/HealthCheckupListController.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/controller/HealthCheckupListController.java @@ -18,6 +18,7 @@ import com.budwk.app.base.utils.easyexcel.EasyExcelUtil; import com.budwk.app.sys.views.View_user; import com.budwk.app.web.commons.auth.utils.AuthUtil; import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.web.commons.base.Globals; import com.budwk.app.zhgh.activity.basic.models.ActivityUserScope; import com.budwk.app.zhgh.dayofficework.healthCheckup.model.*; import com.budwk.app.zhgh.dayofficework.healthCheckup.service.HealthCheckupProjectService; @@ -91,6 +92,7 @@ public class HealthCheckupListController { Cnd cnd = Cnd.NEW(); Sql sql = Sqls.create(""" SELECT + hcu.id AS headId, hcu.userId AS id, hcu.loginName, hcu.userName, @@ -210,82 +212,88 @@ public class HealthCheckupListController { @At @ApiOperation("体检名单导入名单") @SLog(type = "healthCheckup", tag = "体检管理", msg = "管理员导入了体检名单") - @SaCheckPermission("healthCheckup.list.mange") + @SaCheckPermission("healthCheckup.list.import") @Aop(TransAop.READ_COMMITTED) @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) public Result healthImport(TempFile file, String healthProjectId) { - // 读取数据 - List ts = EasyExcelUtil.syncReadModel(file.getFile(), HealthCheckupImportTemp.class, 0, 1); - List healthCheckupImportTemps = JSONUtil.parseArray(JSONUtil.toJsonStr(ts)).toList(HealthCheckupImportTemp.class); - List loginNames = healthCheckupImportTemps.stream().filter(v -> Strings.isNotBlank(v.getLoginName())).map(v -> v.getLoginName()).collect(Collectors.toList()); - //全部的体检名单 - List healthCheckupUserList = dao.query(HealthCheckupUser.class, Cnd.where(HealthCheckupUser::getProjectId, "=", healthProjectId)); + if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), + RoleConstant.SCHOOL_UNION_ADMIN.name(), + RoleConstant.SCHOOL_UNION_CHAIRMAN.name())) { + return Result.error("您没有【导入名单】的权限"); + } else { + // 读取数据 + List ts = EasyExcelUtil.syncReadModel(file.getFile(), HealthCheckupImportTemp.class, 0, 1); + List healthCheckupImportTemps = JSONUtil.parseArray(JSONUtil.toJsonStr(ts)).toList(HealthCheckupImportTemp.class); + List loginNames = healthCheckupImportTemps.stream().filter(v -> Strings.isNotBlank(v.getLoginName())).map(v -> v.getLoginName()).collect(Collectors.toList()); + //全部的体检名单 + List healthCheckupUserList = dao.query(HealthCheckupUser.class, Cnd.where(HealthCheckupUser::getProjectId, "=", healthProjectId)); - List userList = dao.query(View_user.class, Cnd.where(View_user::getLoginname, "in", loginNames)); + List userList = dao.query(View_user.class, Cnd.where(View_user::getLoginname, "in", loginNames)); - HealthCheckupProject checkupProject = dao.fetch(HealthCheckupProject.class, healthProjectId); - ActivityUserScope userScope = dao.fetch(ActivityUserScope.class, Cnd.where("groupId", "=", checkupProject.getActivityGroupId())); - List userScopeList = new ArrayList<>(); - List healthCheckupUsersToAdd = new ArrayList<>(); - int successCount = 0; - for (int i = 0; i < healthCheckupImportTemps.size(); i++) { - HealthCheckupImportTemp excel = healthCheckupImportTemps.get(i); - if (StrUtil.isBlank(excel.getLoginName())) { - excel.setErrInfo("工号为空", i + 1); - continue; + HealthCheckupProject checkupProject = dao.fetch(HealthCheckupProject.class, healthProjectId); + ActivityUserScope userScope = dao.fetch(ActivityUserScope.class, Cnd.where("groupId", "=", checkupProject.getActivityGroupId())); + List userScopeList = new ArrayList<>(); + List healthCheckupUsersToAdd = new ArrayList<>(); + int successCount = 0; + for (int i = 0; i < healthCheckupImportTemps.size(); i++) { + HealthCheckupImportTemp excel = healthCheckupImportTemps.get(i); + if (StrUtil.isBlank(excel.getLoginName())) { + excel.setErrInfo("工号为空", i + 1); + continue; + } + + // 不能在excel里重复 + if (healthCheckupImportTemps.stream().filter(s -> s.getLoginName().equals(excel.getLoginName())).count() > 1) { + excel.setErrInfo("重复数据", i + 1); + } + + View_user user = userList.stream().filter(s -> s.getLoginname().equals(excel.getLoginName())).findFirst().orElse(null); + if (user == null) { + excel.setErrInfo("无此用户", i + 1); + continue; + } + + if (healthCheckupUserList.stream().anyMatch(s -> s.getUserId().equals(user.getId()))) { + excel.setErrInfo("该用户已加入体检名单", i + 1); + continue; + } + + ActivityUserScope s = new ActivityUserScope(); + s.setGroupId(userScope.getGroupId()); + s.setGroupName(userScope.getGroupName()); + s.setUserId(user.getId()); + s.setCreator(SecurityUtil.getUserId()); + userScopeList.add(s); + + HealthCheckupUser newHealthUser = new HealthCheckupUser(); + newHealthUser.setProjectId(healthProjectId); + newHealthUser.setUserId(user.getId()); + newHealthUser.setUserName(user.getUsername()); + newHealthUser.setSex(user.getSex()); + newHealthUser.setLoginName(user.getLoginname()); + newHealthUser.setUnionName(user.getUnionName()); + newHealthUser.setUnionId(user.getUnionId()); + newHealthUser.setUnitName(user.getUnitName()); + newHealthUser.setUnitId(user.getUnitId()); + healthCheckupUsersToAdd.add(newHealthUser); + + successCount++; } - // 不能在excel里重复 - if (healthCheckupImportTemps.stream().filter(s -> s.getLoginName().equals(excel.getLoginName())).count() > 1) { - excel.setErrInfo("重复数据", i + 1); - } - View_user user = userList.stream().filter(s -> s.getLoginname().equals(excel.getLoginName())).findFirst().orElse(null); - if (user == null) { - excel.setErrInfo("无此用户", i + 1); - continue; - } + dao.insert(userScopeList); + dao.insert(healthCheckupUsersToAdd); + // 创建结果集 + ExcelImportRes excelImportRes = new ExcelImportRes<>(); + excelImportRes.setTotalRecords(healthCheckupImportTemps.size()); + // 添加错误记录 + excelImportRes.setErrorDetails(healthCheckupImportTemps.stream().filter(s -> StrUtil.isNotBlank(s.getErrMsg())).collect(Collectors.toList())); + excelImportRes.setFailedCount(excelImportRes.getErrorDetails().size()); + excelImportRes.setSuccessCount(successCount); - if (healthCheckupUserList.stream().anyMatch(s -> s.getUserId().equals(user.getId()))) { - excel.setErrInfo("该用户已加入体检名单", i + 1); - continue; - } - - ActivityUserScope s = new ActivityUserScope(); - s.setGroupId(userScope.getGroupId()); - s.setGroupName(userScope.getGroupName()); - s.setUserId(user.getId()); - s.setCreator(SecurityUtil.getUserId()); - userScopeList.add(s); - - HealthCheckupUser newHealthUser = new HealthCheckupUser(); - newHealthUser.setProjectId(healthProjectId); - newHealthUser.setUserId(user.getId()); - newHealthUser.setUserName(user.getUsername()); - newHealthUser.setSex(user.getSex()); - newHealthUser.setLoginName(user.getLoginname()); - newHealthUser.setUnionName(user.getUnionName()); - newHealthUser.setUnionId(user.getUnionId()); - newHealthUser.setUnitName(user.getUnitName()); - newHealthUser.setUnitId(user.getUnitId()); - healthCheckupUsersToAdd.add(newHealthUser); - - successCount++; + return Result.success(excelImportRes); } - - - dao.insert(userScopeList); - dao.insert(healthCheckupUsersToAdd); - // 创建结果集 - ExcelImportRes excelImportRes = new ExcelImportRes<>(); - excelImportRes.setTotalRecords(healthCheckupImportTemps.size()); - // 添加错误记录 - excelImportRes.setErrorDetails(healthCheckupImportTemps.stream().filter(s -> StrUtil.isNotBlank(s.getErrMsg())).collect(Collectors.toList())); - excelImportRes.setFailedCount(excelImportRes.getErrorDetails().size()); - excelImportRes.setSuccessCount(successCount); - - return Result.success(excelImportRes); } @At @@ -301,4 +309,20 @@ public class HealthCheckupListController { CommonDownloadUtil.download("参加人员导入模版.xlsx", workbook, response); } + @At + @ApiOperation("体检名单删除") + @SaCheckPermission("healthCheckup.list.delete") + @Aop(TransAop.READ_COMMITTED) + public Result doDelete(String id) { + if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), + RoleConstant.SCHOOL_UNION_ADMIN.name(), + RoleConstant.SCHOOL_UNION_CHAIRMAN.name(), + RoleConstant.BRANCH_UNION_ADMIN.name(), + RoleConstant.BRANCH_UNION_CHAIRMAN.name())) { + return Result.error("您没有【删除】的权限"); + } else { + dao.clear(HealthCheckupUser.class, Cnd.where(HealthCheckupUser::getId, "=", id)); + return Result.success(); + } + } } diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/model/HealthCheckupProjectSubjectMoney.java b/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/model/HealthCheckupProjectSubjectMoney.java index 75654488..e3d4d5bd 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/model/HealthCheckupProjectSubjectMoney.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/model/HealthCheckupProjectSubjectMoney.java @@ -62,4 +62,10 @@ public class HealthCheckupProjectSubjectMoney extends BaseModel implements Seria @Comment("选项排序") @ColDefine(type = ColType.VARCHAR, width = 50) private String sort; + + @Column + @Comment("序号") + @ColDefine(type = ColType.INT) + private Integer serialNumber; + } diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/service/impl/HealthCheckupProjectServiceImpl.java b/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/service/impl/HealthCheckupProjectServiceImpl.java index dfc809a2..932f8972 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/service/impl/HealthCheckupProjectServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/healthCheckup/service/impl/HealthCheckupProjectServiceImpl.java @@ -47,7 +47,7 @@ public class HealthCheckupProjectServiceImpl extends BaseServiceImpl { - v.setSubjectMoneys(dao().query(HealthCheckupProjectSubjectMoney.class, Cnd.where("subjectId", "=", v.getId()))); + v.setSubjectMoneys(dao().query(HealthCheckupProjectSubjectMoney.class, Cnd.where("subjectId", "=", v.getId()).asc("serialNumber"))); }); return project; } diff --git a/src/main/resources/views/platform/zhgh/dayofficework/healthCheckup/listMange/index.html b/src/main/resources/views/platform/zhgh/dayofficework/healthCheckup/listMange/index.html index f373bcee..801ad0a5 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/healthCheckup/listMange/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/healthCheckup/listMange/index.html @@ -59,7 +59,8 @@ layout("/layouts/platform.html"){ - 导入名单 + 导入名单 确认名单 @@ -78,7 +79,7 @@ layout("/layouts/platform.html"){ + @@ -317,7 +323,15 @@ layout("/layouts/platform.html"){ this.importLoading = false this.doSearch() }, - + async doDelete(id) { + const resp = await this.$axios.post(loc() + '/doDelete', {id}); + if (resp.code === 0) { + this.notifySuccess(resp.msg); + this.doSearch(); + } else { + this.notifyError(resp.msg); + } + }, }, async created() { this.unions = await this.$businessTool.listUnion() diff --git a/src/main/resources/views/platform/zhgh/dayofficework/healthCheckup/projectMange/index.html b/src/main/resources/views/platform/zhgh/dayofficework/healthCheckup/projectMange/index.html index 9653a59b..17323987 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/healthCheckup/projectMange/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/healthCheckup/projectMange/index.html @@ -1,8 +1,6 @@ - -