diff --git a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyCommon.java b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyCommon.java index 578c2ee..58a1a42 100644 --- a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyCommon.java +++ b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyCommon.java @@ -9,6 +9,7 @@ import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.nutz.dao.Cnd; import org.nutz.dao.Sqls; import org.nutz.dao.entity.Record; +import org.nutz.dao.sql.Sql; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.mvc.annotation.At; @@ -76,8 +77,15 @@ public class LxyCommon { @At @ViReturn - public Object getHdList() { - return lxyHdService.list(Sqls.create("SELECT id,`name` FROM `lxy_hd` ORDER BY hdcjsj desc ")); + public Object getHdList(Integer year) { + Sql sql = Sqls.create("SELECT id,`name` FROM `lxy_hd` $condition"); + Cnd cnd = Cnd.NEW(); + if (year != null) { + cnd.and(new org.nutz.dao.util.cri.Static("YEAR(hdcjsj) = " + year)); + } + cnd.desc("hdcjsj"); + sql.setCondition(cnd); + return lxyHdService.list(sql); } @At @@ -88,8 +96,16 @@ public class LxyCommon { @At @ViReturn - public Object getNowHdList() { - return lxyHdService.list(Sqls.create("SELECT id,`name` FROM `lxy_hd` WHERE now() < bmjzsj ORDER BY hdcjsj desc ")); + public Object getNowHdList(Integer year) { + Sql sql = Sqls.create("SELECT id,`name` FROM `lxy_hd` $condition"); + Cnd cnd = Cnd.NEW(); + cnd.and(new org.nutz.dao.util.cri.Static("now() < bmjzsj")); + if (year != null) { + cnd.and(new org.nutz.dao.util.cri.Static("YEAR(hdcjsj) = " + year)); + } + cnd.desc("hdcjsj"); + sql.setCondition(cnd); + return lxyHdService.list(sql); } } diff --git a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyFghShController.java b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyFghShController.java index 1847678..407739d 100644 --- a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyFghShController.java +++ b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyFghShController.java @@ -101,6 +101,7 @@ public class LxyFghShController { cnd.and(new Static("bm.bmzt = 1 ")); cnd.and(new Static("bm.bmlx = 2 ")); + cnd.and(new Static("(hd.activityGroupId IS NULL OR u.id IN (SELECT userId FROM activity_user_scope WHERE groupId = hd.activityGroupId))")); if (Strings.isNotBlank(hdid)) { cnd.and("bm.hdid", "=", hdid); diff --git a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyGhbmController.java b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyGhbmController.java index bb1f971..e387b38 100644 --- a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyGhbmController.java +++ b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyGhbmController.java @@ -16,6 +16,7 @@ import io.v.nutz.sys.services.SysUserService; import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.lxy.model.Lxy_bm; import io.v.nutz.zhgh.lxy.model.Lxy_grxx; +import io.v.nutz.zhgh.lxy.model.Lxy_hd; import io.v.nutz.zhgh.lxy.model.Lxy_mefp; import io.v.nutz.zhgh.lxy.service.LxyBmService; import io.v.nutz.zhgh.lxy.service.LxyGrxxService; @@ -182,6 +183,7 @@ public class LxyGhbmController { Cnd cnd = Cnd.NEW(); cnd.and("member", "=", 1); cnd.and("unit.unionid", "=", unionid); + addActivityScopeCnd(cnd, "u", hdid); cnd.and(new Static("u.id NOT IN ( SELECT bm.userid FROM lxy_bm bm WHERE bm.hdid = '" + hdid + "' OR hdid = '1' ) ")); if (checks != null && checks.length > 0) { for (String check : checks) { @@ -241,6 +243,9 @@ public class LxyGhbmController { return Result.error("未获取到报名数据,请选择人员报名"); } + if (!checkActivityUserScope(bmList.get(0).getHdid(), bmList.stream().map(Lxy_bm::getUserid).collect(Collectors.toList()))) { + return Result.error("存在不在活动人员范围内的人员,请重新选择"); + } String unionId = Vi.getUnionId(); Lxy_mefp meNum = dao.fetch(Lxy_mefp.class, Cnd.where("hdid", "=", bmList.get(0).getHdid()).and("ghid", "=", unionId)); @@ -416,6 +421,7 @@ public class LxyGhbmController { List sourUserIdList = sourceList.stream().map(Lxy_bm::getUserid).collect(Collectors.toList()); String today = cn.hutool.core.date.DateUtil.today(); + Integer activityGroupId = getActivityGroupId(projectId); // 要插入的数据 List bmList = new ArrayList<>(); @@ -440,6 +446,12 @@ public class LxyGhbmController { continue; } + if (activityGroupId != null && dao.count("activity_user_scope", Cnd.where("groupId", "=", activityGroupId).and("userId", "=", user.getId())) == 0) { + temp.setRemark("此人员不在活动人员范围内"); + errorInfos.add(temp); + continue; + } + if (lastJoinUserIds.contains(user.getId())) { temp.setRemark("此教师参加过以往疗休养,请更换人员上报"); errorInfos.add(temp); @@ -506,4 +518,28 @@ public class LxyGhbmController { } } + + private void addActivityScopeCnd(Cnd cnd, String userAlias, String hdid) { + Integer activityGroupId = getActivityGroupId(hdid); + if (activityGroupId != null) { + cnd.and(new Static(userAlias + ".id IN (SELECT userId FROM activity_user_scope WHERE groupId = " + activityGroupId + ")")); + } + } + + private boolean checkActivityUserScope(String hdid, List userIds) { + Integer activityGroupId = getActivityGroupId(hdid); + if (activityGroupId == null) { + return true; + } + List ids = userIds.stream().filter(Strings::isNotBlank).distinct().collect(Collectors.toList()); + if (ids.size() != userIds.size()) { + return false; + } + return dao.count("activity_user_scope", Cnd.where("groupId", "=", activityGroupId).and("userId", "in", ids)) == ids.size(); + } + + private Integer getActivityGroupId(String hdid) { + Lxy_hd hd = lxyHdService.fetch(hdid); + return hd == null ? null : hd.getActivityGroupId(); + } } diff --git a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyGrBmController.java b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyGrBmController.java index 8e472d1..1e77890 100644 --- a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyGrBmController.java +++ b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyGrBmController.java @@ -107,6 +107,7 @@ public class LxyGrBmController { cnd.and(new Static("now() < hd.bmjzsj")); cnd.and(new Static("bm.bmlx = 2 ")); + cnd.and(new Static("(hd.activityGroupId IS NULL OR u.id IN (SELECT userId FROM activity_user_scope WHERE groupId = hd.activityGroupId))")); if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin"})) { cnd.and("u.id", "=", ShiroUtil.getPrincipalProperty("id")); diff --git a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyHdCon.java b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyHdCon.java index 2879d0c..0ad4b74 100644 --- a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyHdCon.java +++ b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyHdCon.java @@ -74,8 +74,12 @@ public class LxyHdCon { CndPlus cnd = CndPlus.create(); cnd.andEx("YEAR(hdcjsj)", "=", year); - cnd.andEx("id", "=", hdcd); - cnd.andEx("id", "=", pastQuota); + if (Strings.isNotBlank(hdcd)) { + cnd.and("id", "=", hdcd); + } + if (Strings.isNotBlank(pastQuota)) { + cnd.and("id", "=", pastQuota); + } if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) { cnd.where().andLike(searchName, searchKeyword); } @@ -94,9 +98,13 @@ public class LxyHdCon { @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) @ViReturn @RequiresPermissions("zgfw.lxy.hdmange") - public Object doAdd(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, Lxy_mefp[] mefp) throws IOException { + public Object doAdd(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, Lxy_mefp[] mefp, + @Param(value = "activityGroupId", required = false) Integer activityGroupId, + @Param(value = "activityGroupName", required = false) String activityGroupName) throws IOException { hd.setHdcjsj(new Date()); + hd.setActivityGroupId(activityGroupId); + hd.setActivityGroupName(Strings.isBlank(activityGroupName) ? "全部教职工" : activityGroupName); hd = lxyHdService.insert(hd); for (Lxy_mefp lxyMefp : mefp) { @@ -136,8 +144,16 @@ public class LxyHdCon { @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) @ViReturn @RequiresPermissions("zgfw.lxy.hdmange") - public Object doEdit(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, String[] delFiles) throws IOException { + public Object doEdit(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, String[] delFiles, + @Param(value = "activityGroupId", required = false) Integer activityGroupId, + @Param(value = "activityGroupName", required = false) String activityGroupName) throws IOException { + hd.setActivityGroupId(activityGroupId); + hd.setActivityGroupName(Strings.isBlank(activityGroupName) ? "全部教职工" : activityGroupName); lxyHdService.updateIgnoreNull(hd); + baseService.dao().update(Lxy_hd.class, + Chain.make("activityGroupId", activityGroupId) + .add("activityGroupName", hd.getActivityGroupName()), + Cnd.where("id", "=", hd.getId())); for (TempFile file : files) { String rid = R.UU32(); diff --git a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyMetjController.java b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyMetjController.java index 3b94986..996b33f 100644 --- a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyMetjController.java +++ b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyMetjController.java @@ -80,6 +80,7 @@ public class LxyMetjController { if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "SchoolUnionAdmin"})) { cnd.and(new Static("mefp.ghid in " + vi.getMangeUnionStr())); + cnd.and(new Static("(hd.activityGroupId IS NULL OR EXISTS (SELECT 1 FROM activity_user_scope aus LEFT JOIN sys_user u ON u.id = aus.userId WHERE aus.groupId = hd.activityGroupId AND u.unionid = mefp.ghid))")); } if (year != null) { @@ -141,6 +142,7 @@ public class LxyMetjController { "FROM\n" + "\tsys_user u\n" + "\tLEFT JOIN lxy_bm bm ON bm.userid = u.id AND bm.hdid = '" + hdid + "'\n" + + "\tLEFT JOIN lxy_hd hd ON hd.id = '" + hdid + "'\n" + "\tLEFT JOIN sys_unit unit ON u.unitid = unit.id\n" + "\tLEFT JOIN ry_rygl_gr ry ON ry.userid = u.id\n" + "\tLEFT JOIN sys_union un ON unit.unionid = un.id $condition"); @@ -148,6 +150,7 @@ public class LxyMetjController { Cnd cnd = Cnd.NEW(); cnd.and("unit.unionid", "=", unionid); + cnd.and(new Static("(hd.activityGroupId IS NULL OR u.id IN (SELECT userId FROM activity_user_scope WHERE groupId = hd.activityGroupId))")); if (sign == 0) { cnd.and(new Static("u.id not in (SELECT bm.userid from lxy_bm bm WHERE bm.bmlx=2 AND bm.hdid = '" + hdid + "')")); diff --git a/src/main/java/io/v/nutz/zhgh/lxy/model/Lxy_hd.java b/src/main/java/io/v/nutz/zhgh/lxy/model/Lxy_hd.java index 2050b79..8dc207c 100644 --- a/src/main/java/io/v/nutz/zhgh/lxy/model/Lxy_hd.java +++ b/src/main/java/io/v/nutz/zhgh/lxy/model/Lxy_hd.java @@ -54,6 +54,16 @@ public class Lxy_hd { @ColDefine(type = ColType.VARCHAR, width = 30) private String hdcd; + @Column + @Comment("面向对象") + @ColDefine(type = ColType.INT) + private Integer activityGroupId; + + @Column + @Comment("面向对象名称") + @ColDefine(type = ColType.VARCHAR, width = 100) + private String activityGroupName; + @Column @Comment("活动注意事项") @ColDefine(type = ColType.TEXT) diff --git a/src/main/resources/static/assets/platform/js/v.js b/src/main/resources/static/assets/platform/js/v.js index 200a4f9..2692196 100644 --- a/src/main/resources/static/assets/platform/js/v.js +++ b/src/main/resources/static/assets/platform/js/v.js @@ -305,8 +305,8 @@ const getGzzllx = async () => { * 获取疗休养活动 * @returns {Promise<*>} */ -const getLxyHd = async () => { - const { data } = await $.get("/platform/zgfw/lxy/common/getHdList") +const getLxyHd = async (year) => { + const { data } = await $.get("/platform/zgfw/lxy/common/getHdList", { year }) return data } const getlxyHdCd = async () => { @@ -314,8 +314,8 @@ const getlxyHdCd = async () => { return data } -const getNowLxyHd = async () => { - const { data } = await $.get("/platform/zgfw/lxy/common/getNowHdList") +const getNowLxyHd = async (year) => { + const { data } = await $.get("/platform/zgfw/lxy/common/getNowHdList", { year }) return data } diff --git a/src/main/resources/views/platform/zgfw/lxy/HdGhbm.html b/src/main/resources/views/platform/zgfw/lxy/HdGhbm.html index 2cf1be0..511a387 100644 --- a/src/main/resources/views/platform/zgfw/lxy/HdGhbm.html +++ b/src/main/resources/views/platform/zgfw/lxy/HdGhbm.html @@ -48,7 +48,13 @@ layout("/layouts/platform.html"){
- +
@@ -750,6 +756,11 @@ display: -webkit-box; const { data } = await $.get(base + "/platform/zgfw/lxy/fghsh/getBmInfo", { id }) return data }, + async hdSearch() { + this.lxyHd = await getNowLxyHd(this.pageForm.year) + this.pageForm.hdid = this.lxyHd.length > 0 ? this.lxyHd[0].id : "" + this.doSearch() + }, async openViewXx(row) { this.viewData = await this.getLxyBmInfo(row.id) this.pageForm.hdid = row.hdid @@ -831,8 +842,8 @@ display: -webkit-box; }, async created() { this.unions = await getUnions() - this.lxyHd = await getNowLxyHd() - this.pageForm.hdid = this.lxyHd[0].id + this.lxyHd = await getNowLxyHd(this.pageForm.year) + this.pageForm.hdid = this.lxyHd.length > 0 ? this.lxyHd[0].id : "" this.pageData() this.unionList = await getUnions() this.nationList = nation diff --git a/src/main/resources/views/platform/zgfw/lxy/HdMange.html b/src/main/resources/views/platform/zgfw/lxy/HdMange.html index b61c3ad..43b5496 100644 --- a/src/main/resources/views/platform/zgfw/lxy/HdMange.html +++ b/src/main/resources/views/platform/zgfw/lxy/HdMange.html @@ -43,12 +43,26 @@ layout("/layouts/platform.html"){
- +
-
+ +
+