Compare commits
9
Commits
c75bcd4a92
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
486934f3b6 | ||
|
|
e3eb5b639b | ||
|
|
f5e5720120 | ||
|
|
36d844a1e8 | ||
|
|
caf83bdbd9 | ||
|
|
e0ecdda400 | ||
|
|
7d5d2da60f | ||
|
|
5f1ba33fd4 | ||
|
|
ecf8ad3536 |
@@ -26,3 +26,6 @@ hs_err_pid*
|
|||||||
|
|
||||||
src/main/resources/application.yaml
|
src/main/resources/application.yaml
|
||||||
src/main/resources/application-dev.yaml
|
src/main/resources/application-dev.yaml
|
||||||
|
.vscode
|
||||||
|
bin
|
||||||
|
node-data-center-mock/
|
||||||
@@ -26,7 +26,7 @@ public class Sys_unit extends BaseModel implements Serializable {
|
|||||||
@Name
|
@Name
|
||||||
@Comment("ID")
|
@Comment("ID")
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||||
@PrevInsert(uu32 = true)
|
@PrevInsert(uu32 = true, nullEffective = true)
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.budwk.app.sys.services;
|
|||||||
import com.budwk.app.base.service.BaseService;
|
import com.budwk.app.base.service.BaseService;
|
||||||
import com.budwk.app.sys.models.Sys_unit;
|
import com.budwk.app.sys.models.Sys_unit;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by wizzer on 2016/12/22.
|
* Created by wizzer on 2016/12/22.
|
||||||
*/
|
*/
|
||||||
@@ -15,6 +17,8 @@ public interface SysUnitService extends BaseService<Sys_unit> {
|
|||||||
*/
|
*/
|
||||||
void save(Sys_unit unit, String pid);
|
void save(Sys_unit unit, String pid);
|
||||||
|
|
||||||
|
void saveBatch(List<Sys_unit> units, String pid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 级联删除单位及单位下用户
|
* 级联删除单位及单位下用户
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.budwk.app.sys.services.impl;
|
package com.budwk.app.sys.services.impl;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.digest.DigestUtil;
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
@@ -14,18 +13,20 @@ import com.budwk.app.base.exception.BaseException;
|
|||||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||||
import com.budwk.app.sys.annotation.DataCenterColumn;
|
import com.budwk.app.sys.annotation.DataCenterColumn;
|
||||||
import com.budwk.app.sys.models.Sys_dict;
|
import com.budwk.app.sys.models.Sys_dict;
|
||||||
|
import com.budwk.app.sys.models.Sys_unit;
|
||||||
import com.budwk.app.sys.models.Sys_user;
|
import com.budwk.app.sys.models.Sys_user;
|
||||||
import com.budwk.app.sys.models.Sys_user_source;
|
import com.budwk.app.sys.models.Sys_user_source;
|
||||||
import com.budwk.app.sys.services.SysDataUserPullService;
|
import com.budwk.app.sys.services.SysDataUserPullService;
|
||||||
import com.budwk.app.sys.services.SysDictService;
|
import com.budwk.app.sys.services.SysDictService;
|
||||||
|
import com.budwk.app.sys.services.SysUnitService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nutz.aop.interceptor.async.Async;
|
import org.nutz.aop.interceptor.async.Async;
|
||||||
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Dao;
|
import org.nutz.dao.Dao;
|
||||||
import org.nutz.dao.Sqls;
|
import org.nutz.dao.Sqls;
|
||||||
import org.nutz.dao.sql.Sql;
|
import org.nutz.dao.sql.Sql;
|
||||||
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.json.Json;
|
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
|
||||||
@@ -40,6 +41,8 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
|||||||
@Inject
|
@Inject
|
||||||
private SysDictService sysDictService;
|
private SysDictService sysDictService;
|
||||||
@Inject
|
@Inject
|
||||||
|
private SysUnitService sysUnitService;
|
||||||
|
@Inject
|
||||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||||
|
|
||||||
public SysDataUserPullServiceImpl(Dao dao) {
|
public SysDataUserPullServiceImpl(Dao dao) {
|
||||||
@@ -106,6 +109,7 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
|||||||
String sign = Base64.encode(DigestUtil.md5Hex(appId + secret + ts, CharsetUtil.CHARSET_UTF_8));
|
String sign = Base64.encode(DigestUtil.md5Hex(appId + secret + ts, CharsetUtil.CHARSET_UTF_8));
|
||||||
|
|
||||||
HttpRequest httpRequest = HttpUtil.createPost("https://sjzcpt.nnu.edu.cn/cdsp/data-api/v2/DS0026");
|
HttpRequest httpRequest = HttpUtil.createPost("https://sjzcpt.nnu.edu.cn/cdsp/data-api/v2/DS0026");
|
||||||
|
// HttpRequest httpRequest = HttpUtil.createPost("http://127.0.0.1:3001/cdsp/data-api/v2/DS0026");
|
||||||
httpRequest.header("Content-Type", "application/json");
|
httpRequest.header("Content-Type", "application/json");
|
||||||
httpRequest.header("appId", appId);
|
httpRequest.header("appId", appId);
|
||||||
httpRequest.header("timestamp", String.valueOf(ts));
|
httpRequest.header("timestamp", String.valueOf(ts));
|
||||||
@@ -180,6 +184,7 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
|||||||
log.info("--------------------");
|
log.info("--------------------");
|
||||||
// 插入到数据库
|
// 插入到数据库
|
||||||
dao().insert(latestSourceList);
|
dao().insert(latestSourceList);
|
||||||
|
syncUnits(latestSourceList);
|
||||||
|
|
||||||
return nowDate;
|
return nowDate;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -187,6 +192,33 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void syncUnits(List<Sys_user_source> userSources) {
|
||||||
|
Map<String, String> unitIdNameMap = userSources.stream()
|
||||||
|
.filter(source -> StrUtil.isAllNotBlank(source.getUnitId(), source.getUnitName()))
|
||||||
|
.collect(Collectors.toMap(Sys_user_source::getUnitId, Sys_user_source::getUnitName,
|
||||||
|
(existingValue, newValue) -> newValue));
|
||||||
|
if (unitIdNameMap.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<String> existingUnitIds = dao().query(Sys_unit.class, Cnd.NEW()).stream()
|
||||||
|
.map(Sys_unit::getId).collect(Collectors.toSet());
|
||||||
|
List<Sys_unit> insertUnits = unitIdNameMap.entrySet().stream()
|
||||||
|
.filter(entry -> !existingUnitIds.contains(entry.getKey()))
|
||||||
|
.map(entry -> {
|
||||||
|
Sys_unit unit = new Sys_unit();
|
||||||
|
unit.setId(entry.getKey());
|
||||||
|
unit.setUnitcode(entry.getKey());
|
||||||
|
unit.setName(entry.getValue());
|
||||||
|
unit.setParentId("1");
|
||||||
|
unit.setUnitLevel(2);
|
||||||
|
return unit;
|
||||||
|
}).toList();
|
||||||
|
if (!insertUnits.isEmpty()) {
|
||||||
|
sysUnitService.saveBatch(insertUnits, "1");
|
||||||
|
log.info("拉取数据后新增单位: {} 个", insertUnits.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
private void updateDict(List<Sys_user_source> userSources) {
|
private void updateDict(List<Sys_user_source> userSources) {
|
||||||
//判断是否要更新在职状态字典
|
//判断是否要更新在职状态字典
|
||||||
@@ -261,6 +293,7 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
|||||||
String sign = Base64.encode(DigestUtil.md5Hex(appId + secret + ts, CharsetUtil.CHARSET_UTF_8));
|
String sign = Base64.encode(DigestUtil.md5Hex(appId + secret + ts, CharsetUtil.CHARSET_UTF_8));
|
||||||
|
|
||||||
HttpRequest httpRequest = HttpUtil.createPost("https://sjzcpt.nnu.edu.cn/cdsp/data-api/v2/DS0040");
|
HttpRequest httpRequest = HttpUtil.createPost("https://sjzcpt.nnu.edu.cn/cdsp/data-api/v2/DS0040");
|
||||||
|
// HttpRequest httpRequest = HttpUtil.createPost("http://127.0.0.1:3001/cdsp/data-api/v2/DS0040");
|
||||||
httpRequest.header("Content-Type", "application/json");
|
httpRequest.header("Content-Type", "application/json");
|
||||||
httpRequest.header("appId", appId);
|
httpRequest.header("appId", appId);
|
||||||
httpRequest.header("timestamp", String.valueOf(ts));
|
httpRequest.header("timestamp", String.valueOf(ts));
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import org.nutz.lang.Strings;
|
|||||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by wizzer on 2016/12/22.
|
* Created by wizzer on 2016/12/22.
|
||||||
*/
|
*/
|
||||||
@@ -50,6 +52,40 @@ public class SysUnitServiceImpl extends BaseServiceImpl<Sys_unit> implements Sys
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
|
public void saveBatch(List<Sys_unit> units, String pid) {
|
||||||
|
if (units == null || units.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String path = "";
|
||||||
|
if (!Strings.isEmpty(pid)) {
|
||||||
|
Sys_unit parent = this.fetch(pid);
|
||||||
|
if (parent != null) {
|
||||||
|
path = parent.getPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int nextPathIndex = 0;
|
||||||
|
if (StrUtil.isNotBlank(path)) {
|
||||||
|
String nextPath = getSubPath("sys_unit", "path", path);
|
||||||
|
nextPathIndex = Integer.parseInt(nextPath.substring(path.length()));
|
||||||
|
}
|
||||||
|
for (Sys_unit unit : units) {
|
||||||
|
if (StrUtil.isNotBlank(path) && nextPathIndex <= 9999) {
|
||||||
|
// 批量入库前按序分配路径,避免重复查询产生相同路径。
|
||||||
|
unit.setPath(path + String.format("%04d", nextPathIndex++));
|
||||||
|
} else {
|
||||||
|
unit.setPath(null);
|
||||||
|
}
|
||||||
|
unit.setId(unit.getUnitcode());
|
||||||
|
unit.setParentId(pid);
|
||||||
|
}
|
||||||
|
dao().fastInsert(units);
|
||||||
|
if (!Strings.isEmpty(pid)) {
|
||||||
|
this.update(Chain.make("hasChildren", true), Cnd.where("id", "=", pid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 级联删除单位
|
* 级联删除单位
|
||||||
*
|
*
|
||||||
|
|||||||
+45
-51
@@ -370,14 +370,15 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
|
|
||||||
FamilyActivity activity = dao().fetch(FamilyActivity.class, activityId);
|
FamilyActivity activity = dao().fetch(FamilyActivity.class, activityId);
|
||||||
if (formalSignUp && Objects.equals(course.getReserveMode(), 2) && isWithinSignUpTime(activity)) {
|
if (formalSignUp && Objects.equals(course.getReserveMode(), 2) && isWithinSignUpTime(activity)) {
|
||||||
promoteWaitingUsers(course, currentSignUp);
|
promoteWaitingUsers(course);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按报名时间顺序递补候补人员。本人和家属是否计入总人数,严格按课程类型配置计算。
|
* 按报名时间顺序从全部分工会候补中查找当前可容纳的人员。
|
||||||
|
* 本人和家属是否计入总人数,严格按课程类型配置计算。
|
||||||
*/
|
*/
|
||||||
private void promoteWaitingUsers(FamilyCourse course, FamilyUser canceledSignUp) {
|
private void promoteWaitingUsers(FamilyCourse course) {
|
||||||
FamilyType type = dao().fetch(FamilyType.class, course.getCourseType());
|
FamilyType type = dao().fetch(FamilyType.class, course.getCourseType());
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return;
|
return;
|
||||||
@@ -386,10 +387,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
Cnd waitingCnd = Cnd.where(FamilyUser::getActivityId, "=", course.getActivityId())
|
Cnd waitingCnd = Cnd.where(FamilyUser::getActivityId, "=", course.getActivityId())
|
||||||
.and(FamilyUser::getCourseId, "=", course.getId())
|
.and(FamilyUser::getCourseId, "=", course.getId())
|
||||||
.and(FamilyUser::getState, "=", 2);
|
.and(FamilyUser::getState, "=", 2);
|
||||||
// 配置了分工会名额时,取消释放的是原分工会名额,只允许该分工会候补人员递补。
|
|
||||||
if (Lang.isNotEmpty(course.getUnionLimit())) {
|
|
||||||
waitingCnd.and(FamilyUser::getUnionId, "=", canceledSignUp.getUnionId());
|
|
||||||
}
|
|
||||||
waitingCnd.asc(FamilyUser::getSignUpTime);
|
waitingCnd.asc(FamilyUser::getSignUpTime);
|
||||||
|
|
||||||
List<FamilyUser> waitingUsers = dao().query(FamilyUser.class, waitingCnd);
|
List<FamilyUser> waitingUsers = dao().query(FamilyUser.class, waitingCnd);
|
||||||
@@ -397,9 +394,9 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
int familyNumber = Lang.isNotEmpty(waitingUser.getMobileColumnsValue())
|
int familyNumber = Lang.isNotEmpty(waitingUser.getMobileColumnsValue())
|
||||||
? waitingUser.getMobileColumnsValue().size() : 0;
|
? waitingUser.getMobileColumnsValue().size() : 0;
|
||||||
int contribution = getFamilyContribution(type, familyNumber);
|
int contribution = getFamilyContribution(type, familyNumber);
|
||||||
// 严格保持候补先后顺序;排在前面的人员当前无法容纳时,不跨过该人员补后续人员。
|
// 当前候补所需人数或原选时段无法容纳时,继续查找后续能够使用空余名额的候补。
|
||||||
if (!canPromoteWaitingUser(course, waitingUser, contribution)) {
|
if (!canPromoteWaitingUser(course, waitingUser, contribution)) {
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
waitingUser.setState(3);
|
waitingUser.setState(3);
|
||||||
dao().update(waitingUser);
|
dao().update(waitingUser);
|
||||||
@@ -407,7 +404,8 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验候补人员转正后的课程总人数、分工会人数和独立时段人数是否均不超限。
|
* 校验候补人员转正后的课程总人数和独立时段人数是否均不超限。
|
||||||
|
* 自动递补不校验分工会限制,避免空余名额因原分工会没有合适候补而闲置。
|
||||||
*/
|
*/
|
||||||
private boolean canPromoteWaitingUser(FamilyCourse course, FamilyUser waitingUser, int contribution) {
|
private boolean canPromoteWaitingUser(FamilyCourse course, FamilyUser waitingUser, int contribution) {
|
||||||
int courseLimit = course.getCoursePeopleNumber();
|
int courseLimit = course.getCoursePeopleNumber();
|
||||||
@@ -417,20 +415,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Lang.isNotEmpty(course.getUnionLimit())) {
|
|
||||||
NutMap unionLimit = course.getUnionLimit().stream()
|
|
||||||
.filter(item -> Objects.equals(item.getString("id"), waitingUser.getUnionId()))
|
|
||||||
.findFirst().orElse(null);
|
|
||||||
if (unionLimit == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int unionCount = statisticsService.queryCourseCount(
|
|
||||||
course.getId(), course.getCourseType(), waitingUser.getUnionId());
|
|
||||||
if (unionCount + contribution > unionLimit.getInt("limitCount")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasAvailableCourseTime(course, waitingUser);
|
return hasAvailableCourseTime(course, waitingUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,10 +617,17 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
}
|
}
|
||||||
FamilyActivity activity = dao().fetch(FamilyActivity.class, course.getActivityId());
|
FamilyActivity activity = dao().fetch(FamilyActivity.class, course.getActivityId());
|
||||||
validateSignUpTimeAndScope(activity, SecurityUtil.getUserId(), true);
|
validateSignUpTimeAndScope(activity, SecurityUtil.getUserId(), true);
|
||||||
|
FamilyType type = dao().fetch(FamilyType.class, course.getCourseType());
|
||||||
|
if (type == null) {
|
||||||
|
throw new BaseException("报名类型不存在或已变更");
|
||||||
|
}
|
||||||
|
|
||||||
if (Lang.isEmpty(familyUser.getMobileColumnsValue())) {
|
if (Lang.isEmpty(familyUser.getMobileColumnsValue())) {
|
||||||
throw new BaseException("请填写" + activity.getKeyWord() + "信息");
|
throw new BaseException("请填写" + activity.getKeyWord() + "信息");
|
||||||
}
|
}
|
||||||
|
// 修改报名与新增报名使用同一套子活动类型字段及家属人数上限,防止绕过前端提交超额数据。
|
||||||
|
familyUser.setMobileColumnsValue(normalizeAndValidateFamilyColumns(
|
||||||
|
familyUser.getMobileColumnsValue(), type, course, activity));
|
||||||
|
|
||||||
// 修改校验必须排除本人原报名,否则人数、唯一标识及报名限制都会重复计算。
|
// 修改校验必须排除本人原报名,否则人数、唯一标识及报名限制都会重复计算。
|
||||||
familyUser.setActivityId(currentSignUp.getActivityId());
|
familyUser.setActivityId(currentSignUp.getActivityId());
|
||||||
@@ -646,10 +637,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
throw new BaseException(familyCountResult.get(false));
|
throw new BaseException(familyCountResult.get(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
FamilyType type = dao().fetch(FamilyType.class, course.getCourseType());
|
|
||||||
if (type == null) {
|
|
||||||
throw new BaseException("报名类型不存在或已变更");
|
|
||||||
}
|
|
||||||
int currentFamilyNumber = Boolean.TRUE.equals(type.getIsBringFamily()) && Boolean.TRUE.equals(type.getIsAddFamily())
|
int currentFamilyNumber = Boolean.TRUE.equals(type.getIsBringFamily()) && Boolean.TRUE.equals(type.getIsAddFamily())
|
||||||
? familyUser.getMobileColumnsValue().size() : 0;
|
? familyUser.getMobileColumnsValue().size() : 0;
|
||||||
if (isSignFullForUpdate(course, type, currentFamilyNumber, currentSignUp, null)) {
|
if (isSignFullForUpdate(course, type, currentFamilyNumber, currentSignUp, null)) {
|
||||||
@@ -761,14 +748,14 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
if (StrUtil.isBlank(activity.getOnlyKey())) {
|
if (StrUtil.isBlank(activity.getOnlyKey())) {
|
||||||
throw new BaseException("活动未配置家属唯一标识,请联系管理员");
|
throw new BaseException("活动未配置家属唯一标识,请联系管理员");
|
||||||
}
|
}
|
||||||
if (activity.getFamilyMaxCount() == null) {
|
if (type.getFamilyMaxCount() == null) {
|
||||||
throw new BaseException("活动未配置家属最多人数,请联系管理员");
|
throw new BaseException("子活动类型未配置家属最多人数,请联系管理员");
|
||||||
}
|
}
|
||||||
if (Lang.isEmpty(submittedFamilies)) {
|
if (Lang.isEmpty(submittedFamilies)) {
|
||||||
throw new BaseException("请填写" + activity.getKeyWord() + "信息");
|
throw new BaseException("请填写" + activity.getKeyWord() + "信息");
|
||||||
}
|
}
|
||||||
if (activity.getFamilyMaxCount() != null && submittedFamilies.size() > activity.getFamilyMaxCount()) {
|
if (submittedFamilies.size() > type.getFamilyMaxCount()) {
|
||||||
throw new BaseException(activity.getKeyWord() + "人数最多为" + activity.getFamilyMaxCount());
|
throw new BaseException(activity.getKeyWord() + "人数最多为" + type.getFamilyMaxCount());
|
||||||
}
|
}
|
||||||
dao().fetchLinks(type, "familyMobileSignColumnList", Cnd.NEW().asc("columnIndex"));
|
dao().fetchLinks(type, "familyMobileSignColumnList", Cnd.NEW().asc("columnIndex"));
|
||||||
List<FamilyMobileSignColumn> columnConfigs = type.getFamilyMobileSignColumnList();
|
List<FamilyMobileSignColumn> columnConfigs = type.getFamilyMobileSignColumnList();
|
||||||
@@ -1126,14 +1113,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
@Override
|
@Override
|
||||||
public Map<Boolean, String> validFamilyCount(FamilyUser user) {
|
public Map<Boolean, String> validFamilyCount(FamilyUser user) {
|
||||||
String activityId = user.getActivityId();
|
String activityId = user.getActivityId();
|
||||||
// 查询报名记录
|
|
||||||
Cnd signUpCnd = Cnd.where(FamilyUser::getActivityId, "=", activityId)
|
|
||||||
.and(FamilyUser::getUserId, "=", SecurityUtil.getUserId());
|
|
||||||
if (StrUtil.isNotBlank(user.getId())) {
|
|
||||||
signUpCnd.and(FamilyUser::getId, "!=", user.getId());
|
|
||||||
}
|
|
||||||
List<FamilyUser> list = dao().query(FamilyUser.class, signUpCnd);
|
|
||||||
|
|
||||||
FamilyActivity activity = dao().fetch(FamilyActivity.class, activityId);
|
FamilyActivity activity = dao().fetch(FamilyActivity.class, activityId);
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
return Map.of(false, "报名活动不存在或已删除");
|
return Map.of(false, "报名活动不存在或已删除");
|
||||||
@@ -1141,14 +1120,35 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
if (StrUtil.isBlank(activity.getOnlyKey())) {
|
if (StrUtil.isBlank(activity.getOnlyKey())) {
|
||||||
return Map.of(false, "活动未配置家属唯一标识,请联系管理员");
|
return Map.of(false, "活动未配置家属唯一标识,请联系管理员");
|
||||||
}
|
}
|
||||||
if (activity.getFamilyMaxCount() == null) {
|
|
||||||
return Map.of(false, "活动未配置家属最多人数,请联系管理员");
|
|
||||||
}
|
|
||||||
if (Lang.isEmpty(user.getMobileColumnsValue())) {
|
if (Lang.isEmpty(user.getMobileColumnsValue())) {
|
||||||
return Map.of(false, "请填写" + activity.getKeyWord() + "信息");
|
return Map.of(false, "请填写" + activity.getKeyWord() + "信息");
|
||||||
}
|
}
|
||||||
|
FamilyCourse currentCourse = dao().fetch(FamilyCourse.class, user.getCourseId());
|
||||||
|
if (currentCourse == null || !Objects.equals(currentCourse.getActivityId(), activityId)) {
|
||||||
|
return Map.of(false, "报名课程不存在或已变更");
|
||||||
|
}
|
||||||
|
FamilyType currentType = dao().fetch(FamilyType.class, currentCourse.getCourseType());
|
||||||
|
if (currentType == null) {
|
||||||
|
return Map.of(false, "子活动类型不存在或已变更");
|
||||||
|
}
|
||||||
|
if (currentType.getFamilyMaxCount() == null) {
|
||||||
|
return Map.of(false, "子活动类型未配置家属最多人数,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询本人本活动的其他报名,修改报名时排除当前记录,后续冲突校验仍覆盖全部子活动类型。
|
||||||
|
Cnd signUpCnd = Cnd.where(FamilyUser::getActivityId, "=", activityId)
|
||||||
|
.and(FamilyUser::getUserId, "=", SecurityUtil.getUserId());
|
||||||
|
if (StrUtil.isNotBlank(user.getId())) {
|
||||||
|
signUpCnd.and(FamilyUser::getId, "!=", user.getId());
|
||||||
|
}
|
||||||
|
List<FamilyUser> list = dao().query(FamilyUser.class, signUpCnd);
|
||||||
|
List<FamilyCourse> courseList = dao().query(FamilyCourse.class, Cnd.where("activityId", "=", activityId));
|
||||||
|
Map<String, String> courseMap = courseList.stream()
|
||||||
|
.collect(Collectors.toMap(FamilyCourse::getId, FamilyCourse::getCourseType));
|
||||||
|
|
||||||
|
// 家属最多数按当前子活动类型独立累计,同类型多个子活动按家属唯一标识去重。
|
||||||
List<List<NutMap>> allMobileColumnsValue = new ArrayList<>(list.stream()
|
List<List<NutMap>> allMobileColumnsValue = new ArrayList<>(list.stream()
|
||||||
|
.filter(item -> Objects.equals(currentCourse.getCourseType(), courseMap.get(item.getCourseId())))
|
||||||
.map(FamilyUser::getMobileColumnsValue)
|
.map(FamilyUser::getMobileColumnsValue)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.flatMap(List::stream)
|
.flatMap(List::stream)
|
||||||
@@ -1156,9 +1156,6 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
|
|
||||||
allMobileColumnsValue.addAll(user.getMobileColumnsValue());
|
allMobileColumnsValue.addAll(user.getMobileColumnsValue());
|
||||||
|
|
||||||
// 后面搞活动,用这行代码吧,因为这次活动1个人可以报2个孩子,但是同一个孩子又可以报2个场地,草
|
|
||||||
//return allMobileColumnsValue.size() > activity.getFamilyMaxCount();
|
|
||||||
|
|
||||||
long count = allMobileColumnsValue.stream()
|
long count = allMobileColumnsValue.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.flatMap(List::stream)
|
.flatMap(List::stream)
|
||||||
@@ -1169,13 +1166,10 @@ public class FamilyActivityServiceImpl extends BaseServiceImpl<FamilyActivity> i
|
|||||||
.distinct()
|
.distinct()
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
if(count > activity.getFamilyMaxCount()) {
|
if(count > currentType.getFamilyMaxCount()) {
|
||||||
return Map.of(false, activity.getKeyWord() + "人数最多为" + activity.getFamilyMaxCount());
|
return Map.of(false, activity.getKeyWord() + "人数最多为" + currentType.getFamilyMaxCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FamilyCourse> courseList = dao().query(FamilyCourse.class, Cnd.where("activityId", "=", activityId));
|
|
||||||
Map<String, String> courseMap = courseList.stream().collect(Collectors.toMap(FamilyCourse::getId, FamilyCourse::getCourseType));
|
|
||||||
|
|
||||||
List<FamilyType> typeList = dao().query(FamilyType.class, Cnd.NEW());
|
List<FamilyType> typeList = dao().query(FamilyType.class, Cnd.NEW());
|
||||||
Map<String, String> typeMap = typeList.stream().collect(Collectors.toMap(FamilyType::getId, FamilyType::getTypeName));
|
Map<String, String> typeMap = typeList.stream().collect(Collectors.toMap(FamilyType::getId, FamilyType::getTypeName));
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 994 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 223 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 1.3 MiB |
@@ -165,8 +165,12 @@ const signForm = {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addFamily() {
|
addFamily() {
|
||||||
if(this.formData.mobileColumnsValue.length >= this.activity.familyMaxCount) {
|
if(this.courseTypeRow.familyMaxCount === null || this.courseTypeRow.familyMaxCount === undefined || this.courseTypeRow.familyMaxCount === '') {
|
||||||
this.$message.warning('家属最多人数为' + this.activity.familyMaxCount)
|
this.$message.warning('当前子活动类型未配置家属最多人数')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if(this.formData.mobileColumnsValue.length >= Number(this.courseTypeRow.familyMaxCount)) {
|
||||||
|
this.$message.warning('家属最多人数为' + this.courseTypeRow.familyMaxCount)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const list = clone(this.courseTypeRow.familyMobileSignColumnList)
|
const list = clone(this.courseTypeRow.familyMobileSignColumnList)
|
||||||
|
|||||||
@@ -103,8 +103,12 @@ const applyForm = {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addFamily() {
|
addFamily() {
|
||||||
if(this.formData.mobileColumnsValue.length >= this.activity.familyMaxCount) {
|
if(this.courseType.familyMaxCount === null || this.courseType.familyMaxCount === undefined || this.courseType.familyMaxCount === '') {
|
||||||
this.$toast(this.activity.keyWord + '最多人数为' + this.activity.familyMaxCount)
|
this.$toast('当前子活动类型未配置家属最多人数')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if(this.formData.mobileColumnsValue.length >= Number(this.courseType.familyMaxCount)) {
|
||||||
|
this.$toast(this.activity.keyWord + '最多人数为' + this.courseType.familyMaxCount)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const list = clone(this.courseType.familyMobileSignColumnList)
|
const list = clone(this.courseType.familyMobileSignColumnList)
|
||||||
|
|||||||
Reference in New Issue
Block a user