功能修改:
体检管理->体检项目:详情页控制体检套餐按需保存 新增功能: 体检管理->体检名单: 1、添加删除功能并控制权限(系统管理员、校工会管理员、校工会主席、分工会管理员、分工会主席) 2、导入名单控制权限(系统管理员、校工会管理员、校工会主席)
This commit is contained in:
+89
-65
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user