commit
This commit is contained in:
+125
@@ -0,0 +1,125 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupCampus;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupCampusController
|
||||
* @Description TODO 体检院区
|
||||
* @Author zzr
|
||||
* @Date 2023/7/20 09:50
|
||||
*/
|
||||
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@Slf4j
|
||||
@Api(tags = "体检院区")
|
||||
@At("/platform/healthCheckup/campus")
|
||||
public class HealthCheckupCampusController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/healthCheckup/campus/index.html")
|
||||
@SaCheckPermission("healthCheckup.campus")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("分页查询")
|
||||
@SaCheckPermission("healthCheckup.campus")
|
||||
public Result pageData(PageForm pageForm, @Param(value = "campusName") String campusName) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("select * from health_checkup_campus $condition");
|
||||
cnd.and(Cnd.likeEX("campusName", campusName));
|
||||
cnd.asc("campusCode");
|
||||
sql.setCondition(cnd);
|
||||
return Result.success(baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("添加院区")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "添加院区")
|
||||
@SaCheckPermission("healthCheckup.campus")
|
||||
public Result doAdd(HealthCheckupCampus campus) {
|
||||
try {
|
||||
int count = baseService.dao().count(HealthCheckupCampus.class, Cnd.where(HealthCheckupCampus::getCampusCode, "=", campus.getCampusCode()));
|
||||
if (count > 0) {
|
||||
return Result.error("编码重复");
|
||||
}
|
||||
baseService.dao().insert(campus);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("编辑院区")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "编辑院区")
|
||||
@SaCheckPermission("healthCheckup.campus")
|
||||
public Result doEdit(HealthCheckupCampus campus) {
|
||||
try {
|
||||
int count = baseService.dao().count(HealthCheckupCampus.class,
|
||||
Cnd.where(HealthCheckupCampus::getCampusCode, "=", campus.getCampusCode())
|
||||
.and(HealthCheckupCampus::getId, "!=", campus.getId()));
|
||||
if (count > 0) {
|
||||
return Result.error("编码重复");
|
||||
}
|
||||
baseService.dao().update(campus);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("编辑院区")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "删除院区")
|
||||
@SaCheckPermission("healthCheckup.campus")
|
||||
public Result doDelete(String id) {
|
||||
try {
|
||||
baseService.dao().clear(HealthCheckupCampus.class, Cnd.where(HealthCheckupCampus::getId, "=", id));
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("查询所有院区")
|
||||
@SaCheckPermission("healthCheckup.campus")
|
||||
public Result queryCampus() {
|
||||
try {
|
||||
List<HealthCheckupCampus> campusList = baseService.dao().query(HealthCheckupCampus.class, Cnd.NEW().asc("campusCode"));
|
||||
return Result.success(campusList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.model.ExcelImportRes;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||
import com.budwk.app.base.utils.EasyExcelUtil;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
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.zhgh.activity.basic.models.ActivityUserScope;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.*;
|
||||
import com.budwk.app.zhgh.healthCheckup.service.HealthCheckupProjectService;
|
||||
import com.budwk.app.zhgh.healthCheckup.template.HealthCheckupImportTemp;
|
||||
import com.budwk.app.zhgh.integral.controller.IntegralManageController;
|
||||
import com.budwk.app.zhgh.welfare.mode.WelfareUserImportExcel;
|
||||
import com.budwk.app.zhgh.welfare.model.WelfareList;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupListController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/7/18 8:43
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@Slf4j
|
||||
@Api(tags = "体检名单")
|
||||
@At("/platform/healthCheckup/list/mange")
|
||||
public class HealthCheckupListController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Inject
|
||||
private HealthCheckupProjectService healthCheckupProjectService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/healthCheckup/listMange/index.html")
|
||||
@SaCheckPermission("healthCheckup.list.mange")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("分页查询")
|
||||
@SaCheckPermission("healthCheckup.list.mange")
|
||||
public Result pageData(PageForm pageForm,
|
||||
String projectId,
|
||||
String unionId,
|
||||
String unitId) {
|
||||
List<HealthCheckupUnionConfirm> confirms = dao.query(HealthCheckupUnionConfirm.class, Cnd.where("projectId", "=", projectId));
|
||||
|
||||
HealthCheckupProject project = healthCheckupProjectService.findOne(projectId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
hcu.userId AS id,
|
||||
hcu.loginName,
|
||||
hcu.userName,
|
||||
hcu.sex,
|
||||
hcu.unionId,
|
||||
hcu.unionName,
|
||||
hcu.unitName,
|
||||
hcus.selectTime,
|
||||
hcus.campus,
|
||||
hcus.subjectId,
|
||||
ca.campusName
|
||||
FROM
|
||||
health_checkup_user hcu
|
||||
LEFT JOIN health_checkup_user_selection hcus ON hcu.userId = hcus.selectUserId
|
||||
AND hcus.projectId=@projectId
|
||||
LEFT JOIN health_checkup_campus ca on ca.id=hcus.campus
|
||||
$condition
|
||||
""").setParam("projectId", projectId);
|
||||
sql.setCondition(cnd);
|
||||
cnd.andEX("hcu.projectId", "=", projectId);
|
||||
cnd.andEX("hcu.unionId", "=", unionId);
|
||||
cnd.andEX("hcu.unitId", "=", unitId);
|
||||
|
||||
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
|
||||
cnd.andEX("hcu.unionId", "=", SecurityUtil.getUnionId());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchName()) && StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
|
||||
}
|
||||
cnd.groupBy("hcu.userId");
|
||||
if (StrUtil.isNotBlank(pageForm.getPageOrderName()) && Strings.isNotBlank(pageForm.getPageOrderBy())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), "ascending".equalsIgnoreCase(pageForm.getPageOrderBy()) ? "ASC" : "DESC");
|
||||
} else {
|
||||
cnd.desc("hcus.selectTime").asc("hcu.unitId");
|
||||
}
|
||||
Pagination pagination = healthCheckupProjectService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
List<NutMap> paginationList = pagination.getList();
|
||||
|
||||
paginationList.forEach(v -> {
|
||||
if (StrUtil.isNotBlank(v.getString("subjectId"))) {
|
||||
List<HealthCheckupProjectSubject> subjects = project.getHealthCheckupProjectSubjects();
|
||||
HealthCheckupProjectSubject subject = subjects.stream().filter(s -> s.getId().equals(v.getString("subjectId"))).findFirst().orElse(null);
|
||||
v.setv("optionName", subject.getOptionName());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(v.getString("unionId"))) {
|
||||
HealthCheckupUnionConfirm confirm = confirms.stream().filter(o -> o.getUnionId().equals(v.getString("unionId"))).findFirst().orElse(null);
|
||||
v.setv("isAudit", confirm != null ? confirm.getIsAudit() : "");
|
||||
v.setv("auditTime", confirm != null ? confirm.getAuditTime() : "");
|
||||
}
|
||||
});
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("体检名单确认")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "体检名单确认")
|
||||
@SaCheckPermission("healthCheckup.list.mange")
|
||||
public Result doAuditUser(String projectId,
|
||||
String unionId,
|
||||
Boolean flag) {
|
||||
if (flag) {
|
||||
dao.update(HealthCheckupUnionConfirm.class, Chain.make("isAudit", true)
|
||||
.add("auditTime", DateUtil.date())
|
||||
.add("auditUser", SecurityUtil.getUserId()),
|
||||
Cnd.where("projectId", "=", projectId).and("unionId", "=", unionId));
|
||||
} else {
|
||||
dao.update(HealthCheckupUnionConfirm.class, Chain.make("isAudit", null)
|
||||
.add("auditTime", null)
|
||||
.add("auditUser", null),
|
||||
Cnd.where("projectId", "=", projectId).and("unionId", "=", unionId));
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("体检名单管理员编辑选择记录")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "管理员编辑了一条选择记录")
|
||||
@SaCheckPermission("healthCheckup.list.mange")
|
||||
public Result doEditHealthCheckupData(String subjectId, String campus, String projectId, String userId) {
|
||||
|
||||
//查询用户有没有选择过套餐
|
||||
HealthCheckupUserSelection userSelection = healthCheckupProjectService.dao().fetch(HealthCheckupUserSelection.class,
|
||||
Cnd.where("projectId", "=", projectId).and("selectUserId", "=", userId));
|
||||
//如果选择过套餐就修改选择的套餐id
|
||||
if (Lang.isNotEmpty(userSelection)) {
|
||||
userSelection.setSubjectId(subjectId);
|
||||
userSelection.setCampus(campus);
|
||||
healthCheckupProjectService.update(userSelection);
|
||||
} else {
|
||||
//如果没有选择过套餐添加一条记录
|
||||
HealthCheckupUserSelection checkupUserSelection = new HealthCheckupUserSelection();
|
||||
checkupUserSelection.setSelectUserId(userId);
|
||||
checkupUserSelection.setProjectId(projectId);
|
||||
checkupUserSelection.setSubjectId(subjectId);
|
||||
checkupUserSelection.setCampus(campus);
|
||||
checkupUserSelection.setSelectTime(new Date());
|
||||
healthCheckupProjectService.insert(checkupUserSelection);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("体检名单导入名单")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "管理员导入了体检名单")
|
||||
@SaCheckPermission("healthCheckup.list.mange")
|
||||
@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));
|
||||
|
||||
|
||||
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<>();
|
||||
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);
|
||||
}
|
||||
;
|
||||
|
||||
dao.insert(userScopeList);
|
||||
// 创建结果集
|
||||
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());
|
||||
|
||||
return Result.success(excelImportRes);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("下载体检参加人员导入模版")
|
||||
@SaCheckPermission("healthCheckup.list.mange")
|
||||
public void downloadTem(HttpServletResponse response) {
|
||||
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();) {
|
||||
|
||||
EasyExcel.write(byteArrayOutputStream, HealthCheckupImportTemp.class)
|
||||
.sheet("参加人员导入模版")
|
||||
.doWrite(ArrayList::new);
|
||||
CommonDownloadUtil.download("参加人员导入模版.xlsx", byteArrayOutputStream.toByteArray(), response);
|
||||
} catch (Exception e) {
|
||||
log.error("下载参加人员导入模版失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.sys.models.Sys_union;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.*;
|
||||
import com.budwk.app.zhgh.healthCheckup.service.HealthCheckupProjectService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupProjectMangeController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/7/17 10:58
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@Api(tags = "体检项目")
|
||||
@At("/platform/healthCheckup/project/mange")
|
||||
public class HealthCheckupProjectMangeController {
|
||||
|
||||
@Inject
|
||||
private HealthCheckupProjectService healthCheckupProjectService;
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/healthCheckup/projectMange/index.html")
|
||||
@SaCheckPermission("healthCheckup.projectMange")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("分页查询")
|
||||
@SaCheckPermission("healthCheckup.projectMange")
|
||||
public Result pageData(PageForm pageForm,
|
||||
Integer year,
|
||||
String name) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
hcp.id,
|
||||
hcp.`year`,
|
||||
hcp.`name`,
|
||||
hcp.choiceTimeStart,
|
||||
hcp.choiceTimeEnd,
|
||||
hcp.activityGroupId,
|
||||
hcp.cover,
|
||||
hcp.activityGroupName,
|
||||
hcp.healthCheckupType,
|
||||
IF((select count(userId) from health_checkup_user hcu where hcu.projectId = hcp.id) > 0,true,false) AS isHasUserList,
|
||||
IF(NOW() > hcp.choiceTimeStart AND NOW() < hcp.choiceTimeEnd, true, false) AS isWithinChoiceTime,
|
||||
IF(NOW() < hcp.choiceTimeStart, true, false) AS canCreated
|
||||
FROM
|
||||
health_checkup_project hcp
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("hcp.`year`", "=", year);
|
||||
cnd.andEX("hcp.`name`", "=", name);
|
||||
cnd.desc("hcp.choiceTimeStart");
|
||||
sql.setCondition(cnd);
|
||||
return Result.success(healthCheckupProjectService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("体检名单确认")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("healthCheckup.projectMange")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "提交体检项目")
|
||||
public Result doAdd(HealthCheckupProject healthCheckupProject, @Param(value = "deleteRowIds") String[] deleteRowIds) {
|
||||
|
||||
|
||||
String projectId;
|
||||
//如果是保存
|
||||
if (StrUtil.isBlank(healthCheckupProject.getId())) {
|
||||
healthCheckupProject.setYear(DateUtil.thisYear());
|
||||
HealthCheckupProject checkupProject = healthCheckupProjectService.insertWith(healthCheckupProject, "healthCheckupProjectSubjects");
|
||||
projectId = checkupProject.getId();
|
||||
} else {
|
||||
projectId = healthCheckupProject.getId();
|
||||
healthCheckupProjectService.dao().clear(HealthCheckupProjectSubject.class, Cnd.where("id", "in", deleteRowIds));
|
||||
healthCheckupProject.getHealthCheckupProjectSubjects().forEach(v -> {
|
||||
v.setProjectId(healthCheckupProject.getId());
|
||||
});
|
||||
healthCheckupProjectService.dao().insertOrUpdate(healthCheckupProject.getHealthCheckupProjectSubjects());
|
||||
healthCheckupProjectService.update(healthCheckupProject);
|
||||
}
|
||||
|
||||
healthCheckupProjectService.dao().clear(HealthCheckupUnionConfirm.class, Cnd.where("projectId", "=", projectId));
|
||||
List<Sys_union> unionList = healthCheckupProjectService.dao().query(Sys_union.class, Cnd.NEW());
|
||||
List<HealthCheckupUnionConfirm> confirmList = new ArrayList<>();
|
||||
unionList.forEach(item -> {
|
||||
HealthCheckupUnionConfirm c = new HealthCheckupUnionConfirm();
|
||||
c.setProjectId(projectId);
|
||||
c.setUnionId(item.getId());
|
||||
c.setIsAudit(false);
|
||||
confirmList.add(c);
|
||||
});
|
||||
healthCheckupProjectService.dao().insert(confirmList);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("查询体检项目内容")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "查询体检项目内容")
|
||||
public Result findOne(String id) {
|
||||
return Result.success(healthCheckupProjectService.findOne(id));
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("删除体检项目")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("healthCheckup.projectMange")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "删除了一条体检项目")
|
||||
public Result doDelete(String id) {
|
||||
healthCheckupProjectService.delete(id);
|
||||
healthCheckupProjectService.dao().clear(HealthCheckupProjectSubject.class, Cnd.where("projectId", "=", id));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("按年份获取体检项目")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "查询了所有的体检项目")
|
||||
public Result getHealthCheckupProject(Integer year) {
|
||||
List<HealthCheckupProject> projectList = healthCheckupProjectService.query(Cnd.NEW().andEX("year", "=", year).desc("choiceTimeStart"));
|
||||
return Result.success(projectList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建体检名单
|
||||
*
|
||||
* @param healthCheckupProject
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ApiOperation("创建体检名单")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("healthCheckup.projectMange")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "创建体检名单")
|
||||
public Result createUserList(HealthCheckupProject healthCheckupProject) {
|
||||
healthCheckupProjectService.addHealthCheckupUser(healthCheckupProject);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新名单
|
||||
*
|
||||
* @param healthCheckupProject
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ApiOperation("更新体检名单")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("healthCheckup.projectMange")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "更新体检名单")
|
||||
public Result renewUserList(HealthCheckupProject healthCheckupProject) {
|
||||
healthCheckupProjectService.renewHealthCheckupUser(healthCheckupProject);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重置名单
|
||||
*
|
||||
* @param healthCheckupProject
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ApiOperation("重置体检名单")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("healthCheckup.projectMange")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "重置体检名单")
|
||||
public Result resetUserList(HealthCheckupProject healthCheckupProject) {
|
||||
//重置名单,清空已选择的用户记录
|
||||
Sql sql = Sqls.create("select id,selectUserId from health_checkup_user_selection where projectId = @projectId").setParam("projectId", healthCheckupProject.getId());
|
||||
List<NutMap> list = (List<NutMap>) Daos.query(healthCheckupProjectService.dao(), sql.toString(), Sqls.callback.maps());
|
||||
List<String> userSelectionIds = list.stream().map(v -> v.getString("id")).collect(Collectors.toList());
|
||||
List<String> userIds = list.stream().map(v -> v.getString("selectUserId")).collect(Collectors.toList());
|
||||
|
||||
healthCheckupProjectService.dao().clear(HealthCheckupUserSelection.class, Cnd.where("selectUserId", "in", userIds));
|
||||
healthCheckupProjectService.dao().clear(HealthCheckupUserCompanion.class, Cnd.where("userSelectionId", "in", userSelectionIds));
|
||||
healthCheckupProjectService.dao().clear(HealthCheckupUser.class, Cnd.where("projectId", "=", healthCheckupProject.getId()));
|
||||
healthCheckupProjectService.addHealthCheckupUser(healthCheckupProject);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
+278
@@ -0,0 +1,278 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||
import com.budwk.app.base.utils.ManyAddOrRenewUtil;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupProject;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupProjectSubject;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupUserSelection;
|
||||
import com.budwk.app.zhgh.healthCheckup.service.HealthCheckupSingleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupSingleController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/7/18 13:53
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@Api(tags = "体检数据统计")
|
||||
@At("/platform/healthCheckup/statistics/single")
|
||||
public class HealthCheckupSingleController {
|
||||
|
||||
|
||||
@Inject
|
||||
private HealthCheckupSingleService healthCheckupSingleService;
|
||||
@Inject
|
||||
private ManyAddOrRenewUtil manyAddOrRenewUtil;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhgh/healthCheckup/statisticsSingle/index.html")
|
||||
@SaCheckPermission("healthCheckup.statisticsSingle")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("首页查询")
|
||||
@SaCheckPermission("healthCheckup.statisticsSingle")
|
||||
public Result pageData(String projectId,
|
||||
String unionId) {
|
||||
NutMap nutMap = healthCheckupSingleService.pageData(projectId, unionId);
|
||||
return Result.success(nutMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 每个分工会领取人员/未领取人员
|
||||
*
|
||||
* @param page
|
||||
* @param isSelected 是否领取
|
||||
* @param projectId
|
||||
* @param unionId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ApiOperation("每个分工会领取人员/未领取人员")
|
||||
@SaCheckPermission("healthCheckup.statisticsSingle")
|
||||
public Result receivePageData(PageForm page, String isSelected,
|
||||
String projectId,
|
||||
String unionId) {
|
||||
List<NutMap> labelList = healthCheckupSingleService.receivePageDataColumns(projectId);
|
||||
Pagination list = healthCheckupSingleService.receivePageData(page.getPageNumber(), page.getPageSize(), page.getSearchName(), page.getSearchKeyword(), projectId, unionId, isSelected);
|
||||
return Result.success(NutMap.NEW().addv("list", list).addv("label", labelList));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出已选/未选人员名单
|
||||
*
|
||||
* @param projectId
|
||||
* @param unionId
|
||||
* @param year
|
||||
* @param flag
|
||||
* @param response
|
||||
*/
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("导出已选/未选人员名单")
|
||||
@SaCheckPermission("healthCheckup.statisticsSingle")
|
||||
public void exportReceiveDetail(String projectId,
|
||||
String unionId,
|
||||
Integer year,
|
||||
boolean flag, HttpServletResponse response) {
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>() {{
|
||||
add(new ExcelExportEntity("职工号", "loginName", 20));
|
||||
add(new ExcelExportEntity("姓名", "userName", 20));
|
||||
add(new ExcelExportEntity("性别", "sex", 20));
|
||||
add(new ExcelExportEntity("出生年月", "birthday", 20));
|
||||
add(new ExcelExportEntity("年龄", "age", 20));
|
||||
add(new ExcelExportEntity("婚姻状况", "marriage", 20));
|
||||
add(new ExcelExportEntity("证件号", "idCard", 20));
|
||||
add(new ExcelExportEntity("部门", "unitName", 20));
|
||||
add(new ExcelExportEntity("部门编码", "unitCode", 20));
|
||||
add(new ExcelExportEntity("自选项目", "subjectName", 20));
|
||||
add(new ExcelExportEntity("自选院区", "campusName", 50));
|
||||
}};
|
||||
|
||||
List<NutMap> list;
|
||||
if (flag) {
|
||||
//已选人员
|
||||
list = healthCheckupSingleService.receivePageData(projectId, unionId, "0");
|
||||
} else {
|
||||
//未选人员
|
||||
list = healthCheckupSingleService.receivePageData(projectId, unionId, "1");
|
||||
}
|
||||
//获取当前年
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int thisYear = calendar.get(Calendar.YEAR);
|
||||
list.forEach(v -> {
|
||||
int substring = 0;
|
||||
if (Strings.isNotBlank(v.getString("birthday"))) {
|
||||
substring = Integer.parseInt(v.getString("birthday").substring(0, 4));
|
||||
} else if (Strings.isNotBlank(v.getString("idCard")) && v.getString("idCard").length() >= 10) {
|
||||
substring = Integer.parseInt(v.getString("idCard").substring(6, 10));
|
||||
}
|
||||
v.put("age", thisYear - substring);
|
||||
});
|
||||
|
||||
List<NutMap> list2 = list.stream().filter(v -> Strings.isNotBlank(v.getString("unionName"))).collect(Collectors.toList());
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setSheetName(year + "年教职工体检项目及地点统计表");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list2);
|
||||
CommonDownloadUtil.download((flag ? year + "年教职工体检项目及地点统计表" : "未选名单") + ".xlsx", workbook, response);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@ApiOperation("导出教职工家属体检登记表")
|
||||
@SaCheckPermission("healthCheckup.statisticsSingle")
|
||||
public void exportUserCompanion(String projectId,
|
||||
String unionId,
|
||||
Integer year, HttpServletResponse response) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.username,
|
||||
u.unitname unitName,
|
||||
u.mobile,
|
||||
hcuc.userName familyName,
|
||||
hcuc.sex,
|
||||
hcuc.marry isMarried,
|
||||
hcuc.idCard,
|
||||
hcc.campusName,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( hcps.optionName )
|
||||
FROM
|
||||
health_checkup_user_selection hcus
|
||||
LEFT JOIN `health_checkup_project_subject` hcps ON hcps.id = hcus.subjectId
|
||||
WHERE
|
||||
hcus.projectId = @projectId
|
||||
AND hcus.selectUserId = u.id
|
||||
) optionName
|
||||
FROM
|
||||
`health_checkup_user_companion` hcuc
|
||||
LEFT JOIN `health_checkup_user_selection` hcus ON hcus.id = hcuc.userSelectionId
|
||||
LEFT JOIN `health_checkup_campus` hcc ON hcc.id = hcus.campus
|
||||
LEFT JOIN `vw_user` u ON u.id = hcus.selectUserId
|
||||
LEFT JOIN `health_checkup_project` hcp ON hcp.id = hcus.projectId
|
||||
$condition
|
||||
""").setParam("projectId", projectId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("hcus.projectId", "=", projectId);
|
||||
cnd.andEX("u.unionid", "=", unionId);
|
||||
cnd.andEX("hcp.year", "=", year);
|
||||
cnd.asc("u.unioncode");
|
||||
sql.setCondition(cnd);
|
||||
//家属信息表
|
||||
List<NutMap> companionList = healthCheckupSingleService.listMap(sql);
|
||||
|
||||
for (int i = 0; i < companionList.size(); i++) {
|
||||
companionList.get(i).put("index", i + 1);
|
||||
}
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>() {{
|
||||
add(new ExcelExportEntity("序号", "index", 20));
|
||||
add(new ExcelExportEntity("教职工姓名", "username", 20));
|
||||
add(new ExcelExportEntity("学院(部门)", "unitName", 20));
|
||||
add(new ExcelExportEntity("手机", "mobile", 20));
|
||||
add(new ExcelExportEntity("体检人姓名", "familyName", 20));
|
||||
add(new ExcelExportEntity("性别", "sex", 20));
|
||||
add(new ExcelExportEntity("婚否", "isMarried", 20));
|
||||
add(new ExcelExportEntity("体检人身份证号", "idCard", 50));
|
||||
add(new ExcelExportEntity("自选项目", "optionName", 50));
|
||||
add(new ExcelExportEntity("自选院区", "campusName", 50));
|
||||
}};
|
||||
|
||||
try {
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setTitle(year + "教职工家属体检登记表");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, companionList);
|
||||
CommonDownloadUtil.download(year + "教职工家属体检登记表.xlsx", workbook, response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("管理员一键代选")
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("healthCheckup.statisticsSingle")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "管理员一键代选")
|
||||
public Result doSelectByAdmin(String projectId, String optionId, String campus) {
|
||||
Dao dao = healthCheckupSingleService.dao();
|
||||
HealthCheckupProject project = dao.fetch(HealthCheckupProject.class, projectId);
|
||||
HealthCheckupProjectSubject subject = dao.fetch(HealthCheckupProjectSubject.class, optionId);
|
||||
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
u.loginname loginName,
|
||||
u.username userName,
|
||||
u.sex,
|
||||
u.birthday,
|
||||
u.unitname unitName,
|
||||
u.unionname unionName,
|
||||
u.idcard idCard,
|
||||
u.mobile
|
||||
FROM
|
||||
`activity_user_scope` aus
|
||||
LEFT JOIN `vw_user` u ON u.id = aus.userId
|
||||
$projectCnd $condition
|
||||
""");
|
||||
|
||||
cnd.and("aus.groupId", "=", project.getActivityGroupId());
|
||||
sql.setVar("projectCnd", "AND u.id NOT IN ( SELECT selectUserId FROM `health_checkup_user_selection` WHERE projectId = '" + projectId + "' AND selectUserId IS NOT NULL )");
|
||||
cnd.groupBy("u.loginname");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> mapList = healthCheckupSingleService.listMap(sql);
|
||||
|
||||
List<String> userIds = mapList.stream().map(v -> v.getString("id")).collect(Collectors.toList());
|
||||
//题目id
|
||||
List<HealthCheckupUserSelection> selections = userIds.stream().map(v -> {
|
||||
HealthCheckupUserSelection selection = new HealthCheckupUserSelection();
|
||||
selection.setProjectId(projectId);
|
||||
selection.setSelectUserId(v);
|
||||
selection.setCampus(campus);
|
||||
selection.setSubjectId(optionId);
|
||||
return selection;
|
||||
}).collect(Collectors.toList());
|
||||
manyAddOrRenewUtil.asyncExecuteFastInsert(selections,null);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupCampus
|
||||
* @Description TODO 体检院区
|
||||
* @Author zzr
|
||||
* @Date 2023/7/20 09:50
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("health_checkup_campus")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("体检院区表")
|
||||
public class HealthCheckupCampus extends BaseModel implements Serializable {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("院区编码")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String campusCode;
|
||||
|
||||
@Column
|
||||
@Comment("院区名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String campusName;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupProject
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/7/17 10:40
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("health_checkup_project")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("体检项目表")
|
||||
public class HealthCheckupProject extends BaseModel implements Serializable {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("年度")
|
||||
@ColDefine(type = ColType.INT, width = 4)
|
||||
private Integer year;
|
||||
|
||||
@Column
|
||||
@Comment("项目名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("体检对象类型")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String healthCheckupType;
|
||||
|
||||
@Column
|
||||
@Comment("选择开始时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date choiceTimeStart;
|
||||
|
||||
@Column
|
||||
@Comment("选择结束时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date choiceTimeEnd;
|
||||
|
||||
@Column
|
||||
@Comment("发送对象")
|
||||
@ColDefine(type = ColType.INT, width = 32)
|
||||
private Integer activityGroupId;
|
||||
|
||||
@Column
|
||||
@Comment("发送对象名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String activityGroupName;
|
||||
|
||||
|
||||
@Column
|
||||
@Comment("封面")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 200)
|
||||
private String cover;
|
||||
|
||||
|
||||
@Many(field = "projectId")
|
||||
private List<HealthCheckupProjectSubject> healthCheckupProjectSubjects;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupProjectSubject
|
||||
* @Description 体检套餐
|
||||
* @Author zhf
|
||||
* @Date 2023/7/17 10:51
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("health_checkup_project_subject")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("体检套餐表")
|
||||
public class HealthCheckupProjectSubject extends BaseModel implements Serializable {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("所属项目")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String projectId;
|
||||
|
||||
@Column
|
||||
@Comment("选项名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String optionName;
|
||||
|
||||
@Column
|
||||
@Comment("选项排序")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String optionSort;
|
||||
|
||||
@Column
|
||||
@Comment("图片地址")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String imgUrl;
|
||||
|
||||
@Column
|
||||
@Comment("说明描述")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.model;
|
||||
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("health_checkup_union_confirm")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("分工会体检确认表")
|
||||
public class HealthCheckupUnionConfirm extends BaseModel implements Serializable {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("所属项目")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String projectId;
|
||||
|
||||
@Column
|
||||
@Comment("工会id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unionId;
|
||||
|
||||
@Column
|
||||
@Comment("是否确认")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isAudit;
|
||||
|
||||
@Column
|
||||
@Comment("确认时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date auditTime;
|
||||
|
||||
@Column
|
||||
@Comment("操作人")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String auditUser;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:HealthCheckupUser
|
||||
* @Date 2024/7/24 15:42
|
||||
* @注释 体检用户
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("health_checkup_user")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("体检名单表")
|
||||
public class HealthCheckupUser extends BaseModel implements Serializable {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("所属项目")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String projectId;
|
||||
|
||||
@Column
|
||||
@Comment("用户id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@Comment("用户姓名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String userName;
|
||||
|
||||
@Column
|
||||
@Comment("性别")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String sex;
|
||||
|
||||
@Column
|
||||
@Comment("工号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String loginName;
|
||||
|
||||
@Column
|
||||
@Comment("所属工会")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String unionName;
|
||||
|
||||
@Column
|
||||
@Comment("工会Id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String unionId;
|
||||
|
||||
@Column
|
||||
@Comment("所属单位")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String unitName;
|
||||
|
||||
@Column
|
||||
@Comment("单位Id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String unitId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupUserCompanion
|
||||
* @Description TODO 体检家属表
|
||||
* @Author zzr
|
||||
* @Date 2023/7/20 10:40
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("health_checkup_user_companion")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("体检家属表")
|
||||
public class HealthCheckupUserCompanion extends BaseModel implements Serializable {
|
||||
|
||||
@Name
|
||||
@Comment("id")
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("体检选择表Id")
|
||||
private String userSelectionId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("姓名")
|
||||
private String userName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.CHAR, width = 1)
|
||||
@Comment("性别")
|
||||
private String sex;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("年龄")
|
||||
private Integer age;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
@Comment("婚否")
|
||||
private String marry;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 18)
|
||||
@Comment("身份证号")
|
||||
private String idCard;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 18)
|
||||
@Comment("手机号")
|
||||
private String mobile;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupUserSelection
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/7/18 9:20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("health_checkup_user_selection")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("体检教职工选择表")
|
||||
public class HealthCheckupUserSelection extends BaseModel implements Serializable {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("所属项目")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String projectId;
|
||||
|
||||
@Column
|
||||
@Comment("所属选项")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String subjectId;
|
||||
|
||||
@Column
|
||||
@Comment("选择用户")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String selectUserId;
|
||||
|
||||
@Column
|
||||
@Comment("选择院区")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String campus;
|
||||
|
||||
@Column
|
||||
@Comment("选择时间")
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private Date selectTime;
|
||||
|
||||
@Many(field = "userSelectionId")
|
||||
private List<HealthCheckupUserCompanion> companionList;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupProject;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
public interface HealthCheckupProjectService extends BaseService<HealthCheckupProject> {
|
||||
|
||||
|
||||
HealthCheckupProject findOne(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 添加体检用户
|
||||
* @param healthCheckupProject
|
||||
*/
|
||||
void addHealthCheckupUser(HealthCheckupProject healthCheckupProject);
|
||||
|
||||
/**
|
||||
* 更新体检用户
|
||||
* @param healthCheckupProject
|
||||
*/
|
||||
void renewHealthCheckupUser(HealthCheckupProject healthCheckupProject);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.service;
|
||||
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupProject;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HealthCheckupSingleService extends BaseService<HealthCheckupProject> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param projectId 福利id
|
||||
* @return
|
||||
*/
|
||||
NutMap pageData(String projectId,String unionId);
|
||||
|
||||
|
||||
/**
|
||||
* 导出发放详细表
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> receivePageDataColumns(String projectId);
|
||||
|
||||
|
||||
/**
|
||||
* 领取详情分页
|
||||
*
|
||||
* @param projectId 体检id
|
||||
* @return
|
||||
*/
|
||||
Pagination receivePageData(Integer pageNumber, Integer pageSize, String searchName, String searchKeyword, String projectId, String unionId, String isSelected);
|
||||
|
||||
|
||||
/**
|
||||
* 领取详情不分页
|
||||
*
|
||||
* @param projectId 体检id
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> receivePageData(String projectId, String unionId,String isSelected);
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.base.utils.ManyAddOrRenewUtil;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.zhgh.activity.basic.models.ActivityUserScope;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupProject;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupUser;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupUserCompanion;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupUserSelection;
|
||||
import com.budwk.app.zhgh.healthCheckup.service.HealthCheckupProjectService;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Mirror;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupProjectServiceImpl
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2023/7/17 14:48
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class HealthCheckupProjectServiceImpl extends BaseServiceImpl<HealthCheckupProject> implements HealthCheckupProjectService {
|
||||
|
||||
|
||||
@Inject
|
||||
private ManyAddOrRenewUtil manyAddOrRenewUtil;
|
||||
|
||||
public HealthCheckupProjectServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HealthCheckupProject findOne(String id) {
|
||||
HealthCheckupProject project = fetchLinks(fetch(id), "healthCheckupProjectSubjects", Cnd.NEW().asc("optionSort"));
|
||||
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addHealthCheckupUser(HealthCheckupProject healthCheckupProject) {
|
||||
List<HealthCheckupUser> needAddUsers = getHealthCheckupUserListByProject(healthCheckupProject);
|
||||
manyAddOrRenewUtil.asyncExecuteFastInsert(needAddUsers, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void renewHealthCheckupUser(HealthCheckupProject healthCheckupProject) {
|
||||
//全部组别人员
|
||||
List<HealthCheckupUser> allGroupUsers = getHealthCheckupUserListByProject(healthCheckupProject);
|
||||
//已选取人员,选择表的人员
|
||||
List<HealthCheckupUser> userList = dao().query(HealthCheckupUser.class, Cnd.where("projectId", "=", healthCheckupProject.getId()));
|
||||
// 找出在 userList 中但不在allGroupUsers中的userId,这部分人要删除体检信息
|
||||
List<String> needDeleteUserIds = userList.stream()
|
||||
.map(HealthCheckupUser::getUserId)
|
||||
.filter(selectUserId -> allGroupUsers.stream()
|
||||
.noneMatch(user -> user.getUserId().equals(selectUserId)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//获取生成名单中没有的用户,这部分要添加
|
||||
Sql sql = Sqls.create("select userId from health_checkup_user where projectId = @projectId").setParam("projectId", healthCheckupProject.getId());
|
||||
List<NutMap> sourceSelectionUserMaps = (List<NutMap>) Daos.query(dao(), sql.toString(), Sqls.callback.maps());
|
||||
Set<String> sourceSelectionUserIds = sourceSelectionUserMaps.stream().map(v -> v.getString("userId")).collect(Collectors.toSet());
|
||||
//找出原来名单中没有的人,没有的就可以新增
|
||||
List<HealthCheckupUser> canInsertSelectionUsers = allGroupUsers.stream().filter(v -> !sourceSelectionUserIds.contains(v.getId())).collect(Collectors.toList());
|
||||
|
||||
//过滤出原有名单中没有的,可以新增
|
||||
List<HealthCheckupUser> needInsertSelectionUsers = canInsertSelectionUsers.parallelStream()
|
||||
.filter(v -> !sourceSelectionUserIds.contains(v.getUserId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> userSelectionIds = userList.stream().filter(needDeleteUserIds::contains).map(HealthCheckupUser::getId).collect(Collectors.toList());
|
||||
dao().clear(HealthCheckupUser.class, Cnd.where("userId", "in", needDeleteUserIds));
|
||||
dao().clear(HealthCheckupUserSelection.class, Cnd.where("selectUserId", "in", needDeleteUserIds));
|
||||
dao().clear(HealthCheckupUserCompanion.class, Cnd.where("userSelectionId", "in", userSelectionIds));
|
||||
|
||||
manyAddOrRenewUtil.asyncExecuteFastInsert(needInsertSelectionUsers, null);
|
||||
}
|
||||
|
||||
|
||||
public List<HealthCheckupUser> getHealthCheckupUserListByProject(HealthCheckupProject healthCheckupProject) {
|
||||
String projectId = healthCheckupProject.getId();
|
||||
List<ActivityUserScope> groupUsers = dao().query(ActivityUserScope.class, Cnd.where("groupId", "=", healthCheckupProject.getActivityGroupId()));
|
||||
List<String> userIds = groupUsers.stream().map(ActivityUserScope::getUserId).collect(Collectors.toList());
|
||||
List<View_user> userMapList = dao().query(View_user.class, Cnd.where("id", "in", userIds));
|
||||
return userMapList.stream().map(v -> {
|
||||
HealthCheckupUser user = new HealthCheckupUser();
|
||||
user.setId(R.UU32());
|
||||
user.setProjectId(projectId);
|
||||
user.setUserId(v.getId());
|
||||
user.setLoginName(v.getLoginname());
|
||||
user.setUserName(v.getUsername());
|
||||
user.setSex(v.getSex());
|
||||
user.setUnitId(v.getUnitId());
|
||||
user.setUnitName(v.getUnitName());
|
||||
user.setUnionId(v.getUnionId());
|
||||
user.setUnionName(v.getUnionName());
|
||||
return user;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.service.impl;
|
||||
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupProject;
|
||||
import com.budwk.app.zhgh.healthCheckup.model.HealthCheckupProjectSubject;
|
||||
import com.budwk.app.zhgh.healthCheckup.service.HealthCheckupProjectService;
|
||||
import com.budwk.app.zhgh.healthCheckup.service.HealthCheckupSingleService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class HealthCheckupSingleServiceImpl extends BaseServiceImpl<HealthCheckupProject> implements HealthCheckupSingleService {
|
||||
public HealthCheckupSingleServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private HealthCheckupProjectService healthCheckupProjectService;
|
||||
|
||||
@Override
|
||||
public NutMap pageData(String projectId, String unionId) {
|
||||
HealthCheckupProject project = healthCheckupProjectService.findOne(projectId);
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
su.id,
|
||||
su.name unionName,
|
||||
(SELECT count( 1 ) FROM `health_checkup_user` hcu WHERE hcu.projectId=@projectId and hcu.unionId = su.id ) sumCount
|
||||
FROM
|
||||
sys_union su
|
||||
$condition
|
||||
""").setParam("projectId", projectId);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("su.id", "=", unionId);
|
||||
cnd.asc("su.unionCode");
|
||||
sql.setCondition(cnd);
|
||||
//分工会参加体检人数汇总
|
||||
List<NutMap> healthCheckupList = listMap(sql);
|
||||
//该体检项目下的套餐
|
||||
List<HealthCheckupProjectSubject> subjectList = project.getHealthCheckupProjectSubjects();
|
||||
|
||||
//体检人员详情
|
||||
List<NutMap> userSelectList = this.getUserSelectionByProjectId(projectId);
|
||||
|
||||
for (NutMap healthCheckup : healthCheckupList) {
|
||||
List<NutMap> thisUnionSelectList = userSelectList.stream().filter(x ->
|
||||
x.getString("unionId").equals(healthCheckup.getString("id")) &&
|
||||
x.getString("projectId").equals(projectId)).collect(Collectors.toList());
|
||||
|
||||
subjectList.forEach(o -> {
|
||||
//每一项选择的人数
|
||||
Cnd optionCountCnd = Cnd.NEW();
|
||||
Sql optionCountSql = Sqls.create("""
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
`health_checkup_user_selection` hs
|
||||
LEFT JOIN health_checkup_user hcu ON hcu.userId = hs.selectUserId
|
||||
AND hcu.projectId = @projectId
|
||||
$condition
|
||||
""").setParam("projectId", projectId);
|
||||
optionCountCnd.andEX("hcu.unionId", "=", healthCheckup.getString("id"));
|
||||
optionCountCnd.andEX("hs.projectId", "=", projectId);
|
||||
optionCountCnd.andEX("hs.subjectId", "=", o.getId());
|
||||
optionCountSql.setCondition(optionCountCnd);
|
||||
int count = count(optionCountSql);
|
||||
healthCheckup.put(o.getOptionName(), count);
|
||||
});
|
||||
//已选人数
|
||||
healthCheckup.put("totalCount", thisUnionSelectList.stream().map(v -> v.getString("selectUserId")).distinct().count());
|
||||
//未选人数
|
||||
healthCheckup.put("unselectedTeacherSum", healthCheckup.getInt("sumCount") - healthCheckup.getInt("totalCount"));
|
||||
}
|
||||
//表格列数据
|
||||
List<NutMap> labelList = new ArrayList<>();
|
||||
labelList.add(NutMap.NEW().addv("label", "本次体检人数").addv("prop", "sumCount"));
|
||||
subjectList.forEach(v -> {
|
||||
labelList.add(NutMap.NEW().addv("label", v.getOptionName()).addv("prop", v.getOptionName()));
|
||||
});
|
||||
labelList.add(NutMap.NEW().addv("label", "参加人数").addv("prop", "totalCount"));
|
||||
labelList.add(NutMap.NEW().addv("label", "未选人数").addv("prop", "unselectedTeacherSum"));
|
||||
|
||||
return NutMap.NEW().addv("tableList", healthCheckupList).addv("tableColumn", labelList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 体检参加人员
|
||||
*
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
public List<NutMap> getUserSelectionByProjectId(String projectId) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("hcu.unionId", "is not", null);
|
||||
cnd.andEX("hu.projectId", "=", projectId);
|
||||
cnd.asc("hu.selectUserId");
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
hu.subjectId,
|
||||
hu.selectTime,
|
||||
hu.projectId,
|
||||
hu.selectUserId,
|
||||
hcu.unionId
|
||||
FROM
|
||||
`health_checkup_user_selection` hu
|
||||
LEFT JOIN `health_checkup_user` hcu ON hcu.userId = hu.selectUserId and hcu.projectId=@projectId
|
||||
$condition
|
||||
""").setParam("projectId", projectId);
|
||||
sql.setCondition(cnd);
|
||||
return listMap(sql);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<NutMap> receivePageDataColumns(String projectId) {
|
||||
List<NutMap> labelList = new ArrayList<>();
|
||||
labelList.add(NutMap.NEW().addv("label", "工号").addv("prop", "loginName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "姓名").addv("prop", "userName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "联系电话").addv("prop", "mobile"));
|
||||
labelList.add(NutMap.NEW().addv("label", "身份证").addv("prop", "idCard").addv("width", 20));
|
||||
labelList.add(NutMap.NEW().addv("label", "人员类型").addv("prop", "personType"));
|
||||
labelList.add(NutMap.NEW().addv("label", "工会").addv("prop", "unionName"));
|
||||
labelList.add(NutMap.NEW().addv("label", "单位").addv("prop", "unitName"));
|
||||
return labelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pagination receivePageData(Integer pageNumber, Integer pageSize, String searchName,
|
||||
String searchKeyword, String projectId, String unionId, String isSelected) {
|
||||
Sql sql = null;
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(isSelected)) {
|
||||
//查看已选择体检
|
||||
if ("0".equals(isSelected)) {
|
||||
sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname AS loginName,
|
||||
u.username AS userName,
|
||||
u.sex,
|
||||
u.birthday,
|
||||
u.personType,
|
||||
u.unitname AS unitName,
|
||||
u.unionname AS unionName,
|
||||
u.idcard AS idCard,
|
||||
u.mobile
|
||||
FROM
|
||||
`health_checkup_user_selection` hcus
|
||||
LEFT JOIN `vw_user` u ON u.id = hcus.selectUserId
|
||||
LEFT JOIN `health_checkup_project_subject` hcps ON hcps.id = hcus.subjectId
|
||||
$condition
|
||||
""").setParam("projectId", projectId);
|
||||
cnd.and("hcus.projectId", "=", projectId);
|
||||
cnd.andEX("u.unionId", "=", unionId);
|
||||
cnd.desc("hcus.subjectId");
|
||||
} else if ("1".equals(isSelected)) {//查看未选择体检
|
||||
sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
hcu.loginName,
|
||||
hcu.userName,
|
||||
hcu.sex,
|
||||
u.birthday,
|
||||
u.personType,
|
||||
hcu.unitName,
|
||||
hcu.unionName,
|
||||
u.idcard idCard,
|
||||
u.mobile
|
||||
FROM
|
||||
`health_checkup_user` hcu
|
||||
LEFT JOIN `vw_user` u ON u.id = hcu.userId
|
||||
$condition
|
||||
""");
|
||||
cnd.and(new Static("u.id NOT IN ( SELECT selectUserId FROM `health_checkup_user_selection` WHERE projectId = '" + projectId + "' AND selectUserId IS NOT NULL )"));
|
||||
cnd.andEX("hcu.unionId", "=", unionId);
|
||||
cnd.andEX("hcu.projectId", "=", projectId);
|
||||
}
|
||||
}
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
cnd.and(searchName, "like", "%" + searchKeyword + "%");
|
||||
}
|
||||
|
||||
|
||||
cnd.asc("u.unionCode");
|
||||
cnd.groupBy("u.loginname");
|
||||
sql.setCondition(cnd);
|
||||
return listPageMap(pageNumber, pageSize, sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> receivePageData(String projectId, String unionId, String isSelected) {
|
||||
Sql sql = null;
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(isSelected)) {
|
||||
//查看已选择体检
|
||||
if ("0".equals(isSelected)) {
|
||||
sql = Sqls.create("""
|
||||
SELECT
|
||||
u.loginname AS loginName,
|
||||
u.username AS userName,
|
||||
u.sex,
|
||||
u.birthday,
|
||||
u.personType,
|
||||
u.unitName,
|
||||
u.unitCode,
|
||||
u.marriage,
|
||||
u.unionName,
|
||||
u.idCard,
|
||||
u.mobile,
|
||||
hcps.optionName subjectName,
|
||||
hcc.campusName,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( hcps.optionName )
|
||||
FROM
|
||||
health_checkup_user_selection hcus
|
||||
LEFT JOIN `health_checkup_project_subject` hcps ON hcps.id = hcus.subjectId
|
||||
WHERE
|
||||
hcus.projectId = @projectId
|
||||
AND hcus.selectUserId = u.id
|
||||
) optionName
|
||||
FROM
|
||||
`health_checkup_user_selection` hcus
|
||||
LEFT JOIN `vw_user` u ON u.id = hcus.selectUserId
|
||||
LEFT JOIN `health_checkup_user` hcu ON hcu.userId = hcus.selectUserId and hcu.projectId=@projectId
|
||||
LEFT JOIN `health_checkup_project_subject` hcps ON hcps.id = hcus.subjectId
|
||||
LEFT JOIN `health_checkup_campus` hcc ON hcc.id = hcus.campus
|
||||
$condition
|
||||
""").setParam("projectId", projectId);
|
||||
cnd.and("hcus.projectId", "=", projectId);
|
||||
cnd.desc("hcus.subjectId");
|
||||
} else if ("1".equals(isSelected)) {//查看未选择体检
|
||||
sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
hcu.loginName,
|
||||
hcu.userName,
|
||||
hcu.sex,
|
||||
u.birthday,
|
||||
u.marriage,
|
||||
u.personType,
|
||||
hcu.unitName,
|
||||
hcu.unionName,
|
||||
u.idcard idCard,
|
||||
u.mobile
|
||||
FROM
|
||||
`health_checkup_user` hcu
|
||||
LEFT JOIN `vw_user` u ON u.id = hcu.userId
|
||||
$condition
|
||||
""");
|
||||
sql.setVar("projectCnd", projectId);
|
||||
cnd.and(new Static("u.id NOT IN ( SELECT selectUserId FROM `health_checkup_user_selection` WHERE projectId = '" + projectId + "' AND selectUserId IS NOT NULL )"));
|
||||
}
|
||||
|
||||
}
|
||||
cnd.andEX("hcu.projectId", "=", projectId);
|
||||
cnd.andEX("hcu.unionId", "=", unionId);
|
||||
cnd.asc("u.unionCode");
|
||||
cnd.groupBy("u.loginname");
|
||||
sql.setCondition(cnd);
|
||||
return listMap(sql);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.budwk.app.zhgh.healthCheckup.template;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import com.budwk.app.base.model.ExcelImportError;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@ContentRowHeight(20) // 内容行高
|
||||
@HeadRowHeight(20) // 表头行高
|
||||
@ColumnWidth(25)
|
||||
public class HealthCheckupImportTemp extends ExcelImportError {
|
||||
|
||||
@ExcelProperty("工号" )
|
||||
private String loginName;
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
private String userName;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user