Merge remote-tracking branch 'origin/main'
This commit is contained in:
+179
@@ -0,0 +1,179 @@
|
||||
package com.budwk.app.zhgh.democratic.executiveCommittee.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.democratic.executiveCommittee.models.ExecutiveCommitteeTwoPush;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2026/3/20 10:51
|
||||
* @description 正式委员录入
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/executiveCommittee/formalPush")
|
||||
@Ok("json:full")
|
||||
@Slf4j
|
||||
@Api(tags = "执委会推选-正式委员录入")
|
||||
public class ExecutiveCommitteeFormalPushController {
|
||||
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@At("/index")
|
||||
@SaCheckPermission("executiveCommittee.formalPush")
|
||||
@Ok("beetl:/platform/zhgh/democratic/executiveCommittee/formalPush/index.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("分页查询")
|
||||
@SaCheckPermission("executiveCommittee.formalPush")
|
||||
public Result pageData(PageForm pageForm,
|
||||
String teacherMeetId,
|
||||
String delegationId,
|
||||
String unionId,
|
||||
String roleCode) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.loginName,
|
||||
t2.userName,
|
||||
t3.name AS unitName,
|
||||
t4.name unionName,
|
||||
t5.sex,
|
||||
TIMESTAMPDIFF(
|
||||
YEAR,
|
||||
t5.birthday,
|
||||
CURDATE()) AS age,
|
||||
t6.name AS delegationName
|
||||
FROM
|
||||
`executive_committee_two_push` t1
|
||||
LEFT JOIN executive_committee_one_push t2 on t2.userId=t1.userId and t2.teacherMeetId=t1.teacherMeetId
|
||||
LEFT JOIN sys_unit t3 ON t2.unitId = t3.id
|
||||
LEFT JOIN `sys_union` t4 ON t4.id = t3.unionid
|
||||
LEFT JOIN `vw_user` t5 ON t5.id = t1.userId
|
||||
LEFT JOIN teacher_congress_delegation t6 ON t6.id = t2.delegationId
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("t1.teacherMeetId", "=", teacherMeetId);
|
||||
cnd.andEX("t2.delegationId", "=", delegationId);
|
||||
cnd.andEX("t1.roleCode", "=", roleCode);
|
||||
cnd.andEX("t1.isFormal", "=", true);
|
||||
if (StpUtil.hasRole(RoleConstant.SYSADMIN.name()) ||
|
||||
StpUtil.hasRole(RoleConstant.SCHOOL_UNION_ADMIN.name()) ||
|
||||
StpUtil.hasRole(RoleConstant.BRANCH_UNION_CHAIRMAN.name())) {
|
||||
cnd.andEX("t4.id", "=", unionId);
|
||||
} else {
|
||||
cnd.andEX("t4.id", "=", SecurityUtil.getUnionId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup group = new SqlExpressionGroup();
|
||||
group.orLike("t2.userName", pageForm.getSearchKeyword());
|
||||
group.orLike("t2.loginName", pageForm.getSearchKeyword());
|
||||
cnd.and(group);
|
||||
}
|
||||
cnd.asc("t6.code").asc("t2.firstLetter");
|
||||
sql.setCondition(cnd);
|
||||
return Result.success(baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("executiveCommittee.formalPush")
|
||||
@ApiOperation("查询可以推选委员和已经推选的人员")
|
||||
public Result getDelegationUser(String teacherMeetId) {
|
||||
List<ExecutiveCommitteeTwoPush> twoPushList = dao.query(ExecutiveCommitteeTwoPush.class,
|
||||
Cnd.where("teacherMeetId", "=", teacherMeetId).and(ExecutiveCommitteeTwoPush::getRoleCode, "is not", null));
|
||||
|
||||
List<ExecutiveCommitteeTwoPush> userValue = twoPushList.stream().filter(ExecutiveCommitteeTwoPush::getIsFormal).toList();
|
||||
List<String> userIds = userValue.stream().map(ExecutiveCommitteeTwoPush::getUserId).toList();
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t2.id userId,
|
||||
t2.username userName,
|
||||
t2.loginname loginName,
|
||||
t2.unitName,
|
||||
t2.sex,
|
||||
t2.professionalTitle,
|
||||
t2.professionalLevel,
|
||||
t1.roleCode,
|
||||
TIMESTAMPDIFF(
|
||||
YEAR,
|
||||
t2.birthday,
|
||||
CURDATE()) age
|
||||
FROM
|
||||
executive_committee_two_push t1
|
||||
LEFT JOIN `vw_user` t2 ON t1.userId = t2.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("t1.teacherMeetId", "=", teacherMeetId);
|
||||
cnd.andEX("t1.userId", "not in", userIds);
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> userData = baseService.listMap(sql);
|
||||
return Result.success(Map.of("userData", userData, "userValue", userValue));
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("executiveCommittee.formalPush")
|
||||
@SLog(tag = "执委会推选-正式委员录入", msg = "推选委员")
|
||||
public Result addOnePush(@Param("userValue") String[] userValue,
|
||||
String teacherMeetId) {
|
||||
try {
|
||||
if (ObjectUtil.isEmpty(userValue)) {
|
||||
return Result.error("请选择要录入的委员!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(teacherMeetId)) {
|
||||
return Result.error("请选择教代会!");
|
||||
}
|
||||
List<ExecutiveCommitteeTwoPush> twoPushList = dao.query(ExecutiveCommitteeTwoPush.class, Cnd.where(ExecutiveCommitteeTwoPush::getTeacherMeetId, "=", teacherMeetId).and(ExecutiveCommitteeTwoPush::getUserId, "in", userValue));
|
||||
List<String> ids = twoPushList.stream().map(ExecutiveCommitteeTwoPush::getId).toList();
|
||||
dao.update(ExecutiveCommitteeTwoPush.class, Chain.make("isFormal", true), Cnd.where("id", "in", ids));
|
||||
return Result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("添加失败!");
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("executiveCommittee.formalPush")
|
||||
@SLog(tag = "执委会推选-正式委员录入", msg = "删除推选的人")
|
||||
public Result doDelete(@Valid String id, @Valid String teacherMeetId) {
|
||||
dao.update(ExecutiveCommitteeTwoPush.class, Chain.make("isFormal", false), Cnd.where("id", "=", id));
|
||||
return Result.success("删除成功!");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user