This commit is contained in:
Paidax
2024-07-25 11:09:11 +08:00
parent 020b6c48ed
commit 1eca5ba3b8
10 changed files with 563 additions and 109 deletions
@@ -0,0 +1,80 @@
package io.v.nutz.base.utils;
import io.v.nutz.sys.models.Sys_user;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
/**
* @version 1.0
* @Author zzr
* @name:ManyAddOrRenewUtil
* @Date 2024/7/24 16:16
* @注释
*/
@IocBean
public class ManyAddOrRenewUtil {
@Inject
private Dao dao;
/**
* 批量新增或更新
* @param list
* @param mode true新增;false更新
* @param <T>
* @return
*/
public <T> void addOrRenew(List<T> list, boolean mode) {
try {
executeInBatches(list, mode);
} catch (Exception e) {
// 在实际应用中,应该有更精细的异常处理策略
e.printStackTrace();
}
}
private <T> void executeInBatches(List<T> list, boolean mode) throws InterruptedException, ExecutionException {
int numberOfThreads = Runtime.getRuntime().availableProcessors() * 2;
ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
ExecutorCompletionService<Void> ecs = new ExecutorCompletionService<>(executorService);
int batchSize = 100;
// 在调用ecs.submit的地方添加futures列表
List<Future<Void>> futures = new ArrayList<>();
for (int i = 0; i < list.size(); i += batchSize) {
final int end = Math.min(i + batchSize, list.size());
List<T> batch = list.subList(i, end);
Future<Void> future = ecs.submit(() -> processBatch(batch, mode));
futures.add(future);
}
completeAllTasks(ecs, futures);
// 关闭线程池
executorService.shutdown();
}
private <T> Void processBatch(List<T> batch, boolean mode) {
// 执行数据库更新操作
if (mode) {
dao.fastInsert(batch);
} else {
dao.update(batch);
}
return null;
}
private void completeAllTasks(ExecutorCompletionService<Void> ecs, List<Future<Void>> futures) throws InterruptedException, ExecutionException {
for (Future<Void> future : futures) {
// 等待任务完成
future.get();
}
}
}
@@ -61,46 +61,42 @@ public class HealthCheckupListController {
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
u.id, hcu.userId AS id,
u.loginname, hcu.loginname,
u.username, hcu.username,
u.sex, hcu.sex,
u.unionname, hcu.unionname,
u.unitname, hcu.unitname,
u.threeUnitName, hcu.threeUnitName,
u.unionGroupName, hcu.unionGroupName,
hcus.selectTime, hcus.selectTime,
hcus.subjectId, hcus.subjectId,
hcus.campus, hcus.campus,
hcus.userSign, hcus.userSign
aus.id ausid
FROM FROM
activity_user_scope aus health_checkup_user hcu
LEFT JOIN `user` u ON u.id = aus.userId LEFT JOIN health_checkup_user_selection hcus ON hcu.userId = hcus.selectUserId
LEFT JOIN health_checkup_user_selection hcus ON aus.userId = hcus.selectUserId
AND hcus.projectId=@projectId AND hcus.projectId=@projectId
$condition $condition
""").setParam("projectId", projectId); """).setParam("projectId", projectId);
sql.setCondition(cnd); sql.setCondition(cnd);
cnd.andEX("aus.groupId", "=", project.getActivityGroupId()); cnd.andEX("hcu.unionId", "=", unionId);
cnd.andEX("u.unionid", "=", unionId); cnd.andEX("hcu.unitId", "=", unitId);
cnd.andEX("u.unitId", "=", unitId); cnd.andEX("hcu.unionGroupId", "=", unionGroupId);
cnd.andEX("u.unionGroupId", "=", unionGroupId); cnd.andEX("hcu.threeUnitId", "=", threeUnitId);
cnd.andEX("u.threeUnitId", "=", threeUnitId);
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) { if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
cnd.andEX("u.unionid", "=", Vi.getUnionId()); cnd.andEX("hcu.unionId", "=", Vi.getUnionId());
} }
if (StrUtil.isNotBlank(pageForm.getSearchName()) && StrUtil.isNotBlank(pageForm.getSearchKeyword())) { if (StrUtil.isNotBlank(pageForm.getSearchName()) && StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword())); cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
} }
if (Vi.isNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) { if (Vi.isNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC"); cnd.orderBy(pageForm.getPageOrderName(), "ascending".equalsIgnoreCase(pageForm.getPageOrderBy()) ? "ASC" : "DESC");
} else { } else {
cnd.desc("hcus.selectTime").desc("u.unitcode").desc("u.unioncode"); cnd.desc("hcus.selectTime").asc("hcu.unitId");
} }
Pagination pagination = healthCheckupProjectService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); Pagination pagination = healthCheckupProjectService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
List<NutMap> paginationList = pagination.getList(); List<NutMap> paginationList = pagination.getList();
@@ -111,7 +107,6 @@ public class HealthCheckupListController {
HealthCheckupProjectSubject subject = subjects.stream().filter(s -> s.getId().equals(v.getString("subjectId"))).findFirst().orElse(null); HealthCheckupProjectSubject subject = subjects.stream().filter(s -> s.getId().equals(v.getString("subjectId"))).findFirst().orElse(null);
v.setv("optionName", subject.getOptionName()); v.setv("optionName", subject.getOptionName());
} }
}); });
return pagination; return pagination;
} }
@@ -5,21 +5,27 @@ import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.zhgh.data.model.MatchConditionStructure; import io.v.nutz.zhgh.data.model.MatchConditionStructure;
import io.v.nutz.zhgh.data.service.MatchConditionStructureService; import io.v.nutz.zhgh.data.service.MatchConditionStructureService;
import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProject; import io.v.nutz.zhgh.healthCheckup.model.*;
import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProjectSubject;
import io.v.nutz.zhgh.healthCheckup.service.HealthCheckupProjectService; import io.v.nutz.zhgh.healthCheckup.service.HealthCheckupProjectService;
import io.v.nutz.base.query.PageForm; import io.v.nutz.base.query.PageForm;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop; import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd; 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.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang; import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param; import org.nutz.mvc.annotation.Param;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* @ClassName HealthCheckupProjectMangeController * @ClassName HealthCheckupProjectMangeController
* @Description TODO * @Description TODO
@@ -78,15 +84,35 @@ public class HealthCheckupProjectMangeController {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("welfare.project.mange") @RequiresPermissions("healthCheckup.projectMange")
public Object pageData(PageForm pageForm, public Object pageData(PageForm pageForm,
@Param(value = "year", required = false) Integer year, @Param(value = "year", required = false) Integer year,
@Param(value = "name", required = false) String name) { @Param(value = "name", required = false) String name) {
Sql sql = Sqls.create("""
SELECT
hcp.id,
hcp.`year`,
hcp.`name`,
hcp.choiceTimeStart,
hcp.choiceTimeEnd,
hcp.activityGroupId,
hcp.cover,
hcp.activityGroupName,
hcp.provideTimeStart,
hcp.provideTimeEnd,
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
FROM
health_checkup_project hcp
$condition
""");
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.andEX("year", "=", year); cnd.andEX("hcp.`year`", "=", year);
cnd.andEX("name", "=", name); cnd.andEX("hcp.`name`", "=", name);
cnd.desc("choiceTimeStart"); cnd.desc("hcp.choiceTimeStart");
return healthCheckupProjectService.list(pageForm, cnd); sql.setCondition(cnd);
return healthCheckupProjectService.listPageMap(pageForm.getPageNumber(),pageForm.getPageSize(),sql);
} }
@At @At
@@ -98,7 +124,7 @@ public class HealthCheckupProjectMangeController {
@At @At
@ViReturn @ViReturn
@Aop(TransAop.READ_COMMITTED) @Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("welfare.project.mange") @RequiresPermissions("healthCheckup.projectMange")
public Object doDelete(String id) { public Object doDelete(String id) {
healthCheckupProjectService.delete(id); healthCheckupProjectService.delete(id);
healthCheckupProjectService.dao().clear(HealthCheckupProjectSubject.class, Cnd.where("projectId", "=", id)); healthCheckupProjectService.dao().clear(HealthCheckupProjectSubject.class, Cnd.where("projectId", "=", id));
@@ -112,4 +138,56 @@ public class HealthCheckupProjectMangeController {
} }
/**
* 创建体检名单
* @param healthCheckupProject
* @return
*/
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("healthCheckup.projectMange")
public Object createUserList(HealthCheckupProject healthCheckupProject){
healthCheckupProjectService.addHealthCheckupUser(healthCheckupProject);
return null;
}
/**
* 更新名单
* @param healthCheckupProject
* @return
*/
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("healthCheckup.projectMange")
public Object renewUserList(HealthCheckupProject healthCheckupProject){
healthCheckupProjectService.renewHealthCheckupUser(healthCheckupProject);
return null;
}
/**
* 重置名单
* @param healthCheckupProject
* @return
*/
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("healthCheckup.projectMange")
public Object 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 null;
}
} }
@@ -0,0 +1,93 @@
package io.v.nutz.zhgh.healthCheckup.model;
import io.v.nutz.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
/**
* @version 1.0
* @Author zzr
* @name:HealthCheckupUser
* @Date 2024/7/24 15:42
* @注释 体检用户
*/
@Data
@Table
@Comment("体检用户中间表")
@EqualsAndHashCode(callSuper = true)
public class HealthCheckupUser extends BaseModel {
@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 = 50)
private String unionName;
@Column
@Comment("工会Id")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unionId;
@Column
@Comment("所属单位")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unitName;
@Column
@Comment("单位Id")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unitId;
@Column
@Comment("三级单位Id")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String threeUnitId;
@Column
@Comment("三级单位名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String threeUnitName;
@Column
@Comment("工会小组Id")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unionGroupId;
@Column
@Comment("工会小组名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unionGroupName;
}
@@ -11,4 +11,15 @@ public interface HealthCheckupProjectService extends ViService<HealthCheckupProj
NutMap validCondition(String cndId); NutMap validCondition(String cndId);
/**
* 添加体检用户
* @param healthCheckupProject
*/
void addHealthCheckupUser(HealthCheckupProject healthCheckupProject);
/**
* 更新体检用户
* @param healthCheckupProject
*/
void renewHealthCheckupUser(HealthCheckupProject healthCheckupProject);
} }
@@ -2,29 +2,42 @@ package io.v.nutz.zhgh.healthCheckup.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import io.v.nutz.base.service.impl.ViServiceImpl; import io.v.nutz.base.service.impl.ViServiceImpl;
import io.v.nutz.base.utils.ManyAddOrRenewUtil;
import io.v.nutz.zhgh.activity.models.ActivityUserScope;
import io.v.nutz.zhgh.data.constant.ConditionalOperational; import io.v.nutz.zhgh.data.constant.ConditionalOperational;
import io.v.nutz.zhgh.data.constant.MatchMethod; import io.v.nutz.zhgh.data.constant.MatchMethod;
import io.v.nutz.zhgh.data.model.MatchCondition; import io.v.nutz.zhgh.data.model.MatchCondition;
import io.v.nutz.zhgh.data.model.MatchConditionStructure; import io.v.nutz.zhgh.data.model.MatchConditionStructure;
import io.v.nutz.zhgh.data.service.MatchConditionStructureService; import io.v.nutz.zhgh.data.service.MatchConditionStructureService;
import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProject; import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProject;
import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupUser;
import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupUserCompanion;
import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupUserSelection;
import io.v.nutz.zhgh.healthCheckup.service.HealthCheckupProjectService; import io.v.nutz.zhgh.healthCheckup.service.HealthCheckupProjectService;
import io.v.nutz.sys.models.Sys_user; import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.annotation.Comment; 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.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang; import org.nutz.lang.Lang;
import org.nutz.lang.Mirror; import org.nutz.lang.Mirror;
import org.nutz.lang.Strings; import org.nutz.lang.Strings;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap; import org.nutz.lang.util.NutMap;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* @ClassName HealthCheckupProjectServiceImpl * @ClassName HealthCheckupProjectServiceImpl
@@ -38,6 +51,9 @@ public class HealthCheckupProjectServiceImpl extends ViServiceImpl<HealthCheckup
@Inject @Inject
private MatchConditionStructureService matchConditionStructureService; private MatchConditionStructureService matchConditionStructureService;
@Inject
private ManyAddOrRenewUtil manyAddOrRenewUtil;
public HealthCheckupProjectServiceImpl(Dao dao) { public HealthCheckupProjectServiceImpl(Dao dao) {
super(dao); super(dao);
} }
@@ -104,4 +120,77 @@ public class HealthCheckupProjectServiceImpl extends ViServiceImpl<HealthCheckup
return resultMap; return resultMap;
} }
@Override
public void addHealthCheckupUser(HealthCheckupProject healthCheckupProject) {
List<HealthCheckupUser> needAddUsers = getHealthCheckupUserListByProject(healthCheckupProject);
manyAddOrRenewUtil.addOrRenew(needAddUsers, true);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void renewHealthCheckupUser(HealthCheckupProject healthCheckupProject) {
//全部组别人员
List<HealthCheckupUser> allGroupUsers = getHealthCheckupUserListByProject(healthCheckupProject);
//已选取人员
List<HealthCheckupUserSelection> selectionList = dao().query(HealthCheckupUserSelection.class, Cnd.where("projectId", "=", healthCheckupProject.getId()));
// Set<String> selectUserIds = selectionList.stream().map(HealthCheckupUserSelection::getSelectUserId).collect(Collectors.toSet());
//已选取人员不在组别里面的人
// 找出在selectionList中但不在allGroupUsers中的userId,这部分人要删除体检信息
List<String> needDeleteUserIds = selectionList.stream()
.map(HealthCheckupUserSelection::getSelectUserId)
.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> sourceUserMaps = (List<NutMap>) Daos.query(dao(), sql.toString(), Sqls.callback.maps());
Set<String> sourceUserIds = sourceUserMaps.stream().map(v -> v.getString("userId")).collect(Collectors.toSet());
//找出原来名单中没有的人,没有的就可以新增
List<HealthCheckupUser> canInsertUsers = allGroupUsers.stream().filter(v -> !sourceUserIds.contains(v.getId())).collect(Collectors.toList());
//过滤出原有名单中没有的,可以新增
List<HealthCheckupUser> needInsertUsers = canInsertUsers.parallelStream()
.filter(v -> !sourceUserIds.contains(v.getUserId()))
.collect(Collectors.toList());
// List<HealthCheckupUser> needInsertUsers = canInsertUsers.stream().filter(v -> !healthUserIdList.contains(v.getUserId())).collect(Collectors.toList());
List<String> userSelectionIds = selectionList.stream().map(HealthCheckupUserSelection::getId).collect(Collectors.toList());
dao().clear(HealthCheckupUser.class, Cnd.where("userId", "in", needInsertUsers));
dao().clear(HealthCheckupUserSelection.class, Cnd.where("selectUserId", "in", needInsertUsers));
dao().clear(HealthCheckupUserCompanion.class, Cnd.where("userSelectionId", "in", userSelectionIds));
manyAddOrRenewUtil.addOrRenew(needInsertUsers, true);
}
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());
Sql sql = Sqls.create("select id,loginname,username,sex,unitid,unitname,unionid,unionname,threeUnitId,threeUnitName,unionGroupId,unionGroupName from `user` where id in (@userIds)").setParam("userIds", userIds);
List<NutMap> userMapList = (List<NutMap>) Daos.query(dao(), sql.toString(), Sqls.callback.maps());
return userMapList.stream().map(v -> {
HealthCheckupUser user = new HealthCheckupUser();
user.setId(R.UU32());
user.setProjectId(projectId);
user.setUserId(v.getString("id"));
user.setLoginName(v.getString("loginname"));
user.setUserName(v.getString("username"));
user.setSex(v.getString("sex"));
user.setUnitId(v.getString("unitid"));
user.setUnitName(v.getString("unitname"));
user.setUnionId(v.getString("unionid"));
user.setUnionName(v.getString("unionname"));
user.setThreeUnitId(v.getString("threeUnitId"));
user.setThreeUnitName(v.getString("threeUnitName"));
user.setUnionGroupId(v.getString("unionGroupId"));
user.setUnionGroupName(v.getString("unionGroupName"));
return user;
}).collect(Collectors.toList());
}
} }
@@ -36,16 +36,7 @@ public class HealthCheckupSingleServiceImpl extends ViServiceImpl<HealthCheckupP
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
su.*, su.*,
( (SELECT count( 1 ) FROM `health_checkup_user` hcu WHERE hcu.unionId = su.id $unionGroupIdCnd ) sumCount
SELECT
count( 1 )
FROM
`activity_user_scope` aus
LEFT JOIN `user` u ON u.id = aus.userId
WHERE
u.unionid = su.id
AND aus.groupId = @groupId $unionGroupIdCnd
) sumCount
FROM FROM
sys_union su sys_union su
$condition $condition
@@ -54,7 +45,6 @@ public class HealthCheckupSingleServiceImpl extends ViServiceImpl<HealthCheckupP
cnd.andEX("su.id","=",unionId); cnd.andEX("su.id","=",unionId);
cnd.asc("su.unioncode"); cnd.asc("su.unioncode");
sql.setCondition(cnd); sql.setCondition(cnd);
sql.setParam("groupId", project.getActivityGroupId());
if (StrUtil.isNotBlank(unionGroupId)) { if (StrUtil.isNotBlank(unionGroupId)) {
sql.setVar("unionGroupIdCnd", "and u.unionGroupId = '%s'".formatted(unionGroupId)); sql.setVar("unionGroupIdCnd", "and u.unionGroupId = '%s'".formatted(unionGroupId));
} }
@@ -64,13 +64,15 @@ public class MHealthCheckupListController {
(select count(*) from health_checkup_user_selection s where s.projectId=p.id and s.selectUserId=@userId) as selectCount (select count(*) from health_checkup_user_selection s where s.projectId=p.id and s.selectUserId=@userId) as selectCount
from from
health_checkup_project p health_checkup_project p
LEFT JOIN health_checkup_user hcu on hcu.projectId = p.id
$condition $condition
""").setParam("userId", ShiroUtil.getPlatformUid()); """).setParam("userId", ShiroUtil.getUserId());
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
if (tabName.equals("ing")) { cnd.and("hcu.userId", "=", ShiroUtil.getUserId());
cnd.and(Cnd.exps("choiceTimeStart", "<", DateUtil.now()).and("choiceTimeEnd", ">", DateUtil.now())); if ("ing".equals(tabName)) {
} else if (tabName.equals("end")) { cnd.and(Cnd.exps("p.choiceTimeStart", "<", DateUtil.now()).and("p.choiceTimeEnd", ">", DateUtil.now()));
cnd.and("choiceTimeEnd", "<", DateUtil.now()); } else if ("end".equals(tabName)) {
cnd.and("p.choiceTimeEnd", "<", DateUtil.now());
} }
cnd.asc("selectCount"); cnd.asc("selectCount");
sql.setCondition(cnd); sql.setCondition(cnd);
@@ -109,7 +111,7 @@ public class MHealthCheckupListController {
@ViReturn @ViReturn
public Object doSubmit(@Param("userSelection") HealthCheckupUserSelection userSelection) { public Object doSubmit(@Param("userSelection") HealthCheckupUserSelection userSelection) {
Trans.exec(() -> { Trans.exec(() -> {
if(userSelection.getId() == null) { if (userSelection.getId() == null) {
userSelection.setSelectUserId(ShiroUtil.getPlatformUid()); userSelection.setSelectUserId(ShiroUtil.getPlatformUid());
userSelection.setSelectTime(new Date()); userSelection.setSelectTime(new Date());
baseService.dao().insertWith(userSelection, "companionList"); baseService.dao().insertWith(userSelection, "companionList");
@@ -143,7 +145,7 @@ public class MHealthCheckupListController {
HealthCheckupUserSelection selection = baseService.dao().fetch(HealthCheckupUserSelection.class, id); HealthCheckupUserSelection selection = baseService.dao().fetch(HealthCheckupUserSelection.class, id);
baseService.dao().fetchLinks(selection, "companionList"); baseService.dao().fetchLinks(selection, "companionList");
NutMap nutMap = Lang.obj2map(selection, NutMap.class); NutMap nutMap = Lang.obj2map(selection, NutMap.class);
if(selection.getCompanionList().size() > 0) { if (selection.getCompanionList().size() > 0) {
nutMap.put("isFamily", "是"); nutMap.put("isFamily", "是");
} else { } else {
nutMap.put("isFamily", "否"); nutMap.put("isFamily", "否");
@@ -160,11 +162,11 @@ public class MHealthCheckupListController {
@At @At
@ViReturn @ViReturn
public Object validCondition(String cndId) { public Object validCondition(String cndId) {
if(StrUtil.isBlank(cndId)) { if (StrUtil.isBlank(cndId)) {
return Result.success(); return Result.success();
} }
NutMap nutMap = healthCheckupProjectService.validCondition(cndId); NutMap nutMap = healthCheckupProjectService.validCondition(cndId);
if(!nutMap.getBoolean("flag")) { if (!nutMap.getBoolean("flag")) {
return Result.error("选择条件:" + nutMap.getString("msg")); return Result.error("选择条件:" + nutMap.getString("msg"));
} }
return null; return null;
@@ -78,39 +78,42 @@ layout("/layouts/platform.html"){
</div> </div>
</div> </div>
<div class="search-item"> <template v-if="isThreeUnit">
<div class="search-item-label">工会小组:</div> <div class="search-item">
<div class="search-item-option"> <div class="search-item-label">工会小组:</div>
<el-select @change="getThreeUnits" clearable <div class="search-item-option">
filterable <el-select @change="getThreeUnits" clearable
placeholder="请选择" filterable
style="width: 100%" placeholder="请选择"
v-model="pageForm.unionGroupId"> style="width: 100%"
<el-option v-model="pageForm.unionGroupId">
:key="item.id" <el-option
:label="item.groupName" :key="item.id"
:value="item.id" :label="item.groupName"
v-for="item in unionGroups"> :value="item.id"
</el-option> v-for="item in unionGroups">
</el-select> </el-option>
</el-select>
</div>
</div> </div>
</div>
<div class="search-item"> <div class="search-item">
<div class="search-item-label">组成科室:</div> <div class="search-item-label">组成科室:</div>
<div class="search-item-option"> <div class="search-item-option">
<el-select clearable filterable placeholder="请选择" <el-select clearable filterable placeholder="请选择"
style="width: 100%" style="width: 100%"
v-model="pageForm.threeUnitId"> v-model="pageForm.threeUnitId">
<el-option <el-option
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.id" :value="item.id"
v-for="item in threeUnits"> v-for="item in threeUnits">
</el-option> </el-option>
</el-select> </el-select>
</div>
</div> </div>
</div> </template>
<div class="search-query"> <div class="search-query">
<el-button @click="doSearch" icon="el-icon-search" type="primary">搜索 <el-button @click="doSearch" icon="el-icon-search" type="primary">搜索
</el-button> </el-button>
@@ -204,11 +207,8 @@ layout("/layouts/platform.html"){
</el-button> </el-button>
</el-row> </el-row>
</el-dialog> </el-dialog>
</div> </div>
<script> <script>
const vue = new Vue({ const vue = new Vue({
el: '#app', el: '#app',
@@ -231,8 +231,8 @@ layout("/layouts/platform.html"){
{prop: 'sex', label: '性别', sortable: true, width: '100px'}, {prop: 'sex', label: '性别', sortable: true, width: '100px'},
{prop: 'unionname', label: '所属工会', sortable: true}, {prop: 'unionname', label: '所属工会', sortable: true},
{prop: 'unitname', label: '所属单位', sortable: true}, {prop: 'unitname', label: '所属单位', sortable: true},
{prop: 'threeUnitName', label: '所在科室', sortable: true}, {prop: 'threeUnitName', label: '所在科室', sortable: true, checked: 0},
{prop: 'unionGroupName', label: '工会小组', sortable: true}, {prop: 'unionGroupName', label: '工会小组', sortable: true, checked: 0},
{prop: 'optionName', label: '所选套餐', width: "100px"}, {prop: 'optionName', label: '所选套餐', width: "100px"},
// {prop: 'userSign', label: '签字', width: "100px"}, // {prop: 'userSign', label: '签字', width: "100px"},
], ],
@@ -241,6 +241,7 @@ layout("/layouts/platform.html"){
loading: false, loading: false,
campusOptions: [], campusOptions: [],
isThreeUnit: null,
} }
}, },
components: {}, components: {},
@@ -322,13 +323,20 @@ layout("/layouts/platform.html"){
}, },
}, },
async created() { async created() {
this.isThreeUnit = await getConfigKey('isThreeUnit') === 'true'
if (this.isThreeUnit) {
this.tableColumns.forEach(v => {
if (["threeUnitName", "unionGroupName"].includes(v.prop)) {
v.checked = 1
}
})
}
this.unions = await getUnions() this.unions = await getUnions()
this.flushUnits() this.flushUnits()
await this.yearChange() await this.yearChange()
this.pageData() this.pageData()
this.getCampus() this.getCampus()
} }
}) })
</script> </script>
@@ -75,25 +75,44 @@ layout("/layouts/platform.html"){
</el-table-column> </el-table-column>
<el-table-column prop="userOnline" align="center" header-align="center" <el-table-column prop="userOnline" align="center" header-align="center"
label="操作" width="500px"> label="操作" width="100px">
<template scope="{row}"> <template scope="{row}">
<el-button size="mini" :loading="row.loading" @click="openView(row)">
查看 <el-dropdown @command="dropdownCommand">
</el-button> <el-button plain size="mini">
<el-button size="mini" :loading="row.loading" type="primary" <i class="ti-settings"></i>
@click="openEdit(row)"> <span class="ti-angle-down"></span>
编辑 </el-button>
</el-button> <el-dropdown-menu slot="dropdown">
<el-button size="mini" :loading="row.loading" type="danger" <el-dropdown-item :command="{type:'view',data:row}">
@click="doDelete(row.id)"> 查看
删除 </el-dropdown-item>
</el-button> <el-dropdown-item v-if="row.isWithinChoiceTime && !row.isHasUserList"
<el-button plain size="mini" @click="sendMsg(row)" type="primary"> :command="{type:'create',data:row}">
通知 生成名单
</el-button> </el-dropdown-item>
<el-button plain size="mini" @click="openCode(row.id)" type="primary"> <el-dropdown-item v-if="row.isWithinChoiceTime && row.isHasUserList"
二维码 :command="{type:'renew',data:row}">
</el-button> 更新名单
</el-dropdown-item>
<el-dropdown-item v-if="row.isWithinChoiceTime"
:command="{type:'reset',data:row}">
重置名单
</el-dropdown-item>
<el-dropdown-item :command="{type:'edit',data:row}">
编辑
</el-dropdown-item>
<el-dropdown-item :command="{type:'delete',data:row}">
删除
</el-dropdown-item>
<el-dropdown-item :command="{type:'send',data:row}">
通知
</el-dropdown-item>
<el-dropdown-item :command="{type:'code',data:row}">
二维码
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -354,7 +373,7 @@ layout("/layouts/platform.html"){
name: [{required: true, message: '必填', trigger: ['blur', 'change']}], name: [{required: true, message: '必填', trigger: ['blur', 'change']}],
choiceTime: [{required: true, message: '必填', trigger: ['blur', 'change']}], choiceTime: [{required: true, message: '必填', trigger: ['blur', 'change']}],
activityGroupId: [{required: true, message: '必填', trigger: ['blur', 'change']}], activityGroupId: [{required: true, message: '必填', trigger: ['blur', 'change']}],
cover: [{required: true, message: '必填', trigger: ['blur', 'change']}], // cover: [{required: true, message: '必填', trigger: ['blur', 'change']}],
healthCheckupType: [{required: true, message: '必填', trigger: ['blur', 'change']}], healthCheckupType: [{required: true, message: '必填', trigger: ['blur', 'change']}],
healthCheckupProjectSubjects: [{ healthCheckupProjectSubjects: [{
required: true, required: true,
@@ -371,7 +390,7 @@ layout("/layouts/platform.html"){
}, },
{label: '出生日期', value: 'birthday', type: "date"}, {label: '出生日期', value: 'birthday', type: "date"},
], ],
deleteRowIds: [] deleteRowIds: [],
} }
}, },
components: { components: {
@@ -381,6 +400,95 @@ layout("/layouts/platform.html"){
'condition': httpVueLoader('/components/plugins/ConditionStructure.vue?v=1.0.0'), 'condition': httpVueLoader('/components/plugins/ConditionStructure.vue?v=1.0.0'),
}, },
methods: { methods: {
dropdownCommand(command) {
const {type, data} = command
if (type === 'view') {
this.openView(data)
} else if (type === 'created') {
this.createUserList(data)
} else if (type === 'renew') {
this.renewUserList(data)
} else if (type === 'reset') {
this.resetUserList(data)
} else if (type === 'edit') {
this.openEdit(data)
} else if (type === 'delete') {
this.doDelete(data.id)
} else if (type === 'send') {
this.sendMsg(data)
} else if (type === 'code') {
this.openCode(data.id)
}
},
async createUserList(row) {
const msg = '您确定要生成【' + row.name + '】体检名单吗?(该名单生成是按照创建时选择的可报名人员范围来生成)'
const confirm = await this.$confirm(msg, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
if ('confirm' !== confirm) return
const loading = this.$loading({
lock: true,
text: '数据更新中,请稍后...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
const resp = await $.post(loc() + '/createUserList', row)
loading.close()
if (resp.code === 0) {
this.$message.success('操作成功')
this.pageData()
} else {
this.$message.warning(resp.msg)
}
},
async renewUserList(row) {
const msg = '您确定要更新【' + row.name + '】的体检名单吗?(如可报名人员范围发生变化会删除已选择的人员信息)'
const confirm = await this.$confirm(msg, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
if ('confirm' !== confirm) return
const loading = this.$loading({
lock: true,
text: '数据更新中,请稍后...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
const resp = await $.post(loc() + '/renewUserList', row)
loading.close()
if (resp.code === 0) {
this.$message.success('操作成功')
this.pageData()
} else {
this.$message.warning(resp.msg)
}
},
async resetUserList(row) {
const msg = '您确定要重置【' + row.name + '】的体检名单吗?(该操作会将所有已选择的人员清空后,在进行生成)'
const confirm = await this.$confirm(msg, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
if ('confirm' !== confirm) return
const loading = this.$loading({
lock: true,
text: '数据更新中,请稍后...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
const resp = await $.post(loc() + '/resetUserList', row)
loading.close()
if (resp.code === 0) {
this.$message.success('操作成功')
this.pageData()
} else {
this.$message.warning(resp.msg)
}
},
openCode(id) { openCode(id) {
this.$refs.openQRCode.openCode("/childrenActivities?id=" + id) this.$refs.openQRCode.openCode("/childrenActivities?id=" + id)
}, },