diff --git a/src/main/java/com/budwk/app/sys/controller/SysUnionController.java b/src/main/java/com/budwk/app/sys/controller/SysUnionController.java index 50cffeb..e97c3dc 100644 --- a/src/main/java/com/budwk/app/sys/controller/SysUnionController.java +++ b/src/main/java/com/budwk/app/sys/controller/SysUnionController.java @@ -3,6 +3,7 @@ package com.budwk.app.sys.controller; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Dict; import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.TreeNode; import cn.hutool.core.lang.tree.TreeUtil; @@ -13,7 +14,14 @@ import com.budwk.app.base.exception.BaseException; import com.budwk.app.base.page.Pagination; import com.budwk.app.base.param.PageForm; import com.budwk.app.base.result.Result; +import com.budwk.app.base.utils.PageUtil; import com.budwk.app.bpm.service.BpmService; +import com.budwk.app.flow.constant.FlowConst; +import com.budwk.app.flow.engine.FlowEngine; +import com.budwk.app.flow.entity.ProcessInstance; +import com.budwk.app.flow.entity.ProcessTask; +import com.budwk.app.flow.enums.ProcessSubmitTypeEnum; +import com.budwk.app.flow.enums.ProcessTaskStateEnum; import com.budwk.app.sys.models.*; import com.budwk.app.sys.services.*; import com.budwk.app.sys.views.View_user; @@ -41,6 +49,7 @@ import org.nutz.mvc.annotation.Param; import javax.validation.Valid; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -71,6 +80,9 @@ public class SysUnionController { @Inject private Dao dao; + @Inject + private FlowEngine flowEngine; + @At("") @Ok("beetl:/platform/sys/union/index.html") @SaCheckPermission("sys.manager.union") @@ -319,10 +331,47 @@ public class SysUnionController { // bpmService.startSubmitProcessInstance(BpmProcessConstant.BRANCH_UNION_WEIYUAN_AUTHORIZATION.name(), instanceName, permission.getId(), List.of("24017"), null); - sysRoleService.clear("sys_user_role", Cnd.where("roleId", "=", role.getId()).and("userId", "=", userId).and("unionId", "=", unionId)); - sysRoleService.insert("sys_user_role", Chain.make("roleId", role.getId()).add("userId", userId).add("unionId", unionId)); - sysRoleService.clearCache(); - sysUserService.clearCache(); +// sysRoleService.clear("sys_user_role", Cnd.where("roleId", "=", role.getId()).and("userId", "=", userId).and("unionId", "=", unionId)); +// sysRoleService.insert("sys_user_role", Chain.make("roleId", role.getId()).add("userId", userId).add("unionId", unionId)); +// sysRoleService.clearCache(); +// sysUserService.clearCache(); + // 构建表结构存储 + View_user user = dao.fetch(View_user.class, Cnd.where("id", "=", userId)); + + Sys_union_cadre unionCadre = new Sys_union_cadre(); + unionCadre.setUserId(userId); + unionCadre.setUnionId(unionId); + unionCadre.setMobile(user.getMobile()); + unionCadre.setUnionName(user.getUnionName()); + unionCadre.setLoginName(user.getLoginname()); + unionCadre.setUserName(user.getUsername()); + unionCadre.setRoleCode(roleCode); + unionCadre.setApplyDate(new Date()); + unionCadre.setIsJoin(true); + dao.insert(unionCadre); + + // 去走工作流 + boolean isAdmin = AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name()); + Dict args = Dict.create(); + args.set("submit", isAdmin ? "admin" : "branch"); + args.set(FlowConst.SUBMIT_TYPE, ProcessSubmitTypeEnum.APPLY.getCode()); + args.set(FlowConst.FORM_DATA, unionCadre); + + ProcessInstance instance = flowEngine.startProcessInstanceByKey("JCGHWY", unionCadre.getId(), SecurityUtil.getUserId(), args); + // 自动完成第一个申请任务 + List doingTaskList = flowEngine.processTaskService().getDoingTaskList(instance.getId(), null); + for (ProcessTask task : doingTaskList) { + flowEngine.executeProcessTask(task.getId(), SecurityUtil.getUserId(), args); + } + + if (isAdmin) { + // 如果是管理员,直接加角色 + sysRoleService.clear("sys_user_role", Cnd.where("roleId", "=", role.getId()).and("userId", "=", userId).and("unionId", "=", unionId)); + sysRoleService.insert("sys_user_role", Chain.make("roleId", role.getId()).add("userId", userId).add("unionId", unionId)); + sysRoleService.clearCache(); + sysUserService.clearCache(); + } + return Result.success(); } @@ -413,4 +462,63 @@ public class SysUnionController { return Result.success(list); } + /** + * 基层干部审核相关 + */ + @At + @ApiOperation("基层干部审核菜单") + @SaCheckPermission("sys.manager.union") + public Result cadrePageData(PageForm pageForm, @Param("isJoin") Boolean isJoin) { + Sql sql = Sqls.create(""" + SELECT + info.*, + role.`name` AS roleName, + ins.id AS instanceId, + ins.businessNo, + ins.state instanceState, + ins.variable instanceVariable, + ins.processDefineId instanceProcessDefineId, + t.id taskId, + t.taskName AS taskKey, + t.displayName taskName, + t.taskType, + t.performType taskPerformType, + t.taskState, + t.finishTime, + t.taskParentId, + t.variable taskVariable, + IFNULL(GROUP_CONCAT(DISTINCT nt.displayName), '结束') curTaskName, + IF(rt.id IS NOT NULL, 1, 0) AS canRevoke + FROM + wf_process_task t + LEFT JOIN wf_process_instance ins ON ins.id = t.processInstanceId + LEFT JOIN sys_union_cadre info ON info.id = ins.businessNo + LEFT JOIN sys_role role ON role.`code` = info.roleCode + LEFT JOIN wf_process_task_actor ta ON ta.processTaskId = t.id + LEFT JOIN wf_process_task nt ON nt.processInstanceId = ins.id AND nt.taskState = 10 + LEFT JOIN wf_process_task rt ON rt.processInstanceId = ins.id AND rt.taskParentId = t.id AND rt.taskState = 10 + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("t.taskName", "=", "2978a74a-75c1-4f95-99f9-9c08c480f1b5"); + if (pageForm.getAudit()) { + cnd.and("t.taskState", "in", List.of(ProcessTaskStateEnum.FINISHED.getCode(), + ProcessTaskStateEnum.WITHDRAW.getCode(), ProcessTaskStateEnum.INTERRUPT.getCode())); + } else { + cnd.and("t.taskState", "=", ProcessTaskStateEnum.DOING.getCode()); + } + + cnd.andEX("info.isJoin", "=", isJoin); + if (StrUtil.isAllBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) { + cnd.desc("t.createdAt"); + cnd.desc("info.applyDate"); + } else { + cnd.orderBy("info." + pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy())); + } + cnd.groupBy("t.id"); + sql.setCondition(cnd); + Pagination pagination = sysUnionService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + return Result.success(pagination); + } + } diff --git a/src/main/java/com/budwk/app/sys/interceptor/SysUnionSchoolAuditInterceptor.java b/src/main/java/com/budwk/app/sys/interceptor/SysUnionSchoolAuditInterceptor.java new file mode 100644 index 0000000..39de1e1 --- /dev/null +++ b/src/main/java/com/budwk/app/sys/interceptor/SysUnionSchoolAuditInterceptor.java @@ -0,0 +1,53 @@ +package com.budwk.app.sys.interceptor; + +import cn.hutool.json.JSONUtil; +import com.budwk.app.flow.constant.FlowConst; +import com.budwk.app.flow.engine.FlowInterceptor; +import com.budwk.app.flow.engine.core.Execution; +import com.budwk.app.flow.engine.core.ServiceContext; +import com.budwk.app.flow.enums.ProcessSubmitTypeEnum; +import com.budwk.app.sys.models.Sys_role; +import com.budwk.app.sys.models.Sys_union_cadre; +import com.budwk.app.sys.services.SysRoleService; +import com.budwk.app.sys.services.SysUserService; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; + +/** + * @version 1.0 + * @Author FKY + * @name:SysUnionSchoolAuditInterceptor + * @Date 2025/10/28 10:15 + * @注释 + */ +public class SysUnionSchoolAuditInterceptor implements FlowInterceptor { + + + @Override + public void intercept(Execution execution) { + // 是否审核通过 + boolean submitType = execution.getArgs().getInt("submitType").equals(ProcessSubmitTypeEnum.AGREE.getCode()); + if (submitType) { + // 审核通过,添加相应的角色 + String formDataStr = execution.getArgs().getStr(FlowConst.FORM_DATA); + + SysRoleService sysRoleService = ServiceContext.find(SysRoleService.class); + SysUserService sysUserService = ServiceContext.find(SysUserService.class); + + // 表单数据 + Sys_union_cadre unionBean = JSONUtil.toBean(formDataStr, Sys_union_cadre.class); + + // 清除对应角色然后再新增 + Sys_role role = sysRoleService.getByCode(unionBean.getRoleCode()); + sysRoleService.clear("sys_user_role", Cnd.where("roleId", "=", role.getId()) + .and("userId", "=", unionBean.getUserId()).and("unionId", "=", unionBean.getUnionId())); + sysRoleService.insert("sys_user_role", Chain.make("roleId", role.getId()) + .add("userId", unionBean.getUserId()).add("unionId", unionBean.getUnionId())); + + // 清除缓存 + sysRoleService.clearCache(); + sysUserService.clearCache(); + } + // 未审核通过,不作操作 + } +} diff --git a/src/main/java/com/budwk/app/sys/models/Sys_union_cadre.java b/src/main/java/com/budwk/app/sys/models/Sys_union_cadre.java new file mode 100644 index 0000000..63c18fe --- /dev/null +++ b/src/main/java/com/budwk/app/sys/models/Sys_union_cadre.java @@ -0,0 +1,73 @@ +package com.budwk.app.sys.models; + +import com.budwk.app.base.model.BaseModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +import java.util.Date; + +/** + * @version 1.0 + * @Author FKY + * @name:Sys_union_cadre + * @Date 2025/10/28 10:22 + * @注释 + */ +@Data +@Table +@EqualsAndHashCode(callSuper = true) +public class Sys_union_cadre extends BaseModel { + + @Name + @Comment("ID") + @ColDefine(type = ColType.VARCHAR, width = 32) + @PrevInsert(uu32 = true) + private String id; + + @Column + @Comment("工会Id") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String unionId; + + @Column + @Comment("工会名称") + @ColDefine(type = ColType.VARCHAR, width = 100) + private String unionName; + + @Column + @Comment("用户Id") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String userId; + + @Column + @Comment("用户名称") + @ColDefine(type = ColType.VARCHAR, width = 100) + private String userName; + + @Column + @Comment("工号") + @ColDefine(type = ColType.VARCHAR, width = 20) + private String loginName; + + @Column + @Comment("联系方式") + @ColDefine(type = ColType.VARCHAR, width = 20) + private String mobile; + + @Column + @Comment("角色编码") + @ColDefine(type = ColType.VARCHAR, width = 100) + private String roleCode; + + @Column + @Comment("添加时间") + @ColDefine(type = ColType.DATETIME) + private Date applyDate; + + @Column + @Comment("加入还是退出") + @ColDefine(type = ColType.BOOLEAN) + private Boolean isJoin; +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsResultsController.java b/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsResultsController.java new file mode 100644 index 0000000..1f840c0 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsResultsController.java @@ -0,0 +1,306 @@ +package com.budwk.app.zhgh.activity.sports.controller; + +import cn.dev33.satoken.annotation.SaCheckLogin; +import cn.dev33.satoken.annotation.SaCheckPermission; +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.base.utils.DateUtil; +import com.budwk.app.base.utils.PwdUtil; +import com.budwk.app.sys.models.Sys_user; +import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.zhgh.activity.basic.models.ActivityBasicUnion; +import com.budwk.app.zhgh.activity.basic.models.ActivityBasicUnit; +import com.budwk.app.zhgh.activity.sports.models.ActivityResults; +import com.budwk.app.zhgh.activity.sports.models.ActivitySchoolApply; +import com.budwk.app.zhgh.activity.sports.service.ActivitySportsApplyUserService; +import org.nutz.dao.Cnd; +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.random.R; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; +import org.nutz.trans.Trans; + +import java.util.Arrays; + +/** + * @author zhf + * @date 2021/5/19 14:58 + * @description 运动会成绩录入 + */ +@IocBean +@Ok("json:full") +@At("/platform/activity/results/input") +public class ActivitySportsResultsController { + + @Inject + private BaseService baseService; + + @Inject + private ActivitySportsApplyUserService activitySchoolApplyViService; + + + @At("") + @Ok("beetl:platform/zhgh/activity/sports/ActivityResults/index.html") + @SaCheckPermission("activity.results.input") + public void index() { + } + + @At + @SaCheckPermission("activity.results.input") + public Result pageData(String groupName, + PageForm page, + String activityId, + String eventId, + String[] isMenWomen) { + Cnd cnd = Cnd.NEW(); + Sql sql = Sqls.create(""" + SELECT + ase.id, + ase.activityId, + ase.eventId, + ae.projectType awardsMode, + ae.allName, + ae.isMenWomen, + school.`name` , + ( SELECT COUNT( 1 ) FROM activity_results ar WHERE ar.eventId = ase.eventId and ar.activityId=ase.activityId) rs + FROM + activity_school_event ase + LEFT JOIN activity_event ae ON ase.eventId = ae.id + LEFT JOIN activity_school school ON school.id = ase.activityId + LEFT JOIN activity_basic_settings abs ON abs.id=ae.competitionCategory + $condition + """); + cnd.and("ase.activityId", "=", activityId); + cnd.andEX("abs.`name`", "=", groupName); + cnd.andEX("ae.`id`", "=", eventId); + SqlExpressionGroup sqlExpressionGroup = new SqlExpressionGroup(); + if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("2"))) { + sqlExpressionGroup.and("ae.isMenWomen", "=", 1); + } + if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("3"))) { + sqlExpressionGroup.or("ae.isMenWomen", "=", 2); + } + if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("4"))) { + sqlExpressionGroup.and("ae.projectType", "=", 1); + } + if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("5"))) { + sqlExpressionGroup.or("ae.projectType", "=", 2); + } + if (sqlExpressionGroup.getExps().size() > 0) { + cnd.and(sqlExpressionGroup); + } + cnd.desc("allName"); + sql.setCondition(cnd); + return Result.success(baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql)); + } + + + @At + @SaCheckPermission("activity.results.input") + public Result doAdd(@Param(value = "activityResults") ActivityResults[] activityResults, String activityId, String eventId) { + + baseService.dao().clear(ActivityResults.class, Cnd.where("activityId", "=", activityId).and("eventId", "=", eventId)); + baseService.insert(activityResults); + + return Result.success(); + } + + @At + @SaCheckPermission("activity.results.input") + public Result doAddUser(ActivitySchoolApply activitySchoolApply) { + + + Sys_user sysUser = baseService.dao().fetch(Sys_user.class, Cnd.where("loginname", "=", activitySchoolApply.getLoginname())); + + + if (sysUser != null && sysUser.getLoginname().equals(activitySchoolApply.getLoginname()) && !sysUser.getUsername().equals(activitySchoolApply.getUsername())) { + return Result.error("工号已存在,请检查姓名和工号是否一致!"); + } + if (sysUser == null) { + Trans.exec(() -> { + String pwd = "@dd3s#3618!"; + String salt = R.UU32(); + Sys_user user = new Sys_user(); + user.setId(R.UU32()); + user.setSalt(R.UU32()); + user.setPassword(PwdUtil.getPassword(pwd, salt)); + user.setUsername(activitySchoolApply.getUsername()); + user.setLoginname(activitySchoolApply.getLoginname()); + user.setSex(activitySchoolApply.getSex()); + user.setUnitId(activitySchoolApply.getUnitId()); + user.setMobile(activitySchoolApply.getMobile()); + baseService.insert(user); + ActivityBasicUnit activityBasicUnit = activitySchoolApplyViService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", user.getUnitId())); + ActivityBasicUnion basicUnion = activitySchoolApplyViService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", activityBasicUnit.getUnionId())); + + activitySchoolApply.setUserId(user.getId()); + activitySchoolApply.setApplyDate(DateUtil.getDate()); + activitySchoolApply.setSex(user.getSex()); + activitySchoolApply.setUnitId(user.getUnitId()); + activitySchoolApply.setActivityUnionId(basicUnion.getId()); + activitySchoolApply.setActivityUnionName(basicUnion.getName()); + activitySchoolApplyViService.insert(activitySchoolApply); + }); + return null; + } + sysUser.setSex(activitySchoolApply.getSex()); + baseService.update(sysUser); + ActivityBasicUnit activityBasicUnit = activitySchoolApplyViService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", sysUser.getUnitId())); + ActivityBasicUnion basicUnion = activitySchoolApplyViService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", activityBasicUnit.getUnionId())); + activitySchoolApply.setUserId(sysUser.getId()); + activitySchoolApply.setApplyUser(SecurityUtil.getUserId()); + activitySchoolApply.setApplyDate(DateUtil.getDate()); + activitySchoolApply.setUnitId(sysUser.getUnitId()); + activitySchoolApply.setActivityUnionId(basicUnion.getId()); + activitySchoolApply.setActivityUnionName(basicUnion.getName()); + activitySchoolApplyViService.insert(activitySchoolApply); + + return Result.success(); + } + + + /** + * 查询个人参赛人员 + * + * @param activityId + * @param eventId + * @param isMenWomen + * @return + */ + + @At + @SaCheckPermission("activity.results.input") + public Result getUserList(String activityId, + String eventId, + Integer isMenWomen) { + Cnd cnd = Cnd.NEW(); + Sql sql = Sqls.create(""" + SELECT + u.id,u.username,u.loginname,u.unionId, + u.unionname,u.sex + FROM + activity_school_apply asa + LEFT JOIN `vw_user` u ON u.id = asa.userId $condition + """); + + cnd.and("asa.activityId", "=", activityId); + cnd.and("asa.eventId", "=", eventId); + cnd.and("asa.awardsMode", "=", 1); + if (isMenWomen != null && isMenWomen == 1) cnd.and("u.sex", "=", "男性"); + if (isMenWomen != null && isMenWomen == 2) cnd.and("u.sex", "=", "女性"); + sql.setCondition(cnd); + return Result.success(activitySchoolApplyViService.listMap(sql)); + } + + @At + @SaCheckPermission("activity.results.input") + public Result getUnionDetails(String activityId, String eventId, String unionId) { + int count = activitySchoolApplyViService.count(Cnd.where("activityId", "=", activityId).and("eventId", "=", eventId).and("unionId", "=", unionId)); + return Result.success(count); + } + + + /** + * 查询团体参赛分工会 + * + * @param activityId + * @param eventId + * @return + */ + + @At + @SaCheckLogin + public Result getUnionList(String activityId, + String eventId) { + Sql sql = Sqls.create(""" + + SELECT + un.id, + un.unionname + FROM + activity_school_apply asa + LEFT JOIN sys_union un ON un.id = asa.unionId + WHERE + asa.activityId = @activityId + AND asa.eventId = @eventId + + GROUP BY + un.unionname + """).setParam("activityId", activityId).setParam("eventId", eventId); + return Result.success(activitySchoolApplyViService.list(sql)); + } + + + /** + * 根据活动项目性别查询有没有获奖人员 + * + * @return + */ + + @At + @SaCheckPermission("activity.results.input") + public Result getUserData(String activityId, + String eventId, + Integer isMenWomen) { + Cnd cnd = Cnd.NEW(); + Sql sql = Sqls.create(""" + SELECT + ar.id, + ar.userId, + ar.activityId, + ar.eventId, + u.username, + u.unionId unionId, + u.unionname, + u.sex, + ar.integral, + ar.numberOfPeople, + ar.ranking, + ar.isTeamPersonal + FROM + `activity_results` ar + LEFT JOIN `vw_user` u ON ar.userId = u.id $condition + """); + cnd.and("ar.activityId", "=", activityId); + cnd.and("ar.eventId", "=", eventId); + if (isMenWomen != null && isMenWomen == 1) cnd.and("u.sex", "=", "男性"); + if (isMenWomen != null && isMenWomen == 2) cnd.and("u.sex", "=", "女性"); + cnd.asc("ar.ranking"); + sql.setCondition(cnd); + return Result.success(baseService.listMap(sql)); + } + + + @At + @SaCheckPermission("activity.results.input") + public Result getUnionData(String activityId, + String eventId) { + Sql sql = Sqls.create(""" + SELECT + ar.id, + ar.activityId, + ar.eventId, + ar.ranking, + ar.unionId, + ar.numberOfPeople, + ar.integral, + ar.isTeamPersonal + FROM + activity_results ar + WHERE + ar.isTeamPersonal = 2 + AND ar.activityId = @activityId + AND ar.eventId = @eventId + ORDER BY ar.ranking asc + """).setParam("activityId", activityId).setParam("eventId", eventId); + return Result.success(baseService.listMap(sql)); + } + + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsScoreStatisticsController.java b/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsScoreStatisticsController.java new file mode 100644 index 0000000..74b6d64 --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsScoreStatisticsController.java @@ -0,0 +1,603 @@ +package com.budwk.app.zhgh.activity.sports.controller; + +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; +import cn.dev33.satoken.annotation.SaCheckLogin; +import cn.dev33.satoken.annotation.SaCheckPermission; +import com.budwk.app.base.result.Result; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.base.utils.CommonDownloadUtil; +import com.budwk.app.sys.models.Sys_union; +import com.budwk.app.sys.services.SysUnionService; +import com.budwk.app.zhgh.activity.sports.models.ActivitySchool; +import com.budwk.app.zhgh.activity.sports.models.ActivitySchoolEvent; +import org.apache.poi.ss.usermodel.Workbook; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.entity.Record; +import org.nutz.dao.sql.Sql; +import org.nutz.dao.util.cri.Static; +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 javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +/** + * @author zhf + * @date 2021/5/24 14:12 + * @description 运动会成绩统计 + */ +@IocBean +@Ok("json:full") +@At("/platform/activity/score/statistics") +public class ActivitySportsScoreStatisticsController { + + @Inject + private SysUnionService sysUnionService; + + @Inject + private BaseService baseService; + + +// @Inject +// private OfficeTemplateUtil officeTemplateUtil; + + + @At("") + @Ok("beetl:platform/zhgh/activity/sports/scoreStatistics/index.html") + @SaCheckPermission("activity.score.statistics") + public void index() { + } + + @At + @SaCheckLogin + public Result isMaleFemale(String activityId, String sex, Integer awardsMode) { + + NutMap map = new NutMap(); + List result = new ArrayList<>(); + + //查询所有的工会 + List query = sysUnionService.query(); + Cnd cndX = Cnd.NEW(); + //查询所有的项目 + Sql sqlX = Sqls.create(""" + SELECT + ev.id, + ev.eventId, + ba.`name` baname, + eve.projectType awardsMode, + eve.allName label, + eve.isMenWomen + FROM + activity_school_event ev + LEFT JOIN activity_event eve ON ev.eventId = eve.id + LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition + """); + cndX.and("ev.activityId", "=", activityId); + if (awardsMode < 3) { + cndX.and("eve.projectType", "=", awardsMode); + cndX.and("eve.isInterest", "=", false); + cndX.and("eve.isMenWomen", "=", sex.equals("男性") ? 1 : 2); + } + if (awardsMode == 3) { + cndX.and("eve.isInterest", "=", true); + } + if (awardsMode == 4) { + cndX.and(Cnd.exps("eve.isMenWomen", "=", sex.equals("男性") ? 1 : 2).or("eve.isMenWomen", "is", null)); + } + cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end")); + sqlX.setCondition(cndX); + List eventList = baseService.list(sqlX); + + //查询每个工会下每个项目的成绩 + for (Sys_union sys_union : query) { + NutMap nutMap = new NutMap(); + //记录总积分 + double totalScore = 0; + nutMap.setv("unionname", sys_union.getName()); + for (Record event : eventList) { + Sql sqlC = Sqls.create(""" + SELECT + IF ( sum( integral ) IS NULL, 0, sum( integral )) AS integral, + ev.allName,ev.projectType,abs.`name` AS zb,ev.isInterest + FROM + activity_results ar + LEFT JOIN activity_event ev ON ar.eventId = ev.id + LEFT JOIN activity_basic_settings abs ON abs.id=ev.competitionCategory $condition + """); + Cnd cndC = Cnd.NEW(); + if ((awardsMode == 1 && event.getString("awardsMode").equals("1")) || (awardsMode == 2 && event.getString("awardsMode").equals("2"))) { + cndC.and("ev.isInterest", "=", false); + cndC.and("ev.isMenWomen", "=", sex.equals("男性") ? 1 : 2); + } else if (awardsMode == 3) { + cndC.and("ev.isInterest", "=", true); + } else if (awardsMode == 4) { + cndC.and(Cnd.exps("ev.isMenWomen", "=", sex.equals("男性") ? 1 : 2).or("ev.isMenWomen", "is", null)); + } + cndC.and("ar.eventId", "=", event.getString("eventid")); + cndC.and("ar.unionid", "=", sys_union.getId()); + cndC.and("ar.activityId", "=", activityId); + sqlC.setCondition(cndC); + Double score = 0.0; + List list = baseService.listMap(sqlC); + boolean isInterest = list.get(0).getBoolean("isInterest"); + + if (list.size() > 0) { + score = list.get(0).getDouble("integral"); + } + + if (list.get(0).getString("allName") != null) { + if (!isInterest) { + nutMap.setv(list.get(0).getString("allName"), score); + } else { + nutMap.setv(list.get(0).getString("allName"), score / 2); + } + } + totalScore += isInterest ? (score / 2) : score; + if (list.get(0).getString("zb") != null) { + nutMap.setv("projectType", list.get(0).getString("projectType")); + nutMap.setv("zb", list.get(0).getString("zb")); + } + } + nutMap.setv("totalScore", totalScore); + result.add(nutMap); + } + + map.put("score", result); + map.put("eventList", eventList); + return Result.success(map); + + } + + + @At + @SaCheckLogin + public Result isTopEight(String activityId, String sex, Integer awardsMode) { + NutMap map = new NutMap(); + Cnd cndX = Cnd.NEW(); + //查询所有的项目 + Sql sqlX = Sqls.create(""" + SELECT + ev.id, + ev.eventId, + ba.`name` baname, + eve.projectType awardsMode, + eve.allName label + FROM + activity_school_event ev + LEFT JOIN activity_event eve ON ev.eventId = eve.id + LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition + """); + cndX.and("ev.activityId", "=", activityId); + if (awardsMode == 1) { + cndX.and("eve.isMenWomen", "!=", sex.equals("男性") ? 2 : 1); + cndX.and("eve.projectType", "=", 1); + + } else { + cndX.and("eve.projectType", "=", 2); + } + cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end")); + sqlX.setCondition(cndX); + List eventList = baseService.list(sqlX); + + + Sql sqlC = Sqls.create(""); + Cnd cnd = Cnd.NEW(); + if (awardsMode == 1) { + sqlC = Sqls.create(""" + SELECT + CONCAT( apply.username, '(', apply.activityUnionName, ')' ) username, + ar.integral, + ar.ranking, + eve.allName + FROM + activity_results ar + LEFT JOIN activity_event eve ON ar.eventId = eve.id + LEFT JOIN activity_school_apply apply ON apply.userId = ar.userId + AND ar.activityId = apply.activityId $condition + """); + cnd.and("ar.isTeamPersonal", "=", awardsMode); + cnd.and("apply.sex", "=", sex); + cnd.and("ar.activityId", "=", activityId); + cnd.and("ar.ranking", "<=", 8); + cnd.groupBy("ar.id"); + } else { + sqlC = Sqls.create(""" + SELECT + CONCAT(sun.name) username, + eve.allName,ar.ranking + FROM + activity_results ar + LEFT JOIN activity_event eve ON ar.eventId = eve.id + LEFT JOIN sys_union sun ON sun.id = ar.unionId $condition + """); + cnd.and("ar.isTeamPersonal", "=", awardsMode); + cnd.and("ar.activityId", "=", activityId); + cnd.and("ar.ranking", "<=", 8); + + + } + + sqlC.setCondition(cnd); + List list = baseService.list(sqlC); + + map.put("userList", list); + map.put("eventList", eventList); + return Result.success(map); + } + + @At + @SaCheckLogin + public Result getActivitys(Integer year) { + List schoolList = baseService.dao().query(ActivitySchool.class, Cnd.where("YEAR(applyEndTime)", "=", year)); + return Result.success(schoolList); + } + + + @At + @SaCheckLogin + public Result isScoreTopEight(String activityId, String sex) { + + NutMap map = new NutMap(); + List result = new ArrayList<>(); + Cnd cndX = Cnd.NEW(); + //查询所有的项目 + Sql sqlX = Sqls.create(""" + SELECT + ev.id, + ev.eventId, + ba.`name` baname, + eve.projectType awardsMode, + eve.allName label + FROM + activity_school_event ev + LEFT JOIN activity_event eve ON ev.eventId = eve.id + LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition + """); + cndX.and("ev.activityId", "=", activityId); + cndX.and(Cnd.exps("eve.isMenWomen", "=", sex.equals("男性") ? 1 : 2).or("eve.isMenWomen", "is", null)); + cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end")); + sqlX.setCondition(cndX); + List eventList = baseService.list(sqlX); + + //查询所有的工会 + List query = sysUnionService.query(); + + for (Sys_union sys_union : query) { + NutMap nutMap = new NutMap(); + + //记录总积分 + double totalScore = 0; + nutMap.setv("unionname", sys_union.getName()); + for (Record event : eventList) { + Sql sqlC = Sqls.create(""" + SELECT + IF ( sum( integral ) IS NULL, 0, sum( integral )) AS integral, + ev.allName,ev.isInterest + FROM + activity_results ar + LEFT JOIN activity_event ev ON ar.eventId = ev.id $condition + """); + Cnd cndC = Cnd.NEW(); + cndC.and(Cnd.exps("ev.isMenWomen", "=", sex.equals("男性") ? 1 : 2).or("ev.isMenWomen", "is", null)); + cndC.and("ar.unionid", "=", sys_union.getId()); + cndC.and("ar.eventId", "=", event.getString("eventid")); + cndC.and("ar.activityId", "=", activityId); + sqlC.setCondition(cndC); + Double score = 0.0; + List list = baseService.listMap(sqlC); + boolean isInterest = list.get(0).getBoolean("isInterest"); + if (list.size() > 0) { + score = list.get(0).getDouble("integral"); + } + totalScore += isInterest ? (score / 2) : score; + + } + nutMap.setv("totalScore", totalScore); + result.add(nutMap); + + } + + map.put("score", result); + return Result.success(map); + } + + + @At + @SaCheckLogin + public Result getAnnualResults(Integer year) { + + ArrayList resultMap = new ArrayList<>(); + + + Dao dao = sysUnionService.dao(); + List unionList = sysUnionService.query(); + List activitySchoolList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year)); + + List labelList = activitySchoolList.stream().map(v -> v.getName()).collect(Collectors.toList()); + labelList.add(0, "分工会"); + + unionList.forEach(u -> { + NutMap unionMap = Lang.obj2nutmap(u); + AtomicReference scoreSum = new AtomicReference<>((double) 0); + activitySchoolList.forEach(x -> { + Sql sql = Sqls.create(""" + SELECT sum(integral) as sumScore FROM `activity_results` ar + where ar.activityId = @activityId and ar.unionId = @unionId + """); + sql.setParam("activityId", x.getId()); + sql.setParam("unionId", u.getId()); + sql.setCallback(Sqls.callback.map()); + dao.execute(sql); + NutMap scoreMap = (NutMap) sql.getResult(); + double score = scoreMap.getDouble("sumScore"); + scoreSum.updateAndGet(v -> v + score); + unionMap.put(x.getName(), score); + }); + unionMap.put("总分", scoreSum.get()); + unionMap.put("分工会", unionMap.getString("unionname")); + resultMap.add(unionMap); + }); + labelList.add("总分"); + + return Result.success(Map.of("label", labelList, "score", resultMap)); + + } + + @At + @SaCheckLogin + public Result getYear8(Integer isMenWomen, Integer year) { + ArrayList resultMap = new ArrayList<>(); + + // int isMenWomen = sex.equals("男性") ? 1 : 2; + + Dao dao = sysUnionService.dao(); + List unionList = sysUnionService.query(); + + List activityList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year)); + List activityIdList = activityList.stream().map(ActivitySchool::getId).collect(Collectors.toList()); + List activityNameList = activityList.stream().map(ActivitySchool::getName).collect(Collectors.toList()); + + List eventIdList = dao.query(ActivitySchoolEvent.class, Cnd.where("activityId", "in", activityIdList)).stream().map(v -> v.getEventId()).collect(Collectors.toList()); + + activityNameList.add(0, "分工会"); + + Sql sql = Sqls.create(""" + SELECT + ae.isMenWomen, + ae.isInterest, + ar.integral, + ar.unionId, + ar.activityId + FROM + activity_event ae + LEFT JOIN activity_results ar ON ar.eventId = ae.id + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("ae.id", "in", eventIdList); + cnd.and("ar.activityId", "in", activityIdList); + + sql.setCondition(cnd); + sql.setCallback(Sqls.callback.maps()); + dao.execute(sql); + List list = sql.getList(NutMap.class); + + unionList.forEach(u -> { + NutMap unionMap = Lang.obj2nutmap(u); + AtomicReference scoreSum = new AtomicReference<>((double) 0); + + activityList.forEach(a -> { + double sexScore = list.stream().filter(x -> x.getString("unionId").equals(u.getId()) && x.getInt("isMenWomen") == isMenWomen && x.getString("activityId").equals(a.getId())).mapToDouble(h -> h.getDouble("integral")).sum(); + double qwScore = list.stream().filter(x -> x.getString("unionId").equals(u.getId()) && x.getInt("isInterest") == 1 && x.getString("activityId").equals(a.getId())).mapToDouble(h -> h.getDouble("integral")).sum(); + scoreSum.updateAndGet(v -> v + sexScore + qwScore * 0.5); + unionMap.put(a.getName(), sexScore + (qwScore * 0.5)); + }); + unionMap.put("总分", scoreSum.get()); + unionMap.put("分工会", unionMap.getString("unionname")); + resultMap.add(unionMap); + + }); + activityNameList.add("总分"); + return Result.success(Map.of("label", activityNameList, "score", resultMap)); + + } + + + @At + @SaCheckLogin + @Ok("void") + public void doGetYear8(HttpServletResponse response, Integer isMenWomen, Integer year) throws Exception { + List result = new ArrayList<>(); + + List unionList = sysUnionService.query(); + + unionList.forEach(u -> { + NutMap nutMap = new NutMap(); + nutMap.setv("unionname", u.getName()); + double score = 0; + for (int i = 1; i <= 2; i++) { + Sql sql = Sqls.create(""" + SELECT + SUM( ar.integral ) score + FROM + activity_results ar + LEFT JOIN activity_event eve ON ar.eventId = eve.id + LEFT JOIN activity_school `as` ON `as`.id = ar.activityId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("YEAR ( `as`.applyStartTime )", "=", year); + cnd.and("ar.unionId", "=", u.getId()); + if (i == 1) { + cnd.and("eve.isMenWomen", "=", isMenWomen); + sql.setCondition(cnd); + List list = baseService.listMap(sql); + score += list.get(0).getDouble("score"); + } else { + cnd.and("eve.isInterest", "=", 1); + sql.setCondition(cnd); + List list = baseService.listMap(sql); + score += list.get(0).getDouble("score") * 0.5; + } + } + nutMap.setv("score", score); + result.add(nutMap); + }); + List scoreList = result.stream().sorted(Comparator.comparing(ActivitySportsScoreStatisticsController::getDouble).reversed()).collect(Collectors.toList()).subList(0, 8); + + for (int i = 0; i < scoreList.size(); i++) { + scoreList.get(i).put("ranking", i + 1); + } + + + /* HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); + Configure config = Configure.newBuilder().bind("scoreList", policy).build(); + HashMap map = new HashMap<>(); + map.put("year", year); + map.put("sex", isMenWomen == 1 ? '男性' : '女'); + map.put("scoreList", scoreList); + String fileName = "%s年运动会%s子积分表".formatted(year, isMenWomen == 1 ? '男性' : '女'); + + response.addHeader("Content-Type", "application/octet-stream"); + response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\".docx"); + XWPFTemplate.compile(officeTemplateUtil.getPath("activity_getYear8"), config).render(map).writeAndClose(response.getOutputStream());*/ + } + + public static Double getDouble(NutMap o) { + return o.getDouble("score"); + } + + @At + @Ok("void") + @SaCheckLogin + public void doExport8ByActivity(HttpServletResponse response, String activityId, Integer isMenWomen) throws Exception { + List result = new ArrayList<>(); + + List unionList = sysUnionService.query(); + unionList.forEach(u -> { + NutMap nutMap = new NutMap(); + nutMap.setv("unionname", u.getName()); + double score = 0; + for (int i = 1; i <= 2; i++) { + Sql sql = Sqls.create(""" + SELECT + SUM( ar.integral ) score + FROM + activity_results ar + LEFT JOIN activity_event eve ON ar.eventId = eve.id + LEFT JOIN activity_school `as` ON `as`.id = ar.activityId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("activityId", "=", activityId); + cnd.and("ar.unionId", "=", u.getId()); + if (i == 1) { + cnd.and("eve.isMenWomen", "=", isMenWomen); + sql.setCondition(cnd); + List list = baseService.listMap(sql); + score += list.get(0).getDouble("score"); + } else { + cnd.and("eve.isInterest", "=", 1); + sql.setCondition(cnd); + List list = baseService.listMap(sql); + score += list.get(0).getDouble("score") * 0.5; + } + } + nutMap.setv("score", score); + result.add(nutMap); + }); + List scoreList = result.stream().sorted(Comparator.comparing(ActivitySportsScoreStatisticsController::getDouble).reversed()).collect(Collectors.toList()).subList(0, 8); + + for (int i = 0; i < scoreList.size(); i++) { + scoreList.get(i).put("ranking", i + 1); + } + + /*HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); + Configure config = Configure.newBuilder().bind("scoreList", policy).build(); + HashMap map = new HashMap<>(); + map.put("sex", isMenWomen == 1 ? '男性' : '女'); + map.put("scoreList", scoreList); + String fileName = "%s子积分表".formatted(isMenWomen == 1 ? '男性' : '女'); + + response.addHeader("Content-Type", "application/octet-stream"); + response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\".docx"); + XWPFTemplate.compile(officeTemplateUtil.getPath("activity_getYear8"), config).render(map, response.getOutputStream());*/ + } + + + @At + @Ok("void") + @SaCheckLogin + public void doExcelCj(String activityId, String unionId, HttpServletResponse response) throws IOException { + + Sql sql = Sqls.create(""" + SELECT + un.unioncode, + un.unionname, + us.loginname, + us.username, + us.sex, + eve.projectCode, + abs.`name` competitionCategoryName, + eve.allName, + ar.integral, + CEILING( + IF + ( us.loginname IS NOT NULL, ar.integral, ar.integral / 2 )) jf, + ar.ranking + FROM + activity_results ar + LEFT JOIN activity_event eve ON ar.eventId = eve.id + LEFT JOIN activity_basic_settings abs ON abs.id = eve.competitionCategory + LEFT JOIN activity_school_apply apply ON apply.userId = ar.userId + AND ar.activityId = apply.activityId + LEFT JOIN sys_union un ON un.id = ar.unionId + LEFT JOIN sys_user us ON us.id = ar.userId + $condition + ORDER BY + un.unioncode ASC, + us.sex DESC, + FIELD( abs.`name`, '甲组', '乙组', '丙组', '丁组', '团体' ) ASC + """); + Cnd cnd = Cnd.NEW(); + cnd.and("ar.activityId", "=", activityId); + cnd.andEX("ar.unionId", "=", unionId); + cnd.groupBy("ar.id"); + sql.setCondition(cnd); + + List list = baseService.listMap(sql); + List entityList = new ArrayList<>(); + entityList.add(new ExcelExportEntity("分工会代码", "unioncode", 40)); + entityList.add(new ExcelExportEntity("分工会名称", "unionname", 20)); + entityList.add(new ExcelExportEntity("工号", "loginname", 20)); + entityList.add(new ExcelExportEntity("姓名", "username", 20)); + entityList.add(new ExcelExportEntity("性别", "sex", 20)); + entityList.add(new ExcelExportEntity("项目代码", "projectCode", 20)); + entityList.add(new ExcelExportEntity("组别", "competitionCategoryName", 20)); + entityList.add(new ExcelExportEntity("项目名称", "allName", 40)); + entityList.add(new ExcelExportEntity("成绩", "integral", 20)); + entityList.add(new ExcelExportEntity("名次", "ranking", 20)); + entityList.add(new ExcelExportEntity("积分", "jf", 20)); + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, list); + CommonDownloadUtil.download("成绩名单.xlsx", workbook, response); + } + + +} diff --git a/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsStatisticsTypeExportController.java b/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsStatisticsTypeExportController.java new file mode 100644 index 0000000..b987baa --- /dev/null +++ b/src/main/java/com/budwk/app/zhgh/activity/sports/controller/ActivitySportsStatisticsTypeExportController.java @@ -0,0 +1,487 @@ +package com.budwk.app.zhgh.activity.sports.controller; + + +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; +import cn.dev33.satoken.annotation.SaCheckLogin; +import com.budwk.app.base.service.BaseService; +import com.budwk.app.base.utils.CommonDownloadUtil; +import com.budwk.app.sys.models.Sys_union; +import com.budwk.app.sys.services.SysUnionService; +import com.budwk.app.zhgh.activity.sports.models.ActivitySchool; +import com.budwk.app.zhgh.activity.sports.models.ActivitySchoolEvent; +import org.apache.poi.ss.usermodel.Workbook; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.Sqls; +import org.nutz.dao.entity.Record; +import org.nutz.dao.sql.Sql; +import org.nutz.dao.util.cri.Static; +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 javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +@IocBean +@Ok("json:full") +@At("/platform/activity/statistics/export") +public class ActivitySportsStatisticsTypeExportController { + + @Inject + private SysUnionService sysUnionService; + + @Inject + private BaseService baseService; + + @Ok("void") + @At + @SaCheckLogin + public void getYear8(Integer isMenWomen, Integer year, HttpServletResponse response) { + ArrayList resultMap = new ArrayList<>(); + List unionList = sysUnionService.query(); + + List activityList = baseService.dao().query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year)); + List activityIdList = activityList.stream().map(ActivitySchool::getId).collect(Collectors.toList()); + List activityNameList = activityList.stream().map(ActivitySchool::getName).collect(Collectors.toList()); + + List eventIdList = baseService.dao().query(ActivitySchoolEvent.class, Cnd.where("activityId", "in", activityIdList)).stream().map(v -> v.getEventId()).collect(Collectors.toList()); + + activityNameList.add(0, "分工会"); + + Sql sql = Sqls.create(""" + SELECT + ae.isMenWomen, + ae.isInterest, + ar.integral, + ar.unionId, + ar.activityId + FROM + activity_event ae + LEFT JOIN activity_results ar ON ar.eventId = ae.id + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("ae.id", "in", eventIdList); + cnd.and("ar.activityId", "in", activityIdList); + + sql.setCondition(cnd); + List list = baseService.listMap(sql); + unionList.forEach(u -> { + NutMap unionMap = Lang.obj2nutmap(u); + AtomicReference scoreSum = new AtomicReference<>((double) 0); + + activityList.forEach(a -> { + double sexScore = list.stream().filter(x -> x.getString("unionId").equals(u.getId()) && x.getInt("isMenWomen") == isMenWomen && x.getString("activityId").equals(a.getId())).mapToDouble(h -> h.getDouble("integral")).sum(); + double qwScore = list.stream().filter(x -> x.getString("unionId").equals(u.getId()) && x.getInt("isInterest") == 1 && x.getString("activityId").equals(a.getId())).mapToDouble(h -> h.getDouble("integral")).sum(); + scoreSum.updateAndGet(v -> v + (sexScore + (qwScore * 0.5))); + unionMap.put(a.getName(), sexScore + (qwScore * 0.5)); + }); + unionMap.put("总分", scoreSum.get()); + unionMap.put("分工会", unionMap.getString("unionname")); + resultMap.add(unionMap); + + }); + activityNameList.add("总分"); + + resultMap.sort(Comparator.comparing((Map m) -> (new BigDecimal(m.get("总分").toString()))).reversed()); + for (int i = 0; i < resultMap.size(); i++) { + resultMap.get(i).put("名次", i + 1); + } + List entityList = new ArrayList<>(); + entityList.add(new ExcelExportEntity("名次", "名次", 20)); + activityNameList.forEach(v -> { + entityList.add(new ExcelExportEntity(v, v, 40)); + }); + try { + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, resultMap); + CommonDownloadUtil.download("年度" + (isMenWomen == 1 ? "男子" : "女子") + "团体总分.xlsx", workbook, response); + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + + @Ok("void") + @At + @SaCheckLogin + public void getAnnualResults(Integer year, HttpServletResponse response) { + ArrayList resultMap = new ArrayList<>(); + + + Dao dao = sysUnionService.dao(); + List unionList = sysUnionService.query(); + List activitySchoolList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year)); + + List labelList = activitySchoolList.stream().map(v -> v.getName()).collect(Collectors.toList()); + labelList.add(0, "分工会"); + + unionList.forEach(u -> { + NutMap unionMap = Lang.obj2nutmap(u); + AtomicReference scoreSum = new AtomicReference<>((double) 0); + activitySchoolList.forEach(x -> { + Sql sql = Sqls.create(""" + SELECT sum(integral) as sumScore FROM `activity_results` ar + where ar.activityId = @activityId and ar.unionId = @unionId + """); + sql.setParam("activityId", x.getId()); + sql.setParam("unionId", u.getId()); + sql.setCallback(Sqls.callback.map()); + dao.execute(sql); + NutMap scoreMap = (NutMap) sql.getResult(); + double score = scoreMap.getDouble("sumScore"); + scoreSum.updateAndGet(v -> v + score); + unionMap.put(x.getName(), score); + }); + unionMap.put("总分", scoreSum.get()); + unionMap.put("分工会", unionMap.getString("unionname")); + resultMap.add(unionMap); + }); + labelList.add("总分"); + + resultMap.sort(Comparator.comparing((Map m) -> (new BigDecimal(m.get("总分").toString()))).reversed()); + for (int i = 0; i < resultMap.size(); i++) { + resultMap.get(i).put("名次", i + 1); + } + + List entityList = new ArrayList<>(); + entityList.add(new ExcelExportEntity("名次", "名次", 20)); + labelList.forEach(v -> { + entityList.add(new ExcelExportEntity(v, v, 40)); + + }); + try { + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, resultMap); + CommonDownloadUtil.download("年度团体总分.xlsx", workbook, response); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + + @At + @Ok("void") + public void isMaleFemale(String activityId, String sex, Integer awardsMode, HttpServletResponse response) { + NutMap map = new NutMap(); + List result = new ArrayList<>(); + + //查询所有的工会 + List query = sysUnionService.query(); + Cnd cndX = Cnd.NEW(); + //查询所有的项目 + Sql sqlX = Sqls.create(""" + SELECT + ev.id, + ev.eventId, + ba.`name` baname, + eve.projectType awardsMode, + eve.allName label, + eve.isMenWomen + FROM + activity_school_event ev + LEFT JOIN activity_event eve ON ev.eventId = eve.id + LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition + """); + cndX.and("ev.activityId", "=", activityId); + if (awardsMode < 3) { + cndX.and("eve.projectType", "=", awardsMode); + cndX.and("eve.isInterest", "=", false); + cndX.and("eve.isMenWomen", "=", sex.equals("男性") ? 1 : 2); + } + if (awardsMode == 3) { + cndX.and("eve.isInterest", "=", true); + } + if (awardsMode == 4) { + cndX.and(Cnd.exps("eve.isMenWomen", "=", sex.equals("男性") ? 1 : 2).or("eve.isMenWomen", "is", null)); + } + cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end")); + sqlX.setCondition(cndX); + List eventList = baseService.list(sqlX); + + //查询每个工会下每个项目的成绩 + for (Sys_union sys_union : query) { + NutMap nutMap = new NutMap(); + //记录总积分 + double totalScore = 0; + nutMap.setv("unionname", sys_union.getName()); + for (Record event : eventList) { + Sql sqlC = Sqls.create(""" + SELECT + IF ( sum( integral ) IS NULL, 0, sum( integral )) AS integral, + ev.allName,ev.projectType,abs.`name` AS zb,ev.isInterest + FROM + activity_results ar + LEFT JOIN activity_event ev ON ar.eventId = ev.id + LEFT JOIN activity_basic_settings abs ON abs.id=ev.competitionCategory $condition + """); + Cnd cndC = Cnd.NEW(); + if ((awardsMode == 1 && event.getString("awardsMode").equals("1")) || (awardsMode == 2 && event.getString("awardsMode").equals("2"))) { + cndC.and("ev.isInterest", "=", false); + cndC.and("ev.isMenWomen", "=", sex.equals("男性") ? 1 : 2); + } else if (awardsMode == 3) { + cndC.and("ev.isInterest", "=", true); + } else if (awardsMode == 4) { + cndC.and(Cnd.exps("ev.isMenWomen", "=", sex.equals("男性") ? 1 : 2).or("ev.isMenWomen", "is", null)); + } + cndC.and("ar.eventId", "=", event.getString("eventid")); + cndC.and("ar.unionid", "=", sys_union.getId()); + cndC.and("ar.activityId", "=", activityId); + sqlC.setCondition(cndC); + Double score = 0.0; + List list = baseService.listMap(sqlC); + boolean isInterest = list.get(0).getBoolean("isInterest"); + + if (list.size() > 0) { + score = list.get(0).getDouble("integral"); + } + + if (list.get(0).getString("allName") != null) { + if (!isInterest) { + nutMap.setv(list.get(0).getString("allName"), score); + } else { + nutMap.setv(list.get(0).getString("allName"), score / 2); + } + } + totalScore += isInterest ? (score / 2) : score; + if (list.get(0).getString("zb") != null) { + nutMap.setv("projectType", list.get(0).getString("projectType")); + nutMap.setv("zb", list.get(0).getString("zb")); + } + } + nutMap.setv("totalScore", totalScore); + result.add(nutMap); + } + + result.sort(Comparator.comparing((Map m) -> (new BigDecimal(m.get("totalScore").toString()))).reversed()); + for (int i = 0; i < result.size(); i++) { + result.get(i).put("名次", i + 1); + } + + List entityList = new ArrayList<>(); + entityList.add(new ExcelExportEntity("名次", "名次", 20)); + entityList.add(new ExcelExportEntity("分工会", "unionname", 40)); + eventList.forEach(v -> { + entityList.add(new ExcelExportEntity(v.getString("label"), v.getString("label"), 40)); + }); + entityList.add(new ExcelExportEntity("总分", "totalScore", 40)); + try { + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, result); + CommonDownloadUtil.download("分工会" + sex + "项目积分.xlsx", workbook, response); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + @At + @Ok("void") + public void isTopEight(String activityId, String sex, Integer awardsMode, HttpServletResponse response) { + NutMap map = new NutMap(); + List result = new ArrayList<>(); + Cnd cndX = Cnd.NEW(); + //查询所有的项目 + Sql sqlX = Sqls.create(""" + SELECT + ev.id, + ev.eventId, + ba.`name` baname, + eve.projectType awardsMode, + eve.allName label + FROM + activity_school_event ev + LEFT JOIN activity_event eve ON ev.eventId = eve.id + LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition + """); + cndX.and("ev.activityId", "=", activityId); + if (awardsMode == 1) { + cndX.and("eve.isMenWomen", "!=", sex.equals("男性") ? 2 : 1); + cndX.and("eve.projectType", "=", 1); + + } else { + cndX.and("eve.projectType", "=", 2); + } + cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end")); + sqlX.setCondition(cndX); + List eventList = baseService.list(sqlX); + + + List nutMaps = new ArrayList<>(); + + for (int i = 0; i < 8; i++) { + NutMap nutMap = new NutMap(); + Sql sqlC = Sqls.create(""); + Cnd cnd = Cnd.NEW(); + if (awardsMode == 1) { + sqlC = Sqls.create(""" + SELECT + CONCAT( apply.username, '(', apply.activityUnionName, ')' ) username, + ar.integral, + ar.ranking, + eve.allName + FROM + activity_results ar + LEFT JOIN activity_event eve ON ar.eventId = eve.id + LEFT JOIN activity_school_apply apply ON apply.userId = ar.userId + AND ar.activityId = apply.activityId $condition + """); + cnd.and("ar.isTeamPersonal", "=", awardsMode); + cnd.and("apply.sex", "=", sex); + cnd.and("ar.activityId", "=", activityId); + cnd.and("ar.ranking", "=", i + 1); + cnd.groupBy("ar.id"); + } else { + sqlC = Sqls.create(""" + SELECT + CONCAT(sun.name) username, + eve.allName,ar.ranking + FROM + activity_results ar + LEFT JOIN activity_event eve ON ar.eventId = eve.id + LEFT JOIN sys_union sun ON sun.id = ar.unionId $condition + """); + cnd.and("ar.isTeamPersonal", "=", awardsMode); + cnd.and("ar.activityId", "=", activityId); + cnd.and("ar.ranking", "=", i + 1); + + + } + + sqlC.setCondition(cnd); + List list = baseService.list(sqlC); + list.forEach(l -> { + nutMap.setv(l.getString("allName"), l.getString("username")); + }); + + nutMaps.add(nutMap); + } + + for (int i = 0; i < nutMaps.size(); i++) { + nutMaps.get(i).put("名次", i + 1); + } + + + List entityList = new ArrayList<>(); + entityList.add(new ExcelExportEntity("名次", "名次", 20)); + eventList.forEach(v -> { + entityList.add(new ExcelExportEntity(v.getString("label"), v.getString("label"), 40)); + }); + String sex2 = awardsMode == 2 ? "团体" : sex.equals("男性") ? "男子" : "女子"; + try { + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, nutMaps); + CommonDownloadUtil.download("项目前八.xlsx", workbook, response); + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + + @At + @Ok("void") + public void isScoreTopEight(String activityId, String sex, HttpServletResponse response) { + + NutMap map = new NutMap(); + List result = new ArrayList<>(); + Cnd cndX = Cnd.NEW(); + //查询所有的项目 + Sql sqlX = Sqls.create(""" + SELECT + ev.id, + ev.eventId, + ba.`name` baname, + eve.projectType awardsMode, + eve.allName label + FROM + activity_school_event ev + LEFT JOIN activity_event eve ON ev.eventId = eve.id + LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition + """); + cndX.and("ev.activityId", "=", activityId); + cndX.and(Cnd.exps("eve.isMenWomen", "=", sex.equals("男性") ? 1 : 2).or("eve.isMenWomen", "is", null)); + cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end")); + sqlX.setCondition(cndX); + List eventList = baseService.list(sqlX); + + //查询所有的工会 + List query = sysUnionService.query(); + + for (Sys_union sys_union : query) { + NutMap nutMap = new NutMap(); + + //记录总积分 + double totalScore = 0; + nutMap.setv("unionname", sys_union.getName()); + for (Record event : eventList) { + Sql sqlC = Sqls.create(""" + SELECT + IF ( sum( integral ) IS NULL, 0, sum( integral )) AS integral, + ev.allName,ev.isInterest + FROM + activity_results ar + LEFT JOIN activity_event ev ON ar.eventId = ev.id $condition + """); + Cnd cndC = Cnd.NEW(); + cndC.and(Cnd.exps("ev.isMenWomen", "=", sex.equals("男性") ? 1 : 2).or("ev.isMenWomen", "is", null)); + cndC.and("ar.unionid", "=", sys_union.getId()); + cndC.and("ar.eventId", "=", event.getString("eventid")); + cndC.and("ar.activityId", "=", activityId); + sqlC.setCondition(cndC); + Double score = 0.0; + List list = baseService.listMap(sqlC); + boolean isInterest = list.get(0).getBoolean("isInterest"); + if (list.size() > 0) { + score = list.get(0).getDouble("integral"); + } + totalScore += isInterest ? (score / 2) : score; + + } + nutMap.setv("totalScore", totalScore); + result.add(nutMap); + } + + List entityList = new ArrayList<>(); + entityList.add(new ExcelExportEntity("名次", "名次", 20)); + entityList.add(new ExcelExportEntity("分工会", "unionname", 40)); + entityList.add(new ExcelExportEntity("总分", "totalScore", 40)); + + result.sort(Comparator.comparing((Map m) -> (new BigDecimal(m.get("totalScore").toString()))).reversed()); + for (int i = 0; i < result.size(); i++) { + result.get(i).put("名次", i + 1); + } + + try { + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, result); + CommonDownloadUtil.download("分工会" + sex + "子总分.xlsx", workbook, response); + } catch (Exception e) { + e.printStackTrace(); + } + } + + +} diff --git a/src/main/java/com/budwk/app/zhgh/democratic/proposal/models/ProposalInfo.java b/src/main/java/com/budwk/app/zhgh/democratic/proposal/models/ProposalInfo.java index 9423506..896f81d 100644 --- a/src/main/java/com/budwk/app/zhgh/democratic/proposal/models/ProposalInfo.java +++ b/src/main/java/com/budwk/app/zhgh/democratic/proposal/models/ProposalInfo.java @@ -45,6 +45,11 @@ public class ProposalInfo extends BaseModel { @ColDefine(type = ColType.INT) private Integer typeId; + @Column + @Comment("提案类型") + @ColDefine(type = ColType.INT) + private Integer proposalTypeId; + @Column @Comment("提案来源") @ColDefine(type = ColType.VARCHAR, width = 32) diff --git a/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/controller/SuggestionBoxMineController.java b/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/controller/SuggestionBoxMineController.java index d848963..0fef845 100644 --- a/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/controller/SuggestionBoxMineController.java +++ b/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/controller/SuggestionBoxMineController.java @@ -9,6 +9,7 @@ import com.budwk.app.base.page.Pagination; import com.budwk.app.base.result.Result; import com.budwk.app.flow.engine.FlowEngine; import com.budwk.app.web.commons.auth.utils.SecurityUtil; +import com.budwk.app.zhgh.democratic.suggestionBox.models.SuggestionBox; import com.budwk.app.zhgh.democratic.suggestionBox.service.SuggestionBoxService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -111,5 +112,16 @@ public class SuggestionBoxMineController { return Result.success(); } + @At + @SaCheckPermission(value = {"suggestionBox.mine", "h5.suggestionBox.mine"}, mode = SaMode.OR) + @ApiOperation("保存评价") + @SLog(tag = "建言献策-", msg = "保存评价") + public Result evaluate(String id ,String evaluate) { + SuggestionBox box = dao.fetch(SuggestionBox.class, id); + box.setEvaluate(evaluate); + dao.update(box); + return Result.success(); + } + } diff --git a/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/controller/SuggestionBoxQueryController.java b/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/controller/SuggestionBoxQueryController.java index 1213feb..e0c7f15 100644 --- a/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/controller/SuggestionBoxQueryController.java +++ b/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/controller/SuggestionBoxQueryController.java @@ -4,9 +4,11 @@ import cn.dev33.satoken.annotation.SaCheckLogin; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaMode; import cn.hutool.core.util.StrUtil; +import com.budwk.app.base.annotation.SLog; import com.budwk.app.base.page.Pagination; import com.budwk.app.base.result.Result; import com.budwk.app.flow.engine.FlowEngine; +import com.budwk.app.zhgh.democratic.suggestionBox.models.SuggestionBox; import com.budwk.app.zhgh.democratic.suggestionBox.service.SuggestionBoxService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -23,6 +25,8 @@ import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Param; +import java.util.Date; + @IocBean @At("/platform/suggestionBox/query") @Ok("json:full") @@ -117,5 +121,16 @@ public class SuggestionBoxQueryController { return Result.success(); } + @At + @SaCheckPermission(value = {"suggestionBox.query", "h5.suggestionBox.query"}, mode = SaMode.OR) + @ApiOperation("保存答复") + @SLog(tag = "建言献策-", msg = "保存答复") + public Result reply(String id ,String reply) { + SuggestionBox box = dao.fetch(SuggestionBox.class, id); + box.setReply(reply); + dao.update(box); + return Result.success(); + } + } diff --git a/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/models/SuggestionBox.java b/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/models/SuggestionBox.java index 59a07f5..52cb884 100644 --- a/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/models/SuggestionBox.java +++ b/src/main/java/com/budwk/app/zhgh/democratic/suggestionBox/models/SuggestionBox.java @@ -73,6 +73,16 @@ public class SuggestionBox extends BaseModel { @ColDefine(type = ColType.TEXT) private String content; + @Column + @Comment("答复") + @ColDefine(type = ColType.TEXT) + private String reply; + + @Column + @Comment("评价") + @ColDefine(type = ColType.TEXT) + private String evaluate; + @Column @Comment("附件") @ColDefine(type = ColType.MYSQL_JSON) diff --git a/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/controller/CondolenceMineController.java b/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/controller/CondolenceMineController.java index 8f8506c..6dd7411 100644 --- a/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/controller/CondolenceMineController.java +++ b/src/main/java/com/budwk/app/zhgh/staffbenefit/condolence/controller/CondolenceMineController.java @@ -3,6 +3,7 @@ package com.budwk.app.zhgh.staffbenefit.condolence.controller; import cn.dev33.satoken.annotation.SaCheckLogin; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaMode; +import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Dict; import cn.hutool.core.util.StrUtil; @@ -51,6 +52,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -270,5 +272,123 @@ public class CondolenceMineController { } + } + @At + @ApiOperation("导出单个慰问报销凭证") + @SaCheckPermission("condolence") + public void doExport(@Valid String id, HttpServletResponse response) throws ParseException { + HashMap docData = new HashMap<>(); + + Sql sql = Sqls.create(""" + SELECT + info.*, + ins.id AS instanceId, + ct.name AS typeName + FROM + `condolence` info + LEFT JOIN wf_process_instance ins ON ins.businessNo = info.id + LEFT JOIN condolence_type ct ON ct.id = info.type + WHERE + info.id = @id + """).setParam("id", id); + sql.setCallback(Sqls.callback.map()); + dao.execute(sql); + NutMap info = (NutMap) sql.getResult(); + + // 根据慰问类型选择不同的模板和文件名 + String type = info.getString("type"); + String templateName; + String fileName; + + templateName = "condolence_reimbursement"; + fileName = "河北地质大学慰问报销凭证" + ".docx"; + + + + // 添加日期格式化处理 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + if (info.get("createTime") != null) { + if (info.get("createTime") instanceof String) { + String createTimeStr = (String) info.get("createTime"); + Date date = inputFormat.parse(createTimeStr); + info.put("createTime", sdf.format(date)); + + } + } + if (StrUtil.isNotBlank(info.getString("signature"))) { + info.put("signature", sysOfficeTemplateUtil.createPictureRenderData(info.getString("signature"))); + } + + info.put("money_big", Convert.digitToChinese(info.getDouble("money"))); + info.put("typeName", info.getString("typeName")); + double price = info.getDouble("money"); + int money_int = (int) price; + BigDecimal b1 = new BigDecimal(Double.toString(price)); + BigDecimal b2 = new BigDecimal(Double.toString(money_int)); + double moneyAngle = b1.subtract(b2).doubleValue(); + BigDecimal b3 = new BigDecimal(moneyAngle); + + info.put("one", money_int >= 1000000 ? (money_int / 1000000) % 10 : null); + info.put("two", money_int >= 100000 ? (money_int / 100000) % 10 : null); + info.put("three", money_int >= 10000 ? (money_int / 10000) % 10 : null); + info.put("four", money_int >= 1000 ? (money_int / 1000) % 10 : null); + info.put("five", money_int >= 100 ? (money_int / 100) % 10 : null); + info.put("six", money_int >= 10 ? (money_int / 10) % 10 : null); + info.put("seven", money_int >= 10 ? money_int % 10 : null); + info.put("eight", (int) (moneyAngle * 10)); + info.put("nine", (int) (moneyAngle * 100 % 10)); + + docData.put("schoolName", Globals.AppName); + docData.put("info", info); + + + List doneTaskVos = new ArrayList<>(); + List doneTaskList = flowEngine.processTaskService().getDoneTaskList(info.getLong("instanceId"), null); + for (ProcessTask doneTask : doneTaskList) { + ProcessTaskVO taskVO = flowEngine.processTaskService().findById(doneTask.getId()); + doneTaskVos.add(taskVO); + } + + // 各审批节点处理 + doneTaskVos.stream().filter(task -> "分工会审核".equals(task.getDisplayName())) + .max(Comparator.comparing(ProcessTaskVO::getCreatedAt)) + .ifPresent(v -> { + Dict taskFormData = v.getTaskFormData(); + HashMap approval = new HashMap<>(); + + approval.put("date", DateUtil.format(v.getFinishTime(), "yyyy年MM月dd日")); + approval.put("user", taskFormData.getStr("tf_userName")); + if (StrUtil.isNotBlank(taskFormData.getStr("tf_userSign"))) { + approval.put("sign", sysOfficeTemplateUtil.createPictureRenderData(taskFormData.getStr("tf_userSign"))); + } + approval.put("opinion", taskFormData.getStr("tf_opinion")); + docData.put("fgh", approval); + }); + + doneTaskVos.stream().filter(task -> "校工会审核".equals(task.getDisplayName())) + .max(Comparator.comparing(ProcessTaskVO::getCreatedAt)) + .ifPresent(v -> { + Dict taskFormData = v.getTaskFormData(); + HashMap approval = new HashMap<>(); + + approval.put("date", DateUtil.format(v.getFinishTime(), "yyyy年MM月dd日")); + approval.put("user", taskFormData.getStr("tf_userName")); + if (StrUtil.isNotBlank(taskFormData.getStr("tf_userSign"))) { + approval.put("sign", sysOfficeTemplateUtil.createPictureRenderData(taskFormData.getStr("tf_userSign"))); + } + approval.put("opinion", taskFormData.getStr("tf_opinion")); + docData.put("xgh", approval); + }); + + try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) { + XWPFTemplate.compile(sysOfficeTemplateUtil.getTemplate(templateName)).render(docData).writeAndClose(byteArrayOutputStream); + CommonDownloadUtil.download(fileName, byteArrayOutputStream.toByteArray(), response); + } catch (IOException e) { + log.error("河北地质大学慰问报销凭证导出失败,id:{},错误信息:{}", id, e.getMessage()); + } + + } } diff --git a/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java b/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java index 4c23504..c5c9ac7 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java @@ -1,12 +1,22 @@ package com.budwk.app.zhgh.welfare.controller; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; import cn.dev33.satoken.annotation.SaCheckLogin; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.hutool.core.util.StrUtil; import com.budwk.app.base.annotation.SLog; +import com.budwk.app.base.model.ExcelImportRes; import com.budwk.app.base.page.Pagination; import com.budwk.app.base.result.Result; +import com.budwk.app.base.utils.CommonDownloadUtil; import com.budwk.app.sys.models.Sys_user; +import com.budwk.app.sys.views.View_user; +import com.budwk.app.zhgh.welfare.mode.CourierNumberExcelMode; +import com.budwk.app.zhgh.welfare.mode.WelfareUserImportExcel; import com.budwk.app.zhgh.welfare.model.WelfareList; import com.budwk.app.zhgh.welfare.model.WelfareUserSelection; import com.budwk.app.zhgh.welfare.param.WelfareSelectionSituationPageForm; @@ -16,21 +26,27 @@ import com.budwk.app.zhgh.welfare.service.WelfareStatisticsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.Workbook; import org.nutz.aop.interceptor.ioc.TransAop; import org.nutz.dao.Cnd; import org.nutz.dao.Dao; import org.nutz.ioc.aop.Aop; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.mvc.annotation.AdaptBy; import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Param; +import org.nutz.mvc.upload.TempFile; +import org.nutz.mvc.upload.UploadAdaptor; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @IocBean @Ok("json:full") @@ -113,4 +129,86 @@ public class WelfareSelectionSituationController { return Result.success().addData(user.getMobile()); } + @At + @Ok("void") + @SaCheckPermission("welfare.selection.situation") + @ApiOperation("下载模版") + public void downloadTemplate(HttpServletResponse response) { + List entities = new ArrayList<>(); + entities.add(new ExcelExportEntity("工号", "loginname", 20)); + entities.add(new ExcelExportEntity("姓名", "username", 20)); + entities.add(new ExcelExportEntity("快递单号", "courierNumber", 30)); + ExportParams exportParams = new ExportParams(); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entities, Collections.emptyList()); + CommonDownloadUtil.download("福利快递单号模版.xlsx", workbook, response); + } + + + @At + @Aop(TransAop.READ_COMMITTED) + @SaCheckPermission("welfare.list.mange") + @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) + @SLog(tag = "福利名单管理", msg = "导入福利单号") + public Result importByExcel(@Param("file") TempFile tempFile, @Valid @Param("projectId") String projectId, @Valid @Param("welfareOptionId") String welfareOptionId) { + + if (StrUtil.isBlank(projectId)||StrUtil.isBlank(welfareOptionId)){ + return Result.error("请选择福利项目或福利选项"); + } + // 读取数据 + List excelList = ExcelImportUtil.importExcel(tempFile.getFile(), CourierNumberExcelMode.class, new ImportParams()); + + // 查询用户 + List loginNames = excelList.stream().map(CourierNumberExcelMode::getLoginName).filter(StrUtil::isNotBlank).collect(Collectors.toList()); + + List sysUsers = welfareListService.dao().query(View_user.class, Cnd.where(View_user::getLoginname, "in", loginNames)); + + List selectionList = dao.query(WelfareUserSelection.class, Cnd.where(WelfareUserSelection::getWelfareId, "=", projectId) + .and(WelfareUserSelection::getSelectOptionId, "=", welfareOptionId)); + + // 创建结果集 + ExcelImportRes excelImportRes = new ExcelImportRes<>(); + excelImportRes.setTotalRecords(excelList.size()); + + + for (int i = 0; i < excelList.size(); i++) { + CourierNumberExcelMode excel = excelList.get(i); + if (StrUtil.isBlank(excel.getLoginName())) { + excel.setErrInfo("工号为空", i + 1); + continue; + } + + // 不能在excel里重复 + if (excelList.stream().filter(s -> s.getLoginName().equals(excel.getLoginName())).count() > 1) { + excel.setErrInfo("重复数据", i + 1); + } + + View_user user = sysUsers.stream().filter(s -> s.getLoginname().equals(excel.getLoginName())).findFirst().orElse(null); + if (user == null) { + excel.setErrInfo("无此用户", i + 1); + continue; + } + + if (!selectionList.stream().anyMatch(s -> s.getSelectUserId().equals(user.getId()))) { + excel.setErrInfo("该用户不存在", i + 1); + continue; + } + WelfareUserSelection selection = selectionList.stream().filter(s -> s.getSelectUserId().equals(user.getId())).findFirst().orElse(null); + selection.setCourierNumber(excel.getCourierNumber()); + try { + welfareListService.updateIgnoreNull(selection); + } catch (Exception e) { + log.error("添加福利名单失败:{}", e.getMessage()); + excel.setErrInfo("添加失败", i + 1); + } + } + + // 添加错误记录 + excelImportRes.setErrorDetails(excelList.stream().filter(s -> StrUtil.isNotBlank(s.getErrMsg())).collect(Collectors.toList())); + excelImportRes.setFailedCount(excelImportRes.getErrorDetails().size()); + + return Result.success(excelImportRes); + + + } + } diff --git a/src/main/java/com/budwk/app/zhgh/welfare/mode/CourierNumberExcelMode.java b/src/main/java/com/budwk/app/zhgh/welfare/mode/CourierNumberExcelMode.java index fcf26ba..bfe3ca1 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/mode/CourierNumberExcelMode.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/mode/CourierNumberExcelMode.java @@ -1,10 +1,13 @@ package com.budwk.app.zhgh.welfare.mode; import cn.afterturn.easypoi.excel.annotation.Excel; +import com.budwk.app.base.model.ExcelImportError; import lombok.Data; +import lombok.EqualsAndHashCode; +@EqualsAndHashCode(callSuper = true) @Data -public class CourierNumberExcelMode { +public class CourierNumberExcelMode extends ExcelImportError { @Excel(name = "工号", width = 20) private String loginName; @@ -12,6 +15,9 @@ public class CourierNumberExcelMode { @Excel(name = "姓名", width = 20) private String userName; + @Excel(name = "快递单号", width = 30) + private String courierNumber; + @Excel(name = "快递单号1", width = 30) private String oneCourierNumber; diff --git a/src/main/resources/static/components/module/activity/score/isMaleFemale.vue b/src/main/resources/static/components/module/activity/score/isMaleFemale.vue new file mode 100644 index 0000000..103b41a --- /dev/null +++ b/src/main/resources/static/components/module/activity/score/isMaleFemale.vue @@ -0,0 +1,145 @@ + + + diff --git a/src/main/resources/static/components/module/activity/score/scoreTopEight.vue b/src/main/resources/static/components/module/activity/score/scoreTopEight.vue new file mode 100644 index 0000000..044ac32 --- /dev/null +++ b/src/main/resources/static/components/module/activity/score/scoreTopEight.vue @@ -0,0 +1,71 @@ + + + diff --git a/src/main/resources/static/components/module/activity/score/topEight.vue b/src/main/resources/static/components/module/activity/score/topEight.vue new file mode 100644 index 0000000..9a4c7c9 --- /dev/null +++ b/src/main/resources/static/components/module/activity/score/topEight.vue @@ -0,0 +1,93 @@ + + + + diff --git a/src/main/resources/views/platform/sys/union/branchUnionCadreAudit.js b/src/main/resources/views/platform/sys/union/branchUnionCadreAudit.js new file mode 100644 index 0000000..a57ae2f --- /dev/null +++ b/src/main/resources/views/platform/sys/union/branchUnionCadreAudit.js @@ -0,0 +1,151 @@ +const branchUnionCadreAudit = { + template: /*language=HTML*/ ` + + + + 已审核 + 未审核 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `, + mixins: [initTableMixins], + data() { + return { + pageForm: { + audit: false + }, + tableColumns: [ + { prop: 'loginName', label: '工号' }, + { prop: 'userName', label: '姓名' }, + { prop: 'unionName', label: '所属工会' }, + { prop: 'mobile', label: '联系方式' }, + { prop: 'roleName', label: '职务' }, + { prop: 'isJoin', label: '申请类型' }, + { prop: "curTaskName", label: "当前节点" }, + { prop: "instanceState", label: "流程状态" } + ], + multipleSelection: [], + } + }, + methods: { + handleSelectionChange(val) { + this.multipleSelection = val; + }, + doAudit(pass) { + this.$confirm('是否确认提交?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(async () => { + const ids = JSON.stringify(this.multipleSelection.map(v => v.id)) + this.$axios.post('/platform/sys/union/cadreDoAudit', {ids, pass}) + .then(resp => { + if (resp.code === 0) { + this.pageData() + this.$refs.table.clearSelection(); + this.$message.success(resp.msg) + }else{ + this.$message.error(resp.msg) + } + }) + + }) + }, + + handleTaskAction(row, val) { + const msg = val === 1 ? "通过" : "拒绝" + this.$confirm("您确定要" + msg + "吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(() => { + const loading = createLoading() + this.formData = { + origin: row.origin, + processTaskId: row.taskId, + taskName: row.curTaskName + } + this.$axios.post("/flow/common/executeTask", { + data: JSON.stringify({ + ...this.formData, + submitType: val + }) + }).then((res) => { + if (res.code === 0) { + this.$message.success(res.msg) + this.doSearch() + } + }).finally(() => { + loading.close() + }) + }) + }, + + pageData() { + this.$axios.post('/platform/sys/union/cadrePageData', this.pageForm) + .then(resp => { + if (resp.code === 0) { + this.tableData = resp.data.list + this.pageForm.totalCount = resp.data.totalCount + } + }) + } + } +} diff --git a/src/main/resources/views/platform/sys/union/branchUnionManage.js b/src/main/resources/views/platform/sys/union/branchUnionManage.js index 2e20626..8df135d 100644 --- a/src/main/resources/views/platform/sys/union/branchUnionManage.js +++ b/src/main/resources/views/platform/sys/union/branchUnionManage.js @@ -6,7 +6,7 @@ const branchUnionManage = { - + 基层干部审核 新建分工会 @@ -75,6 +75,10 @@ const branchUnionManage = { this.pageForm.totalCount = res.data.totalCount }) }, + // 基层干部审核 + openAudit() { + this.$emit('union-cadre') + }, openAdd() { this.dialogFormVisible = true this.$nextTick(() => { diff --git a/src/main/resources/views/platform/sys/union/index.html b/src/main/resources/views/platform/sys/union/index.html index 886865e..c133e4e 100644 --- a/src/main/resources/views/platform/sys/union/index.html +++ b/src/main/resources/views/platform/sys/union/index.html @@ -3,89 +3,103 @@ layout("/layouts/platform.html"){ #-->
- - - - -
- + + + +
+ + + diff --git a/src/main/resources/views/platform/zhgh/activity/sports/scoreStatistics/index.html b/src/main/resources/views/platform/zhgh/activity/sports/scoreStatistics/index.html new file mode 100644 index 0000000..44af215 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/activity/sports/scoreStatistics/index.html @@ -0,0 +1,433 @@ + + + +
+ + + +
+ + + + + + diff --git a/src/main/resources/views/platform/zhgh/democratic/proposal/transact/mine/index.html b/src/main/resources/views/platform/zhgh/democratic/proposal/transact/mine/index.html index bb8dcdf..dcd0a42 100644 --- a/src/main/resources/views/platform/zhgh/democratic/proposal/transact/mine/index.html +++ b/src/main/resources/views/platform/zhgh/democratic/proposal/transact/mine/index.html @@ -46,6 +46,9 @@ layout("/layouts/platform.html"){ + @@ -111,10 +114,10 @@ layout("/layouts/platform.html"){ }, methods: { onExport(id) { - this.$downLoad('/platform/condolence/mine/onExport', { - id: id - }) - + this.$downLoad('/platform/condolence/mine/onExport', {id: id}) + }, + doExport(id) { + this.$downLoad('/platform/condolence/mine/doExport', {id: id}) }, onAdd() { commonUtil.pjaxPush('/platform/condolence/apply') diff --git a/src/main/resources/views/platform/zhgh/staffbenefit/maternityLeave/collect/index.html b/src/main/resources/views/platform/zhgh/staffbenefit/maternityLeave/collect/index.html index adbc73d..eb14749 100644 --- a/src/main/resources/views/platform/zhgh/staffbenefit/maternityLeave/collect/index.html +++ b/src/main/resources/views/platform/zhgh/staffbenefit/maternityLeave/collect/index.html @@ -12,8 +12,8 @@ layout("/layouts/platform.html"){ - - + + diff --git a/src/main/resources/views/platform/zhgh/welfare/selectionSituation/index.html b/src/main/resources/views/platform/zhgh/welfare/selectionSituation/index.html index e9c2233..072aac2 100644 --- a/src/main/resources/views/platform/zhgh/welfare/selectionSituation/index.html +++ b/src/main/resources/views/platform/zhgh/welfare/selectionSituation/index.html @@ -72,7 +72,7 @@ layout("/layouts/platform.html"){ 未选择 - + 导入快递单号 @@ -118,6 +118,18 @@ layout("/layouts/platform.html"){ + + +