This commit is contained in:
2026-04-02 10:41:40 +08:00
5 changed files with 139 additions and 72 deletions
@@ -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<T> ts = EasyExcelUtil.syncReadModel(file.getFile(), HealthCheckupImportTemp.class, 0, 1);
List<HealthCheckupImportTemp> healthCheckupImportTemps = JSONUtil.parseArray(JSONUtil.toJsonStr(ts)).toList(HealthCheckupImportTemp.class);
List<String> loginNames = healthCheckupImportTemps.stream().filter(v -> Strings.isNotBlank(v.getLoginName())).map(v -> v.getLoginName()).collect(Collectors.toList());
//全部的体检名单
List<HealthCheckupUser> 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<T> ts = EasyExcelUtil.syncReadModel(file.getFile(), HealthCheckupImportTemp.class, 0, 1);
List<HealthCheckupImportTemp> healthCheckupImportTemps = JSONUtil.parseArray(JSONUtil.toJsonStr(ts)).toList(HealthCheckupImportTemp.class);
List<String> loginNames = healthCheckupImportTemps.stream().filter(v -> Strings.isNotBlank(v.getLoginName())).map(v -> v.getLoginName()).collect(Collectors.toList());
//全部的体检名单
List<HealthCheckupUser> healthCheckupUserList = dao.query(HealthCheckupUser.class, Cnd.where(HealthCheckupUser::getProjectId, "=", healthProjectId));
List<View_user> userList = dao.query(View_user.class, Cnd.where(View_user::getLoginname, "in", loginNames));
List<View_user> 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<ActivityUserScope> userScopeList = new ArrayList<>();
List<HealthCheckupUser> 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<ActivityUserScope> userScopeList = new ArrayList<>();
List<HealthCheckupUser> 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<HealthCheckupImportTemp> 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<HealthCheckupImportTemp> 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();
}
}
}
@@ -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;
}
@@ -47,7 +47,7 @@ public class HealthCheckupProjectServiceImpl extends BaseServiceImpl<HealthCheck
}
HealthCheckupProject project = fetchLinks(fetch(id), "healthCheckupProjectSubjects", Cnd.NEW().asc("optionSort"));
project.getHealthCheckupProjectSubjects().forEach(v -> {
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;
}
@@ -59,7 +59,8 @@ layout("/layouts/platform.html"){
<el-card shadow="never" class="mt10">
<table-tool label="体检项目">
<el-button type="primary" size="small" @click="openImport">导入名单
<el-button type="primary" size="small" @click="openImport"
v-if="$auth.hasPermissionOr(['healthCheckup.list.import'])">导入名单
</el-button>
<el-button :disabled="!pageForm.projectId" type="primary" size="small"
@click="doAudit(true)">确认名单
@@ -106,13 +107,18 @@ layout("/layouts/platform.html"){
</template>
</el-table-column>
<el-table-column prop="userOnline" align="center" header-align="center"
label="操作"
label="操作" width="160px"
fixed="right">
<template slot-scope="{row}">
<el-button @click="openEditHealthCheckup(row)" size="mini"
:disabled="row.isAudit" type="primary">
编辑
</el-button>
<el-button @click="doDelete(row.headId)" size="mini"
v-if="$auth.hasPermissionOr(['healthCheckup.list.delete'])"
:disabled="row.isAudit" type="danger">
删除
</el-button>
</template>
</el-table-column>
</el-table>
@@ -317,7 +323,22 @@ layout("/layouts/platform.html"){
this.importLoading = false
this.doSearch()
},
doDelete(id) {
this.$confirm("您确定要删除吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "info"
}).then(async () => {
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()
@@ -1,8 +1,6 @@
<!--#
layout("/layouts/platform.html"){
#-->
<div id="app" class="platform" v-cloak>
<guava ref="guava" padding="0 5%">
<template>
@@ -196,6 +194,17 @@ layout("/layouts/platform.html"){
<div class="s-options-list" style="margin-top: 10px;">
<el-table :data="item.subjectMoneys" border size="small">
<el-table-column label="序号" width="100px">
<template slot-scope="{row}">
<el-input v-model="row.serialNumber"
:value="row.serialNumber"
autosize
class="text-input"
data-type="option"
readonly
></el-input>
</template>
</el-table-column>
<el-table-column label="名称">
<template slot-scope="{row}">
<el-input v-model="row.subjectMoneyName" autosize
@@ -225,6 +234,7 @@ layout("/layouts/platform.html"){
<template slot-scope="{row,$index}" slot="header">
<el-button size="mini" type="primary"
@click="item.subjectMoneys.push({
serialNumber: item.subjectMoneys.length + 1,
money:'',
settlementMoney:'',
subjectMoneyName:'',
@@ -593,7 +603,14 @@ layout("/layouts/platform.html"){
deleteRow(row, index, subjectMoneyIndex) {
this.formData.healthCheckupProjectSubjects[subjectMoneyIndex].subjectMoneys.splice(index, 1)
if (row.id) this.deleteRowIds.push(row.id)
this.reloadSubjectMoneySerialNumber(this.formData.healthCheckupProjectSubjects[subjectMoneyIndex].subjectMoneys);
},
reloadSubjectMoneySerialNumber(rowDetail){
//重新加载体检套餐序号
for (let i = 0; i < rowDetail.length; i++) {
rowDetail[i].serialNumber = i + 1;
}
},
async doDelete(id) {
const confirm = await this.$confirm('确定要删除该项目吗?', '提示', {type: 'warning'})
if (confirm) {
@@ -697,7 +714,6 @@ layout("/layouts/platform.html"){
})
</script>
<!--#
}
#-->