This commit is contained in:
=
2026-06-30 13:44:18 +08:00
14 changed files with 3696 additions and 2 deletions
@@ -0,0 +1,312 @@
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.aop.interceptor.ioc.TransAop;
import org.nutz.ioc.aop.Aop;
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 (isMenWomen != null) {
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")
@Aop(TransAop.READ_COMMITTED)
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")
@Aop(TransAop.READ_COMMITTED)
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.setApplyUser(SecurityUtil.getUserId());
activitySchoolApply.setApplyDate(DateUtil.getDate());
activitySchoolApply.setSex(user.getSex());
activitySchoolApply.setUnitId(user.getUnitId());
activitySchoolApply.setActivityUnionId(basicUnion.getId());
activitySchoolApply.setActivityUnionName(basicUnion.getName());
activitySchoolApplyViService.insert(activitySchoolApply);
});
return Result.success();
}
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.name 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.name
""").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));
}
}
@@ -0,0 +1,491 @@
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 io.swagger.annotations.ApiOperation;
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
@SaCheckPermission("activity.score.statistics")
@ApiOperation("男子项目分工会积分/女子项目分工会积分")
public Result isMaleFemale(String activityId, String sex, Integer awardsMode) {
NutMap map = new NutMap();
List<NutMap> result = new ArrayList<>();
//查询所有的工会
List<Sys_union> 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<Record> 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<NutMap> 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
@SaCheckPermission("activity.score.statistics")
@ApiOperation("单子单项前八/女子单项前八/团体项目前八")
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<Record> 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<Record> list = baseService.list(sqlC);
map.put("userList", list);
map.put("eventList", eventList);
return Result.success(map);
}
@At
@SaCheckLogin
public Result getActivitys(Integer year) {
List<ActivitySchool> schoolList = baseService.dao().query(ActivitySchool.class, Cnd.where("YEAR(applyEndTime)", "=", year));
return Result.success(schoolList);
}
@At
@SaCheckPermission("activity.score.statistics")
@ApiOperation("男子总分前八/女子总分前八")
public Result isScoreTopEight(String activityId, String sex) {
NutMap map = new NutMap();
List<NutMap> 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<Record> eventList = baseService.list(sqlX);
//查询所有的工会
List<Sys_union> 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<NutMap> 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
@SaCheckPermission("activity.score.statistics")
@ApiOperation("年度团体总分")
public Result getAnnualResults(Integer year) {
ArrayList<Map> resultMap = new ArrayList<>();
Dao dao = sysUnionService.dao();
List<Sys_union> unionList = sysUnionService.query();
List<ActivitySchool> activitySchoolList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
List<String> labelList = activitySchoolList.stream().map(v -> v.getName()).collect(Collectors.toList());
labelList.add(0, "分工会");
unionList.forEach(u -> {
NutMap unionMap = Lang.obj2nutmap(u);
AtomicReference<Double> 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("name"));
resultMap.add(unionMap);
});
labelList.add("总分");
return Result.success(Map.of("label", labelList, "score", resultMap));
}
@At
@ApiOperation("年度男子团体总分/年度女子团体总分")
@SaCheckPermission("activity.score.statistics")
public Result getYear8(Integer isMenWomen, Integer year) {
ArrayList<Map> resultMap = new ArrayList<>();
// int isMenWomen = sex.equals("男") ? 1 : 2;
Dao dao = sysUnionService.dao();
List<Sys_union> unionList = sysUnionService.query();
List<ActivitySchool> activityList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
List<String> activityIdList = activityList.stream().map(ActivitySchool::getId).collect(Collectors.toList());
List<String> activityNameList = activityList.stream().map(ActivitySchool::getName).collect(Collectors.toList());
List<String> 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<NutMap> list = sql.getList(NutMap.class);
unionList.forEach(u -> {
NutMap unionMap = Lang.obj2nutmap(u);
AtomicReference<Double> 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("name"));
resultMap.add(unionMap);
});
activityNameList.add("总分");
return Result.success(Map.of("label", activityNameList, "score", resultMap));
}
public static Double getDouble(NutMap o) {
return o.getDouble("score");
}
@At
@Ok("void")
@SaCheckPermission("activity.score.statistics")
public void doExcelCj(String activityId, String unionId, HttpServletResponse response) throws IOException {
Sql sql = Sqls.create("""
SELECT
un.unioncode,
un.name 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<NutMap> list = baseService.listMap(sql);
List<ExcelExportEntity> 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);
}
}
@@ -0,0 +1,494 @@
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.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 io.swagger.annotations.ApiOperation;
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
@ApiOperation("年度男子团体总分/年度女子团体总分")
@SaCheckPermission("activity.score.statistics")
public void getYear8(Integer isMenWomen, Integer year, HttpServletResponse response) {
ArrayList<Map> resultMap = new ArrayList<>();
List<Sys_union> unionList = sysUnionService.query();
List<ActivitySchool> activityList = baseService.dao().query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
List<String> activityIdList = activityList.stream().map(ActivitySchool::getId).collect(Collectors.toList());
List<String> activityNameList = activityList.stream().map(ActivitySchool::getName).collect(Collectors.toList());
List<String> 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<NutMap> list = baseService.listMap(sql);
unionList.forEach(u -> {
NutMap unionMap = Lang.obj2nutmap(u);
AtomicReference<Double> 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("name"));
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<ExcelExportEntity> 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
@ApiOperation("年度团体总分")
@SaCheckPermission("activity.score.statistics")
public void getAnnualResults(Integer year, HttpServletResponse response) {
ArrayList<Map> resultMap = new ArrayList<>();
Dao dao = sysUnionService.dao();
List<Sys_union> unionList = sysUnionService.query();
List<ActivitySchool> activitySchoolList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
List<String> labelList = activitySchoolList.stream().map(v -> v.getName()).collect(Collectors.toList());
labelList.add(0, "分工会");
unionList.forEach(u -> {
NutMap unionMap = Lang.obj2nutmap(u);
AtomicReference<Double> 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("name"));
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<ExcelExportEntity> 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")
@SaCheckPermission("activity.score.statistics")
@ApiOperation("男子项目分工会积分/女子项目分工会积分")
public void isMaleFemale(String activityId, String sex, Integer awardsMode, HttpServletResponse response) {
NutMap map = new NutMap();
List<NutMap> result = new ArrayList<>();
//查询所有的工会
List<Sys_union> 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<Record> 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<NutMap> 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<ExcelExportEntity> 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")
@SaCheckPermission("activity.score.statistics")
@ApiOperation("单子单项前八/女子单项前八/团体项目前八")
public void isTopEight(String activityId, String sex, Integer awardsMode, HttpServletResponse response) {
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<Record> eventList = baseService.list(sqlX);
List<NutMap> nutMaps = new ArrayList<>();
for (int i = 0; i < 8; i++) {
NutMap nutMap = new NutMap();
Sql sqlC;
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<Record> 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<ExcelExportEntity> 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(sex2 + "项目前八.xlsx", workbook, response);
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Ok("void")
@SaCheckPermission("activity.score.statistics")
@ApiOperation("男子总分前八/女子总分前八")
public void isScoreTopEight(String activityId, String sex, HttpServletResponse response) {
List<NutMap> 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<Record> eventList = baseService.list(sqlX);
//查询所有的工会
List<Sys_union> 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<NutMap> 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<ExcelExportEntity> 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();
}
}
}
@@ -140,7 +140,7 @@ public class MemberApplyMineController {
*/
@At
@ApiOperation("获取申请信息")
@SaCheckPermission(value = {"member.apply.mine", "member.apply.branchUnionApproval", "member.apply.branchUnionApproval"}, mode = SaMode.OR)
@SaCheckPermission(value = {"member.apply.mine", "member.apply.branchUnionApproval", "member.apply.branchUnionApproval", "member.apply.statistics"}, mode = SaMode.OR)
public Result findMemberApplyRecord(@Valid String id) {
MemberApplyRecord record = dao.fetch(MemberApplyRecord.class, id);
return Result.success().addData(record);
@@ -0,0 +1,205 @@
package com.budwk.app.zhgh.staffmanage.member.controller.statistics;
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.SaCheckPermission;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.base.constant.RoleConstant;
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.base.utils.PageUtil;
import com.budwk.app.web.commons.auth.utils.AuthUtil;
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
import com.budwk.app.zhgh.staffmanage.member.param.pageform.MemberApplyRecordStatisticsPageForm;
import com.budwk.app.zhgh.staffmanage.member.service.MemberApplyRecordService;
import com.budwk.app.zhgh.staffmanage.member.vo.MemberApplyRecordStatisticsVO;
import org.apache.poi.ss.usermodel.Workbook;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 会员申请记录查询统计。
*/
@At("/platform/member/apply/statistics")
@Ok("json:full")
@IocBean
public class MemberApplyRecordStatisticsController {
private static final Map<String, String> ORDER_COLUMN_MAP;
static {
Map<String, String> orderColumnMap = new HashMap<>();
orderColumnMap.put("loginName", "info.loginName");
orderColumnMap.put("userName", "info.userName");
orderColumnMap.put("unitName", "info.unitName");
orderColumnMap.put("unionName", "info.unionName");
orderColumnMap.put("userState", "info.userState");
orderColumnMap.put("preparedBy", "info.preparedBy");
orderColumnMap.put("personType", "info.personType");
orderColumnMap.put("origin", "info.origin");
orderColumnMap.put("applyDateTime", "info.applyDateTime");
orderColumnMap.put("instanceState", "ins.state");
ORDER_COLUMN_MAP = Collections.unmodifiableMap(orderColumnMap);
}
@Inject
private MemberApplyRecordService memberApplyRecordService;
@At("")
@Ok("beetl:/platform/zhgh/staffmanage/member/statistics/applyRecord/index.html")
@SaCheckPermission("member.apply.statistics")
public void index() {
}
/**
* 分页查询会员申请记录统计。
*
* @param pageForm 查询参数:searchKeyword 传姓名/工号关键字,unionId/unitId 传工会和单位ID数组,
* userStates/personTypes/preparedBys 传人员字典值数组,instanceStates 传流程状态 code 数组,
* startApplyDate/endApplyDate 传申请日期范围;分页和排序使用 PageForm 公共字段
* @return Result 包装的 Pagination<MemberApplyRecordStatisticsVO>list 为申请记录,totalCount 为总条数
*/
@At
@SaCheckPermission("member.apply.statistics")
public Result pageData(MemberApplyRecordStatisticsPageForm pageForm) {
Sql sql = getApplyRecordSql(pageForm);
Pagination<MemberApplyRecordStatisticsVO> pagination = memberApplyRecordService.listPageVO(
pageForm, sql, MemberApplyRecordStatisticsVO.class
);
return Result.success(pagination);
}
/**
* 导出会员申请记录统计。
*
* @param pageForm 查询和导出参数:columns 为前端选择的导出列,prop 对应 MemberApplyRecordStatisticsVO 属性,
* label 为 Excel 表头;其他筛选参数与 pageData 保持一致
* @param response 文件下载响应,返回 xlsx 格式 Excel 文件
*/
@At
@Ok("void")
@SaCheckPermission("member.apply.statistics")
public void doExport(MemberApplyRecordStatisticsPageForm pageForm, HttpServletResponse response) {
Sql sql = getApplyRecordSql(pageForm);
List<MemberApplyRecordStatisticsVO> list = memberApplyRecordService.listVO(sql, MemberApplyRecordStatisticsVO.class);
try {
List<ExcelExportEntity> exportEntities = buildExportColumns(pageForm);
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
CommonDownloadUtil.download("会员申请记录统计.xlsx", workbook, response);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 构建申请记录统计 SQL,当前节点先在子查询中合并,避免一个申请存在多个待办时重复展示。
*/
private Sql getApplyRecordSql(MemberApplyRecordStatisticsPageForm pageForm) {
Sql sql = Sqls.create("SELECT " +
"info.id, " +
"info.userName, " +
"info.loginName, " +
"info.unitName, " +
"info.unionName, " +
"info.userState, " +
"info.preparedBy, " +
"info.personType, " +
"info.origin, " +
"info.applyDateTime, " +
"CASE WHEN info.sign IS NOT NULL AND info.sign != '' THEN '已签字' ELSE '未签字' END signState, " +
"ins.id AS instanceId, " +
"ins.businessNo, " +
"ins.state AS instanceState, " +
"CASE ins.state " +
"WHEN 10 THEN '进行中' " +
"WHEN 20 THEN '已完成' " +
"WHEN 30 THEN '已撤回' " +
"WHEN 40 THEN '强行终止' " +
"WHEN 45 THEN '已拒绝' " +
"WHEN 50 THEN '挂起' " +
"WHEN 99 THEN '已废弃' " +
"ELSE '未知' END AS instanceStateName, " +
"ins.processDefineId AS instanceProcessDefineId, " +
"IFNULL(nt.curTaskName, '结束') AS curTaskName " +
"FROM member_apply_record info " +
"LEFT JOIN wf_process_instance ins ON ins.businessNo = info.id " +
"LEFT JOIN (SELECT processInstanceId, GROUP_CONCAT(DISTINCT displayName) AS curTaskName " +
"FROM wf_process_task WHERE taskState = 10 GROUP BY processInstanceId) nt ON nt.processInstanceId = ins.id " +
"$condition");
Cnd cnd = Cnd.NEW();
MemberApplyRecordStatisticsPageForm.buildSearch(cnd, pageForm);
buildDataScope(cnd);
buildOrder(cnd, pageForm);
sql.setCondition(cnd);
return sql;
}
/**
* 按当前登录人的角色补充数据范围,避免普通用户通过统计入口看到无权限的申请记录。
*/
private void buildDataScope(Cnd cnd) {
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_MEMBER_ADMIN.name())) {
if (AuthUtil.hasRole(RoleConstant.BRANCH_UNION_CHAIRMAN.name())) {
cnd.and("info.unionId", "=", SecurityUtil.getUnionId());
} else {
cnd.and("info.userId", "=", SecurityUtil.getUserId());
}
}
}
/**
* 仅允许前端按白名单字段排序,避免页面排序字段被拼接成非预期 SQL。
*/
private void buildOrder(Cnd cnd, MemberApplyRecordStatisticsPageForm pageForm) {
if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())
&& ORDER_COLUMN_MAP.containsKey(pageForm.getPageOrderName())) {
cnd.orderBy(ORDER_COLUMN_MAP.get(pageForm.getPageOrderName()), PageUtil.getOrder(pageForm.getPageOrderBy()));
} else {
cnd.desc("info.applyDateTime");
}
}
/**
* 生成导出列;前端未传列设置时,使用申请记录统计的默认核心字段。
*/
private List<ExcelExportEntity> buildExportColumns(MemberApplyRecordStatisticsPageForm pageForm) {
List<ExcelExportEntity> exportEntities = new ArrayList<>();
if (Lang.isNotEmpty(pageForm.getColumns())) {
pageForm.getColumns().forEach(column -> {
exportEntities.add(new ExcelExportEntity(column.get("label"), column.get("prop"), 20));
});
return exportEntities;
}
exportEntities.add(new ExcelExportEntity("工号", "loginName", 20));
exportEntities.add(new ExcelExportEntity("姓名", "userName", 20));
exportEntities.add(new ExcelExportEntity("所属工会", "unionName", 20));
exportEntities.add(new ExcelExportEntity("所属单位", "unitName", 20));
exportEntities.add(new ExcelExportEntity("在职状态", "userState", 20));
exportEntities.add(new ExcelExportEntity("教职工类别", "personType", 20));
exportEntities.add(new ExcelExportEntity("编制类别", "preparedBy", 20));
exportEntities.add(new ExcelExportEntity("来源", "origin", 20));
exportEntities.add(new ExcelExportEntity("申请时间", "applyDateTime", 25));
exportEntities.add(new ExcelExportEntity("签字状态", "signState", 20));
exportEntities.add(new ExcelExportEntity("当前节点", "curTaskName", 20));
exportEntities.add(new ExcelExportEntity("流程状态", "instanceStateName", 20));
return exportEntities;
}
}
@@ -0,0 +1,74 @@
package com.budwk.app.zhgh.staffmanage.member.param.pageform;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.base.param.PageForm;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.Cnd;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import java.util.List;
import java.util.Map;
/**
* 会员申请记录统计查询参数。
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MemberApplyRecordStatisticsPageForm extends PageForm {
@ApiModelProperty("所属工会ID,多个值由前端数组提交")
private List<String> unionId;
@ApiModelProperty("所属单位ID,多个值由前端数组提交")
private List<String> unitId;
@ApiModelProperty("在职状态字典值,多个值由前端数组提交")
private List<String> userStates;
@ApiModelProperty("教职工类别字典值,多个值由前端数组提交")
private List<String> personTypes;
@ApiModelProperty("编制类别字典值,多个值由前端数组提交")
private List<String> preparedBys;
@ApiModelProperty("流程实例状态,使用 ProcessInstanceStateEnum 的 code")
private List<Integer> instanceStates;
@ApiModelProperty("申请开始时间,格式 yyyy-MM-dd")
private String startApplyDate;
@ApiModelProperty("申请结束时间,格式 yyyy-MM-dd")
private String endApplyDate;
@ApiModelProperty("导出列,字段 prop 对应 VO 属性,label 为 Excel 表头")
private List<Map<String, String>> columns;
/**
* 组装申请记录统计的公共查询条件。
*
* @param cnd SQL 条件对象,由调用方继续追加权限、排序等条件
* @param pageForm 查询参数,包含姓名/工号关键字、工会、单位、人员类别、申请时间和流程状态
*/
public static void buildSearch(Cnd cnd, MemberApplyRecordStatisticsPageForm pageForm) {
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
SqlExpressionGroup seg = new SqlExpressionGroup();
seg.or("info.loginName", "like", "%" + pageForm.getSearchKeyword() + "%");
seg.or("info.username", "like", "%" + pageForm.getSearchKeyword() + "%");
cnd.and(seg);
}
cnd.andEX("info.unionId", "in", pageForm.getUnionId());
cnd.andEX("info.unitId", "in", pageForm.getUnitId());
cnd.andEX("info.userState", "in", pageForm.getUserStates());
cnd.andEX("info.personType", "in", pageForm.getPersonTypes());
cnd.andEX("info.preparedBy", "in", pageForm.getPreparedBys());
cnd.andEX("ins.state", "in", pageForm.getInstanceStates());
if (StrUtil.isNotBlank(pageForm.getStartApplyDate())) {
cnd.and("info.applyDateTime", ">=", pageForm.getStartApplyDate() + " 00:00:00");
}
if (StrUtil.isNotBlank(pageForm.getEndApplyDate())) {
cnd.and("info.applyDateTime", "<=", pageForm.getEndApplyDate() + " 23:59:59");
}
}
}
@@ -0,0 +1,46 @@
package com.budwk.app.zhgh.staffmanage.member.vo;
import lombok.Data;
import java.util.Date;
/**
* 会员申请记录统计返回数据。
*/
@Data
public class MemberApplyRecordStatisticsVO {
private String id;
private String userName;
private String loginName;
private String unitName;
private String unionName;
private String userState;
private String preparedBy;
private String personType;
private String origin;
private Date applyDateTime;
private String signState;
private String instanceId;
private String businessNo;
private Integer instanceState;
private String instanceStateName;
private String instanceProcessDefineId;
private String curTaskName;
}
+1 -1
View File
@@ -81,7 +81,7 @@ redis:
#nodes=192.168.6.31:6377,192.168.6.31:6378,192.168.6.28:6377,192.168.6.28:6378,192.168.6.34:6377,192.168.6.34:6378
jdbc:
url: jdbc:mysql://192.168.21.212:3306/zhgh_jshvc?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
url: jdbc:mysql://127.0.0.1:3306/zhgh_jshvc?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: 123456
validationQuery: select 1
@@ -0,0 +1,144 @@
<template>
<el-table :data="tableData" style="width: 100%;height: 100%" stripe border
ref="MaleFemaleTab"
:header-cell-style="{background:'#FAFAFA'}" row-key="id" @sort-change="pageOrder"
v-loading="tableLoading" size="mini" fixed>
<el-table-column align="center" header-align="center" type="index" :index="indexMethod" label="序号"
width="80px" fixed></el-table-column>
<el-table-column label="分工会" prop="unionname" header-align="center"
align="center" fixed show-overflow-tooltip width="250px"></el-table-column>
<el-table-column label="甲组" header-align="center" v-if="tableColumns.length>0">
<el-table-column
align="center"
header-align="center"
v-for="column in tableColumns"
:label="column.label"
:prop="column.prop"
:sortable="column.sortable"
show-overflow-tooltip>
</el-table-column>
</el-table-column>
<el-table-column label="乙组" header-align="center" v-if="tableColumns2.length>0">
<el-table-column
align="center"
header-align="center"
v-for="column in tableColumns2"
:label="column.label"
:prop="column.prop"
:sortable="column.sortable"
show-overflow-tooltip>
</el-table-column>
</el-table-column>
<el-table-column label="丙组" header-align="center" v-if="tableColumns3.length>0">
<el-table-column
align="center"
header-align="center"
v-for="column in tableColumns3"
:label="column.label"
:prop="column.prop"
:sortable="column.sortable"
show-overflow-tooltip>
</el-table-column>
</el-table-column>
<el-table-column label="丁组" header-align="center" v-if="tableColumns4.length>0">
<el-table-column
align="center"
header-align="center"
v-for="column in tableColumns4"
:label="column.label"
:prop="column.prop"
:sortable="column.sortable"
show-overflow-tooltip>
</el-table-column>
</el-table-column>
<el-table-column label="团体" header-align="center" v-if="tableColumns5.length>0">
<el-table-column
align="center"
header-align="center"
v-for="column in tableColumns5"
:label="column.label"
:prop="column.prop"
:sortable="column.sortable"
show-overflow-tooltip>
</el-table-column>
</el-table-column>
<el-table-column label="总分" prop="totalScore" header-align="center"
align="center" show-overflow-tooltip fixed="right"></el-table-column>
<el-table-column align="center" header-align="center" type="index" show-overflow-tooltip label="名次"
width="80px" fixed="right"></el-table-column>
</el-table>
</template>
<script>
module.exports = {
props: {
Form: {
type: Object,
default: {},
}
},
mixins: [initTableMixins],
data() {
return {
tableData: [],
maxHeight: 0,
tableColumns2: [],
tableColumns3: [],
tableColumns4: [],
tableColumns5: []
}
},
mounted() {
/* const tabHeight = document.getElementById("app").clientHeight - (this.$refs.MaleFemaleTab.$el.offsetTop + 60)
this.$nextTick(()=>{
this.maxHeight = tabHeight
})*/
},
methods: {
isMaleFemale() {
this.tableLoading = true
this.tableColumns = []
this.tableColumns2 = []
this.tableColumns3 = []
this.tableColumns4 = []
this.tableColumns5 = []
this.tableData = []
this.$axios.post("/platform/activity/score/statistics/isMaleFemale", this.Form).then((resp) => {
const data = resp.data
data.eventList.forEach(v => {
if (v.baname == "甲组" || v.baname == "乙组" || v.baname == "丙组" || v.baname == "丁组") {
this.tableColumns.push({label: v.isMenWomen ? v.label.substr(4) : v.label.substr(2), prop: v.label})
} else {
this.tableColumns5.push({label: v.label, prop: v.label})
}
})
this.tableData = data.score.sort(this.compare("totalScore"))
if (this.Form.unionname) {
this.tableData = this.tableData.filter(v => v.unionname == this.Form.unionname)
}
}).finally(() => {
this.tableLoading = false
})
},
compare(prop) {
return (obj1, obj2) => {
const val1 = obj1[prop];
const val2 = obj2[prop];
if (val1 > val2) {
return -1;
} else if (val1 < val2) {
return 1;
} else {
return 0;
}
}
}
},
}
</script>
@@ -0,0 +1,75 @@
<template>
<el-table :data="tableData" style="width: 100%;height: 100%" stripe border
ref="MaleFemaleTab"
:header-cell-style="{background:'#FAFAFA'}" row-key="id" @sort-change="pageOrder"
v-loading="tableLoading" size="mini" fixed>
<!--:max-height="maxHeight"-->
<el-table-column align="center" header-align="center" type="index" :index="indexMethod" label="序号"
width="80px" fixed></el-table-column>
<el-table-column label="分工会" prop="unionname" header-align="center"
align="center" fixed show-overflow-tooltip></el-table-column>
<el-table-column label="总分" prop="totalScore" header-align="center"
align="center" show-overflow-tooltip></el-table-column>
<el-table-column align="center" header-align="center" type="index" :index="indexMethod" label="名次"
width="80px"></el-table-column>
</el-table>
</template>
<script>
module.exports = {
props: {
Form: {
type: Object,
default: {},
}
},
mixins: [initTableMixins],
data() {
return {
tableData: [],
maxHeight: 0
}
},
mounted() {
/*const tabHeight = document.getElementById("app").clientHeight - (this.$refs.MaleFemaleTab.$el.offsetTop + 60)
this.$nextTick(() => {
this.maxHeight = tabHeight
})*/
},
methods: {
isScoreTopEight() {
this.tableLoading = true
this.tableColumns = []
this.tableData = []
this.$axios.post(loc() + "/isScoreTopEight", this.Form).then((resp) => {
const data = resp.data
const table = data.score.sort(this.compare("totalScore"))
this.tableData = table.slice(0, 8)
}).finally(() => {
this.tableLoading = false
})
},
compare(prop) {
return (obj1, obj2) => {
const val1 = obj1[prop];
const val2 = obj2[prop];
if (val1 > val2) {
return -1;
} else if (val1 < val2) {
return 1;
} else {
return 0;
}
}
}
},
}
</script>
@@ -0,0 +1,91 @@
<template>
<div v-loading="tableLoading">
<!-- <el-table :data="tableData" style="width: 100%" stripe border
:header-cell-style="{background:'#FAFAFA'}" row-key="id" @sort-change="pageOrder"
v-loading="tableLoading" size="mini">
<el-table-column align="center" header-align="center" type="index" :index="indexMethod" label="名次"
width="100px"></el-table-column>
<el-table-column
align="center"
header-align="center"
v-for="column in tableColumns"
:label="column.label"
:prop="column.prop"
:sortable="column.sortable"
show-overflow-tooltip>
</el-table-column>
</el-table>-->
<table class="table table-bordered" style="table-layout: fixed;">
<thead>
<tr>
<th style="text-align: center!important;">项目</th>
<th style="text-align: center!important;" v-for="i in 8">{{ i }}</th>
</tr>
</thead>
<tbody>
<tr v-for="i in tableData">
<td align="center" width="20%">{{ i.label }}</td>
<td v-for="x in 8" align="center" width="10%">
{{ getTableTdContent(i.sss, x) }}
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
module.exports = {
props: {
Form: {
type: Object,
default: {},
}
},
mixins: [initTableMixins],
data() {
return {
tableData: []
}
},
methods: {
getTableTdContent(d, i) {
return d.filter(v => {
if (v.ranking == i) {
return v.username
}
}).map(v => {
return v.username
}).toString()
},
isTopEight() {
this.tableLoading = true
this.tableColumns = []
this.tableData = []
this.$axios.post(loc() + "/isTopEight", this.Form).then((resp) => {
const data = resp.data
data.eventList.map(v => {
v.sss = []
data.userList.map(x => {
if (v.label === x.allname) {
console.log(x)
v.sss.push(x)
}
})
})
this.tableData = data.eventList
}).finally(() => {
this.tableLoading = false
})
},
},
}
</script>
@@ -0,0 +1,957 @@
<!--#
layout("/layouts/platform.html"){
#-->
<div id="app" class="platform" v-cloak>
<guava ref="guava">
<template>
<el-card shadow="never">
<div class="search">
<div class="search-item">
<div class="search-item-label">&emsp;&emsp;</div>
<div class="search-item-option">
<el-date-picker
@change="yearChange"
v-model="pageForm.year"
type="year"
value-format="yyyy" style="width: 100%"
placeholder="选择年">
</el-date-picker>
</div>
</div>
<div class="search-item">
<div class="search-item-label">活动名称</div>
<div class="search-item-option">
<el-select v-model="pageForm.activityId" placeholder="请选择活动名称" filterable clearable
style="width: 100%" @change="doSearchS">
<el-option
v-for="item in activityList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
</div>
<div class="search-item">
<div class="search-item-label">活动项目</div>
<div class="search-item-option">
<el-select v-model="pageForm.eventId" placeholder="请选择活动项目" filterable clearable
style="width: 100%" @change="doSearch">
<el-option
v-for="item in events"
:key="item.eventId"
:label="item.allName"
:value="item.eventId">
</el-option>
</el-select>
</div>
</div>
<div class="search-item">
<div class="search-item-label">男子女子</div>
<div class="search-item-option">
<el-select v-model="pageForm.isMenWomen" placeholder="请选择男子女子" clearable
style="width: 100%" @change="doSearch">
<el-option
v-for="item in menWomenList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
</div>
<div class="search-item">
<div class="search-item-label">项目类型</div>
<div class="search-item-option">
<el-select v-model="pageForm.projectType" placeholder="请选择项目类型" clearable
style="width: 100%" @change="doSearch">
<el-option
v-for="item in projectTypeList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
</div>
<div class="search-item">
<div class="search-item-label">比赛组别</div>
<div class="search-item-option">
<el-select v-model="pageForm.competitionCategory" placeholder="请选择比赛组别" filterable clearable
style="width: 100%" @change="doSearch">
<el-option
v-for="item in groupList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
</div>
</div>
</el-card>
<el-card shadow="never" class="mt10">
<table-tool label="项目列表">
<!--<el-radio-group v-model="pageForm.isMenWomen" @change="doSearch"
style="margin-left: 10px">
<el-radio-button :label="1">全部</el-radio-button>
<el-radio-button :label="2">男子</el-radio-button>
<el-radio-button :label="3">女子</el-radio-button>
<el-radio-button :label="4">团体</el-radio-button>
</el-radio-group>-->
<!-- <el-checkbox-group @change="doSearch" v-model="pageForm.isMenWomen">
<el-checkbox-button :key="2" :label="2">男子</el-checkbox-button>
<el-checkbox-button :key="3" :label="3">女子</el-checkbox-button>
</el-checkbox-group>-->
<!-- <el-checkbox-group @change="doSearch" v-model="pageForm.isMenWomen">
<el-checkbox-button :key="4" :label="4">单项</el-checkbox-button>
<el-checkbox-button :key="5" :label="5">团体</el-checkbox-button>
</el-checkbox-group>
<el-select v-model="pageForm.groupName" placeholder="请选择组别"
filterable clearable
style="width: 100%;margin-bottom: 5px;margin-left: 10px" @change="doSearch">
<el-option
v-for="item in groupList"
:key="item.id"
:label="item.name"
:value="item.name">
</el-option>
</el-select>-->
</table-tool>
<el-table :data="tableData" style="width: 100%;margin-bottom: 20px" row-key="id"
@sort-change="pageOrder" v-loading="tableLoading" :size="tableSize" class="vi-table">
<el-table-column align="center" header-align="center" type="index" :index="indexMethod" label="序号"
width="80px"></el-table-column>
<el-table-column prop="allName" align="center" header-align="center"
label="项目名称"></el-table-column>
<el-table-column prop="rs" align="center" header-align="center"
label="获奖数量"></el-table-column>
<el-table-column prop="userOnline" align="center" header-align="center" label="操作" width="150px">
<template scope="{row}">
<el-dropdown @command="dropdownCommand">
<el-button size="mini" :loading="row.loading">
<i class="ti-settings"></i>
<span class="ti-angle-down"></span>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="{type:'input',row}">
录入成绩
</el-dropdown-item>
<el-dropdown-item :command="{type:'view',row}">
&emsp;&emsp;
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<!--#include("/layouts/pagination.html"){}#-->
</el-card>
</template>
<template #edit_func>
<el-button type="primary" @click="openAdd">临时获奖人员添加</el-button>
<el-button type="primary" @click="doAdd">确 定</el-button>
</template>
<template #edit>
<template>
<table-tool label="录入成绩"></table-tool>
<el-form :model="formData" ref="addForm" label-width="120px"
label-suffix="">
<el-row :gutter="40">
<el-col :span="12">
<el-form-item prop="name" label="活动名称">
<el-input maxlength="200" disabled v-model="name"
type="text"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="allName" label="活动项目">
<el-input maxlength="200" disabled v-model="allName"
type="text"></el-input>
</el-form-item>
</el-col>
</el-row>
<div style="display: flex;margin: 20px 0">
<el-divider content-position="left">获奖名次列表</el-divider>
<div style="padding-left: 10px;padding-top: 10px;">
<el-tooltip class="item" effect="dark" content="点击添加活动人员" placement="top">
<el-button style="float: right;margin-bottom: 10px" type="primary" icon="el-icon-plus"
size="mini"
@click="openAddUser">
添加
</el-button>
</el-tooltip>
</div>
</div>
<el-table style="margin-bottom: 20px" border stripe :data="userData" size="small"
v-loading="userTabLoading">
<el-table-column
type="index" label="序号" header-align="center" align="center" width="100">
</el-table-column>
<el-table-column align="center" header-align="center"
:label="awardsMode==1?'姓名':'分工会'"
prop="id">
<template scope="{$index,row}">
<el-select v-model="row.userId" @change="(val)=>{userDetailsChange(val,row)}"
placeholder="请输入姓名" filterable clearable
style="width: 100%" size="small" v-if="awardsMode==1">
<el-option
v-for="item in userList"
:disabled="item.disabled"
:key="item.id"
:label="item.username+''+item.loginname+''+item.sex"
:value="item.id">
</el-option>
</el-select>
<el-select v-model="row.unionId" @change="(val)=>{unionDetailsChange(val,row)}"
placeholder="请输入分工会" filterable clearable
style="width: 100%" size="small" v-if="awardsMode==2">
<el-option
v-for="item in unionList"
:disabled="item.disabled"
:key="item.id"
:label="item.unionname"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="名次" prop="ranking">
<template scope="{$index,row}">
<el-select v-model="row.ranking" @change="rankingChange(row)"
placeholder="请输入名次" filterable clearable
style="width: 100%" size="small">
<el-option
v-for="item in rankingList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="积分" prop="integral">
<template scope="{row}">
<el-input-number v-model="row.integral"
type="text"></el-input-number>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="人数" prop="numberOfPeople"
v-if="awardsMode==2">
<template scope="{row}">
<el-input-number v-model="row.numberOfPeople"
type="text"></el-input-number>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="分工会" prop="unionname"
v-if="awardsMode==1">
<template scope="{row}">
<el-input v-model="row.unionname" disabled placeholder="分工会"
type="text"></el-input>
</template>
</el-table-column>
<el-table-column prop="userOnline" align="center" header-align="center" label="操作"
width="150px">
<template scope="{$index,row}">
<el-button type="danger" icon="el-icon-delete" circle
@click="delUser($index,row)"></el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</template>
</template>
<template #view>
<el-form :model="formData" ref="addForm" label-width="120px" label-suffix="">
<el-row :gutter="40">
<el-col :span="12">
<el-form-item prop="name" label="活动名称">
<el-input maxlength="200" disabled v-model="name"
type="text"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="allName" label="活动项目">
<el-input maxlength="200" disabled v-model="allName"
type="text"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div style="display: flex;margin: 20px 0">
<el-divider content-position="left">获奖名次列表</el-divider>
</div>
<el-table style="margin-bottom: 20px" border stripe :data="viewData" size="small"
v-loading="userTabLoading">
<el-table-column
type="index" label="序号" header-align="center" align="center" width="100">
</el-table-column>
<el-table-column align="center" header-align="center"
:label="awardsMode==1?'姓名':'分工会'"
prop="id">
<template scope="{$index,row}">
<el-select v-model="row.userId" @change="(val)=>{userDetailsChange(val,row)}"
placeholder="请输入姓名" filterable clearable disabled
style="width: 100%" size="small" v-if="awardsMode==1">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.username+''+item.loginname+''+item.sex"
:value="item.id">
</el-option>
</el-select>
<el-select v-model="row.unionId" @change="(val)=>{unionDetailsChange(val,row)}"
placeholder="请输入分工会" filterable clearable disabled
style="width: 100%" size="small" v-if="awardsMode==2">
<el-option
v-for="item in unionList"
:key="item.id"
:label="item.unionname"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="名次" prop="ranking">
<template scope="{$index,row}">
<el-select v-model="row.ranking" @change="rankingChange(row)"
placeholder="请输入名次" filterable clearable disabled
style="width: 100%" size="small">
<el-option
v-for="item in rankingList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="积分" prop="integral">
<template scope="{row}">
<el-input v-model="row.integral" disabled type="text"></el-input>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="人数" prop="numberOfPeople"
v-if="awardsMode==2">
<template scope="{row}">
<el-input v-model="row.numberOfPeople" disabled type="text"></el-input>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="分工会" prop="unionname"
v-if="awardsMode==1">
<template scope="{row}">
<el-input v-model="row.unionname" disabled placeholder="分工会"
type="text"></el-input>
</template>
</el-table-column>
</el-table>
</template>
</guava>
<el-dialog
title="添加人员"
:visible.sync="dialogVisible"
width="40%"
:close-on-click-modal="false"
>
<el-form :model="formData" ref="form" :rules="formRules" label-width="100px">
<!-- <el-form-item prop="loginname" label="工&emsp;&emsp;号">
<el-input maxlength="50" placeholder="请填写工号" v-model="formData.loginname"
type="text" @blur="userBlur"></el-input>
</el-form-item>
<el-form-item prop="username" label="姓&emsp;&emsp;名">
<el-input maxlength="50" placeholder="请填写姓名" v-model="formData.username"
type="text"></el-input>
</el-form-item>-->
<el-form-item prop="mobile" label="姓名或工号">
<el-select
style="width: 100%"
v-model="formData.userid"
filterable
clearable
remote
reserve-keyword
allow-create
default-first-option
placeholder="请输入姓名或工号查找"
:remote-method="userRemoteMethod"
@change="userChange2">
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.username+''+item.loginname+''"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="loginname" label="工&emsp;&emsp;号">
<el-input maxlength="50" placeholder="请填写工号" v-model="formData.loginname"
type="text"></el-input>
</el-form-item>
<el-form-item prop="mobile" label="电&emsp;&emsp;话">
<el-input maxlength="50" placeholder="请填写电话" v-model="formData.mobile"
type="text"></el-input>
</el-form-item>
<el-form-item prop="sex" label="性&emsp;&emsp;别">
<el-radio-group v-model="formData.sex">
<el-radio :label="'男'" border></el-radio>
<el-radio :label="'女'" border></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item prop="unitId" label="所在单位">
<el-select v-model="formData.unitId" placeholder="请选择所在单位" clearable @change="unitChange"
filterable
style="width: 100%">
<el-option
v-for="item in unitOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="unionname" label="所属工会">
<el-input disabled placeholder="所属工会" v-model="formData.unionname"
type="text"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="doAddUser">确 定</el-button>
</span>
</el-dialog>
</div>
<script nonce="${cspNonce!}">
const vue = new Vue({
el: '#app',
mixins: [initTableMixins],
data() {
return {
userOptions: [],
groupList: [],
menWomenList: [
{id: 1, name: "男子"},
{id: 2, name: "女子"}
],
projectTypeList: [
{id: "1", name: "单项"},
{id: "2", name: "团体"}
],
dialogVisible: false,
viewData: [],
userTabLoading: false,
awardsMode: "",
isMenWomen: "",
allName: "",
name: "",
eventId: "",
activityId: "",
userData: [],
userList: [],
userList2: [],
unionList: [],
unionList2: [],
activityList: [],
events: [],
unitOptions: [],
rankingList: [
{name: "第一名", id: 1},
{name: "第二名", id: 2},
{name: "第三名", id: 3},
{name: "第四名", id: 4},
{name: "第五名", id: 5},
{name: "第六名", id: 6},
{name: "第七名", id: 7},
{name: "第八名", id: 8}],
sexList: [{sex: "男", id: 1}, {sex: "女", id: 2}],
pageForm: {
isMenWomen: "",
projectType: "",
competitionCategory: "",
year: new Date().getFullYear() + "",
},
formRules: {
unitId: [{required: true, message: '必填', trigger: ['blur', 'change']}],
username: [{required: true, message: '必填', trigger: ['blur', 'change']}],
loginname: [{required: true, message: '必填', trigger: ['blur', 'change']}],
}
}
},
components: {},
methods: {
dropdownCommand(command) {
const {type, row} = command
if (type === 'view') {
this.openView(row)
} else if (type === 'input') {
this.openInput(row)
}
},
userRemoteMethod(query) {
if (query) {
this.$axios.post("/open/common/userOptions", {query: query}).then((resp) => {
this.userOptions = resp.data
})
}
},
userChange2(userid) {
const aa = this.userOptions.find(v => v.id === userid)
if (aa) {
const unit = this.unitOptions.find(v => v.id === aa.unitId)
this.$set(this.formData, "username", aa.username)
this.$set(this.formData, "loginname", aa.loginname)
this.$set(this.formData, "mobile", aa.mobile)
this.$set(this.formData, "unitId", aa.unitId)
this.$set(this.formData, "unionId", unit.unionId)
this.$set(this.formData, "unionname", unit.unionName)
this.$set(this.formData, "sex", aa.sex)
} else {
this.$set(this.formData, "username", userid)
}
},
unitChange() {
const unit = this.unitOptions.find(v => v.id === this.formData.unitId)
this.$set(this.formData, "unionId", unit.unionId)
this.$set(this.formData, "unionname", unit.unionName)
this.$set(this.formData, "unitname", unit.name)
},
openAdd() {
this.$businessTool.listUnit().then((data) => {
this.unitOptions = data
this.$set(this.formData, "activityId", this.activityId)
this.$set(this.formData, "eventId", this.eventId)
this.$set(this.formData, "awardsMode", this.awardsMode)
this.$set(this.formData, "identity", ['1'])
this.$set(this.formData, "status", 2)
this.$set(this.formData, "sex", "男")
this.dialogVisible = true
if (this.$refs['form']) {
this.$refs['form'].resetFields()
}
})
},
doAddUser() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.userList.some(v => v.id === this.formData.userid)) {
this.notifyWarning("您添加的运动员已经是远动员!")
return
}
this.$axios.post(loc() + "/doAdd", {
activityResults: JSON.stringify(this.userData),
activityId: this.activityId,
eventId: this.eventId
}).then(() => {
const pageForm = clone(this.formData)
pageForm.identity = JSON.stringify(this.formData.identity)
return this.$axios.post(loc() + "/doAddUser", pageForm)
}).then((resp) => {
if (resp.code === 0) {
if (this.awardsMode == 2) {
this.getUnionList({
activityId: this.activityId,
eventId: this.eventId
}).then((unionList) => {
this.unionList = unionList
return this.getUnionData({activityId: this.activityId, eventId: this.eventId})
}).then((userData) => {
this.userData = userData
return this.unionDetailsChange()
}).then(() => {
this.dialogVisible = false
})
} else {
this.userChange().then(() => {
this.userDetailsChange()
this.dialogVisible = false
})
}
} else {
this.notifyWarning(resp.msg)
}
})
}
})
},
yearChange() {
this.activityList = []
this.events = []
this.$set(this.pageForm, "activityId", "")
this.$set(this.pageForm, "eventId", "")
this.$axios.post("/platform/activity/score/statistics/getActivitys", {year: this.pageForm.year}).then((res) => {
const data = res.data
this.activityList = data
if (data.length > 0) {
this.pageForm.activityId = this.activityList[0].id
}
this.doSearchS()
})
},
changeActivit() {
return this.$axios.post("/platform/activity/apply/getEvents", {activityId: this.pageForm.activityId}).then((resp) => {
this.events = resp.data
})
},
doAdd() {
this.userData.activityId = this.activityId
this.userData.eventId = this.eventId
this.$axios.post(loc() + "/doAdd", {
activityResults: JSON.stringify(this.userData),
activityId: this.activityId,
eventId: this.eventId
}).then((resp) => {
if (resp.code === 0) {
this.pageData()
this.$refs.guava.index()
} else {
this.notifyWarning(resp.msg)
}
})
},
rankingChange() {
for (let ranking = 1; ranking <= 8; ranking++) {
let size = 0
let indexArray = [];
this.userData.forEach((v, index) => {
if (ranking == v.ranking) {
size++
indexArray.push(index)
}
})
if (size == 1) {
/*
if (this.awardsMode == 2) {
this.userData[indexArray[0]].integral = (this.calScore(ranking) / 2).toFixed(2);
console.log(this.calScore(ranking),2)
} else {
this.userData[indexArray[0]].integral = this.calScore(ranking).toFixed(2);
console.log(this.calScore(ranking),1)
}*/
this.userData[indexArray[0]].integral = this.calScore(ranking).toFixed(2);
} else {
var scoreArray = 0;
for (var i = 0; i < size; i++) {
scoreArray += this.calScore(ranking * 1 + i * 1);
}
/* if (this.awardsMode == 2) {
scoreArray = scoreArray / size / 2;
console.log(scoreArray, 2)
} else {
scoreArray = scoreArray / size;
console.log(scoreArray, 1)
}*/
scoreArray = scoreArray / size;
indexArray.forEach(v => {
this.userData[v].integral = scoreArray.toFixed(2);
})
}
}
},
calScore(ranking) {
let score;
if (ranking < 5) {// 1 2 3 4
if (ranking < 3) {//1 2
if (ranking == 1) {
score = this.awardsMode == 1 ? 9 : 9 * 2;
} else if (ranking == 2) {
score = this.awardsMode == 1 ? 7 : 7 * 2;
}
} else {//3 4
if (ranking == 3) {
score = this.awardsMode == 1 ? 6 : 6 * 2;
} else if (ranking == 4) {
score = this.awardsMode == 1 ? 5 : 5 * 2;
}
}
} else {//5 6 7 8
if (ranking < 7) {//5 6
if (ranking == 5) {
score = this.awardsMode == 1 ? 4 : 4 * 2;
} else if (ranking == 6) {
score = this.awardsMode == 1 ? 3 : 3 * 2;
}
} else {//7 8 9
if (ranking == 7) {
score = this.awardsMode == 1 ? 2 : 2 * 2;
} else if (ranking == 8) {
score = this.awardsMode == 1 ? 1 : 1 * 2;
} else if (ranking == 9) {
score = this.awardsMode == 1 ? 1 : 1 * 2;
}
}
}
return score;
},
userDetailsChange(val, row) {
const useridArr = this.userData.map(v => v.userId)
this.userList.forEach(v => {
v.disabled = useridArr.includes(v.id)
if (row && row.userId === v.id) {
const o = {
unionId: v.unionId,
activityId: this.activityId,
eventId: this.eventId,
isTeamPersonal: 1,
unionname: v.unionname
}
Object.assign(row, o)
}
})
},
unionDetailsChange(val, row) {
if (row) {
const {unionId} = row
return this.$axios.post(loc() + "/getUnionDetails", {
activityId: this.activityId,
eventId: this.eventId,
unionId: unionId
}).then((data) => {
this.setUnionDetails(row, data)
})
}
this.setUnionDetails(row, '')
return Promise.resolve()
},
setUnionDetails(row, data) {
this.$nextTick(() => {
const unionIdArr = this.userData.map(v => v.unionId)
this.unionList.forEach(v => {
v.disabled = unionIdArr.includes(v.id)
if (row && row.unionId === v.id) {
const o = {
numberOfPeople: data.data,
activityId: this.activityId,
eventId: this.eventId,
isTeamPersonal: 2
}
Object.assign(row, o)
}
})
})
},
delUser(index, row) {
this.userData.splice(index, 1)
this.userDetailsChange()
this.unionDetailsChange()
},
getUserList() {
return this.$axios.post(loc() + "/getUserList", {
activityId: this.activityId,
eventId: this.eventId,
isMenWomen: this.isMenWomen
}).then((resp) => {
return resp.data
})
},
getUnionList(row) {
const {activityId, eventId} = row
return this.$axios.post(loc() + "/getUnionList", {
activityId: activityId,
eventId: eventId
}).then((resp) => {
return resp.data
})
},
openAddUser() {
this.userData.push({})
},
userChange() {
return this.getUserList().then((userList) => {
this.userList = userList
this.userList2 = this.userList
this.userData = []
return this.$axios.post(loc() + "/getUserData", {
activityId: this.activityId,
eventId: this.eventId,
isMenWomen: this.isMenWomen
})
}).then((resp) => {
const data = resp.data
if (data.length > 0) {
this.userData = data
this.viewData = data
}
this.$forceUpdate();
})
},
getUnionData(row) {
const {activityId, eventId} = row
return this.$axios.post(loc() + "/getUnionData", {
activityId: activityId,
eventId: eventId
}).then((resp) => {
return resp.data
})
},
openView(row) {
this.isMenWomen = ""
this.userData = []
this.viewData = []
this.userList = []
this.awardsMode = row.awardsMode
this.name = row.name
this.allName = row.allName
this.activityId = row.activityId
this.eventId = row.eventId
if (row.awardsMode == 2) {
this.getUnionList(row).then((unionList) => {
this.unionList = unionList
return this.getUnionData(row)
}).then((viewData) => {
this.viewData = viewData
return this.unionDetailsChange()
}).then(() => {
this.$refs.guava.view()
})
} else {
this.userChange().then(() => {
this.userDetailsChange()
this.$refs.guava.view()
})
}
},
openInput(row) {
this.isMenWomen = ""
this.userData = []
this.userList = []
this.awardsMode = row.awardsMode
this.name = row.name
this.allName = row.allName
this.activityId = row.activityId
this.eventId = row.eventId
this.isMenWomen = row.isMenWomen
if (row.awardsMode == 2) {
this.getUnionList(row).then((unionList) => {
this.unionList = unionList
return this.getUnionData(row)
}).then((userData) => {
this.userData = userData
return this.unionDetailsChange()
}).then(() => {
this.$refs.guava.edit()
})
} else {
this.userChange().then(() => {
this.userDetailsChange()
this.$refs.guava.edit()
})
}
},
getActivitys() {
return this.$axios.post("/platform/activity/score/statistics/getActivitys", {year: this.pageForm.year}).then((res) => {
return res.data
})
},
focusGroup() {
this.$axios.post("/platform/activity/basic/event/focusGroup").then((resp) => {
if (resp.code === 0) {
this.groupList = resp.data
} else {
this.notifyWarning(resp.msg)
}
})
},
doSearchS() {
this.$set(this.pageForm, "eventId", "")
this.changeActivit().then(() => {
this.doSearch()
})
},
doSearch() {
this.pageForm.pageNumber = 1
this.pageData()
},
pageData() {
this.tableLoading = true
const pageForm = clone(this.pageForm)
this.$axios.post("/platform/activity/results/input/pageData", pageForm).then(resp => {
if (resp.code == 0) {
this.tableData = resp.data.list;
this.pageForm.totalCount = resp.data.totalCount;
} else {
this.$message({
message: resp.msg,
type: 'error'
});
}
}).finally(() => {
this.tableLoading = false
})
},
},
created() {
this.focusGroup()
this.yearChange()
}
})
</script>
<!--#
}
#-->
@@ -0,0 +1,487 @@
<!--#
layout("/layouts/platform.html"){
#-->
<style>
#app {
/*max-height: calc(100vh - 50px);
overflow: hidden;*/
}
.query-row {
height: 70px;
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
}
.query-row:not(:last-child) {
border-bottom: 1px dashed rgb(230, 230, 230);
}
.query-row-title {
width: 120px;
}
/* .el-select, .el-input {
width: 80%;
}*/
.el-date-editor.el-input, .el-date-editor.el-input__inner {
width: 175px !important;
}
/* Bootstrap 会覆盖 a:focus,导致左侧菜单当前项出现白色焦点框,这里仅还原侧边栏菜单链接的焦点态。 */
#sidebar-menu .el-menu .el-menu-item a:focus {
outline: none;
box-shadow: none;
text-decoration: none;
background: transparent;
}
</style>
<div id="app" v-cloak>
<guava ref="guava"
style="width: 100%;min-height: 100%;background-color: #f0f2f5;padding: 20px;box-sizing: border-box;">
<template>
<el-card shadow="never">
<search @search="doSearch" :is-search-button="false">
<search-item label="年度">
<el-date-picker
:clearable="false"
@change="getActivitys"
placeholder="选择年"
type="year"
v-model="pageForm.year" value-format="yyyy">
</el-date-picker>
</search-item>
<search-item label="活动名称" v-if="!pageForm.status">
<el-select :clearable="false" @change="activityChange" filterable
placeholder="请选择活动名称" style="width: 100%" v-model="pageForm.activityId">
<el-option
:key="item.id"
:label="item.name"
:value="item.id"
v-for="item in activityList">
</el-option>
</el-select>
</search-item>
<search-item label="所属工会" v-if="isUnion">
<el-select @change="unionChange(pageForm.unionId)" clearable filterable placeholder="请选择工会"
style="width: 100%" v-model="pageForm.unionname">
<el-option
:key="item.id"
:label="item.name"
:value="item.name"
v-for="item in unionList">
</el-option>
</el-select>
</search-item>
<search-item>
<el-button @click="doExcelCj" icon="el-icon-printer" type="primary">导出成绩excel
</el-button>
</search-item>
</search>
</el-card>
<div style="max-height: 250px">
<el-card shadow="never" style="margin-top: 10px">
<el-row type="flex" align="middle" class="query-row">
<el-col class="query-row-title">按年度统计:</el-col>
<el-col class="query-row-content" v-if="isSearchOptions">
<el-tag
:effect="pageForm.status===item.code?'dark':'plain'"
:key="item.code"
:type="item.name"
@click="statusType(item.code)"
style="margin-right: 10px;cursor: pointer"
v-for="item in statusOptions">
{{ item.name }}
</el-tag>
</el-col>
</el-row>
<el-row type="flex" align="middle" class="query-row">
<el-col class="query-row-title">运动会成绩统计:</el-col>
<el-col class="query-row-content" v-if="isSearchOptions">
<el-tag
:effect="pageForm.status2===item.id?'dark':'plain'"
:key="item.id"
:type="item.name"
@click="status2Type(item.id)"
style="margin-right: 10px;cursor: pointer"
v-for="item in searchOptions">
{{ item.name }}
</el-tag>
</el-col>
<el-col class="query-row-content" v-else>
<el-button style="margin-left: 10px"
size="medium" @click="gradesClick(9)">成绩统计
</el-button>
</el-col>
<div class="pull-right offscreen-right" style="margin-left: auto">
<el-button @click="doExportByActivityStatisticsType" icon="el-icon-printer" type="primary">
导出
</el-button>
</div>
</el-row>
</el-card>
</div>
<el-card shadow="never" class="mt10"
v-show="[1,2,3,4,5,9,10].includes(isSearchOptions)&&isSearchOptions">
<table-tool v-if="isSearchOptions==1" label="男子单项成绩"></table-tool>
<table-tool v-if="isSearchOptions==2" label="女子单项成绩"></table-tool>
<table-tool v-if="isSearchOptions==3" label="男子团体成绩"></table-tool>
<table-tool v-if="isSearchOptions==4" label="女子团体成绩"></table-tool>
<table-tool v-if="isSearchOptions==5" label="男女混合类成绩"></table-tool>
<table-tool v-if="isSearchOptions==9&&isSearch" label="男子项目分工会积分"></table-tool>
<table-tool v-if="isSearchOptions==9&&!isSearch" label="分工会项目成绩"></table-tool>
<table-tool v-if="isSearchOptions==10" label="女子项目分工会积分"></table-tool>
<is-male-female :form="pageForm" ref="female"></is-male-female>
</el-card>
<el-card shadow="never" class="mt10" v-show="[6,7,8].includes(isSearchOptions)&&isSearchOptions">
<table-tool v-if="isSearchOptions==6" label="男子项目前八"></table-tool>
<table-tool v-if="isSearchOptions==7" label="女子项目前八"></table-tool>
<table-tool v-if="isSearchOptions==8" label="综合类前八"></table-tool>
<el-row>
<top-eight :form="pageForm" ref="doeight"></top-eight>
</el-row>
</el-card>
<el-card shadow="never" class="mt10" v-show="[11,12].includes(isSearchOptions)&&isSearchOptions">
<table-tool v-if="isSearchOptions==11" label="男子总分前八"></table-tool>
<table-tool v-if="isSearchOptions==12" label="女子总分前八"></table-tool>
<score-top-eight :form="pageForm" ref="doTopEight"></score-top-eight>
</el-card>
<el-card shadow="never" class="mt10" v-show="[99].includes(isSearchOptions)">
<table-tool v-if="isSearchOptions==99" label="全年成绩"></table-tool>
<el-table :data="annualResultsTableData" style="width: 100%;height: 100%" stripe border
show-summary
:header-cell-style="{background:'#FAFAFA'}" row-key="id" @sort-change="pageOrder"
v-loading="tableLoading" size="mini" fixed ref="annualResults"
>
<el-table-column align="center" header-align="center" type="index"
label="名次"
width="80px" fixed></el-table-column>
<el-table-column
align="center"
header-align="center"
v-for="column in annualTableColumns"
:label="column.label"
:prop="column.prop"
:sortable="column.sortable"
show-overflow-tooltip>
</el-table-column>
</el-table>
</el-card>
</template>
</guava>
</div>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script nonce="${cspNonce!}">
const vue = new Vue({
el: '#app',
mixins: [initTableMixins],
data() {
return {
isMenWomen: "",
isUnion: false,
isYear8: false,
annualTableColumns: [],
annualResultsTableData: [],
annualMaxHeight: 0,
colspan: [],
eventList: [],
score: [],
titleCol: 0,
activityList: [],
events: [],
unionList: [],
units: [],
isSearch: true,
searchOptions: [],
Options: [
/* {id: 1, name: "男子单项"},
{id: 2, name: "女子单项"},
{id: 3, name: "男子团体"},
{id: 4, name: "女子团体"},
{id: 5, name: "男女混合类"},*/
{id: 9, name: "男子项目分工会积分"},
{id: 10, name: "女子项目分工会积分"},
{id: 6, name: "男子单项前八"},
{id: 7, name: "女子单项前八"},
{id: 8, name: "团体项目前八"},
{id: 11, name: "男子总分前八"},
{id: 12, name: "女子总分前八"},
],
isSearchOptions: 9,
pageForm: {
status2: 9,
status: '',
unionname: '',
activityId: "",
personTypes: [],
year: new Date().getFullYear() + "",
},
activityStatisticsType: 0,//统计类型说明:1 年度男子团体总分2.年度女子团体总分3.年度团体总分4.分工会男子项目积分5.分工会女子项目积分,依次后推
statusOptions: [
{code: "1", name: "年度男子团体总分"},
{code: "2", name: "年度女子团体总分"},
{code: "3", name: "年度团体总分"}
]
}
},
components: {
'is-male-female': httpVueLoader('/components/module/activity/score/isMaleFemale.vue?v=' + new Date().getTime()),
'top-eight': httpVueLoader('/components/module/activity/score/topEight.vue?v=' + new Date().getTime()),
'score-top-eight': httpVueLoader('/components/module/activity/score/scoreTopEight.vue?v=' + new Date().getTime()),
},
methods: {
status2Type(id) {
if (this.pageForm.status2 === id) {
this.$set(this.pageForm, "status2", 9)
this.$set(this.pageForm, "sex", "男")
this.$set(this.pageForm, "activityId", this.activityList[0].id)
} else {
this.$set(this.pageForm, "status2", id)
}
this.searchClick(id)
},
statusType(state) {
let promise = Promise.resolve()
if (state === "1") {
promise = this.getYear8(1)
} else if (state === "2") {
promise = this.getYear8(2)
} else if (state === "3") {
promise = this.annualResults()
}
promise.then(() => {
if (this.pageForm.status === state) {
this.$set(this.pageForm, "status", null)
this.$set(this.pageForm, "activityId", this.activityList[0].id)
this.activityChange()
this.$set(this.pageForm, "status2", 9)
} else {
this.$set(this.pageForm, "status", state)
this.$set(this.pageForm, "status2", '')
}
})
},
doExportByActivityStatisticsType() {
const {activityId, year} = this.pageForm
const url = "/platform/activity/statistics/export"
if (this.activityStatisticsType === 1 || this.activityStatisticsType === 2) {
this.$downLoad(url + "/getYear8", {year: year, isMenWomen: this.isMenWomen})
} else if (this.activityStatisticsType === 3) {
this.$downLoad(url + "/getAnnualResults", {year})
} else if (this.activityStatisticsType === 4 || this.activityStatisticsType === 5) {
let sex = this.activityStatisticsType === 4 ? "男" : "女"
this.$downLoad(url + "/isMaleFemale", {activityId: activityId, sex: sex, awardsMode: 4})
} else if (this.activityStatisticsType === 6 || this.activityStatisticsType === 7 || this.activityStatisticsType === 8) {
let sex = this.activityStatisticsType === 6 ? "男" : "女"
let awardsMode = this.activityStatisticsType === 8 ? 2 : 1
this.$downLoad(url + "/isTopEight", {activityId: activityId, sex: sex, awardsMode: awardsMode})
} else if (this.activityStatisticsType === 9 || this.activityStatisticsType === 10) {
let sex = this.activityStatisticsType === 9 ? "男" : "女"
this.$downLoad(url + "/isScoreTopEight", {activityId: activityId, sex: sex})
}
},
doExcelCj() {
const {activityId, unionname} = this.pageForm
let unionId = ''
if (unionname) {
const unionlist = clone(this.unionList)
unionId = unionlist.find(v => v.name === unionname).id
}
this.$downLoad(loc() + "/doExcelCj", {activityId: activityId, unionId: unionId})
},
activityChange() {
this.$set(this.pageForm, "yearDoSearch", null)
const aa = this.activityList.find(v => v.id == this.pageForm.activityId)
if (!aa) {
return
}
if (aa.applyType == 1) {
this.isSearch = false
this.searchOptions = [{id: 9, name: "分工会项目成绩"}]
} else {
this.searchOptions = this.Options
}
this.searchClick(9)
},
unionChange() {
this.searchClick(9)
},
searchClick(id) {
this.$set(this.pageForm, "status", null)
if (!this.pageForm.activityId) {
this.$set(this.pageForm, "activityId", this.activityList[0].id)
}
if (id === 9) {
this.activityStatisticsType = 4
} else if (id === 10) {
this.activityStatisticsType = 5
} else if (id === 6) {
this.activityStatisticsType = 6
} else if (id === 7) {
this.activityStatisticsType = 7
} else if (id === 8) {
this.activityStatisticsType = 8
} else if (id === 11) {
this.activityStatisticsType = 9
} else if (id === 12) {
this.activityStatisticsType = 10
}
this.isSearchOptions = id
if (id <= 5 || id == 9 || id == 10) {
if (id == 1 || id == 2) {
this.isUnion = false
this.isYear8 = false
this.pageForm.sex = id == 1 ? "男" : "女"
this.pageForm.awardsMode = 1
} else if (id == 3 || id == 4) {
this.isUnion = false
this.isUnionisYear8 = false
this.pageForm.sex = id == 3 ? "男" : "女"
this.pageForm.awardsMode = 2
} else if (id == 9 || id == 10) {
this.isUnion = true
this.pageForm.sex = id == 9 ? "男" : "女"
this.pageForm.awardsMode = 4
} else {
this.pageForm.awardsMode = 3
}
this.$refs.female.isMaleFemale()
} else if (id == 6 || id == 7 || id == 8) {
if (id == 6 || id == 7) {
this.isUnion = false
this.isYear8 = false
this.pageForm.sex = id == 6 ? "男" : "女"
this.pageForm.awardsMode = 1
} else if (id == 8) {
this.pageForm.awardsMode = 2
}
this.$refs.doeight.isTopEight()
} else if (id == 11 || id == 12) {
this.pageForm.sex = id == 11 ? "男" : "女"
this.$refs.doTopEight.isScoreTopEight()
}
},
getYear8(isMenWomen) {
this.activityStatisticsType = isMenWomen
this.isMenWomen = isMenWomen
this.isUnion = false
this.isYear8 = true
this.$set(this.pageForm, "activityId", null)
this.$set(this.pageForm, "unionname", null)
this.annualTableColumns = []
this.annualResultsTableData = []
this.tableLoading = true
this.isSearchOptions = 99
return this.$axios.post(loc() + "/getYear8", {
year: this.pageForm.year,
isMenWomen: isMenWomen
}).then((resp) => {
const data = resp.data
this.annualResultsTableData = data.score
this.annualResultsTableData = this.annualResultsTableData.sort((a, b) => b['总分'] - a['总分'])
data.label.forEach(v => {
this.annualTableColumns.push({label: v, prop: v})
})
}).finally(() => {
this.tableLoading = false
})
},
annualResults() {
this.activityStatisticsType = 3
this.isUnion = false
this.isYear8 = false
this.$set(this.pageForm, "activityId", null)
this.$set(this.pageForm, "unionname", null)
this.annualTableColumns = []
this.annualResultsTableData = []
this.tableLoading = true;
this.isSearchOptions = 99
return this.$axios.post(loc() + "/getAnnualResults", {
year: this.pageForm.year
}).then((resp) => {
const data = resp.data
this.annualResultsTableData = data.score
this.annualResultsTableData = this.annualResultsTableData.sort((a, b) => b['总分'] - a['总分'])
data.label.forEach(v => {
this.annualTableColumns.push({label: v, prop: v})
})
}).finally(() => {
this.tableLoading = false
})
},
getActivitys() {
return this.$axios.post(loc() + "/getActivitys", {year: this.pageForm.year}).then((resp) => {
const data = resp.data
this.pageForm = {
activityId: "",
status2: 9,
year: this.pageForm.year
}
this.activityList = data
})
},
changeActivit() {
return this.$axios.post("/platform/activity/apply/getEvents", {activityId: this.pageForm.activityId}).then((resp) => {
this.events = resp
})
},
},
created() {
this.searchOptions = this.Options
this.$businessTool.listUnion().then((unionList) => {
this.unionList = unionList
return this.getActivitys()
}).then(() => {
if (this.activityList.length) {
this.pageForm.activityId = this.activityList[0].id
}
setTimeout(() => {
this.searchClick(9)
}, 200)
})
},
})
</script>
<!--#
}
#-->
@@ -0,0 +1,318 @@
<!--#
layout("/layouts/platform.html"){
#-->
<div id="app" v-cloak>
<guava ref="guava">
<el-card shadow="never">
<search @search="doSearch">
<search-item label="姓名/工号">
<el-input v-model="pageForm.searchKeyword" clearable placeholder="请输入姓名或工号"></el-input>
</search-item>
<search-item label="所属工会">
<el-select
v-model="pageForm.unionId"
:disabled="$auth.hasRole('BRANCH_UNION_CHAIRMAN')"
@change="flushUnits"
@clear="flushUnits"
clearable
collapse-tags
filterable
multiple
placeholder="请选择所属工会"
style="width: 100%">
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in unions"></el-option>
</el-select>
</search-item>
<search-item label="所属单位">
<el-select
v-model="pageForm.unitId"
clearable
collapse-tags
filterable
multiple
placeholder="请选择所属单位"
style="width: 100%">
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in units"></el-option>
</el-select>
</search-item>
<search-item label="在职状态">
<dict-select
v-model="pageForm.userStates"
code="USER_STATE"
collapse-tags
multiple
placeholder="请选择在职状态"></dict-select>
</search-item>
<search-item label="教职工类别">
<dict-select
v-model="pageForm.personTypes"
code="USER_PERSON_TYPE"
collapse-tags
multiple
placeholder="请选择教职工类别"></dict-select>
</search-item>
<search-item label="编制类别">
<dict-select
v-model="pageForm.preparedBys"
code="USER_PREPARED_BY_TYPE"
collapse-tags
multiple
placeholder="请选择编制类别"></dict-select>
</search-item>
<search-item label="流程状态">
<el-select
v-model="pageForm.instanceStates"
clearable
collapse-tags
filterable
multiple
placeholder="请选择流程状态"
style="width: 100%">
<el-option :key="item.value" :label="item.label" :value="item.value" v-for="item in instanceStateOptions"></el-option>
</el-select>
</search-item>
<search-item label="申请时间">
<el-date-picker
v-model="pageForm.applyDateRange"
clearable
end-placeholder="结束日期"
range-separator="至"
start-placeholder="开始日期"
style="width: 100%"
type="daterange"
value-format="yyyy-MM-dd"></el-date-picker>
</search-item>
</search>
</el-card>
<el-card shadow="never" class="mt10">
<table-tool label="会员申请记录统计">
<el-button icon="el-icon-printer" type="primary" size="small" @click="doExport">导出</el-button>
<el-popover placement="bottom" trigger="click" width="220">
<div style="padding:4px 0;border-bottom:1px solid #eee;">
<el-button size="mini" @click="checkAll">全选</el-button>
<el-button size="mini" @click="invertCheck">反选</el-button>
</div>
<div style="max-height:40vh;overflow-y:auto;padding:6px 0;">
<el-checkbox-group v-model="checkedFields">
<el-checkbox
:key="column.prop"
:label="column.prop"
style="display:block;margin:6px 0;"
v-for="column in tableColumns">
{{ column.label }}
</el-checkbox>
</el-checkbox-group>
</div>
<el-button slot="reference" type="text" icon="el-icon-s-operation" size="small" style="margin-left:12px;">
列设置
</el-button>
</el-popover>
</table-tool>
<el-table
:data="tableData"
:header-cell-style="{background:'#FAFAFA'}"
@sort-change="pageOrder"
border
row-key="id"
stripe
style="width: 100%"
v-loading="tableLoading">
<el-table-column
:index="indexMethod"
align="center"
fixed="left"
header-align="center"
label="序号"
type="index"
width="80px"></el-table-column>
<el-table-column
:fixed="column.fixed"
:key="column.prop"
:label="column.label"
:prop="column.prop"
:sortable="column.sortable"
:width="column.width"
align="center"
header-align="center"
min-width="120px"
show-overflow-tooltip
v-for="column in showColumns">
<template scope="{row}" v-if="column.prop === 'loginName'">
<el-link @click="openView(row)" type="primary">{{ row.loginName }}</el-link>
</template>
<template scope="{row}" v-else-if="column.prop === 'applyDateTime'">
{{ row.applyDateTime ? $moment(row.applyDateTime).format("YYYY-MM-DD HH:mm") : "" }}
</template>
<template scope="{row}" v-else-if="column.prop === 'signState'">
<el-tag :type="row.signState === '已签字' ? 'success' : 'warning'" size="small">{{ row.signState }}</el-tag>
</template>
<template scope="{row}" v-else-if="column.prop === 'instanceState'">
<enum-tag :value="row.instanceState" name="ProcessInstanceStateEnum" label_key="message" size="small"></enum-tag>
</template>
</el-table-column>
<el-table-column align="center" fixed="right" header-align="center" label="操作" width="100px">
<template scope="{row}">
<el-button size="mini" type="primary" @click="openView(row)">查看</el-button>
</template>
</el-table-column>
</el-table>
<!--#include("/layouts/pagination.html"){}#-->
</el-card>
<template #view>
<info ref="infoRef"></info>
</template>
</guava>
</div>
<script nonce="${cspNonce!}">
<!--#include("../../apply/common/info.js"){}#-->
new Vue({
el: "#app",
store,
mixins: [initTableMixins],
data() {
return {
pageForm: {
searchKeyword: "",
unionId: [],
unitId: [],
userStates: [],
personTypes: [],
preparedBys: [],
instanceStates: [],
applyDateRange: []
},
unions: [],
units: [],
checkedFields: [],
instanceStateOptions: [
{ label: "进行中", value: 10 },
{ label: "已完成", value: 20 },
{ label: "已撤回", value: 30 },
{ label: "强行终止", value: 40 },
{ label: "已拒绝", value: 45 },
{ label: "挂起", value: 50 },
{ label: "已废弃", value: 99 }
],
tableColumns: [
{ prop: "loginName", label: "工号", width: 120, fixed: "left", sortable: true },
{ prop: "userName", label: "姓名", width: 120, fixed: "left", sortable: true },
{ prop: "unionName", label: "所属工会", width: 160, sortable: true },
{ prop: "unitName", label: "所属单位", width: 180, sortable: true },
{ prop: "userState", label: "在职状态", width: 120, sortable: true },
{ prop: "personType", label: "教职工类别", width: 140, sortable: true },
{ prop: "preparedBy", label: "编制类别", width: 120, sortable: true },
{ prop: "origin", label: "来源", width: 100, sortable: true },
{ prop: "applyDateTime", label: "申请时间", width: 160, sortable: true },
{ prop: "signState", label: "签字状态", width: 110 },
{ prop: "curTaskName", label: "当前节点", width: 160 },
{ prop: "instanceState", label: "流程状态", width: 120, sortable: true, exportProp: "instanceStateName" }
]
}
},
components: {
"info": INFO
},
computed: {
showColumns() {
return this.tableColumns.filter(column => this.checkedFields.includes(column.prop))
}
},
methods: {
openView(row) {
this.$refs.guava.view(() => {
this.$refs.infoRef.onOpen(row)
})
},
buildRequestForm() {
const pageForm = clone(this.pageForm)
pageForm.unionId = JSON.stringify(this.pageForm.unionId)
pageForm.unitId = JSON.stringify(this.pageForm.unitId)
pageForm.userStates = JSON.stringify(this.pageForm.userStates)
pageForm.personTypes = JSON.stringify(this.pageForm.personTypes)
pageForm.preparedBys = JSON.stringify(this.pageForm.preparedBys)
pageForm.instanceStates = JSON.stringify(this.pageForm.instanceStates)
if (this.pageForm.applyDateRange && this.pageForm.applyDateRange.length > 0) {
pageForm.startApplyDate = this.pageForm.applyDateRange[0]
pageForm.endApplyDate = this.pageForm.applyDateRange[1]
} else {
pageForm.startApplyDate = ""
pageForm.endApplyDate = ""
}
return pageForm
},
pageData() {
const pageForm = this.buildRequestForm()
this.tableLoading = true
this.$axios.post("/platform/member/apply/statistics/pageData", pageForm).then((res) => {
if (res.code === 0) {
this.tableData = res.data.list
this.pageForm.totalCount = res.data.totalCount
} else {
this.$message.error(res.msg)
}
}).finally(() => {
this.tableLoading = false
})
},
doExport() {
const pageForm = this.buildRequestForm()
const columns = this.tableColumns.filter(column => this.checkedFields.includes(column.prop)).map(column => {
return {
prop: column.exportProp ? column.exportProp : column.prop,
label: column.label
}
})
pageForm.columns = JSON.stringify(columns)
this.$downLoad("/platform/member/apply/statistics/doExport", pageForm)
},
checkAll() {
this.checkedFields = this.tableColumns.map(column => column.prop)
},
invertCheck() {
const allFields = this.tableColumns.map(column => column.prop)
this.checkedFields = allFields.filter(prop => !this.checkedFields.includes(prop))
},
flushUnits() {
this.$set(this.pageForm, "unitId", [])
this.units = []
if (this.pageForm.unionId && this.pageForm.unionId.length === 1) {
this.$businessTool.listUnit(this.pageForm.unionId[0]).then((data) => {
this.units = data
})
} else {
this.$businessTool.listUnit().then((data) => {
this.units = data
})
}
},
initQueryOptions() {
if (this.$auth.hasRoleOr(["SYSADMIN", "SCHOOL_UNION_MEMBER_ADMIN", "SCHOOL_UNION_ADMIN"])) {
this.$businessTool.listUnion().then((data) => {
this.unions = data
})
this.$businessTool.listUnit().then((data) => {
this.units = data
})
} else if (this.$auth.hasRole("BRANCH_UNION_CHAIRMAN")) {
this.$set(this.pageForm, "unionId", [this.$store.state.user.union.id])
this.$businessTool.listUnion(this.$store.state.user.union.id).then((data) => {
this.unions = data
})
this.$businessTool.listUnit(this.$store.state.user.union.id).then((data) => {
this.units = data
})
}
}
},
created() {
this.checkedFields = this.tableColumns.map(column => column.prop)
this.initQueryOptions()
this.pageData()
}
})
</script>
<!--#
}
#-->