commit
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-23
@@ -61,46 +61,42 @@ public class HealthCheckupListController {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id,
|
||||
u.loginname,
|
||||
u.username,
|
||||
u.sex,
|
||||
u.unionname,
|
||||
u.unitname,
|
||||
u.threeUnitName,
|
||||
u.unionGroupName,
|
||||
hcu.userId AS id,
|
||||
hcu.loginname,
|
||||
hcu.username,
|
||||
hcu.sex,
|
||||
hcu.unionname,
|
||||
hcu.unitname,
|
||||
hcu.threeUnitName,
|
||||
hcu.unionGroupName,
|
||||
hcus.selectTime,
|
||||
hcus.subjectId,
|
||||
hcus.campus,
|
||||
hcus.userSign,
|
||||
aus.id ausid
|
||||
hcus.userSign
|
||||
FROM
|
||||
activity_user_scope aus
|
||||
LEFT JOIN `user` u ON u.id = aus.userId
|
||||
LEFT JOIN health_checkup_user_selection hcus ON aus.userId = hcus.selectUserId
|
||||
health_checkup_user hcu
|
||||
LEFT JOIN health_checkup_user_selection hcus ON hcu.userId = hcus.selectUserId
|
||||
AND hcus.projectId=@projectId
|
||||
$condition
|
||||
""").setParam("projectId", projectId);
|
||||
sql.setCondition(cnd);
|
||||
cnd.andEX("aus.groupId", "=", project.getActivityGroupId());
|
||||
cnd.andEX("u.unionid", "=", unionId);
|
||||
cnd.andEX("u.unitId", "=", unitId);
|
||||
cnd.andEX("u.unionGroupId", "=", unionGroupId);
|
||||
cnd.andEX("u.threeUnitId", "=", threeUnitId);
|
||||
cnd.andEX("hcu.unionId", "=", unionId);
|
||||
cnd.andEX("hcu.unitId", "=", unitId);
|
||||
cnd.andEX("hcu.unionGroupId", "=", unionGroupId);
|
||||
cnd.andEX("hcu.threeUnitId", "=", threeUnitId);
|
||||
|
||||
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())) {
|
||||
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
|
||||
}
|
||||
|
||||
|
||||
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 {
|
||||
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);
|
||||
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);
|
||||
v.setv("optionName", subject.getOptionName());
|
||||
}
|
||||
|
||||
});
|
||||
return pagination;
|
||||
}
|
||||
|
||||
+86
-8
@@ -5,21 +5,27 @@ import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.zhgh.data.model.MatchConditionStructure;
|
||||
import io.v.nutz.zhgh.data.service.MatchConditionStructureService;
|
||||
import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProject;
|
||||
import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProjectSubject;
|
||||
import io.v.nutz.zhgh.healthCheckup.model.*;
|
||||
import io.v.nutz.zhgh.healthCheckup.service.HealthCheckupProjectService;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
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.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName HealthCheckupProjectMangeController
|
||||
* @Description TODO
|
||||
@@ -78,15 +84,35 @@ public class HealthCheckupProjectMangeController {
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("welfare.project.mange")
|
||||
@RequiresPermissions("healthCheckup.projectMange")
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "year", required = false) Integer year,
|
||||
@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.andEX("year", "=", year);
|
||||
cnd.andEX("name", "=", name);
|
||||
cnd.desc("choiceTimeStart");
|
||||
return healthCheckupProjectService.list(pageForm, cnd);
|
||||
cnd.andEX("hcp.`year`", "=", year);
|
||||
cnd.andEX("hcp.`name`", "=", name);
|
||||
cnd.desc("hcp.choiceTimeStart");
|
||||
sql.setCondition(cnd);
|
||||
return healthCheckupProjectService.listPageMap(pageForm.getPageNumber(),pageForm.getPageSize(),sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@@ -98,7 +124,7 @@ public class HealthCheckupProjectMangeController {
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@RequiresPermissions("welfare.project.mange")
|
||||
@RequiresPermissions("healthCheckup.projectMange")
|
||||
public Object doDelete(String id) {
|
||||
healthCheckupProjectService.delete(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);
|
||||
|
||||
/**
|
||||
* 添加体检用户
|
||||
* @param healthCheckupProject
|
||||
*/
|
||||
void addHealthCheckupUser(HealthCheckupProject healthCheckupProject);
|
||||
|
||||
/**
|
||||
* 更新体检用户
|
||||
* @param healthCheckupProject
|
||||
*/
|
||||
void renewHealthCheckupUser(HealthCheckupProject healthCheckupProject);
|
||||
}
|
||||
|
||||
+89
@@ -2,29 +2,42 @@ package io.v.nutz.zhgh.healthCheckup.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.MatchMethod;
|
||||
import io.v.nutz.zhgh.data.model.MatchCondition;
|
||||
import io.v.nutz.zhgh.data.model.MatchConditionStructure;
|
||||
import io.v.nutz.zhgh.data.service.MatchConditionStructureService;
|
||||
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.sys.models.Sys_user;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
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
|
||||
@@ -38,6 +51,9 @@ public class HealthCheckupProjectServiceImpl extends ViServiceImpl<HealthCheckup
|
||||
@Inject
|
||||
private MatchConditionStructureService matchConditionStructureService;
|
||||
|
||||
@Inject
|
||||
private ManyAddOrRenewUtil manyAddOrRenewUtil;
|
||||
|
||||
public HealthCheckupProjectServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
@@ -104,4 +120,77 @@ public class HealthCheckupProjectServiceImpl extends ViServiceImpl<HealthCheckup
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-11
@@ -36,16 +36,7 @@ public class HealthCheckupSingleServiceImpl extends ViServiceImpl<HealthCheckupP
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
su.*,
|
||||
(
|
||||
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
|
||||
(SELECT count( 1 ) FROM `health_checkup_user` hcu WHERE hcu.unionId = su.id $unionGroupIdCnd ) sumCount
|
||||
FROM
|
||||
sys_union su
|
||||
$condition
|
||||
@@ -54,7 +45,6 @@ public class HealthCheckupSingleServiceImpl extends ViServiceImpl<HealthCheckupP
|
||||
cnd.andEX("su.id","=",unionId);
|
||||
cnd.asc("su.unioncode");
|
||||
sql.setCondition(cnd);
|
||||
sql.setParam("groupId", project.getActivityGroupId());
|
||||
if (StrUtil.isNotBlank(unionGroupId)) {
|
||||
sql.setVar("unionGroupIdCnd", "and u.unionGroupId = '%s'".formatted(unionGroupId));
|
||||
}
|
||||
|
||||
+11
-9
@@ -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
|
||||
from
|
||||
health_checkup_project p
|
||||
LEFT JOIN health_checkup_user hcu on hcu.projectId = p.id
|
||||
$condition
|
||||
""").setParam("userId", ShiroUtil.getPlatformUid());
|
||||
""").setParam("userId", ShiroUtil.getUserId());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (tabName.equals("ing")) {
|
||||
cnd.and(Cnd.exps("choiceTimeStart", "<", DateUtil.now()).and("choiceTimeEnd", ">", DateUtil.now()));
|
||||
} else if (tabName.equals("end")) {
|
||||
cnd.and("choiceTimeEnd", "<", DateUtil.now());
|
||||
cnd.and("hcu.userId", "=", ShiroUtil.getUserId());
|
||||
if ("ing".equals(tabName)) {
|
||||
cnd.and(Cnd.exps("p.choiceTimeStart", "<", DateUtil.now()).and("p.choiceTimeEnd", ">", DateUtil.now()));
|
||||
} else if ("end".equals(tabName)) {
|
||||
cnd.and("p.choiceTimeEnd", "<", DateUtil.now());
|
||||
}
|
||||
cnd.asc("selectCount");
|
||||
sql.setCondition(cnd);
|
||||
@@ -109,7 +111,7 @@ public class MHealthCheckupListController {
|
||||
@ViReturn
|
||||
public Object doSubmit(@Param("userSelection") HealthCheckupUserSelection userSelection) {
|
||||
Trans.exec(() -> {
|
||||
if(userSelection.getId() == null) {
|
||||
if (userSelection.getId() == null) {
|
||||
userSelection.setSelectUserId(ShiroUtil.getPlatformUid());
|
||||
userSelection.setSelectTime(new Date());
|
||||
baseService.dao().insertWith(userSelection, "companionList");
|
||||
@@ -143,7 +145,7 @@ public class MHealthCheckupListController {
|
||||
HealthCheckupUserSelection selection = baseService.dao().fetch(HealthCheckupUserSelection.class, id);
|
||||
baseService.dao().fetchLinks(selection, "companionList");
|
||||
NutMap nutMap = Lang.obj2map(selection, NutMap.class);
|
||||
if(selection.getCompanionList().size() > 0) {
|
||||
if (selection.getCompanionList().size() > 0) {
|
||||
nutMap.put("isFamily", "是");
|
||||
} else {
|
||||
nutMap.put("isFamily", "否");
|
||||
@@ -160,11 +162,11 @@ public class MHealthCheckupListController {
|
||||
@At
|
||||
@ViReturn
|
||||
public Object validCondition(String cndId) {
|
||||
if(StrUtil.isBlank(cndId)) {
|
||||
if (StrUtil.isBlank(cndId)) {
|
||||
return Result.success();
|
||||
}
|
||||
NutMap nutMap = healthCheckupProjectService.validCondition(cndId);
|
||||
if(!nutMap.getBoolean("flag")) {
|
||||
if (!nutMap.getBoolean("flag")) {
|
||||
return Result.error("选择条件:" + nutMap.getString("msg"));
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user