Merge remote-tracking branch 'origin/main'

This commit is contained in:
Paidax
2024-09-12 14:30:00 +08:00
129 changed files with 11744 additions and 4860 deletions
@@ -1,5 +1,7 @@
package io.v.nutz.jf.controller.activitybx; package io.v.nutz.jf.controller.activitybx;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil; import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi; import io.v.nutz.base.utils.Vi;
@@ -10,6 +12,7 @@ import io.v.nutz.sys.models.Sys_signature;
import io.v.nutz.sys.services.SysSignatureService; import io.v.nutz.sys.services.SysSignatureService;
import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls; import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql; import org.nutz.dao.sql.Sql;
@@ -17,7 +20,6 @@ import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json; import org.nutz.json.Json;
import org.nutz.lang.Strings; import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
@@ -90,8 +92,8 @@ public class AccountingCon {
} else { } else {
cnd.asc("bx.state_id").desc("bx.apply_time"); cnd.asc("bx.state_id").desc("bx.apply_time");
} }
Vi.cndPlus(cnd, "u.unitid", "=", unitId); Vi.cndPlus(cnd, "bxr.unitid", "=", unitId);
Vi.cndPlus(cnd, "u.unionid", "=", unionId); Vi.cndPlus(cnd, "bxr.unionid", "=", unionId);
sql.setCondition(cnd); sql.setCondition(cnd);
return activityBxService.listPageMap(pageNumber, pageSize, sql); return activityBxService.listPageMap(pageNumber, pageSize, sql);
} }
@@ -119,5 +121,17 @@ public class AccountingCon {
return activityBxService.dao().query(Goods.class, Cnd.where("reid", "=", id)); return activityBxService.dao().query(Goods.class, Cnd.where("reid", "=", id));
} }
@At
public Object doRevoke(String id) {
if (StrUtil.isBlank(id)) {
return Result.error("参数错误");
}
activityBxService.update(Chain.make("state_id", 1020)
.add("accounting", null)
.add("accounting_name", null),
Cnd.where("id", "=", id));
return Result.success("撤回成功");
}
} }
@@ -105,8 +105,8 @@ public class ReimbursementViewCon {
if (Vi.isNotBlank(searchName, searchKeyword)) { if (Vi.isNotBlank(searchName, searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword); cnd.where().andLike(searchName, searchKeyword);
} }
Vi.cndPlus(cnd, "u.unitid", "=", unitId); Vi.cndPlus(cnd, "bxr.unitid", "=", unitId);
Vi.cndPlus(cnd, "u.unionid", "=", unionId); Vi.cndPlus(cnd, "bxr.unionid", "=", unionId);
if (Vi.isNotBlank(pageOrderName, pageOrderBy)) { if (Vi.isNotBlank(pageOrderName, pageOrderBy)) {
cnd.orderBy(pageOrderName, pageOrderBy); cnd.orderBy(pageOrderName, pageOrderBy);
@@ -1,9 +1,9 @@
package io.v.nutz.zgfw.controller.lxy; package io.v.nutz.lxy.controller;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.Vi; import io.v.nutz.base.utils.Vi;
import io.v.nutz.util.ShiroUtil; import io.v.nutz.lxy.service.LxyBmService;
import io.v.nutz.zgfw.service.LxyBmService; import io.v.nutz.web.commons.utils.ShiroUtil;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls; import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record; import org.nutz.dao.entity.Record;
@@ -1,10 +1,10 @@
package io.v.nutz.zgfw.controller.lxy; package io.v.nutz.lxy.controller;
import cn.wizzer.framework.base.service.BaseService; import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.zgfw.service.LxyBmService; import io.v.nutz.lxy.service.LxyBmService;
import io.v.nutz.zgfw.service.LxyHdService; import io.v.nutz.lxy.service.LxyHdService;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls; import org.nutz.dao.Sqls;
@@ -1,15 +1,17 @@
package io.v.nutz.zgfw.controller.lxy; package io.v.nutz.lxy.controller;
import cn.wizzer.framework.base.service.BaseService; import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil; import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Vi; import io.v.nutz.base.utils.Vi;
import io.v.nutz.lxy.model.Lxy_bm;
import io.v.nutz.lxy.model.Lxy_grxx;
import io.v.nutz.lxy.service.LxyBmService;
import io.v.nutz.lxy.service.LxyGrxxService;
import io.v.nutz.lxy.service.LxyHdService;
import io.v.nutz.sys.models.Sys_file; import io.v.nutz.sys.models.Sys_file;
import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zgfw.model.lxy.Lxy_grxx; import org.apache.shiro.authz.annotation.Logical;
import io.v.nutz.zgfw.service.LxyBmService;
import io.v.nutz.zgfw.service.LxyGrxxService;
import io.v.nutz.zgfw.service.LxyHdService;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain; import org.nutz.dao.Chain;
@@ -19,9 +21,12 @@ import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static; import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings; import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.List; import java.util.List;
@@ -59,7 +64,14 @@ public class LxyFghShController {
@At @At
@ViReturn @ViReturn
public Object pageData(Integer year, String hdid, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) { @RequiresPermissions("zgfw.lxy.fghsh")
public Object pageData(@Param(value = "year", required = false) Integer year,
@Param(value = "hdid", required = false) String hdid,
@Param(value = "searchName", required = false) String searchName,
@Param(value = "searchKeyword", required = false) String searchKeyword,
@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize,
@Param(value = "pageOrderName", required = false) String pageOrderName,
@Param(value = "pageOrderBy", required = false) String pageOrderBy) {
Sql sql = Sqls.create("SELECT\n" + Sql sql = Sqls.create("SELECT\n" +
"\tunit.name unitname,\n" + "\tunit.name unitname,\n" +
"\tl.id,\n" + "\tl.id,\n" +
@@ -121,6 +133,7 @@ public class LxyFghShController {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("zgfw.lxy.fghsh")
public Object sh(String hdid, String uid, Integer bmzt) { public Object sh(String hdid, String uid, Integer bmzt) {
lxyBmService.update(Chain.make("bmzt", bmzt), Cnd.where("hdid", "=", hdid).and("userid", "=", uid)); lxyBmService.update(Chain.make("bmzt", bmzt), Cnd.where("hdid", "=", hdid).and("userid", "=", uid));
return null; return null;
@@ -128,11 +141,22 @@ public class LxyFghShController {
@At @At
@ViReturn @ViReturn
@RequiresPermissions(value = {"zgfw.lxy.xghsh", "zgfw.lxy.fghsh"}, logical = Logical.OR)
public Object getBmInfo(String id) { public Object getBmInfo(String id) {
Lxy_grxx grxx = lxyGrxxService.fetch(id); Lxy_grxx grxx = lxyGrxxService.fetch(id);
List<Sys_file> files = baseService.dao().query(Sys_file.class, Cnd.where("reid", "=", id)); List<Sys_file> files = baseService.dao().query(Sys_file.class, Cnd.where("reid", "=", id));
grxx.setFiles(files); grxx.setFiles(files);
return grxx;
Lxy_bm lxyBm = lxyBmService.dao().fetch(Lxy_bm.class, Cnd.where("hdid", "=", grxx.getHdid())
.and("userid", "=", grxx.getUserid()));
NutMap nutMap = Lang.obj2nutmap(grxx);
nutMap.put("bmFiles", lxyBm.getFiles());
nutMap.put("mobile", lxyBm.getMobile());
nutMap.put("idcard", lxyBm.getIdcard());
nutMap.put("zyhj", lxyBm.getZyhj());
nutMap.put("bz", lxyBm.getBz());
return nutMap;
} }
} }
@@ -0,0 +1,304 @@
package io.v.nutz.lxy.controller;
import cn.wizzer.framework.base.Result;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.lxy.model.Lxy_bm;
import io.v.nutz.lxy.model.Lxy_grxx;
import io.v.nutz.lxy.service.LxyBmService;
import io.v.nutz.lxy.service.LxyGrxxService;
import io.v.nutz.lxy.service.LxyHdService;
import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.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.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.trans.Trans;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: 1V
* @DateTime: 2020/8/28 9:21
* @Description: 院级工会统一报名
*/
@At("/platform/zgfw/lxy/ghbm")
@Ok("json")
@IocBean
@RequiresAuthentication
public class LxyGhbmController {
@Inject
private LxyHdService lxyHdService;
@Inject
private Vi vi;
@Inject
private LxyBmService lxyBmService;
@Inject
private SysUserService sysUserService;
@Inject
private LxyGrxxService lxyGrxxService;
@At("")
@Ok("beetl:/platform/zgfw/lxy/HdGhbm.html")
@RequiresPermissions("zgfw.lxy.ghbm")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.ghbm")
public Object pageData(@Param(value = "year", required = false) Integer year,
@Param(value = "hdid", required = false) String hdid,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "searchName", required = false) String searchName,
@Param(value = "searchKeyword", required = false) String searchKeyword,
@Param(value = "pageNumber", required = false) int pageNumber,
@Param(value = "pageSize", required = false) int pageSize,
@Param(value = "pageOrderName", required = false) String pageOrderName,
@Param(value = "pageOrderBy", required = false) String pageOrderBy) {
Sql sql = Sqls.create("""
SELECT
mefp.*,
(
mefp.number - ( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt not in (2,4))\s
) remain,
(
( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt =5 )\s
) passnum,
(
( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt = 3 )\s
) reviewnum,
un.unionname,
un.unioncode,
hd.*
FROM
lxy_mefp mefp
LEFT JOIN sys_union un ON mefp.ghid = un.id
LEFT JOIN lxy_hd hd ON mefp.hdid = hd.id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and(new Static("now() < hd.bmjzsj"));
cnd.and("mefp.hdid", "=", hdid);
cnd.andEX("un.id", "=", unionId);
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "SchoolUnionAdmin"})) {
cnd.and(new Static("mefp.ghid in " + vi.getMangeUnionStr()));
//工会管理员查看分配名额大于0的
cnd.and("mefp.number", ">", 0);
}
if (year != null) {
cnd.and("YEAR(hdcjsj)", "=", year);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.desc("hdcjsj");
}
sql.setCondition(cnd);
return lxyHdService.listPage(pageNumber, pageSize, sql);
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.ghbm")
public Object getNotApply(String unionid, String hdid,
@Param(value = "query", required = false) String query,
@Param(value = "checks", required = false) String[] checks) {
Sql sql = Sqls.create("""
SELECT
u.id,
u.sex,
u.mobile,
u.unitid,
TIMESTAMPDIFF(
YEAR,
u.birthday,
CURDATE()) age,
u.username,
u.loginname,
unit.`name` unitname,
un.unionname,
u.idcard
FROM
sys_user u
LEFT JOIN lxy_bm bm ON bm.userid = u.id
AND bm.hdid = @hdid
LEFT JOIN sys_unit unit ON u.unitid = unit.id
LEFT JOIN ry_rygl_gr ry ON ry.userid = u.id
LEFT JOIN sys_union un ON unit.unionid = un.id $condition
""").setParam("hdid", hdid).setParam("unionid", unionid);
Cnd cnd = Cnd.NEW();
cnd.and("member", "=", 1);
cnd.and("unit.unionid", "=", unionid);
cnd.and(new Static("u.id NOT IN ( SELECT bm.userid FROM lxy_bm bm WHERE bm.hdid = '" + hdid + "' ) "));
if (checks != null && checks.length > 0) {
for (String check : checks) {
if (check.equals("honer")) {
cnd.and(new Static("ry.zyxjsj is not null"));
}
if (check.equals("five")) {
cnd.and(new Static(" u.id not in (SELECT bm.userid from lxy_bm bm WHERE YEAR (NOW())- 5 < YEAR ( bm.bmsj ) )"));
}
}
}
sql.setCondition(cnd);
return lxyBmService.list(sql);
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.ghbm")
public Object getHasApply(String unionid, String hdid,
@Param(value = "query", required = false) String query,
@Param(value = "checks", required = false) String[] checks) {
Sql sql = Sqls.create("""
SELECT
u.id,
u.loginname,
u.username,
bm.bmzt,
bm.age,
bm.files,
bm.zyhj,
bm.bz,
bm.mobile,
bm.idcard,
bm.unitid,
bm.unitname,
bm.unionname
FROM
lxy_bm bm
LEFT JOIN `user` u ON u.id = bm.userid
where bm.hdid = @hdid and u.unionid = @unionid ORDER BY bm.bmzt ASC
""").setParam("hdid", hdid).setParam("unionid", unionid);
return Result.success().addData(lxyBmService.list(sql));
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.ghbm")
public Object bm(@Param("::data") List<NutMap> bmMapList, @Param("flag") boolean flag) {
Trans.exec(() -> {
List<Lxy_bm> bmList = Lang.collection2list(bmMapList, Lxy_bm.class);
if (Lang.isNotEmpty(bmList)) {
lxyBmService.clear(Cnd
.NEW().and(Cnd.exps("bmzt", "is", null).or("bmzt", "=", 4))
.and("ghid", "=", bmList.get(0).getGhid())
.and("hdid", "=", bmList.get(0).getHdid()));
List<Lxy_grxx> grxxList = new ArrayList<>();
for (Lxy_bm bm : bmList) {
lxyBmService.clear(Cnd
.where("userid","=",bm.getUserid())
.and("ghid", "=", bmList.get(0).getGhid())
.and("hdid", "=", bmList.get(0).getHdid()));
Lxy_bm fetch = lxyBmService.fetch(Cnd.where("hdid", "=", bm.getGhid()).and("userid", "=", bm.getUserid()).and("bmzt", "=", 3));
if (Lang.isNotEmpty(fetch)) {
continue;
}
bm.setBmzt(flag ? 3 : null);
bm.setBmlx(1);
bm.setBmsj(DateUtil.getDate());
if (flag) {
Sql sql = Sqls.create("SELECT u.loginname,u.username,u.mobile,TIMESTAMPDIFF(YEAR,u.birthday,CURDATE()) age,u.sex,u.position,u.personType,u.nation,u.idcard FROM sys_user u WHERE u.id = '" + bm.getUserid() + "'");
List<Record> records = sysUserService.list(sql);
records.forEach(item -> {
Lxy_grxx lxy_grxx = new Lxy_grxx();
lxy_grxx.setLoginname(item.getString("loginname"));
lxy_grxx.setUsername(item.getString("username"));
lxy_grxx.setMobile(bm.getMobile());
lxy_grxx.setAge(bm.getAge());
lxy_grxx.setSex(item.getString("sex"));
lxy_grxx.setZw(item.getString("position"));
lxy_grxx.setRsbz(item.getString("personType"));
lxy_grxx.setMz(item.getString("nation"));
lxy_grxx.setIdcard(bm.getIdcard());
lxy_grxx.setChry(new ArrayList());
lxy_grxx.setUserid(bm.getUserid());
lxy_grxx.setHdid(bm.getHdid());
lxy_grxx.setGhid(bm.getGhid());
grxxList.add(lxy_grxx);
});
}
}
lxyBmService.insert(bmList);
lxyGrxxService.insert(grxxList);
}
});
return null;
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.ghbm")
public Object findBm(String ghId, String hdId) {
Sql sql = Sqls.create("""
SELECT
l.id,
hd.id hdid,
u.id uid,
u.loginname,
u.username,
u.sex,
bm.age,
bm.mobile,
bm.idcard,
bm.unitname,
bm.bmzt,
bm.zyhj,
bm.bz,
bm.ghid
FROM
lxy_bm bm
LEFT JOIN lxy_hd hd ON hd.id = bm.hdid
LEFT JOIN sys_user u ON u.id = bm.userid
LEFT JOIN sys_unit unit ON u.unitid = unit.id
LEFT JOIN Lxy_grxx l ON l.loginname = u.loginname
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("bm.bmzt","NOT IN",List.of(2,4,6));
cnd.and("bm.hdid","=",hdId);
cnd.and("bm.ghid","=",ghId);
cnd.groupBy("u.loginname");
cnd.desc("bm.bmzt");
sql.setCondition(cnd);
return lxyBmService.list(sql);
}
}
@@ -1,16 +1,16 @@
package io.v.nutz.zgfw.controller.lxy; package io.v.nutz.lxy.controller;
import cn.wizzer.framework.base.service.BaseService; import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil; import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Vi; import io.v.nutz.base.utils.Vi;
import io.v.nutz.lxy.model.Lxy_grxx;
import io.v.nutz.lxy.service.LxyBmService;
import io.v.nutz.lxy.service.LxyGrxxService;
import io.v.nutz.lxy.service.LxyHdService;
import io.v.nutz.sys.models.Sys_file; import io.v.nutz.sys.models.Sys_file;
import io.v.nutz.sys.services.SysUserService; import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zgfw.model.lxy.Lxy_grxx;
import io.v.nutz.zgfw.service.LxyBmService;
import io.v.nutz.zgfw.service.LxyGrxxService;
import io.v.nutz.zgfw.service.LxyHdService;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -66,34 +66,42 @@ public class LxyGrBmController {
@At @At
@ViReturn @ViReturn
public Object pageData(Integer year, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) { @RequiresPermissions("zgfw.lxy.grbm")
Sql sql = Sqls.create("SELECT\n" + public Object pageData(@Param(value = "year",required = false) Integer year,
"hd.id hdid,\n" + @Param(value = "searchName",required = false) String searchName,
"hd.`name`,\n" + @Param(value = "searchKeyword",required = false) String searchKeyword,
"hd.hdcd,\n" + @Param("pageNumber") int pageNumber,@Param("pageSize") int pageSize,
"hd.hdkssj,\n" + @Param(value = "pageOrderName",required = false) String pageOrderName,
"hd.hdjssj,\n" + @Param(value = "pageOrderBy",required = false) String pageOrderBy) {
"hd.bmjzsj,\n" + Sql sql = Sqls.create("""
"u.id uid,\n" + SELECT
"u.loginname,\n" + hd.id hdid,
"u.username,\n" + hd.`name`,
"u.chry,\n" + hd.hdcd,
"u.rsbz,\n" + hd.hdkssj,
"u.zw,\n" + hd.hdjssj,
"u.sex,\n" + hd.bmjzsj,
"u.mobile,\n" + u.id uid,
"u.mz,\n" + u.loginname,
"u.idcard,\n" + u.username,
"unit.unionid,\n" + u.chry,
"bm.bmzt ,\n" + u.rsbz,
"g.id gid,\n" + u.zw,
"TIMESTAMPDIFF(YEAR,u.birthday,CURDATE()) age\n" + u.sex,
"FROM lxy_bm bm\n" + u.mobile,
"LEFT JOIN lxy_hd hd ON hd.id = bm.hdid\n" + u.mz,
"LEFT JOIN sys_user u ON u.id = bm.userid \n" + u.idcard,
"LEFT JOIN sys_unit unit ON unit.id = u.unitid\n" + unit.unionid,
"LEFT JOIN sys_union un ON un.id = unit.unionid\n" + bm.bmzt ,
"LEFT JOIN lxy_grxx g ON g.userid = bm.userid $condition"); g.id gid,
TIMESTAMPDIFF(YEAR,u.birthday,CURDATE()) age
FROM lxy_bm bm
LEFT JOIN lxy_hd hd ON hd.id = bm.hdid
LEFT JOIN sys_user u ON u.id = bm.userid
LEFT JOIN sys_unit unit ON unit.id = u.unitid
LEFT JOIN sys_union un ON un.id = unit.unionid
LEFT JOIN lxy_grxx g ON g.userid = bm.userid $condition
""");
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.and(new Static("now() < hd.bmjzsj")); cnd.and(new Static("now() < hd.bmjzsj"));
@@ -126,6 +134,7 @@ public class LxyGrBmController {
@POST @POST
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@ViReturn @ViReturn
@RequiresPermissions("zgfw.lxy.grbm")
public Object doAdd(Lxy_grxx lxy_grxx, @Param("fileList") TempFile[] fileList) throws IOException { public Object doAdd(Lxy_grxx lxy_grxx, @Param("fileList") TempFile[] fileList) throws IOException {
lxy_grxx = lxyGrxxService.insert(lxy_grxx); lxy_grxx = lxyGrxxService.insert(lxy_grxx);
@@ -154,6 +163,7 @@ public class LxyGrBmController {
@POST @POST
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@ViReturn @ViReturn
@RequiresPermissions("zgfw.lxy.grbm")
public Object doEdit(Lxy_grxx lxy_grxx, @Param("fileList") TempFile[] fileList, String[] delFiles) throws IOException { public Object doEdit(Lxy_grxx lxy_grxx, @Param("fileList") TempFile[] fileList, String[] delFiles) throws IOException {
lxyGrxxService.updateIgnoreNull(lxy_grxx); lxyGrxxService.updateIgnoreNull(lxy_grxx);
@@ -184,6 +194,7 @@ public class LxyGrBmController {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("zgfw.lxy.grbm")
public Object findOne(String id) { public Object findOne(String id) {
Lxy_grxx grxx = lxyGrxxService.fetch(id); Lxy_grxx grxx = lxyGrxxService.fetch(id);
List<Sys_file> files = baseService.dao().query(Sys_file.class, Cnd.where("reid", "=", id)); List<Sys_file> files = baseService.dao().query(Sys_file.class, Cnd.where("reid", "=", id));
@@ -1,14 +1,14 @@
package io.v.nutz.zgfw.controller.lxy; package io.v.nutz.lxy.controller;
import cn.wizzer.framework.base.service.BaseService; import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil; import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.dao.CndPlus; import io.v.nutz.dao.CndPlus;
import io.v.nutz.lxy.model.Lxy_hd;
import io.v.nutz.lxy.model.Lxy_mefp;
import io.v.nutz.lxy.service.LxyHdService;
import io.v.nutz.lxy.service.LxyMefpService;
import io.v.nutz.sys.models.Sys_file; import io.v.nutz.sys.models.Sys_file;
import io.v.nutz.zgfw.model.lxy.Lxy_hd;
import io.v.nutz.zgfw.model.lxy.Lxy_mefp;
import io.v.nutz.zgfw.service.LxyHdService;
import io.v.nutz.zgfw.service.LxyMefpService;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.boot.starter.ftp.FtpService; import org.nutz.boot.starter.ftp.FtpService;
@@ -62,12 +62,20 @@ public class LxyHdCon {
@At @At
@ViReturn @ViReturn
public Object pageData(String hdcd,String pastQuota,Integer year, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) { @RequiresPermissions("zgfw.lxy.hdmange")
CndPlus cnd = CndPlus.create(); public Object pageData(@Param(value = "hdcd",required = false) String hdcd,
@Param(value = "pastQuota",required = false) String pastQuota,
@Param(value = "year",required = false) Integer year,
@Param(value = "searchName",required = false) String searchName,
@Param(value = "searchKeyword",required = false) String searchKeyword,
@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize,
@Param(value = "pageOrderName",required = false) String pageOrderName,
@Param(value = "pageOrderBy",required = false) String pageOrderBy) {
Cnd cnd = Cnd.NEW();
cnd.andExcludeEmpty("YEAR(hdcjsj)", "=", year); cnd.andEX("YEAR(hdcjsj)", "=", year);
cnd.andExcludeEmpty("id", "=", hdcd); cnd.andEX("id", "=", hdcd);
cnd.andExcludeEmpty("id", "=", pastQuota); cnd.andEX("id", "=", pastQuota);
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) { if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword); cnd.where().andLike(searchName, searchKeyword);
} }
@@ -85,7 +93,8 @@ public class LxyHdCon {
@POST @POST
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@ViReturn @ViReturn
public Object doAdd(Lxy_hd hd, @Param("files") TempFile[] files, Lxy_mefp[] mefp) throws IOException { @RequiresPermissions("zgfw.lxy.hdmange")
public Object doAdd(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, Lxy_mefp[] mefp) throws IOException {
hd.setHdcjsj(new Date()); hd.setHdcjsj(new Date());
hd = lxyHdService.insert(hd); hd = lxyHdService.insert(hd);
@@ -114,6 +123,7 @@ public class LxyHdCon {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("zgfw.lxy.hdmange")
public Object doEditMefp(Lxy_mefp[] mefp) { public Object doEditMefp(Lxy_mefp[] mefp) {
for (Lxy_mefp lxyMefp : mefp) { for (Lxy_mefp lxyMefp : mefp) {
baseService.dao().update("lxy_mefp", Chain.make("number", lxyMefp.getNumber()), Cnd.where("ghid", "=", lxyMefp.getGhid()).and("hdid", "=", lxyMefp.getHdid())); baseService.dao().update("lxy_mefp", Chain.make("number", lxyMefp.getNumber()), Cnd.where("ghid", "=", lxyMefp.getGhid()).and("hdid", "=", lxyMefp.getHdid()));
@@ -125,7 +135,8 @@ public class LxyHdCon {
@POST @POST
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@ViReturn @ViReturn
public Object doEdit(Lxy_hd hd, @Param("files") TempFile[] files, String[] delFiles) throws IOException { @RequiresPermissions("zgfw.lxy.hdmange")
public Object doEdit(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, String[] delFiles) throws IOException {
lxyHdService.updateIgnoreNull(hd); lxyHdService.updateIgnoreNull(hd);
for (TempFile file : files) { for (TempFile file : files) {
@@ -152,6 +163,7 @@ public class LxyHdCon {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("zgfw.lxy.hdmange")
public Object delete(String id) { public Object delete(String id) {
List<Record> files = baseService.dao().query("sys_file", Cnd.where("reid", "=", id)); List<Record> files = baseService.dao().query("sys_file", Cnd.where("reid", "=", id));
files.forEach(file -> { files.forEach(file -> {
@@ -167,12 +179,14 @@ public class LxyHdCon {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("zgfw.lxy.hdmange")
public Object getPastQuota(String pastQuota) { public Object getPastQuota(String pastQuota) {
return lxyMefpService.list(Sqls.create("SELECT fp.ghid,fp.number,un.unionname FROM lxy_mefp fp LEFT JOIN sys_union un ON fp.ghid = un.id WHERE hdid = '" + pastQuota + "'")); return lxyMefpService.list(Sqls.create("SELECT fp.ghid,fp.number,un.unionname FROM lxy_mefp fp LEFT JOIN sys_union un ON fp.ghid = un.id WHERE hdid = '" + pastQuota + "'"));
} }
@At @At
@ViReturn @ViReturn
@RequiresPermissions("zgfw.lxy.hdmange")
public Object getUnions(){ public Object getUnions(){
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
@@ -0,0 +1,180 @@
package io.v.nutz.lxy.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.MsgApi;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.lxy.model.Lxy_bm;
import io.v.nutz.lxy.service.LxyGrxxService;
import io.v.nutz.lxy.service.LxyHdService;
import io.v.nutz.util.ViTool;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author: Aaron
* @create: 2020-09-25 14:55
* @description: 疗休养活动统计
**/
@At("/platform/zgfw/lxy/hdtj")
@Ok("json")
@IocBean
@RequiresAuthentication
public class LxyHdTjController {
@Inject
private LxyHdService lxyHdService;
@Inject
private LxyGrxxService lxyGrxxService;
@Inject
private Vi vi;
@Inject
private MsgApi msgApi;
@At("")
@Ok("beetl:/platform/zgfw/lxy/HdTj.html")
@RequiresPermissions("zgfw.lxy.hdtj")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.hdtj")
public Object pageData(@Param(value = "hdid", required = false) String hdid,
@Param(value = "ghid", required = false) String ghid,
@Param(value = "searchKey", required = false) String searchKey,
@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("SELECT gr.* ,u.unionname,u.unioncode,u.unitname unitname,u.unitcode FROM `lxy_grxx` gr \n" +
"LEFT JOIN lxy_bm bm ON bm.userid = gr.userid \n" +
"LEFT JOIN `user` u ON u.id=bm.userid $condition");
cnd.and(new Static("bm.bmzt = 5"));
cnd.and("gr.hdid", "=", hdid);
if (Strings.isNotBlank(ghid)) {
cnd.and("gr.ghid", "=", ghid);
}
if (Strings.isNotBlank(searchKey)) {
cnd.where().andLike("u.loginname", searchKey).orLike("u.username", searchKey);
}
cnd.groupBy("bm.userid");
cnd.asc("u.unioncode");
sql.setCondition(cnd);
return lxyGrxxService.listPage(pageNumber, pageSize, sql);
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.hdtj")
public Object getLxyHd(String year) {
return lxyHdService.list(Sqls.create("SELECT id,`name` FROM `lxy_hd` WHERE YEAR(hdcjsj) = @year ORDER BY hdcjsj DESC ").setParam("year", year));
}
@At
@Ok("void")
@RequiresPermissions("zgfw.lxy.hdtj")
public void doExport(@Param(value = "hdid", required = false) String hdid,
@Param(value = "hdname", required = false) String hdname,
@Param(value = "ghid", required = false) String ghid, HttpServletResponse response) throws IOException {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
gr.*,
bm.unionname,
bm.unitname,
bm.zyhj,
bm.bz
FROM
`lxy_grxx` gr
LEFT JOIN lxy_bm bm ON bm.userid = gr.userid
LEFT JOIN `user` u ON u.id = bm.userid
$condition
""");
cnd.and(new Static("bm.bmzt = 5"));
cnd.and("gr.hdid", "=", hdid);
if (Strings.isNotBlank(ghid)) {
cnd.and("gr.ghid", "=", ghid);
}
cnd.groupBy("bm.userid");
cnd.asc("bm.unionname").asc("bm.unitname").asc("gr.age");
sql.setCondition(cnd);
List<Record> list = lxyGrxxService.list(sql);
int i = 1;
for (Record r : list) {
r.set("index", i);
List<NutMap> chry = Json.fromJsonAsList(NutMap.class, r.getString("chry"));
for (NutMap map : chry) {
r.set("rych", (r.getString("rych") == null ? "" : r.getString("rych")) + " " + map.getString("shry"));
}
i++;
}
List<ExcelExportEntity> entities = new ArrayList<>();
entities.add(new ExcelExportEntity("序号", "index", 10));
entities.add(new ExcelExportEntity("工号", "loginname", 20));
entities.add(new ExcelExportEntity("姓名", "username", 20));
entities.add(new ExcelExportEntity("年龄", "age", 20));
entities.add(new ExcelExportEntity("手机号", "mobile", 20));
entities.add(new ExcelExportEntity("身份证号", "idcard", 20));
entities.add(new ExcelExportEntity("工会", "unionname", 20));
entities.add(new ExcelExportEntity("单位", "unitname", 20));
entities.add(new ExcelExportEntity("单位", "unitname", 20));
entities.add(new ExcelExportEntity("获奖名称", "zyhj", 20));
entities.add(new ExcelExportEntity("备注", "bz", 20));
ViTool.excelResponse(response, "疗休养人员名单汇总表.xlsx");
ExportParams exportParams = new ExportParams();
exportParams.setTitle(hdname);
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entities, list);
workbook.write(response.getOutputStream());
}
@At
@RequiresPermissions("zgfw.lxy.hdtj")
public Object openSendMessage(String hdid,
@Param("sendTypes") String[] sendTypes,
@Param("content") String content) {
List<Lxy_bm> grxxes = lxyGrxxService.dao().query(Lxy_bm.class, Cnd.where("hdid", "=", hdid).and("bmzt", "=", 5));
List<String> loginnames = grxxes.stream().map(Lxy_bm::getLoginname).collect(Collectors.toList());
loginnames.forEach(loginname -> {
/* msgApi.sendMsg(content, "", "", "", "4", new ArrayList<>() {{
add(NutMap.NEW().addv("userId", loginname));
}});*/
});
return null;
}
}
@@ -1,15 +1,15 @@
package io.v.nutz.zgfw.controller.lxy; package io.v.nutz.lxy.controller;
import cn.wizzer.framework.base.Result; import cn.wizzer.framework.base.Result;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil; import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.PageUtil; import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Vi; import io.v.nutz.base.utils.Vi;
import io.v.nutz.lxy.model.Lxy_bm;
import io.v.nutz.lxy.service.LxyBmService;
import io.v.nutz.lxy.service.LxyHdService;
import io.v.nutz.sys.services.SysUserService; import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zgfw.model.lxy.Lxy_bm;
import io.v.nutz.zgfw.service.LxyBmService;
import io.v.nutz.zgfw.service.LxyHdService;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
@@ -78,7 +78,7 @@ public class LxyMetjController {
cnd.and("mefp.hdid", "=", hdid); cnd.and("mefp.hdid", "=", hdid);
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) { if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "SchoolUnionAdmin"})) {
cnd.and(new Static("mefp.ghid in " + vi.getMangeUnionStr())); cnd.and(new Static("mefp.ghid in " + vi.getMangeUnionStr()));
} }
@@ -0,0 +1,336 @@
package io.v.nutz.lxy.controller;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.lxy.model.Lxy_grxx;
import io.v.nutz.lxy.service.LxyBmService;
import io.v.nutz.lxy.service.LxyHdService;
import io.v.nutz.sys.models.Sys_file;
import io.v.nutz.web.commons.utils.FileUtil;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.boot.starter.ftp.FtpService;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Strings;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.trans.Trans;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author: 1V
* @DateTime: 2020/8/28 9:21
* @Description: 校工会审核
*/
@At("/platform/zgfw/lxy/xghsh")
@Ok("json")
@IocBean
@RequiresAuthentication
public class LxyXghshController {
@Inject
private LxyHdService lxyHdService;
@Inject
private LxyBmService lxyBmService;
@Inject
private BaseService baseService;
@Inject
private Vi vi;
@Inject
protected PropertiesProxy conf;
@Inject
private FtpService ftpService;
@At("")
@Ok("beetl:/platform/zgfw/lxy/HdXghsh.html")
@RequiresPermissions("zgfw.lxy.xghsh")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.xghsh")
public Object pageData(@Param(value = "hdid", required = false) String hdid,
@Param(value = "year", required = false) Integer year,
@Param(value = "isAudit", required = false) Integer isAudit,
@Param(value = "searchName", required = false) String searchName,
@Param(value = "unionId", required = false) String unionId,
@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize,
@Param(value = "pageOrderName", required = false) String pageOrderName,
@Param(value = "pageOrderBy", required = false) String pageOrderBy) {
Sql sql = Sqls.create("""
SELECT
mefp.*,
un.unionname,
un.unioncode,
hd.*,
(mefp.number - ( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt NOT IN (2,4)) ) remain,
(SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt = 3) dsh,
(SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt = 5) ysh,
(SELECT GROUP_CONCAT(u.username) FROM lxy_bm bm LEFT JOIN `user` u on u.id=bm.userid WHERE bm.hdid=@hdid AND bm.ghid=mefp.ghid AND bm.bmzt != 4) username ,
(SELECT GROUP_CONCAT(DISTINCT concat(u.username,'(',u.mobile,')') ) FROM `user` u LEFT JOIN sys_user_role ur ON u.id = ur.userId WHERE u.unionid = mefp.ghid AND ur.roleId = @roleId ) fglyname
FROM
lxy_mefp mefp
LEFT JOIN sys_union un ON mefp.ghid = un.id
LEFT JOIN lxy_bm bm ON bm.ghid = mefp.ghid
LEFT JOIN sys_user u ON u.id = bm.userid AND bm.bmzt IN (3,5)
LEFT JOIN lxy_hd hd ON mefp.hdid = hd.id
$condition
""").setParam("hdid", hdid).setParam("roleId", Roles.UNION_MANGER);
Cnd cnd = Cnd.NEW();
cnd.andEX("mefp.ghid", "=", unionId);
cnd.and(new Static("now()<hd.bmjzsj"));
cnd.and("mefp.number", ">", 0);
cnd.and("mefp.hdid", "=", hdid);
cnd.and(new Static("(select count(1) from lxy_bm lb where lb.hdid = '" + hdid + "' and lb.ghid = mefp.ghid AND lb.bmzt is NOT null) > 0 "));
if (isAudit == 2) {
cnd.and(new Static("(SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt = 3 )=0"));
} else if (isAudit == 3) {
cnd.and(new Static("(SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt = 3 )>0"));
}
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "SchoolUnionAdmin"})) {
cnd.and(new Static("mefp.ghid in " + vi.getMangeUnionStr()));
}
if (year != null) {
cnd.and("YEAR(hdkssj)", "=", year);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.desc("hdcjsj");
cnd.desc("username");
}
cnd.groupBy(" mefp.ghid ");
sql.setCondition(cnd);
return lxyHdService.listPage(pageNumber, pageSize, sql);
}
/**
* 查询通过审核及待校工会审核的人员
*
* @param ghId
* @param hdId
* @param pageNumber
* @param pageSize
* @return
*/
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.xghsh")
public Object findBm(String ghId, String hdId, Integer pageNumber, Integer pageSize) {
Sql sql = Sqls.create("""
SELECT
l.id,
hd.id hdid,
u.id uid,
u.loginname,
u.username,
u.sex,
bm.age,
bm.mobile,
bm.idcard,
bm.unitname,
bm.bmzt,
bm.zyhj,
bm.bz,
bm.ghid
FROM
lxy_bm bm
LEFT JOIN lxy_hd hd ON hd.id = bm.hdid
LEFT JOIN sys_user u ON u.id = bm.userid
LEFT JOIN sys_unit unit ON u.unitid = unit.id
LEFT JOIN Lxy_grxx l ON l.loginname = u.loginname
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("bm.bmzt", "NOT IN", List.of(2, 4, 6));
cnd.and("bm.hdid", "=", hdId);
cnd.and("bm.ghid", "=", ghId);
cnd.groupBy("u.loginname");
cnd.desc("bm.bmzt");
sql.setCondition(cnd);
Pagination pagination = lxyBmService.listPage(pageNumber, pageSize, sql);
return Result.success().addData(pagination);
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.xghsh")
public Object sh(String hdid, String ghid, Integer bmzt, String[] users) {
for (String user : users) {
lxyBmService.update(Chain.make("bmzt", bmzt), Cnd.where("ghid", "=", ghid).and("hdid", "=", hdid).and("userid", "=", user));
}
return null;
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.xghsh")
public Object grsh(String hdid, String ghid, Integer bmzt, String userid) {
lxyBmService.update(Chain.make("bmzt", bmzt), Cnd.where("ghid", "=", ghid).and("hdid", "=", hdid).and("userid", "=", userid));
return null;
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.xghsh")
public Object yjSh(NutMap[] maps) {
for (NutMap map : maps) {
lxyBmService.update(Chain.make("bmzt", 5), Cnd.where("ghid", "=", map.get("ghid")).and("hdid", "=", map.get("hdid")).and("bmzt", "=", 3));
}
return null;
}
@At
@ViReturn
@RequiresPermissions("zgfw.lxy.xghsh")
public Object doDelete(String id, String unionid, String userid, String hdid) {
Trans.exec(() -> {
lxyBmService.clear(Cnd.where("userid", "=", userid).and("hdid", "=", hdid).and("ghid", "=", unionid));
baseService.dao().delete(Lxy_grxx.class, id);
});
return null;
}
@At
@RequiresPermissions("zgfw.lxy.xghsh")
public void downLoadAll(@Param(value = "year", required = false) Integer year,
@Param(value = "hdid", required = false) String hdid,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "isAudit", required = false) Integer isAudit, HttpServletResponse response) throws IOException {
Sql sql = Sqls.create("""
SELECT
b.*,
u.username,
u.unionId,
u.unionname
FROM
lxy_bm b
LEFT JOIN `user` u ON b.userid = u.id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("hdid", "=", hdid);
cnd.andEX("year(bmsj)", "=", year);
cnd.andEX("u.unionId", "=", unionId);
if (isAudit != null) {
if (isAudit == 2) {
cnd.and("bmzt", ">", 3);
} else if (isAudit == 3) {
cnd.and("bmzt", "=", 3);
}
}
sql.setCondition(cnd);
List<NutMap> list = baseService.listMap(sql);
try {
response.reset();
response.setContentType("application/x-msdownload;charset=utf-8");
/**
* 创建临时文件夹
*/
String tmpPath = "tmp/" + R.UU32();
File tmpDir = new File(tmpPath + "/报名人员材料");
tmpDir.mkdirs();
Map<String, List<NutMap>> unionNameMap = list.stream()
.collect(Collectors.groupingBy(l -> l.getString("unionname")));
unionNameMap.forEach((k, v) -> {
File unionTmpDir = new File(tmpDir + "/" + k);
unionTmpDir.mkdirs();
List<NutMap> unionNameList = list.stream().filter(li -> li.getString("unionname").equals(k)).collect(Collectors.toList());
unionNameList.forEach(item -> {
File tDir = new File(unionTmpDir + "/" + item.getString("username"));
tDir.mkdirs();
if (StrUtil.isNotBlank(item.getString("files"))) {
List<Sys_file> fileList = Json.fromJsonAsList(Sys_file.class, item.getString("files"));
fileList.forEach(file -> {
try {
FileOutputStream outputStream = new FileOutputStream(tDir.getPath() + "/" + file.getFilename());
ftpService.download(file.getFilepath(), outputStream);
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
});
}
});
});
String aimsDir = "zipTmp/" + R.UU32();
String aimsName = "报名人员材料.zip";
String aimsPath = aimsDir + "/" + aimsName;
FileUtil.compressToZip(tmpDir.getPath(), aimsDir, aimsName);
response.setHeader("content-disposition", "attachment;filename="
+ URLEncoder.encode(aimsName, "UTF-8"));
File aimsFile = new File(aimsPath);
FileInputStream inputStream = new FileInputStream(aimsFile);
org.apache.commons.io.IOUtils.copy(inputStream, response.getOutputStream());
inputStream.close();
aimsFile.delete();
FileUtil.deleteDir(new File(tmpPath));
FileUtil.deleteDir(new File(aimsDir));
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,103 @@
package io.v.nutz.lxy.model;
import io.v.nutz.sys.models.Sys_file;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.util.List;
/**
* @Author: 1V
* @DateTime: 2020/8/27 9:11
* @Description: 疗休养报名
*/
@Data
@Table("Lxy_bm")
public class Lxy_bm {
@Column
@Name
@Comment("id")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("活动id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String hdid;
@Column
@Comment("用户id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userid;
@Column
@Comment("工号")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String loginname;
@Column
@Comment("工会id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String ghid;
@Column
@Comment("报名时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String bmsj;
@Column
@Comment("报名状态(1.待分工会审核 2.分工会审核不通过 3.待校工会审核 4 校工会审核不通过 5 报名成功 6 待填写个人资料)")
@ColDefine(type = ColType.INT)
private Integer bmzt;
@Column
@Comment("报名类型(1.分工会统一报名 2.个人报名)")
@ColDefine(type = ColType.INT)
private Integer bmlx;
@Column
@Comment("单位")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unitname;
@Column
@Comment("单位id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unitid;
@Column
@Comment("年龄")
@ColDefine(type = ColType.INT)
private String age;
@Column
@Comment("工会")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unionname;
@Column
@Comment("手机号")
@ColDefine(type = ColType.VARCHAR, width = 11)
private String mobile;
@Column
@Comment("身份证号码")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String idcard;
@Column
@Comment("主要获奖")
@ColDefine(type = ColType.VARCHAR, width = 1000)
private String zyhj;
@Column
@Comment("备注")
@ColDefine(type = ColType.VARCHAR, width = 1000)
private String bz;
@Column
@Comment("附件")
@ColDefine(type = ColType.MYSQL_JSON)
private List<Sys_file> files;
}
@@ -1,4 +1,4 @@
package io.v.nutz.zgfw.model.lxy; package io.v.nutz.lxy.model;
import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.wizzer.framework.base.model.BaseModel; import cn.wizzer.framework.base.model.BaseModel;
@@ -1,4 +1,4 @@
package io.v.nutz.zgfw.model.lxy; package io.v.nutz.lxy.model;
import lombok.Data; import lombok.Data;
import org.nutz.dao.entity.annotation.*; import org.nutz.dao.entity.annotation.*;
@@ -1,4 +1,4 @@
package io.v.nutz.zgfw.model.lxy; package io.v.nutz.lxy.model;
import org.nutz.dao.entity.annotation.*; import org.nutz.dao.entity.annotation.*;
@@ -1,7 +1,7 @@
package io.v.nutz.zgfw.service; package io.v.nutz.lxy.service;
import io.v.nutz.zgfw.model.lxy.Lxy_bm;
import cn.wizzer.framework.base.service.BaseService; import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.lxy.model.Lxy_bm;
public interface LxyBmService extends BaseService<Lxy_bm> { public interface LxyBmService extends BaseService<Lxy_bm> {
} }
@@ -1,8 +1,7 @@
package io.v.nutz.zgfw.service; package io.v.nutz.lxy.service;
import cn.wizzer.framework.base.service.BaseService; import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.zgfw.model.lxy.Lxy_grxx; import io.v.nutz.lxy.model.Lxy_grxx;
public interface LxyGrxxService extends BaseService<Lxy_grxx> { public interface LxyGrxxService extends BaseService<Lxy_grxx> {
} }
@@ -1,7 +1,7 @@
package io.v.nutz.zgfw.service; package io.v.nutz.lxy.service;
import cn.wizzer.framework.base.service.BaseService; import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.zgfw.model.lxy.Lxy_hd; import io.v.nutz.lxy.model.Lxy_hd;
public interface LxyHdService extends BaseService<Lxy_hd> { public interface LxyHdService extends BaseService<Lxy_hd> {
} }
@@ -1,7 +1,8 @@
package io.v.nutz.zgfw.service; package io.v.nutz.lxy.service;
import cn.wizzer.framework.base.service.BaseService; import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.zgfw.model.lxy.Lxy_mefp; import io.v.nutz.lxy.model.Lxy_mefp;
public interface LxyMefpService extends BaseService<Lxy_mefp> { public interface LxyMefpService extends BaseService<Lxy_mefp> {
} }
@@ -1,8 +1,8 @@
package io.v.nutz.zgfw.service.impl; package io.v.nutz.lxy.service.impl;
import cn.wizzer.framework.base.service.BaseServiceImpl; import cn.wizzer.framework.base.service.BaseServiceImpl;
import io.v.nutz.zgfw.model.lxy.Lxy_bm; import io.v.nutz.lxy.model.Lxy_bm;
import io.v.nutz.zgfw.service.LxyBmService; import io.v.nutz.lxy.service.LxyBmService;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
@@ -1,8 +1,8 @@
package io.v.nutz.zgfw.service.impl; package io.v.nutz.lxy.service.impl;
import cn.wizzer.framework.base.service.BaseServiceImpl; import cn.wizzer.framework.base.service.BaseServiceImpl;
import io.v.nutz.zgfw.model.lxy.Lxy_grxx; import io.v.nutz.lxy.model.Lxy_grxx;
import io.v.nutz.zgfw.service.LxyGrxxService; import io.v.nutz.lxy.service.LxyGrxxService;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
@@ -1,8 +1,8 @@
package io.v.nutz.zgfw.service.impl; package io.v.nutz.lxy.service.impl;
import cn.wizzer.framework.base.service.BaseServiceImpl; import cn.wizzer.framework.base.service.BaseServiceImpl;
import io.v.nutz.zgfw.model.lxy.Lxy_hd; import io.v.nutz.lxy.model.Lxy_hd;
import io.v.nutz.zgfw.service.LxyHdService; import io.v.nutz.lxy.service.LxyHdService;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
@@ -1,8 +1,8 @@
package io.v.nutz.zgfw.service.impl; package io.v.nutz.lxy.service.impl;
import cn.wizzer.framework.base.service.BaseServiceImpl; import cn.wizzer.framework.base.service.BaseServiceImpl;
import io.v.nutz.zgfw.model.lxy.Lxy_mefp; import io.v.nutz.lxy.model.Lxy_mefp;
import io.v.nutz.zgfw.service.LxyMefpService; import io.v.nutz.lxy.service.LxyMefpService;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
@@ -0,0 +1,94 @@
package io.v.nutz.meeting.controller.mobile;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.result.Result;
import io.v.nutz.meeting.service.MeetingAuditService;
import io.v.nutz.modules.models.Audit;
import io.v.nutz.modules.models.PageForm;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletRequest;
/**
* 会议手机端审核
*/
@IocBean
@Slf4j
@At("/mobile/meeting/audit")
public class MMeetingAuditController {
@Inject
private MeetingAuditService meetingAuditService;
@Inject
private Dao dao;
/**
* 跳转审核页面
*
* @param request
*/
@At("")
@Ok("beetl:/mobile/meeting/audit.html")
@RequiresAuthentication
public void index(HttpServletRequest request) {
}
@At("/pageData")
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object pageData(PageForm pageForm,
@Param(value = "typeId", required = false) String typeId,
@Param(value = "meetingTime", required = false) Integer meetingTime) {
return meetingAuditService.myMeetingPageData(pageForm.getPageNumber(), pageForm.getPageSize(), pageForm.getSearchKeyword(), typeId, meetingTime);
}
/**
* 查询会议提交了请假的人员
* 这里需要根据当前登录用户去过滤他能审核的 are you ok?
*/
@At("/getLeaveUser")
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object getLeaveUser(@Param(value = "meetingId", required = false) String meetingId,
@Param(value = "moduleName", required = false) String moduleName,
@Param(value = "auditType", required = false) String auditType) {
if (StringUtils.isBlank(meetingId)) {
log.error("getUserByLoginUser()参数为空");
return Result.error("参数为空");
}
return meetingAuditService.getLeaveUser(meetingId, moduleName, auditType);
}
/**
* 会议审核
*
* @param tpuIds 审核记录Ids
* @param audit 审核
* @param isPass 是否通过
* @return
*/
@At("/audit")
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object audit(@Param("tpuIds") String[] tpuIds, Audit audit,
@Param("isPass") boolean isPass) {
meetingAuditService.audit(tpuIds, audit, isPass);
return null;
}
}
@@ -0,0 +1,222 @@
package io.v.nutz.meeting.controller.mobile;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingTimePeriodUser;
import io.v.nutz.meeting.service.MeetingMineService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.mvc.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* 会议手机端签到
*/
@IocBean
@At("/mobile/meeting/mine")
public class MMeetingMineController {
@Inject
private MeetingMineService meetingMineService;
@Inject
private Dao dao;
/**
* 跳转签到页面
*
* @param request
*/
@At("/go_sign")
@RequiresAuthentication
@Ok("beetl:/mobile/meeting/sign_in.html")
public void goSign(HttpServletRequest request) {
}
@At("/myMeeting")
@RequiresAuthentication
@Ok("beetl:/mobile/meeting/myMeeting.html")
public void myMeeting(HttpServletRequest request) {
}
/**
* 我的会议
*
* @param pageForm 分页
* @param tabNameIndex tab页下标
* @return
*/
@At("/pageData")
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object pageData(PageForm pageForm,
@Param(value = "tabNameIndex", required = false) Integer tabNameIndex,
@Param(value = "typeId", required = false) String typeId,
@Param(value = "meetingTime", required = false) Integer meetingTime) {
Cnd cnd = Cnd.NEW();
if (StrUtil.isNotBlank(typeId)) {
cnd.andEX("info.typeId", "=", typeId);
}
if (meetingTime != null) {
if (meetingTime == 0) {
cnd.andEX("info.startTime", ">=", DateUtil.getDateTime());
} else {
cnd.andEX("info.startTime", "<", DateUtil.getDateTime());
}
}
switch (tabNameIndex) {
case 1 -> cnd.and("mu.isJoin", "is", null);
case 2 -> cnd.and("mu.isJoin", "=", 0);
default -> {
}
}
return meetingMineService.myMeetingPageData(pageForm, cnd);
}
/**
* 我的会议时间段信息
*
* @param meetingId
* @return
*/
@At("/findMyMeetPeriod")
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object findMyMeetPeriod(@Param("meetingId") String meetingId) {
if (StrUtil.isBlank(meetingId)) {
return Result.error("参数错误");
}
return meetingMineService.findMyMeetPeriod(meetingId);
}
/**
* 请假
*
* @return
*/
@At("/askForLeave")
@POST
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object askForLeave(@Param("data") String meetingTimePeriodUsers) {
//先清空,因为可能会涉及到修改
/*org.nutz.dao.Chain clearChain = Chain.make("isJoin", null);
clearChain.add("stateCode", null);
clearChain.add("leaveReason", "");
clearChain.add("auditIdList", null);
Cnd clearCnd = Cnd.where("meetingId", "=", meetingId)
.and("userId", "=", ShiroUtil.getPrincipalProperty("id"));
dao.update(MeetingTimePeriodUser.class, clearChain, clearCnd);*/
List<MeetingTimePeriodUser> meetingTimePeriod = Json.fromJsonAsList(MeetingTimePeriodUser.class, meetingTimePeriodUsers);
if (Lang.isEmpty(meetingTimePeriod)) {
return null;
}
meetingMineService.askForLeave(meetingTimePeriod);
return null;
}
/**
* 确认参加会议
*
* @return
*/
@At("/confirmMeeting")
@POST
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object confirmMeeting(@Param("tpuIds") List<String> tpuIds) {
meetingMineService.confirmMeeting(tpuIds);
return null;
}
/**
* @param meetingId 会议id
* @param mtpId 时间段id
* @return
*/
@At("/getMeetingInfo")
@GET
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object getMeetingInfo(@Param("meetingId") String meetingId, @Param("mtpId") String mtpId) {
MeetingInfo meetingInfo = dao.fetch(MeetingInfo.class, meetingId);
dao.fetchLinks(meetingInfo, "meetingTimePeriods", Cnd.NEW().asc("startTime"));
Cnd cnd = Cnd.NEW();
cnd.and("meetingTimePeriodId", "=", mtpId);
cnd.and("userId", "=", ShiroUtil.getPrincipalProperty("id"));
MeetingTimePeriodUser mtPu = dao.fetch(MeetingTimePeriodUser.class, cnd);
if (Lang.isEmpty(meetingInfo)) {
return Result.error("参数错误");
}
if (Lang.isEmpty(mtPu)) {
return Result.error("你不是当前会议人员");
}
return Map.of("meetingInfo", meetingInfo, "signInfo", mtPu);
}
/**
* 签到
*
* @return
*/
@At("/signIn")
@POST
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object signIn(@Param("mtpId") String mtpId) {
if (StrUtil.isBlank(mtpId)) {
return Result.error("参数错误");
}
Cnd cnd = Cnd.NEW();
cnd.and("meetingTimePeriodId", "=", mtpId);
cnd.and("userId", "=", ShiroUtil.getPrincipalProperty("id"));
MeetingTimePeriodUser mtpu = dao.fetch(MeetingTimePeriodUser.class, cnd);
if (Lang.isEmpty(mtpu)) {
return Result.error("参数错误");
}
if (Lang.isNotEmpty(mtpu.getIsJoin()) && !mtpu.getIsJoin()) {
return Result.error("您已请假,不能签到喔");
}
if (Lang.isNotEmpty(mtpu.getIsSignIn()) && mtpu.getIsSignIn()) {
return Result.error("您已签到,不要重复签到喔");
}
meetingMineService.signIn(mtpu);
return Result.success().addMsg("签到成功");
}
@At
@POST
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object cancelLeave(String id) {
dao.update(MeetingTimePeriodUser.class, Chain.make("isJoin", null).add("leaveReason", null).add("stateCode", null)
, Cnd.where("id", "=", id));
return null;
}
}
@@ -0,0 +1,158 @@
package io.v.nutz.meeting.controller.pc;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingUser;
import io.v.nutz.meeting.service.MeetingManageService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.msgNotify.models.MsgNotify;
import io.v.nutz.msgNotify.service.MsgNotifyService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@IocBean
@At("/platform/meeting/manage")
public class MeetingManageController {
@Inject
private Dao dao;
@Inject
private MeetingManageService meetingManageService;
@Inject
private MsgNotifyService msgNotifyService;
@At("/createMeeting")
@Ok("beetl:/platform/meeting/manage/add.html")
@RequiresPermissions("meeting.manage.add")
public void createMeeting(HttpServletRequest request) {
}
@At("")
@Ok("beetl:/platform/meeting/index.html")
@RequiresPermissions("meeting.manage.search")
public void index(HttpServletRequest request) {
}
@At("/pageData")
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.manage.search")
public Object pageData(PageForm pageForm,
@Param(value = "year", required = false) Integer year,
@Param(value = "typeId", required = false) String typeId) {
Cnd cnd = Cnd.NEW();
cnd.andEX("YEAR(info.startTime)", "=", year);
cnd.andEX("info.typeId", "=", typeId);
return meetingManageService.pageData(pageForm, cnd);
}
/**
* 添加会议
*
* @param meetingInfo 会议信息
* @return
*/
@At("/doAdd")
@POST
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.manage.add")
public Object doAdd(@Param("meetingInfo") MeetingInfo meetingInfo,
@Param("msgNotify") MsgNotify msgNotify, String[] users) {
NutMap nutMap = msgNotifyService.addMsgNotify(msgNotify, users);
meetingInfo.setNotifyId(nutMap.getString("id"));
List<String> userIdList = nutMap.getList("userIdList", String.class);
List<MeetingUser> meetingUserList = new ArrayList<>();
for (String id : userIdList) {
MeetingUser meetingUser = new MeetingUser();
meetingUser.setUserId(id);
meetingUserList.add(meetingUser);
}
meetingInfo.setMeetingUserList(meetingUserList);
meetingManageService.doAdd(meetingInfo);
return null;
}
/**
* 编辑会议
*
* @param meetingInfo 会议信息
* @return
*/
@At("/doEdit")
@POST
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.manage.add")
public Object doEdit(@Param("meetingInfo") MeetingInfo meetingInfo,
@Param("msgNotify") MsgNotify msgNotify, String[] users) {
NutMap msgMap = msgNotifyService.editMsgNotify(msgNotify, users);
List<String> userIdList = msgMap.getList("userIdList", String.class);
// Cnd muCnd = Cnd.where("meetingId", "=", meetingInfo.getId());
// List<MeetingUser> muList = dao.query(MeetingUser.class, muCnd);
//
// List<MeetingUser> meetingUserList = new ArrayList<>();
// for (String userId : userIdList) {
// MeetingUser insertMu = new MeetingUser();
// Optional<MeetingUser> optionalMeetingUser = muList.stream().filter(v -> v.getUserId().equals(userId)).findFirst();
// MeetingUser mu = optionalMeetingUser.orElse(null);
// if (Lang.isNotEmpty(mu)) {
// insertMu.setId(mu.getId());
// }
// insertMu.setMeetingId(meetingInfo.getId());
// insertMu.setUserId(userId);
// meetingUserList.add(insertMu);
// }
// meetingInfo.setMeetingUserList(meetingUserList);
meetingManageService.doEdit(meetingInfo, userIdList);
return null;
}
@At
@Ok("json:full")
@ViReturn
@RequiresPermissions(value = {"meeting.manage.search", "meeting.manage.add"}, logical = Logical.OR)
public Object findOne(String id) {
return dao.fetchLinks(dao.fetch(MeetingInfo.class, id), "^meetingTimePeriods$", Cnd.NEW().asc("startTime"));
}
/**
* 删除会议
*
* @param id
* @return
*/
@At
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.manage.search")
public Object doDelete(String id) {
meetingManageService.doDelete(id);
return null;
}
}
@@ -0,0 +1,133 @@
package io.v.nutz.meeting.controller.pc;
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 io.v.nutz.annontation.ViReturn;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingTimePeriod;
import io.v.nutz.meeting.service.MeetingOnlineService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.util.ViTool;
import io.v.nutz.web.commons.base.Globals;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@IocBean
@At("/platform/meeting/online")
public class MeetingOnlineController {
@Inject
private Dao dao;
@Inject
private MeetingOnlineService meetingOnlineService;
@At("")
@Ok("beetl:/platform/meeting/online.html")
@RequiresPermissions("meeting.online")
public void index(HttpServletRequest request) {
}
/**
* 分页查询
*
* @param pageForm
* @param year
* @param typeId
* @return
*/
@At("/pageData")
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.online")
public Object pageData(PageForm pageForm,
@Param(value = "year", required = false) Integer year,
@Param(value = "typeId", required = false) String typeId) {
Cnd cnd = Cnd.NEW();
cnd.andEX("YEAR(info.startTime)", "=", year);
cnd.andEX("info.typeId", "=", typeId);
return meetingOnlineService.pageData(pageForm, cnd);
}
/**
* 导出签字表
*
* @param timePeriodId
* @param response
*/
@At("/exportSignature/?")
@Ok("void")
@ViReturn
@RequiresAuthentication
public void exportSignature(@Param(value = "timePeriodId", required = false) String timePeriodId, HttpServletResponse response) {
MeetingTimePeriod timePeriod = dao.fetch(MeetingTimePeriod.class, timePeriodId);
MeetingInfo meetingInfo = dao.fetch(MeetingInfo.class, timePeriod.getMeetingId());
String fileName = meetingInfo.getMeetingName() + "(" + timePeriod.getTimePeriodName() + ")签字表";
List<ExcelExportEntity> entityArrayList = new ArrayList<>();
entityArrayList.add(new ExcelExportEntity("姓名", "username", 20));
entityArrayList.add(new ExcelExportEntity("工号", "loginname", 20));
entityArrayList.add(new ExcelExportEntity("单位", "unitname", 20));
entityArrayList.add(new ExcelExportEntity("分工会", "unionname", 20));
entityArrayList.add(new ExcelExportEntity("角色", "roleName", 20));
entityArrayList.add(new ExcelExportEntity("签字", "", 20));
try {
ViTool.excelResponse(response, fileName + ".xlsx");
ExportParams exportParams = new ExportParams();
exportParams.setTitle(timePeriod.getTimePeriodName() + "签字表");
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityArrayList, meetingOnlineService.exportSignature(timePeriodId));
workbook.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
@At("/generateQrCodeUrl")
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object generateQrCodeUrl(@Param(value = "tpId", required = false) String tpId,
@Param(value = "meetingId", required = false) String meetingId,
HttpServletRequest request) {
StringBuffer redirect = new StringBuffer();
redirect.append(Globals.AppDomain);
redirect.append("/mobile/meeting/mine/go_sign?");
redirect.append("mtpId=").append(tpId);
redirect.append("&");
redirect.append("meetingId=").append(meetingId);
return redirect.toString();
}
@At("/getRealTimeData/?")
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.online")
public Object getRealTimeData(String timePeriodId) {
List<NutMap> signInUser = meetingOnlineService.getSignInUser(timePeriodId);
List<Map<String, Object>> countData = meetingOnlineService.getRealTimeData(timePeriodId);
return Map.of("countData", countData, "userData", signInUser);
}
}
@@ -0,0 +1,148 @@
package io.v.nutz.meeting.controller.pc;
import cn.wizzer.framework.base.Result;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.meeting.models.MeetingType;
import io.v.nutz.meeting.service.MeetingCommonService;
import io.v.nutz.meeting.service.MeetingTypeService;
import io.v.nutz.modules.models.AuditState;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@IocBean
@At("/platform/meeting/basic/type")
public class MeetingTypeController {
@Inject
private Dao dao;
@Inject
private MeetingTypeService meetingTypeService;
@Inject
private MeetingCommonService meetingCommonService;
@At("")
@Ok("beetl:/platform/meeting/basic/type.html")
@RequiresPermissions("meeting.basic.type")
public void index(HttpServletRequest request) {
}
@At("/findAll")
@Ok("json:full")
@ViReturn
@RequiresAuthentication
public Object findAll() {
List<MeetingType> meetingTypeList = dao.query(MeetingType.class, Cnd.NEW().asc("sortNum"));
dao.fetchLinks(meetingTypeList, "^auditStateList$");
for (MeetingType meetingType : meetingTypeList) {
meetingType.setAuditStateList(dao.query(AuditState.class, Cnd.where("meetingTypeId", "=", meetingType.getId()).and("module", "=", meetingType.getModuleName())));
List<AuditState> auditStateList = meetingType.getAuditStateList();
dao.fetchLinks(auditStateList, "^auditStateUserList$");
}
return meetingTypeList;
}
@At("/doHandle")
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.basic.type")
public Object doHandle(@Param("data") String data) {
MeetingType meetingType = Json.fromJson(MeetingType.class, data);
if (null == meetingType.getId()) {
int typeCount = dao.count(MeetingType.class, Cnd.where("moduleName", "=", meetingType.getModuleName()));
int count = dao.count(AuditState.class, Cnd.where("module", "=", meetingType.getModuleName()));
if (typeCount > 0 || count > 0) {
return Result.error("模块名称已存在,换一个试试");
}
meetingTypeService.add(meetingType);
} else {
meetingTypeService.edit(meetingType);
}
return null;
}
@At("/delete/?")
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.basic.type")
public Object delete(Integer id) {
MeetingType meetingType = dao.fetch(MeetingType.class, id);
dao.clear(AuditState.class, Cnd.where("module", "=", meetingType.getModuleName()));
dao.clear(MeetingType.class, Cnd.where("id", "=", id));
return null;
}
@At("/findUserList")
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.basic.type")
public Object findUserList(@Param("keyWords") String[] keyWords) {
Sql sql = Sqls.create("""
SELECT
id,
username,
loginname,
mobile,
sex,
unitname,
unionname,
unionid,
unitid
FROM
`user`
$condition
""");
Cnd cnd = Cnd.NEW();
SqlExpressionGroup seg = new SqlExpressionGroup();
for (String keyWord : keyWords) {
seg.andLike("loginname", keyWord);
seg.orLike("username", keyWord);
}
cnd.and(seg);
sql.setCondition(cnd);
return Daos.query(dao, sql.toString(), Sqls.callback.maps());
}
@At
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.basic.type")
public Object findMaxStateId() {
return meetingTypeService.findMaxStateId();
}
@At
@Ok("json:full")
@ViReturn
@RequiresPermissions("meeting.basic.type")
public Object checkStateId(@Param("stateId") Integer stateId, @Param("stateIndex") Integer stateIndex) {
if (stateId == null) {
return Result.error("参数错误");
}
int count = dao.count(AuditState.class, Cnd.where("stateId", "=", stateId));
if (count == 0) {
return Result.success().addData(stateId);
} else {
return Result.success(meetingTypeService.findMaxStateId() + 10 * stateIndex);
}
}
}
@@ -0,0 +1,126 @@
package io.v.nutz.meeting.controller.pc.statistics;
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.afterturn.easypoi.excel.export.ExcelExportService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingType;
import io.v.nutz.meeting.service.MeetingBasicStatisticsService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.util.ViTool;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
@IocBean
@Ok("json:full")
@At("/meeting/statistics/basic")
public class MeetingBasicStatisticsController {
@Inject
private MeetingBasicStatisticsService meetingBasicStatisticsService;
@Inject
private Dao dao;
@At("")
@Ok("beetl:/platform/meeting/statistics/basic.html")
@RequiresPermissions("meeting.statistics.basic")
public void index(HttpServletRequest request) {
}
/**
* 根据会议id查询会议时间段及对应人数
*
* @param pageForm
* @return
*/
@At
@ViReturn
@RequiresPermissions("meeting.statistics.basic")
public Object pageData(PageForm pageForm,
@Param(value = "meetingId", required = false) String meetingId,
@Param(value = "meetingTime", required = false) String[] meetingTime,
@Param(value = "typeId", required = false) String typeId) {
return meetingBasicStatisticsService.pageData(pageForm, meetingId, meetingTime, typeId);
}
@At
@ViReturn
@RequiresPermissions("meeting.statistics.basic")
public Object getMeetingList(String[] meetingTime) {
return meetingBasicStatisticsService.getMeetingList(meetingTime);
}
@At
@ViReturn
@RequiresPermissions("meeting.statistics.basic")
public Object getUserData(PageForm pageForm,
@Param(value = "id", required = false) String id,
@Param(value = "meetingId", required = false) String meetingId,
@Param(value = "type", required = false) String type,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "unionId", required = false) String unionId) {
return meetingBasicStatisticsService.getUserData(pageForm, id, meetingId, type, unitId, unionId);
}
@At
@Ok("void")
@RequiresAuthentication
public void exportUser(@Param(value = "id", required = false) String id,
@Param(value = "meetingId", required = false) String meetingId,
HttpServletResponse response) {
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("姓名", "userName", 20));
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
entityList.add(new ExcelExportEntity("单位", "unitName", 30));
entityList.add(new ExcelExportEntity("分工会", "unionName", 35));
Workbook workbook = new XSSFWorkbook();
MeetingInfo meetingInfo = dao.fetch(MeetingInfo.class, meetingId);
MeetingType meetingType = dao.fetch(MeetingType.class, meetingInfo.getTypeId());
String[] arr = null;
if(List.of("teacherMeeting","gdh").contains(meetingType.getModuleName())) {
arr = new String[]{"应到人数", "实到人数", "正式代表", "列席代表", "请假人数", "未到人数"};
} else {
arr = new String[]{"应到人数", "实到人数", "请假人数", "未到人数"};
}
for (String a : arr) {
List<NutMap> userData = meetingBasicStatisticsService.getUserData(id, meetingId, a);
ExcelExportService service = new ExcelExportService();
ExportParams exportParams = new ExportParams();
exportParams.setTitle(a);
exportParams.setSheetName(a);
exportParams.setType(ExcelType.XSSF);
service.createSheetForMap(workbook, exportParams, entityList, userData);
}
try {
ViTool.excelResponse(response, "人员列表.xlsx");
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,28 @@
package io.v.nutz.meeting.models;
import io.v.nutz.annontation.SelectEnum;
@SelectEnum
public enum CustomAuditTypeEnum {
CLUB("CLUB", "审核本协会"),
DW("DW", "审核本单位"),
FGH("FGH", "审核本分工会"),
TZ("TZ", "审核本代表团");
public String value;
public String desc;
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
private CustomAuditTypeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
}
@@ -0,0 +1,83 @@
package io.v.nutz.meeting.models;
import io.v.nutz.annontation.SelectEnum;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.models.Sys_club_user;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.models.Sys_user_role;
import io.v.nutz.util.ShiroUtil;
import io.v.nutz.util.ViResource;
import lombok.Getter;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.lang.Lang;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author JyuHsin
* @Date 2023/3/30
* @Description
*/
@Getter
@SelectEnum
public enum CustomAuditTypeHandle {
DW(CustomAuditTypeEnum.DW.getValue()) {
@Override
public SqlExpressionGroup next(SqlExpressionGroup sqlExpressionGroup) {
Sys_user user = dao.fetch(Sys_user.class, Cnd.where("id", "=", ShiroUtil.getPrincipalProperty("id")));
sqlExpressionGroup.or("u.unitid", "in", user.getUnitid());
return sqlExpressionGroup;
}
},
FGH(CustomAuditTypeEnum.FGH.getValue()) {
@Override
public SqlExpressionGroup next(SqlExpressionGroup sqlExpressionGroup) {
//查询当前登录用户管理的工会
List<Sys_user_role> userRoles = dao.query(Sys_user_role.class, Cnd.where("userid", "=", ShiroUtil.getPrincipalProperty("id"))
.and("roleid", "in", Lang.array(Roles.UNION_MANGER)));
List<String> unionIds = userRoles.stream().map(Sys_user_role::getUnionid).collect(Collectors.toList());
sqlExpressionGroup.or("u.unionid", "in", unionIds);
return sqlExpressionGroup;
}
},
CLUB(CustomAuditTypeEnum.CLUB.getValue()) {
@Override
public SqlExpressionGroup next(SqlExpressionGroup sqlExpressionGroup) {
//查询当前登录用户管理的协会
List<Sys_user_role> userRoles = dao.query(Sys_user_role.class, Cnd.where("userid", "=", ShiroUtil.getPrincipalProperty("id"))
.and("roleid", "in", Lang.array(Roles.CLUB_FZR)));
List<String> clubIds = userRoles.stream().map(Sys_user_role::getStid).collect(Collectors.toList());
List<Sys_club_user> clubUsers = dao.query(Sys_club_user.class, Cnd.where("stid", "in", clubIds));
if (Lang.isNotEmpty(clubUsers)) {
sqlExpressionGroup.or("u.id", "in", clubUsers.stream().map(v -> v.getUserid()).collect(Collectors.toList()));
}
return sqlExpressionGroup;
}
},
TZ(CustomAuditTypeEnum.TZ.getValue()) {
@Override
public SqlExpressionGroup next(SqlExpressionGroup sqlExpressionGroup) {
String dbtId = vi.getLastDelegationId((String) ShiroUtil.getPrincipalProperty("id"));
sqlExpressionGroup.or("u.id", "in", Sqls.createf("select DISTINCT dbid from jdh_db where dbtid = '%s'", dbtId));
return sqlExpressionGroup;
}
};
private final String name;
public Dao dao = ViResource.ioc.getByType(Dao.class);
public Vi vi = ViResource.ioc.getByType(Vi.class);
CustomAuditTypeHandle(String name) {
this.name = name;
}
public abstract SqlExpressionGroup next(SqlExpressionGroup sqlExpressionGroup);
}
@@ -0,0 +1,90 @@
package io.v.nutz.meeting.models;
import lombok.Data;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.util.Date;
import java.util.List;
@Table
@Data
@Accessors(chain = true)
public class MeetingInfo {
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true)
private String id;
@Column
@Comment("名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String meetingName;
@Column
@Comment("地点")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String location;
@Column
@Comment("会议类型")
@ColDefine(type = ColType.INT)
private Integer typeId;
@Column
@Comment("开始时间")
@ColDefine(type = ColType.DATETIME)
private Date startTime;
@Column
@Comment("结束时间")
@ColDefine(type = ColType.DATETIME)
private Date endTime;
@Column
@Comment("是否可以请假")
@ColDefine(type = ColType.BOOLEAN)
private Boolean isCanLeave;
@Column
@Comment("是否多次签到")
@ColDefine(type = ColType.BOOLEAN)
private Boolean manySign;
@Column
@Comment("请假截至时间")
@ColDefine(type = ColType.DATETIME)
private Date leaveDeadline;
@Column
@Comment("会议描述")
@ColDefine(type = ColType.VARCHAR, width = 2000)
private String meetingDescription;
@Column
@Comment("关联会议id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String notifyId;
/**
* 会议时间段
*/
@Many(field = "meetingId")
private List<MeetingTimePeriod> meetingTimePeriods;
/**
* 会议参加人员
*/
@Many(field = "meetingId")
private List<MeetingUser> meetingUserList;
/**
* 消息对象
*/
// @One(field = "")
// private MsgNotify msgNotify;
}
@@ -0,0 +1,48 @@
package io.v.nutz.meeting.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.util.Date;
import java.util.List;
/**
* 会议时间段
*/
@Table
@Data
@TableIndexes({
@Index(name = "INDEX_MEETINGTIMEPERIOD_MEETING_ID", fields = {"meetingId"}, unique = false),})
public class MeetingTimePeriod {
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true)
private String id;
@Column
@Comment("会议id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String meetingId;
@Column
@Comment("时间段会议名称")
@ColDefine(type = ColType.VARCHAR, width = 20)
private String timePeriodName;
@Column
@Comment("开始时间")
@ColDefine(type = ColType.DATETIME)
private Date startTime;
@Column
@Comment("结束时间")
@ColDefine(type = ColType.DATETIME)
private Date endTime;
@Many(field = "meetingTimePeriodId")
private List<MeetingTimePeriodUser> meetingTimePeriodUserList;
}
@@ -0,0 +1,83 @@
package io.v.nutz.meeting.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import org.nutz.lang.util.NutMap;
import java.util.Date;
import java.util.List;
@Table
@Data
@TableIndexes({
@Index(name = "INDEX_MEETINGTIMEPERIODUSER_MEETING_TIME_PERIOD_ID", fields = {"meetingTimePeriodId"}, unique = false),
@Index(name = "INDEX_MEETINGTIMEPERIODUSER_MEETING_ID", fields = {"meetingId"}, unique = false)})
public class MeetingTimePeriodUser {
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true)
private String id;
@Column
@Comment("会议id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String meetingId;
@Column
@Comment("会议时间段id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String meetingTimePeriodId;
@Column
@ColDefine(type = ColType.VARCHAR, width = 32)
@Comment("用户id")
private String userId;
@Column
@ColDefine(type = ColType.BOOLEAN)
@Comment("是否参加")
private Boolean isJoin;
@Column
@ColDefine(type = ColType.VARCHAR, width = 100)
@Comment("请假理由")
private String leaveReason;
@Column
@Comment("用户请假开始时间")
@ColDefine(type = ColType.DATETIME)
private Date userLeaveStartTime;
@Column
@Comment("用户请假结束时间")
@ColDefine(type = ColType.DATETIME)
private Date userLeaveEndTime;
@Column
@ColDefine(type = ColType.INT)
@Comment("请假当前状态")
private Integer stateCode;
@Column
@ColDefine(type = ColType.BOOLEAN)
@Comment("是否签到")
private Boolean isSignIn;
@Column
@ColDefine(type = ColType.DATETIME)
@Comment("签到时间")
private Date signInDateTime;
/**
* 审核记录
*/
@Column
@ColDefine(type = ColType.MYSQL_JSON)
@Comment("审核记录ID")
private List<NutMap> auditIdList;
}
@@ -0,0 +1,38 @@
package io.v.nutz.meeting.models;
import io.v.nutz.modules.models.AuditState;
import lombok.Data;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import java.util.List;
@Table
@Data
@Accessors(chain = true)
public class MeetingType {
@Id
@Comment("ID")
@ColDefine(type = ColType.INT)
private Integer id;
@Column
@Comment("名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String meetingTypeName;
@Column
@Comment("模块名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String moduleName;
@Column
@Comment("排序")
@ColDefine(type = ColType.INT)
private int sortNum;
@Many(field = "meetingTypeId")
private List<AuditState> auditStateList;
}
@@ -0,0 +1,78 @@
package io.v.nutz.meeting.models;
import lombok.Data;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import org.nutz.lang.util.NutMap;
import java.util.Date;
import java.util.List;
/**
* 参会人员表
*/
@Table
@Data
@Accessors(chain = true)
public class MeetingUser {
@Name
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true)
private String id;
@Column
@ColDefine(type = ColType.VARCHAR, width = 32)
@Comment("会议ID")
private String meetingId;
@Column
@ColDefine(type = ColType.VARCHAR, width = 32)
@Comment("用户id")
private String userId;
@Column
@ColDefine(type = ColType.BOOLEAN)
@Comment("是否参加")
private Boolean isJoin;
@Column
@ColDefine(type = ColType.VARCHAR, width = 100)
@Comment("请假理由")
private String leaveReason;
@Column
@Comment("用户请假开始时间")
@ColDefine(type = ColType.DATETIME)
private Date userLeaveStartTime;
@Column
@Comment("用户请假结束时间")
@ColDefine(type = ColType.DATETIME)
private Date userLeaveEndTime;
@Column
@ColDefine(type = ColType.INT)
@Comment("请假当前状态")
private Integer stateCode;
@Column
@ColDefine(type = ColType.BOOLEAN)
@Comment("是否签到")
private Boolean isSignIn;
@Column
@ColDefine(type = ColType.DATETIME)
@Comment("签到时间")
private Date signInDateTime;
/**
* 审核记录
*/
@Column
@ColDefine(type = ColType.MYSQL_JSON)
@Comment("审核记录ID")
private List<NutMap> auditIdList;
}
@@ -0,0 +1,40 @@
package io.v.nutz.meeting.service;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.modules.models.Audit;
import io.v.nutz.service.ViService;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* 会议审核接口
*/
public interface MeetingAuditService extends ViService {
/**
* 会议审核分页数据
*
* @param pageNumber
* @param pageSize
* @return
*/
Pagination myMeetingPageData(int pageNumber, int pageSize, String keySearchWord, String typeId, Integer meetingTime);
/**
* 查询会议提交了请假的人员
*
* @param meetingId 会议id
*/
List<NutMap> getLeaveUser(String meetingId, String moduleName, String auditType);
/**
* 会议审核
*
* @param tpuIds 记录id
* @param audit 审核对象
* @param isPass isPass
*/
void audit(String[] tpuIds, Audit audit, boolean isPass);
}
@@ -0,0 +1,29 @@
package io.v.nutz.meeting.service;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.modules.models.PageForm;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* 会议基本统计service
*/
public interface MeetingBasicStatisticsService {
Pagination pageData(PageForm pageForm, String meetingId, String[] meetingTime, String typeId);
/**
* 根据时间段查询会议列表
*
* @param meetingTime
* @return
*/
Object getMeetingList(String[] meetingTime);
Object getUserData(PageForm pageForm, String id, String meetingId, String type, String unitId, String unionId);
List<NutMap> getUserData(String id, String meetingId, String type);
}
@@ -0,0 +1,66 @@
package io.v.nutz.meeting.service;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* 会议通用方法
*/
@IocBean
public interface MeetingCommonService {
/**
* 根据typeId查询所属模块名称
*
* @param typeId
* @return
*/
String findModuleNameByTypeId(Integer typeId);
/**
* 根据MeetId查询所属模块名称
*
* @param meetingId
* @return
*/
String findModuleNameByMeetingId(String meetingId);
/**
* 根据模块名称查找对应stateCode 最开始的那个
*
* @param moduleName
* @return
*/
Integer findStartStateCodeByModuleName(String moduleName);
Integer findAfterStateCode(Integer stateCode, boolean isPass);
Integer findAfterStateCodeByModuleName(Integer stateCode, String moduleName);
/**
* 根据会议id查询请假成功的code
*
* @param meetingId
* @return
*/
Integer findSuccessStateCode(String meetingId);
/**
* 获取当前用户关联哪些会议
*
* @return
*/
Object find();
/**
* 查询当前登录用户能审核的状态Id
*
* @return
*/
List<Integer> findStateIdForMeCanAudit();
List<NutMap> getNextAuditUser(Integer stateCode, String moduleName);
}
@@ -0,0 +1,52 @@
package io.v.nutz.meeting.service;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import org.nutz.dao.Cnd;
import java.util.List;
/**
* 会议管理service
*/
public interface MeetingManageService extends ViService<MeetingInfo> {
/**
* 模块名字
*/
String MODULE_NAME = "";
/**
* 分页数据
*
* @param pageForm
* @param cnd
* @return
*/
Pagination pageData(PageForm pageForm, Cnd cnd);
/**
* 添加会议及审核流程
*
* @param meetingInfo 会议信息
*/
void doAdd(MeetingInfo meetingInfo);
/**
* 编辑会议及审核流程
*
* @param meetingInfo 会议信息
*/
void doEdit(MeetingInfo meetingInfo, List<String> userIds);
/**
* 删除会议
*
* @param id 会议id
*/
void doDelete(String id);
}
@@ -0,0 +1,56 @@
package io.v.nutz.meeting.service;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.meeting.models.MeetingTimePeriodUser;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import org.nutz.dao.Cnd;
import java.util.List;
/**
* 会议通用service
*/
public interface MeetingMineService extends ViService {
/**
* 我的会议分页数据
*
* @param pageForm
* @param cnd
* @return
*/
Pagination myMeetingPageData(PageForm pageForm, Cnd cnd);
/**
* 查询我的会议时间段
*
* @return
*/
List<Object> findMyMeetPeriod(String meetingId);
/**
* 请假
*
* @param meetingId 会议id
* @param tpuIds tpuId 不解释
* @param leaveReason 请假理由
*/
void askForLeave(List<MeetingTimePeriodUser> meetingTimePeriodUsers);
/**
* 参加会议确认
*
* @param tpuIds
*/
void confirmMeeting(List<String> tpuIds);
/**
* 签到
*
* @param timePeriodUser
*/
void signIn(MeetingTimePeriodUser timePeriodUser);
}
@@ -0,0 +1,46 @@
package io.v.nutz.meeting.service;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import org.nutz.dao.Cnd;
import org.nutz.lang.util.NutMap;
import java.util.List;
import java.util.Map;
public interface MeetingOnlineService extends ViService {
/**
* 分页查询
*
* @param pageForm
* @param cnd
* @return
*/
Pagination pageData(PageForm pageForm, Cnd cnd);
/**
* 导出签字表
*
* @param timePeriodId 时间段id
* @return
*/
List<NutMap> exportSignature(String timePeriodId);
/**
* 在线数据
*
* @param timePeriodId
* @return
*/
List<Map<String, Object>> getRealTimeData(String timePeriodId);
/**
* 获取签到人员
*
* @param timePeriodId
* @return
*/
List<NutMap> getSignInUser(String timePeriodId);
}
@@ -0,0 +1,24 @@
package io.v.nutz.meeting.service;
import io.v.nutz.meeting.models.MeetingType;
import io.v.nutz.service.ViService;
/**
* 会议类型 流程 service
*/
public interface MeetingTypeService extends ViService<MeetingType> {
/**
* 找出最大的那行stateId
*
* @return
*/
int findMaxStateId();
void add(MeetingType meetingType);
void edit(MeetingType meetingType);
void delete(MeetingType meetingTyp);
}
@@ -0,0 +1,238 @@
package io.v.nutz.meeting.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.constant.AuditTypeEnum;
import io.v.nutz.lang.Enum;
import io.v.nutz.meeting.models.CustomAuditTypeHandle;
import io.v.nutz.meeting.models.MeetingTimePeriodUser;
import io.v.nutz.meeting.service.MeetingAuditService;
import io.v.nutz.meeting.service.MeetingCommonService;
import io.v.nutz.modules.models.Audit;
import io.v.nutz.modules.models.AuditState;
import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.commons.lang3.StringUtils;
import org.nutz.aop.interceptor.ioc.TransAop;
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.SqlExpressionGroup;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@IocBean(args = {"refer:dao"})
public class MeetingAuditServiceImpl extends ViServiceImpl implements MeetingAuditService {
@Inject
private MeetingCommonService meetingCommonService;
@Inject
private Vi vi;
public MeetingAuditServiceImpl(Dao dao) {
super(dao);
}
@Override
public Pagination myMeetingPageData(int pageNumber, int pageSize, String keySearchWord, String typeId, Integer meetingTime) {
Sql sql = Sqls.create("""
SELECT
info.*,
type.meetingTypeName,
type.moduleName,
(select count(*) from meeting_time_period_user where meetingId=info.id and JSON_CONTAINS(auditIdList, JSON_OBJECT('auditUser', @userid))) as audit
FROM
meeting_info info
LEFT JOIN meeting_type type ON type.id = info.typeId
LEFT JOIN audit_state state ON state.module = type.moduleName
$condition
""").setParam("userid", ShiroUtil.getPrincipalProperty("id"));
Cnd cnd = Cnd.NEW();
cnd.andEX("info.isCanLeave", "=", 1);
List<Integer> stateIdForMeCanAudit = meetingCommonService.findStateIdForMeCanAudit();
cnd.and("state.stateId", "in", stateIdForMeCanAudit);
if (StringUtils.isNotBlank(keySearchWord)) {
SqlExpressionGroup seg = new SqlExpressionGroup();
seg.orLike("mi.meetingName", keySearchWord);
seg.orLike("mi.location", keySearchWord);
cnd.and(seg);
}
if (StrUtil.isNotBlank(typeId)) {
cnd.andEX("info.typeId", "=", typeId);
}
if (meetingTime != null) {
if (meetingTime == 0) {
cnd.andEX("info.startTime", ">=", DateUtil.getDateTime());
} else {
cnd.andEX("info.startTime", "<", DateUtil.getDateTime());
}
}
cnd.groupBy("info.id");
cnd.desc("startTime");
sql.setCondition(cnd);
Pagination pagination = listPage(pageNumber, pageSize, sql);
List<Object> list = pagination.getList();
list.forEach(item -> {
Record map = (Record) item;
List<NutMap> canAuditUserByLoginUser = this.getCanAuditUserByLoginUser(map.getString("id"), stateIdForMeCanAudit);
map.put("no_audit", canAuditUserByLoginUser.size());
});
return pagination;
}
@Override
public List<NutMap> getLeaveUser(String meetingId, String moduleName, String auditType) {
Sql sqlMeeting = Sqls.create("""
select
id,
startTime,
endTime,
timePeriodName
from
meeting_time_period
$condition
""");
Cnd cndMeeting = Cnd.NEW();
cndMeeting.and("meetingId", "=", meetingId);
sqlMeeting.setCondition(cndMeeting);
List<NutMap> meetingList = listMap(sqlMeeting);
List<NutMap> list = "canAudit".equals(auditType) ? this.getCanAuditUserByLoginUser(meetingId, meetingCommonService.findStateIdForMeCanAudit()) : this.getHasAuditUserByLoginUser(meetingId);
//将list分组
LinkedHashMap<String, List<NutMap>> map = new LinkedHashMap<>();
list.forEach(item -> {
String meetingTimePeriodId = item.getString("meetingTimePeriodId");
if (map.containsKey(meetingTimePeriodId)) {
map.get(meetingTimePeriodId).add(item);
} else {
List<NutMap> listMap = new ArrayList<>();
listMap.add(item);
map.put(meetingTimePeriodId, listMap);
}
});
//汇总数据
meetingList.forEach(item -> {
String id = item.getString("id");
item.put("users", map.get(id));
});
return meetingList;
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void audit(String[] tpuIds, Audit audit, boolean isPass) {
dao().insert(audit);
for (String tp_id : tpuIds) {
MeetingTimePeriodUser periodUser = dao().fetch(MeetingTimePeriodUser.class, tp_id);
Integer stateCode = periodUser.getStateCode();
Integer afterStateCode = meetingCommonService.findAfterStateCode(stateCode, isPass);
periodUser.setStateCode(afterStateCode);
List<NutMap> auditIdList = periodUser.getAuditIdList();
if (Lang.isEmpty(auditIdList)) {
auditIdList = new ArrayList<>();
}
auditIdList.add(NutMap.NEW().addv("stateCode", stateCode).addv("auditId", audit.getId()).addv("auditUser", ShiroUtil.getPrincipalProperty("id")).addv("auditState", isPass));
periodUser.setAuditIdList(auditIdList);
if (!isPass) {
periodUser.setIsJoin(null);
periodUser.setLeaveReason(null);
}
dao().update(periodUser);
}
}
/*根据当前登录用户获取可以审核的用户*/
public List<NutMap> getCanAuditUserByLoginUser(String meetingId, List<Integer> stateIdForMeCanAudit) {
Sql sql = Sqls.create("""
SELECT
mu.*,
u.username,
u.loginname,
u.sex,
u.unionid,
u.unitid,
u.unitname,
state.auditAfterType
FROM
meeting_time_period_user mu
left join `user` u on mu.userId=u.id
LEFT JOIN audit_state state on state.stateId = mu.stateCode
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.andEX("mu.meetingId", "=", meetingId);
cnd.and("u.username", "is not", null);
cnd.and("u.username", "!=", "");
cnd.and("mu.stateCode", "in", Sqls.createf("SELECT stateId FROM audit_state_user WHERE userid = '%s'", ShiroUtil.getPrincipalProperty("id")));
cnd.and("state.stateAuditType", "in", Lang.list(AuditTypeEnum.AUDIT.getValue()));
List<AuditState> audit = dao().query(AuditState.class, Cnd.where("stateId", "in", stateIdForMeCanAudit));
SqlExpressionGroup sqlExpressionGroup = new SqlExpressionGroup();
audit.forEach(v -> {
if (StrUtil.isNotBlank(v.getAuditAfterType())) {
CustomAuditTypeHandle instance = Enum.instance(CustomAuditTypeHandle.class, v.getAuditAfterType());
if(instance != null) {
instance.next(sqlExpressionGroup);
}
}
});
if (!sqlExpressionGroup.isEmpty()) {
cnd.and(sqlExpressionGroup);
}
sql.setCondition(cnd);
return listMap(sql);
}
/*根据当前登录用户获取已经审核的用户*/
public List<NutMap> getHasAuditUserByLoginUser(String meetingId) {
Sql sql = Sqls.create("""
select
mu.*,
u.username,
u.loginname,
u.unitname
from
meeting_time_period_user mu
left join
`user` u on mu.userid=u.id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("meetingId", "=", meetingId);
cnd.and(new Static("JSON_CONTAINS(auditIdList, JSON_OBJECT('auditUser', '" + ShiroUtil.getPrincipalProperty("id") + "'))"));
sql.setCondition(cnd);
List<NutMap> list = listMap(sql);
list.forEach(item -> {
List<NutMap> listMap = Json.fromJsonAsList(NutMap.class, item.getString("auditIdList"));
Boolean auditState = false;
for (NutMap map : listMap) {
if (map.getString("auditUser").equals(ShiroUtil.getPrincipalProperty("id"))) {
auditState = map.get("auditState") == null ? null : map.getBoolean("auditState");
break;
}
}
item.put("auditState", auditState);
});
return list;
}
}
@@ -0,0 +1,265 @@
package io.v.nutz.meeting.service.impl;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.jdh.model.cb.Jdh_jdhxx;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingType;
import io.v.nutz.meeting.service.MeetingBasicStatisticsService;
import io.v.nutz.meeting.service.MeetingCommonService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.workersCongress.model.WorkersCongressSession;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import java.util.List;
@IocBean(args = {"refer:dao"})
public class MeetingBasicStatisticsServiceImpl extends ViServiceImpl implements MeetingBasicStatisticsService {
@Inject
private MeetingCommonService meetingCommonService;
public MeetingBasicStatisticsServiceImpl(Dao dao) {
super(dao);
}
@Override
public Pagination pageData(PageForm pageForm, String meetingId, String[] meetingTime, String typeId) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
info.* ,
type.moduleName,
type.meetingTypeName
FROM
meeting_info info
LEFT JOIN meeting_type type ON type.id = info.typeId
$condition
""");
if (meetingTime != null && meetingTime.length == 2) {
cnd.and("info.startTime", ">=", meetingTime[0]);
cnd.and("info.startTime", "<=", meetingTime[1]);
}
cnd.andEX("info.id", "=", meetingId);
cnd.andEX("type.id", "=", typeId);
cnd.desc("startTime");
sql.setCondition(cnd);
Pagination list = list(pageForm, sql);
List<NutMap> listList = list.getList();
//获取教代会最新届次
Jdh_jdhxx jdh = dao().fetch(Jdh_jdhxx.class, Cnd.where("jdhkqzt", "=", 1).desc("jdhkqsj"));
//获取教代会最新届次
WorkersCongressSession gdh = dao().fetch(WorkersCongressSession.class, Cnd.where("startState", "=", 1).desc("startTime"));
listList.forEach(v -> {
MeetingType meetingType = dao().fetch(MeetingType.class, v.getInt("typeId"));
String successStateCode = meetingCommonService.findSuccessStateCode(v.getString("id")).toString();
if ("teacherMeeting".equals(meetingType.getModuleName())) {
Cnd cndChild = Cnd.NEW();
Sql sqlChild = Sqls.create("""
SELECT
mtp.*,
info.meetingName,
type.meetingTypeName,
count( mtpu.id ) AS total,
sum( CASE WHEN mtpu.isJoin IS null OR (mtpu.isJoin is NOT null AND mtpu.stateCode != @successStateCode) THEN 1 ELSE 0 END ) AS joinNum,
sum( CASE WHEN mtpu.isJoin = 0 AND mtpu.stateCode = @successStateCode THEN 1 ELSE 0 END ) AS notJoinNum,
sum( CASE WHEN mtpu.isSignIn = 1 THEN 1 ELSE 0 END ) AS signJoinNum,
sum( CASE WHEN (mtpu.isJoin IS null AND mtpu.isSignIn is null) OR (mtpu.isJoin is NOT null AND mtpu.stateCode !=@successStateCode AND mtpu.isSignIn is null) THEN 1 ELSE 0 END ) AS notJoinNullNum,
sum( CASE WHEN (mtpu.isSignIn = 1) AND (d.roleid = @zsdb) AND d.jdhid = @jdhId THEN 1 ELSE 0 END) as zsdbNum,
sum( CASE WHEN (mtpu.isSignIn = 1) AND (d.roleid = @lxdb) AND d.jdhid = @jdhId THEN 1 ELSE 0 END) as lxdbNum
FROM
meeting_time_period mtp
LEFT JOIN meeting_info info ON mtp.meetingId = info.id
LEFT JOIN meeting_type type ON type.id = info.typeId
LEFT JOIN meeting_time_period_user mtpu ON mtpu.meetingTimePeriodId = mtp.id
LEFT JOIN jdh_db d on d.dbid = mtpu.userId and jdhid=@jdhId
$condition
""").setParam("successStateCode", successStateCode)
.setParam("zsdb", Roles.ZSDB)
.setParam("lxdb", Roles.LXDB)
.setParam("jdhId", jdh.getId());
cndChild.and("mtp.meetingId", "=", v.getString("id"));
cndChild.desc("mtp.startTime");
cndChild.groupBy("mtp.id");
sqlChild.setCondition(cndChild);
List<NutMap> childList = listMap(sqlChild);
v.put("meetingTimeData", childList);
}else if ("gdh".equals(meetingType.getModuleName())) {
Cnd cndChild = Cnd.NEW();
Sql sqlChild = Sqls.create("""
SELECT
mtp.*,
info.meetingName,
type.meetingTypeName,
count( mtpu.id ) AS total,
sum( CASE WHEN mtpu.isJoin IS null OR (mtpu.isJoin is NOT null AND mtpu.stateCode != @successStateCode) THEN 1 ELSE 0 END ) AS joinNum,
sum( CASE WHEN mtpu.isJoin = 0 AND mtpu.stateCode = @successStateCode THEN 1 ELSE 0 END ) AS notJoinNum,
sum( CASE WHEN mtpu.isSignIn = 1 THEN 1 ELSE 0 END ) AS signJoinNum,
sum( CASE WHEN (mtpu.isJoin IS null AND mtpu.isSignIn is null) OR (mtpu.isJoin is NOT null AND mtpu.stateCode !=@successStateCode AND mtpu.isSignIn is null) THEN 1 ELSE 0 END ) AS notJoinNullNum,
sum( CASE WHEN (mtpu.isSignIn = 1) AND (d.roleId = @zsdb) AND d.gdh_id = @gdhId THEN 1 ELSE 0 END) as zsdbNum,
sum( CASE WHEN (mtpu.isSignIn = 1) AND (d.roleId = @lxdb) AND d.gdh_id = @gdhId THEN 1 ELSE 0 END) as lxdbNum
FROM
meeting_time_period mtp
LEFT JOIN meeting_info info ON mtp.meetingId = info.id
LEFT JOIN meeting_type type ON type.id = info.typeId
LEFT JOIN meeting_time_period_user mtpu ON mtpu.meetingTimePeriodId = mtp.id
LEFT JOIN workers_congress_representative d on d.userId = mtpu.userId and gdh_id=@gdhId
$condition
""").setParam("successStateCode", successStateCode)
.setParam("zsdb", Roles.GDHDB)
.setParam("lxdb", Roles.GDHLX)
.setParam("gdhId", gdh.getId());
cndChild.and("mtp.meetingId", "=", v.getString("id"));
cndChild.desc("mtp.startTime");
cndChild.groupBy("mtp.id");
sqlChild.setCondition(cndChild);
List<NutMap> childList = listMap(sqlChild);
v.put("meetingTimeData", childList);
}
});
return list;
}
@Override
public Object getMeetingList(String[] meetingTime) {
Cnd cnd = Cnd.NEW();
if (meetingTime != null && meetingTime.length == 2) {
cnd.and("startTime", ">=", meetingTime[0]);
cnd.and("startTime", "<=", meetingTime[1]);
}
cnd.desc("startTime");
return dao().query(MeetingInfo.class, cnd);
}
@Override
public Object getUserData(PageForm pageForm, String id, String meetingId, String type, String unitId, String unionId) {
String successStateCode = meetingCommonService.findSuccessStateCode(meetingId).toString();
MeetingInfo meetingInfo = dao().fetch(MeetingInfo.class, meetingId);
MeetingType meetingType = dao().fetch(MeetingType.class, meetingInfo.getTypeId());
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
mtp.*,
u.loginname AS loginName,
u.username AS userName,
u.unitname AS unitName,
u.unionname AS unionName
FROM
meeting_time_period_user mtp
LEFT JOIN `user` u ON mtp.userId = u.id
$condition
""");
if (type.equals("notJoinNum")) {
cnd.and("mtp.isJoin", "=", 0);
} else if (type.equals("signJoinNum")) {
cnd.and("mtp.isSignIn", "=", 1);
} else if (type.equals("notJoinNullNum")) {
cnd.and(new Static("(mtp.isJoin IS null AND mtp.isSignIn is null AND mtp.meetingTimePeriodId = '%s') OR (mtp.isJoin is NOT null AND mtp.stateCode !='%s' AND mtp.isSignIn is null AND mtp.meetingTimePeriodId = '%s')".formatted(id, successStateCode, id)));
}
if ("teacherMeeting".equals(meetingType.getModuleName())) {
//获取教代会最新届次
Jdh_jdhxx jdh = dao().fetch(Jdh_jdhxx.class, Cnd.where("jdhkqzt", "=", 1).desc("jdhkqsj"));
if (type.equals("zsdbNum")) {
cnd.and("mtp.isSignIn", "=", 1);
cnd.and(new Static(" mtp.userId in (select dbid from jdh_db where jdhid='%s' and roleid='%s')".formatted(jdh.getId(), Roles.ZSDB)));
} else if (type.equals("lxdbNum")) {
cnd.and("mtp.isSignIn", "=", 1);
cnd.and(new Static(" mtp.userId in (select dbid from jdh_db where jdhid='%s' and roleid='%s')".formatted(jdh.getId(), Roles.LXDB)));
}
} else if ("gdh".equals(meetingType.getModuleName())) {
//获取教代会最新届次
WorkersCongressSession jdh = dao().fetch(WorkersCongressSession.class, Cnd.where("startState", "=", 1).desc("startTime"));
if (type.equals("zsdbNum")) {
cnd.and("mtp.isSignIn", "=", 1);
cnd.and(new Static(" mtp.userId in (select userId from workers_congress_representative where gdh_id='%s' and roleId='%s')".formatted(jdh.getId(), Roles.GDHDB)));
} else if (type.equals("lxdbNum")) {
cnd.and("mtp.isSignIn", "=", 1);
cnd.and(new Static(" mtp.userId in (select userId from workers_congress_representative where gdh_id='%s' and roleId='%s')".formatted(jdh.getId(), Roles.GDHLX)));
}
}
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("u.unionid", "=", unionId);
if (Strings.isNotBlank(pageForm.getSearchName()) && Strings.isNotBlank(pageForm.getSearchKeyword())) {
cnd.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
}
cnd.and("mtp.meetingTimePeriodId", "=", id);
cnd.desc("u.unitid");
sql.setCondition(cnd);
return list(pageForm, sql);
}
@Override
public List<NutMap> getUserData(String id, String meetingId, String type) {
String successStateCode = meetingCommonService.findSuccessStateCode(meetingId).toString();
MeetingInfo meetingInfo = dao().fetch(MeetingInfo.class, meetingId);
MeetingType meetingType = dao().fetch(MeetingType.class, meetingInfo.getTypeId());
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
mtp.*,
u.loginname AS loginName,
u.username AS userName,
u.unitname AS unitName,
u.unionname AS unionName
FROM
meeting_time_period_user mtp
LEFT JOIN `user` u ON mtp.userId = u.id
$condition
""");
cnd.and("mtp.meetingTimePeriodId", "=", id);
if (type.equals("请假人数")) {
cnd.and("mtp.isJoin", "=", 0).and("mtp.stateCode", "=", successStateCode);
} else if (type.equals("实到人数")) {
cnd.and("mtp.isSignIn", "=", 1);
} else if (type.equals("未到人数")) {
cnd.and(new Static("(mtp.isJoin IS null AND mtp.isSignIn is null and mtp.meetingTimePeriodId ='%s') OR (mtp.isJoin is NOT null AND mtp.stateCode !='%s' AND mtp.isSignIn is null and mtp.meetingTimePeriodId ='%s')".formatted(id, successStateCode, id)));
}
if ("teacherMeeting".equals(meetingType.getModuleName())) {
//获取教代会最新届次
Jdh_jdhxx jdh = dao().fetch(Jdh_jdhxx.class, Cnd.where("jdhkqzt", "=", 1).desc("jdhkqsj"));
if (type.equals("正式代表")) {
cnd.and("mtp.isSignIn", "=", 1);
cnd.and(new Static(" mtp.userId in (select dbid from jdh_db where jdhid='%s' and roleid='%s')".formatted(jdh.getId(), Roles.ZSDB)));
} else if (type.equals("列席代表")) {
cnd.and("mtp.isSignIn", "=", 1);
cnd.and(new Static(" mtp.userId in (select dbid from jdh_db where jdhid='%s' and roleid='%s')".formatted(jdh.getId(), Roles.LXDB)));
}
} else if ("gdh".equals(meetingType.getModuleName())) {
//获取教代会最新届次
WorkersCongressSession jdh = dao().fetch(WorkersCongressSession.class, Cnd.where("startState", "=", 1).desc("startTime"));
if (type.equals("正式代表")) {
cnd.and("mtp.isSignIn", "=", 1);
cnd.and(new Static(" mtp.userId in (select userId from workers_congress_representative where gdh_id='%s' and roleId='%s')".formatted(jdh.getId(), Roles.GDHDB)));
} else if (type.equals("列席代表")) {
cnd.and("mtp.isSignIn", "=", 1);
cnd.and(new Static(" mtp.userId in (select userId from workers_congress_representative where gdh_id='%s' and roleId='%s')".formatted(jdh.getId(), Roles.GDHLX)));
}
}
sql.setCondition(cnd);
return listMap(sql);
}
}
@@ -0,0 +1,137 @@
package io.v.nutz.meeting.service.impl;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.constant.AuditTypeEnum;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingType;
import io.v.nutz.meeting.service.MeetingCommonService;
import io.v.nutz.modules.models.AuditState;
import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.util.ShiroUtil;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
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.lang.util.NutMap;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@IocBean(args = {"refer:dao"})
public class MeetingCommonServiceImpl extends ViServiceImpl implements MeetingCommonService {
@Inject
private Vi vi;
public MeetingCommonServiceImpl(Dao dao) {
super(dao);
}
@Override
public String findModuleNameByTypeId(Integer typeId) {
MeetingType meetingType = dao().fetch(MeetingType.class, Cnd.where("id", "=", typeId));
if (Lang.isNotEmpty(meetingType)) {
return meetingType.getModuleName();
}
return null;
}
@Override
public String findModuleNameByMeetingId(String meetingId) {
MeetingInfo meetingInfo = dao().fetch(MeetingInfo.class, meetingId);
if (Lang.isNotEmpty(meetingInfo) && null != meetingInfo.getTypeId()) {
return findModuleNameByTypeId(meetingInfo.getTypeId());
}
return null;
}
@Override
public Integer findStartStateCodeByModuleName(String moduleName) {
List<AuditState> auditStateList = dao().query(AuditState.class, Cnd.where("module", "=", moduleName).asc("stateId"));
Optional<Integer> minOptional = auditStateList.stream().map(v -> v.getStateId()).min(Comparator.comparingInt(a -> a)).stream().findFirst();
return minOptional.orElse(null);
}
@Override
public Integer findAfterStateCode(Integer stateCode, boolean isPass) {
AuditState auditState = dao().fetch(AuditState.class, stateCode);
return isPass ? auditState.getAfterPassStateId() : auditState.getAfterRejectStateId();
}
@Override
public Integer findSuccessStateCode(String meetingId) {
String moduleName = findModuleNameByMeetingId(meetingId);
Cnd cnd = Cnd.where("module", "=", moduleName).and("stateAuditType", "=", AuditTypeEnum.PROCESS_PASS.getValue());
AuditState auditState = dao().fetch(AuditState.class, cnd);
return auditState.getStateId();
}
@Override
public Integer findAfterStateCodeByModuleName(Integer stateCode, String moduleName) {
AuditState auditState = dao().fetch(AuditState.class, Cnd.where("stateId", "=", stateCode));
if (Lang.isNotEmpty(auditState)) {
return auditState.getAfterStateId();
}
return null;
}
@Override
public Object find() {
List<MeetingType> typeList = dao().query(MeetingType.class, null);
List<String> typeModuleNameList = typeList.stream().map(MeetingType::getModuleName).collect(Collectors.toList());
List<AuditState> auditStateList = dao().query(AuditState.class, Cnd.where("module", "in", typeModuleNameList));
for (AuditState state : auditStateList) {
dao().fetchLinks(state, "auditStateUserList");
}
return null;
}
@Override
public List<Integer> findStateIdForMeCanAudit() {
Cnd cnd = Cnd.NEW();
cnd.and("stateId", "in", Sqls.create("select stateId from audit_state_user where userId = @userid").setParam("userid", ShiroUtil.getPrincipalProperty("id")));
List<AuditState> auditStateList = dao().query(AuditState.class, cnd);
return auditStateList.stream().map(v -> v.getStateId()).collect(Collectors.toList());
}
/*根据状态码获取下一节点审核人*/
@Override
public List<NutMap> getNextAuditUser(Integer stateCode, String moduleName) {
Sql sql = Sqls.create("""
select
au.userId as userId,
u.username as userName,
u.loginname as loginName,
u.unitname as unitName,
u.mobile as mobile
from
audit_state_user au
left join
`user` u on au.userid = u.id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("stateId", "=", stateCode);
if (StrUtil.isNotBlank(moduleName) && "teacherMeeting".equals(moduleName) && stateCode == 4910) {
String jdhid = vi.getLastTeacherMeetingId();
String dbtId = vi.getLastDelegationId(ShiroUtil.getPrincipalProperty("id").toString());
cnd.and("userId", "in", Sqls.createf("select userid from sys_user_role where jdhid='%s' and roleid='%s' and dbtId='%s'", jdhid, Roles.DBT_TZ, dbtId));
}
sql.setCondition(cnd);
return listMap(sql);
}
}
@@ -0,0 +1,241 @@
package io.v.nutz.meeting.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingTimePeriod;
import io.v.nutz.meeting.models.MeetingTimePeriodUser;
import io.v.nutz.meeting.models.MeetingUser;
import io.v.nutz.meeting.service.MeetingManageService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.msgNotify.models.MsgNotify;
import io.v.nutz.msgNotify.models.MsgNotifyUser;
import io.v.nutz.msgNotify.service.MsgNotifyService;
import io.v.nutz.service.impl.ViServiceImpl;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@IocBean(args = {"refer:dao"})
public class MeetingManageServiceImpl extends ViServiceImpl<MeetingInfo> implements MeetingManageService {
@Inject
private MsgNotifyService msgNotifyService;
public MeetingManageServiceImpl(Dao dao) {
super(dao);
}
@Override
public Pagination pageData(PageForm pageForm, Cnd cnd) {
Sql sql = Sqls.create("""
SELECT
info.*,
type.meetingTypeName
FROM
meeting_info info
LEFT JOIN meeting_type type ON type.id = info.typeId
$condition
""");
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
SqlExpressionGroup seg = new SqlExpressionGroup();
seg.orLike("info.meetingName", pageForm.getSearchKeyword());
seg.orLike("info.location", pageForm.getSearchKeyword());
cnd.and(seg);
}
cnd.desc("info.startTime");
sql.setCondition(cnd);
return list(pageForm, sql);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doAdd(MeetingInfo meetingInfo) {
dao().insertWith(meetingInfo, "^meetingUserList|meetingTimePeriods$");
insertMeetingTimePeriodUser(meetingInfo.getId(), meetingInfo.getMeetingTimePeriods(), meetingInfo.getMeetingUserList());
}
/**
* 插入会议时间段 - 用户 数据
*
* @param meetingId 会议id
* @param meetingTimePeriods 时间段
* @param meetingUserList 人员
*/
private void insertMeetingTimePeriodUser(String meetingId, List<MeetingTimePeriod> meetingTimePeriods, List<MeetingUser> meetingUserList) {
if (Lang.isNotEmpty(meetingTimePeriods) && Lang.isNotEmpty(meetingUserList)) {
ArrayList<MeetingTimePeriodUser> insertList = new ArrayList<>();
for (MeetingTimePeriod timePeriod : meetingTimePeriods) {
for (MeetingUser meetingUser : meetingUserList) {
MeetingTimePeriodUser timePeriodUser = new MeetingTimePeriodUser();
timePeriodUser.setMeetingId(meetingId);
timePeriodUser.setMeetingTimePeriodId(timePeriod.getId());
timePeriodUser.setUserId(meetingUser.getUserId());
insertList.add(timePeriodUser);
}
}
dao().insert(insertList);
}
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doEdit(MeetingInfo meetingInfo, List<String> userIds) {
//原来的人
List<MeetingUser> oldMus = dao().query(MeetingUser.class, Cnd.where("meetingId", "=", meetingInfo.getId()));
List<String> oldMuIds = oldMus.stream().map(v -> v.getUserId()).collect(Collectors.toList());
//新增的人
List<String> newMuIds = userIds.stream().filter(v -> !oldMuIds.contains(v)).collect(Collectors.toList());
//新增的人
// List<MeetingUser> newMus = dao().query(MeetingUser.class, Cnd.where("userid", "not in", userIds).and("meetingId","=",meetingInfo.getId()));
// List<String> newMuIds = newMus.stream().map(v -> v.getUserId()).collect(Collectors.toList());
//新增的时间段
List<MeetingTimePeriod> newTps = meetingInfo.getMeetingTimePeriods().stream().filter(v -> StrUtil.isBlank(v.getId())).collect(Collectors.toList());
//原来的用户
// List<MeetingUser> oldMus = dao().query(MeetingUser.class, Cnd.where("meetingId", "=", meetingInfo.getId()));
// List<String> oldMuIds = oldMus.stream().map(v -> v.getUserId()).collect(Collectors.toList());
dao().update(meetingInfo);
//删除改删得记录
dao().clear(MeetingUser.class, Cnd.where("userid", "not in", userIds).and("meetingId", "=", meetingInfo.getId()));
dao().clear(MeetingTimePeriodUser.class, Cnd.where("userid", "not in", userIds).and("meetingId", "=", meetingInfo.getId()));
List<MeetingTimePeriod> meetingTimePeriods = meetingInfo.getMeetingTimePeriods();
List<String> meetingTimePeriodIds = meetingTimePeriods.stream().map(v -> v.getId()).collect(Collectors.toList());
dao().clear(MeetingTimePeriod.class, Cnd.where("id", "not in", meetingTimePeriodIds).and("meetingId", "=", meetingInfo.getId()));
// dao().clear(MeetingTimePeriodUser.class, Cnd.where("meetingTimePeriodId", "not in", meetingTimePeriodIds));
dao().clear(MeetingUser.class, Cnd.where("meetingId", "=", meetingInfo.getId()));
ArrayList<MeetingUser> insertMuList = new ArrayList<>();
userIds.forEach(v -> {
MeetingUser meetingUser = new MeetingUser();
meetingUser.setMeetingId(meetingInfo.getId());
meetingUser.setUserId(v);
insertMuList.add(meetingUser);
});
dao().insert(insertMuList);
List<MeetingTimePeriod> mTps = meetingInfo.getMeetingTimePeriods();
for (MeetingTimePeriod mTp : mTps) {
if (StrUtil.isNotBlank(mTp.getId())) {
dao().update(mTp);
List<MeetingTimePeriodUser> mtpus = new ArrayList<>();
if (Lang.isNotEmpty(newMuIds)) {
//旧时间段 并且 有新增的人员
for (String newMuId : newMuIds) {
MeetingTimePeriodUser mtpu = new MeetingTimePeriodUser();
mtpu.setMeetingId(meetingInfo.getId());
mtpu.setUserId(newMuId);
mtpu.setMeetingTimePeriodId(mTp.getId());
mtpus.add(mtpu);
}
dao().insert(mtpus);
} else {
//旧时间段 并且 没有新增的人员 不用管
}
} else {
//有新增的时间段
mTp.setMeetingId(meetingInfo.getId());
dao().insert(mTp);
List<MeetingTimePeriodUser> mtpus = new ArrayList<>();
for (String userId : userIds) {
MeetingTimePeriodUser mtpu = new MeetingTimePeriodUser();
mtpu.setMeetingId(meetingInfo.getId());
mtpu.setUserId(userId);
mtpu.setMeetingTimePeriodId(mTp.getId());
mtpus.add(mtpu);
}
dao().insert(mtpus);
/*if (Lang.isEmpty(newMus)) {
//有新增的时间段 但是 没有新增的人员
for (String oldMuUserId : oldMuIds) {
MeetingTimePeriodUser mtpu = new MeetingTimePeriodUser();
mtpu.setMeetingId(meetingInfo.getId());
mtpu.setUserId(oldMuUserId);
mtpu.setMeetingTimePeriodId(mTp.getId());
mtpus.add(mtpu);
}
dao().insert(mtpus);
} else {
//有新增的时间段 并且 有新增的人员
for (String userId : userIds) {
MeetingTimePeriodUser mtpu = new MeetingTimePeriodUser();
mtpu.setMeetingId(meetingInfo.getId());
mtpu.setUserId(userId);
mtpu.setMeetingTimePeriodId(mTp.getId());
mtpus.add(mtpu);
}
dao().insert(mtpus);
}*/
}
}
// //更新会议
// dao().update(meetingInfo);
//
// //新会议人员
// List<MeetingUser> meetingUserList = meetingInfo.getMeetingUserList();
// List<String> meetingUserIdList = meetingUserList.stream().map(MeetingUser::getId).collect(Collectors.toList());
// //删除不在新会议人员里面的数据
// dao().clear(MeetingUser.class, Cnd.where("id", "not in", meetingUserIdList));
// //批量更新 效率更高
// for (MeetingUser meetingUser : meetingUserList) {
// meetingUser.setMeetingId(meetingInfo.getId());
// }
// dao().insertOrUpdate(meetingUserList);
//
//
// //会议时间段
// List<MeetingTimePeriod> meetingTimePeriods = meetingInfo.getMeetingTimePeriods();
// List<String> meetingTimePeriodIds = meetingTimePeriods.stream().map(MeetingTimePeriod::getId).collect(Collectors.toList());
// //删除会议时间段 - 用户 记录
// dao().clear(MeetingTimePeriodUser.class, Cnd.where("meetingTimePeriodId", "not in", meetingTimePeriodIds));
// dao().clear(MeetingTimePeriodUser.class, Cnd.where("userId", "not in", meetingUserList.stream().map(v -> v.getUserId()).collect(Collectors.toList())));
//
// //新增的时间段
// List<MeetingTimePeriod> newTimePeriod = meetingInfo.getMeetingTimePeriods().stream().filter(v -> StrUtil.isBlank(v.getId())).collect(Collectors.toList());
// insertMeetingTimePeriodUser(meetingInfo.getId(), newTimePeriod, meetingInfo.getMeetingUserList());
//
// //需要编辑的时间段
// List<MeetingTimePeriod> editTimePeriod = meetingInfo.getMeetingTimePeriods().stream().filter(v -> StrUtil.isBlank(v.getId())).collect(Collectors.toList());
// dao().update(editTimePeriod);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doDelete(String id) {
MeetingInfo meetingInfo = dao().fetch(MeetingInfo.class, id);
dao().clear(MeetingUser.class, Cnd.where("meetingId", "=", id));
dao().clear(MeetingTimePeriod.class, Cnd.where("meetingId", "=", id));
dao().clear(MeetingTimePeriodUser.class, Cnd.where("meetingId", "=", id));
dao().clear(MsgNotify.class, Cnd.where("id", "=", meetingInfo.getNotifyId()));
dao().clear(MsgNotifyUser.class, Cnd.where("titleId", "=", meetingInfo.getNotifyId()));
dao().delete(meetingInfo);
}
}
@@ -0,0 +1,141 @@
package io.v.nutz.meeting.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingTimePeriodUser;
import io.v.nutz.meeting.service.MeetingCommonService;
import io.v.nutz.meeting.service.MeetingMineService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.msgNotify.service.MsgNotifyService;
import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import java.util.Date;
import java.util.List;
@IocBean(args = {"refer:dao"})
public class MeetingMineServiceImpl extends ViServiceImpl implements MeetingMineService {
@Inject
private MeetingCommonService meetingCommonService;
@Inject
private MsgNotifyService msgNotifyService;
public MeetingMineServiceImpl(Dao dao) {
super(dao);
}
@Override
public Pagination myMeetingPageData(PageForm pageForm, Cnd cnd) {
String userId = (String) ShiroUtil.getPrincipalProperty("id");
Sql sql = Sqls.create("""
SELECT
info.*,
type.meetingTypeName,
mu.isJoin,
state.stateName,
state.stateColor,
mu.stateCode,
(select stateId from audit_state where module = type.moduleName order by stateId asc limit 1) firstState
FROM
meeting_info info
LEFT JOIN meeting_type type ON type.id = info.typeId
LEFT JOIN meeting_time_period_user mu ON mu.meetingId = info.id
LEFT JOIN audit_state state on state.stateId = mu.stateCode
$condition
""");
Sql userSql = Sqls.create("select meetingId from meeting_time_period_user where userId = @userId").setParam("userId", userId);
cnd.and("info.id", "in", userSql);
cnd.and("mu.userid", "=", userId);
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
SqlExpressionGroup seg = new SqlExpressionGroup();
seg.orLike("meetingName", pageForm.getSearchKeyword());
seg.orLike("location", pageForm.getSearchKeyword());
cnd.and(seg);
}
cnd.groupBy("info.id");
cnd.desc("info.startTime");
sql.setCondition(cnd);
Pagination list = list(pageForm, sql);
return list;
}
@Override
public List<Object> findMyMeetPeriod(String meetingId) {
Sql sql = Sqls.create("""
SELECT
tp.id AS tpid,
tp.startTime,
tp.endTime,
tp.timePeriodName,
tpu.*,
tpu.id as tpuId,
state.stateName,
state.stateAuditType
FROM
meeting_time_period tp
LEFT JOIN meeting_time_period_user tpu ON tpu.meetingTimePeriodId = tp.id
LEFT JOIN audit_state state on state.stateId = tpu.stateCode
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("tp.meetingId", "=", meetingId);
cnd.and("tpu.userId", "=", ShiroUtil.getPrincipalProperty("id"));
sql.setCondition(cnd);
return listMap(sql);
}
@Override
public void askForLeave(List<MeetingTimePeriodUser> meetingTimePeriodUsers) {
String moduleName = meetingCommonService.findModuleNameByMeetingId(meetingTimePeriodUsers.get(0).getMeetingId());
Integer stateCode = meetingCommonService.findStartStateCodeByModuleName(moduleName);
if (stateCode != null) {
meetingTimePeriodUsers.forEach(item -> {
item.setIsJoin(false);
item.setStateCode(stateCode);
});
dao().updateIgnoreNull(meetingTimePeriodUsers);
List<NutMap> userIdMap = meetingCommonService.getNextAuditUser(stateCode, moduleName);
String userInfoStr = msgNotifyService.userData(userIdMap);
String meetingId = meetingTimePeriodUsers.get(0).getMeetingId();
MeetingInfo meetingInfo = dao().fetch(MeetingInfo.class, meetingId);
String loginname = ShiroUtil.getPlatformUsername();
String msgStr = String.format("%s针对%s提交了请假申请,请您审批!", loginname, meetingInfo.getMeetingName());
//msgApi.sendSmsMsg(userInfoStr, msgStr);
}
}
@Override
public void confirmMeeting(List<String> tpuIds) {
// meetingUser.setIsJoin(true);
// dao().updateIgnoreNull(meetingUser);
Chain chain = Chain.make("isJoin", true);
Cnd cnd = Cnd.where("id", "in", tpuIds);
dao().update(MeetingTimePeriodUser.class, chain, cnd);
}
@Override
public void signIn(MeetingTimePeriodUser timePeriodUser) {
timePeriodUser.setIsSignIn(true);
timePeriodUser.setSignInDateTime(new Date());
dao().updateIgnoreNull(timePeriodUser);
}
}
@@ -0,0 +1,219 @@
package io.v.nutz.meeting.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.jdh.model.cb.Jdh_jdhxx;
import io.v.nutz.jdh.model.db.Jdh_db;
import io.v.nutz.meeting.models.MeetingInfo;
import io.v.nutz.meeting.models.MeetingTimePeriod;
import io.v.nutz.meeting.models.MeetingType;
import io.v.nutz.meeting.service.MeetingCommonService;
import io.v.nutz.meeting.service.MeetingOnlineService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.msgNotify.models.MsgNotify;
import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.workersCongress.model.WorkersCongressRepresentative;
import io.v.nutz.workersCongress.model.WorkersCongressSession;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@IocBean(args = {"refer:dao"})
public class MeetingOnlineServiceImpl extends ViServiceImpl implements MeetingOnlineService {
@Inject
private MeetingCommonService meetingCommonService;
public MeetingOnlineServiceImpl(Dao dao) {
super(dao);
}
@Override
public Pagination pageData(PageForm pageForm, Cnd cnd) {
Sql sql = Sqls.create("""
SELECT
info.*,
type.meetingTypeName,
type.moduleName,
@qrCodeUrl as qrCodeUrl
FROM
meeting_info info
LEFT JOIN meeting_type type ON type.id = info.typeId
$condition
""");
sql.setParam("qrCodeUrl", "");
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
SqlExpressionGroup seg = new SqlExpressionGroup();
seg.orLike("info.meetingName", pageForm.getSearchKeyword());
seg.orLike("info.location", pageForm.getSearchKeyword());
cnd.and(seg);
}
cnd.desc("info.startTime");
sql.setCondition(cnd);
Pagination pagination = list(pageForm, sql);
List<NutMap> list = pagination.getList();
for (NutMap map : list) {
List<MeetingTimePeriod> timePeriods = dao().query(MeetingTimePeriod.class, Cnd.where("meetingId", "=", map.getString("id", "")).asc("startTime"));
map.setv("timePeriods", timePeriods);
}
pagination.setList(list);
return pagination;
}
@Override
public List<NutMap> exportSignature(String timePeriodId) {
Sql sql = Sqls.create("""
SELECT
u.username,
u.loginname,
u.unitname,
u.unionname,
u.mobile
FROM
`meeting_time_period_user` tpu
RIGHT JOIN `user` u ON u.id = tpu.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("tpu.meetingTimePeriodId", "=", timePeriodId);
sql.setCondition(cnd);
List<NutMap> map = listMap(sql);
MeetingTimePeriod period = dao().fetch(MeetingTimePeriod.class, timePeriodId);
MeetingInfo meetingInfo = dao().fetch(MeetingInfo.class, period.getMeetingId());
MeetingType meetingType = dao().fetch(MeetingType.class, meetingInfo.getTypeId());
List<String> userIds = map.stream().map(m -> m.getString("loginname")).collect(Collectors.toList());
List<NutMap> roleNameList=new ArrayList<>();
//如果是教代会会议
if (meetingType.getModuleName().equals("teacherMeeting")) {
MsgNotify notify = dao().fetch(MsgNotify.class, meetingInfo.getNotifyId());
Sql SqlRoleName = Sqls.create("""
SELECT
us.loginname,
sr.`name`
FROM
`jdh_db` db
LEFT JOIN sys_user us ON us.id=db.dbid
LEFT JOIN sys_role sr ON sr.id = db.roleid
where db.jdhid=@jdhid and us.loginname in (@userIds)
""").setParam("jdhid", notify.getTeacherMeetingId()).setParam("userIds", userIds);
roleNameList = listMap(SqlRoleName);
}else if (meetingType.getModuleName().equals("gdh")){
MsgNotify notify = dao().fetch(MsgNotify.class, meetingInfo.getNotifyId());
Sql SqlRoleName = Sqls.create("""
SELECT
us.loginname,
sr.`name`
FROM
`workers_congress_representative` db
LEFT JOIN sys_user us ON us.id = db.userId
LEFT JOIN sys_role sr ON sr.id = db.roleId
WHERE
db.gdh_id = @jdhid and us.loginname in (@userIds)
""").setParam("jdhid", notify.getTeacherMeetingId()).setParam("userIds", userIds);
roleNameList = listMap(SqlRoleName);
}
if (Lang.isNotEmpty(roleNameList)){
List<NutMap> finalRoleNameList = roleNameList;
map.forEach(m -> {
NutMap roleNameMap = finalRoleNameList.stream().filter(r -> r.getString("loginname").equals(m.getString("loginname"))).findFirst().orElse(null);
if (Lang.isNotEmpty(roleNameMap)) {
m.setv("roleName", roleNameMap.getString("name"));
} else {
m.setv("roleName", null);
}
});
}
return map;
}
@Override
public List<Map<String, Object>> getRealTimeData(String timePeriodId) {
MeetingTimePeriod timePeriod = dao().fetch(MeetingTimePeriod.class, timePeriodId);
Integer stateCode = meetingCommonService.findSuccessStateCode(timePeriod.getMeetingId());
Sql sql = Sqls.create("""
SELECT
(select count(1) from meeting_time_period_user where meetingTimePeriodId = @timePeriodId) as shouldComeNumber,
(select count(1) from meeting_time_period_user where meetingTimePeriodId = @timePeriodId and (isJoin is null or (isJoin is not null and stateCode != @stateCode)) and isSignIn is null) as actualComeNumber,
(select count(1) from meeting_time_period_user where meetingTimePeriodId = @timePeriodId and isSignIn = 1) as signInNumber,
(select count(1) from meeting_time_period_user where meetingTimePeriodId = @timePeriodId and isJoin = 0 and stateCode = @stateCode) as leaveNumber
""");
sql.setParam("stateCode", stateCode).setParam("timePeriodId", timePeriodId);
NutMap dataMap = (NutMap) Daos.query(dao(), sql.toString(), Sqls.callback.map());
List<Map<String, Object>> list = new ArrayList<>();
list.add(Map.of("label", "应到人数", "key", "shouldComeNumber", "value", dataMap.getInt("shouldComeNumber", 0)));
list.add(Map.of("label", "未到人数", "key", "actualComeNumber", "value", dataMap.getInt("actualComeNumber", 0)));
list.add(Map.of("label", "签到人数", "key", "signInNumber", "value", dataMap.getInt("signInNumber", 0)));
//如果是教代会,就查询签到的正式代表和列席代表各多少人
MeetingInfo meetingInfo = dao().fetch(MeetingInfo.class, timePeriod.getMeetingId());
MeetingType meetingType = dao().fetch(MeetingType.class, meetingInfo.getTypeId());
if ("teacherMeeting".equals(meetingType.getModuleName())) {
//获取教代会最新届次
Jdh_jdhxx jdh = dao().fetch(Jdh_jdhxx.class, Cnd.where("jdhkqzt", "=", 1).desc("jdhkqsj"));
//查询签到人员
List<NutMap> signInUser = getSignInUser(timePeriodId);
List<String> userList = signInUser.stream().map(o -> o.getString("userId")).collect(Collectors.toList());
//查询代表
List<Jdh_db> dbList = dao().query(Jdh_db.class, Cnd.where("jdhid", "=", jdh.getId()));
long zsdb = dbList.stream().filter(o -> o.getRoleid().equals(Roles.ZSDB) && userList.contains(o.getDbid())).count();
long lxdb = dbList.stream().filter(o -> o.getRoleid().equals(Roles.LXDB) && userList.contains(o.getDbid())).count();
list.add(Map.of("label", "正式代表", "key", "zsdbNumber", "value", zsdb));
list.add(Map.of("label", "列席代表", "key", "lxdbNumber", "value", lxdb));
} else if ("gdh".equals(meetingType.getModuleName())) {
//获取教代会最新届次
WorkersCongressSession jdh = dao().fetch(WorkersCongressSession.class, Cnd.where("startState", "=", 1).desc("startTime"));
//查询签到人员
List<NutMap> signInUser = getSignInUser(timePeriodId);
List<String> userList = signInUser.stream().map(o -> o.getString("userId")).collect(Collectors.toList());
//查询代表
List<WorkersCongressRepresentative> dbList = dao().query(WorkersCongressRepresentative.class, Cnd.where("gdh_id", "=", jdh.getId()));
long zsdb = dbList.stream().filter(o -> o.getRoleId().equals(Roles.GDHDB) && userList.contains(o.getUserId())).count();
long lxdb = dbList.stream().filter(o -> o.getRoleId().equals(Roles.GDHLX) && userList.contains(o.getUserId())).count();
list.add(Map.of("label", "正式代表", "key", "zsdbNumber", "value", zsdb));
list.add(Map.of("label", "列席代表", "key", "lxdbNumber", "value", lxdb));
}
list.add(Map.of("label", "请假人数", "key", "leaveNumber", "value", dataMap.getInt("leaveNumber", 0)));
return list;
}
@Override
public List<NutMap> getSignInUser(String timePeriodId) {
Sql sql = Sqls.create("""
SELECT
tpu.userId,
u.loginname,
u.username,
u.sex,
u.unitname,
tpu.signInDateTime
FROM
`meeting_time_period_user` tpu
LEFT JOIN `user` u ON u.id = tpu.userId
WHERE
tpu.meetingTimePeriodId = @timePeriodId
AND tpu.isSignIn = 1
ORDER BY tpu.signInDateTime desc
""");
sql.setParam("timePeriodId", timePeriodId);
return listMap(sql);
}
}
@@ -0,0 +1,103 @@
package io.v.nutz.meeting.service.impl;
import io.v.nutz.meeting.models.MeetingType;
import io.v.nutz.meeting.service.MeetingCommonService;
import io.v.nutz.meeting.service.MeetingTypeService;
import io.v.nutz.modules.models.AuditState;
import io.v.nutz.modules.models.AuditStateUser;
import io.v.nutz.service.impl.ViServiceImpl;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import java.util.List;
@IocBean(args = {"refer:dao"})
public class MeetingTypeServiceImpl extends ViServiceImpl<MeetingType> implements MeetingTypeService {
@Inject
private MeetingCommonService meetingCommonService;
public MeetingTypeServiceImpl(Dao dao) {
super(dao);
}
@Override
public int findMaxStateId() {
return dao().func(AuditState.class, "max", "stateId");
}
/**
* 根据模块名称查找stateId
*
* @param moduleName
* @return
*/
private String[] findStateIdArray(String moduleName) {
//查询该类型原来关联的stateId
Sql stateSql = Sqls.create("select stateId from audit_state where module = @moduleName").setParam("moduleName", moduleName);
return (String[]) Daos.query(dao(), stateSql.toString(), Sqls.callback.strs());
}
/**
* 添加流程信息
*
* @param meetingType
*/
private void insertAuditInfo(MeetingType meetingType) {
List<AuditState> auditStateList = meetingType.getAuditStateList();
if (Lang.isNotEmpty(auditStateList)) {
for (int i = 0; i < auditStateList.size(); i++) {
AuditState state = auditStateList.get(i);
state.setModule(meetingType.getModuleName());
state.setMeetingTypeId(meetingType.getId());
dao().insertWith(state, "^auditStateUserList$");
}
}
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void add(MeetingType meetingType) {
dao().insert(meetingType);
insertAuditInfo(meetingType);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void edit(MeetingType meetingType) {
dao().update(meetingType);
//查询该类型原来关联的stateId
String[] stateIdStr = findStateIdArray(meetingType.getModuleName());
//删除原来审核状态下的审核人员
dao().clear(AuditStateUser.class, Cnd.where("stateId", "in", stateIdStr));
//删除原来的审核状态
dao().clear(AuditState.class, Cnd.where("stateId", "in", stateIdStr));
//添加新的审核流程
insertAuditInfo(meetingType);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void delete(MeetingType meetingType) {
//查询该类型原来关联的stateId
String[] stateIdStr = findStateIdArray(meetingType.getModuleName());
//删除原来审核状态下的审核人员
dao().clear(AuditStateUser.class, Cnd.where("stateId", "in", stateIdStr));
//删除原来的审核状态
dao().clear(AuditState.class, Cnd.where("stateId", "in", stateIdStr));
dao().delete(meetingType);
}
}
@@ -0,0 +1,30 @@
package io.v.nutz.meeting.ws;
import lombok.extern.slf4j.Slf4j;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.plugins.mvc.websocket.AbstractWsEndpoint;
import org.nutz.plugins.mvc.websocket.NutWsConfigurator;
import org.nutz.plugins.mvc.websocket.WsHandler;
import javax.websocket.EndpointConfig;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
@ServerEndpoint(value = "/websocket/meeting", configurator = NutWsConfigurator.class)
@IocBean
@Slf4j
public class MeetingWebsocket extends AbstractWsEndpoint {
@Inject
private Dao dao;
@Override
public WsHandler createHandler(Session session, EndpointConfig config) {
// 是的,返回你自己的实现类就可以了,需要每次新建哦
return new MeetingWsHandler(dao);
}
}
@@ -0,0 +1,58 @@
package io.v.nutz.meeting.ws;
import lombok.extern.slf4j.Slf4j;
import org.nutz.dao.Dao;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.Mvcs;
import org.nutz.plugins.mvc.websocket.handler.AbstractWsHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@Slf4j
public class MeetingWsHandler extends AbstractWsHandler {
private Dao dao;
public MeetingWsHandler(Dao dao) {
// 覆盖默认前缀
super("");
this.dao = dao;
}
@Override
public void init() {
// 必须调用超类的init,除非直接实现WsHandler接口
super.init();
if (this.httpSession != null) {
// 其他业务代码只需要从HttpSession取出wsid,即可调用AbstractWsEndpoint的api发送消息
this.httpSession.setAttribute("wsid", session.getId());
}
HttpServletRequest req = Mvcs.getReq();
log.debug("req={}", req);
}
/**
* 对应js端的action名称,方法参数必须是NutMap哦
* 通过endpoint可以发生给任何你想发生的对象, session就是当前WebSocket的会话.
*
* @param req
*/
public void getSignData(NutMap req) {
NutMap resp = NutMap.NEW();
resp.setv("?????", "?????????");
endpoint.sendJson(session.getId(), resp);
}
/**
* 这里不知道为什么拿不到httpsession
*
* @param httpSession
*/
@Override
public void setHttpSession(HttpSession httpSession) {
log.debug("http session = " + httpSession);
}
}
@@ -0,0 +1,203 @@
package io.v.nutz.modules.models;
import org.nutz.dao.entity.annotation.*;
import java.util.List;
@Table("audit_state")
public class AuditState {
@Column
@Id(
auto = false
)
@Comment("ID")
@ColDefine(
type = ColType.INT,
width = 8
)
private Integer stateId;
@Column
@Comment("状态名")
@ColDefine(
type = ColType.VARCHAR,
width = 50
)
private String stateName;
@Column
@Comment("强调色")
@ColDefine(
type = ColType.VARCHAR,
width = 20
)
private String stateColor;
@Column
@Comment("隶属(***模块)")
@ColDefine(
type = ColType.VARCHAR,
width = 50
)
private String module;
@Column
@Comment("下个审核节点代码")
@ColDefine(
type = ColType.INT,
width = 8
)
private Integer afterStateId;
@Column
@Comment("通过下个审核节点代码")
@ColDefine(
type = ColType.INT,
width = 8
)
private Integer afterPassStateId;
@Column
@Comment("拒绝后下个节点代码")
@ColDefine(
type = ColType.INT,
width = 8
)
private Integer afterRejectStateId;
@Column
@Comment("会议类型id 属于那个会议类型的流程")
@ColDefine(
type = ColType.INT
)
private Integer meetingTypeId;
@Column
@Comment("会议审核类型")
@ColDefine(
type = ColType.VARCHAR
)
private String auditAfterType;
@Column
@Comment("审核节点类型")
@ColDefine(
type = ColType.INT
)
private Integer stateAuditType;
@Column
@Comment("审核人员匹配条件")
@ColDefine(
type = ColType.VARCHAR
)
private String matchCnd;
@Many(
field = "stateId"
)
private List<AuditStateUser> auditStateUserList;
public AuditState() {
}
public Integer getStateId() {
return this.stateId;
}
public String getStateName() {
return this.stateName;
}
public String getStateColor() {
return this.stateColor;
}
public String getModule() {
return this.module;
}
public Integer getAfterStateId() {
return this.afterStateId;
}
public Integer getAfterPassStateId() {
return this.afterPassStateId;
}
public Integer getAfterRejectStateId() {
return this.afterRejectStateId;
}
public Integer getMeetingTypeId() {
return this.meetingTypeId;
}
public Integer getStateAuditType() {
return this.stateAuditType;
}
public String getMatchCnd() {
return this.matchCnd;
}
public List<AuditStateUser> getAuditStateUserList() {
return this.auditStateUserList;
}
public AuditState setStateId(Integer stateId) {
this.stateId = stateId;
return this;
}
public AuditState setStateName(String stateName) {
this.stateName = stateName;
return this;
}
public AuditState setStateColor(String stateColor) {
this.stateColor = stateColor;
return this;
}
public AuditState setModule(String module) {
this.module = module;
return this;
}
public AuditState setAfterStateId(Integer afterStateId) {
this.afterStateId = afterStateId;
return this;
}
public AuditState setAfterPassStateId(Integer afterPassStateId) {
this.afterPassStateId = afterPassStateId;
return this;
}
public AuditState setAfterRejectStateId(Integer afterRejectStateId) {
this.afterRejectStateId = afterRejectStateId;
return this;
}
public AuditState setMeetingTypeId(Integer meetingTypeId) {
this.meetingTypeId = meetingTypeId;
return this;
}
public AuditState setStateAuditType(Integer stateAuditType) {
this.stateAuditType = stateAuditType;
return this;
}
public String getAuditAfterType() {
return auditAfterType;
}
public void setAuditAfterType(String auditAfterType) {
this.auditAfterType = auditAfterType;
}
public AuditState setMatchCnd(String matchCnd) {
this.matchCnd = matchCnd;
return this;
}
public AuditState setAuditStateUserList(List<AuditStateUser> auditStateUserList) {
this.auditStateUserList = auditStateUserList;
return this;
}
}
@@ -309,7 +309,7 @@ public class MsgNotifyController {
RIGHT JOIN `user` u ON u.id = sur.userid RIGHT JOIN `user` u ON u.id = sur.userid
$condition $condition
"""); """);
if (module.equals(TAXT)) { if (module.equals(TAXT) || module.equals(JDHXT)) {
cnd.and("sur.jdhid", "=", teacherMeetingId); cnd.and("sur.jdhid", "=", teacherMeetingId);
} }
@@ -4,12 +4,13 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.page.Pagination;
import io.v.nutz.modules.models.PageForm; import io.v.nutz.modules.models.PageForm;
import io.v.nutz.question.service.QuestionAnswerRankingService;
import io.v.nutz.question.service.QuestionService; import io.v.nutz.question.service.QuestionService;
import io.v.nutz.sys.services.SysUnionService; import io.v.nutz.sys.services.SysUnionService;
import io.v.nutz.util.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
@@ -40,6 +41,9 @@ public class QuestionAnswerRankingController {
@Inject @Inject
private SysUnionService sysUnionService; private SysUnionService sysUnionService;
@Inject
private QuestionAnswerRankingService questionAnswerRankingService;
@At("") @At("")
@Ok("beetl:/platform/question/ranking.html") @Ok("beetl:/platform/question/ranking.html")
@RequiresPermissions("question.answer.ranking") @RequiresPermissions("question.answer.ranking")
@@ -49,96 +53,25 @@ public class QuestionAnswerRankingController {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("question.answer.ranking") @RequiresPermissions("question.answer.ranking")
public Object pageData(PageForm pageForm, @Param(value = "questionId",required = false) String questionId, public Object pageData(PageForm pageForm, @Param(value = "questionId", required = false) String questionId,
@Param(value = "unionId",required = false) String unionId, @Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId",required = false) String unitId, @Param(value = "unitId", required = false) String unitId,
@Param(value = "answerDate",required = false) String answerDate) { @Param(value = "answerDate", required = false) String answerDate) {
Sql sql = Sqls.create(""" Pagination pagination = questionAnswerRankingService.pageData(pageForm, questionId, unionId, unitId, answerDate);
SELECT return pagination;
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) as answerDate,
MAX( score ) AS max_score,
qus.answerNum,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile
FROM
question_user_score qus
LEFT JOIN `user` u ON u.id = qus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.groupBy("qus.userId", "qus.answerDate");
cnd.desc("qus.userId").desc("max_score");
cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("qus.answerDate", "=", answerDate);
cnd.and("qus.questionId", "=", questionId);
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
cnd.and(Cnd.exps("u.loginname", "like", "%" + pageForm.getSearchKeyword() + "%").or("u.username", "like", "%" + pageForm.getSearchKeyword() + "%"));
}
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
sql.setCondition(cnd);
return questionService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
} }
@At @At
@Ok("void") @Ok("void")
@RequiresPermissions("question.answer.ranking") @RequiresPermissions("question.answer.ranking")
public void doExport(@Param(value = "questionId",required = false) String questionId, public void doExport(@Param(value = "questionId", required = false) String questionId,
@Param(value = "unionId",required = false) String unionId, @Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId",required = false) String unitId, @Param(value = "unitId", required = false) String unitId,
@Param(value = "answerDate",required = false) String answerDate, HttpServletResponse response) { @Param(value = "answerDate", required = false) String answerDate, HttpServletResponse response) {
try { try {
Sql sql = Sqls.create("""
SELECT
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) as answerDate,
MAX( score ) AS max_score,
qus.answerNum,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile
FROM
question_user_score qus
LEFT JOIN `user` u ON u.id = qus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.groupBy("qus.userId", "qus.answerDate");
cnd.desc("qus.userId").desc("max_score");
cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("qus.answerDate", "=", answerDate);
cnd.and("qus.questionId", "=", questionId);
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
sql.setCondition(cnd);
List<NutMap> dataList = questionService.listMap(sql);
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
exportEntities.add(new ExcelExportEntity("所属单位", "unitname", 20));
exportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20));
exportEntities.add(new ExcelExportEntity("联系方式", "mobile", 20));
exportEntities.add(new ExcelExportEntity("分数", "max_score", 20));
exportEntities.add(new ExcelExportEntity("答题日期", "answerDate", 20));
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + new String(("得分名单.xlsx").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)); response.setHeader("Content-Disposition", "attachment;filename=" + new String(("得分名单.xlsx").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
ExportParams exportParams = new ExportParams(); questionAnswerRankingService.exportXlsx(questionId, response.getOutputStream());
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, dataList);
workbook.write(response.getOutputStream());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -147,7 +80,7 @@ public class QuestionAnswerRankingController {
@At @At
@Ok("void") @Ok("void")
@RequiresPermissions("question.answer.ranking") @RequiresPermissions("question.answer.ranking")
public void doExportAll(@Param(value = "questionId",required = false) String questionId, HttpServletResponse response) { public void doExportAll(@Param(value = "questionId", required = false) String questionId, HttpServletResponse response) {
try { try {
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
@@ -1,156 +0,0 @@
package io.v.nutz.question.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 io.v.nutz.annontation.ViReturn;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.question.model.Question;
import io.v.nutz.question.model.QuestionWinner;
import io.v.nutz.question.service.QuestionService;
import io.v.nutz.util.ViTool;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@At("/platform/question/answer/statistics")
@IocBean
@Ok("json:full")
public class QuestionAnswerStatisticsController {
@Inject
private QuestionService questionService;
@At("")
@Ok("beetl:/platform/question/statistics.html")
@RequiresPermissions("question.answer.statistics")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("question.answer.statistics")
public Object pageData(PageForm pageForm, @Param(value = "questionId", required = false) String questionId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId", required = false) String unitId) {
Sql sql = Sqls.create("""
SELECT
qus.userId,
MAX( qus.score ) AS max_score,
u.username,
u.loginname,
u.unitname,
u.unionname,
u.sex,
u.mobile
FROM
question_user_score qus
LEFT JOIN `user` u ON u.id = qus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.groupBy("qus.userId");
cnd.and("qus.questionId", "=", questionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("u.unionid", "=", unionId);
sql.setCondition(cnd);
return questionService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("question.answer.statistics")
public Object doRaffle(String questionId) {
questionService.dao().clear(QuestionWinner.class, Cnd.where("questionId", "=", questionId));
Question question = questionService.fetch(questionId);
Integer raffleScore = question.getRaffleScore();
Integer raffleWinnerUserNum = question.getRaffleWinnerUserNum();
Sql sql = Sqls.create("SELECT userId FROM `question_user_score` where score >= @score order by RAND() limit @num");
sql.setParam("score", raffleScore);
sql.setParam("num", raffleWinnerUserNum);
List<NutMap> list = questionService.listMap(sql);
List<String> userIds = list.stream().map(v -> v.getString("userId")).collect(Collectors.toList());
List<QuestionWinner> winners = new ArrayList<>();
for (String userId : userIds) {
QuestionWinner questionWinner = new QuestionWinner();
questionWinner.setQuestionId(questionId);
questionWinner.setUserId(userId);
winners.add(questionWinner);
}
questionService.dao().insert(winners);
return null;
}
@At
@Ok("void")
@RequiresPermissions("question.answer.statistics")
public void export(@Param(value = "questionId", required = false) String questionId,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId", required = false) String unitId,
HttpServletResponse response) {
Sql sql = Sqls.create("""
SELECT
qus.userId,
MAX( qus.score ) AS max_score,
u.username,
u.loginname,
u.unitname,
u.unionname,
u.sex,
u.mobile
FROM
question_user_score qus
LEFT JOIN `user` u ON u.id = qus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.groupBy("qus.userId");
cnd.and("qus.questionId", "=", questionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("u.unionid", "=", unionId);
sql.setCondition(cnd);
List<NutMap> list = questionService.listMap(sql);
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
exportEntities.add(new ExcelExportEntity("单位", "unitname", 20));
exportEntities.add(new ExcelExportEntity("分工会", "unionname", 20));
exportEntities.add(new ExcelExportEntity("得分", "max_score", 20));
try (ServletOutputStream outputStream = response.getOutputStream()) {
ViTool.excelResponse(response, "参加人员.xlsx");
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook work = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
work.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -51,10 +51,10 @@ public class QuestionAnswerWinnerController {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("question.answer.winners") @RequiresPermissions("question.answer.winners")
public Object pageData(PageForm pageForm, @Param(value = "questionId", required = false) String questionId, public Object pageData(PageForm pageForm, @Param(value = "questionId",required = false) String questionId,
@Param(value = "unionId", required = false) String unionId, @Param(value = "unionId",required = false) String unionId,
@Param(value = "unitId", required = false) String unitId, @Param(value = "unitId",required = false) String unitId,
@Param(value = "winDate", required = false) String winDate) { @Param(value = "winDate",required = false) String winDate) {
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
u.loginname, u.loginname,
@@ -63,15 +63,13 @@ public class QuestionAnswerWinnerController {
u.unitname, u.unitname,
u.unionname, u.unionname,
u.mobile, u.mobile,
qus.score DATE_FORMAT( qw.winDate, '%Y-%m-%d' ) as winDate,
qw.score
FROM FROM
question_winner qw question_winner qw
LEFT JOIN `user` u ON u.id = qw.userId LEFT JOIN `user` u ON u.id = qw.userId
LEFT JOIN question_user_score qus on qus.userId = qw.userId and qus.questionId = @questionId
$condition $condition
"""); """);
sql.setParam("questionId", questionId);
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.andEX("u.unionid", "=", unionId); cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId); cnd.andEX("u.unitid", "=", unitId);
@@ -80,7 +78,6 @@ public class QuestionAnswerWinnerController {
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) { if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
cnd.and(Cnd.exps("u.loginname", "like", "%" + pageForm.getSearchKeyword() + "%").or("u.username", "like", "%" + pageForm.getSearchKeyword() + "%")); cnd.and(Cnd.exps("u.loginname", "like", "%" + pageForm.getSearchKeyword() + "%").or("u.username", "like", "%" + pageForm.getSearchKeyword() + "%"));
} }
cnd.groupBy("u.loginname");
cnd.desc("qw.winDate"); cnd.desc("qw.winDate");
sql.setCondition(cnd); sql.setCondition(cnd);
Pagination pagination = questionService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); Pagination pagination = questionService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
@@ -98,33 +95,31 @@ public class QuestionAnswerWinnerController {
@At @At
@Ok("void") @Ok("void")
@RequiresPermissions("question.answer.winners") @RequiresPermissions("question.answer.winners")
public void exportWinners(@Param(value = "questionId", required = false) String questionId, public void exportWinners(@Param(value = "questionId",required = false) String questionId,
@Param(value = "unionId", required = false) String unionId, @Param(value = "unionId",required = false) String unionId,
@Param(value = "unitId", required = false) String unitId, @Param(value = "unitId",required = false) String unitId,
@Param(value = "winDate", required = false) String winDate, HttpServletResponse response) { @Param(value = "winDate",required = false) String winDate, HttpServletResponse response) {
try { try {
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
u.loginname, u.loginname,
u.username, u.username,
u.sex, u.sex,
u.unitname, u.unitname,
u.unionname, u.unionname,
qus.score u.mobile,
DATE_FORMAT( qw.winDate, '%Y-%m-%d' ) as winDate,
qw.score
FROM FROM
question_winner qw question_winner qw
LEFT JOIN `user` u ON u.id = qw.userId LEFT JOIN `user` u ON u.id = qw.userId
LEFT JOIN question_user_score qus on qus.userId = qw.userId and qus.questionId = @questionId $condition
$condition """);
""");
sql.setParam("questionId", questionId);
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.andEX("u.unionid", "=", unionId); cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId); cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("qw.winDate", "=", winDate); cnd.andEX("qw.winDate", "=", winDate);
cnd.and("qw.questionId", "=", questionId); cnd.and("qw.questionId", "=", questionId);
cnd.groupBy("u.loginname");
cnd.desc("qw.winDate"); cnd.desc("qw.winDate");
sql.setCondition(cnd); sql.setCondition(cnd);
List<NutMap> dataList = questionService.listMap(sql); List<NutMap> dataList = questionService.listMap(sql);
@@ -136,9 +131,8 @@ public class QuestionAnswerWinnerController {
exportEntities.add(new ExcelExportEntity("所属单位", "unitname", 20)); exportEntities.add(new ExcelExportEntity("所属单位", "unitname", 20));
exportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20)); exportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20));
exportEntities.add(new ExcelExportEntity("联系方式", "mobile", 20)); exportEntities.add(new ExcelExportEntity("联系方式", "mobile", 20));
exportEntities.add(new ExcelExportEntity("得分", "score", 20)); exportEntities.add(new ExcelExportEntity("中奖日期", "winDate", 20));
// exportEntities.add(new ExcelExportEntity("中奖日期", "winDate", 20)); exportEntities.add(new ExcelExportEntity("抽奖分数", "score", 20));
// exportEntities.add(new ExcelExportEntity("抽奖分数(最高分)", "maxScore", 20));
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + new String(("中奖名单.xlsx").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)); response.setHeader("Content-Disposition", "attachment;filename=" + new String(("中奖名单.xlsx").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
@@ -154,7 +148,7 @@ public class QuestionAnswerWinnerController {
@At @At
@RequiresPermissions("question.answer.winners") @RequiresPermissions("question.answer.winners")
public Object getQuestion(Integer year) { public Object getQuestion(Integer year) {
List<Question> list = questionService.query(Cnd.NEW().andEX("YEAR(qctime)", "=", year).and("qlx", "=", 2).and("isRaffle", "=", 1)); List<Question> list = questionService.query(Cnd.NEW().andEX("YEAR(qctime)", "=", year).and("qlx", "=", 2).and("isRaffle","=",1));
return Result.success(list); return Result.success(list);
} }
@@ -46,6 +46,23 @@ public class QuestionCakeController {
un.unionName, un.unionName,
(select count(1) from user where member = 1 and unionid = un.id) AS teacherSum, (select count(1) from user where member = 1 and unionid = un.id) AS teacherSum,
( (
select
count(1)
from
activity_user_scope aus
left join "user" u on u.id = aus.userId
where
groupId in (
select
activityUserScopeId
from
question
where
qid = @questionId
)
and u.unionId = un.id
) as teacherSum,
(
SELECT SELECT
count( DISTINCT r.userId ) count( DISTINCT r.userId )
FROM FROM
@@ -1,5 +1,6 @@
package io.v.nutz.question.controller; package io.v.nutz.question.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.wizzer.framework.base.Result; import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination; import cn.wizzer.framework.page.Pagination;
@@ -8,7 +9,7 @@ import io.v.nutz.modules.models.PageForm;
import io.v.nutz.question.model.*; import io.v.nutz.question.model.*;
import io.v.nutz.question.service.QuestionService; import io.v.nutz.question.service.QuestionService;
import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import org.nutz.dao.Chain; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.dao.Sqls; import org.nutz.dao.Sqls;
@@ -23,8 +24,10 @@ import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param; import org.nutz.mvc.annotation.Param;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import java.util.*; import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReference; import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -46,6 +49,7 @@ public class QuestionH5Controller {
@At("/list") @At("/list")
@Ok("beetl:/mobile/question/list.html") @Ok("beetl:/mobile/question/list.html")
@RequiresAuthentication
public void list() { public void list() {
} }
@@ -70,16 +74,11 @@ public class QuestionH5Controller {
@At("/answer/index") @At("/answer/index")
@Ok("beetl:/mobile/question/answer.html") @Ok("beetl:/mobile/question/answer.html")
@RequiresAuthentication
public void answerIndex() { public void answerIndex() {
} }
@At("/answer/index_ctgu")
@Ok("beetl:/mobile/question/answer_ctgu.html")
public void answerIndex2() {
}
/** /**
* 页面数据 * 页面数据
@@ -94,12 +93,13 @@ public class QuestionH5Controller {
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
select select
q.*, q.*,
(select count(1) from question_issue where iqid = q.qid) as topicTotal (select count(1) from question_issue where iqid = q.qid) as topicTotal ,
(select count(1) from question_winner where questionId = q.qid) as zjTotal
from from
question q question q
$condition $condition
"""); """);
// sql.setParam("today", DateUtil.today()); sql.setParam("today", DateUtil.today());
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (status == 1) { if (status == 1) {
@@ -133,171 +133,203 @@ public class QuestionH5Controller {
/** /**
* 问卷信息 * 问卷信息
* *
* @param id id * @param id id
* @param currentDate 日期
* @param randomCount 轮数
* @return {@link Object} * @return {@link Object}
*/ */
@At("/questionInfo/{id}") @At("/questionInfo/{id}")
public Object questionInfo(@PathVariable String id) { public Object questionInfo(@PathVariable String id,
@Param(required = false, value = "currentDate") String currentDate,
@Param(required = false, value = "randomCount") Integer randomCount) {
Question question = questionService.fetch(id); Question question = questionService.fetch(id);
Cnd issueCnd = Cnd.NEW(); Cnd issueCnd = Cnd.NEW();
//出题模式
// mode==1 定时定题 直接查询
// mode==2 先查询今天的随机题目有没有设置好 设置好了直接查询今天的题目 没有的话查询displayDate为null的题目然后取题目再设置时间进行查询
Integer ctMode = question.getCtMode(); Integer ctMode = question.getCtMode();
if (ctMode == 2) {
//单次出题的数量 if (ctMode == 1) {
Integer ctNum = question.getCtNum(); //定时定题
int todayIssueCount = dao.count(Question_issue.class, Cnd.where("displayDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd"))
.and("iqid", "=", id)); //判断传入的日期是否已经加入到表里
if (todayIssueCount == 0) { QuestionRandomIssue randomIssue = dao.fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", question.getQid()).and("userId", "=", ShiroUtil.getUserId())
Sql randIssueSql = Sqls.create("SELECT iid FROM question_issue WHERE iqid = @qid AND displayDate IS NULL ORDER BY RAND() LIMIT @ctNum"); .and("displayDate", "=", currentDate));
randIssueSql.setParam("qid", id); if (Lang.isEmpty(randomIssue)) {
randIssueSql.setParam("ctNum", ctNum); Sql issueSql = Sqls.queryString(" SELECT iid FROM `question_issue` where iqid = @qid AND displayDate = @displayDate");
String[] randIssueIds = (String[]) Daos.query(dao, randIssueSql.toString(), Sqls.callback.strs()); issueSql.setParam("qid", id);
dao.update(Question_issue.class, Chain.make("displayDate", new Date()), Cnd.where("iid", "in", randIssueIds)); issueSql.setParam("displayDate", currentDate);
dao.execute(issueSql);
String[] randomIssueIds = (String[]) issueSql.getResult();
QuestionRandomIssue questionRandomIssue = new QuestionRandomIssue();
questionRandomIssue.setQuestionId(id);
questionRandomIssue.setUserId(ShiroUtil.getUserId());
questionRandomIssue.setIssueIds(Arrays.asList(randomIssueIds));
questionRandomIssue.setNum(null);
questionRandomIssue.setIsFinish(false);
questionRandomIssue.setDisplayDate(DateUtil.parseDate(currentDate));
dao.insert(questionRandomIssue);
issueCnd.and("iid", "in", randomIssueIds);
} else {
issueCnd.and("iid", "in", randomIssue.getIssueIds());
}
} else if (ctMode == 2) {
//随机模式
//判断是否为一天答题
DateTime startTime = DateUtil.date(question.getStartTime());
DateTime endTime = DateUtil.date(question.getEndTime());
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
//每次随机的题目数量
Integer ranDomSingleIssueNum = question.getRanDomSingleIssueNum();
//总共随机几次
Integer ranDomSum = question.getRanDomSum();
if (betweenDay == 0) {
//同一天 一天随机多次
if (randomCount != null) {
QuestionRandomIssue randomIssues = dao.fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", question.getQid()).and("userId", "=", ShiroUtil.getUserId()).and("num", "=", randomCount));
issueCnd.andEX("iid", "in", randomIssues.getIssueIds());
} else {
//用户的随机题目
List<QuestionRandomIssue> randomIssues = dao.query(QuestionRandomIssue.class, Cnd.where("questionId", "=", question.getQid()).and("userId", "=", ShiroUtil.getUserId()));
//查询已经随机但是并没有答题完成的题目
List<String> notFinishIssueIds = randomIssues.stream().filter(v -> v.getIsFinish() != null && !v.getIsFinish()).findFirst().map(QuestionRandomIssue::getIssueIds).orElseGet(Collections::emptyList);
if (Lang.isNotEmpty(notFinishIssueIds)) {
//就查询没答完的题目
issueCnd.and("iid", "in", notFinishIssueIds);
} else {
//进行下一次随机 然后加入到随机题目表里
//已经答了的题目
List<String> hasAnswerIssueIds = randomIssues.stream().flatMap(v -> v.getIssueIds().stream()).collect(Collectors.toList());
//已经随机几次了
int maxAnswerNum = randomIssues.stream().mapToInt(QuestionRandomIssue::getNum).max().orElse(0);
Sql issueSql = null;
if (maxAnswerNum == ranDomSum) {
//随机完了 没有题目了 默认去最后一轮
// issueCnd.andEX("iid", "in", hasAnswerIssueIds);
List<String> lastRanDomIssueIds = randomIssues.stream().filter(v -> v.getNum() == maxAnswerNum).flatMap(v -> v.getIssueIds().stream()).collect(Collectors.toList());
issueCnd.andEX("iid", "in", lastRanDomIssueIds);
} else {
if (maxAnswerNum == 0) {
//从没有随即过
issueSql = Sqls.queryString(" SELECT iid FROM `question_issue` where iqid = @qid ORDER BY RAND() LIMIT @num");
} else {
//之前随机过
issueSql = Sqls.queryString(" SELECT iid FROM `question_issue` where iqid = @qid and iid not in (@issueIds) ORDER BY RAND() LIMIT @num");
issueSql.setParam("issueIds", hasAnswerIssueIds);
}
issueSql.setParam("qid", id);
issueSql.setParam("num", ranDomSingleIssueNum);
dao.execute(issueSql);
String[] randomIssueIds = (String[]) issueSql.getResult();
if (Lang.isNotEmpty(randomIssueIds)) {
QuestionRandomIssue questionRandomIssue = new QuestionRandomIssue();
questionRandomIssue.setQuestionId(id);
questionRandomIssue.setUserId(ShiroUtil.getUserId());
questionRandomIssue.setIssueIds(Arrays.asList(randomIssueIds));
questionRandomIssue.setNum(maxAnswerNum + 1);
questionRandomIssue.setIsFinish(false);
questionRandomIssue.setDisplayDate(DateUtil.parseDate(DateUtil.today()));
dao.insert(questionRandomIssue);
}
//获取本次的随机题目
issueCnd.andEX("iid", "in", randomIssueIds);
}
}
}
} else {
//不是一天 那就一天随机一次
//用户的随机题目记录
List<QuestionRandomIssue> randomIssues = dao.query(QuestionRandomIssue.class, Cnd.where("questionId", "=", question.getQid()).and("userId", "=", ShiroUtil.getUserId()));
//已经随机的题目
List<String> hasRanDomIssueIds = randomIssues.stream().flatMap(v -> v.getIssueIds().stream()).collect(Collectors.toList());
//判断传入的日期是否已经加入到表里
QuestionRandomIssue currentDateRandomIssue = dao.fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", question.getQid()).and("userId", "=", ShiroUtil.getUserId())
.and("displayDate", "=", currentDate));
if (Lang.isEmpty(currentDateRandomIssue)) {
Sql issueSql = null;
if (Lang.isEmpty(hasRanDomIssueIds)) {
issueSql = Sqls.queryString(" SELECT iid FROM `question_issue` where iqid = @qid ORDER BY RAND() LIMIT @num");
} else {
//之前随机过
issueSql = Sqls.queryString(" SELECT iid FROM `question_issue` where iqid = @qid and iid not in (@issueIds) ORDER BY RAND() LIMIT @num");
issueSql.setParam("issueIds", hasRanDomIssueIds);
}
issueSql.setParam("num", ranDomSingleIssueNum);
issueSql.setParam("qid", id);
dao.execute(issueSql);
String[] randomIssueIds = (String[]) issueSql.getResult();
QuestionRandomIssue questionRandomIssue = new QuestionRandomIssue();
questionRandomIssue.setQuestionId(id);
questionRandomIssue.setUserId(ShiroUtil.getUserId());
questionRandomIssue.setIssueIds(Arrays.asList(randomIssueIds));
questionRandomIssue.setNum(null);
questionRandomIssue.setIsFinish(false);
questionRandomIssue.setDisplayDate(DateUtil.parseDate(currentDate));
dao.insert(questionRandomIssue);
issueCnd.and("iid", "in", randomIssueIds);
} else {
issueCnd.and("iid", "in", currentDateRandomIssue.getIssueIds());
}
}
} else if (ctMode == 3) {
//常规模式
//判断是否将题目加进去了
QuestionRandomIssue randomIssue = dao.fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", question.getQid()).and("userId", "=", ShiroUtil.getUserId()));
if (Lang.isEmpty(randomIssue)) {
Sql issueSql = Sqls.create(" SELECT iid FROM `question_issue` where iqid = @qid");
issueSql.setParam("qid", id);
issueSql.setCallback(Sqls.callback.strList());
dao.execute(issueSql);
List<String> randomIssueIds = (List<String>) issueSql.getResult();
Collections.shuffle(randomIssueIds);
QuestionRandomIssue questionRandomIssue = new QuestionRandomIssue();
questionRandomIssue.setQuestionId(id);
questionRandomIssue.setUserId(ShiroUtil.getUserId());
questionRandomIssue.setIssueIds(randomIssueIds);
questionRandomIssue.setNum(null);
questionRandomIssue.setIsFinish(false);
dao.insert(questionRandomIssue);
issueCnd.and("iid", "in", randomIssueIds);
} else {
issueCnd.and("iid", "in", randomIssue.getIssueIds());
} }
// issueCnd.and("displayDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd"));
} }
issueCnd.asc("ipxbh"); // issueCnd.asc("ipxbh");
questionService.fetchLinks(question, "issues", issueCnd); questionService.fetchLinks(question, "issues", issueCnd);
for (Question_issue issue : question.getIssues()) { for (Question_issue issue : question.getIssues()) {
questionService.fetchLinks(issue, "wors", Cnd.NEW().asc("wpxbh")); questionService.fetchLinks(issue, "wors", Cnd.NEW().asc("wpxbh"));
} }
if (question.getDisruptingOrder()) {
Collections.shuffle(question.getIssues());
}
return Result.success(question); return Result.success(question);
} }
/** /**
* 保存答案 * 保存答案
* *
* @param repliesArray 回复 * @param repliesArray 答复记录
* @param questionId 问卷ID
* @param isSave 是否保存
* @return {@link Object} * @return {@link Object}
*/ */
@At("/saveAnswer") @At("/saveAnswer")
public Object saveAnswer(@Param("repliesArray") Question_reply[] repliesArray) { public Object saveAnswer(@Param("replies") Question_reply[] repliesArray, String questionId, Boolean isSave) {
if (Lang.isNotEmpty(repliesArray)) { questionService.saveAnswer(repliesArray, questionId, isSave);
List<Question_reply> replies = Arrays.asList(repliesArray);
if (Lang.isNotEmpty(replies)) {
String qid = replies.get(0).getQid();
questionService.dao().clear(Question_reply.class, Cnd.where("qid", "=", qid).and("userId", "=", ShiroUtil.getPrincipalProperty("id")));
replies.forEach(v -> {
v.setUserId(String.valueOf(ShiroUtil.getPrincipalProperty("id")));
v.setRtime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
});
questionService.insert(replies);
}
return Result.success();
}
return Result.success(); return Result.success();
} }
/**
* 保存答案 只针对答题模式
*
* @param replies 问题回复
* @return {@link Object}
*/
@At("/saveAnswer2")
public Object saveAnswer2(Question_reply[] replies) {
if (Lang.isNotEmpty(replies)) {
Arrays.asList(replies).forEach(v -> {
v.setUserId(String.valueOf(ShiroUtil.getPrincipalProperty("id")));
v.setRtime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
});
questionService.insert(replies);
insertQuestionAnswerScore(Arrays.asList(replies));
insertQuestionAnswerScore2(Arrays.asList(replies));
}
return Result.success();
}
public void insertQuestionAnswerScore(List<Question_reply> replyList) {
//用户id
String userId = (String) ShiroUtil.getPrincipalProperty("id");
//问卷id
String questionId = replyList.get(0).getQid();
//题目id
String issueId = replyList.get(0).getIssueId();
Question_issue issue = dao.fetch(Question_issue.class, Cnd.where("iid", "=", issueId));
Float fraction = issue.getFraction();
Sql sql = Sqls.create("""
SELECT wid FROM question_wor qw WHERE qw.correct = 1 AND qw.wiid = @wiid
""").setParam("wiid", issueId);
//正确的选项
Set<String> correctOptionIdList = new HashSet<>((List<String>) Daos.query(dao, sql.toString(), Sqls.callback.strList()));
//用户选的选项
Set<String> userSelectedOptionIdList = replyList.stream().map(v -> v.getRwid()).collect(Collectors.toSet());
int count = dao.count(QuestionAnswerUserScore.class, Cnd.where("questionId", "=", questionId).and("subjectId", "=", issueId).and("answerDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd")).and("userId", "=", userId));
QuestionAnswerUserScore answerUserScore = new QuestionAnswerUserScore();
answerUserScore.setQuestionId(questionId);
answerUserScore.setSubjectId(issueId);
answerUserScore.setUserId(userId);
answerUserScore.setAnswerDate(new Date());
answerUserScore.setAnswerNum(count + 1);
if (correctOptionIdList.equals(userSelectedOptionIdList)) {
answerUserScore.setSubjectScore(fraction);
} else {
answerUserScore.setSubjectScore(0f);
}
dao.insert(answerUserScore);
}
public void insertQuestionAnswerScore2(List<Question_reply> replyList) {
//问卷id
String questionId = replyList.get(0).getQid();
//查询今天的题目
List<Question_issue> todayIssues = dao.query(Question_issue.class, Cnd.where("displayDate", "=", DateUtil.today())
.and("iqid", "=", questionId));
if (todayIssues != null && todayIssues.size() > 0) {
Set<String> todayIssueIds = todayIssues.stream().map(v -> v.getIid()).collect(Collectors.toSet());
//判断今天的题目是否已答完
List<Question_reply> replyIssues = dao.query(Question_reply.class, Cnd.where("userId", "=", ShiroUtil.getPrincipalProperty("id")).and("qid", "=", questionId));
Set<String> replyIssueIds = replyIssues.stream().map(v -> v.getIssueId()).collect(Collectors.toSet());
if (todayIssueIds.equals(replyIssueIds)) {
//答完了 去看看今天有没有答过
int count = dao.count(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getPrincipalProperty("id")).and("answerDate", "=", DateUtil.today()));
// AtomicInteger sum = new AtomicInteger();
AtomicReference<Float> sum = new AtomicReference<>(0f);
//每题的回答记录
Map<String, List<Question_reply>> issueReplies = replyIssues.stream().collect(Collectors.groupingBy(v -> v.getIssueId()));
//查出选项信息
dao.fetchLinks(todayIssues, "wors");
issueReplies.forEach((k, v) -> {
//用户回答的选项
Set<String> userReplyOptionIds = v.stream().map(x -> x.getRwid()).collect(Collectors.toSet());
Optional<Question_issue> issueOptional = todayIssues.stream().filter(x -> x.getIid().equals(k)).findFirst();
//正确答案
Set<String> correctOptionIds = issueOptional.map(x -> x.getWors().stream().filter(c -> c.getCorrect() != null && c.getCorrect()).map(z -> z.getWid()).collect(Collectors.toSet())).orElse(null);
if (userReplyOptionIds.equals(correctOptionIds)) {
// sum.addAndGet(issueOptional.map(i -> i.getFraction()).orElse(0f));
sum.updateAndGet(v1 -> v1 + issueOptional.map(i -> i.getFraction()).orElse(0f));
}
});
QuestionUserScore questionUserScore = new QuestionUserScore();
questionUserScore.setQuestionId(questionId);
questionUserScore.setUserId((String) ShiroUtil.getPrincipalProperty("id"));
questionUserScore.setAnswerDate(new Date());
questionUserScore.setAnswerNum(count + 1);
questionUserScore.setScore(sum.get());
dao.insert(questionUserScore);
}
}
}
/** /**
* 答题信息 * 答题信息
@@ -306,8 +338,25 @@ public class QuestionH5Controller {
* @return {@link Object} * @return {@link Object}
*/ */
@At("/answerInfo/?") @At("/answerInfo/?")
public Object answerInfo(String id) { public Object answerInfo(String id,
List<Question_reply> replies = questionService.dao().query(Question_reply.class, Cnd.where("qid", "=", id).and("userId", "=", ShiroUtil.getPrincipalProperty("id"))); @Param(required = false, value = "currentDate") String currentDate,
@Param(required = false, value = "randomCount") Integer randomCount) {
Cnd cnd = Cnd.where("qid", "=", id).and("userId", "=", ShiroUtil.getPrincipalProperty("id"));
Question question = dao.fetch(Question.class, id);
if (question.getCtMode() == 1) {
cnd.and("DATE(rtime)", "=", currentDate);
} else if (question.getCtMode() == 2) {
if (questionService.isSameDay(question.getStartTime(), question.getEndTime())) {
} else {
cnd.and("DATE(rtime)", "=", currentDate);
}
} else if (question.getCtMode() == 3) {
}
List<Question_reply> replies = questionService.dao().query(Question_reply.class, cnd);
return Result.success(replies); return Result.success(replies);
} }
@@ -346,74 +395,156 @@ public class QuestionH5Controller {
return Result.success(list); return Result.success(list);
} }
@At("/canAnswer") /**
public Object canAnswer(String questionId) { * 判断用户是否答完
*
* @param questionId 问卷ID
* @return
*/
@At
public Object checkUserFinishAnswer(String questionId,
@Param(required = false, value = "currentDate") String currentDate,
@Param(required = false, value = "randomCount") Integer randomCount) {
Question question = dao.fetch(Question.class, questionId);
if (question.getCtMode() == 3) {
QuestionRandomIssue randomIssue = dao.fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
return Result.success(randomIssue.getIsFinish());
} else if (question.getCtMode() == 2) {
//判断是否为一天答题
DateTime startTime = DateUtil.date(question.getStartTime());
DateTime endTime = DateUtil.date(question.getEndTime());
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
if (betweenDay == 0) {
//同一天
if (randomCount != null) {
QuestionRandomIssue randomIssue = dao.fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("num", "=", randomCount));
return Result.success(randomIssue.getIsFinish());
}
return Result.success(false);
} else {
//不是同一天 判断今天是否答完就行了
QuestionRandomIssue randomIssue = dao.fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("displayDate", "=", DateUtil.today()));
//时间过了
if (DateUtil.parseDate(currentDate).isBefore(DateUtil.parseDate(DateUtil.today()))) {
return Result.success(true);
}
return Result.success(randomIssue.getIsFinish());
}
} else if (question.getCtMode() == 1) {
QuestionRandomIssue randomIssue = dao.fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("displayDate", "=", currentDate));
//时间过了
if (DateUtil.parseDate(currentDate).isBefore(DateUtil.parseDate(DateUtil.today()))) {
return Result.success(true);
}
return Result.success(randomIssue.getIsFinish());
}
return Result.success(false);
}
@At
public Object checkCanAnswerAgain(String questionId,
@Param(required = false, value = "currentDate") String currentDate,
@Param(required = false, value = "randomCount") Integer randomCount) {
Question question = dao.fetch(Question.class, questionId);
if (question.getCanRepeatedAnswer()) {
//0次则不限制
if (question.getCanRepeatedAnswerNum() == 0) {
return Result.success(true);
}
if (question.getCtMode() == 3) {
int count = dao.count(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
return Result.success(count < question.getCanRepeatedAnswerNum());
} else if (question.getCtMode() == 2) {
//判断是否为一天答题
DateTime startTime = DateUtil.date(question.getStartTime());
DateTime endTime = DateUtil.date(question.getEndTime());
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
if (betweenDay == 0) {
return Result.success(false);
} else {
int count = dao.count(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("answerDate", "=", DateUtil.today()));
return Result.success(count < question.getCanRepeatedAnswerNum());
}
} else if (question.getCtMode() == 1) {
int count = dao.count(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("answerDate", "=", currentDate));
//时间过了
if (Lang.isNotEmpty(currentDate) && DateUtil.parseDate(currentDate).isBefore(DateUtil.parseDate(DateUtil.today()))) {
return Result.success(false);
}
return Result.success(count < question.getCanRepeatedAnswerNum());
}
}
return Result.success(false);
}
/**
* 获取得分
*
* @param questionId
* @param currentDate
* @param randomCount
* @return
*/
@At
public Object getScore(String questionId,
@Param(required = false, value = "currentDate") String currentDate,
@Param(required = false, value = "randomCount") Integer randomCount) {
Question question = dao.fetch(Question.class, questionId); Question question = dao.fetch(Question.class, questionId);
//每天的题目数量 if (question.getCtMode() == 1) {
int issueCount = dao.count(Question_issue.class, Cnd.where("iqid", "=", questionId).and("displayDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd"))); QuestionUserScore userScore = dao.fetch(QuestionUserScore.class, Cnd.where("questionId", "=", questionId)
.and("userId", "=", ShiroUtil.getUserId())
.and("displayDate", "=", currentDate)
.desc(question.getCalcScoreMode() == 1 ? "score" : "answerNum"));
return Result.success().addData(Optional.ofNullable(userScore).map(v -> v.getScore()).orElse(0));
} else if (question.getCtMode() == 2) {
DateTime startTime = DateUtil.date(question.getStartTime());
DateTime endTime = DateUtil.date(question.getEndTime());
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
//当前最大答题次数 if (betweenDay == 0) {
int maxCount = dao.func(QuestionAnswerUserScore.class, "max", "answerNum", Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getPrincipalProperty("id"))); QuestionUserScore userScore = dao.fetch(QuestionUserScore.class, Cnd.where("questionId", "=", questionId)
.and("userId", "=", ShiroUtil.getUserId())
//最大答题次数已经答了多少题 // .and("displayDate", "=", currentDate)
int answerIssue = dao.count(QuestionAnswerUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getPrincipalProperty("id")).and("answerNum", "=", maxCount)); .and("answerNum", "=", randomCount)
.desc("answerNum"));
//今天的题目已经答了几次 return Result.success().addData(Optional.ofNullable(userScore).map(v -> v.getScore()).orElse(0));
int todayMaxCount = dao.func(QuestionAnswerUserScore.class, "max", "answerNum", } else {
Cnd.where("questionId", "=", questionId) QuestionUserScore userScore = dao.fetch(QuestionUserScore.class, Cnd.where("questionId", "=", questionId)
.and("userId", "=", ShiroUtil.getPrincipalProperty("id")) .and("userId", "=", ShiroUtil.getUserId())
.and("answerDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd")) .and("displayDate", "=", currentDate)
); .desc(question.getCalcScoreMode() == 1 ? "score" : "answerNum"));
return Result.success().addData(Optional.ofNullable(userScore).map(v -> v.getScore()).orElse(0));
}
} else if (question.getCtMode() == 3) {
QuestionUserScore userScore = dao.fetch(QuestionUserScore.class, Cnd.where("questionId", "=", questionId)
if (question.getAnswerTotalSum() != 0 && maxCount < question.getAnswerTotalSum()) { .and("userId", "=", ShiroUtil.getUserId())
//今天的题目需要全部答完 .desc(question.getCalcScoreMode() == 1 ? "score" : "answerNum"));
return Result.success().addData(Optional.ofNullable(userScore).map(v -> v.getScore()).orElse(0));
// //今天所有的题目
// int todayAllIssues = dao.count(Question_issue.class, Cnd.where("iqid", "=", questionId).and("displayDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd")));
// //今天已经答了的题目
// int todayHasAnswerIssues = dao.count(QuestionAnswerUserScore.class, Cnd.where("questionId", "=", questionId)
// .and("userId", "=", ShiroUtil.getPrincipalProperty("id"))
// .and("answerDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd"))
// .and("answerNum", "=", todayMaxCount)
//
// );
return Result.success(true);
} }
return Result.success();
if (question.getQrkdcs() != 0 && question.getQrkdcs() > todayMaxCount) {
return Result.success(true);
}
if (answerIssue < issueCount) {
return Result.success(true);
}
return Result.success(false);
// return Result.success(answerIssue < issueCount || (question.getQrkdcs() > 0 && question.getQrkdcs() > todayMaxCount));
} }
@At("/todayMaxScore") /**
public Object todayMaxScore(String questionId) { * 获取用户已回答的轮数 针对单天随机
List<QuestionUserScore> userScores = dao.query(QuestionUserScore.class, Cnd.where("questionId", "=", questionId) *
.and("userId", "=", ShiroUtil.getPrincipalProperty("id")) * @param questionId 问卷ID
.and("answerDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd"))); * @return
*/
Map<Integer, Float> numScoreMap = userScores.stream().collect(Collectors.toMap(v -> v.getAnswerNum(), v -> v.getScore())); @At
public Object getUserHasAnswerRandomNum(String questionId) {
// List<QuestionAnswerUserScore> list = dao.query(QuestionAnswerUserScore.class, Cnd.where("questionId", "=", questionId) Question question = dao.fetch(Question.class, questionId);
// .and("userId", "=", ShiroUtil.getPrincipalProperty("id")) //判断是否为一天答题
// .and("answerDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd"))); DateTime startTime = DateUtil.date(question.getStartTime());
// DateTime endTime = DateUtil.date(question.getEndTime());
// Map<Integer, Integer> numScoreMap = list.stream().collect(Collectors.groupingBy(v -> v.getAnswerNum(), Collectors.summingInt(v -> v.getSubjectScore()))); long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
return Result.success(numScoreMap); if (question.getCtMode() == 2 && betweenDay == 0) {
int count = dao.count(QuestionRandomIssue.class, Cnd.where("questionId", "=", questionId)
.and("userId", "=", ShiroUtil.getUserId()));
return Result.success().addData(count);
}
return Result.success().addData(0);
} }
} }
@@ -1,273 +0,0 @@
package io.v.nutz.question.controller;
import cn.hutool.core.date.DateUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.question.model.*;
import io.v.nutz.question.service.QuestionService;
import io.v.nutz.util.ShiroUtil;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* 三峡答题
*
* @author jug
* @date 2023/10/20
*/
@IocBean
@At("/mobile/question/h5ctgu")
@Ok("json:full")
public class QuestionH5CtguController {
@Inject
private QuestionService questionService;
@Inject
private Dao dao;
@At("/score")
@Ok("beetl:/mobile/question/ctgu_answer/score.html")
public void score() {
}
@At("/answerSheet")
@Ok("beetl:/mobile/question/ctgu_answer/answerSheet.html")
public void answerSheet(){
}
/**
* 问卷信息
*
* @param id id
* @return {@link Object}
*/
@At("/questionInfo/{id}")
public Object questionInfo(@PathVariable String id) {
Question question = questionService.fetch(id);
dao.fetchLinks(question, "issues", Cnd.NEW().asc("ipxbh"));
for (Question_issue issue : question.getIssues()) {
questionService.fetchLinks(issue, "wors", Cnd.NEW().asc("wpxbh"));
}
// List<Question_issue> issues = question.getIssues();
// Collections.shuffle(issues.subList(0,issues.size()));
// Collections.shuffle(issues.subList(22,issues.size()));
return Result.success(question);
}
/**
* 保存、提交答案
*
* @param replies
* @param questionId
* @param isSave
* @return {@link Object}
*/
@At
@Aop(TransAop.READ_COMMITTED)
public Object saveAnswer(@Param("replies") NutMap[] replies, String questionId, Boolean isSave) {
dao.clear(Question_reply.class, Cnd.where("userId", "=", ShiroUtil.getUserId()).and("qid", "=", questionId));
List<Question_reply> replyList = new ArrayList<>();
for (NutMap reply : replies) {
for (String userSelect : reply.getList("userSelect", String.class)) {
Question_reply questionReply = new Question_reply();
questionReply.setRwid(userSelect);
questionReply.setIssueId(reply.getString("issueId"));
replyList.add(questionReply);
}
}
for (Question_reply questionReply : replyList) {
questionReply.setQid(questionId);
questionReply.setRtime(DateUtil.now());
questionReply.setUserId(ShiroUtil.getUserId());
questionReply.setSave(isSave);
}
dao.insert(replyList);
if (!isSave) {
//全部答完提交计算分数
Sql answerSql = Sqls.create("SELECT count(DISTINCT issueId) as count FROM Question_reply WHERE qid=@questionId AND userId=@userId AND save=0");
answerSql.setParam("questionId", questionId);
answerSql.setParam("userId", ShiroUtil.getUserId());
NutMap answerCountMap = (NutMap) Daos.query(dao, answerSql.toString(), Sqls.callback.map());
int answerCount = answerCountMap.getInt("count", 0);
int issueCount = dao.count(Question_issue.class, Cnd.where("iqid", "=", questionId));
if (answerCount == issueCount) {
insertQuestionAnswerScore2(null, questionId);
}
}
return Result.success();
}
/**
* 回答信息
*
* @param id
* @return {@link Object}
*/
@At("/answerInfo/?")
public Object answerInfo(String id) {
List<Question_reply> replies = questionService.dao().query(Question_reply.class, Cnd.where("qid", "=", id).and("userId", "=", ShiroUtil.getUserId()));
return Result.success(replies);
}
/**
* 检查用户是否答完
*
* @param questionId
* @return {@link Object}
*/
@At
public Object checkUserFinishAnswer(String questionId) {
Sql answerSql = Sqls.create("SELECT count(DISTINCT issueId) as count FROM Question_reply WHERE qid=@questionId AND userId=@userId AND save=0");
answerSql.setParam("questionId", questionId);
answerSql.setParam("userId", ShiroUtil.getUserId());
NutMap answerCountMap = (NutMap) Daos.query(dao, answerSql.toString(), Sqls.callback.map());
int answerCount = answerCountMap.getInt("count", 0);
// int answerCount = dao.count(Question_reply.class, Cnd.where("userId", "=", ShiroUtil.getUserId()).and("qid", "=", questionId).and("save", "=", 0));
int issueCount = dao.count(Question_issue.class, Cnd.where("iqid", "=", questionId));
return Result.success(answerCount == issueCount);
}
@At
public Object getScore(String questionId) {
int fullScore = dao.func(Question_issue.class, "sum", "fraction", Cnd.where("iqid", "=", questionId));
//历史最高分
Integer maxScore = dao.func(QuestionUserScore.class, "max", "score", Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
//当前得分
Float score = dao.fetch(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).desc("answerNum")).getScore();
//回答次数
int answerCount = dao.count(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
String qtitle = dao.fetch(Question.class, questionId).getQtitle();
Sql sql = Sqls.create("select username,loginname,sex,unitname,unionname from `user` where id = @id").setParam("id", ShiroUtil.getUserId());
NutMap userMap = (NutMap) Daos.query(dao, sql.toString(), Sqls.callback.map());
NutMap map = NutMap.NEW();
map.put("maxScore", maxScore);
map.put("score", score);
map.put("title", qtitle);
map.put("user", userMap);
map.put("answerCount", answerCount);
double percentage = (double) score / fullScore * 100;
String message;
if (percentage >= 90) {
message = "你真棒!这是一个优秀的成绩!";
} else if (percentage >= 80) {
message = "不错哦!你取得了一个良好的成绩!";
} else if (percentage >= 70) {
message = "还不错,继续努力,你可以取得更好的成绩!";
} else if (percentage >= 60) {
message = "及格了,但还有进步的空间,请继续努力!";
} else {
message = "很遗憾,你没有及格,但别灰心,下次会更好的!";
}
map.put("message", message);
return Result.success(map);
}
@At("/canAnswer")
public Object canAnswer(String questionId) {
Question question = dao.fetch(Question.class, questionId);
//题目数量
int issueCount = dao.count(Question_issue.class, Cnd.where("iqid", "=", questionId));
//当前最大答题次数
int maxCount = dao.func(QuestionAnswerUserScore.class, "max", "answerNum", Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
//最大答题次数已经答了多少题
int answerIssue = dao.count(QuestionAnswerUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("answerNum", "=", maxCount));
//今天的题目已经答了几次
int todayMaxCount = dao.func(QuestionAnswerUserScore.class, "max", "answerNum", Cnd.where("questionId", "=", questionId).and("userId", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("id")).and("answerDate", "=", DateUtil.format(new Date(), "yyyy-MM-dd")));
if (question.getAnswerTotalSum() != 0 && maxCount < question.getAnswerTotalSum()) {
return Result.success(true);
}
if (question.getQrkdcs() != 0 && question.getQrkdcs() > todayMaxCount) {
return Result.success(true);
}
if (answerIssue < issueCount) {
return Result.success(true);
}
return Result.success(false);
}
private void insertQuestionAnswerScore2(List<Question_reply> replyList, String questionId) {
int answerNum = dao.func(QuestionUserScore.class, "max", "answerNum", Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
//查询题目及选项信息
List<Question_issue> issues = dao.query(Question_issue.class, Cnd.where("iqid", "=", questionId));
dao.fetchLinks(issues, "wors");
// AtomicReference<Float> score = new AtomicReference<>();
AtomicReference<Float> score = new AtomicReference<>((float) 0);
List<Question_reply> replyIssues = dao.query(Question_reply.class, Cnd.where("userId", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("id")).and("qid", "=", questionId));
//每题的回答记录
Map<String, List<Question_reply>> issueReplies = replyIssues.stream().collect(Collectors.groupingBy(v -> v.getIssueId()));
issueReplies.forEach((k, v) -> {
//用户回答的选项
Set<String> userReplyOptionIds = v.stream().map(x -> x.getRwid()).collect(Collectors.toSet());
//正确的选项
Set<String> correctOptionIds = issues.stream().filter(x -> x.getIid().equals(k)).findFirst().map(x -> x.getWors().stream().filter(c -> c.getCorrect() != null && c.getCorrect()).map(c -> c.getWid()).collect(Collectors.toSet())).orElse(null);
if (userReplyOptionIds.equals(correctOptionIds)) {
//该题的分数
double sum = issues.stream().filter(x -> x.getIid().equals(k)).mapToDouble(x -> x.getFraction() == null ? 0 : x.getFraction()).sum();
// score.addAndGet(sum);
score.updateAndGet(v1 -> (float) (v1 + sum));
}
});
QuestionUserScore questionUserScore = new QuestionUserScore();
questionUserScore.setQuestionId(questionId);
questionUserScore.setUserId(ShiroUtil.getUserId());
questionUserScore.setAnswerDate(new Date());
questionUserScore.setAnswerNum(answerNum + 1);
questionUserScore.setScore(score.get());
dao.insert(questionUserScore);
}
}
@@ -1,11 +1,12 @@
package io.v.nutz.question.controller; package io.v.nutz.question.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HtmlUtil; import cn.hutool.http.HtmlUtil;
import cn.wizzer.framework.base.Result; import cn.wizzer.framework.base.Result;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.modules.models.PageForm; import io.v.nutz.modules.models.PageForm;
import io.v.nutz.question.model.Question; import io.v.nutz.question.model.Question;
import io.v.nutz.question.model.Question_issue; import io.v.nutz.question.model.Question_issue;
@@ -18,7 +19,7 @@ import io.v.nutz.question.service.QuestionWorService;
import io.v.nutz.sys.models.Sys_task; import io.v.nutz.sys.models.Sys_task;
import io.v.nutz.sys.services.SysTaskService; import io.v.nutz.sys.services.SysTaskService;
import io.v.nutz.task.services.TaskPlatformService; import io.v.nutz.task.services.TaskPlatformService;
import io.v.nutz.util.ShiroUtil; import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop; import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain; import org.nutz.dao.Chain;
@@ -30,18 +31,18 @@ import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json; import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings; import org.nutz.lang.Strings;
import org.nutz.lang.random.R; import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST; import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param; import org.nutz.mvc.annotation.Param;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -98,6 +99,7 @@ public class QuestionMangeController {
sql.setCondition(cnd); sql.setCondition(cnd);
return Result.success().addData(questionService.listPage(pageForm.getPageNumber(), pageForm.getPageSize(), sql)); return Result.success().addData(questionService.listPage(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
return Result.error(); return Result.error();
} }
} }
@@ -114,8 +116,6 @@ public class QuestionMangeController {
@RequiresPermissions("question.mange") @RequiresPermissions("question.mange")
public Object upStatus(String qid, Integer flag) { public Object upStatus(String qid, Integer flag) {
try { try {
Assert.notBlank(qid);
Assert.notNull(flag);
dao.update(Question.class, Chain.make("qflag", flag), Cnd.where("qid", "=", qid)); dao.update(Question.class, Chain.make("qflag", flag), Cnd.where("qid", "=", qid));
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
@@ -131,13 +131,23 @@ public class QuestionMangeController {
public Object doAdd(@Param("question") Question question) { public Object doAdd(@Param("question") Question question) {
try { try {
question.setQflag(1); question.setQflag(1);
question.setQctime(DateUtil.getDate()); question.setQctime(DateUtil.now());
question.setQcreator(ShiroUtil.getPrincipalProperty("id").toString()); question.setQcreator(ShiroUtil.getPrincipalProperty("id").toString());
//这里要额外判断下随机模式下的答题天数
if (question.getQlx() == 2) {
DateTime startTime = DateUtil.date(question.getStartTime());
DateTime endTime = DateUtil.date(question.getEndTime());
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
if (betweenDay < 1) {
//同一天
question.setCanRepeatedAnswer(false);
question.setCanRepeatedAnswerNum(null);
}
}
Question insert = questionService.insert(question); Question insert = questionService.insert(question);
int i = 1; int i = 1;
for (Question_issue issue : question.getIssues()) { for (Question_issue issue : question.getIssues()) {
issue.setIid(Strings.isNotBlank(issue.getIid()) ? issue.getIid() : R.UU32()); issue.setIid(Strings.isNotBlank(issue.getIid()) ? issue.getIid() : R.UU32());
issue.setIqid(insert.getQid()); issue.setIqid(insert.getQid());
@@ -145,7 +155,6 @@ public class QuestionMangeController {
if (question.getCtMode() == 2) { if (question.getCtMode() == 2) {
issue.setIpxbh(i); issue.setIpxbh(i);
} }
Question_issue issueInsert = questionIssueService.insert(issue); Question_issue issueInsert = questionIssueService.insert(issue);
int j = 1; int j = 1;
for (Question_wor wor : issue.getWors()) { for (Question_wor wor : issue.getWors()) {
@@ -157,9 +166,7 @@ public class QuestionMangeController {
} }
i++; i++;
} }
// raffleTask(question.getQid());
raffleTask(question.getQid());
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -173,6 +180,17 @@ public class QuestionMangeController {
@ViReturn @ViReturn
@RequiresPermissions("question.mange") @RequiresPermissions("question.mange")
public Object doEdit(@Param("question") Question question) { public Object doEdit(@Param("question") Question question) {
//这里要额外判断下随机模式下的答题天数
if (question.getQlx() == 2) {
DateTime startTime = DateUtil.date(question.getStartTime());
DateTime endTime = DateUtil.date(question.getEndTime());
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
if (betweenDay < 1) {
//同一天
question.setCanRepeatedAnswer(false);
question.setCanRepeatedAnswerNum(null);
}
}
questionService.update(question); questionService.update(question);
List<Question_issue> oldIssues = dao.query(Question_issue.class, Cnd.where("iqid", "=", question.getQid())); List<Question_issue> oldIssues = dao.query(Question_issue.class, Cnd.where("iqid", "=", question.getQid()));
@@ -182,11 +200,9 @@ public class QuestionMangeController {
for (int i = 0; i < issues.size(); i++) { for (int i = 0; i < issues.size(); i++) {
Question_issue issue = issues.get(i); Question_issue issue = issues.get(i);
issue.setIqid(question.getQid()); issue.setIqid(question.getQid());
// if (question.getCtMode() == 2) { if (question.getCtMode() == 2) {
issue.setIpxbh(i + 1); issue.setIpxbh(i + 1);
// } }
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
System.out.println(Json.toJson(issue));
dao.insertOrUpdate(issue); dao.insertOrUpdate(issue);
List<Question_wor> wors = issue.getWors(); List<Question_wor> wors = issue.getWors();
for (int i1 = 0; i1 < wors.size(); i1++) { for (int i1 = 0; i1 < wors.size(); i1++) {
@@ -241,7 +257,7 @@ public class QuestionMangeController {
/** /**
* 删除文具按 * 删除问卷
* *
* @param qid qid * @param qid qid
* @return {@link Object} * @return {@link Object}
@@ -311,13 +327,23 @@ public class QuestionMangeController {
@At("/modifyBasicInfo") @At("/modifyBasicInfo")
@RequiresPermissions("question.mange") @RequiresPermissions("question.mange")
@ViReturn @ViReturn
public Object modifyBasicInfo(Question question) { public Object modifyBasicInfo(@Param("question") Question question) {
try { try {
Assert.notNull(question); Assert.notNull(question);
if (question.getQlx() == 2) {
DateTime startTime = DateUtil.date(question.getStartTime());
DateTime endTime = DateUtil.date(question.getEndTime());
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
if (betweenDay < 1) {
//同一天
question.setCanRepeatedAnswer(false);
question.setCanRepeatedAnswerNum(null);
}
}
if (StrUtil.isNotBlank(question.getQid())) { if (StrUtil.isNotBlank(question.getQid())) {
dao.updateIgnoreNull(question); dao.updateIgnoreNull(question);
} else { } else {
question.setQctime(cn.hutool.core.date.DateUtil.today()); question.setQctime(DateUtil.today());
question.setQcreator(ShiroUtil.getUserId()); question.setQcreator(ShiroUtil.getUserId());
question.setQflag(1); question.setQflag(1);
dao.insert(question); dao.insert(question);
@@ -373,7 +399,7 @@ public class QuestionMangeController {
Question_issue issue = issueList.get(i); Question_issue issue = issueList.get(i);
issue.setIqid(questionId); issue.setIqid(questionId);
// if (question.getCtMode() == 2) { // if (question.getCtMode() == 2) {
issue.setIpxbh(i + 1); issue.setIpxbh(i + 1);
// } // }
dao.insertOrUpdate(issue); dao.insertOrUpdate(issue);
List<Question_wor> wors = issue.getWors(); List<Question_wor> wors = issue.getWors();
@@ -418,41 +444,41 @@ public class QuestionMangeController {
* @param questionId 问题id * @param questionId 问题id
*/ */
private void raffleTask(String questionId) { private void raffleTask(String questionId) {
Question question = dao.fetch(Question.class, questionId); //删除之前的任务再添加
List<Sys_task> oldTasks = dao.query(Sys_task.class, Cnd.where("data", "like", "%" + questionId + "%"));
//每天凌晨一点执行 for (Sys_task task : oldTasks) {
String cron = "0 0 1 * * ?"; taskPlatformService.delete(task.getId(), task.getId());
cron = "30 * * * * ? "; sysTaskService.delete(task.getId());
String cronData = Json.toJson(Map.of("questionId", questionId)); }
String jobClass = "io.v.nutz.task.job.question.QuestionRaffleJob"; String jobClass = "io.v.nutz.task.job.question.QuestionRaffleJob";
Sys_task task = sysTaskService.fetch(Cnd.where("jobClass", "=", jobClass).and("data", "=", cronData)); Question question = dao.fetch(Question.class, questionId);
//需要抽奖 //需要抽奖
if (question.getIsRaffle() != null && question.getIsRaffle()) { if (question.getIsRaffle() != null && question.getIsRaffle()) {
if (task != null) {
String dateFormat = "ss mm HH dd MM ? yyyy";
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
List<Question.RaffleRule> raffleRules = question.getRaffleRule();
for (Question.RaffleRule raffleRule : raffleRules) {
Date raffleTime = raffleRule.getRaffleTime();
String formatTimeStr = sdf.format(raffleTime);
NutMap raffleRuleMap = Lang.obj2nutmap(raffleRule);
raffleRuleMap.put("questionId", questionId);
String cronData = Json.toJson(raffleRuleMap);
Sys_task task = new Sys_task();
task.setName(HtmlUtil.cleanHtmlTag(question.getQtitle()) + "问卷调查抽奖任务"); task.setName(HtmlUtil.cleanHtmlTag(question.getQtitle()) + "问卷调查抽奖任务");
task.setCron(cron);
sysTaskService.updateIgnoreNull(task);
if (taskPlatformService.isExist(task.getId(), task.getId())) {
taskPlatformService.delete(task.getId(), task.getId());
}
} else {
task = new Sys_task();
task.setName(HtmlUtil.cleanHtmlTag(question.getQsm()) + "问卷调查抽奖任务");
task.setJobClass(jobClass); task.setJobClass(jobClass);
task.setNote("问卷调查抽奖任务"); task.setNote("问卷调查抽奖任务");
task.setCron(cron); task.setCron(formatTimeStr);
task.setData(cronData); task.setData(cronData);
task.setDisabled(false); task.setDisabled(false);
sysTaskService.insert(task); sysTaskService.insert(task);
} taskPlatformService.add(task.getId(), task.getId(), task.getJobClass(), task.getCron(),
taskPlatformService.add(task.getId(), task.getId(), task.getJobClass(), task.getCron(), task.getNote(), task.getData());
task.getNote(), task.getData());
} else {
if (task != null) {
taskPlatformService.delete(task.getId(), task.getId());
sysTaskService.delete(task.getId());
} }
} }
} }
@@ -3,8 +3,6 @@ package io.v.nutz.question.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.annotation.Excel; import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.hutool.http.HtmlUtil;
import cn.wizzer.framework.base.Result; import cn.wizzer.framework.base.Result;
import io.v.nutz.base.utils.Html2Text; import io.v.nutz.base.utils.Html2Text;
import io.v.nutz.modules.models.PageForm; import io.v.nutz.modules.models.PageForm;
@@ -14,7 +12,6 @@ import io.v.nutz.question.service.QuestionIssueService;
import io.v.nutz.question.service.QuestionReplyService; import io.v.nutz.question.service.QuestionReplyService;
import io.v.nutz.question.service.QuestionService; import io.v.nutz.question.service.QuestionService;
import io.v.nutz.question.service.QuestionWorService; import io.v.nutz.question.service.QuestionWorService;
import io.v.nutz.sys.models.Sys_union;
import lombok.Data; import lombok.Data;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -25,15 +22,12 @@ import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings; import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param; import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -75,17 +69,13 @@ public class QuestionPollAnalysisController {
@Param("pageNumber") int pageNumber, @Param("pageNumber") int pageNumber,
@Param("pageSize") int pageSize) { @Param("pageSize") int pageSize) {
try { try {
Sql sql = Sqls.create("""
select r.*,u.username,u.unionname,u.unitname,u.mobile from question_reply r left join `user` u on r.userId = u.id $condition
""");
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.and("rwid", "=", wid); cnd.and("rwid", "=", wid);
if (Strings.isNotBlank(searchKeyword)) { if (Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike("rval", searchKeyword); cnd.where().andLike("rval", searchKeyword);
} }
cnd.desc("rtime"); cnd.desc("rtime");
sql.setCondition(cnd); return Result.success().addData(questionReplyService.listPage(pageNumber, pageSize, cnd));
return Result.success().addData(questionReplyService.listPage(pageNumber, pageSize, sql));
} catch (Exception e) { } catch (Exception e) {
return Result.error(); return Result.error();
} }
@@ -166,7 +156,6 @@ public class QuestionPollAnalysisController {
} }
@At @At
@Ok("void")
@RequiresPermissions("question.pollAnalysis") @RequiresPermissions("question.pollAnalysis")
public void doExport(@Param(value = "questionId",required = false) String questionId, HttpServletResponse response) { public void doExport(@Param(value = "questionId",required = false) String questionId, HttpServletResponse response) {
try { try {
@@ -211,52 +200,6 @@ public class QuestionPollAnalysisController {
} }
} }
@At
@Ok("void")
@RequiresPermissions("question.pollAnalysis")
public void doExportByUnion(@Param(value = "questionId",required = false) String questionId, HttpServletResponse response) throws IOException {
//查询所有工会
List<Sys_union> unionList = questionService.dao().query(Sys_union.class, Cnd.NEW());
//查询所有答复
Sql sql = Sqls.create("""
select r.*,u.unionId,u.username,u.mobile from question_reply r left join `user` u on r.userId = u.id where r.qid = @qid and unionId is not null
""").setParam("qid", questionId);
List<NutMap> replyList = questionService.listMap(sql);
//查询所有题目
List<Question_issue> issueList = questionService.dao().query(Question_issue.class, Cnd.where("iqid", "=", questionId).asc("ipxbh"));
//设置第一行
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("", "unionname", 30));
for (int i = 0; i < issueList.size(); i++) {
exportEntities.add(new ExcelExportEntity(HtmlUtil.cleanHtmlTag(issueList.get(i).getIname()), i + "", 30));
}
exportEntities.add(new ExcelExportEntity("填报人姓名", "username", 30));
exportEntities.add(new ExcelExportEntity("填报人电话", "mobile", 30));
List<NutMap> result = new ArrayList<>();
unionList.forEach(item -> {
NutMap nutMap = new NutMap();
nutMap.put("unionname", item.getUnionname());
for (int i = 0; i < issueList.size(); i++) {
int finalI = i;
NutMap map = replyList.stream().filter(o -> o.getString("unionid").equals(item.getId()) && o.getString("issueId").equals(issueList.get(finalI).getIid())).findFirst().orElse(null);
nutMap.put(i + "", map != null ? map.getString("rval") : "");
nutMap.put("username", map != null ? map.getString("username") : "");
nutMap.put("mobile", map != null ? map.getString("mobile") : "");
}
result.add(nutMap);
});
Question question = questionService.fetch(questionId);
String fileName = question.getQtitle() + "按分工会导出";
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".xls").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), exportEntities, result);
workbook.write(response.getOutputStream());
workbook.close();
}
@Data @Data
public static class ExportEntity { public static class ExportEntity {
@Excel(name = "序号") @Excel(name = "序号")
@@ -75,7 +75,24 @@ public class QuestionUnionIntentionalChoiceController {
SELECT SELECT
un.id unionId, un.id unionId,
un.unionName, un.unionName,
(select count(1) from user where member = 1 and unionid = un.id) AS teacherSum, (select count(1) from "user" where member = 1 and unionid = un.id) AS teacherSum1,
(
select
count(1)
from
activity_user_scope aus
left join "user" u on u.id = aus.userId
where
groupId in (
select
activityUserScopeId
from
question
where
qid = @questionId
)
and u.unionId = un.id
) as teacherSum,
( (
SELECT SELECT
count( DISTINCT r.userId ) count( DISTINCT r.userId )
@@ -92,7 +109,7 @@ public class QuestionUnionIntentionalChoiceController {
""").setParam("questionId", questionId); """).setParam("questionId", questionId);
CndPlus cndPlus = CndPlus.create(); CndPlus cndPlus = CndPlus.create();
cndPlus.andExcludeEmpty("un.id", "=", unionId); cndPlus.andEX("un.id", "=", unionId);
sql.setCondition(cndPlus); sql.setCondition(cndPlus);
List<NutMap> unionList = questionService.listMap(sql); List<NutMap> unionList = questionService.listMap(sql);
@@ -253,7 +270,7 @@ public class QuestionUnionIntentionalChoiceController {
$condition $condition
""").setParam("questionId", questionId); """).setParam("questionId", questionId);
cnd.andExcludeEmpty("u.unionid", "=", unionId); cnd.andEX("u.unionid", "=", unionId);
cnd.groupBy("u.id"); cnd.groupBy("u.id");
cnd.desc("u.unioncode"); cnd.desc("u.unioncode");
sql.setCondition(cnd); sql.setCondition(cnd);
@@ -4,6 +4,7 @@ import lombok.Data;
import org.nutz.dao.entity.annotation.*; import org.nutz.dao.entity.annotation.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
@@ -51,7 +52,7 @@ public class Question implements Serializable {
@Column @Column
@Comment("说明") @Comment("说明")
@ColDefine(type = ColType.VARCHAR, width = 2000) @ColDefine(customType = "text")
private String qsm; private String qsm;
@Column @Column
@@ -69,11 +70,6 @@ public class Question implements Serializable {
@ColDefine(type = ColType.VARCHAR, width = 50) @ColDefine(type = ColType.VARCHAR, width = 50)
private String qdtjssj; private String qdtjssj;
@Column
@Comment("活动时间内可答题总次数")
@ColDefine(type = ColType.INT, width = 2)
private Integer answerTotalSum;
@Many(field = "iqid") @Many(field = "iqid")
private List<Question_issue> issues; private List<Question_issue> issues;
@@ -100,16 +96,16 @@ public class Question implements Serializable {
@ColDefine(type = ColType.INT) @ColDefine(type = ColType.INT)
private Integer ctMode; private Integer ctMode;
@Column
@Comment("单次出题数量")
@ColDefine(type = ColType.INT)
private Integer ctNum;
@Column @Column
@Comment("是否抽奖") @Comment("是否抽奖")
@ColDefine(type = ColType.BOOLEAN) @ColDefine(type = ColType.BOOLEAN)
private Boolean isRaffle; private Boolean isRaffle;
@Column
@Comment("抽奖时间")
@ColDefine(type = ColType.DATETIME)
private Date raffleTime;
@Column @Column
@Comment("多少分可以抽奖") @Comment("多少分可以抽奖")
@ColDefine(type = ColType.INT) @ColDefine(type = ColType.INT)
@@ -120,5 +116,59 @@ public class Question implements Serializable {
@ColDefine(type = ColType.INT) @ColDefine(type = ColType.INT)
private Integer raffleWinnerUserNum; private Integer raffleWinnerUserNum;
@Column
@Comment("题目顺序打乱")
@ColDefine(type = ColType.BOOLEAN)
private Boolean disruptingOrder;
@Column
@Comment("随机单次出题数量")
@ColDefine(type = ColType.INT)
private Integer ranDomSingleIssueNum;
@Column
@Comment("总共随机次数")
@ColDefine(type = ColType.INT)
private Integer ranDomSum;
@Column
@Comment("是否多次答")
@ColDefine(type = ColType.BOOLEAN)
private Boolean canRepeatedAnswer;
@Column
@Comment("多次答数")
@ColDefine(type = ColType.INT)
private Integer canRepeatedAnswerNum;
@Column
@Comment("得分统计(重复答题允许下 1.保存最高分 2.保存最新得分)")
@ColDefine(type = ColType.INT)
private Integer calcScoreMode;
@Column
@Comment("抽奖规则")
@ColDefine(type = ColType.MYSQL_JSON)
private List<RaffleRule> raffleRule;
/**
* 抽奖规则
*/
@Data
public static class RaffleRule {
//开始答题时间
private Date startAnswerDate;
//结束答题时间
private Date endAnswerDate;
//抽奖时间
private Date raffleTime;
//抽奖分数
private Integer raffleScore;
//抽奖人数
private Integer raffleWinnerUserNum;
}
} }
@@ -34,8 +34,8 @@ public class QuestionAnswerUserScore {
@Column @Column
@Comment("该题得分") @Comment("该题得分")
@ColDefine(type = ColType.FLOAT) @ColDefine(type = ColType.INT)
private Float subjectScore; private Integer subjectScore;
@Column @Column
@Comment("用户id") @Comment("用户id")
@@ -0,0 +1,52 @@
package io.v.nutz.question.model;
import io.v.nutz.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.util.Date;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
@Comment("问卷随机题目")
@Table
public class QuestionRandomIssue extends BaseModel {
@Name
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true)
private String id;
@Column
@Comment("问卷的id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String questionId;
@Column
@Comment("用户id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userId;
@Column
@Comment("题目")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> issueIds;
@Column
@Comment("回答次数")
@ColDefine(type = ColType.INT)
private Integer num;
@Column
@Comment("是否回答完成")
@ColDefine(type = ColType.BOOLEAN)
private Boolean isFinish;
@Column
@Comment("显示日期")
@ColDefine(type = ColType.DATE)
private Date displayDate;
}
@@ -1,6 +1,8 @@
package io.v.nutz.question.model; package io.v.nutz.question.model;
import io.v.nutz.base.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*; import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert; import org.nutz.dao.interceptor.annotation.PrevInsert;
@@ -12,9 +14,10 @@ import java.util.Date;
* @author jug * @author jug
* @date 2023/06/20 * @date 2023/06/20
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
@Table @Table
public class QuestionUserScore { public class QuestionUserScore extends BaseModel {
@Name @Name
@ColDefine(type = ColType.VARCHAR, width = 32) @ColDefine(type = ColType.VARCHAR, width = 32)
@@ -28,8 +31,8 @@ public class QuestionUserScore {
@Column @Column
@Comment("得分") @Comment("得分")
@ColDefine(type = ColType.FLOAT) @ColDefine(type = ColType.INT)
private Float score; private Integer score;
@Column @Column
@Comment("用户id") @Comment("用户id")
@@ -46,4 +49,13 @@ public class QuestionUserScore {
@ColDefine(type = ColType.INT) @ColDefine(type = ColType.INT)
private Integer answerNum; private Integer answerNum;
@Column
@Comment("随机次数")
@ColDefine(type = ColType.INT)
private Integer randomNum;
@Column
@Comment("显示日期(只针对定时定题)")
@ColDefine(type = ColType.DATE)
private Date displayDate;
} }
@@ -37,4 +37,9 @@ public class QuestionWinner {
@ColDefine(type = ColType.DATE) @ColDefine(type = ColType.DATE)
private Date winDate; private Date winDate;
@Column
@Comment("分数")
@ColDefine(type = ColType.INT)
private Integer score;
} }
@@ -101,8 +101,8 @@ public class Question_issue implements Serializable {
@Column @Column
@Comment("该题分数") @Comment("该题分数")
@J4EIgnore @J4EIgnore
@ColDefine(type = ColType.FLOAT, width = 4, precision = 1) @ColDefine(type = ColType.INT, width = 4)
private Float fraction; private Integer fraction;
@Column @Column
@Comment("显示日期") @Comment("显示日期")
@@ -5,6 +5,7 @@ import org.nutz.dao.entity.annotation.*;
import org.nutz.integration.json4excel.annotation.J4EIgnore; import org.nutz.integration.json4excel.annotation.J4EIgnore;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
@@ -85,4 +86,6 @@ public class Question_reply implements Serializable {
@One(field = "rwid", key = "wid") @One(field = "rwid", key = "wid")
private Question_wor wor; private Question_wor wor;
private List<String> userSelect;
} }
@@ -0,0 +1,23 @@
package io.v.nutz.question.service;
import io.v.nutz.base.page.Pagination;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.question.model.QuestionUserScore;
import java.io.IOException;
import java.io.OutputStream;
/**
* 得分
*/
public interface QuestionAnswerRankingService extends BaseService<QuestionUserScore> {
Pagination pageData(PageForm pageForm,
String questionId,
String unionId,
String unitId,
String answerDate);
void exportXlsx(String questionId, OutputStream os) throws IOException;
}
@@ -1,7 +1,6 @@
package io.v.nutz.question.service; package io.v.nutz.question.service;
import io.v.nutz.question.model.Question; import io.v.nutz.question.model.Question;
import io.v.nutz.question.model.Question_reply; import io.v.nutz.question.model.Question_reply;
import io.v.nutz.service.ViService; import io.v.nutz.service.ViService;
@@ -1,6 +1,7 @@
package io.v.nutz.question.service; package io.v.nutz.question.service;
import io.v.nutz.question.model.Question; import io.v.nutz.question.model.Question;
import io.v.nutz.question.model.Question_reply;
import io.v.nutz.service.ViService; import io.v.nutz.service.ViService;
import org.nutz.lang.util.NutMap; import org.nutz.lang.util.NutMap;
@@ -15,4 +16,29 @@ public interface QuestionService extends ViService<Question> {
NutMap getRankData(String qid); NutMap getRankData(String qid);
/**
* 答题
*
* @param repliesArray 记录
* @param questionId 问卷ID
* @param isSave 是否保存
*/
void saveAnswer(Question_reply[] repliesArray, String questionId, Boolean isSave);
/**
* 是否同天 仅限随机
* @param questionId 问卷ID
* @return
*/
boolean isSameDay(String questionId);
/**
* 是否同天 仅限随机
* @param startTimeTs 开始时间
* @param endTimeTs 结束时间
* @return
*/
boolean isSameDay(long startTimeTs,long endTimeTs);
} }
@@ -0,0 +1,427 @@
package io.v.nutz.question.service.impl;
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.hutool.core.util.StrUtil;
import io.v.nutz.base.page.Pagination;
import io.v.nutz.base.service.impl.BaseServiceImpl;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.question.model.Question;
import io.v.nutz.question.model.QuestionUserScore;
import io.v.nutz.question.service.QuestionAnswerRankingService;
import io.v.nutz.question.service.QuestionService;
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.sql.Sql;
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 java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@IocBean(args = {"refer:dao"})
public class QuestionAnswerRankingServiceImpl extends BaseServiceImpl<QuestionUserScore> implements QuestionAnswerRankingService {
public QuestionAnswerRankingServiceImpl(Dao dao) {
super(dao);
}
@Inject
private QuestionService questionService;
@Override
public Pagination pageData(PageForm pageForm, String questionId, String unionId, String unitId, String answerDate) {
Question question = dao().fetch(Question.class, questionId);
if (Lang.isEmpty(question)) {
return new Pagination();
}
if (question.getCtMode() == 1) {
Sql sql = Sqls.create("""
SELECT
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) as answerDate,
qus.score,
qus.answerNum,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile
FROM
question_user_score qus
LEFT JOIN `user` u ON u.id = qus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("qus.questionId", "=", questionId);
cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("qus.answerDate", "=", answerDate);
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
cnd.and(Cnd.exps("u.loginname", "like", "%" + pageForm.getSearchKeyword() + "%").or("u.username", "like", "%" + pageForm.getSearchKeyword() + "%"));
}
cnd.groupBy("qus.answerDate", "qus.userId");
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
if (question.getCalcScoreMode() == 1) {
cnd.and("qus.score", "in", Sqls.create("select max(score) from question_user_score where userId = qus.userId and questionId = qus.questionId and answerDate = qus.answerDate"));
} else if (question.getCalcScoreMode() == 2) {
cnd.and("qus.answerNum", "in", Sqls.create("select max(answerNum) from question_user_score where userId = qus.userId and questionId = qus.questionId and answerDate = qus.answerDate"));
}
sql.setCondition(cnd);
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
} else if (question.getCtMode() == 2) {
if (questionService.isSameDay(question.getStartTime(), question.getEndTime())) {
Sql sql = Sqls.create("""
SELECT
GROUP_CONCAT( qus.answerNum, '(', qus.score, ')' ORDER BY qus.answerNum SEPARATOR ', ' ) AS everyRandomScore,
sum( score ) AS score,
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) AS answerDate,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile,
q.ctMode,
q.calcScoreMode
FROM
`question_user_score` qus
LEFT JOIN `user` u ON u.id = qus.userId
LEFT JOIN question q ON q.qid = qus.questionId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("qus.questionId", "=", questionId);
cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("qus.answerDate", "=", answerDate);
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
cnd.and(Cnd.exps("u.loginname", "like", "%" + pageForm.getSearchKeyword() + "%").or("u.username", "like", "%" + pageForm.getSearchKeyword() + "%"));
}
cnd.groupBy("qus.answerDate", "qus.userId");
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
sql.setCondition(cnd);
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
} else {
Sql sql = Sqls.create("""
SELECT
(
SELECT
score\s
FROM
question_user_score\s
WHERE
userId = qus.userId\s
AND answerDate = qus.answerDate\s
AND answerNum = max( qus.answerNum )\s
AND questionId = qus.questionId
) as lastAnswerNumScore,
(
SELECT
score\s
FROM
question_user_score\s
WHERE
userId = qus.userId\s
AND answerDate = qus.answerDate\s
AND score = max( qus.score )\s
AND questionId = qus.questionId
) as maxAnswerScore,
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) AS answerDate,
qus.answerNum,
max( qus.answerNum ),
min( qus.answerNum ),
qus.score,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile,
q.ctMode,
q.calcScoreMode
FROM
`question_user_score` qus
LEFT JOIN `user` u ON u.id = qus.userId
LEFT JOIN question q ON q.qid = qus.questionId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("qus.questionId", "=", questionId);
cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("qus.answerDate", "=", answerDate);
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
cnd.and(Cnd.exps("u.loginname", "like", "%" + pageForm.getSearchKeyword() + "%").or("u.username", "like", "%" + pageForm.getSearchKeyword() + "%"));
}
cnd.groupBy("qus.answerDate", "qus.userId");
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
sql.setCondition(cnd);
Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
List<NutMap> list = pagination.getList();
for (NutMap map : list) {
map.put("score", map.getInt(question.getCalcScoreMode() == 1 ? "maxAnswerScore" : "lastAnswerNumScore"));
}
return pagination;
}
} else if (question.getCtMode() == 3) {
Sql sql = Sqls.create("""
SELECT
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) as answerDate,
qus.score,
qus.answerNum,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile
FROM
question_user_score qus
LEFT JOIN `user` u ON u.id = qus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("qus.questionId", "=", questionId);
cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("qus.answerDate", "=", answerDate);
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
cnd.and(Cnd.exps("u.loginname", "like", "%" + pageForm.getSearchKeyword() + "%").or("u.username", "like", "%" + pageForm.getSearchKeyword() + "%"));
}
cnd.groupBy("qus.answerDate", "qus.userId");
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
if (question.getCalcScoreMode() == 1) {
cnd.and("qus.score", "in", Sqls.create("select max(score) from question_user_score where userId = qus.userId and questionId = qus.questionId and answerDate = qus.answerDate"));
} else if (question.getCalcScoreMode() == 2) {
cnd.and("qus.answerNum", "in", Sqls.create("select max(answerNum) from question_user_score where userId = qus.userId and questionId = qus.questionId and answerDate = qus.answerDate"));
}
sql.setCondition(cnd);
return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
}
return new Pagination();
}
@Override
public void exportXlsx(String questionId, OutputStream os) throws IOException {
Question question = dao().fetch(Question.class, questionId);
if (question.getCtMode() == 1) {
Sql sql = Sqls.create("""
SELECT
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) as answerDate,
qus.score,
qus.answerNum,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile
FROM
question_user_score qus
LEFT JOIN `user` u ON u.id = qus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("qus.questionId", "=", questionId);
cnd.groupBy("qus.answerDate", "qus.userId");
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
if (question.getCalcScoreMode() == 1) {
cnd.and("qus.score", "in", Sqls.create("select max(score) from question_user_score where userId = qus.userId and questionId = qus.questionId and answerDate = qus.answerDate"));
} else if (question.getCalcScoreMode() == 2) {
cnd.and("qus.answerNum", "in", Sqls.create("select max(answerNum) from question_user_score where userId = qus.userId and questionId = qus.questionId and answerDate = qus.answerDate"));
}
sql.setCondition(cnd);
List<NutMap> list = listMap(sql);
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
exportEntities.add(new ExcelExportEntity("所属单位", "unitname", 20));
exportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20));
exportEntities.add(new ExcelExportEntity("联系方式", "mobile", 20));
exportEntities.add(new ExcelExportEntity("分数", "score", 20));
exportEntities.add(new ExcelExportEntity("答题日期", "answerDate", 20));
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
workbook.write(os);
} else if (question.getCtMode() == 2) {
if (questionService.isSameDay(question.getStartTime(), question.getEndTime())) {
Sql sql = Sqls.create("""
SELECT
GROUP_CONCAT( qus.answerNum, '(', qus.score, ')' ORDER BY qus.answerNum SEPARATOR ', ' ) AS everyRandomScore,
sum( score ) AS score,
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) AS answerDate,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile,
q.ctMode,
q.calcScoreMode
FROM
`question_user_score` qus
LEFT JOIN `user` u ON u.id = qus.userId
LEFT JOIN question q ON q.qid = qus.questionId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("qus.questionId", "=", questionId);
cnd.groupBy("qus.answerDate", "qus.userId");
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
sql.setCondition(cnd);
List<NutMap> list = listMap(sql);
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
exportEntities.add(new ExcelExportEntity("所属单位", "unitname", 20));
exportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20));
exportEntities.add(new ExcelExportEntity("联系方式", "mobile", 20));
exportEntities.add(new ExcelExportEntity("分数", "score", 20));
exportEntities.add(new ExcelExportEntity("每轮分数", "everyRandomScore", 20));
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
workbook.write(os);
} else {
Sql sql = Sqls.create("""
SELECT
(
SELECT
score\s
FROM
question_user_score\s
WHERE
userId = qus.userId\s
AND answerDate = qus.answerDate\s
AND answerNum = max( qus.answerNum )\s
AND questionId = qus.questionId
) as lastAnswerNumScore,
(
SELECT
score\s
FROM
question_user_score\s
WHERE
userId = qus.userId\s
AND answerDate = qus.answerDate\s
AND score = max( qus.score )\s
AND questionId = qus.questionId
) as maxAnswerScore,
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) AS answerDate,
qus.answerNum,
max( qus.answerNum ),
min( qus.answerNum ),
qus.score,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile,
q.ctMode,
q.calcScoreMode
FROM
`question_user_score` qus
LEFT JOIN `user` u ON u.id = qus.userId
LEFT JOIN question q ON q.qid = qus.questionId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("qus.questionId", "=", questionId);
cnd.groupBy("qus.answerDate", "qus.userId");
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
sql.setCondition(cnd);
List<NutMap> list = listMap(sql);
for (NutMap map : list) {
map.put("score", map.getInt(question.getCalcScoreMode() == 1 ? "maxAnswerScore" : "lastAnswerNumScore"));
}
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
exportEntities.add(new ExcelExportEntity("所属单位", "unitname", 20));
exportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20));
exportEntities.add(new ExcelExportEntity("联系方式", "mobile", 20));
exportEntities.add(new ExcelExportEntity("分数", "score", 20));
exportEntities.add(new ExcelExportEntity("答题日期", "answerDate", 20));
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
workbook.write(os);
}
} else if (question.getCtMode() == 3) {
Sql sql = Sqls.create("""
SELECT
qus.userId,
DATE_FORMAT( qus.answerDate, '%Y-%m-%d' ) as answerDate,
qus.score,
qus.answerNum,
u.loginname,
u.username,
u.sex,
u.unitname,
u.unionname,
u.mobile
FROM
question_user_score qus
LEFT JOIN `user` u ON u.id = qus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("qus.questionId", "=", questionId);
cnd.groupBy("qus.answerDate", "qus.userId");
cnd.asc("qus.answerDate").asc("u.unionid").asc("u.id");
if (question.getCalcScoreMode() == 1) {
cnd.and("qus.score", "in", Sqls.create("select max(score) from question_user_score where userId = qus.userId and questionId = qus.questionId and answerDate = qus.answerDate"));
} else if (question.getCalcScoreMode() == 2) {
cnd.and("qus.answerNum", "in", Sqls.create("select max(answerNum) from question_user_score where userId = qus.userId and questionId = qus.questionId and answerDate = qus.answerDate"));
}
sql.setCondition(cnd);
List<NutMap> list = listMap(sql);
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("工号", "loginname", 20));
exportEntities.add(new ExcelExportEntity("姓名", "username", 20));
exportEntities.add(new ExcelExportEntity("性别", "sex", 20));
exportEntities.add(new ExcelExportEntity("所属单位", "unitname", 20));
exportEntities.add(new ExcelExportEntity("所属工会", "unionname", 20));
exportEntities.add(new ExcelExportEntity("联系方式", "mobile", 20));
exportEntities.add(new ExcelExportEntity("分数", "score", 20));
exportEntities.add(new ExcelExportEntity("答题日期", "answerDate", 20));
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list);
workbook.write(os);
}
}
}
@@ -76,7 +76,7 @@ public class QuestionReplyServiceImpl extends ViServiceImpl<Question_reply> impl
String wiid = questionWor.getWiid(); String wiid = questionWor.getWiid();
Question_issue subject = dao().fetch(Question_issue.class, Cnd.where("iid", "=", wiid)); Question_issue subject = dao().fetch(Question_issue.class, Cnd.where("iid", "=", wiid));
Float fraction = subject.getFraction(); Integer fraction = subject.getFraction();
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
@@ -108,7 +108,7 @@ public class QuestionReplyServiceImpl extends ViServiceImpl<Question_reply> impl
if (Arrays.equals(correctOptionIdArray, userSelectedOptionIdArray)) { if (Arrays.equals(correctOptionIdArray, userSelectedOptionIdArray)) {
answerUserScore.setSubjectScore(fraction); answerUserScore.setSubjectScore(fraction);
} else { } else {
answerUserScore.setSubjectScore(0f); answerUserScore.setSubjectScore(0);
} }
dao().insert(answerUserScore); dao().insert(answerUserScore);
@@ -1,23 +1,33 @@
package io.v.nutz.question.service.impl; package io.v.nutz.question.service.impl;
import io.v.nutz.question.model.Question; import cn.hutool.core.date.DateTime;
import io.v.nutz.question.model.Question_issue; import cn.hutool.core.date.DateUtil;
import io.v.nutz.question.model.*;
import io.v.nutz.question.service.QuestionIssueService; import io.v.nutz.question.service.QuestionIssueService;
import io.v.nutz.question.service.QuestionReplyService; import io.v.nutz.question.service.QuestionReplyService;
import io.v.nutz.question.service.QuestionService; import io.v.nutz.question.service.QuestionService;
import io.v.nutz.question.service.QuestionWorService; import io.v.nutz.question.service.QuestionWorService;
import io.v.nutz.service.impl.ViServiceImpl; import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd; import org.nutz.dao.Cnd;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.dao.Sqls; import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record; import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql; import org.nutz.dao.sql.Sql;
import org.nutz.integration.jedis.RedisService; import org.nutz.integration.jedis.RedisService;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap; import org.nutz.lang.util.NutMap;
import org.nutz.plugins.wkcache.annotation.CacheDefaults; import org.nutz.plugins.wkcache.annotation.CacheDefaults;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@IocBean(args = {"refer:dao"}) @IocBean(args = {"refer:dao"})
@CacheDefaults(cacheName = "Zgfw_question") @CacheDefaults(cacheName = "Zgfw_question")
public class QuestionServiceImpl extends ViServiceImpl<Question> implements QuestionService { public class QuestionServiceImpl extends ViServiceImpl<Question> implements QuestionService {
@@ -81,4 +91,176 @@ public class QuestionServiceImpl extends ViServiceImpl<Question> implements Ques
return res; return res;
} }
@Override
@Aop(TransAop.READ_COMMITTED)
public void saveAnswer(Question_reply[] repliesArray, String questionId, Boolean isSave) {
//删除上一次的答题记录
//此处需判断 如果是有分多天 随机多次就要按条件删除
//问卷信息包含题目选项
Question question = getQuestion(questionId);
if (question.getCtMode() == 1) {
//删除今天的之前的答题记录
dao().clear(Question_reply.class, Cnd.where("qid", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("DATE(rtime)", "=", DateUtil.today()));
} else if (question.getCtMode() == 2) {
DateTime startTime = DateUtil.date(question.getStartTime());
DateTime endTime = DateUtil.date(question.getEndTime());
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
if (betweenDay > 0) {
//多天随机
dao().clear(Question_reply.class, Cnd.where("qid", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("DATE(rtime)", "=", DateUtil.today()));
} else {
//一天多次随机 删除保存的
dao().clear(Question_reply.class, Cnd.where("qid", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("DATE(rtime)", "=", DateUtil.today()).and("save", "=", 1));
}
} else if (question.getCtMode() == 3) {
dao().clear(Question_reply.class, Cnd.where("qid", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
}
List<Question_reply> replyList = new ArrayList<>();
for (Question_reply reply : repliesArray) {
if (Lang.isNotEmpty(reply.getUserSelect())) {
for (String userSelect : reply.getUserSelect()) {
Question_reply questionReply = new Question_reply();
questionReply.setRwid(userSelect);
questionReply.setIssueId(reply.getIssueId());
questionReply.setUserId(ShiroUtil.getUserId());
questionReply.setRtime(DateUtil.now());
questionReply.setRwid(userSelect);
questionReply.setQid(questionId);
questionReply.setSave(isSave);
replyList.add(questionReply);
}
}
}
insert(replyList);
//判断是否提交 提交则计算此次分数
if (!isSave) {
//得分
AtomicInteger sum = new AtomicInteger();
//常规模式计算全部题目的分数
if (question.getCtMode() == 3) {
//每题的回答记录
List<Question_reply> replies = dao().query(Question_reply.class, Cnd.where("qid", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("userId", "=", ShiroUtil.getUserId()));
Map<String, List<Question_reply>> issueReplies = replies.stream().collect(Collectors.groupingBy(Question_reply::getIssueId));
issueReplies.forEach((k, v) -> {
//用户回答的选项
Set<String> userReplyOptionIds = v.stream().map(Question_reply::getRwid).collect(Collectors.toSet());
//正确答案
Optional<Question_issue> issueOptional = question.getIssues().stream().filter(x -> x.getIid().equals(k)).findFirst();
Set<String> correctOptionIds = issueOptional.map(x -> x.getWors().stream().filter(c -> c.getCorrect() != null && c.getCorrect()).map(z -> z.getWid()).collect(Collectors.toSet())).orElse(null);
if (userReplyOptionIds.equals(correctOptionIds)) {
sum.addAndGet(issueOptional.map(i -> i.getFraction()).orElse(0));
}
});
//查询之前的回答记录
int count = dao().count(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
QuestionUserScore questionUserScore = new QuestionUserScore();
questionUserScore.setQuestionId(questionId);
questionUserScore.setUserId(ShiroUtil.getUserId());
questionUserScore.setAnswerDate(new Date());
questionUserScore.setAnswerNum(count + 1);
questionUserScore.setScore(sum.get());
dao().insert(questionUserScore);
} else if (question.getCtMode() == 1) {
//每题的回答记录
QuestionRandomIssue randomIssue = dao().fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("displayDate", "=", DateUtil.today()));
List<String> issueIds = randomIssue.getIssueIds();
List<Question_reply> replies = dao().query(Question_reply.class, Cnd.where("issueId", "in", issueIds).and("qid", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
Map<String, List<Question_reply>> issueReplies = replies.stream().collect(Collectors.groupingBy(Question_reply::getIssueId));
issueReplies.forEach((k, v) -> {
//用户回答的选项
Set<String> userReplyOptionIds = v.stream().map(Question_reply::getRwid).collect(Collectors.toSet());
//正确答案
Optional<Question_issue> issueOptional = question.getIssues().stream().filter(x -> x.getIid().equals(k)).findFirst();
Set<String> correctOptionIds = issueOptional.map(x -> x.getWors().stream().filter(c -> c.getCorrect() != null && c.getCorrect()).map(z -> z.getWid()).collect(Collectors.toSet())).orElse(null);
if (userReplyOptionIds.equals(correctOptionIds)) {
sum.addAndGet(issueOptional.map(i -> i.getFraction()).orElse(0));
}
});
//查询之前的回答记录
int count = dao().count(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("displayDate", "=", DateUtil.today()));
QuestionUserScore questionUserScore = new QuestionUserScore();
questionUserScore.setQuestionId(questionId);
questionUserScore.setUserId(ShiroUtil.getUserId());
questionUserScore.setAnswerDate(new Date());
questionUserScore.setAnswerNum(count + 1);
questionUserScore.setScore(sum.get());
questionUserScore.setDisplayDate(DateUtil.parseDate(DateUtil.today()));
dao().insert(questionUserScore);
} else if (question.getCtMode() == 2) {
//每题的回答记录
QuestionRandomIssue randomIssue = dao().fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("displayDate", "=", DateUtil.today()).desc("num"));
List<String> issueIds = randomIssue.getIssueIds();
List<Question_reply> replies = dao().query(Question_reply.class, Cnd.where("issueId", "in", issueIds).and("qid", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
Map<String, List<Question_reply>> issueReplies = replies.stream().collect(Collectors.groupingBy(Question_reply::getIssueId));
issueReplies.forEach((k, v) -> {
//用户回答的选项
Set<String> userReplyOptionIds = v.stream().map(Question_reply::getRwid).collect(Collectors.toSet());
//正确答案
Optional<Question_issue> issueOptional = question.getIssues().stream().filter(x -> x.getIid().equals(k)).findFirst();
Set<String> correctOptionIds = issueOptional.map(x -> x.getWors().stream().filter(c -> c.getCorrect() != null && c.getCorrect()).map(z -> z.getWid()).collect(Collectors.toSet())).orElse(null);
if (userReplyOptionIds.equals(correctOptionIds)) {
sum.addAndGet(issueOptional.map(i -> i.getFraction()).orElse(0));
}
});
//同一天
//查询之前的回答记录
int count = dao().count(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("displayDate", "=", DateUtil.today()));
QuestionUserScore questionUserScore = new QuestionUserScore();
questionUserScore.setQuestionId(questionId);
questionUserScore.setUserId(ShiroUtil.getUserId());
questionUserScore.setAnswerDate(new Date());
questionUserScore.setAnswerNum(count + 1);
questionUserScore.setScore(sum.get());
questionUserScore.setDisplayDate(DateUtil.parseDate(DateUtil.today()));
dao().insert(questionUserScore);
}
//随机题库设为已完成
if (question.getCtMode() == 3) {
//常规模式下不需要判断次数
dao().update(QuestionRandomIssue.class, Chain.make("isFinish", 1), Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()));
} else if (question.getCtMode() == 1) {
//定时定题需要加上日期的条件
dao().update(QuestionRandomIssue.class, Chain.make("isFinish", 1), Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("displayDate", "=", DateUtil.today()));
} else if (question.getCtMode() == 2) {
//随机模式 要判断是否为同一天
QuestionRandomIssue randomIssue = dao().fetch(QuestionRandomIssue.class, Cnd.where("questionId", "=", questionId).and("userId", "=", ShiroUtil.getUserId()).and("displayDate", "=", DateUtil.today()).desc("num"));
randomIssue.setIsFinish(true);
dao().update(randomIssue, "isFinish");
}
}
}
@Override
public boolean isSameDay(String questionId) {
Question question = dao().fetch(Question.class, questionId);
return isSameDay(question.getStartTime(), question.getEndTime());
}
@Override
public boolean isSameDay(long startTimeTs, long endTimeTs) {
DateTime startTime = DateUtil.date(startTimeTs);
DateTime endTime = DateUtil.date(endTimeTs);
long betweenDay = DateUtil.betweenDay(startTime, endTime, true);
return betweenDay == 0;
}
} }
@@ -0,0 +1,154 @@
package io.v.nutz.task.job.question;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import io.v.nutz.question.model.Question;
import io.v.nutz.question.model.QuestionUserScore;
import io.v.nutz.question.model.QuestionWinner;
import io.v.nutz.question.service.QuestionService;
import io.v.nutz.sys.models.Sys_task;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* 问卷抽奖定时任务
*
* @author jug
* @date 2023/06/12
*/
@IocBean
public class QuestionRaffleJob implements Job {
@Inject
private Dao dao;
@Inject
private QuestionService questionService;
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
JobDataMap data = context.getJobDetail().getJobDataMap();
DateTime startAnswerDate = DateUtil.parseDateTime(data.getString("startAnswerDate"));
DateTime endAnswerDate = DateUtil.parseDateTime(data.getString("endAnswerDate"));
DateTime raffleTime = DateUtil.parseDate(data.getString("raffleTime"));
//抽奖分数
int raffleScore = data.getInt("raffleScore");
//中奖者人数
int raffleWinnerUserNum = data.getInt("raffleWinnerUserNum");
//问卷id
String questionId = data.getString("questionId");
Question question = dao.fetch(Question.class, questionId);
//已中奖的用户
List<QuestionWinner> winners = dao.query(QuestionWinner.class, Cnd.where("questionId", "=", questionId));
List<String> hasWinnUserIds = winners.stream().map(v -> v.getUserId()).collect(Collectors.toList());
//得分记录
List<QuestionUserScore> questionUserScores = dao.query(QuestionUserScore.class, Cnd.where("questionId", "=", questionId).andEX("userId", "not in", hasWinnUserIds));
//抽奖规则时间范围内的记录
List<QuestionUserScore> thisTimeQuestionUserScores = questionUserScores.stream().filter(s -> startAnswerDate.isBeforeOrEquals(DateUtil.date(s.getCreatedAt())) && endAnswerDate.isAfter(DateUtil.date(s.getCreatedAt()))).collect(Collectors.toList());
//本次中奖用户
List<String> winnerUserIds = new ArrayList<>();
//每个用户的分数
List<NutMap> userScoreMap = new ArrayList<>();
if (question.getCtMode() == 1) {
Map<String, List<QuestionUserScore>> userScoreListMap = thisTimeQuestionUserScores.stream().collect(Collectors.groupingBy(v -> v.getUserId()));
userScoreListMap.forEach((userId, v) -> {
Map<Date, List<QuestionUserScore>> userDayScoreListMap = v.stream().collect(Collectors.groupingBy(x -> x.getAnswerDate()));
AtomicInteger sumScore = new AtomicInteger();
userDayScoreListMap.forEach((day, v1) -> {
if (question.getCalcScoreMode() == 1) {
int score = v1.stream().mapToInt(s -> s.getScore()).max().orElse(0);
sumScore.addAndGet(score);
} else if (question.getCalcScoreMode() == 2) {
int maxAnswerNum = v1.stream().mapToInt(s -> s.getAnswerNum()).max().orElse(1);
Integer score = v1.stream().filter(s -> s.getAnswerNum() == maxAnswerNum).findFirst().map(s -> s.getScore()).orElse(0);
sumScore.addAndGet(score);
}
});
userScoreMap.add(NutMap.NEW().addv("userId", userId).addv("score", sumScore.get()));
});
} else if (question.getCtMode() == 2) {
if (questionService.isSameDay(question.getStartTime(), question.getEndTime())) {
thisTimeQuestionUserScores.stream().collect(Collectors.groupingBy(v -> v.getUserId(), Collectors.summingInt(v -> v.getScore()))).forEach((k, v) -> {
userScoreMap.add(NutMap.NEW().addv("userId", k).addv("score", v));
});
} else {
Map<String, List<QuestionUserScore>> userScoreListMap = thisTimeQuestionUserScores.stream().collect(Collectors.groupingBy(v -> v.getUserId()));
userScoreListMap.forEach((userId, v) -> {
Map<Date, List<QuestionUserScore>> userDayScoreListMap = v.stream().collect(Collectors.groupingBy(x -> x.getAnswerDate()));
AtomicInteger sumScore = new AtomicInteger();
userDayScoreListMap.forEach((day, v1) -> {
if (question.getCalcScoreMode() == 1) {
int score = v1.stream().mapToInt(s -> s.getScore()).max().orElse(0);
sumScore.addAndGet(score);
} else if (question.getCalcScoreMode() == 2) {
int maxAnswerNum = v1.stream().mapToInt(s -> s.getAnswerNum()).max().orElse(1);
Integer score = v1.stream().filter(s -> s.getAnswerNum() == maxAnswerNum).findFirst().map(s -> s.getScore()).orElse(0);
sumScore.addAndGet(score);
}
});
userScoreMap.add(NutMap.NEW().addv("userId", userId).addv("score", sumScore.get()));
});
}
} else if (question.getCtMode() == 3) {
Map<String, List<QuestionUserScore>> userScoreListMap = thisTimeQuestionUserScores.stream().collect(Collectors.groupingBy(v -> v.getUserId()));
userScoreListMap.forEach((userId, v) -> {
AtomicInteger sumScore = new AtomicInteger();
if (question.getCalcScoreMode() == 1) {
int score = v.stream().mapToInt(s -> s.getScore()).max().orElse(0);
sumScore.addAndGet(score);
} else if (question.getCalcScoreMode() == 2) {
int maxAnswerNum = v.stream().mapToInt(s -> s.getAnswerNum()).max().orElse(1);
Integer score = v.stream().filter(s -> s.getAnswerNum() == maxAnswerNum).findFirst().map(s -> s.getScore()).orElse(0);
sumScore.addAndGet(score);
}
userScoreMap.add(NutMap.NEW().addv("userId", userId).addv("score", sumScore.get()));
});
}
//待抽奖用户
List<String> readyRaffleUserId = userScoreMap.stream().filter(x -> x.getInt("score") >= raffleScore).map(v -> v.getString("userId")).collect(Collectors.toList());
// 随机打乱用户ID列表
Collections.shuffle(readyRaffleUserId);
if (readyRaffleUserId.size() >= raffleWinnerUserNum) {
winnerUserIds = readyRaffleUserId.subList(0, raffleWinnerUserNum);
} else {
winnerUserIds = readyRaffleUserId.subList(0, readyRaffleUserId.size());
}
List<QuestionWinner> questionWinners = winnerUserIds.stream().map(v -> {
QuestionWinner winner = new QuestionWinner();
winner.setQuestionId(questionId);
winner.setUserId(v);
winner.setWinDate(new Date());
Integer score = userScoreMap.stream().filter(x -> x.getString("userId").equals(v)).findFirst().map(x -> x.getInt("score", 0)).orElse(0);
winner.setScore(score);
return winner;
}).collect(Collectors.toList());
dao.insert(questionWinners);
dao.update(Sys_task.class, Chain.make("disabled", 1), Cnd.where("data", "like", "%" + raffleTime + "%").and("data", "like", "%" + questionId + "%"));
}
}
@@ -44,6 +44,7 @@ public class TrainEduAlbumController {
public Object doAdd(TrainEduAlbum trainEduAlbum) { public Object doAdd(TrainEduAlbum trainEduAlbum) {
trainEduAlbum.setUnionId(Vi.getUnionId()); trainEduAlbum.setUnionId(Vi.getUnionId());
trainEduAlbum.setUnitId(Vi.getUnit().getId()); trainEduAlbum.setUnitId(Vi.getUnit().getId());
trainEduAlbum.setDisabled(false);
dao.insert(trainEduAlbum); dao.insert(trainEduAlbum);
return null; return null;
} }
@@ -8,6 +8,7 @@ import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection; import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter; import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter;
import io.v.nutz.sys.models.Sys_file; import io.v.nutz.sys.models.Sys_file;
import io.v.nutz.sys.models.Sys_log; import io.v.nutz.sys.models.Sys_log;
import io.v.nutz.sys.models.Sys_user; import io.v.nutz.sys.models.Sys_user;
@@ -22,6 +23,7 @@ import org.nutz.dao.Cnd;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.dao.entity.Record; import org.nutz.dao.entity.Record;
import org.nutz.ioc.IocException; import org.nutz.ioc.IocException;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json; import org.nutz.json.Json;
@@ -40,6 +42,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -57,6 +61,9 @@ import java.util.List;
@Slf4j @Slf4j
public class FileServerController { public class FileServerController {
@Inject
private PropertiesProxy conf;
private static final List<String> IMGTYPES = new ArrayList<>() {{ private static final List<String> IMGTYPES = new ArrayList<>() {{
add("JPG"); add("JPG");
add("JPEG"); add("JPEG");
@@ -137,12 +144,17 @@ public class FileServerController {
response.setContentType("application/pdf"); response.setContentType("application/pdf");
ftpService.download(filepath, response.getOutputStream()); ftpService.download(filepath, response.getOutputStream());
} else if (OFFICETYPES.contains(suffix)) { } else if (OFFICETYPES.contains(suffix)) {
response.setHeader("Content-Disposition", "attachment;filename=" + new String((prefix + ".pdf").getBytes("utf-8"), "ISO8859-1")); /* response.setHeader("Content-Disposition", "attachment;filename=" + new String((prefix + ".pdf").getBytes("utf-8"), "ISO8859-1"));
response.setContentType("application/pdf"); response.setContentType("application/pdf");
String pdfPath = generatePDF(filepath, id + ".pdf"); String pdfPath = generatePDF(filepath, id + ".pdf");
assert pdfPath != null; assert pdfPath != null;
FileCopyUtils.copy(new FileInputStream(pdfPath), response.getOutputStream()); FileCopyUtils.copy(new FileInputStream(pdfPath), response.getOutputStream());
//ftpService.download(filepath, response.getOutputStream()); //ftpService.download(filepath, response.getOutputStream());*/
response.setHeader("Content-Disposition", "attachment;filename=" + new String((prefix + ".pdf").getBytes("utf-8"), "ISO8859-1"));
response.setContentType("application/pdf");
String pdfPath = generatePDF(filepath, id + ".pdf");
FileCopyUtils.copy(new FileInputStream(pdfPath), response.getOutputStream());
Files.delete(Path.of(pdfPath));
} else { } else {
response.setHeader("Content-Disposition", "attachment;filename=" + new String(fullFileName.getBytes("utf-8"), "ISO8859-1")); response.setHeader("Content-Disposition", "attachment;filename=" + new String(fullFileName.getBytes("utf-8"), "ISO8859-1"));
ftpService.download(filepath, response.getOutputStream()); ftpService.download(filepath, response.getOutputStream());
@@ -167,21 +179,20 @@ public class FileServerController {
*/ */
private String generatePDF(String sourcePath, String targetPath) { private String generatePDF(String sourcePath, String targetPath) {
try { try {
//文件扩展名
String extName = FileUtil.extName(sourcePath);
//将ftp文件下载到本地的临时文件路径
Path localSourcePath = Files.createTempFile(null, "." + extName);
FileOutputStream localOutPutStream = new FileOutputStream(localSourcePath.toFile());
ftpService.download(sourcePath, localOutPutStream);
File TEMPDIRECTORYFile = new File(TEMPDIRECTORY); //要转换的pdf本地临时路径
if (!TEMPDIRECTORYFile.exists()) { Path localPdfPath = Files.createTempFile(null, ".pdf");
TEMPDIRECTORYFile.mkdir(); this.convert(localSourcePath.toFile(), localPdfPath.toFile());
}
File tempSourceFile = new File("D:\\FTP\\" + sourcePath); //删除临时文件(docx,xlsx)
Files.deleteIfExists(localSourcePath);
//FileOutputStream tempSourceFileOutPutStream = new FileOutputStream(tempSourceFile); return localPdfPath.toString();
//ftpService.download(sourcePath, tempSourceFileOutPutStream);
File tempTargetFile = new File(TEMPDIRECTORY + targetPath);
this.convert(tempSourceFile, tempTargetFile);
return tempTargetFile.getCanonicalPath();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -199,13 +210,12 @@ public class FileServerController {
throw new NullPointerException(); throw new NullPointerException();
} }
if (targetFile.exists() && targetFile.length() == 0L) { String localIp = StrUtil.blankToDefault(conf.get("v.ip"), "127.0.0.1");
throw new NullPointerException(); OpenOfficeConnection connection = new SocketOpenOfficeConnection(localIp, 8100);
}
OpenOfficeConnection connection = new SocketOpenOfficeConnection();
connection.connect(); connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection); //此处如果是使用远程的openoffice服务 需要使用StreamOpenOfficeDocumentConverter
// DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
StreamOpenOfficeDocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);
converter.convert(sourceFile, targetFile); converter.convert(sourceFile, targetFile);
connection.disconnect(); connection.disconnect();
} catch (IocException var4) { } catch (IocException var4) {
@@ -342,14 +352,14 @@ public class FileServerController {
/** /**
* 下载 * 下载
* *
* @param filepath * @param id
* @param filename * @param filename
* @param response * @param response
*/ */
@At @At
@Ok("void") @Ok("void")
@RequiresAuthentication @RequiresAuthentication
public void download(String filepath, String filename, HttpServletResponse response, HttpServletRequest request) { public void download(String id, String filename, HttpServletResponse response, HttpServletRequest request) {
HashMap<String, Object> logMap = new HashMap<>(); HashMap<String, Object> logMap = new HashMap<>();
try { try {
String loginName = (String) ShiroUtil.getPrincipalProperty("loginname"); String loginName = (String) ShiroUtil.getPrincipalProperty("loginname");
@@ -361,9 +371,18 @@ public class FileServerController {
logMap.put("执行类", this.getClass().getName() + "#download"); logMap.put("执行类", this.getClass().getName() + "#download");
logMap.put("来源IP", Lang.getIP(request)); logMap.put("来源IP", Lang.getIP(request));
logMap.put("执行时间", DateUtil.now()); logMap.put("执行时间", DateUtil.now());
response.setContentType("application/octet-stream"); if (StrUtil.isBlank(filename)) {
response.setHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes("utf-8"), "ISO8859-1")); Sys_file sysFile = dao.fetch(Sys_file.class, Cnd.where("id", "=", id).or("filepath", "=", id));
ftpService.download(filepath, response.getOutputStream()); if (null == sysFile) {
log.error("下载文件不存在:id={}", id);
} else {
filename = sysFile.getFilename();
String filepath = sysFile.getFilepath();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes("utf-8"), "ISO8859-1"));
ftpService.download(filepath, response.getOutputStream());
}
}
logMap.put("请求结果", Result.success().toJsonString()); logMap.put("请求结果", Result.success().toJsonString());
logMap.put("执行结果", true); logMap.put("执行结果", true);
log.info(logMap.toString()); log.info(logMap.toString());
@@ -1,390 +0,0 @@
package io.v.nutz.zgfw.controller.lxy;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zgfw.model.lxy.Lxy_bm;
import io.v.nutz.zgfw.model.lxy.Lxy_grxx;
import io.v.nutz.zgfw.service.LxyBmService;
import io.v.nutz.zgfw.service.LxyGrxxService;
import io.v.nutz.zgfw.service.LxyHdService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
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.Strings;
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.ArrayList;
import java.util.List;
/**
* @Author: 1V
* @DateTime: 2020/8/28 9:21
* @Description: 院级工会统一报名
*/
@At("/platform/zgfw/lxy/ghbm")
@Ok("json")
@IocBean
@RequiresAuthentication
public class LxyGhbmController {
@Inject
private LxyHdService lxyHdService;
@Inject
private Vi vi;
@Inject
private LxyBmService lxyBmService;
@Inject
private SysUserService sysUserService;
@Inject
private LxyGrxxService lxyGrxxService;
@At("")
@Ok("beetl:/platform/zgfw/lxy/HdGhbm.html")
@RequiresPermissions("zgfw.lxy.ghbm")
public void index() {
}
@At
@ViReturn
public Object pageData(Integer year, String hdid, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
Sql sql = Sqls.create("SELECT\n" +
"\tmefp.*,\n" +
"\t(\n" +
"\tmefp.number - ( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt not in (2,4)) \n" +
"\t) remain,\n" +
"\t(\n" +
"\t( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt =5 ) \n" +
"\t) passnum,\n" +
"\t(\n" +
"\t( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt = 3 ) \n" +
"\t) reviewnum,\n" +
"\tun.unionname,\n" +
"\tun.unioncode,\n" +
"\thd.* \n" +
"FROM\n" +
"\tlxy_mefp mefp\n" +
"\tLEFT JOIN sys_union un ON mefp.ghid = un.id\n" +
"\tLEFT JOIN lxy_hd hd ON mefp.hdid = hd.id $condition");
Cnd cnd = Cnd.NEW();
cnd.and(new Static("now() < hd.bmjzsj"));
cnd.and("mefp.hdid", "=", hdid);
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
cnd.and(new Static("mefp.ghid in " + vi.getMangeUnionStr()));
//工会管理员查看分配名额大于0的
cnd.and("mefp.number", ">", 0);
}
if (year != null) {
cnd.and("YEAR(hdcjsj)", "=", year);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.desc("hdcjsj");
}
sql.setCondition(cnd);
return lxyHdService.listPage(pageNumber, pageSize, sql);
}
@At
@ViReturn
public Object getNotApply(String unionid, String hdid, String query, String[] checks) {
Sql sql = Sqls.create("""
SELECT
u.id,
u.sex,
u.mobile,
TIMESTAMPDIFF(
YEAR,
u.birthday,
CURDATE()) age,
u.username,
u.loginname,
unit.`name` unitname,
un.unionname\s
FROM
sys_user u
LEFT JOIN lxy_bm bm ON bm.userid = u.id\s
AND bm.hdid = @hdid
LEFT JOIN sys_unit unit ON u.unitid = unit.id
LEFT JOIN ry_rygl_gr ry ON ry.userid = u.id
LEFT JOIN sys_union un ON unit.unionid = un.id $condition
""").setParam("hdid", hdid).setParam("unionid", unionid);
Cnd cnd = Cnd.NEW();
cnd.and("member", "=", 1);
cnd.and("unit.unionid", "=", unionid);
cnd.and(new Static("u.id NOT IN ( SELECT bm.userid FROM lxy_bm bm WHERE bm.hdid = '" + hdid + "' ) "));
if (checks != null && checks.length > 0) {
for (String check : checks) {
if (check.equals("honer")) {
cnd.and(new Static("ry.zyxjsj is not null"));
}
if (check.equals("five")) {
cnd.and(new Static(" u.id not in (SELECT bm.userid from lxy_bm bm WHERE YEAR (NOW())- 5 < YEAR ( bm.bmsj ) )"));
}
}
}
sql.setCondition(cnd);
return lxyBmService.list(sql);
}
@At
@ViReturn
public Object getHasApply(String unionid, String hdid, String query, String[] checks) {
Sql sql = Sqls.create("""
SELECT
u.id,
u.loginname,
u.username,
u.unitname,
bm.bmzt,
TIMESTAMPDIFF(
YEAR,
u.birthday,
CURDATE()) age
FROM
lxy_bm bm
LEFT JOIN `user` u ON u.id = bm.userid
where bm.hdid = @hdid and u.unionid = @unionid ORDER BY bm.bmzt ASC
""").setParam("hdid", hdid).setParam("unionid", unionid);
return Result.success().addData(lxyBmService.list(sql));
}
@At
@ViReturn
public Object getUser(Integer sign, String unionid, String hdid, String query, String[] checks, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
Sql sql = Sqls.create("SELECT\n" +
"\tu.id,\n" +
"\tu.sex,u.mobile, TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) age,\n" +
"\tu.username,\n" +
"\tu.loginname,\n" +
"\tunit.`name` unitname,\n" +
"\tun.unionname \n" +
"FROM\n" +
"\tsys_user u\n" +
"\tLEFT JOIN lxy_bm bm ON bm.userid = u.id AND bm.hdid = '" + hdid + "'\n" +
"\tLEFT JOIN sys_unit unit ON u.unitid = unit.id\n" +
"\tLEFT JOIN ry_rygl_gr ry ON ry.userid = u.id\n" +
"\tLEFT JOIN sys_union un ON unit.unionid = un.id $condition");
Cnd cnd = Cnd.NEW();
cnd.and("unit.unionid", "=", unionid);
if (sign == 0) {
cnd.and(new Static("u.id not in (SELECT bm.userid from lxy_bm bm WHERE bm.hdid = '" + hdid + "')"));
}
if (checks.length > 0) {
for (String check : checks) {
if (check.equals("honer")) {
cnd.and(new Static("ry.zyxjsj is not null"));
}
if (check.equals("five")) {
cnd.and(new Static(" u.id not in (SELECT bm.userid from lxy_bm bm WHERE YEAR (NOW())- 5 < YEAR ( bm.bmsj ) )"));
}
}
}
if (Strings.isNotBlank(query)) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.orLike("u.username", query).orLike("u.loginname", query);
cnd.and(group);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
}
cnd.desc("bm.bmzt");
sql.setCondition(cnd);
Pagination pagination = lxyHdService.listPage(pageNumber, pageSize, sql);
return pagination;
}
@At
@ViReturn
public Object getNumberData(String unionid, String hdid) {
Sql sql = Sqls.create("SELECT\n" +
"\tun.unionname,\n" +
"\tmefp.number sum,\n" +
"\t( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt = 5) ybm,\n" +
"\t( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt in (1,3)) dsh ,\n" +
"\t( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt in (2,4)) btg ,\n" +
"\t(mefp.number - (SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid and bm.bmzt not in (2,4))) kxz\n" +
"FROM\n" +
"\tlxy_mefp mefp\n" +
"\tLEFT JOIN sys_union un ON mefp.ghid = un.id WHERE mefp.hdid=@hdid and mefp.ghid=@unionid").setParam("hdid", hdid).setParam("unionid", unionid);
Record record = lxyHdService.list(sql).get(0);
record.set("multiple", lxyBmService.list(Sqls.create("SELECT bm.userid id from lxy_bm bm WHERE bm.hdid = '" + hdid + "' AND bm.ghid = '" + unionid + "'")));
return record;
}
@At
@ViReturn
public Object bm(String hdid, String unionid, @Param("users[]") String[] users, boolean flag) {
List<Lxy_bm> lxyBms = lxyBmService.query(Cnd.where("ghid", "=", unionid).and("hdid", "=", hdid));
Trans.exec(() -> {
lxyBmService.clear(Cnd
.where("bmzt", "is", null)
.and("ghid", "=", unionid)
.and("hdid", "=", hdid));
for (String user : users) {
Lxy_bm bm = new Lxy_bm();
bm.setBmzt(flag ? 3 : null);
bm.setBmlx(1);
bm.setBmsj(DateUtil.getDate());
bm.setUserid(user);
bm.setHdid(hdid);
bm.setGhid(unionid);
lxyBmService.insert(bm);
}
if (Lang.isNotEmpty(users)) {
for (String user : users) {
if (flag) {
Sql sql = Sqls.create("SELECT u.loginname,u.username,u.mobile,TIMESTAMPDIFF(YEAR,u.birthday,CURDATE()) age,u.sex,u.position,u.personType,u.nation,u.idcard FROM sys_user u WHERE u.id = '" + user + "'");
List<Record> records = sysUserService.list(sql);
records.forEach(item -> {
Lxy_grxx lxy_grxx = new Lxy_grxx();
lxy_grxx.setLoginname(item.getString("loginname"));
lxy_grxx.setUsername(item.getString("username"));
lxy_grxx.setMobile(item.getString("mobile"));
lxy_grxx.setAge(item.getString("age"));
lxy_grxx.setSex(item.getString("sex"));
lxy_grxx.setZw(item.getString("position"));
lxy_grxx.setRsbz(item.getString("personType"));
lxy_grxx.setMz(item.getString("nation"));
lxy_grxx.setIdcard(item.getString("idcard"));
lxy_grxx.setChry(new ArrayList());
lxy_grxx.setUserid(user);
lxy_grxx.setHdid(hdid);
lxy_grxx.setGhid(unionid);
lxyGrxxService.insert(lxy_grxx);
});
}
}
}
});
return null;
}
@At
@ViReturn
public Object doEdit(String hdid, String unionid, String[] users) {
for (String userid : users) {
if (userid == null) {
return Result.success();
}
}
lxyBmService.clear(Cnd.where("hdid", "=", hdid).and("ghid", "=", unionid).and("bmlx", "=", 1));
lxyGrxxService.clear(Cnd.where("hdid", "=", hdid).and("ghid", "=", unionid));
for (String userid : users) {
Lxy_bm bm = new Lxy_bm();
bm.setBmzt(3);
bm.setBmlx(1);
bm.setBmsj(DateUtil.getDate());
bm.setUserid(userid);
bm.setHdid(hdid);
bm.setGhid(unionid);
lxyBmService.insert(bm);
Sql sql = Sqls.create("SELECT u.loginname,u.username,u.mobile,TIMESTAMPDIFF(YEAR,u.birthday,CURDATE()) age,u.sex,u.position,u.preparedBy,u.nation,u.idcard FROM sys_user u WHERE u.id = '" + userid + "'");
List<Record> records = sysUserService.list(sql);
records.forEach(item -> {
Lxy_grxx lxy_grxx = new Lxy_grxx();
lxy_grxx.setLoginname(item.getString("loginname"));
lxy_grxx.setUsername(item.getString("username"));
lxy_grxx.setMobile(item.getString("mobile"));
lxy_grxx.setAge(item.getString("age"));
lxy_grxx.setSex(item.getString("sex"));
lxy_grxx.setZw(item.getString("position"));
lxy_grxx.setRsbz(item.getString("preparedBy"));
lxy_grxx.setMz(item.getString("nation"));
lxy_grxx.setIdcard(item.getString("idcard"));
lxy_grxx.setChry(new ArrayList());
lxy_grxx.setUserid(userid);
lxy_grxx.setHdid(hdid);
lxy_grxx.setGhid(unionid);
lxyGrxxService.insert(lxy_grxx);
});
}
return null;
}
@At
public Object findBm(String ghId, String hdId) {
try {
Sql sql = Sqls.create("SELECT\n" +
"unit.`name` unitname,\n" +
"l.id,\n" +
"hd.id hdid,\n" +
"u.id uid,\n" +
"u.loginname,\n" +
"u.username,\n" +
"u.sex,\n" +
"u.mobile,\n" +
"TIMESTAMPDIFF(YEAR,u.birthday,CURDATE()) age,\n" +
"bm.bmzt,\n" +
"bm.ghid\n" +
"FROM lxy_bm bm\n" +
"LEFT JOIN lxy_hd hd ON hd.id = bm.hdid\n" +
"LEFT JOIN sys_user u ON u.id = bm.userid\n" +
"LEFT JOIN sys_unit unit ON u.unitid = unit.id\n" +
"LEFT JOIN Lxy_grxx l ON l.loginname = u.loginname \n" +
"WHERE bm.bmzt NOT IN (2,4,6) AND bm.hdid = @hdid \n" +
"AND bm.ghid = @ghid \n" +
"GROUP BY u.loginname\n" +
"ORDER BY bm.bmzt DESC");
sql.setParam("hdid", hdId);
sql.setParam("ghid", ghId);
List<Record> list = lxyBmService.list(sql);
return Result.success().addData(list);
} catch (Exception e) {
return Result.error();
}
}
}
@@ -1,137 +0,0 @@
package io.v.nutz.zgfw.controller.lxy;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.zgfw.service.LxyGrxxService;
import io.v.nutz.zgfw.service.LxyHdService;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
/**
* @author: Aaron
* @create: 2020-09-25 14:55
* @description: 疗休养活动统计
**/
@At("/platform/zgfw/lxy/hdtj")
@Ok("json")
@IocBean
@RequiresAuthentication
public class LxyHdTjController {
@Inject
private LxyHdService lxyHdService;
@Inject
private LxyGrxxService lxyGrxxService;
@Inject
private Vi vi;
@At("")
@Ok("beetl:/platform/zgfw/lxy/HdTj.html")
@RequiresPermissions("zgfw.lxy.hdtj")
public void index() {
}
@At
@ViReturn
public Object pageData(String hdid, String ghid, String searchKey, int pageNumber, int pageSize) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("SELECT gr.* ,u.unionname,u.unioncode,u.unitname unitname,u.unitcode FROM `lxy_grxx` gr \n" +
"LEFT JOIN lxy_bm bm ON bm.userid = gr.userid \n" +
"LEFT JOIN `user` u ON u.id=bm.userid $condition");
cnd.and(new Static("bm.bmzt = 5"));
cnd.and("gr.hdid", "=", hdid);
if (Strings.isNotBlank(ghid)) {
cnd.and("gr.ghid", "=", ghid);
}
if (Strings.isNotBlank(searchKey)) {
cnd.where().andLike("loginname", searchKey).orLike("username", searchKey);
}
cnd.groupBy("bm.userid");
cnd.asc("u.unioncode");
sql.setCondition(cnd);
return lxyGrxxService.listPage(pageNumber, pageSize, sql);
}
@At
@ViReturn
public Object getLxyHd(String year) {
return lxyHdService.list(Sqls.create("SELECT id,`name` FROM `lxy_hd` WHERE YEAR(hdcjsj) = @year ORDER BY hdcjsj DESC ").setParam("year", year));
}
@At
public void doExport(String hdid, String hdname, String ghid, HttpServletResponse response) throws IOException {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("SELECT gr.* ,u.unionname,u.unioncode,u.unitname unitname,u.unitcode FROM `lxy_grxx` gr \n" +
"LEFT JOIN lxy_bm bm ON bm.userid = gr.userid \n" +
"LEFT JOIN `user` u ON u.id=bm.userid $condition");
cnd.and(new Static("bm.bmzt = 5"));
cnd.and("gr.hdid", "=", hdid);
if (Strings.isNotBlank(ghid)) {
cnd.and("gr.ghid", "=", ghid);
}
cnd.groupBy("bm.userid");
cnd.asc("u.unionname").asc("u.unitcode").asc("gr.age");
sql.setCondition(cnd);
List<Record> list = lxyGrxxService.list(sql);
int i = 1;
for (Record r : list) {
r.set("index", i);
List<NutMap> chry = Json.fromJsonAsList(NutMap.class, r.getString("chry"));
for (NutMap map : chry) {
r.set("rych", (r.getString("rych") == null ? "" : r.getString("rych")) + " " + map.getString("shry"));
}
i++;
}
// HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
// Configure config = Configure.newBuilder().bind("list", policy).build();
HashMap<String, Object> map = new HashMap<>();
map.put("hdmc", hdname);
map.put("mapList", list);
String fileName = "疗休养人员名单汇总表.xls";
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO8859-1"));
TemplateExportParams params = new TemplateExportParams(
"templates/lxy/lxyrymd.xls");
// Workbook workbook = ExcelExportUtil.exportExcel(params, map);
// workbook.write(response.getOutputStream());
Workbook workbook = ExcelExportUtil.exportExcel(params, map);
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.close();
// String fileName = "疗休养人员名单汇总表";
// response.addHeader("Content-Type", "application/octet-stream");
// response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\".docx;filename*=UTF-8''" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1"));
// InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/lxyrymd.docx");
// XWPFTemplate.compile(inputStream, config).render(map, response.getOutputStream());
// inputStream.close();
}
}
@@ -1,197 +0,0 @@
package io.v.nutz.zgfw.controller.lxy;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.base.service.BaseService;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zgfw.model.lxy.Lxy_grxx;
import io.v.nutz.zgfw.service.LxyBmService;
import io.v.nutz.zgfw.service.LxyHdService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
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.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.trans.Trans;
/**
* @Author: 1V
* @DateTime: 2020/8/28 9:21
* @Description: 校工会审核
*/
@At("/platform/zgfw/lxy/xghsh")
@Ok("json")
@IocBean
@RequiresAuthentication
public class LxyXghshController {
@Inject
private LxyHdService lxyHdService;
@Inject
private LxyBmService lxyBmService;
@Inject
private BaseService baseService;
@Inject
private Vi vi;
@At("")
@Ok("beetl:/platform/zgfw/lxy/HdXghsh.html")
@RequiresPermissions("zgfw.lxy.xghsh")
public void index() {
}
@At
@ViReturn
public Object pageData(String hdid, Integer year, Integer isAudit, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
Sql sql = Sqls.create("""
SELECT
mefp.*,
un.unionname,
un.unioncode,
hd.*,
(mefp.number - ( SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt NOT IN (2,4)) ) remain,
(SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt = 3) dsh,
(SELECT GROUP_CONCAT(u.username) FROM lxy_bm bm LEFT JOIN `user` u on u.id=bm.userid WHERE bm.hdid=@hdid AND bm.ghid=mefp.ghid AND bm.bmzt = 5) username ,
(SELECT GROUP_CONCAT(DISTINCT concat(u.username,'(',u.mobile,')') ) FROM `user` u LEFT JOIN sys_user_role ur ON u.id = ur.userId WHERE u.unionid = mefp.ghid AND ur.roleId = @roleId ) fglyname
FROM
lxy_mefp mefp
LEFT JOIN sys_union un ON mefp.ghid = un.id
LEFT JOIN lxy_bm bm ON bm.ghid = mefp.ghid
LEFT JOIN sys_user u ON u.id = bm.userid AND bm.bmzt IN (3,5)
LEFT JOIN lxy_hd hd ON mefp.hdid = hd.id
$condition
""").setParam("hdid", hdid).setParam("roleId", Roles.UNION_MANGER);
Cnd cnd = Cnd.NEW();
cnd.and(new Static("now()<hd.bmjzsj"));
cnd.and("mefp.number", ">", 0);
cnd.and("mefp.hdid", "=", hdid);
cnd.and(new Static("(select count(1) from lxy_bm lb where lb.hdid = '" + hdid + "' and lb.ghid = mefp.ghid AND lb.bmzt is NOT null) > 0 "));
if (isAudit == 2) {
cnd.and(new Static("(SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt = 3 )=0"));
} else if (isAudit == 3) {
cnd.and(new Static("(SELECT count( 1 ) FROM lxy_bm bm WHERE bm.hdid = mefp.hdid AND bm.ghid = mefp.ghid AND bm.bmzt = 3 )>0"));
}
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
cnd.and(new Static("mefp.ghid in " + vi.getMangeUnionStr()));
}
if (year != null) {
cnd.and("YEAR(hdkssj)", "=", year);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.desc("hdcjsj");
cnd.desc("username");
}
cnd.groupBy(" mefp.ghid ");
sql.setCondition(cnd);
return lxyHdService.listPage(pageNumber, pageSize, sql);
}
/**
* 查询通过审核及待校工会审核的人员
*
* @param ghId
* @param hdId
* @param pageNumber
* @param pageSize
* @return
*/
@At
public Object findBm(String ghId, String hdId, Integer pageNumber, Integer pageSize) {
try {
Sql sql = Sqls.create("SELECT\n" +
"l.id,\n" +
"hd.id hdid,\n" +
"u.id uid,\n" +
"u.loginname,\n" +
"u.username,\n" +
"u.unitname,\n" +
"u.unionname,\n" +
"u.sex,\n" +
"u.mobile,\n" +
"TIMESTAMPDIFF(YEAR,u.birthday,CURDATE()) age,\n" +
"bm.bmzt,\n" +
"bm.ghid\n" +
"FROM lxy_bm bm\n" +
"LEFT JOIN lxy_hd hd ON hd.id = bm.hdid\n" +
"LEFT JOIN Lxy_grxx l ON l.userid = bm.userid\n" +
"LEFT JOIN `user` u ON u.id = bm.userid \n" +
"WHERE bm.bmzt IN (3,4,5) AND bm.hdid = @hdid \n" +
"AND bm.ghid = @ghid \n" +
"GROUP BY u.username \n" +
"ORDER BY bm.bmzt ASC");
sql.setParam("hdid", hdId);
sql.setParam("ghid", ghId);
// List<Record> list = lxyBmService.list(sql);
Pagination pagination = lxyBmService.listPage(pageNumber, pageSize, sql);
return Result.success().addData(pagination);
} catch (Exception e) {
return Result.error();
}
}
@At
@ViReturn
public Object sh(String hdid, String ghid, Integer bmzt, String[] users) {
for (String user : users) {
lxyBmService.update(Chain.make("bmzt", bmzt), Cnd.where("ghid", "=", ghid).and("hdid", "=", hdid).and("userid", "=", user));
}
return null;
}
@At
@ViReturn
public Object grsh(String hdid, String ghid, Integer bmzt, String userid) {
lxyBmService.update(Chain.make("bmzt", bmzt), Cnd.where("ghid", "=", ghid).and("hdid", "=", hdid).and("userid", "=", userid));
return null;
}
@At
@ViReturn
public Object yjSh(NutMap[] maps) {
for (NutMap map : maps) {
lxyBmService.update(Chain.make("bmzt", 5), Cnd.where("ghid", "=", map.get("ghid")).and("hdid", "=", map.get("hdid")).and("bmzt", "=", 3));
}
return null;
}
@At
@ViReturn
public Object doDelete(String id, String unionid, String userid, String hdid) {
Trans.exec(() -> {
lxyBmService.clear(Cnd.where("userid", "=", userid).and("hdid", "=", hdid).and("ghid", "=", unionid));
baseService.dao().delete(Lxy_grxx.class, id);
});
return null;
}
}
@@ -1,104 +0,0 @@
package io.v.nutz.zgfw.model.lxy;
import org.nutz.dao.entity.annotation.*;
/**
* @Author: 1V
* @DateTime: 2020/8/27 9:11
* @Description: 疗休养报名
*/
@Table("Lxy_bm")
public class Lxy_bm {
@Column
@Name
@Comment("id")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("活动id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String hdid;
@Column
@Comment("用户id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userid;
@Column
@Comment("工会id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String ghid;
@Column
@Comment("报名时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String bmsj;
@Column
@Comment("报名状态(1.待分工会审核 2.分工会审核不通过 3.待校工会审核 4 校工会审核不通过 5 报名成功 6 待填写个人资料)")
@ColDefine(type = ColType.INT)
private Integer bmzt;
@Column
@Comment("报名类型(1.分工会统一报名 2.个人报名)")
@ColDefine(type = ColType.INT)
private Integer bmlx;
public Integer getBmlx() {
return bmlx;
}
public void setBmlx(Integer bmlx) {
this.bmlx = bmlx;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getHdid() {
return hdid;
}
public void setHdid(String hdid) {
this.hdid = hdid;
}
public String getGhid() {
return ghid;
}
public void setGhid(String ghid) {
this.ghid = ghid;
}
public String getBmsj() {
return bmsj;
}
public void setBmsj(String bmsj) {
this.bmsj = bmsj;
}
public Integer getBmzt() {
return bmzt;
}
public void setBmzt(Integer bmzt) {
this.bmzt = bmzt;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 468 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

@@ -19,7 +19,8 @@ const initTableMixins = {
totalCount: 0, totalCount: 0,
pageOrderName: "", pageOrderName: "",
pageOrderBy: "" pageOrderBy: ""
} },
guavaIndex: 'index',
} }
}, },
filters: { filters: {
@@ -121,6 +122,15 @@ const initTableMixins = {
title: '错误', title: '错误',
message: msg message: msg
}); });
},
toggleFullScreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
} }
} }
} }
@@ -12,10 +12,14 @@
</template> </template>
<template v-else> <template v-else>
<svg aria-hidden="true"> <svg aria-hidden="true">
<use :xlink:href="APP_DOMAIN + '/file_server/fileStreamPreview?id=' + file.id"></use> <!-- <use :xlink:href="APP_DOMAIN + '/file_server/fileStreamPreview?id=' + file.id"></use>-->
<use
:xlink:href="wpUploadFileShowResolving.getFileItemShowIcon(resolvingShowByFileName(file.filename), file.filepath, true)"></use>
</svg> </svg>
</template> </template>
<div :title="file.filename" class="viewFileName">{{ file.filename }}</div> <div :title="file.filename" class="viewFileName" title="点击下载" @click.stop="downLoadFile(file)">
<i class="el-icon-download"></i> {{file.filename }}
</div>
</div> </div>
</div> </div>
@@ -692,6 +696,9 @@ module.exports = {
preview(filename, id) preview(filename, id)
} }
}, },
downLoadFile({id, filename}) {
window.open('/file_server/download?id=' + id)
}
}, },
created() { created() {
this.updateFileList(this.files) this.updateFileList(this.files)
@@ -721,11 +728,12 @@ module.exports = {
position: relative; position: relative;
display: flex; display: flex;
width: 100%; width: 100%;
max-height: 256px; /*max-height: 256px;*/
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
overflow-y: auto; /*overflow-y: auto;*/
overflow-x: hidden; /*overflow-x: hidden;*/
/*height: 150px;*/
} }
.viewFileItem { .viewFileItem {
@@ -736,7 +744,7 @@ module.exports = {
transition: all 500ms; transition: all 500ms;
border-radius: 5px; border-radius: 5px;
cursor: pointer; cursor: pointer;
margin-bottom: 10px; /*margin-bottom: 10px;*/
} }
.viewFileItem:hover { .viewFileItem:hover {
+52 -28
View File
@@ -75,19 +75,19 @@ layout("/mobile/platform.html"){
<div class="user_info"> <div class="user_info">
<van-row style="height: 200px"> <van-row style="height: 200px">
<van-image <van-image
width="100%"
height="200px" height="200px"
src="/back2.png" src="/back2.png"
width="100%"
></van-image> ></van-image>
</van-row> </van-row>
<van-row class="user_avatar" style="height: 80px"> <van-row class="user_avatar" style="height: 80px">
<van-col span="6" class="text-center"> <van-col class="text-center" span="6">
<van-image <van-image
:src="avatar"
height="70"
round round
width="70" width="70"
height="70"
:src="avatar"
></van-image> ></van-image>
</van-col> </van-col>
<van-col span="18"> <van-col span="18">
@@ -99,7 +99,8 @@ layout("/mobile/platform.html"){
${@shiro.getPrincipalProperty('loginname')} ${@shiro.getPrincipalProperty('loginname')}
</span> </span>
</div> </div>
<div class="van-ellipsis" style="height: 40px;line-height: 40px;font-size: 14px;color: #969799"> <div class="van-ellipsis"
style="height: 40px;line-height: 40px;font-size: 14px;color: #969799">
<!--#if(@shiro.getPrincipalProperty('union')!=null){#--> <!--#if(@shiro.getPrincipalProperty('union')!=null){#-->
${@shiro.getPrincipalProperty('union').getUnionname()} ${@shiro.getPrincipalProperty('union').getUnionname()}
<!--#}#--> <!--#}#-->
@@ -109,23 +110,24 @@ layout("/mobile/platform.html"){
</div> </div>
<div v-if="paramType === '会员管理'"> <div v-if="paramType === '会员管理'">
<div v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('public')||@shiro.hasRole('H01')}" <div class="van-sidebar-item van-sidebar-item--select"
class="van-sidebar-item van-sidebar-item--select"> v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('public')||@shiro.hasRole('H01')}">
会员管理 会员管理
</div> </div>
<van-grid :column-num="3" :border="false"> <van-grid :border="false" :column-num="3">
<van-grid-item v-if="${@shiro.hasRole('H01')}" url="/mobile/member/detail"> <van-grid-item url="/mobile/member/detail" v-if="${@shiro.hasRole('H01')}">
<image src="/assets/mobile/icon/member/da.png"></image> <image src="/assets/mobile/icon/member/da.png"></image>
<span class="icon_text"> 会员档案</span> <span class="icon_text"> 会员档案</span>
</van-grid-item> </van-grid-item>
<van-grid-item v-if="${@shiro.lacksRole('H01')}" url="/mobile/member/apply"> <van-grid-item url="/mobile/member/apply" v-if="${@shiro.lacksRole('H01')}">
<image src="/assets/mobile/icon/member/apply.png"></image> <image src="/assets/mobile/icon/member/apply.png"></image>
<span class="icon_text"> 申请入会</span> <span class="icon_text"> 申请入会</span>
</van-grid-item> </van-grid-item>
<van-grid-item v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('H04')||@shiro.hasRole('A06')}" <van-grid-item
url="/mobile/member/audit"> url="/mobile/member/audit"
v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('H04')||@shiro.hasRole('A06')}">
<image src="/assets/mobile/icon/member/audit.png"></image> <image src="/assets/mobile/icon/member/audit.png"></image>
<span class="icon_text"> 会员审核</span> <span class="icon_text"> 会员审核</span>
</van-grid-item> </van-grid-item>
@@ -145,32 +147,33 @@ layout("/mobile/platform.html"){
民主管理 民主管理
</div> </div>
<van-grid <van-grid
v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('tamange')||@shiro.hasRole('jdhdbt01')||@shiro.hasRole('jdhdb01') || @shiro.hasRole('jdh12')}" :border="false"
:border="false" :column-num="3"> :column-num="3"
<van-grid-item v-if="${@shiro.hasRole('jdhdb01')}" v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('tamange')||@shiro.hasRole('jdhdbt01')||@shiro.hasRole('jdhdb01') || @shiro.hasRole('jdh12')}">
url="/platform/mobile/proposal/compose"> <van-grid-item url="/platform/mobile/proposal/compose"
v-if="${@shiro.hasRole('jdhdb01')}">
<image src="/assets/mobile/icon/proposal/myProposal.png"></image> <image src="/assets/mobile/icon/proposal/myProposal.png"></image>
<span class="icon_text">个人提案阅览</span> <span class="icon_text">个人提案阅览</span>
</van-grid-item> </van-grid-item>
<van-grid-item v-if="${@shiro.hasRole('jdhdb01')}" <van-grid-item url="/platform/mobile/proposal/seconded"
url="/platform/mobile/proposal/seconded"> v-if="${@shiro.hasRole('jdhdb01')}">
<image src="/assets/mobile/icon/proposal/fy.png"></image> <image src="/assets/mobile/icon/proposal/fy.png"></image>
<span class="icon_text">附议提案</span> <span class="icon_text">附议提案</span>
</van-grid-item> </van-grid-item>
<van-grid-item <van-grid-item
v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('tamange')||@shiro.hasRole('jdhdbt01')}" url="/platform/mobile/proposal/delegation"
url="/platform/mobile/proposal/delegation"> v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('tamange')||@shiro.hasRole('jdhdbt01')}">
<image style="width: 59px" src="/assets/mobile/icon/proposal/tz.png"></image> <image src="/assets/mobile/icon/proposal/tz.png" style="width: 59px"></image>
<span class="icon_text">团长审议</span> <span class="icon_text">团长审议</span>
</van-grid-item> </van-grid-item>
<van-grid-item v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('tamange')}" <van-grid-item url="/platform/mobile/proposal/integrated"
url="/platform/mobile/proposal/integrated"> v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('tamange')}">
<image src="/assets/mobile/icon/proposal/search.png"></image> <image src="/assets/mobile/icon/proposal/search.png"></image>
<span class="icon_text">提案查询</span> <span class="icon_text">提案查询</span>
</van-grid-item> </van-grid-item>
<van-grid-item v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('tamange')}" <van-grid-item url="/mobile/proposal/delegate/index"
url="/mobile/proposal/delegate/index"> v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('tamange')}">
<image src="/assets/mobile/icon/proposal/cx.png"></image> <image src="/assets/mobile/icon/proposal/cx.png"></image>
<span class="icon_text">代表查询</span> <span class="icon_text">代表查询</span>
</van-grid-item> </van-grid-item>
@@ -284,6 +287,26 @@ layout("/mobile/platform.html"){
</van-grid-item> </van-grid-item>
</van-grid> </van-grid>
</van-row> </van-row>
<van-row v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('H01')}">
<div class="van-sidebar-item van-sidebar-item--select">
会议管理
</div>
<van-grid :border="false" :column-num="3">
<van-grid-item url="/mobile/meeting/mine/myMeeting"
v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('jdhdb01')||@shiro.hasRole('H01')}">
<image src="/assets/mobile/icon/meeting/会议(我的会议).png"></image>
<span class="icon_text">我的会议</span>
</van-grid-item>
<van-grid-item url="/mobile/meeting/audit"
v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('A06')||@shiro.hasRole('jdhdbt01')}">
<image src="/assets/mobile/icon/meeting/会议(会议审核).png"></image>
<span class="icon_text">会议审核</span>
</van-grid-item>
</van-grid>
</van-row>
</div> </div>
<div v-if="paramType === '福利慰问'"> <div v-if="paramType === '福利慰问'">
@@ -291,7 +314,8 @@ layout("/mobile/platform.html"){
职工慰问 职工慰问
</div> </div>
<van-grid :border="false" :column-num="3"> <van-grid :border="false" :column-num="3">
<template v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('H04')||@shiro.hasRole('H01')}"> <template
v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('H04')||@shiro.hasRole('H01')}">
<van-grid-item url="/mobile/condolence/apply/for"> <van-grid-item url="/mobile/condolence/apply/for">
<image src="/assets/mobile/icon/condolence/apply.png"></image> <image src="/assets/mobile/icon/condolence/apply.png"></image>
<span class="icon_text">慰问申请</span> <span class="icon_text">慰问申请</span>
@@ -303,8 +327,8 @@ layout("/mobile/platform.html"){
</van-grid-item> </van-grid-item>
</template> </template>
<van-grid-item <van-grid-item
v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('H04')||@shiro.hasRole('A06')||@shiro.hasRole('xghkj')}" url="/mobile/condolence/audit"
url="/mobile/condolence/audit"> v-if="${@shiro.hasRole('sysadmin')||@shiro.hasRole('H04')||@shiro.hasRole('A06')||@shiro.hasRole('xghkj')}">
<image src="/assets/mobile/icon/condolence/audit.png"></image> <image src="/assets/mobile/icon/condolence/audit.png"></image>
<span class="icon_text">慰问审核</span> <span class="icon_text">慰问审核</span>
</van-grid-item> </van-grid-item>
@@ -0,0 +1,504 @@
<!--#
layout("/mobile/platform.html"){
#-->
<style>
.van-index-bar__sidebar {
display: none;
}
.van-doc-card {
margin: 14px;
padding: 12px 12px 12px 12px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 8px 12px #ebedf0;
line-height: 20px;
font-size: 13px;
position: relative;
}
.van-divider {
margin: 6px 0 6px 0px;
border-color: lightgray;
}
.van-button--small {
border-radius: revert;
width: 40%;
height: 30px;
}
.van-col {
line-height: 20px;
}
.title_span {
font-size: 16px;
font-weight: bold;
position: absolute;
left: -1px;
top: 11px;
color: #1867b0;
}
.title {
font-size: 13px;
font-weight: bold;
flex: 1;
overflow: hidden;
white-space: nowrap;
}
.cus_overflow {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.showMore {
color: #1867b0;
}
.cus_popup {
width: 70%;
height: 50%;
/*border-radius: 10px;*/
padding: 10px 14px;
font-size: 15px;
/*background-color: #E5E7E9;
background-image: url("https://www.transparenttextures.com/patterns/green-cup.png");*/
}
.cus_icon {
z-index: 10000;
color: white;
font-size: 35px;
position: fixed;
top: 81%;
left: 44%;
}
.userPopup {
height: 80%;
background-color: #f6f7f9;
font-size: 14px;
}
.van-row div {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.firstName {
width: 45px;
background-color: lightgrey;
border-radius: 45px;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
color: white;
}
.content {
height: 84%;
overflow: auto;
}
.van-dialog__header {
padding-top: 8px;
}
.van-dialog__confirm {
color: #1867b0;
}
.van-field__label {
width: 5em;
}
.cus_cell {
padding: 4px 0px;
font-size: 12px;
}
.van-checkbox-group {
max-height: 260px;
overflow-y: auto;
margin-top: 6px;
}
.unit {
display: inline-block;
max-width: 160px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
position: absolute;
}
.cus_button {
border-top-right-radius: 16px;
border-bottom-left-radius: 16px;
height: 26px;
}
.audit_icon {
font-size: 24px;
position: absolute;
font-weight: bolder;
right: 0;
}
.van-dropdown-menu__item {
flex: auto;
}
</style>
<div id="app" v-cloak>
<m-page-loading v-if="mLoading"></m-page-loading>
<!--top栏-->
<van-nav-bar
@click-left="history.go(-1)"
fixed
left-arrow
placeholder
safe-area-inset-top
title="会议请假审核"
></van-nav-bar>
<!--筛选框-->
<div class="search-fixed">
<van-search
@search="doSearch"
maxlength="10"
placeholder="请输入会议名称、会议地点进行查询"
shape="round"
v-model="pageForm.searchKeyword"
>
</van-search>
<van-dropdown-menu>
<van-dropdown-item :options="meetingTimeList" @change="doSearch"
v-model="pageForm.meetingTime"></van-dropdown-item>
<van-dropdown-item :options="typeList" @change="doSearch"
v-model="pageForm.typeId"></van-dropdown-item>
</van-dropdown-menu>
</div>
<!--列表-->
<div style="margin-top: 116px">
<van-list
:finished="finished"
:finished-text="tableData.length>0?'没有更多了':''" :immediate-check="false"
@load="onLoad"
v-model="loading">
<div class="van-doc-card" v-for="o in tableData">
<div @click="openView(o.id, o.modulename)">
<div style="display: flex; justify-content: space-between">
<div style="width: 70%">
<div class="van-ellipsis title">
<span class="title_span">|</span>
<span>{{o.meetingname}}</span>
</div>
<div style="color: grey">{{o.location}}</div>
</div>
<div style="color: #1867b0;">
{{o.meetingtypename}}
</div>
</div>
<div style="margin-top: 10px">
<van-row>
<span style="color: grey">会议时间:</span>
{{o.starttime}}
<!--<van-col span="12"><span style="color: grey">结束时间:</span></van-col>-->
</van-row>
<van-row>
<!--<van-col span="12">{{o.endtime}}</van-col>-->
</van-row>
</div>
<div style="display: flex; justify-content: space-between; margin-top: 8px;">
<div class="cus_overflow" style="line-height: 20px; width: 83%">
<span style="color: grey">会议描述:</span>
{{o.meetingdescription}}
</div>
<span @click.stop="desc = o.meetingdescription; popupShow = true" class="showMore">查看更多</span>
</div>
<van-divider></van-divider>
<div style="display: flex; justify-content: flex-end; margin-top: 4px">
<div>
<van-button @click.stop="getAuditList(o)" class="cus_button"
color="#1867b0" size="small" style="margin-right: 8px; width: auto;"
type="primary">已审{{o.audit}}
</van-button>
<van-button @click.stop="openView(o.id, o.modulename)" class="cus_button"
color="#1867b0" size="small" style="margin-right: 8px; width: auto;"
type="primary">未审{{o.no_audit}}
</van-button>
</div>
</div>
</div>
</div>
</van-list>
<van-empty
class="custom-image"
description="暂无数据"
image="/none.svg"
v-if="mLoading==false&&tableData.length==0"
></van-empty>
</div>
<!--弹出框-->
<van-popup class="cus_popup" v-model:show="popupShow">
<pre style="margin: 0; white-space: break-spaces">{{desc}}</pre>
</van-popup>
<van-icon @click="popupShow = false" class="cus_icon" name="close" v-if="popupShow"></van-icon>
<!--审核人员-->
<van-action-sheet :title="queryType === 'notAudit' ? '请假人员列表' : '请假人员列表'" @close="popClose" class="userPopup"
v-model:show="userShow">
<div class="content">
<div class="van-doc-card" v-for="(item, i) in userList">
<div style="display: flex; justify-content: space-between">
<div style="width: 80%">
<!--<span>{{moment(item.startTime).format('YYYY-MM-DD HH:mm') + ' ~ ' + moment(item.endTime).format('YYYY-MM-DD HH:mm')}}</span>-->
<span>{{'会议时间:' + moment(item.startTime).format('YYYY-MM-DD HH:mm')}}</span>
</div>
<div v-if="queryType === 'notAudit'">
<span @click="checkAll(i)">全选</span>
<span @click="toggleAll(i)" style="margin-left: 4px">反选</span>
</div>
</div>
<div style="margin-top: 4px">
<van-row>
<van-col span="24">
会议名称:
<van-tag size="medium" type="primary">{{item.timePeriodName}}</van-tag>
</van-col>
</van-row>
</div>
<van-checkbox-group ref="checkboxGroup" v-if="item.users !== null" v-model="result">
<van-cell-group>
<van-cell
:key="obj.id"
@click="toggle(i, index)" class="cus_cell"
clickable
v-for="(obj, index) in item.users">
<span style="display: inline-block; width: 40px">{{obj.username}}</span>
<span style="display: inline-block; width: 20px">{{obj.sex}}</span>
<span style="display: inline-block; width: 60px">{{obj.loginname}}</span>
<span class="unit">{{obj.unitname}}</span>
<van-icon class="audit_icon" color="green" name="passed"
v-if="queryType === 'hasAudit' && obj.auditState === true"></van-icon>
<van-icon class="audit_icon" color="grey" name="close"
v-if="queryType === 'hasAudit' && obj.auditState === false"></van-icon>
<template #right-icon v-if="queryType === 'notAudit'">
<van-checkbox :name="obj.id" ref="checkboxes"></van-checkbox>
</template>
</van-cell>
</van-cell-group>
</van-checkbox-group>
<div style="margin-top: 4px; text-align: center" v-else>暂无请假人员</div>
</div>
<div style="display: flex; justify-content: space-evenly; position: fixed; bottom: 56px; width: 95%"
v-if="queryType === 'notAudit'">
<van-button @click="audit('many', 'reject')" color="#ff976a" size="small" style="height: 38px">驳回
</van-button>
<van-button @click="audit('many', 'pass')" color="#1867b0" size="small" style="height: 38px">通过
</van-button>
</div>
<div style="display: flex; justify-content: space-evenly; position: fixed; bottom: 10px; width: 95%"
v-if="queryType === 'notAudit'">
<van-button @click="audit('all', 'reject')" color="#ff976a" size="small" style="height: 38px">一键全部驳回
</van-button>
<van-button @click="audit('all', 'pass')" color="#1867b0" size="small" style="height: 38px">一键全部通过
</van-button>
</div>
</div>
</van-action-sheet>
<!--审核弹框-->
<van-dialog @confirm="auditDo" show-cancel-button title="温馨提示" v-model:show="auditShow">
<div style="padding-top: 8px; text-align: center; font-size: 14px; color: #646566">{{str}}</div>
<van-divider style="margin: 12px 0 1px 0px;"></van-divider>
<van-field
autosize
label="审核意见:"
maxlength="50"
placeholder="请输入审核意见"
rows="2"
show-word-limit
type="textarea"
v-model="reason"
></van-field>
</van-dialog>
</div>
<script>
<!--# include("/platform/meeting/includeJs/meetingUtil.js"){} #-->
const meetUtil = new meetingUtil()
const vue = new Vue({
el: '#app',
mixins: [mobileMixins],
data() {
return {
desc: '',
list: ['a', 'b'],
result: [],
reason: '',
auditShow: false,
popupShow: false,
userShow: false,
userList: [],
userClickList: [],
str: '',
type: '',
auditType: '',
queryType: '',
typeList: [],
meetingTimeList: [{text: '全部时间', value: null}, {text: '即将开始', value: 0}, {text: '已结束', value: 1}],
}
},
methods: {
async getAuditList(o) {
this.queryType = 'hasAudit'
const resp = await $.post('/mobile/meeting/audit/getLeaveUser', {
meetingId: o.id,
auditType: 'hasAudit',
})
if (resp.code === 0) {
this.userList = resp.data
this.userList.forEach(item => {
if (item.users && item.users.length > 1) {
item.users.sort((a, b) => {
return b.auditState - a.auditState
})
}
})
this.userShow = true
}
},
checkAll(i) {
this.$refs.checkboxGroup[i].children.forEach(item => item.toggle(true))
},
toggleAll(i) {
this.$refs.checkboxGroup[i].children.forEach(item => item.toggle())
},
toggle(i, index) {
if (i > 0) {
let length = 0
for (let m = 0; m < i; m++) {
length += this.userList[m].users.length
}
index = length + index
}
this.$refs.checkboxes[index].toggle();
},
async auditDo() {
let idList = this.result
if (this.type === 'all') {
this.userList.forEach(item => {
if (item.users !== null && item.users !== undefined) {
idList = idList.concat(item.users.map(o => o.id))
}
})
}
const resp = await $.post('/mobile/meeting/audit/audit', {
tpuIds: JSON.stringify(idList),
auditOpinion: this.reason,
isPass: this.auditType === 'pass'
})
if (resp.code === 0) {
this.doSearch()
}
vant.Toast(resp.msg)
this.userShow = false
},
audit(type, auditType) {
this.type = type
this.auditType = auditType
if (type === 'many' && this.result.length === 0) {
vant.Toast('请先选择人员')
return
}
this.str = type === 'many' ? '您选择了' + this.result.length + '个人,请确认您的选择' : '您确定要一键全部审核吗?'
this.reason = auditType === 'pass' ? '同意' : '拒绝'
this.auditShow = true
},
async openView(id, modulename) {
this.queryType = 'notAudit'
this.userList = []
const resp = await $.post('/mobile/meeting/audit/getLeaveUser', {
meetingId: id,
moduleName: modulename,
auditType: 'canAudit',
})
if (resp.code === 0) {
this.userList = resp.data
this.userClickList = []
if (this.userList.length === 0) {
vant.Toast('暂无请假人员')
} else {
this.userShow = true
}
return
}
vant.Toast('系统错误,请联系管理员')
},
popClose() {
this.$nextTick(function () {
if (this.$refs.checkboxes !== undefined) {
this.$refs.checkboxes.forEach(item => item.toggle(false));
}
})
},
doSearch() {
this.pageForm.pageNumber = 1
this.tableData = []
this.finished = false
this.onLoad()
},
async onLoad() {
this.loading = true
$.post('/mobile/meeting/audit/pageData', this.pageForm).then(res => {
if (res.code === 0) {
this.tableData = this.tableData.concat(res.data.list)
if (this.tableData.length === res.data.totalCount) {
this.finished = true
} else {
this.pageForm.pageNumber++
}
}
this.loading = false
})
},
},
async created() {
this.typeList = await meetUtil.getAllMeetingType()
this.typeList.unshift({text: '全部会议类型'})
if (this.typeList && this.typeList.length > 0) {
this.$set(this.pageForm, "typeId", this.typeList[0].value)
}
this.$set(this.pageForm, "meetingTime", this.meetingTimeList[1].value)
this.onLoad()
}
})
</script>
<!--#
}
#-->
@@ -0,0 +1,532 @@
<!--#
layout("/mobile/platform.html"){
#-->
<style>
.van-index-bar__sidebar {
display: none;
}
.van-doc-card {
margin: 14px;
padding: 12px 12px 12px 12px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 8px 12px #ebedf0;
line-height: 20px;
font-size: 13px;
position: relative;
}
.van-divider {
margin: 6px 0 6px 0px;
border-color: lightgray;
}
.van-button--small {
border-top-right-radius: 16px;
border-bottom-left-radius: 16px;
height: 26px;
}
.van-col {
line-height: 20px;
}
.title_span {
font-size: 16px;
font-weight: bold;
position: absolute;
left: -1px;
top: 11px;
color: #1867b0;
}
.title {
font-size: 13px;
font-weight: bold;
flex: 1;
overflow: hidden;
white-space: nowrap;
}
.cus_overflow {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.showMore {
color: #1867b0;
}
.cus_popup {
width: 70%;
height: 50%;
/*border-radius: 10px;*/
padding: 10px 14px;
font-size: 15px;
/*background-color: #E5E7E9;
background-image: url("https://www.transparenttextures.com/patterns/green-cup.png");*/
}
.cus_icon {
z-index: 10000;
color: white;
font-size: 35px;
position: fixed;
top: 81%;
left: 44%;
}
.van-dropdown-menu__item {
flex: auto;
}
.leave_pop {
height: 80%;
background-color: #f6f7f9;
}
.content {
height: 82%;
overflow: auto;
}
.van-field__label {
width: 4.6em;
}
.checkDiv {
font-size: 33px;
color: #1867b0;
position: absolute;
right: 4px;
top: 30px;
}
.auditState {
position: absolute;
right: -10px;
top: -3px;
border-radius: 4px;
padding: 1px 8px;
border: 1px #1867b0 solid;
background: #1867b0;
opacity: 0.6;
color: white;
transform: skewY(5deg);
}
.van-field--min-height .van-field__control {
min-height: auto;
font-size: 13px;
}
.border_div {
width: 33px;
height: 33px;
border: 1px lightgrey solid;
border-radius: 14px;
position: absolute;
right: 4px;
top: 28px;
}
</style>
<div id="app" v-cloak>
<m-page-loading v-if="mLoading"></m-page-loading>
<!--top栏-->
<van-nav-bar
@click-left="history.go(-1)"
fixed
left-arrow
placeholder
safe-area-inset-top
title="我的会议"
></van-nav-bar>
<!--筛选框-->
<div class="search-fixed">
<van-search
@search="doSearch"
maxlength="10"
placeholder="请输入会议名称、会议地点进行查询"
shape="round"
v-model="pageForm.searchKeyWord"
>
</van-search>
<van-dropdown-menu>
<van-dropdown-item :options="meetingList" @change="doSearch"
v-model="pageForm.tabNameIndex"></van-dropdown-item>
<van-dropdown-item :options="meetingTimeList" @change="doSearch"
v-model="pageForm.meetingTime"></van-dropdown-item>
<van-dropdown-item :options="typeList" @change="doSearch"
v-model="pageForm.typeId"></van-dropdown-item>
</van-dropdown-menu>
</div>
<!--列表-->
<div style="margin-top: 116px">
<van-list
:finished="finished"
:finished-text="tableData.length>0?'没有更多了':''" :immediate-check="false"
@load="onLoad"
v-model="loading"
>
<div class="van-doc-card" v-for="o in tableData">
<div @click="openView(o.id)">
<div style="display: flex; justify-content: space-between">
<div style="width: 74%">
<div class="van-ellipsis title">
<span class="title_span">|</span>
<span>{{o.meetingName}}</span>
</div>
</div>
<div style="color: #1867b0; white-space: nowrap;">
{{o.meetingTypeName}}
</div>
</div>
<div style="margin-top: 10px">
<van-row>
<span style="color: grey">会议地点:</span>
{{o.location}}
</van-row>
</div>
<div style="margin-top: 10px">
<van-row>
<span style="color: grey">会议时间:</span>
{{o.startTime}}
<!--<van-col span="12"><span style="color: grey">结束时间:</span></van-col>-->
</van-row>
<van-row>
<!--<van-col span="12">{{o.endTime}}</van-col>-->
</van-row>
</div>
<div style="display: flex; justify-content: space-between; margin-top: 8px">
<div class="cus_overflow" style="line-height: 20px; width: 83%">
<span style="color: grey">会议描述:</span>
{{o.meetingDescription}}
</div>
<span @click.stop="popupShow = true; clickRow = o"
class="showMore">查看更多</span>
</div>
<van-divider></van-divider>
<div style="display: flex; justify-content: flex-end">
<!--<div style="display: flex; align-items: center">
<span style="color: grey">审核状态:</span>
<span :style="'color: ' + o.stateColor">{{o.stateName}}</span>
</div>-->
<div>
<!--<van-button @click="needLeave(o)" v-if="o.isCanLeave === null && o.isJoin === null"
type="primary" size="small" color="#1867b0" style="margin-right: 8px">我要请假</van-button>
<van-button v-if="o.isJoin === false" size="small" disabled color="grey" style="margin-right: 8px">已请假</van-button>
<van-button type="primary" v-if="o.isJoin !== false" size="small" color="#1867b0">我要签到</van-button>
<van-button v-if="o.isJoin === true" size="small" disabled color="grey">已签到</van-button>-->
<van-button
:disabled="moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false"
@click="needLeave(o, false)"
color="#1867b0" size="small" style="margin-right: 8px"
type="primary">查看请假状态
</van-button>
<van-button
:disabled="moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false"
@click="needLeave(o, true)"
color="#1867b0" size="small" style="margin-right: 8px"
type="primary">我要请假
</van-button>
</div>
</div>
</div>
</div>
</van-list>
<van-empty
class="custom-image"
description="暂无数据"
image="/none.svg"
v-if="mLoading==false&&tableData.length==0"
></van-empty>
</div>
<!--弹出框-->
<van-popup class="cus_popup" v-model:show="popupShow">
<pre style="margin: 0; white-space: break-spaces; line-height: 28px">{{clickRow.meetingDescription}}</pre>
</van-popup>
<van-icon @click="popupShow = false" class="cus_icon" name="close" v-if="popupShow"></van-icon>
<!--请假弹框-->
<van-action-sheet class="leave_pop" title="会议信息" v-model="leaveShow">
<div v-if="flag === true"
style="padding: 0px 0px 10px 0px; text-align: center; font-size: 14px; color: #646566">
请<span style="color: red">点击选择</span>请假时间段,填写请假原因
</div>
<div class="content">
<div class="van-doc-card" v-for="(item, index) in timeList">
<div>
<div><span style="color: grey">会议名称:</span>{{item.timePeriodName}}</div>
</div>
<div @click="leaveClick(item, index)"
style="display: flex; justify-content: space-between">
<div>
<div>
<span style="color: grey">会议时间:</span>
{{moment(item.startTime).format('YYYY-MM-DD HH:mm')}}
</div>
<!--<div><span style="color: grey">结束时间:</span>{{moment(item.endTime).format('YYYY-MM-DD HH:mm')}}</div>-->
</div>
<div>
<div v-if="flag === true" class="border_div"></div>
<van-icon v-if="flag === true" :class="'checkDiv checkDiv' + index"
name="success" style="display: none;"></van-icon>
<span class="auditState"
v-if="item.isJoin === false">{{item.stateName}}</span>
</div>
</div>
<div v-if="item.isJoin === false">
<div><span style="color: grey">审核状态:</span>{{item.stateName}}</div>
</div>
<div>
<span style="float: left; color: grey">请假原因:</span>
<van-field :disabled="item.isJoin === false" placeholder="请输入请假原因" rows="1"
style="font-size: 12px; padding: 0; width: 70%; line-height: 20px"
type="textarea" autosize
v-model="item.leaveReason"></van-field>
</div>
<div v-if="flag === false && item.stateCode === clickRow.firstState && item.stateAuditType !== 1"
style="text-align: right">
<van-button @click.stop="cancelLeave(item)" border color="#1867b0" size="small">
取消请假
</van-button>
</div>
<div v-if="flag === false && item.stateAuditType === 1" style="text-align: right">
<van-button @click.stop="refreshApply(item)" border color="#1867b0"
size="small">重新申请
</van-button>
</div>
</div>
</div>
<div v-if="flag === true">
<div style="display: flex; justify-content: space-evenly; position: fixed; bottom: 20px; width: 100%">
<van-button @click="leaveShow = false" color="lightgrey" size="small"
style="width: 40%; border-radius: revert; height: 38px">取消
</van-button>
<van-button @click="leave" color="#1867b0" size="small"
style="width: 40%; border-radius: revert; height: 38px">确定
</van-button>
</div>
</div>
</van-action-sheet>
</div>
<script>
<!--# include("/platform/meeting/includeJs/meetingUtil.js"){} #-->
const meetUtil = new meetingUtil()
const vue = new Vue({
el: '#app',
mixins: [mobileMixins],
data() {
return {
timeList: [],
checked: [],
checkboxRefs: [],
leaveReason: '',
leaveShow: false,
popupShow: false,
tabNameIndex: 0,
clickRow: {},
meetingList: [{text: '全部', value: '0'}, {text: '我参与的', value: '1'}, {
text: '我请假的',
value: '2'
}],
typeList: [],
meetingTimeList: [{text: '全部时间', value: null}, {
text: '即将开始',
value: 0
}, {text: '已结束', value: 1}],
flag: true,
}
},
methods: {
refreshApply(o) {
vant.Dialog.confirm({
title: '温馨提示',
message: '您确定要重新申请吗?',
}).then(async () => {
await this.needLeave(this.clickRow, true)
this.timeList.forEach((re, index) => {
if (re.stateAuditType === 1) {
re.isJoin = null
re.stateCode = null
re.leaveReason = null
$('.checkDiv' + index).css('display', 'none')
this.checked = this.checked.filter(function (item, index) {
return item.id !== re.id
})
}
})
}).catch(() => {
})
},
cancelLeave(o) {
vant.Dialog.confirm({
title: '温馨提示',
message: '您确定要取消请假吗?',
}).then(async () => {
const res = await $.post('/mobile/meeting/mine/cancelLeave', {id: o.id})
if (res.code === 0) {
vant.Toast('操作成功')
this.doSearch()
this.leaveShow = false
}
}).catch(() => {
})
},
leaveClick(item, index) {
if (item.isJoin === false) {
return
}
const isExist = this.checked.some(o => o.tpuId === item.tpuId)
if (!isExist) {
$('.checkDiv' + index).css('display', '')
this.checked.push(item)
} else {
$('.checkDiv' + index).css('display', 'none')
this.checked = this.checked.filter(o => o.tpuId !== item.tpuId)
}
},
toggle(item, index) {
if (item.auditIdList === null) {
this.$refs.checkboxes[index].toggle();
}
},
openView(id) {
},
doSearch() {
this.pageForm.pageNumber = 1
this.tableData = []
this.finished = false
this.onLoad()
},
async onLoad() {
this.loading = true
$.post('/mobile/meeting/mine/pageData', this.pageForm).then(res => {
if (res.code === 0) {
this.tableData = this.tableData.concat(res.data.list)
if (this.tableData.length === res.data.totalCount) {
this.finished = true
} else {
this.pageForm.pageNumber++
}
}
this.loading = false
})
},
async needLeave(o, flag) {
this.flag = flag
this.clickRow = o
if (moment().valueOf() > moment(o.leaveDeadline).valueOf() || o.isCanLeave === false) {
vant.Toast('抱歉,已过请假截止时间');
return
}
this.leaveReason = ''
this.checked = []
const res = await $.post('/mobile/meeting/mine/findMyMeetPeriod', {meetingId: o.id})
if (res.code === 0) {
this.timeList = res.data
if (this.timeList.length === 0) {
vant.Toast('您暂无可请假的假时间段');
return
}
this.leaveShow = true
this.$nextTick(function () {
this.timeList.forEach((re, index) => {
if (re.isJoin === false) {
this.checked.push(re)
$('.checkDiv' + index).css('display', '')
}
})
})
return
}
vant.Toast('系统错误,请联系管理员');
},
async leave() {
if (this.checked.length === 0) {
vant.Toast('请选择请假时间段');
return
}
const array = this.timeList.find(o => o.stateCode === null || o.stateCode < this.clickRow.firstState)
if (array === undefined) {
vant.Toast('您的所有请假均已处于审核阶段');
return
}
const paramArray = []
let valid = false
for (const item of this.checked) {
if (item.leaveReason === '' || item.leaveReason === undefined) {
vant.Toast('请填写请假原因');
valid = true
return
}
if (!item.stateCode) {
paramArray.push(
{
id: item.tpuId,
meetingId: this.clickRow.id,
leaveReason: item.leaveReason
}
)
}
}
if (paramArray.length === 0) {
vant.Toast('请选择请假时间段');
return
}
if (valid) {
return
}
const resp = await $.post('/mobile/meeting/mine/askForLeave', {
meetingId: this.clickRow.id,
data: JSON.stringify(paramArray)
})
if (resp.code === 0) {
vant.Toast('操作成功');
this.doSearch()
this.leaveShow = false
}
$('.checkDiv').css('display', 'none')
}
},
async created() {
this.typeList = await meetUtil.getAllMeetingType()
this.typeList.unshift({'text': '全部会议类型'})
if (this.typeList && this.typeList.length > 0) {
this.$set(this.pageForm, "typeId", this.typeList[0].value)
}
this.$set(this.pageForm, "tabNameIndex", this.meetingList[0].value)
this.$set(this.pageForm, "meetingTime", this.meetingTimeList[1].value)
this.onLoad()
}
})
</script>
<!--#
}
#-->
@@ -0,0 +1,320 @@
<!--#
layout("/mobile/platform.html"){
#-->
<style>
[v-cloak] {
display: none !important;
}
#app {
max-height: 100vh;
opacity: 0;
}
.header {
height: 400px;
max-height: 400px;
background-color: white
}
.body {
background-color: white;
margin-top: 6px;
height: calc(100vh - (400px + 6px + 26px + 70px));
max-height: calc(100vh - (400px + 6px + 26px + 70px));
padding: 10px;
}
.footer {
background-color: white;
margin-top: 6px;
width: 100%;
height: 70px;
display: flex;
align-items: center;
}
.meeting_info {
height: 200px;
width: 86%;
margin: 0 auto;
transform: translateY(-60%);
background-color: white;
box-shadow: 0 8px 12px #ebedf0;
padding: 10px 10px;
border-radius: 10px;
}
.header .text {
color: white;
text-align: center;
letter-spacing: 3px;
line-height: 40px;
}
.meeting_info .meeting_name {
text-align: center;
font-weight: bold;
}
.meeting_info .meeting_address {
text-align: center;
color: grey;
font-size: 14px;
}
.van-button--block {
margin: 0 auto;
width: 92%;
}
.tag {
color: #1867b0;
font-weight: bold;
font-size: 20px;
margin-right: 6px;
}
.span_text {
color: grey;
font-size: 14px;
}
.van-col {
font-size: 14px;
}
.van-col span {
color: grey;
font-size: 14px;
}
.icon {
width: 6.4em;
height: 6.4em;
display: inline-block;
vertical-align: middle;
font-size: 10px;
-webkit-mask-size: 100%;
-webkit-mask-position: 50% 50%;
background-color: currentColor;
}
.icon_ok {
-webkit-mask-image: url(data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M12%2022C6.477%2022%202%2017.523%202%2012S6.477%202%2012%202s10%204.477%2010%2010-4.477%2010-10%2010zm-1.177-7.86l-2.765-2.767L7%2012.431l3.119%203.121a1%201%200%20001.414%200l5.952-5.95-1.062-1.062-5.6%205.6z%22%2F%3E%3C%2Fsvg%3E);
color: #07c160;
}
.icon_no {
-webkit-mask-image: url(data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M12%2022C6.477%2022%202%2017.523%202%2012S6.477%202%2012%202s10%204.477%2010%2010-4.477%2010-10%2010zm-.763-15.864l.11%207.596h1.305l.11-7.596h-1.525zm.759%2010.967c.512%200%20.902-.383.902-.882%200-.5-.39-.882-.902-.882a.878.878%200%2000-.896.882c0%20.499.396.882.896.882z%22%2F%3E%3C%2Fsvg%3E);
color: #fa5151;
}
.weui-msg__text-area {
margin-bottom: 32px;
padding: 0 32px;
-webkit-box-flex: 1;
line-height: 1.6;
}
.weui-msg__text-area .weui-msg__title {
margin-bottom: 16px;
font-weight: 500;
font-size: 22px;
color: rgba(0, 0, 0, 0.9);
}
.weui-msg__desc {
font-size: 17px;
font-weight: 400;
color: rgba(0, 0, 0, 0.9);
margin-bottom: 16px;
}
.meeting_index {
width: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background-color: lightgrey;
color: white;
font-size: 20px;
font-weight: bold;
}
.meeting_peri {
width: 90%;
line-height: 19px;
margin-left: 10px
}
.meeting_primary {
display: flex;
justify-content: space-between;
margin-bottom: 10px
}
.weui-btn_primary:not(.weui-btn_disabled):visited {
color: #fff;
}
.weui-btn_primary {
background-color: #1867b0;
}
.weui-btn {
position: relative;
display: block;
width: 184px;
margin-left: auto;
margin-right: auto;
padding: 8px 24px;
box-sizing: border-box;
font-weight: 700;
font-size: 17px;
text-align: center;
text-decoration: none;
color: #fff;
line-height: 1.88235294;
border-radius: 8px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
</style>
<div id="app">
<div v-if="isCanAudit">
<div class="header">
<div style="height: 300px; background-color: #1867b0; border-radius: 0 0 16% 16%;">
<div class="text">会议签到</div>
</div>
<div class="meeting_info">
<div class="meeting_name">{{meetingInfo.meetingName}}</div>
<div class="meeting_address">{{meetingInfo.location}}</div>
<div style="position: relative; top: 55px">
<van-row>
<van-col span="24"><span>会议类型:</span>{{typeName}}</van-col>
</van-row>
<div style="position: relative; top: 30px">
<van-row>
<van-col span="24">
<span style="color: grey; font-size: 14px;">会议时间:</span>
{{moment(meetingInfo.startTime).format('YYYY-MM-DD HH:mm')}}
</van-col>
</van-row>
<van-row>
<van-col span="24">
<span style="color: grey; font-size: 14px;">结束时间:</span>
{{moment(meetingInfo.endTime).format('YYYY-MM-DD HH:mm')}}
</van-col>
</van-row>
</div>
</div>
</div>
</div>
<div class="body">
<div><span class="tag">|</span>会议名称</div>
<div style="overflow-y: auto; height: 100%; font-size: 13px;margin-top: 16px">
<div class="meeting_primary" v-for="(item,index) in meetingInfo.meetingTimePeriods">
<div :style="item.id === mtpId ? 'background-color: #43b26a; font-size: 15px' : ''"
class="meeting_index" v-if="item.id === mtpId">
当前
</div>
<div class="meeting_index" style="font-weight: normal" v-else>
{{index + 1}}
</div>
<div class="meeting_peri">
<div>{{item.timePeriodName}}</div>
<div>{{moment(item.startTime).format('YYYY-MM-DD HH:mm')}}</div>
</div>
</div>
</div>
</div>
<div class="footer">
<van-button :disabled="signInfo.isSignIn" @click="signIn" block color="#1867b0" round type="primary">
{{signInfo.isSignIn ? '您已签到' : '点击签到'}}
</van-button>
</div>
</div>
<div style="text-align: center; padding-top: calc(100% - 50%)" v-cloak v-else>
<div style="margin-bottom: 32px;">
<span :class="isIncorrect === true ? 'icon icon_ok' : 'icon icon_no'"></span>
</div>
<div class="weui-msg__text-area">
<h2 class="weui-msg__title">{{isIncorrect === true ? '操作成功' : '温馨提示'}}</h2>
<p class=".weui-msg__desc">{{incorrectMag}}</p>
</div>
<p style="margin-top: 190px">
<span @click="back" class="weui-btn weui-btn_primary" role="button">点击返回</span>
</p>
</div>
</div>
<script>
<!--# include("/platform/meeting/includeJs/meetingUtil.js"){} #-->
const meetUtil = new meetingUtil()
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURI(r[2]);
return null;
}
const vue = new Vue({
el: '#app',
data() {
return {
meetingInfo: {},
signInfo: {},
isCanAudit: true,
incorrectMag: '',
meetingId: '',
mtpId: '',
isIncorrect: true,
typeName: '',
}
},
methods: {
async pageData() {
const res = await $.get('/mobile/meeting/mine/getMeetingInfo', {
meetingId: this.meetingId,
mtpId: this.mtpId,
})
if (res.code === 0) {
this.meetingInfo = res.data.meetingInfo
this.signInfo = res.data.signInfo
const typeList = await meetUtil.getAllMeetingType()
const type = typeList.find(o => o.id === this.meetingInfo.typeId)
this.typeName = type !== undefined ? type.meetingTypeName : ''
} else {
this.isCanAudit = false
this.incorrectMag = res.msg
this.isIncorrect = false
}
$('#app').css('opacity', '1')
},
async signIn() {
const res = await $.post('/mobile/meeting/mine/signIn', {
mtpId: this.mtpId,
})
this.isIncorrect = res.code === 0
this.isCanAudit = false
this.incorrectMag = res.msg
},
back() {
const str = this.incorrectMag === '你不是当前会议人员' ? 'http://' + window.location.host : '/mobile/meeting/mine/go_sign?meetingId=' + this.meetingId + '&mtpId=' + this.mtpId
location.href = str
},
},
async created() {
this.meetingId = getQueryString('meetingId')
this.mtpId = getQueryString('mtpId')
await this.pageData()
}
})
</script>
<!--#
}
#-->
@@ -53,8 +53,8 @@
<!--如果需要在 Chrome 和 Firefox 等现代浏览器中通过 H5 播放 HLS 格式的视频,需要在 tcplayer.vx.x.x.min.js 之前引入 hls.min.x.xx.xm.js。--> <!--如果需要在 Chrome 和 Firefox 等现代浏览器中通过 H5 播放 HLS 格式的视频,需要在 tcplayer.vx.x.x.min.js 之前引入 hls.min.x.xx.xm.js。-->
<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.2/libs/hls.min.0.13.2m.js"></script> <script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.2/libs/hls.min.0.13.2m.js"></script>
<!--播放器脚本文件--> <!--播放器脚本文件-->
<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.2/tcplayer.v4.3.0.min.js"></script> <!-- <script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.2/tcplayer.v4.3.0.min.js"></script>-->
<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.2/tcplayer.v4.5.2.min.js"></script>
</head> </head>
<body> <body>
File diff suppressed because it is too large Load Diff
@@ -1,391 +0,0 @@
<!--#
layout("/mobile/platform.html"){
#-->
<style>
.page-survey {
background-color: rgba(242, 242, 242, 1);
}
.page-survey .survey-container {
height: 100%;
overflow: visible;
padding-top: 0;
display: flex;
flex-direction: column;
}
.survey-container .question-list {
flex: auto;
padding-bottom: 84px;
}
.question {
position: relative;
margin-bottom: 20px;
background: rgba(255, 255, 255, 1);
}
.question-head {
overflow: hidden;
position: relative;
padding: 20px;
background: rgba(255, 255, 255, 1);
}
.question-tags {
position: absolute;
top: -2px;
}
.question-title {
position: relative;
font-size: 1.125em;
font-weight: normal;
word-wrap: break-word;
word-break: break-word;
outline: 0;
}
.question-seq {
display: block;
margin-right: 8px;
font-size: 18px;
float: left;
}
.question-title .text {
margin-right: 4px;
}
.question-body {
background-color: rgba(255, 255, 255, 1);
user-select: none;
}
.van-checkbox {
margin-right: 10px;
}
.van-cell__title {
font-size: 16px;
color: rgba(0, 0, 0, 1);
}
.page-control {
padding: 20px;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20px;
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #fff;
}
.survey-head {
padding: 20px;
background: #fff;
margin-bottom: 10px;
}
.survey-head .title {
font-size: 22px;
font-weight: 600;
text-align: center;
}
.survey-head .desc {
padding: 10px;
font-size: 14px;
}
</style>
<div id="app" v-cloak>
<div class="root">
<m-page-loading v-if="mLoading"></m-page-loading>
<van-nav-bar title="知识竞答" left-arrow placeholder fixed
@click-left="history.go(-1)"></van-nav-bar>
<template v-if="!mLoading">
<div v-if="finishAnswer">
{{finishAnswer}}
<van-empty description="您已经答完该问卷">
<div>
<van-button type="info" @click="viewScore">查看成绩</van-button>
<van-button type="info" @click="viewAnswerSheet">查看答卷</van-button>
<!-- <van-button type="info" @click="answerAgain">再答一次</van-button>-->
</div>
</van-empty>
</div>
<div v-else class="page-survey" style="touch-action: manipulation;min-height: 100vh;">
<div class="survey-container">
<div class="survey-head">
<div class="title">
{{questionData.qtitle}}
</div>
<div class="desc">
{{titleMsg}}
</div>
</div>
<div class="question-list">
<section v-for="(issue,issueIdx) in issueList" :key="issue.iid" class="question"
:id="'issue'+issue.iid">
<div class="question-head">
<div class="question-tags">
<template v-if="issue.itx===1">
<van-tag :type="issue.iisdx?'primary':'warning'">{{issue.iisdx?'单选':'多选'}}
</van-tag>
</template>
<van-tag v-if="issue.fraction" type="primary">{{issue.fraction}}分</van-tag>
</div>
<h2 class="question-title">
<span class="question-seq">
<b>
{{issueIdx+1}}
</b>
</span>
<div class="text" v-html="issue.iname"></div>
</h2>
</div>
<div class="question-body">
<van-checkbox-group v-model="issue.userSelect" :ref="'checkboxGroup'+issue.iid">
<van-cell-group>
<van-cell
v-for="(item,index) in issue.wors"
clickable
:key="item"
:title="item.wtxt"
@click="toggle(issue,item.wid)"
>
<template #icon>
<van-checkbox :name="item.wid" :ref="'checkboxes'+item.wid"
:shape="issue.iisdx?'round':'square'"></van-checkbox>
</template>
</van-cell>
</van-cell-group>
</van-checkbox-group>
</div>
</section>
</div>
<div class="page-control">
<van-button type="info" block @click="save()">保存</van-button>
<van-button type="info" block @click="submit()">提交</van-button>
</div>
</div>
</div>
</template>
</div>
</div>
<script>
const BASE_URL = '/mobile/question/h5ctgu'
const vue = new Vue({
el: '#app',
data() {
return {
questionData: {
issues: []
},
currentIssueIndex: 0,
replyInfo: [],
finishAnswer: false,
mLoading: true
}
},
computed: {
issueList() {
return this.questionData.issues
},
titleMsg() {
debugger
const radios = this.issueList.filter(v => v.itx === 1 && v.iisdx)
const checkBoxes = this.issueList.filter(v => v.itx === 1 && !v.iisdx)
const radioScore = radios.length > 0 ? radios[0].fraction : 0
const checkBoxesScore = checkBoxes.length > 0 ? checkBoxes[0].fraction : 0
const radioScoreSum = radios.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b, 0)
const checkBoxesScoreSum = checkBoxes.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b, 0)
const sumScore = radioScoreSum + checkBoxesScoreSum
return "说明:单选题" + radios.length + "题,每题" + radioScore + "分,合计" + radioScoreSum + "分;多选题" + checkBoxes.length + "题,每题" + checkBoxesScore + "分,合计" + checkBoxesScoreSum + "分;总分" + sumScore + "分。"
},
fullScore() {
return this.issueList.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b)
},
radioNum() {
return this.issueList.filter(v => v.idx === 1 && v.iisdx).map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b)
},
checkBoxNum() {
}
},
methods: {
async getQuestionData() {
const resp = await $.get(BASE_URL + '/questionInfo/' + this.id)
this.questionData = resp.data
this.questionData.issues.forEach(i => {
// i.userSelect = null
})
},
toggle(issue, worId) {
//单选
if (issue.iisdx) {
vue.$refs['checkboxGroup' + issue.iid][0].toggleAll(false)
} else {
}
console.log(issue.userSelect)
this.$refs['checkboxes' + worId][0].toggle()
setTimeout(() => {
console.log(issue.userSelect)
})
},
save() {
this.$modal.confirm('保存后下次可继续做答,您确定要保存吗?').then(async () => {
const replies = this.questionData.issues.map(v => {
return {
qid: v.iid,
issueId: v.iid,
userSelect: v.userSelect,
}
})
const {code} = await $.post(BASE_URL + '/saveAnswer', {
replies: JSON.stringify(replies),
questionId: this.questionData.qid,
isSave: true
})
this.$modal.closeLoading()
if (code === 0) {
this.$modal.msg('保存成功')
} else {
this.$modal.msg('保存失败')
}
})
},
submit() {
const iids = this.questionData.issues.filter(v => !v.userSelect).map(v => v.iid)
if (iids.length > 0) {
vant.Toast('您还有' + iids.length + '题未作答,请答完后再提交!')
document.getElementById('issue' + iids[0]).scrollIntoView({behavior: 'smooth', block: 'center','inline':'start'});
return
}
const msg = '一旦提交不可修改,您确定要提交吗?'
this.$modal.confirm(msg).then(async () => {
const replies = this.questionData.issues.map(v => {
return {
qid: v.iid,
issueId: v.iid,
userSelect: v.userSelect,
}
})
const {code} = await $.post(BASE_URL + '/saveAnswer', {
replies: JSON.stringify(replies),
questionId: this.questionData.qid,
isSave: false
})
this.$modal.closeLoading()
if (code === 0) {
this.$modal.msg('提交成功')
await this.checkUserFinishAnswer()
if (this.finishAnswer) {
//查看分数
this.viewScore()
}
}
})
},
//获取回答信息
async getReply() {
const resp = await $.get(BASE_URL + '/answerInfo/' + this.id)
this.replyInfo = resp.data
},
//用户是否全部答完提交
async checkUserFinishAnswer() {
this.mLoading = true
const resp = await $.get(BASE_URL + '/checkUserFinishAnswer', {questionId: this.id})
setTimeout(async () => {
this.mLoading = false
this.finishAnswer = resp.data
if (resp.data) {
} else {
await this.getReply()
await this.assignmentAnswer()
}
}, 1000)
},
//答案赋值
assignmentAnswer() {
this.questionData.issues.forEach(issue => {
const rwids = this.replyInfo.filter(v => v.issueId === issue.iid).map(v => v.rwid)
rwids.forEach(rwid => {
this.toggle(issue, rwid)
})
})
},
answerAgain() {
this.finishAnswer = false
setTimeout(() => {
this.questionData.issues.forEach(issue => {
issue.wors.forEach(wor => {
this.$refs['checkboxes' + wor.wid][0].toggle(false)
})
})
}, 0)
},
viewScore() {
window.location.href = BASE_URL + '/score?id=' + this.id
},
viewAnswerSheet(){
window.location.href = BASE_URL + '/answerSheet?id=' + this.id
}
},
async created() {
this.id = GetQueryString("id")
await this.getQuestionData()
await this.checkUserFinishAnswer()
// await this.getReply()
// this.assignmentAnswer()
}
})
window.addEventListener('pageshow', async e => {
if (e.persisted || (window.performance && window.performance.navigation.type === 2)) {
vue.id = GetQueryString("id")
await vue.getQuestionData()
await vue.checkUserFinishAnswer()
}
})
</script>
<!--#
}
#-->
@@ -1,323 +0,0 @@
<!--#
layout("/mobile/platform.html"){
#-->
<style>
.page-survey {
background-color: rgba(242, 242, 242, 1);
}
.page-survey .survey-container {
height: 100%;
overflow: visible;
padding-top: 0;
display: flex;
flex-direction: column;
}
.survey-container .question-list {
flex: auto;
padding-bottom: 84px;
}
.question {
position: relative;
margin-bottom: 20px;
background: rgba(255, 255, 255, 1);
}
.question-head {
overflow: hidden;
position: relative;
padding: 20px;
background: rgba(255, 255, 255, 1);
}
.question-tags {
position: absolute;
top: -2px;
}
.question-title {
position: relative;
font-size: 1.125em;
font-weight: normal;
word-wrap: break-word;
word-break: break-word;
outline: 0;
}
.question-seq {
display: block;
margin-right: 8px;
font-size: 18px;
float: left;
}
.question-title .text {
margin-right: 4px;
}
.question-body {
background-color: rgba(255, 255, 255, 1);
user-select: none;
}
.van-checkbox {
margin-right: 10px;
}
.van-cell__title {
font-size: 16px;
color: rgba(0, 0, 0, 1);
}
.page-control {
padding: 20px;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20px;
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #fff;
}
.survey-head {
padding: 20px;
background: #fff;
margin-bottom: 10px;
}
.survey-head .title {
font-size: 22px;
font-weight: 600;
text-align: center;
}
.survey-head .desc {
padding: 10px;
font-size: 14px;
}
@font-face {
font-family: 'Indie Flower';
font-style: normal;
font-weight: 400;
src: url(/assets/platform/fonts/m8JVjfNVeKWVnh3QMuKkFcZVaUuH.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
.survey-head .score{
color: red;
font-family: 'Indie Flower', cursive;
font-size: 30px;
text-align: right;
}
.question-footer {
padding: 16px;
}
.van-checkbox--disabled .van-checkbox__icon--checked .van-icon {
color: #fff;
background-color: #1989fa;
border-color: #1989fa;
}
</style>
<div id="app" v-cloak>
<div class="page-survey" style="touch-action: manipulation;min-height: 100vh;">
<div class="survey-container">
<div class="survey-head">
<div class="title">
{{questionData.qtitle}}
</div>
<div class="desc">
{{titleMsg}}
</div>
<div class="score">
{{score}}
</div>
</div>
<div class="question-list">
<section v-for="(issue,issueIdx) in issueList" :key="issue.iid" class="question"
:id="'issue'+issue.iid">
<div class="question-head">
<div class="question-tags">
<template v-if="issue.itx===1">
<van-tag :type="issue.iisdx?'primary':'warning'">{{issue.iisdx?'单选':'多选'}}
</van-tag>
</template>
<van-tag v-if="issue.fraction" type="primary">{{issue.fraction}}分</van-tag>
</div>
<h2 class="question-title">
<span class="question-seq">
<b>
{{issueIdx+1}}
</b>
</span>
<div class="text" v-html="issue.iname"></div>
</h2>
</div>
<div class="question-body">
<van-checkbox-group v-model="issue.userSelect" :ref="'checkboxGroup'+issue.iid" disabled>
<van-cell-group>
<van-cell
v-for="(item,index) in issue.wors"
clickable
:key="item"
:title="item.wtxt"
>
<template #label>
<div>
{{item.correct?'正确答案':''}}
</div>
</template>
<template #icon>
<van-checkbox :name="item.wid" :ref="'checkboxes'+item.wid"
:shape="issue.iisdx?'round':'square'"></van-checkbox>
</template>
</van-cell>
</van-cell-group>
</van-checkbox-group>
</div>
<div class="question-footer" v-if="replyInfo">
<div>
<div style="display: flex;align-items: center;"
:style="{color:(issue.isEqual?'#15db81':'red')}">
{{issue.isEqual?'回答正确':'回答错误'}}
</div>
</div>
</div>
</section>
</div>
</div>
</div>
</div>
<script>
const BASE_URL = '/mobile/question/h5ctgu'
const vue = new Vue({
el: '#app',
data() {
return {
questionData: {
issues: []
},
currentIssueIndex: 0,
replyInfo: [],
finishAnswer: false,
mLoading: true,
score: 0
}
},
computed: {
issueList() {
return this.questionData.issues
},
titleMsg() {
// const radios = this.issueList.filter(v => v.itx === 1 && v.iisdx)
// const checkBoxes = this.issueList.filter(v => v.itx === 1 && !v.iisdx)
//
// const radioScore = radios ? radios[0].fraction : 0
// const checkBoxesScore = checkBoxes ? checkBoxes[0].fraction : 0
//
// const radioScoreSum = radios.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b, 0)
// const checkBoxesScoreSum = checkBoxes.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b, 0)
//
// const sumScore = radioScoreSum + checkBoxesScoreSum
//
// return "说明:单选题" + radios.length + "题,每题" + radioScore + "分,合计" + radioScoreSum + "分;多选题" + checkBoxes.length + "题,每题" + checkBoxesScore + "分,合计" + checkBoxesScoreSum + "分;总分" + sumScore + "分。"
return null
},
fullScore() {
return this.issueList.map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b)
},
radioNum() {
return this.issueList.filter(v => v.idx === 1 && v.iisdx).map(v => v.fraction ? v.fraction : 0).reduce((a, b) => a + b)
},
checkBoxNum() {
}
},
methods: {
async getQuestionData() {
const resp = await $.get(BASE_URL + '/questionInfo/' + this.id)
this.questionData = resp.data
},
toggle(issue, worId) {
//单选
if (issue.iisdx) {
vue.$refs['checkboxGroup' + issue.iid][0].toggleAll(false)
} else {
}
this.$refs['checkboxes' + worId][0].toggle()
},
async getReply() {
const resp = await $.get(BASE_URL + '/answerInfo/' + this.id)
this.replyInfo = resp.data
},
//用户是否全部答完提交
async checkUserFinishAnswer() {
this.mLoading = true
const resp = await $.get(BASE_URL + '/checkUserFinishAnswer', {questionId: this.id})
this.finishAnswer = resp.data
if (resp.data) {
await this.getReply()
await this.assignmentAnswer()
} else {
// await this.getReply()
// await this.assignmentAnswer()
}
},
//答案赋值
assignmentAnswer() {
this.questionData.issues.forEach(issue => {
const rwids = this.replyInfo.filter(v => v.issueId === issue.iid).map(v => v.rwid)
rwids.forEach(rwid => {
this.toggle(issue, rwid)
})
const wids = issue.wors.filter(v => v.correct).map(v => v.wid)
const userSelects = this.replyInfo.filter(v => v.issueId === issue.iid).map(v => v.rwid)
const isEqual = wids.length === userSelects.length && wids.every(value => userSelects.includes(value))
issue.isEqual = isEqual
})
},
checkIsCorrect(issue) {
const wids = issue.wors.filter(v => v.correct).map(v => v.wid)
const userSelects = this.replyInfo.filter(v => v.issueId === issue.iid).map(v => v.rwid)
const isEqual = wids.length === userSelects.length && wids.every(value => userSelects.includes(value))
return isEqual
},
async getScore() {
const resp = await $.get(BASE_URL + '/getScore', {questionId: this.id})
this.score = resp.data.score
},
},
async created() {
this.id = GetQueryString("id")
await this.getScore()
await this.getQuestionData()
await this.checkUserFinishAnswer()
}
})
</script>
<!--#
}
#-->
@@ -1,163 +0,0 @@
<!--#
layout("/mobile/platform.html"){
#-->
<style>
.transcript-container {
background-image: url(/assets/mobile/img/question/score.jpg);
background-size: 100% 100%;
min-height: 100%;
padding: 15px;
width: 100%;
max-width: 1128px;
box-sizing: border-box;
height: 100vh;
}
.transcript-header {
margin-bottom: 15px;
flex-direction: column;
text-align: center;
display: flex;
justify-content: space-between;
align-items: center;
color: #fff;
}
.score-detail-group {
align-self: stretch;
background: rgba(255, 255, 255, 0.01);
-webkit-backdrop-filter: blur(50px);
backdrop-filter: blur(50px);
border-radius: 20px;
padding: 20px 0;
margin: 20px 0 0 0 !important;
border: 1px solid rgba(255, 255, 255, 0.1);
flex: none;
text-align: center;
}
.score-total {
margin: 40px 0;
transform: translate3d(0px, 0px, 0px);
display: flex;
align-items: stretch;
justify-content: center;
height: 120px;
line-height: 1;
}
.score-number {
display: flex;
flex-direction: column;
justify-content: center;
margin: 0 20px;
}
.score-text-title {
font-size: 16px;
font-weight: 600;
line-height: 32px;
margin-bottom: 30px;
color: #FFFFFF;
}
.score-text-info {
font-size: 32px;
font-weight: 600;
line-height: 50px;
}
.total-number {
font-size: 64px;
min-width: 100px;
}
.total-percent {
margin-top: 10px;
font-size: 20px;
}
</style>
<div id="app">
<van-nav-bar title="知识竞答分数" left-arrow placeholder fixed
@click-left="history.go(-1)"></van-nav-bar>
<div class="transcript-container">
<div class="transcript-header transcript-header-mobile">
<div class="score-text-container">
<div class="score-text-title">
{{title}}
</div>
<div class="score-text-info">
{{message}}
<!-- <ul>-->
<!-- <li>姓名:{{user.username}}</li>-->
<!-- <li>工号:{{user.loginname}}</li>-->
<!-- <li>单位:{{user.unitname}}</li>-->
<!-- <li>工会:{{user.unionname}}</li>-->
<!-- </ul>-->
</div>
</div>
<div class="score-detail-group">
<div class="score-total" style="transform: translate3d(0px, 0px, 0px);">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 88 188">
<path fill="#fff"
d="M41.035 41.216c1.313-.407 2.5-.657 3.844-.875 2.812-.438 5.687-.438 8.437-.094a21.44 21.44 0 01-3.188 5.25s-.125.125-.125.156c-5.468 6.062-11.999 8.78-20.123 8.75-.625-7.25 4.968-11.125 11.155-13.187zM25.63 76.244c-2.281-8.999 5.062-14.561 12.562-17.436 2.75-.937 5.655-1.437 8.53-1.625C44.38 66.87 35.223 74.682 25.63 76.244zm1.844 9.562c2.218-3.25 4.562-5.25 7.905-7.28 2.594-1.532 5.406-2.657 8.312-3.406-.656 10.53-7.78 19.998-17.623 24.06-2.375-4.75-1.25-9.03 1.406-13.374zm3.687 35.06c-5.75-7.843-.531-16.311 5.53-22.06 2.313-2.032 4.907-3.72 7.688-5.063 1.28 10.499-4.344 21.717-13.218 27.123zm9.28 19.717c-7.218-6.718-3.468-16.155 1.532-22.935 1.968-2.438 4.28-4.594 6.812-6.5 3.156 10.124-.656 22.467-8.343 29.435zm7.781.438c.625-2.406 1.406-4.312 2.563-6.5 1.5-2.812 3.437-5.406 5.624-7.749a24.494 24.494 0 012.25 6.249c1.937 8.75.125 17.812-4.906 25.186-6.25-3.906-6.874-10.499-5.53-17.186zm22.218 31.748c-9.75-3.969-9.906-14.562-7.594-23.374.969-3.187 2.375-6.187 4.125-8.968 6.718 8.656 8.093 22.592 3.468 32.342zM38.504 34.216c.938-8.655 9.437-10.999 16.936-11.03 2.782.093 5.5.625 8.156 1.437a22.477 22.477 0 01-3.968 4.469c-5.656 4.843-13.874 6.78-21.124 5.124zm7.031-16.155c7.562.219 12.687-4.874 15.686-11.343 1-2.125 1.75-4.406 2.313-6.718-2.438.062-4.844.469-7.156 1.281-6.937 2.437-12.937 9-10.843 16.78zM25.63 33.591c-.406-1.375-.812-2.718-1.312-4.062-1.032-2.906-2.313-5.75-3.719-8.468a28.868 28.868 0 00-3.843 7.812c-2.813 8.968-.531 18.123 7.218 23.686 4.593-5.75 3.468-12.343 1.656-18.968zm-6.25 42.091c3.969-7.562-.718-17.28-4.874-23.717a63.492 63.492 0 00-5.656-7.562C4.257 55.653 6.975 71.12 19.38 75.682zm-2.687 10.124c-2.156-3.53-4.437-6.25-7.312-9.218-2.28-2.312-4.718-4.5-7.312-6.468-.812 5.03-.375 10.905 1.469 15.686 3.156 7.75 7.812 12.75 16.28 14.155 1.125-5.374-.5-9.53-3.125-14.155zm8.5 37.154c.156-8.843-9.03-16.155-15.718-20.436a73.267 73.267 0 00-8.812-4.875 33.031 33.031 0 002.125 9.624c3.594 9.281 11.937 16.874 22.405 15.687zm9.843 20.904c-1.844-8.78-12.656-13.842-20.249-16.53a77.954 77.954 0 00-9.843-2.749 32.908 32.908 0 004.281 8.968c5.718 8.405 15.718 13.874 25.81 10.311zm-2.626 7.656c-2.53-.594-4.936-1-7.53-1.312-3.468-.407-6.968-.563-10.405-.532a33.547 33.547 0 006.25 7.969c.124.125.937.906 1.03.937 8.437 6.75 17.437 9.437 27.342 3.937-3.5-6.655-9.75-9.093-16.686-10.999zm34.373 26.436c-5.937-7.469-18.53-7.781-27.185-7.031a72.233 72.233 0 00-10.624 1.656 36.742 36.742 0 008.249 6.812c9.187 5.468 21.436 6.562 29.56-1.437zM33.067 31.216c6.593-4.593 6.468-14.811 5.53-21.904A60.312 60.312 0 0036.818.5c-8.75 7.843-12.25 21.905-3.75 30.717z"></path>
<path fill="#fff"
d="M33.629 37.56c3.5-7.219 7.062-13 11.843-19.405-5.031 6.28-8.718 11.968-12.468 19.123-8.124 16.5-11.405 30.154-11.905 48.56.312 23.748 5.374 41.184 17.967 61.276 13.062 18.999 26.654 30.592 47.528 40.435.469-1.063.937-2.125 1.406-3.156-20.342-9.437-33.623-20.561-46.528-38.904-12.561-19.53-17.748-36.497-18.467-59.683.125-18.186 3.093-31.716 10.624-48.246z"></path>
</svg>
<div class="score-number">
<div class="total-number">{{score}}分</div>
<div v-if="answerCount>1" class="total-percent">历史最高分:{{maxScore}}</div>
</div>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 88 188"
style="transform: rotateY(180deg);">
<path fill="#fff"
d="M41.035 41.216c1.313-.407 2.5-.657 3.844-.875 2.812-.438 5.687-.438 8.437-.094a21.44 21.44 0 01-3.188 5.25s-.125.125-.125.156c-5.468 6.062-11.999 8.78-20.123 8.75-.625-7.25 4.968-11.125 11.155-13.187zM25.63 76.244c-2.281-8.999 5.062-14.561 12.562-17.436 2.75-.937 5.655-1.437 8.53-1.625C44.38 66.87 35.223 74.682 25.63 76.244zm1.844 9.562c2.218-3.25 4.562-5.25 7.905-7.28 2.594-1.532 5.406-2.657 8.312-3.406-.656 10.53-7.78 19.998-17.623 24.06-2.375-4.75-1.25-9.03 1.406-13.374zm3.687 35.06c-5.75-7.843-.531-16.311 5.53-22.06 2.313-2.032 4.907-3.72 7.688-5.063 1.28 10.499-4.344 21.717-13.218 27.123zm9.28 19.717c-7.218-6.718-3.468-16.155 1.532-22.935 1.968-2.438 4.28-4.594 6.812-6.5 3.156 10.124-.656 22.467-8.343 29.435zm7.781.438c.625-2.406 1.406-4.312 2.563-6.5 1.5-2.812 3.437-5.406 5.624-7.749a24.494 24.494 0 012.25 6.249c1.937 8.75.125 17.812-4.906 25.186-6.25-3.906-6.874-10.499-5.53-17.186zm22.218 31.748c-9.75-3.969-9.906-14.562-7.594-23.374.969-3.187 2.375-6.187 4.125-8.968 6.718 8.656 8.093 22.592 3.468 32.342zM38.504 34.216c.938-8.655 9.437-10.999 16.936-11.03 2.782.093 5.5.625 8.156 1.437a22.477 22.477 0 01-3.968 4.469c-5.656 4.843-13.874 6.78-21.124 5.124zm7.031-16.155c7.562.219 12.687-4.874 15.686-11.343 1-2.125 1.75-4.406 2.313-6.718-2.438.062-4.844.469-7.156 1.281-6.937 2.437-12.937 9-10.843 16.78zM25.63 33.591c-.406-1.375-.812-2.718-1.312-4.062-1.032-2.906-2.313-5.75-3.719-8.468a28.868 28.868 0 00-3.843 7.812c-2.813 8.968-.531 18.123 7.218 23.686 4.593-5.75 3.468-12.343 1.656-18.968zm-6.25 42.091c3.969-7.562-.718-17.28-4.874-23.717a63.492 63.492 0 00-5.656-7.562C4.257 55.653 6.975 71.12 19.38 75.682zm-2.687 10.124c-2.156-3.53-4.437-6.25-7.312-9.218-2.28-2.312-4.718-4.5-7.312-6.468-.812 5.03-.375 10.905 1.469 15.686 3.156 7.75 7.812 12.75 16.28 14.155 1.125-5.374-.5-9.53-3.125-14.155zm8.5 37.154c.156-8.843-9.03-16.155-15.718-20.436a73.267 73.267 0 00-8.812-4.875 33.031 33.031 0 002.125 9.624c3.594 9.281 11.937 16.874 22.405 15.687zm9.843 20.904c-1.844-8.78-12.656-13.842-20.249-16.53a77.954 77.954 0 00-9.843-2.749 32.908 32.908 0 004.281 8.968c5.718 8.405 15.718 13.874 25.81 10.311zm-2.626 7.656c-2.53-.594-4.936-1-7.53-1.312-3.468-.407-6.968-.563-10.405-.532a33.547 33.547 0 006.25 7.969c.124.125.937.906 1.03.937 8.437 6.75 17.437 9.437 27.342 3.937-3.5-6.655-9.75-9.093-16.686-10.999zm34.373 26.436c-5.937-7.469-18.53-7.781-27.185-7.031a72.233 72.233 0 00-10.624 1.656 36.742 36.742 0 008.249 6.812c9.187 5.468 21.436 6.562 29.56-1.437zM33.067 31.216c6.593-4.593 6.468-14.811 5.53-21.904A60.312 60.312 0 0036.818.5c-8.75 7.843-12.25 21.905-3.75 30.717z"></path>
<path fill="#fff"
d="M33.629 37.56c3.5-7.219 7.062-13 11.843-19.405-5.031 6.28-8.718 11.968-12.468 19.123-8.124 16.5-11.405 30.154-11.905 48.56.312 23.748 5.374 41.184 17.967 61.276 13.062 18.999 26.654 30.592 47.528 40.435.469-1.063.937-2.125 1.406-3.156-20.342-9.437-33.623-20.561-46.528-38.904-12.561-19.53-17.748-36.497-18.467-59.683.125-18.186 3.093-31.716 10.624-48.246z"></path>
</svg>
</div>
</div>
</div>
</div>
</div>
<script>
const BASE_URL = '/mobile/question/h5ctgu'
const vue = new Vue({
el: '#app',
data() {
return {
score: 0,
maxScore: 0,
title: null,
user: {},
message: null,
answerCount: 0,
questionId: null,
}
},
methods: {
async getScore() {
const resp = await $.get(BASE_URL + '/getScore', {questionId: this.questionId})
this.score = resp.data.score
this.maxScore = resp.data.maxScore
this.title = resp.data.title
this.user = resp.data.user
this.answerCount = resp.data.answerCount
this.message = resp.data.message
},
},
created() {
this.questionId = GetQueryString("id")
this.getScore()
}
})
</script>
<!--#
}
#-->

Some files were not shown because too many files have changed in this diff Show More