diff --git a/src/main/java/io/v/nutz/base/utils/WxHttpUtil.java b/src/main/java/io/v/nutz/base/utils/WxHttpUtil.java index cfc2259..4cd21be 100644 --- a/src/main/java/io/v/nutz/base/utils/WxHttpUtil.java +++ b/src/main/java/io/v/nutz/base/utils/WxHttpUtil.java @@ -36,7 +36,9 @@ public class WxHttpUtil { private final MediaType formData = MediaType.parse("multipart/form-data"); private final NutMap jsonHeader = NutMap.NEW().setv("Content-Type", "application/json"); - public static String env = "jiangnan-7g769v4nce8a4fd2"; + + public String env = "hj-2ggpsf3t8a32c4eb"; + public String queryUrl = "https://api.weixin.qq.com/tcb/databasequery?access_token=ACCESS_TOKEN"; diff --git a/src/main/java/io/v/nutz/base/utils/WxTokenUtil.java b/src/main/java/io/v/nutz/base/utils/WxTokenUtil.java index 02df090..9a287cf 100644 --- a/src/main/java/io/v/nutz/base/utils/WxTokenUtil.java +++ b/src/main/java/io/v/nutz/base/utils/WxTokenUtil.java @@ -19,36 +19,28 @@ import java.util.HashMap; * @date 2024/01/15 */ @IocBean -@Slf4j public class WxTokenUtil { + private static final Log log = Logs.get(); + @Inject private RedisService redisService; - private static final String APPID = "wxffb8d1c4eef5da73"; + private final String APPID = "wx2efb6a8555f1c030"; - private static final String APP_SECRET = "393e63d77631af9b883c1f1e116d41d3"; + private final String APPSECRET = "3039135e9fe0882259db8822b9be5d6c"; private String getTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET"; - /** - * 获取token - * - * @return {@link String} - */ + private final String TOKEN_KEY = "weapp_access_token"; + public String getAccessToken() { - String token = redisService.get(RedisConstant.REDIS_KEY_WE_APP_ACCESS_TOKEN); - if (StrUtil.isNotBlank(token)) { - return token; - } - String url = getTokenUrl.replace("APPID", APPID).replace("APPSECRET", APP_SECRET); + String url = getTokenUrl.replace("APPID", APPID).replace("APPSECRET", APPSECRET); String result = Http.get(url).getContent(); HashMap tokenObject = Json.fromJson(HashMap.class, result); if (tokenObject.containsKey("errcode")) { log.error("获取token失败------" + tokenObject.get("errmsg")); - throw new RuntimeException("获取token失败------" + tokenObject.get("errmsg")); } - redisService.setex(RedisConstant.REDIS_KEY_WE_APP_ACCESS_TOKEN, 7200 - 200, (String) tokenObject.get("access_token")); return (String) tokenObject.get("access_token"); } diff --git a/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysLoginController.java b/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysLoginController.java index 3cca9b9..31bd0c6 100644 --- a/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysLoginController.java +++ b/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysLoginController.java @@ -281,54 +281,4 @@ public class SysLoginController { } } - @At(value = "/platform/jsz/login",top = true) - public Object index(String username, String loginname) { - try { - Sql sql = Sqls.create(""" - SELECT - u.id userid, - u.username, - u.loginname, - u.sex, - u.mobile, - u.birthday, - unit.`name` unitname, - u.unitid, - u.member, - unit.unionid, - un.unionname, - group_concat(sr.`code`) roles, - '$schoolCode' as schoolCode - FROM - sys_user u - LEFT JOIN sys_unit unit ON u.unitid = unit.id - LEFT JOIN sys_union un ON unit.unionid = un.id - LEFT JOIN sys_user_role sur ON sur.userId = u.id - LEFT JOIN sys_role sr ON sr.id = sur.roleId - $condition - """).setParam("loginname", loginname).setParam("username", username); - sql.setVar("schoolCode", Globals.schoolCode); - Cnd cnd = Cnd.NEW(); -// cnd.and("LOWER(u.loginname)", "=", loginname.trim().toLowerCase()); - cnd.and(Cnd.exps("LOWER(u.loginname)", "=", loginname.trim().toLowerCase()).or("LOWER(u.mobile)", "=", loginname.trim().toLowerCase())); - cnd.and("LOWER(u.username)", "=", username.trim().toLowerCase()); - sql.setCondition(cnd); - sql.setCallback(Sqls.callback.map()); - sysUserService.dao().execute(sql); - NutMap user = (NutMap) sql.getResult(); - if (StrUtil.isBlank(user.getString("userid"))) { - return cn.wizzer.framework.base.Result.error().addMsg("系统查询不到您的信息,请与工会管理员联系!"); - } -// if(user.getInt("member",0)==0){ -// return Result.error().addMsg("您没有权限参加本次健步行,请与工会管理员联系!"); -// } - /*if (user.getInt("member", 0) != 1 && !user.getString("sex", "").equals("女")) { - return Result.error().addMsg("您没有权限参加本次健步行,请与工会管理员联系!"); - }*/ - return cn.wizzer.framework.base.Result.success().addData(user); - } catch (Exception e) { - return cn.wizzer.framework.base.Result.error(); - } - } - } diff --git a/src/main/java/io/v/nutz/sys/models/Sys_user.java b/src/main/java/io/v/nutz/sys/models/Sys_user.java index 3970300..9d9a10d 100644 --- a/src/main/java/io/v/nutz/sys/models/Sys_user.java +++ b/src/main/java/io/v/nutz/sys/models/Sys_user.java @@ -266,6 +266,7 @@ public class Sys_user extends BaseModel implements Serializable { @Column @Comment("会员加入时间") + @ColDefine(type = ColType.DATETIME) private Date memberJoinTime; /** diff --git a/src/main/java/io/v/nutz/web/commons/base/Globals.java b/src/main/java/io/v/nutz/web/commons/base/Globals.java index 5086160..ea20da0 100644 --- a/src/main/java/io/v/nutz/web/commons/base/Globals.java +++ b/src/main/java/io/v/nutz/web/commons/base/Globals.java @@ -53,15 +53,16 @@ public class Globals { //项目短名称 public static String AppShrotName = ""; //项目域名 (设置一个默认的 为优先级考虑) - public static String AppDomain = "https://zhgh.hmc.edu.cn"; + public static String AppDomain = "https://zhgh.ecjtu.edu.cn"; + // public static String AppDomain = "http://172.16.11.80"; //cas地址 - public static String CasAddress = "https://newca.hmc.edu.cn/cas"; + public static String CasAddress = "http://cas.ecjtu.edu.cn/cas"; //文件访问域名 public static String AppFileDomain = ""; //文件上传路径 public static String AppUploadBase = ""; //学校代码 - public static String schoolCode = "zufe"; + public static String schoolCode = "ecjtu"; //系统自定义参数 public static NutMap MyConfig = NutMap.NEW(); //自定义路由 @@ -69,7 +70,7 @@ public class Globals { //微信map public static NutMap WxMap = NutMap.NEW(); //高校名称 - public static String schoolName = "杭州医学院"; + public static String schoolName = "华东交通大学"; public static String BrandActivityName = ""; diff --git a/src/main/java/io/v/nutz/web/commons/proc/NutShiroProcessor.java b/src/main/java/io/v/nutz/web/commons/proc/NutShiroProcessor.java index 8cb7076..002a4c7 100644 --- a/src/main/java/io/v/nutz/web/commons/proc/NutShiroProcessor.java +++ b/src/main/java/io/v/nutz/web/commons/proc/NutShiroProcessor.java @@ -74,21 +74,7 @@ public class NutShiroProcessor extends AbstractProcessor { "/platform/home/(500|403|404|UnknownAccountError|LockedAccountError)", "/mobile/login", "/mobile/login/doLogin", - "/platform/jsz/login", - "/platform/activity/basic/scope/getScopeUser", - "/platform/fitnessWalk/stepManage/getActivityDateStep", - "/platform/fitnessWalk/stepManage/winningRecord", - "/platform/fitnessWalk/stepManage/updateStepMonth", - "/platform/fitnessWalk/stepRanking/getUserStepRanking", - "/platform/fitnessWalk/stepManage/getActivityQualifyProgressBar", - "/platform/fitnessWalk/stepWining/getUserStepWining", - "/platform/fitnessWalk/punchLottery/judgeWinningToPunch", - "/platform/fitnessWalk/punchLottery/getLotteryRecord", - "/platform/fitnessWalk/punchLottery/doExchange", - "/platform/fitnessWalk/punchLottery/getPunchWining", - "/platform/fitnessWalk/punchLottery/doReadLottery", - "/platform/fitnessWalk/stepWining/prizeOption", - "/platform/fitnessWalk/stepWining/prizeUsers" + "/platform/jsz/login" ); if (Arrays.stream(authIgnoreUrlArr).noneMatch(v -> Pattern.compile(v).matcher(requestURI).matches())) { if (match) { diff --git a/src/main/java/io/v/nutz/zhgh/data/constant/SourceData.java b/src/main/java/io/v/nutz/zhgh/data/constant/SourceData.java index 04ae47f..918de56 100644 --- a/src/main/java/io/v/nutz/zhgh/data/constant/SourceData.java +++ b/src/main/java/io/v/nutz/zhgh/data/constant/SourceData.java @@ -1,19 +1,26 @@ package io.v.nutz.zhgh.data.constant; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import io.v.nutz.base.expression.Exp4; import io.v.nutz.sys.models.Sys_unit; import io.v.nutz.zhgh.data.model.UserSource; +import org.apache.http.client.utils.URIBuilder; import org.nutz.json.Json; import org.nutz.lang.Strings; import org.nutz.lang.util.NutMap; +import org.springframework.util.Assert; +import wiremock.org.apache.commons.codec.binary.Base64; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.*; /** * 获取源数据配置 @@ -25,83 +32,61 @@ import java.util.Map; */ public interface SourceData { - /** - * 获取单位的地址 - */ - String DATA_URL = "https://zt.hmc.edu.cn/datacenter/dataServiceQuery"; + //加密算法 + String SIGNATURE_METHOD = "HmacSHA256"; + //私钥 + String PRIVATE_SECRET = "7lootinws7rm5ifhinvm6b2twgbakwtt "; + //公钥 + String PUBLIC_SECRET = "5yxqtb49f8yztg22sadu5n24zobb9qfw"; + String URL = "http://172.16.12.92:8020/exchange/api/requestHttp"; + /** * 断言是否成功 * * @param jsonResult 接口返回数据 */ - private static void checkSuccess(NutMap jsonResult) { -// Assert.isTrue(jsonResult.getBoolean("success"), jsonResult.getString("data")); + private static void checkSuccess(JSONObject jsonResult) { + Assert.isTrue(jsonResult.getInteger("code") == 200, jsonResult.getString("message")); } - /** - * 不进系统人员类型 - */ - List NOT_ENTERING_PERSON_TYPE = List.of("退休人员", "兼职教师", "非全日用工(项目临聘)", "服务外包和其他人员", - "教学编制2", "教学教师(附属医院)", "教学编制", "离休人员", "临时人员", "非全日制工", "博士后(在职)"); - /** - * 不进系统在职状态 - * 01 退休 - * 05 调出 - * 06 辞职 - * 07 离职 - * @see io.v.nutz.zhgh.data.constant.HMCFieldCode#USER_STATE_CODE - */ - List NOT_ENTERING_USER_STATE = List.of("01", "05", "06", "07"); + Map sexCode = new HashMap<>() {{ + put("0", "未知的性别"); + put("1", "男"); + put("2", "女"); + put("9", "未说明的性别"); + }}; - List NOT_ENTERING_USER_LOGIN_NAME = List.of("2020000410", "2008000010"); /** * 接口中的数据跟SourceUser的对应关系 - *

- * SourceUser [username,loginname] - * Result [name,code] - *

- * 例:{'name':['username'],'code':['loginname']} */ Map USER_FIELD_RELATION = new HashMap() {{ - put("GH", new String[]{"loginname"}); // 工号 - put("XM", new String[]{"username"}); // 姓名 - put("XBM", new String[]{"sex"});// 性别码 - put("MZMC", new String[]{"nation"});// 民族码 - put("SJ", new String[]{"mobile"}); // 手机号 - put("ZZMMM", new String[]{"political"}); // 政治面貌码 - put("DQZTM", new String[]{"userState"}); // 在职状态码 - put("RYFLMC", new String[]{"personType"}); // 人员类型码 - put("ZGXLM", new String[]{"education"}); // 最高学历码 - put("ZGXWM", new String[]{"academicDegree"}); // 最高学位码 - put("DWH", new String[]{"unitid"}); // 单位id - put("CSRQ", new String[]{"birthday"}); // 出生日期 - put("DZZWMC", new String[]{"position"}); // 党政职务 - put("XQMC", new String[]{"campus"}); // 校区 - put("DZZWJBM", new String[]{"administrativeLevel"}); // 行政职务级别 - put("ZYJSZWDJ", new String[]{"professionalTechnicalLevel"}); // 专业技术等级 - put("JZGLBM", new String[]{"userCategory"}); // 教职工类别 - put("GWLBM", new String[]{"jobCategory"}); // 岗位类别 + put("gh", new String[]{"loginname"});//工号 + put("dwh", new String[]{"unitid"});//所在单位编码 + put("xm", new String[]{"username"});//姓名 + put("xb", new String[]{"sex"});//性别码 + put("CSRQ", new String[]{"birthday"});//出生日期 + put("jg", new String[]{"hometown"});//籍贯 + put("mz", new String[]{"nation"});//民族 + put("sfzjh", new String[]{"idcard"});//身份证件号 + put("sfzjlx", new String[]{"idType"});//身份证件有效期 + put("zzmmmc", new String[]{"political"});//政治面貌码 + put("cjgzny", new String[]{"workStartDate"});//参加工作年月 + put("rylb", new String[]{"personType"});//教职工类别码 + put("ryzt", new String[]{"userState"});//教职工当前状态码 + put("ZGXLM", new String[]{"education"});//最高学历码 + put("lxdh", new String[]{"mobile"});//移动电话 + put("dzyx", new String[]{"email"});//电子邮箱 }}; /** * 字段插件 */ Map USER_FIELD_PLUGIN = new HashMap() {{ -// put("ZZZTMC", v -> Strings.sBlank(USER_STATE_CODE.get(v), "")); - put("XBM", v -> Strings.sBlank(HMCFieldCode.SEX_CODE.get(v), "")); - put("ZZMMM", v -> Strings.sBlank(HMCFieldCode.POLITICAL_CODE.get(v), "")); - put("DQZTM", v -> Strings.sBlank(HMCFieldCode.USER_STATE_CODE.get(v), "")); - put("ZGXLM", v -> Strings.sBlank(HMCFieldCode.EDUCATION_CODE.get(v), "")); - put("ZGXWM", v -> Strings.sBlank(HMCFieldCode.ACADEMIC_DEGREE_CODE.get(v), "")); - put("XQMC", v -> Strings.sBlank(HMCFieldCode.CAMPUS_CODE.get(v), "")); - put("DZZWJBM", v -> Strings.sBlank(HMCFieldCode.ADMINISTRATIVE_LEVEL_CODE.get(v), "")); - put("ZYJSZWDJ", v -> Strings.sBlank(HMCFieldCode.PROFESSIONAL_TECHNICAL_LEVEL_CODE.get(v), "")); - put("JZGLBM", v -> Strings.sBlank(HMCFieldCode.USER_CATEGORY.get(v), "")); - put("GWLBM", v -> Strings.sBlank(HMCFieldCode.JOB_CATEGORY.get(v), "")); }}; + /** * 获取源用户数据 * @@ -109,25 +94,20 @@ public interface SourceData { */ static List users() { List users = new ArrayList<>(); - int page = 1; + String apiAuthUserCode = "SJK2023112916218839"; + int pageNo = 1; + int pageSize = 100; boolean hasRecords = true; - int maxPage; while (hasRecords) { - String body = HttpUtil.createPost(DATA_URL).body(JSON.toJSONString(new NutMap().addv("address", "jzgjbxx").addv("params", new NutMap()) - .addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 500))).execute().body(); - NutMap map = Json.fromJson(NutMap.class, body); -// checkSuccess(map); - List data = map.getAsList("data", NutMap.class); - for (NutMap row : data) { -// if (NOT_ENTERING_PERSON_TYPE.contains(row.getString("RYFLMC")) -// || NOT_ENTERING_USER_LOGIN_NAME.contains(row.getString("GH")) -// || NOT_ENTERING_USER_STATE.contains(row.getString("DQZTM"))) { -// continue; -// } - Map entity = new HashMap(500); + HttpRequest httpRequest = getData(apiAuthUserCode, pageNo, pageSize); + JSONObject jsonObject = JSON.parseObject(httpRequest.execute().body()); + checkSuccess(jsonObject); + List data = jsonObject.getJSONObject("data").getJSONArray("lists").toJavaList(JSONObject.class); + for (JSONObject row : data) { + Map entity = new HashMap(10); row.forEach((k, v) -> { - if (USER_FIELD_RELATION.containsKey(k)) { + if(USER_FIELD_RELATION.containsKey(k)) { Object value = v; if (USER_FIELD_PLUGIN.containsKey(k)) { value = USER_FIELD_PLUGIN.get(k).run(v); @@ -139,10 +119,9 @@ public interface SourceData { }); users.add(BeanUtil.mapToBean(entity, UserSource.class, true)); } - int totalCount = map.getInt("totalCount"); - maxPage = (int) Math.ceil((double) totalCount / 500); - page++; - if (page > maxPage) { + pageNo++; + int totalPage = (int) Math.ceil((double) jsonObject.getJSONObject("data").getInteger("totalCount") / pageSize); + if (pageNo > totalPage) { hasRecords = false; } } @@ -153,10 +132,9 @@ public interface SourceData { * 单位对应接口字段 */ Map UNIT_FIELD_RELATION = new HashMap() {{ - put("DWH", new String[]{"id", "unitcode"}); - put("DWMC", new String[]{"name"}); - put("SJDWH", new String[]{"parentId"}); - put("PX", new String[]{"location"}); + put("dwh", new String[]{"id", "unitcode"}); + put("dwmc", new String[]{"name"}); + put("lsdwh", new String[]{"parentId"}); }}; /** @@ -172,31 +150,108 @@ public interface SourceData { */ static List units() { List units = new ArrayList<>(); - int page = 1; - String body = HttpUtil.createPost(DATA_URL).body(JSON.toJSONString(new NutMap().addv("address", "rsxt_dwjbsj").addv("params", new NutMap()) - .addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 100))).execute().body(); -// String body = HttpUtil.get(DATA_URL, new NutMap().addv("address", "rsxt_dwjbsj").addv("params", new NutMap()) -// .addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 1000)); - NutMap map = Json.fromJson(NutMap.class, body); -// checkSuccess(map); - List data = map.getAsList("data", NutMap.class); - - for (NutMap row : data) { - Map entity = new HashMap(5); - row.forEach((k, v) -> { - if (UNIT_FIELD_RELATION.containsKey(k)) { - Object value = v; - /* if (UNIT_FIELD_PLUGIN.containsKey(k)) { - value = UNIT_FIELD_PLUGIN.get(k).run(v); - }*/ - for (String key : UNIT_FIELD_RELATION.get(k)) { - entity.put(key, value); - } + String apiAuthUnitCode = "SJK2023112915232278"; + int pageNo = 1; + int pageSize = 100; + boolean hasRecords = true; + while (hasRecords) { + HttpRequest httpRequest = getData(apiAuthUnitCode,pageNo,pageSize); + JSONObject jsonObject = JSON.parseObject(httpRequest.execute().body()); + checkSuccess(jsonObject); + List data = jsonObject.getJSONObject("data").getJSONArray("lists").toJavaList(JSONObject.class); + for (JSONObject row : data) { + if ("1".equals(row.getString("sfcxm"))){ + continue; } - }); - units.add(BeanUtil.mapToBean(entity, Sys_unit.class, true)); + Map entity = new HashMap(5); + + row.forEach((k, v) -> { + if(UNIT_FIELD_RELATION.containsKey(k)) { + Object value = v; + if (UNIT_FIELD_PLUGIN.containsKey(k)) { + value = UNIT_FIELD_PLUGIN.get(k).run(v); + } + for (String key : UNIT_FIELD_RELATION.get(k)) { + entity.put(key, value); + } + + } + }); + units.add(BeanUtil.mapToBean(entity, Sys_unit.class, true)); + } + pageNo++; + int totalPage = (int) Math.ceil((double) jsonObject.getJSONObject("data").getInteger("totalCount") / pageSize); + if (pageNo > totalPage) { + hasRecords = false; + } } return units; + + } + + + /** + * 获取InputStreamReader + * + * @param codePath + * @return + */ + static InputStreamReader getIsReaderByCodePath(String codePath) { + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(codePath); + return new InputStreamReader(is); + } + + + /** + * 华交通过签名获取单位、人员数据 + * + * @param apiAuthCode + * @return + */ + private static HttpRequest getData(String apiAuthCode,Integer pageNo,Integer pageSize){ + NutMap header = new NutMap(); + header.put("Accept", "application/json"); + header.put("Content-Type", "application/json;charset=utf-8"); + header.put("Date", String.valueOf(new Date())); + header.put("x-ca-key", PUBLIC_SECRET); + header.put("x-ca-signature-method", SIGNATURE_METHOD); + header.put("x-ca-timestamp", String.valueOf(System.currentTimeMillis())); + + HttpRequest httpRequest = HttpUtil.createPost(URL); + header.forEach((k, v) -> { + httpRequest.header(k, (String) v); + }); + try { + StringBuffer signatureStrBuffer = new StringBuffer(); + signatureStrBuffer.append(httpRequest.getMethod().name().toUpperCase()).append("\n") + .append(header.get("Accept")).append("\n") + .append(header.get("Content-Type")).append("\n") + .append(header.get("Date")).append("\n") + .append("x-ca-key").append(":").append(PUBLIC_SECRET).append("\n") + .append("x-ca-signature-method").append(":").append(SIGNATURE_METHOD).append("\n") + .append("x-ca-timestamp").append(":").append(header.get("x-ca-timestamp")).append("\n") + .append(new URIBuilder(URL).getPath()); + // 签名字符串 + String signatureStr = signatureStrBuffer.toString(); + + Mac hmac = Mac.getInstance(SIGNATURE_METHOD); + byte[] keyBytes = PUBLIC_SECRET.getBytes("UTF-8"); + hmac.init(new SecretKeySpec(PRIVATE_SECRET.getBytes("UTF-8"), 0, keyBytes.length, SIGNATURE_METHOD)); + byte[] md5Result = hmac.doFinal(signatureStr.getBytes("UTF-8")); + String sign = Base64.encodeBase64String(md5Result); + //将签名添加到请求头x-ca-signature + httpRequest.header("x-ca-signature", sign); + NutMap parameter = new NutMap(); + parameter.put("apiAuthCode", apiAuthCode); + parameter.put("pageNo", pageNo); + parameter.put("pageSize", pageSize); + httpRequest.body(JSONUtil.toJsonStr(parameter)); + + return httpRequest; + } catch (Exception e) { + e.printStackTrace(); + return null; + } } } diff --git a/src/main/java/io/v/nutz/zhgh/data/controller/SourceUserController.java b/src/main/java/io/v/nutz/zhgh/data/controller/SourceUserController.java index 4279786..c64f188 100644 --- a/src/main/java/io/v/nutz/zhgh/data/controller/SourceUserController.java +++ b/src/main/java/io/v/nutz/zhgh/data/controller/SourceUserController.java @@ -72,9 +72,9 @@ public class SourceUserController { CndPlus cnd = CndPlus.create(); cnd.and(pageForm); - cnd.andEx("unitid", "=", unitId); - cnd.andEx("personType", "=", personType); - cnd.andEx("userState", "=", userState); + cnd.andEX("unitid", "=", unitId); + cnd.andEX("personType", "=", personType); + cnd.andEX("userState", "=", userState); if(!StringUtils.isEmpty(importDate)){ cnd.and("DATE(u.pullTime)", "=", importDate); diff --git a/src/main/java/io/v/nutz/zhgh/data/controller/UpdateUserController.java b/src/main/java/io/v/nutz/zhgh/data/controller/UpdateUserController.java index 3e97cc1..2b955e0 100644 --- a/src/main/java/io/v/nutz/zhgh/data/controller/UpdateUserController.java +++ b/src/main/java/io/v/nutz/zhgh/data/controller/UpdateUserController.java @@ -3,6 +3,7 @@ package io.v.nutz.zhgh.data.controller; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; +import cn.hutool.core.util.StrUtil; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.dao.CndPlus; import io.v.nutz.base.utils.ViResource; @@ -77,12 +78,14 @@ public class UpdateUserController { CndPlus cnd = CndPlus.create(); cnd.and(pageForm); - cnd.andEx("u.unitid", "=", unitId); - cnd.andEx("u.personType", "=", personType); - cnd.andEx("u.userState", "=", userState); + cnd.andEX("u.unitid", "=", unitId); + cnd.andEX("u.personType", "=", personType); + cnd.andEX("u.userState", "=", userState); - cnd.andEx("Date(his.changeTime)", "=", changeDate); - cnd.andEx("his.changeType", "=", changeType); + if (StrUtil.isNotBlank(changeDate)) { + cnd.and("DATE(his.changeTime)", "=", changeDate); + } + cnd.andEX("his.changeType", "=", changeType); sql.setCondition(cnd); diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/JszUniontjController.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/JszUniontjController.java new file mode 100644 index 0000000..54f47ed --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/JszUniontjController.java @@ -0,0 +1,60 @@ +package io.v.nutz.zhgh.jsz.controller.cxtj; + +import cn.wizzer.framework.base.Result; +import cn.wizzer.framework.base.service.BaseService; +import io.v.nutz.base.utils.WxHttpUtil; +import io.v.nutz.web.commons.base.Globals; +import org.nutz.dao.Cnd; +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 java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +@IocBean +@At("/platform/jsz/cxtj/union") +@Ok("json:full") +public class JszUniontjController { + + @Inject + private WxHttpUtil wxHttpUtil; + + @Inject + private BaseService baseService; + + @At("") + @Ok("re") + public String index(){ + return "beetl:/platform/jsz/cxtj/hdunion.html"; + } + + @At + public Object getAllUnion(){ + return Result.success().addData(baseService.dao().query("sys_union", Cnd.NEW())); + } + + @At + public Object pageData(@Param(value = "pageNumber",required = false) Integer pageNumber, + @Param(value = "pageSize",required = false) Integer pageSize, + @Param("hdid") String hdid){ + //hdid="65825b355f562cf500f37a2667b36e3c"; + Map reqBody = new HashMap(); + reqBody.put("activity_id", hdid); + reqBody.put("schoolCode", Globals.schoolCode); + try { + NutMap result = wxHttpUtil.getCloudResult(wxHttpUtil.cloudUrl, "getBmInfo", reqBody); + NutMap resp_data = result.getAs("resp_data", NutMap.class); + return Result.success().addData(resp_data); + } catch (IOException e) { + e.printStackTrace(); + return Result.error(); + } + + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/JszptphbController.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/JszptphbController.java new file mode 100644 index 0000000..2655f29 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/JszptphbController.java @@ -0,0 +1,42 @@ +package io.v.nutz.zhgh.jsz.controller.cxtj; + +import cn.wizzer.framework.base.Result; +import io.v.nutz.base.utils.WxHttpUtil; +import io.v.nutz.web.commons.base.Globals; +import org.apache.shiro.authz.annotation.RequiresPermissions; +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; + +@IocBean +@At("/platform/jsz/cxtj/phbtj") +@Ok("json:full") +public class JszptphbController { + + @Inject + private WxHttpUtil wxHttpUtil; + + @At("") + @Ok("re") + @RequiresPermissions("jsz.cxtj.phbtj") + public String index(){ + return "beetl:/platform/jsz/cxtj/phb.html"; + } + + + @At + @RequiresPermissions("jsz.cxtj.phbtj") + public Object data(){ + try { + NutMap rankAll = wxHttpUtil.getCloudResult(wxHttpUtil.cloudUrl, "rankAll", NutMap.NEW().addv("schoolCode", Globals.schoolCode)); + return Result.success().addData(rankAll); +// List yearlist = yearMap.getAs("resp_data", NutMap.class).getAs("data", NutMap.class).getAsList("list", NutMap.class); +// return Result.success().addData(NutMap.NEW().addv("daylist",daylist).addv("weeklist",weeklist) + } catch (Exception e) { + e.printStackTrace(); + return Result.error(); + } + } +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/LeaderboardController.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/LeaderboardController.java new file mode 100644 index 0000000..23b638f --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/LeaderboardController.java @@ -0,0 +1,97 @@ +package io.v.nutz.zhgh.jsz.controller.cxtj; + +import cn.hutool.core.util.StrUtil; +import cn.wizzer.framework.base.Result; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.utils.WxHttpUtil; +import io.v.nutz.zhgh.jsz.services.JszWxStepService; +import io.v.nutz.web.commons.utils.ShiroUtil; +import org.apache.shiro.authz.annotation.RequiresPermissions; +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 java.util.Map; + +/** + * @Author JyuHsin + * @Date 2022/9/7 + * @Description 排行榜 + */ +@At("/jsz/leaderboard") +@Ok("json:full") +@IocBean +public class LeaderboardController { + + @Inject + private JszWxStepService jszWxStepService; + + @Inject + private WxHttpUtil wxHttpUtil; + + @At("") + @Ok("re") + @RequiresPermissions("jsz.cxtj.leaderboard") + public String index() { + return "beetl:/platform/jsz/cxtj/leaderboard.html"; + } + + /** + * 获取排行榜数据 + * + * @param hdid: 活动id + * @param type: 0-当日榜 1-累计排行榜 2-当日中奖榜 + * @return java.lang.Object + * @author JyuHsin + * @date 2022/9/7 + */ + @At + @ViReturn + @RequiresPermissions("jsz.cxtj.leaderboard") + public Object getData(@Param(value = "hdid",required = false) String hdid, + @Param(value = "type",required = false) Integer type, + @Param(value = "userId",required = false) String userId) { + if (type == null) { + return Result.error("参数错误"); + } + switch (type) { + case 0: + case 1: + return jszWxStepService.getDataOfLeaderboard(hdid, type, userId, "", "", "", ""); + case 2: + return jszWxStepService.getDataOfPrize(hdid, "", "", "", ""); + default: + break; + } + return null; + } + + @At + @ViReturn + @RequiresPermissions("jsz.cxtj.leaderboard") + public Object pageData(@Param(value = "hdid",required = false) String hdid, + @Param(value = "searchName",required = false) String searchName, + @Param(value = "searchKeyword",required = false) String searchKeyword, + @Param(value = "unionId",required = false) String unionId, + @Param(value = "unitId",required = false) String unitId) { + + if (StrUtil.isBlank(hdid)) { + return Result.error("参数错误!"); + } + + String userId = ShiroUtil.getPrincipalProperty("id").toString(); + Object today = jszWxStepService.getDataOfLeaderboard(hdid, 0, userId, unionId, unitId, searchName, searchKeyword); + Object summary = jszWxStepService.getDataOfLeaderboard(hdid, 1, userId, unionId, unitId, searchName, searchKeyword); + Object yesterday = jszWxStepService.getDataOfPrize(hdid, unionId, unitId, searchName, searchKeyword); + + NutMap map = NutMap.NEW(); + map.put("today", Map.of("list", today)); + map.put("summary", Map.of("list", summary)); + map.put("yesterday", Map.of("list", yesterday)); + return map; + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/UnionRegisterInfoCon.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/UnionRegisterInfoCon.java new file mode 100644 index 0000000..2981428 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/cxtj/UnionRegisterInfoCon.java @@ -0,0 +1,739 @@ +package io.v.nutz.zhgh.jsz.controller.cxtj; + +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.annotation.Excel; +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 cn.wizzer.framework.base.service.BaseService; +import cn.wizzer.framework.page.Pagination; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.utils.ViTool; +import io.v.nutz.base.utils.WxHttpUtil; +import io.v.nutz.sys.models.Sys_union; +import io.v.nutz.sys.services.SysUnionService; +import lombok.Data; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.shiro.authz.annotation.RequiresAuthentication; +import org.apache.shiro.authz.annotation.RequiresPermissions; +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.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.http.HttpServletResponse; +import java.io.IOException; +import java.io.Serializable; +import java.util.*; +import java.util.stream.Collectors; + +import static java.util.Comparator.comparing; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toCollection; + +/** + * @Author: 1V + * @DateTime: 2020/9/19 14:55 + * @Description: 工会报名参与信息 + */ +@At("/platform/jsz/union/registerInfo") +@Ok("json:full") +@IocBean +@RequiresAuthentication +public class UnionRegisterInfoCon { + @Inject + private WxHttpUtil wxHttpUtil; + + @At("") + @Ok("beetl:/platform/jsz/cxtj/unionRegisterInfo.html") + @RequiresPermissions("jsz.union.registerInfo") + public void index() { + } + + @Inject + private SysUnionService sysUnionService; + + @At + @ViReturn + @RequiresPermissions("jsz.union.registerInfo") + public Object getData(String activity_id, @Param("activity_tag[]") String[] activity_tag) throws IOException { + return data(activity_id, activity_tag); + } + + private List data(String activity_id, String[] activity_tag) throws IOException { + List unions = sysUnionService.query(); + Map reqBody = new HashMap<>(); + reqBody.put("unions", unions); + reqBody.put("activity_id", activity_id); + reqBody.put("activity_tag", activity_tag); + NutMap result = wxHttpUtil.getCloudResult(wxHttpUtil.cloudUrl, "getRegisterInfo", reqBody); + List resp_data = result.getAs("resp_data", List.class); + return resp_data; + } + + @At + @Ok("void") + @RequiresPermissions("jsz.union.registerInfo") + public void exportAllUnionData(String activity_id, String activity_name, String activity_tag, HttpServletResponse response) throws IOException { + try { + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + new String((activity_name + "院级工会报名统计表.xls").getBytes("utf-8"), "ISO8859-1")); + + ArrayList list = new ArrayList<>(); + List data = data(activity_id, activity_tag.split(",")); + data.forEach(val -> { + Map v = (Map) val; + E e = new E(); + e.setName((String) v.get("unionname")); + e.setReg_num((Integer) v.get("reg_num")); + e.setSign_num((Integer) v.get("sign_num")); + list.add(e); + }); + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), E.class, list); + workbook.write(response.getOutputStream()); + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + @At + @RequiresPermissions("jsz.union.registerInfo") + public void regExport(String activity_id, String activity_tag, String unionname, String unionid, HttpServletResponse response) throws IOException { + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + new String((unionname + "报名名单.xls").getBytes("utf-8"), "ISO8859-1")); + + Map reqBody = new HashMap(); + reqBody.put("activity_id", activity_id); + reqBody.put("activity_tag", Json.fromJsonAsArray(String.class, activity_tag)); + reqBody.put("unionid", unionid); + + +// NutMap result = wxHttpUtil.getCloudResult(wxHttpUtil.cloudUrl, "getRegisterUsers", reqBody); +// List data = result.getAs("resp_data", List.class); + + Integer pageSize = 20; + Integer pageNum = 1; + List allRegister = new ArrayList<>(); + List oneData = getAllRegister(unionid, activity_id, activity_tag, pageNum, pageSize); + while (oneData.size() > 0) { + allRegister.addAll(oneData); + pageNum++; + oneData = getAllRegister(unionid, activity_id, activity_tag, pageNum, pageSize); + } + System.out.println(allRegister); + + ArrayList list = new ArrayList<>(); + allRegister.forEach(v -> { + RegE e = new RegE(); + e.setActivity_name(StrUtil.isBlank((String) v.get("activity_tag")) ? (String) v.get("activity_name") : v.get("activity_tag") + "-" + v.get("activity_name")); + e.setLoginname((String) v.get("loginname")); + e.setUsername((String) v.get("username")); + e.setSex((String) v.get("sex")); + e.setUnitname((String) v.get("unitname")); + list.add(e); + }); + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), RegE.class, list); + workbook.write(response.getOutputStream()); + +// ArrayList list = new ArrayList<>(); +// data.forEach(val -> { +// Map v = (Map) val; +// RegE e = new RegE(); +// e.setActivity_name((String) v.get("activity_name")); +// e.setLoginname((String) v.get("loginname")); +// e.setUsername((String) v.get("username")); +// e.setSex((String) v.get("sex")); +// e.setUnitname((String) v.get("unitname")); +// list.add(e); +// }); +// +// Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), RegE.class, list); +// workbook.write(response.getOutputStream()); + } + + + private List getAllRegister(String unionid, String activity_id, String activity_tag, Integer pageNumber, Integer pageSize) throws IOException { + String s = String.format( + """ + db.collection('register') + .aggregate() + .lookup({ + from: 'activity', + localField: 'activity_id', + foreignField: '_id', + as: 'activity' + }) + .addFields({ + activity_name: $.arrayElemAt(['$activity.name',0]), + activity_tag: $.arrayElemAt(['$activity.tag',0]) + }) + .match({ + unionid:'%s', + 'activity._id':_.in(%s) + }).project({ + loginname: true, + sex: true, + username: true, + unionname: true, + unionid: true, + unitname: true, + unitid: true, + mobile: true, + register_time: true, + activity_name: true, + activity_tag:true + }).sort({ 'unitid': 1, 'register_time': -1 }).skip(%d).limit(%d).end() + """, unionid, StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(Json.fromJsonAsArray(String.class, activity_tag)), (pageNumber - 1) * pageSize, pageSize + ); + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.aggregateUrl, s); + List data = result.getList("data", Map.class); + return data; + } + + + @At + @Ok("void") + @RequiresPermissions("jsz.union.registerInfo") + public void signExport(String activity_id, String activity_tag, String unionname, String unionid, HttpServletResponse response) throws IOException { + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + new String((unionname + "参与名单.xlsx").getBytes("utf-8"), "ISO8859-1")); + + Map reqBody = new HashMap(); + reqBody.put("activity_id", activity_id); + reqBody.put("activity_tag", Json.fromJsonAsArray(String.class, activity_tag)); + reqBody.put("unionid", unionid); + + NutMap result = wxHttpUtil.getCloudResult(wxHttpUtil.cloudUrl, "getSignUsers", reqBody); + List data = result.getAs("resp_data", List.class); + + ArrayList list = new ArrayList<>(); + for (NutMap v : data) { + SignE e = new SignE(); +// e.setActivity_name((String) v.get("activity_name")); + e.setLoginname((String) v.get("loginname")); + e.setUsername((String) v.get("username")); + e.setSex((String) v.get("sex")); + e.setMobile((String) v.get("mobile")); + e.setUnitname((String) v.get("unitname")); + e.setSignnum(v.getInt("sign_size")); + list.add(e); + } + + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, SignE.class, list); + workbook.write(response.getOutputStream()); + } + + + public class RegE implements Serializable { + @Excel(name = "活动", width = 40.0D) + private String activity_name; + + public String getActivity_name() { + return activity_name; + } + + public void setActivity_name(String activity_name) { + this.activity_name = activity_name; + } + + @Excel(name = "工号", width = 20.0D) + private String loginname; + + @Excel(name = "姓名", width = 20.0D) + private String username; + + @Excel(name = "性别", width = 20.0D) + private String sex; + + @Excel(name = "电话", width = 20.0D) + private String mobile; + + @Excel(name = "单位", width = 60.0D) + private String unitname; + + public String getLoginname() { + return loginname; + } + + public void setLoginname(String loginname) { + this.loginname = loginname; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getSex() { + return sex; + } + + public void setSex(String sex) { + this.sex = sex; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getUnitname() { + return unitname; + } + + public void setUnitname(String unitname) { + this.unitname = unitname; + } + } + + @Data + public static class SignE implements Serializable { + + @Excel(name = "工号", width = 20.0D) + private String loginname; + + @Excel(name = "姓名", width = 20.0D) + private String username; + + @Excel(name = "性别", width = 20.0D) + private String sex; + + @Excel(name = "电话", width = 20.0D) + private String mobile; + + @Excel(name = "单位", width = 60.0D) + private String unitname; + + @Excel(name = "工会", width = 60.0D) + private String unionname; + + @Excel(name = "签到点位数", width = 20.0D) + private Integer signnum; + } + + @Data + public static class E implements Serializable { + @Excel(name = "院级工会", width = 60.0D) + private String name; + + @Excel(name = "报名人数", width = 20.0D) + private Integer reg_num; + + @Excel(name = "参加人数", width = 20.0D) + private Integer sign_num; + } + + @At + @ViReturn + @RequiresPermissions("jsz.union.registerInfo") + public Object getRegisterUser(String activity_id, @Param("activity_tag[]") String[] activity_tag, String unionid, Integer pageNumber, Integer pageSize) throws IOException { + int skip = (pageNumber == 1 ? 0 : (pageNumber - 1)) * pageSize; + + Map map = new HashMap<>() {{ + put("unionid", unionid); + }}; + + /*if (Strings.isNotBlank(activity_tag)) { + map.put("activity.tag", activity_tag); + }*/ + if (Strings.isNotBlank(activity_id)) { + map.put("activity._id", activity_id); + } + + String match = Json.toJson(map); + + String s = String.format( + """ + db.collection('register') + .aggregate() + .lookup({ + from: 'activity', + localField: 'activity_id', + foreignField: '_id', + as: 'activity' + }) + .addFields({ + activity_name: $.arrayElemAt(['$activity.name',0]), + activity_tag: $.arrayElemAt(['$activity.tag',0]) + }) + .match({ + unionid:'%s', + 'activity._id':_.in(%s) + }).project({ + loginname: true, + sex: true, + username: true, + unionname: true, + unionid: true, + unitname: true, + mobile: true, + unitid: true, + register_time: true, + activity_name: true, + activity_tag:true + }).sort({ 'unitid': 1, 'register_time': -1 }).skip(%d).limit(%d).end() + """, unionid, StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(activity_tag), skip, pageSize + ); + + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.aggregateUrl, s); + + + + String count_s = String.format( + """ + db.collection('register').where( + { + unionid:'%s', + activity_id:_.in(%s) + } + ).count() + """, unionid, StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(activity_tag) + ); + NutMap countResult = wxHttpUtil.getWxResult(wxHttpUtil.countUrl, count_s); + + return new Pagination(pageNumber, pageSize, countResult.getInt("count"), result.getList("data", Map.class)); + } + + @At + @ViReturn + @RequiresPermissions("jsz.union.registerInfo") + public Object getSignUser(String activity_id, @Param("activity_tag[]") String[] activity_tag, String unionid, Integer pageNumber, Integer pageSize) throws IOException { + int skip = (pageNumber == 1 ? 0 : (pageNumber - 1)) * pageSize; + String s = """ + db.collection('sign').aggregate().match({ + activity_id: _.in(%s), + unionid:"%s"}).group({ + _id: { + activity_id: '$activity_id', + loginname: '$loginname' + }, + num: $.sum(1), + data: $.first('$$ROOT') + }).lookup({ + from: 'activity', + localField: 'data.activity_id', + foreignField: '_id', + as: 'activity' + }).addFields({ + activity: $.arrayElemAt(['$activity', 0]) + }).project({ + loginname: '$data.loginname', + sex: '$data.sex', + username: '$data.username', + unitname: '$data.unitname', + unionname: '$data.unionname', + pts_size: $.size('$activity.pts'), + sign_size: '$num' + }).skip(%d).limit(%d) + .end() + + """.formatted(StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(activity_tag), + unionid, skip, pageSize); + + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.aggregateUrl, s); + + + String count_s = """ + db.collection('sign').aggregate().match({ + activity_id:_.in(%s), + unionid:'%s' + }).group({ + _id:'$userid', + count: $.sum(1), + }).end() + """.formatted(StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(activity_tag), + unionid); + + + NutMap countResult = wxHttpUtil.getWxResult(wxHttpUtil.aggregateUrl, count_s); + + return new Pagination(pageNumber, pageSize, countResult.getList("data", Map.class).size(), result.getList("data", Map.class)); + } + + final Integer LIMIT = 1000; + + @At + @RequiresPermissions("jsz.union.registerInfo") + public void doGiftExport(String activity_id, String activity_tag, Boolean flag, HttpServletResponse response) throws IOException { + response.setContentType("application/octet-stream"); + + String fileName = flag ? "已领取礼品的用户" : "未领取礼品的用户"; + response.setHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".xls").getBytes("utf-8"), "ISO8859-1")); + + Map reqBody = new HashMap<>(); + reqBody.put("activity_id", activity_id); + + String count = """ + db.collection('gift_voucher').where({activity_id: _.in(%s),used:%b}).count() + """.formatted((StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(Json.fromJsonAsArray(String.class, activity_tag))), + flag); + NutMap wxResultCount = wxHttpUtil.getWxResult(wxHttpUtil.countUrl, count); + + int count1 = wxResultCount.getInt("count"); + + List list2 = new ArrayList<>(); + + int ceil = (int) Math.ceil(count1 / LIMIT) + 1; + + for (int i = 0; i < ceil; i++) { + Integer num = i == 0 ? LIMIT : count1 - LIMIT; + String query = """ + db.collection('gift_voucher') + .where({ + activity_id: _.in(%s), + used: %s + }) + .orderBy('use_time', 'desc') + .skip(%s) + .limit(%s) + .get() + """.formatted(StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(Json.fromJsonAsArray(String.class, activity_tag)) + , flag, i * LIMIT, num); + + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + List data = wxResult.getList("data", Map.class); + list2.addAll(data); + } + + List giftEList = list2.stream().map(v -> { + giftE e = new giftE(); + e.set_openid((String) v.get("_openid")); + e.setLoginname((String) v.get("loginname")); + e.setUsername((String) v.get("username")); + e.setUnitname((String) v.get("unitname")); + e.setUnionname((String) v.get("unionname")); + return e; + }).collect(Collectors.toList()); + ArrayList collect = giftEList.stream().collect( + collectingAndThen(toCollection(() -> new TreeSet<>(comparing(o -> o.get_openid()))), + ArrayList::new)); + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), giftE.class, collect); + workbook.write(response.getOutputStream()); + } + + @At + @Ok("void") + @RequiresPermissions("jsz.union.registerInfo") + public void doExportSummary(String activity_id, String activity_tag, HttpServletResponse response) throws Exception { + + NutMap cloudResult = wxHttpUtil.getCloudResult(wxHttpUtil.cloudUrl, "findActivityInfo", Map.of("activity_id", activity_id, "activity_tag", Json.fromJsonAsArray(String.class, activity_tag))); + NutMap resp_data = cloudResult.getAs("resp_data", NutMap.class); + List pts = resp_data.getList("pts", NutMap.class); + int ptsLength = pts.size(); + + + Map reqBody = new HashMap<>(); + reqBody.put("activity_id", activity_id); + + String count = """ + db.collection('register').where({activity_id: _.in(%s)}).count() + """.formatted((StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(Json.fromJsonAsArray(String.class, activity_tag)))); + NutMap wxResultCount = wxHttpUtil.getWxResult(wxHttpUtil.countUrl, count); + int count1 = wxResultCount.getInt("count"); + + List list2 = new ArrayList<>(); + + int ceil = (int) Math.ceil(count1 / LIMIT) + 1; + for (int i = 0; i < ceil; i++) { + Integer num = i == 0 ? LIMIT : count1 - LIMIT; + String query = """ + db.collection('register') + .where({ + activity_id: _.in(%s) + }) + .orderBy('unitid', 'desc') + .skip(%s) + .limit(%s) + .get() + """.formatted(StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(Json.fromJsonAsArray(String.class, activity_tag)) + , i * LIMIT, num); + + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + List data = wxResult.getList("data", NutMap.class); + list2.addAll(data); + } + + Map signReqBody = new HashMap(); + signReqBody.put("activity_id", activity_id); + signReqBody.put("activity_tag", Json.fromJsonAsArray(String.class, activity_tag)); + //签到数据 + NutMap result = wxHttpUtil.getCloudResult(wxHttpUtil.cloudUrl, "getSignUserAll", signReqBody); + List signData = result.getAs("resp_data", List.class); + for (NutMap val : signData) { + NutMap v = val.getAs("data", NutMap.class); + val.setv("loginname", v.getString("loginname")); + } + + List excelExportEntities = new ArrayList<>(); + excelExportEntities.add(new ExcelExportEntity("工号", "loginname", 20)); + excelExportEntities.add(new ExcelExportEntity("姓名", "username", 20)); + excelExportEntities.add(new ExcelExportEntity("性别", "sex", 20)); + excelExportEntities.add(new ExcelExportEntity("电话", "mobile", 20)); + excelExportEntities.add(new ExcelExportEntity("工会", "unionname", 20)); + excelExportEntities.add(new ExcelExportEntity("单位", "unitname", 20)); + excelExportEntities.add(new ExcelExportEntity("是否参加", "isTakePartIn", 20)); + excelExportEntities.add(new ExcelExportEntity("签到点位数", "signNum", 20)); + + for (NutMap nutMap : list2) { + String loginname = nutMap.getString("loginname"); + Optional signDataMap = signData.stream().filter(v -> StrUtil.isNotBlank(v.getString("loginname")) && v.getString("loginname").equals(loginname)).findFirst(); + if (signDataMap.isPresent()) { + int signNum = signDataMap.get().getInt("num", 0); + nutMap.setv("isTakePartIn", signNum > 0 ? "是" : "否"); + nutMap.setv("signNum", Math.min(signNum, ptsLength)); + } else { + nutMap.setv("isTakePartIn", "否"); + nutMap.setv("signNum", 0); + } + } + +// +// ArrayList collect = giftEList.stream().collect( +// collectingAndThen(toCollection(() -> new TreeSet<>(comparing(o -> o.get_openid()))), +// ArrayList::new)); + ViTool.excelResponse(response, "活动汇总表.xls"); + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), excelExportEntities, list2); + workbook.write(response.getOutputStream()); + } + + @Data + public static class giftE implements Serializable { + + private String _openid; + + @Excel(name = "工号", width = 20D) + private String loginname; + + @Excel(name = "姓名", width = 20D) + private String username; + + @Excel(name = "单位", width = 20D) + private String unitname; + + @Excel(name = "工会", width = 20D) + private String unionname; + } + + @Inject + private BaseService baseService; + + //导出全部人员excel列数据 + private static final List excelExportEntityList = new ArrayList<>() {{ + add(new ExcelExportEntity("姓名", "username", 20)); + add(new ExcelExportEntity("工号", "loginname", 20)); + add(new ExcelExportEntity("单位", "unitname", 20)); + add(new ExcelExportEntity("工会", "unionname", 20)); + }}; + + /** + * 导出活动报名人员 + * + * @param activity_id + */ + @At + @Ok("void") + @RequiresPermissions("jsz.union.registerInfo") + public void doExportRegsiter(String activity_id, String activity_tag, HttpServletResponse response) throws IOException { + Map reqBody = new HashMap<>(); + reqBody.put("activity_id", activity_id); + + String count = """ + db.collection('register').where({activity_id: _.in(%s)}).count() + """.formatted((StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(Json.fromJsonAsArray(String.class, activity_tag)))); + NutMap wxResultCount = wxHttpUtil.getWxResult(wxHttpUtil.countUrl, count); + int count1 = wxResultCount.getInt("count"); + + List list2 = new ArrayList<>(); + + int ceil = (int) Math.ceil(count1 / LIMIT) + 1; + for (int i = 0; i < ceil; i++) { + Integer num = i == 0 ? LIMIT : count1 - LIMIT; + String query = """ + db.collection('register') + .where({ + activity_id: _.in(%s) + }) + .orderBy('unitid', 'desc') + .skip(%s) + .limit(%s) + .get() + """.formatted(StrUtil.isNotBlank(activity_id) ? Json.toJson(Lang.array(activity_id)) : Json.toJson(Json.fromJsonAsArray(String.class, activity_tag)) + , i * LIMIT, num); + + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + List data = wxResult.getList("data", Map.class); + list2.addAll(data); + List giftEList = list2.stream().map(v -> { + giftE e = new giftE(); + e.set_openid((String) v.get("_openid")); + e.setLoginname((String) v.get("loginname")); + e.setUsername((String) v.get("username")); + e.setUnitname((String) v.get("unitname")); + e.setUnionname((String) v.get("unionname")); + return e; + }).collect(Collectors.toList()); + ArrayList collect = giftEList.stream().collect( + collectingAndThen(toCollection(() -> new TreeSet<>(comparing(o -> o.get_openid()))), + ArrayList::new)); + ViTool.excelResponse(response, "活动报名人员.xls"); + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), giftE.class, collect); + workbook.write(response.getOutputStream()); + } + } + + + /** + * 导出活动参与人员 + * + * @param activity_id + */ + @At + @Ok("void") + @RequiresPermissions("jsz.union.registerInfo") + public void doExportSign(String activity_id, String activity_tag, HttpServletResponse response) { + try { + Map reqBody = new HashMap(); + reqBody.put("activity_id", activity_id); + reqBody.put("activity_tag", Json.fromJsonAsArray(String.class, activity_tag)); + + NutMap result = wxHttpUtil.getCloudResult(wxHttpUtil.cloudUrl, "getSignUserAll", reqBody); + List data = result.getAs("resp_data", List.class); + + ArrayList list = new ArrayList<>(); + for (NutMap val : data) { + NutMap v = val.getAs("data", NutMap.class); + SignE e = new SignE(); +// e.setActivity_name((String) v.get("activity_name")); + e.setLoginname((String) v.get("loginname")); + e.setUsername((String) v.get("username")); + e.setSex((String) v.get("sex")); + e.setMobile((String) v.get("mobile")); + e.setUnitname((String) v.get("unitname")); + e.setUnionname(v.getString("unionname")); + e.setSignnum(val.getInt("num")); + list.add(e); + } + ViTool.excelResponse(response, "活动参与人员.xls"); + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), SignE.class, list); + workbook.write(response.getOutputStream()); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/JszApiCon.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/JszApiCon.java new file mode 100644 index 0000000..262304c --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/JszApiCon.java @@ -0,0 +1,35 @@ +package io.v.nutz.zhgh.jsz.controller.mobile; + +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.sys.services.SysUserService; +import org.nutz.dao.Sqls; +import org.nutz.dao.entity.Record; +import org.nutz.dao.sql.Sql; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; + +import java.util.List; + +/** + * @Author: 1V + * @DateTime: 2020/9/4 10:37 + * @Description: TODO + */ +@At("/jsz/api") +@Ok("json:full") +@IocBean +public class JszApiCon { + + @Inject + private SysUserService sysUserService; + + @At + @ViReturn + public Object getUserDataByLoginName(String loginname) { + Sql sql = Sqls.create("SELECT u.id userid,u.username,u.loginname,u.sex,u.mobile,u.birthday,unit.`name` unitname,u.unitid,unit.unionid,un.unionname from sys_user u left join sys_unit unit on u.unitid = unit.id left join sys_union un on unit.unionid = un.id WHERE u.loginname = @loginname").setParam("loginname", loginname); + List list = sysUserService.list(sql); + return list.size() > 0 ? list.get(0) : new Object(); + } +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/JszFillCheckCon.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/JszFillCheckCon.java new file mode 100644 index 0000000..39559fa --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/JszFillCheckCon.java @@ -0,0 +1,57 @@ +package io.v.nutz.zhgh.jsz.controller.mobile; + +import cn.wizzer.framework.base.Result; +import io.v.nutz.base.utils.DateUtil; +import io.v.nutz.zhgh.jsz.models.Jsz_fillcheck; +import io.v.nutz.zhgh.jsz.services.JszFillCheckService; +import io.v.nutz.sys.services.SysUserService; +import org.nutz.dao.Cnd; +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.POST; + +/** + * @Author: 1V + * @DateTime: 2020/9/24 10:14 + * @Description: 补签 + */ +@At("/jsz/fillcheck") +@Ok("json:full") +@IocBean +public class JszFillCheckCon { + + @At("") + @Ok("beetl:/platform/jsz/mobile/FillCheck.html") + public void index() { + } + + @Inject + private JszFillCheckService jszFillCheckService; + + @Inject + private SysUserService sysUserService; + + @At + @POST + public Object doSubmit(Jsz_fillcheck fillcheck) { + try { + if (sysUserService.count(Cnd.where("username", "=", fillcheck.getUsername()).and("loginname", "=", fillcheck.getLoginname()).and("zzzt", "=", "在职")) == 0) { + return Result.error("姓名或工号错误"); + } + + if (jszFillCheckService.count(Cnd.where("username", "=", fillcheck.getUsername()).and("loginname", "=", fillcheck.getLoginname())) > 0) { + return Result.error("存在已提交的签到记录"); + } + + fillcheck.setCheck_time(DateUtil.getDateTime()); + jszFillCheckService.insert(fillcheck); + + return Result.success("提交成功"); + } catch (Exception e) { + return Result.error("系统错误"); + } + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/jszWxStepController.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/jszWxStepController.java new file mode 100644 index 0000000..07f1df4 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/jszWxStepController.java @@ -0,0 +1,100 @@ +package io.v.nutz.zhgh.jsz.controller.mobile; + +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.utils.DateUtil; +import io.v.nutz.zhgh.jsz.models.JszWxStep; +import io.v.nutz.zhgh.jsz.services.JszWxStepService; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +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 java.util.Date; +import java.util.List; + +/** + * TODO + * + * @Author zhf + * @Date 2022/9/6 15:18 + */ +@At("/jsz/my/step") +@Ok("json:full") +@IocBean +public class jszWxStepController { + + @Inject + private JszWxStepService jszWxStepService; + + + /** + * 获取今天当前用户最新步数 + * + * @param userId + * @return + */ + @At + @ViReturn + public Object getStepByUserId(String userId) { + return jszWxStepService.getStepByUserId(userId); + } + + /** + * 获取今天当前用户最新步数 + * + * @param userId + * @return + */ + @At + @ViReturn + public Object getStepRankingByUserId(String userId) { + + List query = jszWxStepService.query(Cnd.where("applyDate", "=", DateUtil.getDate()).desc("step")); + int k = 0; + for (int i = 0; i < query.size(); i++) { + if (query.get(i).getUserId().equals(userId)) { + k = i + 1; + } + } + + return k; + } + + /** + * 添加步数 + * + * @param userId + * @param step + * @return + */ + @At + @ViReturn + public Object addStep(String userId, Integer step) { + JszWxStep jszWxStep = new JszWxStep(); + jszWxStep.setUserId(userId); + jszWxStep.setStep(step); + jszWxStep.setApplyDate(new Date()); + jszWxStepService.insert(jszWxStep); + return null; + } + + /** + * 修改步数 + * + * @param userId + * @param step + * @return + */ + @At + @ViReturn + public Object editStep(String userId, Integer step) { + Cnd cnd = Cnd.NEW(); + cnd.and("userId", "=", userId).and("applyDate", "=", DateUtil.getDate()); + jszWxStepService.update(Chain.make("step", step), cnd); + return null; + } + + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/loginController.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/loginController.java new file mode 100644 index 0000000..716aa43 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/mobile/loginController.java @@ -0,0 +1,77 @@ +package io.v.nutz.zhgh.jsz.controller.mobile; + +import cn.hutool.core.util.StrUtil; +import cn.wizzer.framework.base.Result; +import io.v.nutz.sys.services.SysUserService; +import io.v.nutz.web.commons.base.Globals; +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; + +/** + * @author: Aaron + * @create: 2020-09-11 13:50 + * @description: 小程序登录 + **/ +@At("/platform/jsz/login") +@Ok("json:full") +@IocBean +public class loginController { + + @Inject + private SysUserService sysUserService; + + @At("/") + public Object index(String username, String loginname) { + try { + Sql sql = Sqls.create(""" + SELECT + u.id userid, + u.username, + u.loginname, + u.sex, + u.mobile, + u.birthday, + unit.`name` unitname, + u.unitid, + u.member, + unit.unionid, + un.unionname, + group_concat(sr.`code`) roles, + '$schoolCode' as schoolCode + FROM + sys_user u + LEFT JOIN sys_unit unit ON u.unitid = unit.id + LEFT JOIN sys_union un ON unit.unionid = un.id + LEFT JOIN sys_user_role sur ON sur.userId = u.id + LEFT JOIN sys_role sr ON sr.id = sur.roleId + $condition + """).setParam("loginname", loginname).setParam("username", username); + sql.setVar("schoolCode", Globals.schoolCode); + Cnd cnd = Cnd.NEW(); + cnd.and("LOWER(u.loginname)", "=", loginname.trim().toLowerCase()); + cnd.and("LOWER(u.username)", "like", "%" + username.trim().toLowerCase() + "%"); + sql.setCondition(cnd); + sql.setCallback(Sqls.callback.map()); + sysUserService.dao().execute(sql); + NutMap user = (NutMap) sql.getResult(); + if (StrUtil.isBlank(user.getString("userid"))) { + return Result.error().addMsg("系统查询不到您的信息,请与工会管理员联系!"); + } +// if(user.getInt("member",0)==0){ +// return Result.error().addMsg("您没有权限参加本次健步行,请与工会管理员联系!"); +// } + /*if (user.getInt("member", 0) != 1 && !user.getString("sex", "").equals("女")) { + return Result.error().addMsg("您没有权限参加本次健步行,请与工会管理员联系!"); + }*/ + return Result.success().addData(user); + } catch (Exception e) { + return Result.error(); + } + } +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/HdMangeCon.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/HdMangeCon.java new file mode 100644 index 0000000..21cfbec --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/HdMangeCon.java @@ -0,0 +1,610 @@ +package io.v.nutz.zhgh.jsz.controller.pc; + +import cn.wizzer.framework.base.Result; +import cn.wizzer.framework.page.Pagination; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.utils.WxHttpUtil; +import io.v.nutz.sys.models.Sys_task; +import io.v.nutz.sys.services.SysTaskService; +import io.v.nutz.sys.services.SysUserService; +import io.v.nutz.task.services.TaskPlatformService; +import io.v.nutz.web.commons.base.Globals; +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.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.log.Log; +import org.nutz.log.Logs; +import org.nutz.mvc.annotation.AdaptBy; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; +import org.nutz.mvc.upload.TempFile; +import org.nutz.mvc.upload.UploadAdaptor; +import org.nutz.plugins.wkcache.annotation.CacheDefaults; +import org.nutz.plugins.wkcache.annotation.CacheRemove; +import org.nutz.plugins.wkcache.annotation.CacheRemoveAll; + +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author: 1V + * @DateTime: 2020/9/1 9:48 + * @Description: 健身走活动管理 + */ +@At("/platform/jsz/hdMange") +@Ok("json") +@IocBean +@RequiresAuthentication +@CacheDefaults(cacheName = "jsz_activity") +public class HdMangeCon { + + private static final Log log = Logs.get(); + + @Inject + private WxHttpUtil wxHttpUtil; + + private final String JOB_CLASS = "io.v.nutz.task.job.jszLotteryJob"; //调用类 + @Inject + private TaskPlatformService taskPlatformService; + @Inject + private SysTaskService sysTaskService; + + @At("") + @Ok("beetl:/platform/jsz/pc/HdMange.html") + @RequiresPermissions("jsz.hdmange") + public void index() { + } + + @At + @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) + @RequiresPermissions("jsz.hdmange") + public Object doAdd(String data, TempFile file) { + try { + + String picid = null; + +// if (Objects.nonNull(file)) { +// NutMap picmap = wxHttpUtil.getUploadFile("activity/" + file.getSubmittedFileName()); +// picid = wxHttpUtil.uploadFile(picmap, file, "activity/" + file.getSubmittedFileName()); +// } + + NutMap map = Json.fromJson(NutMap.class, data); + StringBuilder ptsBuffer = new StringBuilder(""); + NutMap[] pts = map.getArray("pts", NutMap.class); + for (int i = 0; i < pts.length; i++) { + NutMap pt = pts[i]; + ptsBuffer.append("{") + .append("issueIds:").append(pt.getAsList("issueIds", String.class).stream().map(v -> "'" + v + "'").collect(Collectors.toList())).append(",") + .append("code:'").append(pt.getString("code")).append("',") + .append("name:'").append(pt.getString("name")).append("',") + .append("radius:").append(pt.getInt("radius")).append(",") + .append("interval:").append(pt.getInt("interval", 0)).append(",") + .append("location:new db.Geo.Point(") + .append(pt.getDouble("lng")).append(",") + .append(pt.getDouble("lat")).append(")") + .append("}"); + if (i < pts.length - 1) { + ptsBuffer.append(","); + } + } + + StringBuilder lpBuffer = new StringBuilder(""); + ArrayList[] linePoints = map.getArray("linePoints", ArrayList.class); + for (int i = 0; i < linePoints.length; i++) { + ArrayList linePoint = linePoints[i]; + lpBuffer.append("new db.Geo.Point(" + linePoint.get(0) + "," + linePoint.get(1) + ")"); + if (i < linePoints.length - 1) { + lpBuffer.append(","); + } + } + +// String pic = Strings.isNotBlank(picid) ? picid : map.getString("pic"); + String pic = "cloud://hj-2ggpsf3t8a32c4eb.686a-hj-2ggpsf3t8a32c4eb-1317134219/activity/健身走1.jpg"; + + String query = """ + db.collection('activity') + .add({ + data: + [{ + groupId:%s, + questionId:'%s', + hasAnswer:%b, + tag:'%s', + name:'%s', + activityModel:'%s', + dailyLottery:'%d', + walkingStepCount:'%d', + lotteryChance:%b, + repeatedlyLottery:%b, + leaderboardNum:'%d', + drawTime:%d, + lotteryTime:'%s', + address:'%s', + note:'%s', + apply_start_time:%d, + apply_end_time:%d, + start_time:%d, + end_time:%d, + pts:[%s], + linePoints:[%s], + toast_num:%d, + toast_msg: '%s', + check_all_msg: '%s', + checkControl:%d, + pic:'%s', + showGift:%b, + gift_name:'%s', + schoolCode:'%s', + activity_apply_user:'%s' + }] + }) + """.formatted( + map.getString("groupId"), + map.getString("questionId", ""), + map.getBoolean("hasAnswer"), + map.getString("tag", ""), + map.getString("name"), + map.getString("activityModel"), + map.getInt("dailyLottery"), + map.getInt("walkingStepCount"), + map.getBoolean("lotteryChance"), + map.getBoolean("repeatedlyLottery"), + map.getInt("leaderboardNum"), + map.getLong("drawTime"), + map.getString("lotteryTime"), + map.getString("address"), + map.getString("note").replaceAll("\r|\n", ""), + map.getLong("apply_start_time"), + map.getLong("apply_end_time"), + map.getLong("start_time"), + map.getLong("end_time"), + ptsBuffer.toString(), + lpBuffer.toString(), + map.get("toast_num") == null ? 0 : map.getInt("toast_num"), + map.getString("toast_msg", ""), + map.getString("check_all_msg", ""), + map.getInt("checkControl"), + pic, + map.getBoolean("showGift"), + map.getString("gift_name"), + Globals.schoolCode, + ShiroUtil.getUserId() + ); + + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.insertUrl, query); + log.debug(query); + + if (result.getInt("errcode") == 0 && result.getString("errmsg").equals("ok")) { +// addTask(map); + return Result.success(); + } + + return Result.error(); + } catch (Exception e) { + e.printStackTrace(); + return Result.error(); + } + } + + + @Inject + private SysUserService sysUserService; + + @At + @ViReturn + @RequiresPermissions("jsz.hdmange") + public Object pageData(@Param(value = "year",required = false) Integer year, + @Param(value = "type",required = false) String type, + @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 = true) String pageOrderName, + @Param(value = "pageOrderBy",required = false) String pageOrderBy) throws IOException { + int skip = (pageNumber == 1 ? 0 : (pageNumber - 1)) * pageSize; + + String query = """ + db.collection('activity') + .where(%s) + .skip(%d) + .limit(%d) + .orderBy('start_time','desc').get() + """; + + List and = new ArrayList<>(); + String search_sql = ""; + String ts_sql = ""; + StringBuilder s = new StringBuilder(); + + if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) { + search_sql = """ + _.or([ + { + name:{$regex:'%s',$options: 'i'} + }, + { + tag:{$regex:'%s',$options: 'i'} + } + ]) + """.formatted(searchKeyword, searchKeyword); + } + if (year != null) { + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + calendar.set(Calendar.YEAR, year); + long start_ts = calendar.getTimeInMillis(); + calendar.clear(); + calendar.set(Calendar.YEAR, year); + calendar.roll(Calendar.DAY_OF_YEAR, -1); + long end_ts = calendar.getTimeInMillis(); + String activity_apply_user_cnd = "_.neq(null)"; + if (!ShiroUtil.hasRole("sysadmin")) { + activity_apply_user_cnd = "'" + ShiroUtil.getUserId() + "'"; + } + ts_sql = "{apply_start_time:_.and(_.gte(%d),_.lte(%d)),schoolCode:'%s',activity_apply_user:%s}".formatted(start_ts, end_ts, Globals.schoolCode, activity_apply_user_cnd); + } + + if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) { + s.append(search_sql); + if (year != null) { + s.append(".and("); + s.append(ts_sql); + s.append(")"); + } + } + if (year != null && Strings.isBlank(searchKeyword)) { + s.append(ts_sql); + } + + + query = query.formatted(s, skip, pageSize); + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + + NutMap pager = result.getAs("pager", NutMap.class); + + return new Pagination(pageNumber, pageSize, pager.getInt("Total"), result.getList("data", Map.class)); + } + + + @At + @ViReturn + @RequiresPermissions("jsz.hdmange") + public Object getData(String id) throws IOException { + String query = "db.collection('activity').doc('%s').get()".formatted(id); + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + List data = wxResult.getList("data", Map.class); + return data.size() > 0 ? data.get(0) : new Object(); + } + + @At + @Ok("json") + @RequiresPermissions("jsz.hdmange") + public Object getFile(String pic) { + try { + NutMap res = NutMap.NEW(); + String imgurl = wxHttpUtil.getWxFileUrl(pic); + HashMap imgmap = new HashMap<>(); + imgmap.put("status", "success"); + imgmap.put("name", imgurl.substring(imgurl.lastIndexOf("/") + 1)); + imgmap.put("id", imgurl); + imgmap.put("url", imgurl); + res.setv("img", imgmap); + return Result.success().addData(res); + } catch (Exception e) { + return Result.error(); + } + } + + + @At + @CacheRemoveAll + @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) + @RequiresPermissions("jsz.hdmange") + public Object doEdit(String data, TempFile file) { + try { + String picid = ""; + if (file != null) { + NutMap picmap = wxHttpUtil.getUploadFile("activity/" + file.getSubmittedFileName()); + picid = wxHttpUtil.uploadFile(picmap, file, "activity/" + file.getSubmittedFileName()); + } + + NutMap map = Json.fromJson(NutMap.class, data); + + StringBuilder ptsBuffer = new StringBuilder(""); + NutMap[] pts = map.getArray("pts", NutMap.class); + for (int i = 0; i < pts.length; i++) { + NutMap pt = pts[i]; + ptsBuffer.append("{") + .append("issueIds:").append(pt.getAsList("issueIds", String.class).stream().map(v -> "'" + v + "'").collect(Collectors.toList())).append(",") + .append("code:'").append(pt.getString("code")).append("',") + .append("name:'").append(pt.getString("name")).append("',") + .append("radius:").append(pt.getInt("radius")).append(",") + .append("interval:").append(pt.getInt("interval", 0)).append(",") + .append("location:new db.Geo.Point(").append(pt.getDouble("lng")).append(",") + .append(pt.getDouble("lat")).append(")").append("}"); + if (i < pts.length - 1) { + ptsBuffer.append(","); + } + } + + StringBuilder lpBuffer = new StringBuilder(""); + ArrayList[] linePoints = map.getArray("linePoints", ArrayList.class); + for (int i = 0; i < linePoints.length; i++) { + ArrayList linePoint = linePoints[i]; + lpBuffer.append("new db.Geo.Point(").append(linePoint.get(0)).append(",") + .append(linePoint.get(1)).append(")"); + if (i < linePoints.length - 1) { + lpBuffer.append(","); + } + } + String picSql = ""; + if (Strings.isNotBlank(picid)) { + picSql = String.format("pic:'%s'", picid); + } + + String query = """ + db.collection('activity').doc('%s') + .update({ + data: + { + groupId:%s, + questionId:'%s', + hasAnswer:%b, + showGift:%b, + gift_name:'%s', + tag:'%s', + name:'%s', + activityModel:'%s', + dailyLottery:'%d', + walkingStepCount:'%d', + lotteryChance:%b, + repeatedlyLottery:%b, + leaderboardNum:'%d', + drawTime:%d, + lotteryTime:'%s', + address:'%s', + note:'%s', + apply_start_time:%d, + apply_end_time:%d, + start_time:%d, + end_time:%d, + pts:[%s], + linePoints:[%s], + toast_num:%d, + toast_msg: '%s', + check_all_msg: '%s', + checkControl:%d, + schoolCode:'%s', + activity_apply_user:'%s', + %s + } + }) + """.formatted( + map.getString("_id"), + map.getString("groupId"), + map.getString("questionId"), + map.getBoolean("hasAnswer"), + map.getBoolean("showGift"), + map.getString("gift_name"), + map.getString("tag"), + map.getString("name"), + map.getString("activityModel"), + map.getInt("dailyLottery"), + map.getInt("walkingStepCount"), + map.getBoolean("lotteryChance"), + map.getBoolean("repeatedlyLottery"), + map.getInt("leaderboardNum"), + map.getLong("drawTime"), + map.getString("lotteryTime"), + map.getString("address"), + map.getString("note").replaceAll("\r|\n", ""), + map.getLong("apply_start_time"), + map.getLong("apply_end_time"), + map.getLong("start_time"), + map.getLong("end_time"), + ptsBuffer.toString(), + lpBuffer.toString(), + map.get("toast_num") == null ? 0 : map.getInt("toast_num"), + map.getString("toast_msg"), + map.getString("check_all_msg"), + map.getInt("checkControl"), + Globals.schoolCode, + ShiroUtil.getUserId(), + picSql + ); + log.debug(query); + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.updateUrl, query); + if (result.getInt("errcode") == 0 && result.getString("errmsg").equals("ok")) { +// addTask(map); + return Result.success(); + } + return Result.error(); + } catch (Exception e) { + return Result.error(); + } + } + + + public void addTask(NutMap map) { +// Trans.exec(() -> { +// try { +// if (map.getInt("dailyLottery") > 0) { +// //先删除在添加 +// List sys_tasks = sysTaskService.query(Cnd.where("note", "=", map.getString("_id"))); +// if (sys_tasks != null) { +// sys_tasks.forEach(v -> { +// taskPlatformService.delete(v.getId(), v.getId()); +// sysTaskService.delete(v.getId()); +// }); +// +// } +// +// +// Sys_task sys_task = new Sys_task(); +// sys_task.setName(map.getString("name")); +// sys_task.setNote(map.getString("_id")); +// sys_task.setJobClass(JOB_CLASS); +// sys_task.setData(Json.toJson(new HashMap() {{ +// put("id", map.getString("_id")); +// }})); +// sys_task.setDisabled(false); +// if (!map.getBoolean("repeatedlyLottery")) { +// Date drawTime = new Date(map.getLong("drawTime")); +// String cron = io.v.nutz.base.utils.DateUtil.getCron(drawTime); +// sys_task.setCron(cron); +// List cronExeTimes = taskPlatformService.getCronExeTimes(cron); +// if (cronExeTimes.size() == 0) { +// return; +// } +// sys_task = sysTaskService.insert(sys_task); +// taskPlatformService.add(sys_task.getId(), sys_task.getId(), sys_task.getJobClass(), sys_task.getCron(), sys_task.getNote(), sys_task.getData()); +// } else { +// String lotteryTime = map.getString("lotteryTime"); +// long start_time_long = map.getLong("start_time"); +// long end_time_long = map.getLong("end_time"); +// +// List taskDates = new ArrayList<>(); +// int offsetDay = 0; +// while (DateUtil.offsetDay(new Date(start_time_long), offsetDay).compareTo(new Date(end_time_long)) < 0 || +// DateUtil.offsetDay(new Date(start_time_long), offsetDay).compareTo(new Date(end_time_long)) == 0) { +// taskDates.add(DateUtil.offsetDay(new Date(start_time_long), offsetDay)); +// offsetDay++; +// } +// +// for (Date taskDate : taskDates) { +// Calendar instance = Calendar.getInstance(); +// instance.setTime(taskDate); +// int year = instance.get(Calendar.YEAR); +// int month = instance.get(Calendar.MONTH) + 1; +// int day = instance.get(Calendar.DATE); +// String[] time = lotteryTime.split(":"); +// String cron = time[2] + " " + time[1] + " " + time[0] + " " + day + " " + month + " " + " ? " + year + " "; +// sys_task.setCron(cron); +// List cronExeTimes = taskPlatformService.getCronExeTimes(cron); +// if (cronExeTimes.size() == 0) { +// return; +// } +// sys_task = sysTaskService.insert(sys_task); +// taskPlatformService.add(sys_task.getId(), sys_task.getId(), sys_task.getJobClass(), sys_task.getCron(), sys_task.getNote(), sys_task.getData()); +// } +// +// +// } +// +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// }); + } + + + @At + @ViReturn + @CacheRemove + @RequiresPermissions("jsz.hdmange") + public Object delete(String id) throws IOException { + String query = "db.collection('activity').doc('" + id + "').remove()"; + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.deleteUrl, query); + if (wxResult.getInt("errcode") == 0 && wxResult.getString("errmsg").equals("ok")) { + + String s1 = "db.collection('register').where({\n" + + " activity_id: '" + id + "'\n" + + "}).remove()\n"; + String s2 = "db.collection('sign').where({\n" + + " activity_id: '" + id + "'\n" + + "}).remove()\n"; + + wxHttpUtil.getWxResult(wxHttpUtil.deleteUrl, s1); + wxHttpUtil.getWxResult(wxHttpUtil.deleteUrl, s2); + List sys_tasks = sysTaskService.query(Cnd.where("note", "=", id)); + if (sys_tasks != null) { + sys_tasks.forEach(v -> { + taskPlatformService.delete(v.getId(), v.getId()); + sysTaskService.delete(v.getId()); + }); + + } + return Result.success(); + } + + return Result.error(); + } + + @At + @ViReturn + public Object getFitnessData() throws IOException { + String query = "db.collection('activity').where({schoolCode:'%s'}).orderBy('apply_start_time', 'desc').get()".formatted(Globals.schoolCode); + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + List data = result.getList("data", NutMap.class); + return data.size() > 0 ? data : new ArrayList<>(); + //return Collections.emptyList(); + } + + @At + @ViReturn + public Object getActivityData() throws IOException { + + Long yearStartTime = getYearStartTime(); + Long yearEndTime = getYearEndTime(); + + String query = "db.collection('activity')\n" + + " .where({\n" + + " apply_start_time: _.and(_.gte(" + yearStartTime + "), _.lte(" + yearEndTime + "))\n" + + " }).get()"; + + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + List data = wxResult.getList("data", Map.class); + return data; + + } + + /** + * 获取当年的开始时间戳 + * + * @return + */ + public static Long getYearStartTime() { + Calendar calendar = Calendar.getInstance();// 获取当前日期 + calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); + calendar.setTimeInMillis(System.currentTimeMillis()); + calendar.add(Calendar.YEAR, 0); + calendar.add(Calendar.DATE, 0); + calendar.add(Calendar.MONTH, 0); + calendar.set(Calendar.DAY_OF_YEAR, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTimeInMillis(); + } + + /** + * 获取当年的最后时间戳 + * + * @return + */ + public static Long getYearEndTime() { + Calendar calendar = Calendar.getInstance();// 获取当前日期 + calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); + calendar.setTimeInMillis(System.currentTimeMillis()); + int year = calendar.get(Calendar.YEAR); + calendar.clear(); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.HOUR_OF_DAY, 23); + calendar.set(Calendar.MINUTE, 59); + calendar.set(Calendar.SECOND, 59); + calendar.set(Calendar.MILLISECOND, 999); + calendar.roll(Calendar.DAY_OF_YEAR, -1); + return calendar.getTimeInMillis(); + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszCommonCon.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszCommonCon.java new file mode 100644 index 0000000..9779b48 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszCommonCon.java @@ -0,0 +1,101 @@ +package io.v.nutz.zhgh.jsz.controller.pc; + +import cn.wizzer.framework.base.Result; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.utils.WxHttpUtil; +import io.v.nutz.web.commons.utils.ShiroUtil; +import io.v.nutz.zhgh.jsz.services.JszTypeService; +import io.v.nutz.web.commons.base.Globals; +import org.apache.shiro.authz.annotation.RequiresAuthentication; +import org.nutz.dao.Cnd; +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 java.io.IOException; +import java.util.Calendar; +import java.util.List; +import java.util.Map; + +/** + * @Author: 1V + * @DateTime: 2020/9/1 10:02 + * @Description: TODO + */ +@At("/platform/jsz/common") +@Ok("json") +@IocBean +@RequiresAuthentication +public class JszCommonCon { + @Inject + private JszTypeService jszTypeService; + + @Inject + private WxHttpUtil wxHttpUtil; + + /** + * 获取类型 + * + * @return + */ + @At + @ViReturn + public Object getTypes() { + return jszTypeService.query(Cnd.NEW().asc("location")); + } + + /** + * 获取所有的活动 + * + * @return + */ + @At + public Object getAllHd(Integer year, String beforeTime, String endTime) { + try { + String str = ""; + + if (Strings.isNotBlank(beforeTime) && Strings.isNotBlank(endTime)) { + str = "start_time:_.gt(" + beforeTime + "),start_time:_.lt(" + endTime + "),schoolCode:'" + Globals.schoolCode + "'"; + } else { + str = "schoolCode:'" + Globals.schoolCode + "'"; + } + + if (year != null) { + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + calendar.set(Calendar.YEAR, year); + long start_ts = calendar.getTimeInMillis(); + calendar.clear(); + calendar.set(Calendar.YEAR, year); + calendar.roll(Calendar.DAY_OF_YEAR, -1); + long end_ts = calendar.getTimeInMillis(); + String activity_apply_user_cnd = "_.neq(null)"; + if (!ShiroUtil.hasRole("sysadmin")) { + activity_apply_user_cnd = "'" + ShiroUtil.getUserId() + "'"; + } + str = "apply_start_time:_.and(_.gte(%d),_.lte(%d)),schoolCode:'%s',activity_apply_user:%s".formatted(start_ts, end_ts, Globals.schoolCode, activity_apply_user_cnd); + } + + String query = "db.collection('activity').where({\n" + + str + + "}).field({\n" + + "tag: true,\n" + + "name: true,\n" + + "start_time: true,\n" + + "end_time: true,\n" + + "activityModel: true,\n" + + "schoolCode: '" + Globals.schoolCode + "'\n" + + "}).orderBy('start_time', 'desc').get()"; + + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + List data = wxResult.getList("data", Map.class); + return Result.success().addData(data); + } catch (IOException e) { + e.printStackTrace(); + return Result.error(); + } + } +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszLoginRecordCon.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszLoginRecordCon.java new file mode 100644 index 0000000..d3a1024 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszLoginRecordCon.java @@ -0,0 +1,121 @@ +package io.v.nutz.zhgh.jsz.controller.pc; + +import cn.hutool.core.util.StrUtil; +import cn.wizzer.framework.base.Result; +import cn.wizzer.framework.page.Pagination; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.utils.WxHttpUtil; +import io.v.nutz.web.commons.base.Globals; +import org.apache.shiro.authz.annotation.RequiresAuthentication; +import org.apache.shiro.authz.annotation.RequiresPermissions; +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 java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * @Author: 1V + * @DateTime: 2020/9/24 15:32 + * @Description: TODO + */ +@At("/platform/jsz/login/record") +@Ok("json") +@IocBean +@RequiresAuthentication +public class JszLoginRecordCon { + + @Inject + private WxHttpUtil wxHttpUtil; + + @At("") + @Ok("beetl:/platform/jsz/pc/LoginRecord.html") + @RequiresPermissions("jsz.login.record") + public void index() { + } + + @At + @ViReturn + @RequiresPermissions("jsz.login.record") + public Object pageData(@Param(value = "keyWord",required = false) String keyWord, + @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) throws IOException { + String cnd = ""; + + if (Strings.isNotBlank(keyWord)) { + cnd = " _.or([{\n" + + " loginname: db.RegExp({\n" + + " regexp: '" + keyWord + "',\n" + + " options: 'i',\n" + + " })},{\n" + + " username: db.RegExp({\n" + + " regexp: '" + keyWord + "',\n" + + " options: 'i',\n" + + " })\n" + + " }])"; + } else { +// cnd = "{schoolCode:'" + Globals.schoolCode + "'}"; + } + + + int skip = (pageNumber == 1 ? 0 : (pageNumber - 1)) * pageSize; + + String query = "db.collection('login_record')" + ( StrUtil.isNotBlank(cnd) ? (".where(" + cnd + ")") : "" ) + + ".field({ data: false }).skip(" + skip + ").limit(" + pageSize + ").get()"; + + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + + NutMap pager = result.getAs("pager", NutMap.class); + + List list = result.getList("data", Map.class); + list.forEach(v -> { + String openid = (String) v.get("openid"); + v.put("openid", openid.substring(0, 3) + "******" + openid.substring(openid.length() - 3)); + }); + + return new Pagination(pageNumber, pageSize, pager.getInt("Total"), list); + } + + + @At + @RequiresPermissions("jsz.login.record") + public Object delete(String[] ids) throws IOException { + try { + String s = "db.collection('login_record').where({_id:_.in(" + Json.toJson(ids) + ")}).remove()\n"; + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.deleteUrl, s); + if (wxResult.getInt("errcode") == 0 && wxResult.getString("errmsg").equals("ok")) { + return Result.success(); + } + return Result.error(); + } catch (Exception e) { + return Result.error(); + } + } + + @At + @RequiresPermissions("jsz.login.record") + public Object deleteAll() throws IOException { + try { + String s = "db.collection('login_record').where({schoolCode: _.eq('" + Globals.schoolCode + "')}).remove()\n"; + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.deleteUrl, s); + if (wxResult.getInt("errcode") == 0 && wxResult.getString("errmsg").equals("ok")) { + return Result.success(); + } + return Result.error(); + } catch (Exception e) { + return Result.error(); + } + } + + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszPrizeController.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszPrizeController.java new file mode 100644 index 0000000..bd6733b --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszPrizeController.java @@ -0,0 +1,124 @@ +package io.v.nutz.zhgh.jsz.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 cn.hutool.core.date.DateUtil; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.utils.ViTool; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.shiro.authz.annotation.RequiresAuthentication; +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.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.HttpServletResponse; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @FileName io.v.nutz.zhgh.jsz.controller.pc.JszPrizeController + * @Description: TODO + * @Author zxc + * @Date 2022/9/8:15:06 + * @Version V1.0 + **/ +@IocBean +@At("/platform/jsz/prize") +public class JszPrizeController { + + @At("") + @Ok("beetl:/platform/jsz/pc/prize.html") + @RequiresAuthentication + public void index() { + + } + + @Inject + private Dao dao; + + private String getSql() { + return """ + SELECT + u.loginname, + u.username, + u.unionname, + u.unitname, + al.applyDate, + date_format(al.applyDate,'%Y-%m-%d') as prizeData + FROM + `jsz_award_list` al + LEFT JOIN `user` u ON u.id = al.userId + $condition + """; + } + + @At("/prizeDataList") + @Ok("json:full") + @ViReturn + public Object prizeDataList(@Param("activityId") String activityId) { + Date toDay = new Date(); + + Sql sql = Sqls.create(getSql()); + Cnd cnd = Cnd.NEW(); + cnd.and("activityId", "=", activityId); + sql.setCondition(cnd); + List list = (List) Daos.query(dao, sql.toString(), Sqls.callback.maps()); + + List yesterdayList = list.stream().filter(v -> v.getString("applyDate").substring(0, 10).equals(DateUtil.format(DateUtil.offsetDay(toDay, -1), "yyyy-MM-dd"))).collect(Collectors.toList()); +// List toDayList = list.stream().filter(v -> v.getString("applyDate").substring(0, 10).equals(DateUtil.format(toDay, "yyyy-MM-dd"))).collect(Collectors.toList()); + + return Map.of("toDayList", Collections.emptyList(), "yesterdayList", yesterdayList, "totalList", list); + } + + @At("/exportExcel") + @Ok("void") + @RequiresAuthentication + public void exportExcel(@Param("activityId") String activityId, + @Param("currentSelectedType") String currentSelectedType, + HttpServletResponse response) { + Date toDay = new Date(); + + Sql sql = Sqls.create(getSql()); + Cnd cnd = Cnd.NEW(); + cnd.and("activityId", "=", activityId); + sql.setCondition(cnd); + + List exportList = new ArrayList<>(); + + List list = (List) Daos.query(dao, sql.toString(), Sqls.callback.maps()); + if ("yesterdayList".equals(currentSelectedType)) { + exportList = list.stream().filter(v -> v.getString("applyDate").substring(0, 10).equals(DateUtil.format(DateUtil.offsetDay(toDay, -1), "yyyy-MM-dd"))).collect(Collectors.toList()); + } else { + exportList = list; + } + + List entityList = new ArrayList<>() {{ + add(new ExcelExportEntity("姓名", "username", 20)); + add(new ExcelExportEntity("工号", "loginname", 20)); + add(new ExcelExportEntity("单位", "unitname", 20)); + add(new ExcelExportEntity("分工会", "unionname", 20)); + add(new ExcelExportEntity("日期", "prizeData", 20)); + }}; + + try { + ViTool.excelResponse(response, "导出数据.xlsx"); + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, exportList); + workbook.write(response.getOutputStream()); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszStepCountingRankCon.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszStepCountingRankCon.java new file mode 100644 index 0000000..e4cb72a --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/JszStepCountingRankCon.java @@ -0,0 +1,140 @@ +package io.v.nutz.zhgh.jsz.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.base.annontation.ViReturn; +import io.v.nutz.base.page.Pagination; +import io.v.nutz.base.query.PageForm; +import io.v.nutz.base.service.BaseService; +import io.v.nutz.base.utils.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.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 org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; + +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; + +/** + * TODO + * + * @Author zhf + * @Date 2022/9/9 14:07 + */ +@IocBean +@At("/platform/jsz/StepCountingRank") +public class JszStepCountingRankCon { + + + @At("") + @Ok("beetl:/platform/jsz/pc/stepCountingRank.html") + @RequiresPermissions("jsz.StepCountingRank") + public void index() { + } + + @Inject + private BaseService baseService; + + private String getSql() { + return """ + SELECT + u.loginname, + u.username, + u.unionname, + u.unitname, + al.applyDate, + al.step, + date_format(al.applyDate,'%Y-%m-%d') as prizeData + FROM + `jsz_wx_step` al + LEFT JOIN `user` u ON u.id = al.userId + $condition + """; + } + + @At + @Ok("json:full") + @ViReturn + @RequiresPermissions("jsz.StepCountingRank") + public Object pageData(PageForm pageForm, + @Param(value = "year",required = false) Integer year, + @Param(value = "hdid",required = false) String hdid, + @Param(value = "activityDate",required = false) String[] activityDate, + @Param(value = "unionId",required = false) String unionId, + @Param(value = "unitId",required = false) String unitId) { + Cnd cnd = Cnd.NEW(); + Sql sql = Sqls.create(getSql()); + if (Lang.isNotEmpty(activityDate)) { + cnd.and("date_format(al.applyDate,'%Y-%m-%d')", ">=", activityDate[0]); + cnd.and("date_format(al.applyDate,'%Y-%m-%d')", ">=", activityDate[1]); + } + cnd.andEX("YEAR(al.applyDate)", "=", year); + cnd.andEX("al.activityId", "=", hdid); + cnd.andEX("u.unionid", "=", unionId); + cnd.andEX("u.unitId", "=", unitId); + cnd.desc("al.step"); + cnd.desc("u.unioncode"); + + sql.setCondition(cnd); + Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + return pagination; + } + + + @At("/exportExcel") + @Ok("void") + @RequiresAuthentication + @RequiresPermissions("jsz.StepCountingRank") + public void exportExcel(@Param(value = "hdid",required = false) String hdid, + @Param(value = "activityDate",required = false) String[] activityDate, + @Param(value = "unionId",required = false) String unionId, + @Param(value = "unitId",required = false) String unitId, HttpServletResponse response) { + Cnd cnd = Cnd.NEW(); + Sql sql = Sqls.create(getSql()); + if (activityDate.length > 0) { + cnd.and("date_format(al.applyDate,'%Y-%m-%d')", ">=", activityDate[0]); + cnd.and("date_format(al.applyDate,'%Y-%m-%d')", ">=", activityDate[1]); + } + cnd.andEX("al.activityId", "=", hdid); + cnd.andEX("u.unionid", "=", unionId); + cnd.andEX("u.unitId", "=", unitId); + cnd.desc("al.step"); + cnd.desc("u.unioncode"); + + List exportList = baseService.listMap(sql); + + List entityList = new ArrayList<>() {{ + add(new ExcelExportEntity("姓名", "username", 20)); + add(new ExcelExportEntity("工号", "loginname", 20)); + add(new ExcelExportEntity("单位", "unitname", 20)); + add(new ExcelExportEntity("分工会", "unionname", 20)); + add(new ExcelExportEntity("当前步数", "step", 20)); + add(new ExcelExportEntity("日期", "prizeData", 20)); + }}; + + try { + ViTool.excelResponse(response, "导出数据.xlsx"); + ExportParams exportParams = new ExportParams(); + exportParams.setType(ExcelType.XSSF); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, exportList); + workbook.write(response.getOutputStream()); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/TkMangeController.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/TkMangeController.java new file mode 100644 index 0000000..27845f8 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/TkMangeController.java @@ -0,0 +1,178 @@ +package io.v.nutz.zhgh.jsz.controller.pc; + +import cn.wizzer.framework.base.Result; +import cn.wizzer.framework.page.Pagination; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.utils.WxHttpUtil; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authz.annotation.RequiresAuthentication; +import org.apache.shiro.authz.annotation.RequiresPermissions; +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 org.nutz.plugins.wkcache.annotation.CacheDefaults; +import org.nutz.plugins.wkcache.annotation.CacheRemove; +import org.nutz.plugins.wkcache.annotation.CacheRemoveAll; +import org.nutz.plugins.wkcache.annotation.CacheResult; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author: Aaron + * @create: 2020-09-03 14:12 + * @description: 健身走题库管理 + **/ +@At("/platform/jsz/tkMange") +@Ok("json") +@IocBean +@RequiresAuthentication +@CacheDefaults(cacheName = "jsz_topic") +public class TkMangeController { + + + + @Inject + private WxHttpUtil wxHttpUtil; + + @At("") + @Ok("beetl:/platform/jsz/pc/TkMange.html") + @RequiresPermissions("jsz.tkmange") + public void index() { + } + + @At + @ViReturn + @RequiresPermissions("jsz.tkmange") + public Object pageData(@Param(value = "searchName",required = false) String searchName, + @Param(value = "searchKeyword",required = false) String searchKeyword, + @Param("pageNumber") int pageNumber,@Param("pageSize") int pageSize) { + try { + List and = new ArrayList<>(); + + if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) { + and.add("" + searchName + ":{$regex:'" + searchKeyword + "',$options: 'i'}"); + } + + int skip = pageNumber == 1 ? 0 : (pageNumber - 1) * pageSize; + + String query = "db.collection('topic')\n" + + " .where({" + StringUtils.join(and, ",") + "})\n" + + " .skip(0)\n" + + " .limit(10)\n" + + " .get()"; + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + + NutMap pager = result.getAs("pager", NutMap.class); + + return new Pagination(pageNumber, pageSize, pager.getInt("Total"), result.getList("data", Map.class)); + } catch (Exception e) { + return Result.error(); + } + } + + @At + @RequiresPermissions("jsz.tkmange") + public Object doAdd(String issue) { + try { + NutMap map = Json.fromJson(NutMap.class, issue); + StringBuffer optionsBuffer = new StringBuffer(""); + NutMap[] options = map.getArray("options", NutMap.class); + for (int i = 0; i < options.length; i++) { + NutMap op = options[i]; + optionsBuffer.append("{" + + "option_name:'" + op.getString("option_name") + "'," + + "option_iswor:" + op.getBoolean("option_iswor") + "" + + "}"); + if (i < options.length - 1) { + optionsBuffer.append(","); + } + } + String query = "db.collection('topic')\n" + + " .add({\n" + + " data: [\n" + + " {\n" + + " issue_multiple: " + map.getBoolean("issue_multiple") + ",\n" + + " issue_name: '" + map.getString("issue_name") + "',\n" + + " options: [" + optionsBuffer.toString() + "]\n" + + " }\n" + + " ]\n" + + " })"; + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.insertUrl, query); + if (result.getInt("errcode") == 0 && result.getString("errmsg").equals("ok")) { + return Result.success(); + } + return Result.error(); + } catch (Exception e) { + return Result.error(); + } + } + + @At + @ViReturn + @CacheResult + @RequiresPermissions("jsz.tkmange") + public Object findOne(String id) throws IOException { + String query = "db.collection('topic').doc('" + id + "').get()"; + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.queryUrl, query); + List data = wxResult.getList("data", Map.class); + return data.size() > 0 ? data.get(0) : new Object(); + } + + @At + @CacheRemoveAll + @RequiresPermissions("jsz.tkmange") + public Object doEdit(String issue) { + try { + NutMap map = Json.fromJson(NutMap.class, issue); + StringBuffer optionsBuffer = new StringBuffer(""); + NutMap[] options = map.getArray("options", NutMap.class); + for (int i = 0; i < options.length; i++) { + NutMap op = options[i]; + optionsBuffer.append("{" + + "option_name:'" + op.getString("option_name") + "'," + + "option_iswor:" + op.getBoolean("option_iswor") + "" + + "}"); + if (i < options.length - 1) { + optionsBuffer.append(","); + } + } + String query = "db.collection('topic').doc('" + map.getString("_id") + "')\n" + + " .update({\n" + + " data: {\n" + + " issue_multiple: " + map.getBoolean("issue_multiple") + ",\n" + + " issue_name: '" + map.getString("issue_name") + "',\n" + + " options: [" + optionsBuffer.toString() + "]\n" + + " }\n" + + " })"; + NutMap result = wxHttpUtil.getWxResult(wxHttpUtil.updateUrl, query); + if (result.getInt("errcode") == 0 && result.getString("errmsg").equals("ok")) { + return Result.success(); + } + return Result.error(); + } catch (Exception e) { + return Result.error(); + } + } + + @At + @ViReturn + @CacheRemove + @RequiresPermissions("jsz.tkmange") + public Object delete(String id) throws IOException { + String query = "db.collection('topic').doc('" + id + "').remove()"; + NutMap wxResult = wxHttpUtil.getWxResult(wxHttpUtil.deleteUrl, query); + if (wxResult.getInt("errcode") == 0 && wxResult.getString("errmsg").equals("ok")) { + return Result.success(); + } + return Result.error(); + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/stepCountingController.java b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/stepCountingController.java new file mode 100644 index 0000000..8c5f48f --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/controller/pc/stepCountingController.java @@ -0,0 +1,170 @@ +package io.v.nutz.zhgh.jsz.controller.pc; + +import cn.hutool.captcha.generator.RandomGenerator; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import cn.wizzer.framework.base.Result; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.zhgh.jsz.models.JszWxStep; +import io.v.nutz.sys.models.Sys_user; +import io.v.nutz.sys.services.SysUserService; +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.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.Lang; +import org.nutz.lang.util.NutMap; +import org.nutz.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.Param; + +import java.io.IOException; +import java.util.*; + +/** + * @FileName io.v.nutz.zhgh.jsz.controller.pc.stepCountingController + * @Description: TODO + * @Author zxc + * @Date 2022/9/6:14:39 + * @Version V1.0 + **/ +@IocBean +@At("/platform/jsz/stepCounting") +public class stepCountingController { + +// @Inject +// private SendMsg sendMsg; + + @Inject + private Dao dao; + + @Inject + private SysUserService sysUserService; + + @At("/sendSmsCode") + @Ok("json:full") + public Object sendSmsCode(@Param("loginName") String loginName) { + int count = dao.count(Sys_user.class, Cnd.where("loginName", "=", loginName)); + if (count == 0) { + return Result.error("系统中查询不到您的工号!"); + } + RandomGenerator randomGenerator = new RandomGenerator("0123456789", 4); + String code = randomGenerator.generate(); +// try { +// sendMsg.sendTextMesg(loginName, "健步走验证码:" + code); +// return Result.success().addData(code); +// } catch (IOException e) { +// e.printStackTrace(); +// return Result.error(); +// } + return null; + } + + @At("/getUserInfo") + @Ok("json:full") + public Object getUserInfo(@Param("loginName") String loginName) { + Sql sql = Sqls.create(""" + SELECT + u.id userid, + u.username, + u.loginname, + u.sex, + u.mobile, + u.birthday, + unit.`name` unitname, + u.unitid, + u.member, + unit.unionid, + un.unionname, + group_concat(sr.`code`) roles + FROM + sys_user u + LEFT JOIN sys_unit unit ON u.unitid = unit.id + LEFT JOIN sys_union un ON unit.unionid = un.id + LEFT JOIN sys_user_role sur ON sur.userId = u.id + LEFT JOIN sys_role sr ON sr.id = sur.roleId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("LOWER(u.loginname)", "=", loginName.toLowerCase()); + sql.setCondition(cnd); + NutMap userMap = (NutMap) Daos.query(dao, sql.toString(), Sqls.callback.map()); + if (StrUtil.isBlank(userMap.getString("userid"))) { + return Result.error().addMsg("系统查询不到您的信息,请与工会管理员联系!"); + } + return Result.success().addData(userMap); + } + + /** + * get week step + * + * @param userId user id + * @return {@link Object} + */ + @At("/getWeekStep") + @Ok("json:full") + @ViReturn + public Object getWeekStep(@Param("userId") String userId, @Param("activityId") String activityId) { + Assert.notBlank(activityId); + Assert.notBlank(userId); + Cnd cnd = Cnd.where("userId", "=", userId); + cnd.and("activityId", "=", activityId); + cnd.and("applyDate", ">", DateUtil.offsetDay(new Date(), -7)); + cnd.asc("applyDate"); + List wxSteps = dao.query(JszWxStep.class, cnd); + + List results = new ArrayList<>(); + for (int i = 7; i >= 0; i--) { + int offset = (i) * -1; + DateTime offsetDay = DateUtil.offsetDay(new Date(), offset); + String dateStr = offsetDay.toString("yyyy-MM-dd"); + + Optional jszWxStepOptional = wxSteps.stream().filter(v -> DateUtil.format(v.getApplyDate(), "yyyy-MM-dd").equals(dateStr)).findFirst(); + + results.add(new HashMap<>() {{ + put("day", dateStr); + put("step", jszWxStepOptional.isPresent() ? jszWxStepOptional.get().getStep() : 0); + }}); + + } + return results; + } + + /** + * 更新步数 + * + * @param activityId 活动id + * @param userId 用户id + * @param step 一步 + * @return {@link Object} + */ + @At + @Ok("json:full") + @ViReturn + public Object updateStep(String activityId, String userId, Integer step) { + Assert.notBlank(activityId); + Assert.notBlank(userId); + + Cnd cnd = Cnd.NEW(); + cnd.and("userId", "=", userId); + cnd.and("applyDate", "=", io.v.nutz.base.utils.DateUtil.getDate()); + cnd.and("activityId", "=", activityId); + + JszWxStep wxStep = dao.fetch(JszWxStep.class, cnd); + if (Lang.isEmpty(wxStep)) { + wxStep = new JszWxStep(); + wxStep.setActivityId(activityId); + wxStep.setUserId(userId); + wxStep.setApplyDate(new Date()); + } + wxStep.setStep(step); + dao.insertOrUpdate(wxStep); + return null; + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/models/JszAwardList.java b/src/main/java/io/v/nutz/zhgh/jsz/models/JszAwardList.java new file mode 100644 index 0000000..fe5143f --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/models/JszAwardList.java @@ -0,0 +1,44 @@ +package io.v.nutz.zhgh.jsz.models; + +import lombok.Data; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +import java.util.Date; + +/** + * TODO + * 健身走获奖名单 + * + * @Author zhf + * @Date 2022/9/8 9:24 + */ +@Table +@Data +public class JszAwardList { + + + @Column + @Name + @ColDefine(type = ColType.VARCHAR, width = 32) + @PrevInsert(uu32 = true) + private String id; + + @Column + @ColDefine(type = ColType.VARCHAR) + @Comment("活动") + private String activityId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("姓名Id") + private String userId; + + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("时间") + private Date applyDate; + + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/models/JszWxStep.java b/src/main/java/io/v/nutz/zhgh/jsz/models/JszWxStep.java new file mode 100644 index 0000000..1c00436 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/models/JszWxStep.java @@ -0,0 +1,45 @@ +package io.v.nutz.zhgh.jsz.models; + +import lombok.Data; +import org.nutz.dao.entity.annotation.*; +import org.nutz.dao.interceptor.annotation.PrevInsert; + +import java.util.Date; + +/** + * TODO + * + * @Author zhf + * @Date 2022/9/6 15:06 + */ +@Table +@Data +public class JszWxStep { + + @Column + @Name + @ColDefine(type = ColType.VARCHAR, width = 32) + @PrevInsert(uu32 = true) + private String id; + + @Column + @ColDefine(type = ColType.VARCHAR) + @Comment("时间") + private String activityId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("姓名Id") + private String userId; + + @Column + @ColDefine(customType = "int") + @Comment("步数") + private Integer step; + + @Column + @ColDefine(type = ColType.DATE) + @Comment("时间") + private Date applyDate; + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/models/Jsz_fillcheck.java b/src/main/java/io/v/nutz/zhgh/jsz/models/Jsz_fillcheck.java new file mode 100644 index 0000000..51a613f --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/models/Jsz_fillcheck.java @@ -0,0 +1,78 @@ +package io.v.nutz.zhgh.jsz.models; + +import org.nutz.dao.entity.annotation.*; + +/** + * @Author: 1V + * @DateTime: 2020/9/24 10:04 + * @Description: TODO + */ +@Table("Jsz_fillcheck") +public class Jsz_fillcheck { + @Column + @Name + @Comment("ID") + @ColDefine(type = ColType.VARCHAR, width = 32) + @Prev(els = {@EL("uuid()")}) + private String id; + + @Column + @Comment("用户名") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String loginname; + + @Column + @Comment("姓名") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String username; + + @Column + @Comment("校区") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String campus; + + @Column + @Comment("签到时间") + @ColDefine(type = ColType.VARCHAR, width = 30) + private String check_time; + + public String getCheck_time() { + return check_time; + } + + public void setCheck_time(String check_time) { + this.check_time = check_time; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLoginname() { + return loginname; + } + + public void setLoginname(String loginname) { + this.loginname = loginname; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getCampus() { + return campus; + } + + public void setCampus(String campus) { + this.campus = campus; + } +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/models/Jsz_type.java b/src/main/java/io/v/nutz/zhgh/jsz/models/Jsz_type.java new file mode 100644 index 0000000..e4e99b4 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/models/Jsz_type.java @@ -0,0 +1,57 @@ +package io.v.nutz.zhgh.jsz.models; + +import org.nutz.dao.DB; +import org.nutz.dao.entity.annotation.*; + +/** + * @Author: 1V + * @DateTime: 2020/9/1 9:42 + * @Description: 活动类型 + */ +@Table("Jsz_type") +public class Jsz_type { + + @Column + @Name + @Comment("ID") + @ColDefine(type = ColType.VARCHAR, width = 32) + @Prev(els = {@EL("uuid()")}) + private String id; + + @Column + @Comment("类型名称") + @ColDefine(type = ColType.VARCHAR, width = 255) + private String name; + + @Column + @Comment("排序") + @Prev({ + @SQL(db = DB.MYSQL, value = "SELECT IFNULL(MAX(location),0)+1 FROM Jsz_type"), + @SQL(db = DB.ORACLE, value = "SELECT COALESCE(MAX(location),0)+1 FROM Jsz_type") + }) + private Integer location; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getLocation() { + return location; + } + + public void setLocation(Integer location) { + this.location = location; + } +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/services/JszFillCheckService.java b/src/main/java/io/v/nutz/zhgh/jsz/services/JszFillCheckService.java new file mode 100644 index 0000000..8feb376 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/services/JszFillCheckService.java @@ -0,0 +1,11 @@ +package io.v.nutz.zhgh.jsz.services; + +import cn.wizzer.framework.base.service.BaseService; +import io.v.nutz.zhgh.jsz.models.Jsz_fillcheck; + + +/** + * @author 1V + */ +public interface JszFillCheckService extends BaseService { +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/services/JszTypeService.java b/src/main/java/io/v/nutz/zhgh/jsz/services/JszTypeService.java new file mode 100644 index 0000000..81faf5d --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/services/JszTypeService.java @@ -0,0 +1,8 @@ +package io.v.nutz.zhgh.jsz.services; + + +import io.v.nutz.base.service.BaseService; +import io.v.nutz.zhgh.jsz.models.Jsz_type; + +public interface JszTypeService extends BaseService { +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/services/JszWxStepService.java b/src/main/java/io/v/nutz/zhgh/jsz/services/JszWxStepService.java new file mode 100644 index 0000000..99d30db --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/services/JszWxStepService.java @@ -0,0 +1,36 @@ +package io.v.nutz.zhgh.jsz.services; + +import io.v.nutz.base.service.ViService; +import io.v.nutz.zhgh.jsz.models.JszWxStep; + +public interface JszWxStepService extends ViService { + + + /** + * 获取今天当前用户最新步数 + */ + Object getStepByUserId(String userId); + + /** + * 获取当日榜或者累计排榜榜 + * + * @param hdid: 活动id + * @param type: 0-当日榜, 1-累计排行榜 + * @return null + * @author JyuHsin + * @date 2022/9/7 + */ + Object getDataOfLeaderboard(String hdid, Integer type, String userId, String unionId, String unitId, String searchName, String searchKeyword); + + /** + * 获取当日中奖榜 + * + * @param hdid: 活动id + * @return java.lang.Object + * @author JyuHsin + * @date 2022/9/7 + */ + Object getDataOfPrize(String hdid, String unionId, String unitId, String searchName, String searchKeyword); + + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszFillCheckServiceImpl.java b/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszFillCheckServiceImpl.java new file mode 100644 index 0000000..f0bfa1b --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszFillCheckServiceImpl.java @@ -0,0 +1,20 @@ +package io.v.nutz.zhgh.jsz.services.impl; + +import cn.wizzer.framework.base.service.BaseServiceImpl; +import io.v.nutz.zhgh.jsz.models.Jsz_fillcheck; +import io.v.nutz.zhgh.jsz.services.JszFillCheckService; +import org.nutz.dao.Dao; +import org.nutz.ioc.loader.annotation.IocBean; + + +/** + * @author 1V + */ +@IocBean(args = {"refer:dao"}) +public class JszFillCheckServiceImpl extends BaseServiceImpl implements JszFillCheckService { + + public JszFillCheckServiceImpl(Dao dao) { + super(dao); + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszTypeServiceImpl.java b/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszTypeServiceImpl.java new file mode 100644 index 0000000..2ce6c3c --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszTypeServiceImpl.java @@ -0,0 +1,19 @@ +package io.v.nutz.zhgh.jsz.services.impl; + +import io.v.nutz.base.service.impl.BaseServiceImpl; +import io.v.nutz.zhgh.jsz.models.Jsz_type; +import io.v.nutz.zhgh.jsz.services.JszTypeService; +import org.nutz.dao.Dao; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.plugins.wkcache.annotation.CacheDefaults; + + +@IocBean(args = {"refer:dao"}) +@CacheDefaults(cacheName = "jsz_type") +public class JszTypeServiceImpl extends BaseServiceImpl implements JszTypeService { + + public JszTypeServiceImpl(Dao dao) { + super(dao); + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszWxStepServiceImpl.java b/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszWxStepServiceImpl.java new file mode 100644 index 0000000..133b195 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/jsz/services/impl/JszWxStepServiceImpl.java @@ -0,0 +1,119 @@ +package io.v.nutz.zhgh.jsz.services.impl; + +import cn.hutool.core.date.DateUtil; +import io.v.nutz.base.dao.CndPlus; +import io.v.nutz.base.service.impl.ViServiceImpl; +import io.v.nutz.zhgh.jsz.models.JszWxStep; +import io.v.nutz.zhgh.jsz.services.JszWxStepService; +import io.v.nutz.sys.models.Sys_user; +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.IocBean; +import org.nutz.lang.Lang; +import org.nutz.lang.Strings; +import org.nutz.lang.util.NutMap; + +import java.util.Date; +import java.util.List; + +/** + * TODO + * + * @Author zhf + * @Date 2022/9/6 15:12 + */ +@IocBean(args = {"refer:dao"}) +public class JszWxStepServiceImpl extends ViServiceImpl implements JszWxStepService { + public JszWxStepServiceImpl(Dao dao) { + super(dao); + } + + @Override + public Object getStepByUserId(String userId) { + Cnd cnd = Cnd.NEW(); + cnd.and("userId", "=", userId).and("applyDate", "=", DateUtil.today()); + return fetch(cnd); + } + + @Override + public Object getDataOfLeaderboard(String hdid, Integer type, String userId, String unionId, String unitId, String searchName, String searchKeyword) { + Sys_user user = dao().fetch(Sys_user.class, userId); + CndPlus cnd = CndPlus.create(); + Sql sql = Sqls.create(""" + SELECT + userId, + sum(step) as step, + u.username, + u.loginname + FROM + `jsz_wx_step` step + LEFT JOIN sys_user u ON step.userId = u.id + $condition + """); + //0查当日 + if (type == 0) { + cnd.and("left(applyDate, 10)", "=", DateUtil.today()); + } + cnd.and("activityId", "=", hdid); + cnd.andEX("u.unitId", "=", unitId); + cnd.andEX("u.unionId", "=", unionId); + + if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) { + cnd.and(searchName, "LIKE", "%" + searchKeyword + "%"); + } + + cnd.groupBy("userId"); + cnd.desc("step"); + + sql.setCondition(cnd); + List lists = listMap(sql); + + Sql sqlMy = sql.duplicate().setCondition(cnd.clone().and("userId", "=", userId)); + List myStep = listMap(sqlMy); + + if (Lang.isEmpty(myStep)) { + NutMap map = NutMap.NEW().setv("username", user.getUsername()) + .setv("loginname", user.getLoginname()) + .setv("userId", user.getId()) + .setv("step", 0); + myStep.add(map); + } + lists.addAll(0, myStep); + return lists; + } + + @Override + public Object getDataOfPrize(String hdid, String unionId, String unitId, String searchName, String searchKeyword) { + + CndPlus cnd = CndPlus.create(); + Sql sql = Sqls.create(""" + SELECT + userId, + u.username, + u.loginname, + un.`name` as unitname + FROM + `jsz_award_list` award + LEFT JOIN sys_user u ON award.userId = u.id + LEFT JOIN sys_unit un ON un.id = u.unitid + $condition + """); + cnd.and("activityId", "=", hdid); + cnd.and("left(applyDate, 10)", "=", DateUtil.format(DateUtil.offsetDay(new Date(), -1), "yyyy-MM-dd")); + + cnd.andEX("u.unitId", "=", unitId); + cnd.andEX("u.unionId", "=", unionId); + + if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) { + cnd.and(searchName, "LIKE", "%" + searchKeyword + "%"); + } + + cnd.groupBy("userId"); + + sql.setCondition(cnd); + List nutMaps = listMap(sql); + return nutMaps; + } +} diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/constant/MemberChangeType.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/constant/MemberChangeType.java index 9e2980e..822bed4 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/constant/MemberChangeType.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/constant/MemberChangeType.java @@ -22,11 +22,10 @@ public enum MemberChangeType { WITHDRAWAL("WITHDRAWAL","退会"), WORK("WORK","在职"), LEAVE_SCHOOL("LEAVE_SCHOOL","离校"), - RETIRE("RETIRE","退休"), - RESIGN("RESIGN","辞职"), - OUT("OUT","调出"), - LEAVE_OFFICE("LEAVE_OFFICE","离职"), - OTHER("OTHER","其他"), + RETIRE("RETIRE","离退休"), + DIE("DIE","去世"), + REPORTING("REPORTING","报到中"), + NO_REPORTING("NO_REPORTING","不报到"), UNIT_CHANGE("UNIT_CHANGE","单位异动"), UNION_CHANGE("UNION_CHANGE","工会关系异动"), BASIC_CHANGE("BASIC_CHANGE","基本信息异动"); diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyBranchUnionAuditController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyBranchUnionAuditController.java index f711f39..61aa63e 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyBranchUnionAuditController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyBranchUnionAuditController.java @@ -7,11 +7,14 @@ import cn.wizzer.framework.base.Result; import cn.wizzer.framework.page.Pagination; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.model.Audit; +import io.v.nutz.base.utils.MsgApi; import io.v.nutz.base.utils.Vi; import io.v.nutz.sys.models.Sys_union; import io.v.nutz.sys.models.Sys_user; import io.v.nutz.sys.models.User; import io.v.nutz.sys.services.SysLocalProcessService; +import io.v.nutz.sys.services.SysUserService; +import io.v.nutz.web.commons.base.Globals; import io.v.nutz.web.commons.slog.annotation.SLog; import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.staffmanage.member.handle.MemberApplyToDoHandler; @@ -35,6 +38,8 @@ import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Param; +import java.util.List; + /** * @version 1.0 * @Author zzr @@ -50,6 +55,10 @@ public class MemberApplyBranchUnionAuditController { @Inject private Dao dao; @Inject + private MsgApi msgApi; + @Inject + private SysUserService sysUserService; + @Inject private MemberCommonService memberCommonService; @Inject private SysLocalProcessService localProcessService; @@ -85,9 +94,9 @@ public class MemberApplyBranchUnionAuditController { cnd.and("record.allocationUnionId", "=", Vi.getUnionId()); } if (pageForm.getAudit()) { - cnd.and("record.applyStateId", ">", 50); + cnd.and("record.applyStateId", ">", 20); } else { - cnd.and("record.applyStateId", "=", 50); + cnd.and("record.applyStateId", "=", 20); } cnd.desc("record.applyDateTime"); sql.setCondition(cnd); @@ -112,53 +121,28 @@ public class MemberApplyBranchUnionAuditController { MemberApplyRecord record = dao.fetch(MemberApplyRecord.class, id); if (audit.getAuditType() == 2) { // 退回修改 - record.setApplyStateId(60); + record.setApplyStateId(30); } else if (audit.getAuditType() == 1) { // 通过 - record.setApplyStateId(80); + record.setApplyStateId(50); } else { // 拒绝 - record.setApplyStateId(70); + record.setApplyStateId(40); } record.setBranchUnionAuditId(audit.getId()); dao.updateIgnoreNull(record); + MemberApplyToDoHandler.COMPLETE_UNION_TASK.exec(record, NutMap.NEW().addv("nodeName", "分工会审核完成")); + // 获取分配工会信息 + Sys_union union = dao.fetch(Sys_union.class, Cnd.where("id", "=", record.getAllocationUnionId())); if (audit.getAuditType() == 2) { MemberApplyToDoHandler.CREATE_APPLY_RE_MODIFY_TASK.exec(record, null); } else if (audit.getAuditType() == 1) { - MemberApplyToDoHandler.COMPLETE_PROCESS.exec(record, null); - // 判断是否改变了工会关系 - - User user = dao.fetch(User.class, Cnd.where("id", "=", record.getUserId())); - if (!ObjectUtil.equals(user.getUnionid(), record.getAllocationUnionId())) { - if (dao.count(SpecialStaff.class, Cnd.where("userId", "=", record.getUserId())) > 0) { - dao.clear(SpecialStaff.class, Cnd.where("userId", "=", record.getUserId())); - user = dao.fetch(User.class, Cnd.where("id", "=", record.getUserId())); - } - - if (!ObjectUtil.equals(user.getUnionid(), record.getAllocationUnionId())) { - Sys_union union = dao.fetch(Sys_union.class, Cnd.where("id", "=", record.getAllocationUnionId())); - SpecialStaff staff = new SpecialStaff(); - staff.setUserId(record.getUserId()); - staff.setPersonnelRelationUnitId(user.getUnitid()); - staff.setPersonnelRelationUnitName(user.getUnitname()); - staff.setUnionRelationUnionId(union.getId()); - staff.setUnionRelationUnionName(union.getUnionname()); - staff.setIsManyUnit(false); - staff.setSpecialStaffType("HMC_RELATION"); - dao.insert(staff); - } - } - - Sys_user sysUser = new Sys_user(); - BeanUtil.copyProperties(record, sysUser); - sysUser.setId(user.getId()); - dao.updateIgnoreNull(sysUser); + MemberApplyToDoHandler.CREATE_SCHOOL_TASK.exec(record, null); } else { MemberApplyToDoHandler.REFUSE_UNION_TASK.exec(record, NutMap.NEW().addv("nodeName", "分工会审核拒绝")); } - MemberApplyToDoHandler.COMPLETE_UNION_TASK.exec(record, NutMap.NEW().addv("nodeName", "分工会审核完成")); return null; } @@ -174,7 +158,7 @@ public class MemberApplyBranchUnionAuditController { .add("branchUnionAuditId", null), Cnd.where("id", "=", id)); dao.clear(Audit.class, Cnd.where("id", "=", record.getBranchUnionAuditId())); // 待办撤回 - localProcessService.revokeTask("MEMBER_APPLY@" + id, "分工会审核"); + localProcessService.revokeTask("MEMBER_APPLY@" + id, "待分工会审核"); return null; } } diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyController.java index 101bfe5..8e598ed 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyController.java @@ -3,7 +3,10 @@ package io.v.nutz.zhgh.staffmanage.member.controller.apply; import cn.wizzer.framework.base.Result; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.utils.MsgApi; +import io.v.nutz.base.utils.Roles; +import io.v.nutz.sys.models.Sys_user_role; import io.v.nutz.sys.models.User; +import io.v.nutz.web.commons.base.Globals; import io.v.nutz.web.commons.slog.annotation.SLog; import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.staffmanage.member.constant.MemberChangeOrigin; @@ -101,6 +104,12 @@ public class MemberApplyController { @RequiresPermissions("member.apply.submit") @SLog(tag = "会员入会申请", msg = "提交申请") public Object doSubmit(MemberApplyRecord record){ + + int count = dao.count(Sys_user_role.class, Cnd.where("userId", "=", record.getUserId()).and("roleId", "=", Roles.MEMBER)); + if (count > 0) { + return Result.error("您已经是会员,请勿重复申请"); + } + record.setMember(true); record.setUserId(ShiroUtil.getUserId()); record.setChangeOrigin(MemberChangeOrigin.PERSONAL.name()); @@ -110,20 +119,14 @@ public class MemberApplyController { if (record.getApplyStateId() != null && List.of(30, 60).contains(record.getApplyStateId())) { MemberApplyToDoHandler.COMPLETE_APPLY_RE_MODIFY_TASK.exec(record, NutMap.NEW().addv("nodeName", "重新修改申请")); } - // 待校工会审核 + // 待分工会审核 record.setApplyStateId(20); dao.insertOrUpdate(record); // 审核流程开始 MemberApplyToDoHandler.START_PROCESS.exec(record, null); - MemberApplyToDoHandler.CREATE_SCHOOL_TASK.exec(record, null); + MemberApplyToDoHandler.CREATE_UNION_TASK.exec(record, null); - // 短信通知 -// List schoolLoginNameList = commonService.getSchoolOrBranchUnionMemberAdminLoginNames("school", null); -// String schoolLoginNameListStr = schoolLoginNameList.stream().distinct().collect(Collectors.joining(",")); -// -// String content = "%s老师正申请加入工会,请您点击此条消息或前往智慧工会进行审核"; -// msgApi.sendMsg(List.of("DingTalk"), schoolLoginNameListStr, 2, "协会入会邀请", content, "", ""); return null; } diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyMineController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyMineController.java index a11305e..3c5e8f2 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyMineController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplyMineController.java @@ -1,11 +1,15 @@ package io.v.nutz.zhgh.staffmanage.member.controller.apply; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.wizzer.framework.base.Result; import cn.wizzer.framework.page.Pagination; +import com.deepoove.poi.XWPFTemplate; +import com.deepoove.poi.config.Configure; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.model.Audit; import io.v.nutz.base.utils.Vi; +import io.v.nutz.sys.models.User; import io.v.nutz.sys.services.SysLocalProcessService; import io.v.nutz.web.commons.slog.annotation.SLog; import io.v.nutz.web.commons.utils.ShiroUtil; @@ -28,6 +32,13 @@ import org.nutz.lang.util.NutMap; import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; +import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + /** * @version 1.0 * @Author zzr @@ -145,4 +156,28 @@ public class MemberApplyMineController { } return nutMap; } + + + @At + @Ok("void") + @RequiresPermissions("member.apply.mine") + @SLog(tag = "会员入会申请", msg = "导出开卡证明") + public void doExportProve(HttpServletResponse response){ + try { + User user = dao.fetch(User.class, Cnd.where("id","=",ShiroUtil.getUserId())); + Map map = new HashMap(); + map.put("userName", user.getUsername()); + map.put("unitName", user.getUnitname()); + map.put("idCard", user.getIdcard()); + map.put("date", DateUtil.format(new Date(),"yyyy年MM月dd日")); + response.addHeader("Content-Type", "application/octet-stream"); + response.addHeader("Content-Disposition", "attachment; filename=\"" + new String("办卡申请".getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + "\".docx"); + Configure config = Configure.newBuilder().build(); + InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/member/addIdCard.docx"); + XWPFTemplate.compile(inputStream, config).render(map, response.getOutputStream()); + inputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplySchoolUnionAuditController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplySchoolUnionAuditController.java index 606024a..8961ec1 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplySchoolUnionAuditController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/apply/MemberApplySchoolUnionAuditController.java @@ -1,11 +1,19 @@ package io.v.nutz.zhgh.staffmanage.member.controller.apply; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import cn.wizzer.framework.base.Result; import cn.wizzer.framework.page.Pagination; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.model.Audit; +import io.v.nutz.base.utils.MsgApi; +import io.v.nutz.base.utils.Roles; +import io.v.nutz.sys.models.Sys_user; +import io.v.nutz.sys.models.Sys_user_role; +import io.v.nutz.sys.models.User; import io.v.nutz.sys.services.SysLocalProcessService; +import io.v.nutz.sys.services.SysUserService; +import io.v.nutz.web.commons.base.Globals; import io.v.nutz.web.commons.slog.annotation.SLog; import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.staffmanage.member.handle.MemberApplyToDoHandler; @@ -22,6 +30,7 @@ import org.nutz.dao.sql.Sql; 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 org.nutz.lang.util.NutMap; import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; @@ -44,6 +53,10 @@ public class MemberApplySchoolUnionAuditController { @Inject private Dao dao; @Inject + private MsgApi msgApi; + @Inject + private SysUserService sysUserService; + @Inject private MemberCommonService memberCommonService; @Inject private SysLocalProcessService localProcessService; @@ -51,16 +64,18 @@ public class MemberApplySchoolUnionAuditController { @At("/") @Ok("beetl:/platform/member/apply/schoolUnionAudit/index.html") @RequiresPermissions("member.apply.schoolUnion.audit") - public void index() {} + public void index() { + } @At("/h5") @Ok("beetl:/mobile/member/apply/schoolUnionAudit/index.html") @RequiresPermissions("member.apply.schoolUnion.audit") - public void h5() {} + public void h5() { + } @At @RequiresPermissions("member.apply.schoolUnion.audit") - public Object pageData(MemberApplyPageForm pageForm){ + public Object pageData(MemberApplyPageForm pageForm) { Sql sql = Sqls.create(""" SELECT record.*, @@ -75,9 +90,9 @@ public class MemberApplySchoolUnionAuditController { Cnd cnd = Cnd.NEW(); pageForm.buildSearch(cnd, "record."); if (pageForm.getAudit()) { - cnd.and("record.applyStateId", ">", 20); + cnd.and("record.applyStateId", ">", 50); } else { - cnd.and("record.applyStateId", "=", 20); + cnd.and("record.applyStateId", "=", 50); } cnd.desc("record.applyDateTime"); sql.setCondition(cnd); @@ -91,7 +106,7 @@ public class MemberApplySchoolUnionAuditController { @Aop(TransAop.READ_COMMITTED) @RequiresPermissions("member.apply.schoolUnion.audit") @SLog(type = "memberApply", tag = "会员入会申请", msg = "校工会审核") - public Object approval(@Param("audit") Audit audit, String id, String unionId){ + public Object approval(@Param("audit") Audit audit, String id) { audit.setAuditor(ShiroUtil.getUserId()); audit.setLoginname(ShiroUtil.getPlatformLoginname()); audit.setUsername(ShiroUtil.getPlatformUsername()); @@ -101,52 +116,43 @@ public class MemberApplySchoolUnionAuditController { MemberApplyRecord record = dao.fetch(MemberApplyRecord.class, id); if (audit.getAuditType() == 2) { // 退回修改 - record.setApplyStateId(30); + record.setApplyStateId(60); } else if (audit.getAuditType() == 1) { // 通过 - record.setApplyStateId(50); + record.setApplyStateId(80); } else { // 拒绝 - record.setApplyStateId(40); + record.setApplyStateId(70); } - record.setAllocationUnionId(unionId); record.setSchoolUnionAuditId(audit.getId()); dao.updateIgnoreNull(record); + MemberApplyToDoHandler.COMPLETE_SCHOOL_TASK.exec(record, NutMap.NEW().addv("nodeName", "校工会审核完成")); if (audit.getAuditType() == 2) { MemberApplyToDoHandler.CREATE_APPLY_RE_MODIFY_TASK.exec(record, null); - // 短信通知 -// String content = "%s老师您好,您的入会申请被校工会退回,您可根据退回原因修改后再次提交,如有疑问请及时联系校工会".formatted(record.getUsername()); } else if (audit.getAuditType() == 1) { - Sql sql = Sqls.create(""" - SELECT - u.loginname, - u.username - FROM - `sys_user_role` userRole - LEFT JOIN sys_role role ON role.id = userRole.roleId - LEFT JOIN `user` u ON u.id = userRole.userId - WHERE - role.`code` = 'BranchUnionMemberAdmin' and u.unionid = @unionId - group by u.loginname - """).setParam("unionId", unionId); - List list = memberCommonService.listMap(sql); + MemberApplyToDoHandler.COMPLETE_PROCESS.exec(record, null); + // 将填写内容修改到用户表 + User user = dao.fetch(User.class, Cnd.where("id", "=", record.getUserId())); + Sys_user sysUser = new Sys_user(); + BeanUtil.copyProperties(record, sysUser); + sysUser.setId(user.getId()); + dao.updateIgnoreNull(sysUser); - List unionLeaderLoginNames = list.stream().map(v -> v.getString("loginname")).toList(); - MemberApplyToDoHandler.CREATE_UNION_TASK.exec(record, NutMap.NEW().addv("unionLeaderLoginNames", unionLeaderLoginNames)); + // 还要设置会员角色 + int count = dao.count(Sys_user_role.class, Cnd.where("userId", "=", user.getId()).and("roleId", "=", Roles.MEMBER)); + if (count == 0) { + Sys_user_role userRole = new Sys_user_role(); + userRole.setUserId(user.getId()); + userRole.setRoleId(Roles.MEMBER); + dao.insert(userRole); + } - // 短信通知 -// for (NutMap map : list) { -// String content = "%s老师您好,%s老师的入会申请校工会已通过,现将工会关系划入本工会,请您点击此消息或前往智慧工会进行接收" -// .formatted(map.getString("username"), record.getUsername()); -// } + sysUserService.deleteCacheAndUpdate(user.getId()); } else { MemberApplyToDoHandler.REFUSE_UNION_TASK.exec(record, NutMap.NEW().addv("nodeName", "校工会审核拒绝")); - // 短信通知 -// String content = "%s老师您好,您的入会申请被校工会拒绝,如有疑问请及时联系校工会".formatted(record.getUsername()); } - MemberApplyToDoHandler.COMPLETE_SCHOOL_TASK.exec(record, NutMap.NEW().addv("nodeName", "校工会审核完成")); return null; } @@ -156,13 +162,13 @@ public class MemberApplySchoolUnionAuditController { @Aop(TransAop.READ_COMMITTED) @RequiresPermissions("member.apply.schoolUnion.audit") @SLog(type = "memberApply", tag = "会员入会申请", msg = "校工会撤回") - public Object doRevoke(String id){ + public Object doRevoke(String id) { MemberApplyRecord record = dao.fetch(MemberApplyRecord.class, id); - dao.update(MemberApplyRecord.class, Chain.make("applyStateId", 20) + dao.update(MemberApplyRecord.class, Chain.make("applyStateId", 50) .add("schoolUnionAuditId", null), Cnd.where("id", "=", id)); dao.clear(Audit.class, Cnd.where("id", "=", record.getSchoolUnionAuditId())); // 待办撤回 - localProcessService.revokeTask("MEMBER_APPLY@" + id, "校工会审核"); + localProcessService.revokeTask("MEMBER_APPLY@" + id, "待校工会审核"); return null; } } diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeBranchUnionAuditController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeBranchUnionAuditController.java index a02e855..6e75870 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeBranchUnionAuditController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeBranchUnionAuditController.java @@ -11,8 +11,6 @@ import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.staffmanage.member.handle.MemberChangeToDoHandler; import io.v.nutz.zhgh.staffmanage.member.model.MemberChangeRecord; import io.v.nutz.zhgh.staffmanage.member.param.pageForm.MemberChangePageForm; - -import io.v.nutz.zhgh.staffmanage.member.param.vo.MemberChangeBranchUnionAuditVo; import io.v.nutz.zhgh.staffmanage.member.service.MemberCommonService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.nutz.aop.interceptor.ioc.TransAop; @@ -29,6 +27,8 @@ import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Param; +import java.util.List; + /** * @version 1.0 * @Author zzr @@ -96,7 +96,7 @@ public class MemberChangeBranchUnionAuditController { audit.setLoginname(ShiroUtil.getPlatformLoginname()); audit.setUsername(ShiroUtil.getPlatformUsername()); audit.setAuditTime(DateUtil.date()); - audit = dao.insert(audit); + dao.insert(audit); MemberChangeRecord record = dao.fetch(MemberChangeRecord.class, id); if (audit.getAuditType() == 2) { @@ -124,28 +124,41 @@ public class MemberChangeBranchUnionAuditController { return null; } + + @At @ViReturn @Aop(TransAop.READ_COMMITTED) @RequiresPermissions("member.change.branchUnion.audit") @SLog(type = "memberChange", tag = "会员变更", msg = "分工会批量审核") - public Object allApproval(MemberChangeBranchUnionAuditVo memberChangeBranchUnionAuditVo){ - Audit audit = memberChangeBranchUnionAuditVo.getAudit(); + public Object doBatchApproval(@Param("data") String[] ids){ + if (ids.length == 0) { + return Result.error("未获取到选择数据"); + } + + // 批量审核,那就只有一条审核的记录 + Audit audit = new Audit(); audit.setAuditor(ShiroUtil.getUserId()); audit.setLoginname(ShiroUtil.getPlatformLoginname()); audit.setUsername(ShiroUtil.getPlatformUsername()); audit.setAuditTime(DateUtil.date()); - audit.setAuditOpinion("通过"); - audit = dao.insert(audit); - for (String id : memberChangeBranchUnionAuditVo.getIds()) { - MemberChangeRecord record = dao.fetch(MemberChangeRecord.class, id); - // 通过 - record.setApplyStateId(10050); - record.setBranchUnionAuditId(audit.getId()); - dao.updateIgnoreNull(record); + audit.setAuditOpinion("分工会批量审核通过"); + dao.insert(audit); + + // 查询要审核的变更记录 + List recordList = dao.query(MemberChangeRecord.class, Cnd.where("id", "in", ids)); + for (MemberChangeRecord record : recordList) { + // 批量推送待办 MemberChangeToDoHandler.COMPLETE_UNION_TASK.exec(record, NutMap.NEW().addv("nodeName", "分工会审核完成")); MemberChangeToDoHandler.CREATE_SCHOOL_TASK.exec(record, null); + + // 推送短信 } + + dao.update(MemberChangeRecord.class, + Chain.make("applyStateId", 10050).add("branchUnionAuditId", audit.getId()), + Cnd.where("id", "in", ids)); + return null; } diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeManageController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeManageController.java index 784bb83..ed3786f 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeManageController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeManageController.java @@ -37,6 +37,7 @@ import io.v.nutz.zhgh.staffmanage.member.template.MemberTemp; import io.v.nutz.zhgh.staffmanage.member.utils.MemberUtils; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.nutz.aop.interceptor.ioc.TransAop; import org.nutz.dao.Chain; @@ -72,33 +73,32 @@ import java.util.stream.Collectors; @Slf4j public class MemberChangeManageController { + @Inject + private MemberCommonService memberService; + @Inject + private AuditService auditService; + @Inject("MemberChangeRecord") + private ViService recordViService; + @Inject + private Vi vi; + @Inject + private Dao dao; + @Inject + private SysUnitService sysUnitService; + @Inject + private SysUserService sysUserService; + + @At("") @Ok("beetl:/platform/member/change/manage/index.html") - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public void index() { } - @Inject - private MemberCommonService memberService; - - @Inject - private AuditService auditService; - - @Inject("MemberChangeRecord") - private ViService recordViService; - - @Inject - private Vi vi; - - @Inject - private Dao dao; - - @Inject - private SysUnitService sysUnitService; @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object pageData(@Param(value = "unionId", required = false) String unionId, @Param(value = "unitId", required = false) String unitId, @Param(value = "threeUnitId", required = false) String threeUnitId, @@ -276,7 +276,7 @@ public class MemberChangeManageController { @At @ViReturn @Aop(TransAop.READ_COMMITTED) - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) @SLog(tag = "会员高级管理-会员变更", msg = "分工会/校工会会员管理员提交变更") public Object doSubmitChange(MemberChangeRecord record) { // 检验是否有变更 @@ -340,7 +340,7 @@ public class MemberChangeManageController { @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object sendSms(String userid) { Sys_user user = userService.fetch(userid); /*if (Strings.isNotBlank(user.getMobile())) { @@ -356,10 +356,13 @@ public class MemberChangeManageController { */ @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object allIsWelfareMember(PageForm pageForm, @Param(value = "startDate", required = false) String startDate, @Param(value = "endDate", required = false) String endDate, + @Param(value = "commonStartDate", required = false) String commonStartDate, + @Param(value = "commonEndDate", required = false) String commonEndDate, + @Param(value = "birthMonth", required = false) String birthMonth, @Param(value = "year", required = false) Integer year, @Param(value = "unionId", required = false) String[] unionId, @Param(value = "unitId", required = false) String[] unitId, @@ -378,9 +381,11 @@ public class MemberChangeManageController { @Param(value = "memberSearchKeyWord", required = false) String memberSearchKeyWord, @Param(value = "isAppendWelfareMember", required = false) Boolean isAppendWelfareMember) { int yyyy = Calendar.getInstance().get(Calendar.YEAR); - Cnd cnd = MemberUtils.getCnd(pageForm, startDate, endDate, unionId, unitId, personTypes, userStates, null, memberTypes, sexTypes, age, null, roleIds, null, null, memberStatus, threeUnitId, unionGroupId, reverseSelection, null, null, campus); + Cnd cnd = MemberUtils.getCnd(pageForm, startDate, endDate, birthMonth, commonStartDate, commonEndDate, unionId, unitId, + personTypes, userStates, null, memberTypes, sexTypes, age, null, roleIds, null, + null, memberStatus, threeUnitId, unionGroupId, reverseSelection, null, null, campus); Sql sql = Sqls.create(""" - SELECT u.* from $table + SELECT u.id from $table LEFT JOIN sys_user_role sur ON sur.userid = u.id $condition """); @@ -396,10 +401,6 @@ public class MemberChangeManageController { if (StrUtil.isNotBlank(memberSearchName)) { cnd.and(new SqlExpressionGroup().andLike(memberSearchName, memberSearchKeyWord)); } - List status = new ArrayList<>(); -// status.add(MemberStatus.NORMAL.getCode()); -// status.add(MemberStatus.TURN_IN.getCode()); -// status.add(MemberStatus.RESTORE.getCode()); if (!ShiroUtil.hasAnyRoles("sysadmin,A06,H03")) { cnd.and("unionid", "=", Vi.getUnionId()); @@ -409,13 +410,24 @@ public class MemberChangeManageController { } cnd.groupBy("u.id"); sql.setCondition(cnd); - List ids = memberService.list(sql).stream().map(v -> v.getString("id")).collect(Collectors.toList()); + sql.setCallback(Sqls.callback.strList()); + dao.execute(sql); + List ids = sql.getList(String.class); + + + // 杭医特有,他们有一个福利享受截止时间,在这个时间之前的退休人员,也需要享受福利 + Sql welfareSql = Sqls.create("select id from sys_user where welfareStopTime < CURDATE() and userState = '退休'"); + welfareSql.setCallback(Sqls.callback.strList()); + dao.execute(welfareSql); + ids.addAll(welfareSql.getList(String.class)); + Trans.exec(() -> { if (!isAppendWelfareMember) { memberService.update(Chain.make("welfareMember", WelfareMemberMode.NONE.getCode()), Cnd.where("welfareMember", "=", WelfareMemberMode.NORMAL.getCode())); } - memberService.update(Chain.make("welfareMember", WelfareMemberMode.NORMAL.getCode()), Cnd.where("member", "=", MemberMode.NORMAL.getCode()).and("id", "in", ids)); +// memberService.update(Chain.make("welfareMember", WelfareMemberMode.NORMAL.getCode()), Cnd.where("member", "=", MemberMode.NORMAL.getCode()).and("id", "in", ids)); + dao.update(Sys_user.class, Chain.make("welfareMember", true), Cnd.where("id", "in", ids)); }); return null; } @@ -428,7 +440,7 @@ public class MemberChangeManageController { */ @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object userUnitMove(String threeUnitId, String unitId, @Param("userId[]") String[] userId) { Sys_unit unit = memberService.dao().fetch(Sys_unit.class, unitId); @@ -465,7 +477,7 @@ public class MemberChangeManageController { @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object userPageData(PageForm pageForm, @Param(value = "unitId", required = false) String unitId, @Param(value = "unionId", required = false) String unionId, @@ -504,7 +516,7 @@ public class MemberChangeManageController { @At @ViReturn @Aop(TransAop.READ_COMMITTED) - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object joinWelfareMember(String[] userIds, String taskId, @Param(value = "threeUnitId", required = false) String threeUnitId, @Param(value = "unitId", required = false) String unitId) { @@ -547,7 +559,7 @@ public class MemberChangeManageController { @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object units() { Cnd cnd = Cnd.NEW(); cnd.and("unitlevel", "=", 2); @@ -559,7 +571,7 @@ public class MemberChangeManageController { @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object batchUpdatePersonType(@Param("users") String data) { List users = Json.fromJsonAsList(Sys_user.class, data); for (Sys_user user : users) { @@ -570,7 +582,7 @@ public class MemberChangeManageController { @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object batchUpdateUserState(@Param("users") String data) { List users = Json.fromJsonAsList(Sys_user.class, data); for (Sys_user user : users) { @@ -582,7 +594,7 @@ public class MemberChangeManageController { @At @Ok("void") - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public void downloadImport(HttpServletResponse response) { try { ViTool.excelResponse(response, "会员导入模版.xlsx"); @@ -612,7 +624,7 @@ public class MemberChangeManageController { @At @Aop(TransAop.READ_COMMITTED) - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) @AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"}) @SLog(type = "会员管理系统", tag = "信息维护-会员高级管理", msg = "导入会员", param = true, result = true) public Object doImport(TempFile file) { @@ -726,7 +738,7 @@ public class MemberChangeManageController { @At @ViReturn - @RequiresPermissions("member.change.mange") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) public Object getAllChangeMemberInfo(String userId){ List mapList = memberService.getAllChangeInfo(userId); if (Lang.isEmpty(mapList)) { @@ -739,4 +751,49 @@ public class MemberChangeManageController { map.put("allChangeInfo", mapList); return map; } + + /** + * 验证工号是否重复 + * @param loginName + * @return + */ + @At + @ViReturn + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) + public Object validLoginName(String loginName){ + return dao.count(Sys_user.class, Cnd.where("loginname", "=", loginName)); + } + + + @At + @SLog(type = "memberChangeMember", tag = "会员高级管理", msg = "添加非库内人员") + @RequiresPermissions(value = {"member.change.mange", "staff.member.change.mange"}, logical = Logical.OR) + public Object doAddUser(Sys_user user){ + try { + if (Lang.isEmpty(user)) { + return Result.error("用户信息为空!"); + } + + int count = dao.count(Sys_user.class, Cnd.where("loginname", "=", user.getLoginname())); + if (count > 0) { + return Result.error("工号已存在!"); + } + + // 初始化用户并添加到系统 + Sys_user sysUser = UserMode.initUser(user); + dao.insert(sysUser); + + // 添加公共角色 + Sys_user_role userRole = new Sys_user_role(); + userRole.setUserId(sysUser.getId()); + userRole.setRoleId(Roles.PUBLIC); + dao.insert(userRole); + + sysUserService.deleteCacheAndUpdate(sysUser.getId()); + return Result.success(); + } catch (Exception e) { + log.error(e.getMessage()); + return Result.error(); + } + } } diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeSchoolUnionAuditController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeSchoolUnionAuditController.java index 23337df..948a373 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeSchoolUnionAuditController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/change/MemberChangeSchoolUnionAuditController.java @@ -27,6 +27,8 @@ import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Param; +import java.util.List; + /** * @version 1.0 * @Author zzr @@ -116,7 +118,7 @@ public class MemberChangeSchoolUnionAuditController { MemberChangeToDoHandler.CREATE_APPLY_RE_MODIFY_TASK.exec(record, NutMap.NEW().addv("nodeName", "校工会退回")); } else if (audit.getAuditType() == 1) { MemberChangeToDoHandler.COMPLETE_PROCESS.exec(record, null); - memberCommonService.compareChangeInfoAndUpdateMember(record.getId()); + memberCommonService.compareChangeInfoAndUpdateMember(record); } else { MemberChangeToDoHandler.REFUSE_UNION_TASK.exec(record, NutMap.NEW().addv("nodeName", "校工会审核拒绝")); } @@ -124,6 +126,44 @@ public class MemberChangeSchoolUnionAuditController { } + @At + @ViReturn + @Aop(TransAop.READ_COMMITTED) + @RequiresPermissions("member.change.schoolUnion.audit") + @SLog(type = "memberChange", tag = "会员变更", msg = "校工会批量审核") + public Object doBatchApproval(@Param("data") String[] ids){ + if (ids.length == 0) { + return Result.error("未获取到选择数据"); + } + + // 批量审核,那就只有一条审核的记录 + Audit audit = new Audit(); + audit.setAuditor(ShiroUtil.getUserId()); + audit.setLoginname(ShiroUtil.getPlatformLoginname()); + audit.setUsername(ShiroUtil.getPlatformUsername()); + audit.setAuditTime(DateUtil.date()); + audit.setAuditOpinion("校工会批量审核通过"); + dao.insert(audit); + + // 查询要审核的变更记录 + List recordList = dao.query(MemberChangeRecord.class, Cnd.where("id", "in", ids)); + for (MemberChangeRecord record : recordList) { + // 批量完成待办 + MemberChangeToDoHandler.COMPLETE_SCHOOL_TASK.exec(record, NutMap.NEW().addv("nodeName", "校工会审核完成")); + MemberChangeToDoHandler.COMPLETE_PROCESS.exec(record, null); + + memberCommonService.compareChangeInfoAndUpdateMember(record.getId()); + // 推送短信 + } + + dao.update(MemberChangeRecord.class, + Chain.make("applyStateId", 10080).add("schoolUnionAuditId", audit.getId()), + Cnd.where("id", "in", ids)); + + return null; + } + + @At @ViReturn @Aop(TransAop.READ_COMMITTED) diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/inquire/MemberAnalysisController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/inquire/MemberAnalysisController.java index 727fb20..1f418b1 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/inquire/MemberAnalysisController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/inquire/MemberAnalysisController.java @@ -52,8 +52,8 @@ public class MemberAnalysisController { gh.unioncode as unionCode, gh.unionname as unionName, ( SELECT count( 1 ) FROM member_his WHERE `year` = @lastYear AND unionid = gh.id ) AS '往年会员人数', - ( SELECT count( 1 ) FROM member_change_record WHERE currentUnionId = gh.id AND currentUnitId != originUnitId AND YEAR ( applyTime ) = @currentYear ) AS '校内异动变动到我工会人数', - ( SELECT count( 1 ) FROM member_change_record WHERE originUnionId = gh.id AND currentUnitId != originUnitId AND YEAR ( applyTime ) = @currentYear ) AS '校内异动我工会减少人数', + ( SELECT count( 1 ) FROM member_change_record WHERE unitId = gh.id AND unitId != changeOrigin AND YEAR ( applyDateTime ) = @currentYear ) AS '校内异动变动到我工会人数', + ( SELECT count( 1 ) FROM member_change_record WHERE changeOrigin = gh.id AND unitId != changeOrigin AND YEAR ( applyDateTime ) = @currentYear ) AS '校内异动我工会减少人数', ( SELECT count( 1 ) @@ -61,9 +61,9 @@ public class MemberAnalysisController { member_change_record mcr LEFT JOIN `user` u ON u.id = mcr.userId WHERE - mcr.`type` IN ( 2, 7 ) + mcr.`changeType` IN ( 2, 7 ) AND u.unionid = gh.id - AND YEAR ( mcr.applyTime ) = @currentYear + AND YEAR ( mcr.applyDateTime ) = @currentYear ) AS '新入职、恢复人数', ( SELECT @@ -72,9 +72,9 @@ public class MemberAnalysisController { member_change_record mcr LEFT JOIN `user` u ON u.id = mcr.userId WHERE - mcr.`type` IN ( 3, 4, 5, 6, 8 ) + mcr.`changeType` IN ( 3, 4, 5, 6, 8 ) AND u.unionid = gh.id - AND YEAR ( mcr.applyTime ) = @currentYear + AND YEAR ( mcr.applyDateTime ) = @currentYear ) AS '离职、去世、退休、开除、退会人数', (select count(1) from `user` where member = 1 and unionid = gh.id) as currentYearMemberNum FROM @@ -123,8 +123,8 @@ public class MemberAnalysisController { dw.unitcode as unitCode, dw.`name` as unitName, ( SELECT count( 1 ) FROM member_his WHERE `year` = @lastYear AND unitid = dw.id ) AS '往年会员人数', - ( SELECT count( 1 ) FROM member_change_record WHERE currentUnitId = dw.id AND currentUnitId != originUnitId AND YEAR ( applyTime ) = @currentYear ) AS '校内异动变动到我单位人数', - ( SELECT count( 1 ) FROM member_change_record WHERE originUnitId = dw.id AND currentUnitId != originUnitId AND YEAR ( applyTime ) = @currentYear ) AS '校内异动我单位减少人数', + ( SELECT count( 1 ) FROM member_change_record WHERE unitId = dw.id AND unitId != changeOrigin AND YEAR ( applyDateTime ) = @currentYear ) AS '校内异动变动到我单位人数', + ( SELECT count( 1 ) FROM member_change_record WHERE changeOrigin = dw.id AND unitId != changeOrigin AND YEAR ( applyDateTime ) = @currentYear ) AS '校内异动我单位减少人数', ( SELECT count( 1 ) @@ -132,9 +132,9 @@ public class MemberAnalysisController { member_change_record mcr LEFT JOIN `user` u ON u.id = mcr.userId WHERE - mcr.`type` IN ( 2, 7 ) + mcr.`changeType` IN ( 2, 7 ) AND u.unitid = dw.id - AND YEAR ( mcr.applyTime ) = @currentYear + AND YEAR ( mcr.applyDateTime ) = @currentYear ) AS '新入职、恢复人数', ( SELECT @@ -143,9 +143,9 @@ public class MemberAnalysisController { member_change_record mcr LEFT JOIN `user` u ON u.id = mcr.userId WHERE - mcr.`type` IN ( 3, 4, 5, 6, 8 ) + mcr.`changeType` IN ( 3, 4, 5, 6, 8 ) AND u.unitid = dw.id - AND YEAR ( mcr.applyTime ) = @currentYear + AND YEAR ( mcr.applyDateTime ) = @currentYear ) AS '离职、去世、退休、开除、退会人数', (select count(1) from `user` where member = 1 and unitid = dw.id) as currentYearMemberNum FROM @@ -192,8 +192,8 @@ public class MemberAnalysisController { dw.unitcode as unitCode, dw.`name` as unitName, ( SELECT count( 1 ) FROM member_his WHERE `year` = @lastYear AND unitid = dw.id ) AS '往年会员人数', - ( SELECT count( 1 ) FROM member_change_record WHERE currentUnitId = dw.id AND currentUnitId != originUnitId AND YEAR ( applyTime ) = @currentYear ) AS '校内异动变动到我单位人数', - ( SELECT count( 1 ) FROM member_change_record WHERE originUnitId = dw.id AND currentUnitId != originUnitId AND YEAR ( applyTime ) = @currentYear ) AS '校内异动我单位减少人数', + ( SELECT count( 1 ) FROM member_change_record WHERE unitId = dw.id AND unitId != changeOrigin AND YEAR ( applyDateTime ) = @currentYear ) AS '校内异动变动到我单位人数', + ( SELECT count( 1 ) FROM member_change_record WHERE changeOrigin = dw.id AND unitId != changeOrigin AND YEAR ( applyDateTime ) = @currentYear ) AS '校内异动我单位减少人数', ( SELECT count( 1 ) @@ -201,9 +201,9 @@ public class MemberAnalysisController { member_change_record mcr LEFT JOIN `user` u ON u.id = mcr.userId WHERE - mcr.`type` IN ( 2, 7 ) + mcr.`changeType` IN ( 2, 7 ) AND u.unitid = dw.id - AND YEAR ( mcr.applyTime ) = @currentYear + AND YEAR ( mcr.applyDateTime ) = @currentYear ) AS '新入职、恢复人数', ( SELECT @@ -212,9 +212,9 @@ public class MemberAnalysisController { member_change_record mcr LEFT JOIN `user` u ON u.id = mcr.userId WHERE - mcr.`type` IN ( 3, 4, 5, 6, 8 ) + mcr.`changeType` IN ( 3, 4, 5, 6, 8 ) AND u.unitid = dw.id - AND YEAR ( mcr.applyTime ) = @currentYear + AND YEAR ( mcr.applyDateTime ) = @currentYear ) AS '离职、去世、退休、开除、退会人数', (select count(1) from `user` where member = 1 and unitid = dw.id) as currentYearMemberNum FROM @@ -228,8 +228,8 @@ public class MemberAnalysisController { gh.unioncode as unionCode, gh.unionname as unionName, ( SELECT count( 1 ) FROM member_his WHERE `year` = @lastYear AND unionid = gh.id ) AS '往年会员人数', - ( SELECT count( 1 ) FROM member_change_record WHERE currentUnionId = gh.id AND currentUnitId != originUnitId AND YEAR ( applyTime ) = @currentYear ) AS '校内异动变动到我单位人数', - ( SELECT count( 1 ) FROM member_change_record WHERE originUnionId = gh.id AND currentUnitId != originUnitId AND YEAR ( applyTime ) = @currentYear ) AS '校内异动我单位减少人数', + ( SELECT count( 1 ) FROM member_change_record WHERE unitId = gh.id AND unitId != changeOrigin AND YEAR ( applyDateTime ) = @currentYear ) AS '校内异动变动到我单位人数', + ( SELECT count( 1 ) FROM member_change_record WHERE changeOrigin = gh.id AND unitId != changeOrigin AND YEAR ( applyDateTime ) = @currentYear ) AS '校内异动我单位减少人数', ( SELECT count( 1 ) @@ -237,9 +237,9 @@ public class MemberAnalysisController { member_change_record mcr LEFT JOIN `user` u ON u.id = mcr.userId WHERE - mcr.`type` IN ( 2, 7 ) + mcr.`changeType` IN ( 2, 7 ) AND u.unionid = gh.id - AND YEAR ( mcr.applyTime ) = @currentYear + AND YEAR ( mcr.applyDateTime ) = @currentYear ) AS '新入职、恢复人数', ( SELECT @@ -248,9 +248,9 @@ public class MemberAnalysisController { member_change_record mcr LEFT JOIN `user` u ON u.id = mcr.userId WHERE - mcr.`type` IN ( 3, 4, 5, 6, 8 ) + mcr.`changeType` IN ( 3, 4, 5, 6, 8 ) AND u.unionid = gh.id - AND YEAR ( mcr.applyTime ) = @currentYear + AND YEAR ( mcr.applyDateTime ) = @currentYear ) AS '离职、去世、退休、开除、退会人数', (select count(1) from `user` where member = 1 and unionid = gh.id) as currentYearMemberNum FROM diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/inquire/MemberInquireIntegrateController.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/inquire/MemberInquireIntegrateController.java index cb4cb09..ce9b959 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/inquire/MemberInquireIntegrateController.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/controller/inquire/MemberInquireIntegrateController.java @@ -73,6 +73,9 @@ public class MemberInquireIntegrateController { @Param(value = "isUnion", required = false) String isUnion, @Param(value = "startDate", required = false) String startDate, @Param(value = "endDate", required = false) String endDate, + @Param(value = "commonStartDate", required = false) String commonStartDate, + @Param(value = "commonEndDate", required = false) String commonEndDate, + @Param(value = "birthMonth", required = false) String birthMonth, @Param(value = "year", required = false) Integer year, @Param(value = "unionId", required = false) String[] unionId, @Param(value = "unitId", required = false) String[] unitId, @@ -93,7 +96,9 @@ public class MemberInquireIntegrateController { @Param(value = "memberSearchKeyWord", required = false) String memberSearchKeyWord) { int yyyy = Calendar.getInstance().get(Calendar.YEAR); - Cnd cnd = MemberUtils.getCnd(pageForm, startDate, endDate, unionId, unitId, personTypes, userStates, preparedBys, memberTypes, sexTypes, age, null, roleIds, null, null, memberStatus, threeUnitId, unionGroupId, reverseSelection, null, null, campus); + Cnd cnd = MemberUtils.getCnd(pageForm, startDate, endDate, commonStartDate, commonEndDate, birthMonth, unionId, + unitId, personTypes, userStates, preparedBys, memberTypes, sexTypes, age, null, roleIds, + null, null, memberStatus, threeUnitId, unionGroupId, reverseSelection, null, null, campus); Sql sql = Sqls.create(""" SELECT u.* from $table @@ -442,6 +447,9 @@ public class MemberInquireIntegrateController { @Param(value = "searchKeyword", required = false) String searchKeyword, @Param(value = "startDate", required = false) String startDate, @Param(value = "endDate", required = false) String endDate, + @Param(value = "commonStartDate", required = false) String commonStartDate, + @Param(value = "commonEndDate", required = false) String commonEndDate, + @Param(value = "birthMonth", required = false) String birthMonth, @Param(value = "year", required = false) Integer year, @Param(value = "unionId", required = false) String[] unionId, @Param(value = "unitId", required = false) String[] unitId, @@ -464,7 +472,9 @@ public class MemberInquireIntegrateController { try { int yyyy = Calendar.getInstance().get(Calendar.YEAR); - Cnd cnd = MemberUtils.getCnd(null, startDate, endDate, unionId, unitId, personTypes, userStates, preparedBys, memberTypes, sexTypes, age, null, roleIds, null, null, memberStatus, threeUnitId, unionGroupId, reverseSelection, null, null, campus); + Cnd cnd = MemberUtils.getCnd(null, startDate, endDate, commonStartDate, commonEndDate, birthMonth, + unionId, unitId, personTypes, userStates, preparedBys, memberTypes, sexTypes, age, null, roleIds, + null, null, memberStatus, threeUnitId, unionGroupId, reverseSelection, null, null, campus); Sql sql = Sqls.create(""" SELECT u.* from $table diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/handle/MemberApplyToDoHandler.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/handle/MemberApplyToDoHandler.java index 25614dd..e896494 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/handle/MemberApplyToDoHandler.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/handle/MemberApplyToDoHandler.java @@ -92,6 +92,44 @@ public enum MemberApplyToDoHandler { } }, + /** + * 创建分工会任务 + */ + CREATE_UNION_TASK() { + @Override + public void exec(MemberApplyRecord record, NutMap extra) { + List unionLeaderLoginNames = memberService.getSchoolOrBranchUnionMemberAdminLoginNames("branch", record.getUserId()); + localProcessService.createTask( + "MEMBER_APPLY@" + record.getId(), + "MEMBER_APPLY_UNION_AUDIT", + "待分工会审核", + ShiroUtil.getUserId(), + unionLeaderLoginNames, + "/platform/member/apply/branchUnion/audit", + "/platform/member/apply/branchUnion/audit", + "/platform/member/apply/branchUnion/audit", + "/platform/member/apply/branchUnion/audit" + ); + localProcessService.updateProcessNodeName("MEMBER_APPLY@" + record.getId(), "待分工会审核"); + } + }, + + /** + * 分工会完成 + */ + COMPLETE_UNION_TASK() { + @Override + public void exec(MemberApplyRecord record, NutMap extra) { + String nodeName = extra.getString("nodeName"); + localProcessService.completeTask( + "MEMBER_APPLY_UNION_AUDIT", + "MEMBER_APPLY@" + record.getId(), + ShiroUtil.getUserId(), + nodeName + ); + localProcessService.updateProcessNodeName("MEMBER_APPLY@" + record.getId(), nodeName); + } + }, /** * 创建校工会任务 @@ -117,7 +155,6 @@ public enum MemberApplyToDoHandler { } }, - /** * 校工会完成 */ @@ -136,46 +173,6 @@ public enum MemberApplyToDoHandler { }, - /** - * 创建分工会任务 - */ - CREATE_UNION_TASK() { - @Override - public void exec(MemberApplyRecord record, NutMap extra) { - List unionLeaderLoginNames = extra.getAsList("unionLeaderLoginNames", String.class); - localProcessService.createTask( - "MEMBER_APPLY@" + record.getId(), - "MEMBER_APPLY_UNION_AUDIT", - "分工会审核", - ShiroUtil.getUserId(), - unionLeaderLoginNames, - "/platform/member/apply/branchUnion/audit", - "/platform/member/apply/branchUnion/audit", - "/platform/member/apply/branchUnion/audit", - "/platform/member/apply/branchUnion/audit" - ); - localProcessService.updateProcessNodeName("MEMBER_APPLY@" + record.getId(), "分工会审核"); - } - }, - - /** - * 分工会完成 - */ - COMPLETE_UNION_TASK() { - @Override - public void exec(MemberApplyRecord record, NutMap extra) { - String nodeName = extra.getString("nodeName"); - localProcessService.completeTask( - "MEMBER_APPLY_UNION_AUDIT", - "MEMBER_APPLY@" + record.getId(), - ShiroUtil.getUserId(), - nodeName - ); - localProcessService.updateProcessNodeName("MEMBER_APPLY@" + record.getId(), nodeName); - } - }, - - /** * 审核拒绝 */ @@ -196,6 +193,17 @@ public enum MemberApplyToDoHandler { localProcessService.completeProcess("MEMBER_APPLY@" + record.getId()); localProcessService.updateProcessNodeName("MEMBER_APPLY@" + record.getId(), "审核通过"); } + }, + + + /** + * 删除流程 + */ + DELETE_PROCESS() { + @Override + public void exec(MemberApplyRecord record, NutMap extra) { + localProcessService.deleteProcessInstance("MEMBER_APPLY@" + record.getId()); + } }; diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/model/MemberApplyRecord.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/model/MemberApplyRecord.java index 50ad5a5..2cc4fe2 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/model/MemberApplyRecord.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/model/MemberApplyRecord.java @@ -217,4 +217,14 @@ public class MemberApplyRecord { @Comment("分配的工会关系") @ColDefine(type = ColType.VARCHAR, width = 50) private String allocationUnionId; + + @Column + @Comment("是否自愿加入工会") + @ColDefine(type = ColType.BOOLEAN) + private Boolean isVoluntary; + + @Column + @Comment("签字") + @ColDefine(type = ColType.VARCHAR, width = 100) + private String sign; } diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/model/MemberChangeRecord.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/model/MemberChangeRecord.java index 3e0e56a..13a132d 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/model/MemberChangeRecord.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/model/MemberChangeRecord.java @@ -239,5 +239,15 @@ public class MemberChangeRecord { @PrevInsert(now = true) private Date applyDateTime; + @Column + @Comment("会员加入时间") + @ColDefine(type = ColType.DATETIME) + private Date memberJoinTime; + + @Column + @Comment("离校日期") + @ColDefine(type = ColType.DATE) + private Date leaveSchoolDate; + private Boolean edit; } diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/param/vo/MemberChangeBranchUnionAuditVo.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/param/vo/MemberChangeBranchUnionAuditVo.java deleted file mode 100644 index aa4ab9e..0000000 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/param/vo/MemberChangeBranchUnionAuditVo.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.v.nutz.zhgh.staffmanage.member.param.vo; - -import io.v.nutz.base.model.Audit; -import lombok.Data; - -import java.util.List; - -/** - * @author hpf - */ -@Data -public class MemberChangeBranchUnionAuditVo { - private Audit audit; - - private List ids; -} diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/service/MemberCommonService.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/service/MemberCommonService.java index 468ba64..16e91d9 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/service/MemberCommonService.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/service/MemberCommonService.java @@ -78,6 +78,11 @@ public interface MemberCommonService extends ViService { * @param recordId */ void compareChangeInfoAndUpdateMember(String recordId); + /** + * 存储比较变更信息并更新会员信息 + * @param record + */ + void compareChangeInfoAndUpdateMember(MemberChangeRecord record); /** * 获取会员的变更信息 diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/service/impl/MemberCommonServiceImpl.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/service/impl/MemberCommonServiceImpl.java index 5c0fa7c..8677dec 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/service/impl/MemberCommonServiceImpl.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/service/impl/MemberCommonServiceImpl.java @@ -3,6 +3,7 @@ package io.v.nutz.zhgh.staffmanage.member.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.http.HtmlUtil; import cn.wizzer.framework.page.Pagination; import io.v.nutz.base.dao.CndPlus; @@ -23,10 +24,12 @@ import io.v.nutz.zhgh.staffmanage.member.service.MemberCommonService; import io.v.nutz.zhgh.staffmanage.specialstaff.model.SpecialStaff; import io.v.nutz.zhgh.welfare.model.WelfareList; import lombok.extern.slf4j.Slf4j; +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.ioc.aop.Aop; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.lang.Lang; @@ -76,7 +79,7 @@ public class MemberCommonServiceImpl extends ViServiceImpl implements @Override public List memberChangeRecords(String userId) { Sql sql = Sqls.create(MEMBER_CHANGE_RECORDS); - sql.setCondition(Cnd.where("mcr.userId", "=", userId).desc("mcr.applyTime")); + sql.setCondition(Cnd.where("mcr.userId", "=", userId).desc("mcr.applyDateTime")); return listMap(sql); } @@ -108,13 +111,13 @@ public class MemberCommonServiceImpl extends ViServiceImpl implements his.lastHistoryId, u.unitname, u.unionname, - mcr.stateId, + mcr.applyStateId, state.stateName, state.stateColor FROM `user_history` his LEFT JOIN member_change_record mcr ON mcr.id = his.memberChangeRecordId - LEFT JOIN audit_state state ON mcr.stateId = state.stateId + LEFT JOIN audit_state state ON mcr.applyStateId = state.stateId LEFT JOIN `user` u ON u.loginname = his.loginname $condition """); @@ -159,10 +162,10 @@ public class MemberCommonServiceImpl extends ViServiceImpl implements List dictList = sysDictService.getSubListByCode("ALLOW_CHANGE_FIELDS"); Set allowChangeFieldNames = dictList.stream().map(Sys_dict::getCode).collect(Collectors.toSet()); allowChangeFieldNames.add("member"); - allowChangeFieldNames.add("welfareMember"); +// allowChangeFieldNames.add("welfareMember"); Map dictMap = dictList.stream().collect(Collectors.toMap(Sys_dict::getCode, Sys_dict::getName)); dictMap.put("member", "会员状态"); - dictMap.put("welfareMember", "福利会员状态"); +// dictMap.put("welfareMember", "福利会员状态"); return NutMap.NEW().addv("allowChangeFieldNames", allowChangeFieldNames).addv("dictMap", dictMap); } @@ -234,6 +237,14 @@ public class MemberCommonServiceImpl extends ViServiceImpl implements @Override public void compareChangeInfoAndUpdateMember(String recordId) { MemberChangeRecord record = dao().fetch(MemberChangeRecord.class, recordId); + compareChangeInfoAndUpdateMember(record); + } + + @Override + @Aop(TransAop.READ_COMMITTED) + public void compareChangeInfoAndUpdateMember(MemberChangeRecord record) { + // 记录变更时间 + Date now = DateUtil.date(); List changeList = getChangeInfos(record); // 如果有工会关系人员,这个user用来存储数据 @@ -247,12 +258,11 @@ public class MemberCommonServiceImpl extends ViServiceImpl implements } if (Lang.isNotEmpty(history)) { - history.setRecordId(recordId); + history.setRecordId(record.getId()); history.setChangeTime(DateUtil.date()); history.setChangeTypes(record.getChangeTypes()); history.setChangeOrigin(record.getChangeOrigin()); - // 加入会员 if (record.getMember()) { int activityCount = dao().count(ActivityUserScope.class, Cnd.where("userId", "=", userId).and("groupId", "=", 1)); @@ -268,20 +278,34 @@ public class MemberCommonServiceImpl extends ViServiceImpl implements } } if (memberCount <= 0) { + // 赋予会员角色 Sys_user_role userRole = new Sys_user_role(); userRole.setUserId(userId); userRole.setRoleId(Roles.MEMBER); dao().insert(userRole); + // 记录入会时间,要判断user表里有没有存储会员加入时间的字段 + if (info.getMemberJoinTime() == null) { + record.setMemberJoinTime(now); + } } - // 杭医特有,其他学校请删除 - record.setPreparedBy("会员"); } else { if (record.getIsExitActivityMemberScope() != null && record.getIsExitActivityMemberScope()) { dao().clear(ActivityUserScope.class, Cnd.where("userId", "=", userId).and("groupId", "=", 1)); } dao().clear(Sys_user_role.class, Cnd.where("userId", "=", userId).and("roleId", "=", Roles.MEMBER)); - // 杭医特有,其他学校请删除 - record.setPreparedBy("教职工"); + // 看这个人的在职状态是退休或者是离职,记录退休时间和离职时间 + switch (record.getUserState()) { + case "退休" -> { + if (info.getRetireDate() == null) { + record.setRetireDate(now); + } + } + case "离职" -> { + if (info.getLeaveSchoolDate() == null) { + record.setLeaveSchoolDate(now); + } + } + } } // 加入福利会员 是否加入福利项目 @@ -348,10 +372,11 @@ public class MemberCommonServiceImpl extends ViServiceImpl implements sysUserService.clearCache(); sysRoleService.clearCache(); + + sysUserService.deleteCacheAndUpdate(info.getId()); } } - /** * 获取所有变更记录 * @param userId @@ -406,9 +431,14 @@ public class MemberCommonServiceImpl extends ViServiceImpl implements Object currentValue = this.booleanVerification(newMap.get(fieldName)); Object previousValue = this.booleanVerification(sourceMap.get(fieldName)); + if ("unitId".equals(fieldName)) { + currentValue = (newMap.get(fieldName) == null ? this.booleanVerification(newMap.get("unitid")) : currentValue); + previousValue = (sourceMap.get(fieldName) == null ? this.booleanVerification(sourceMap.get("unitid")) : previousValue); + } + if (!ObjectUtil.equals(currentValue, previousValue)) { String name = fieldsMap.getOrDefault(fieldName, fieldName); - if ("unitId".equals(fieldName)) { + if ("unitId".equals(fieldName) || "unitid".equals(fieldName)) { List unitList = dao().query(Sys_unit.class, Cnd.where("id", "in", List.of(previousValue, currentValue))); Object finalPreviousValue = previousValue; diff --git a/src/main/java/io/v/nutz/zhgh/staffmanage/member/utils/MemberUtils.java b/src/main/java/io/v/nutz/zhgh/staffmanage/member/utils/MemberUtils.java index 408ef85..be38997 100644 --- a/src/main/java/io/v/nutz/zhgh/staffmanage/member/utils/MemberUtils.java +++ b/src/main/java/io/v/nutz/zhgh/staffmanage/member/utils/MemberUtils.java @@ -1,5 +1,6 @@ package io.v.nutz.zhgh.staffmanage.member.utils; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import io.v.nutz.base.query.PageForm; import io.v.nutz.zhgh.activity.models.ActivityUserCnd; @@ -12,6 +13,9 @@ import org.nutz.dao.util.cri.Static; import org.nutz.lang.Lang; import org.nutz.lang.Strings; +import java.util.Arrays; +import java.util.List; + /** * @author: Aaron * @create: 2021-05-19 13:41 @@ -22,6 +26,9 @@ public class MemberUtils { public static Cnd getCnd(PageForm pageForm, String startDate, String endDate, + String commonStartDate, + String commonEndDate, + String birthMonth, String[] unionId, String[] unitId, String[] personTypes, @@ -117,13 +124,47 @@ public class MemberUtils { cnd.and(group);*/ } + + if (StrUtil.isNotBlank(birthMonth)) { + cnd.and("MONTH(birthday)", EQ_OR_NEQ_OP, NumberUtil.parseInt(birthMonth)); + } + + + if (Lang.isNotEmpty(userStates)) { + List userStateList = Arrays.stream(userStates).toList(); + + if (StrUtil.isAllNotBlank(commonStartDate, commonEndDate)) { + for (String userState : userStateList) { + switch (userState) { + case "在职" -> { + cnd.and("DATE(u.memberJoinTime)",GE_OR_NGE_OP, commonStartDate); + cnd.and("DATE(u.memberJoinTime)",LE_OR_NLE_OP, commonEndDate); + } + + case "离退休" -> { + cnd.and("DATE(u.retireDate)",GE_OR_NGE_OP, commonStartDate); + cnd.and("DATE(u.retireDate)",LE_OR_NLE_OP, commonEndDate); + } + + case "离校" -> { + cnd.and("DATE(u.leaveSchoolDate)",GE_OR_NGE_OP, commonStartDate); + cnd.and("DATE(u.leaveSchoolDate)",LE_OR_NLE_OP, commonEndDate); + } + } + } + } else { + cnd.andEX("u.userState", IN_OR_NIN_OP, userStates); + } + + + } + cnd.andEX("u.unionid", IN_OR_NIN_OP, unionId); cnd.andEX("u.unitid", IN_OR_NIN_OP, unitId); cnd.andEX("u.threeUnitId", IN_OR_NIN_OP, threeUnitId); cnd.andEX("u.unionGroupId", IN_OR_NIN_OP, unionGroupId); cnd.andEX("u.campus", EQ_OR_NEQ_OP, campus); cnd.andEX("u.personType", IN_OR_NIN_OP, personTypes); - cnd.andEX("u.userState", IN_OR_NIN_OP, userStates); cnd.andEX("u.preparedBy", IN_OR_NIN_OP, preparedBys); cnd.andEX("u.sex", IN_OR_NIN_OP, sexTypes); cnd.andEX("sur.jdhid", EQ_OR_NEQ_OP, teacherMeetingId); diff --git a/src/main/resources/docTemplate/member/addIdCard.docx b/src/main/resources/docTemplate/member/addIdCard.docx new file mode 100644 index 0000000..7145ca9 Binary files /dev/null and b/src/main/resources/docTemplate/member/addIdCard.docx differ diff --git a/src/main/resources/views/mobile/member/apply/branchUnionAudit/index.html b/src/main/resources/views/mobile/member/apply/branchUnionAudit/index.html index ecfcfd8..9bbfbe3 100644 --- a/src/main/resources/views/mobile/member/apply/branchUnionAudit/index.html +++ b/src/main/resources/views/mobile/member/apply/branchUnionAudit/index.html @@ -71,7 +71,7 @@ layout("/mobile/platform.html"){

- + 工作单位:{{item.unitName}} 所属工会:{{item.unionName}} - 分配工会:{{item.allocationUnionName}} 在职状态:{{item.userState}} 人员类型:{{item.personType}} @@ -121,12 +120,12 @@ layout("/mobile/platform.html"){ type="info" style="margin-right: 4px">查看 审核 撤回 @@ -145,7 +144,7 @@ layout("/mobile/platform.html"){
-
{{ '分工会接收' }}
+
{{ '分工会审核' }}
@@ -153,7 +152,7 @@ layout("/mobile/platform.html"){
取消 - 退回申请 + 拒绝接收 同意接收
diff --git a/src/main/resources/views/mobile/member/apply/common/memberApplyAuditInfo.js b/src/main/resources/views/mobile/member/apply/common/memberApplyAuditInfo.js index e9f2f93..36320cd 100644 --- a/src/main/resources/views/mobile/member/apply/common/memberApplyAuditInfo.js +++ b/src/main/resources/views/mobile/member/apply/common/memberApplyAuditInfo.js @@ -74,23 +74,20 @@ const MEMBER_APPLY_AUDIT_INFO = { - + + + {{ viewData.branchAudit.username }} + {{ viewData.branchAudit.auditTime }} + {{ viewData.branchAudit.auditOpinion }} + + {{ viewData.schoolAudit.username }} {{ viewData.schoolAudit.auditTime }} - {{ viewData.allocationUnionName }} {{ viewData.schoolAudit.auditOpinion }} - - - - {{ viewData.branchAudit.username }} - {{ viewData.branchAudit.auditTime }} - {{ viewData.branchAudit.auditOpinion }} - -
`, diff --git a/src/main/resources/views/mobile/member/apply/mine/index.html b/src/main/resources/views/mobile/member/apply/mine/index.html index 4a07849..3096736 100644 --- a/src/main/resources/views/mobile/member/apply/mine/index.html +++ b/src/main/resources/views/mobile/member/apply/mine/index.html @@ -2,229 +2,229 @@ layout("/mobile/platform.html"){ #-->
- - - - - - - - - -
- -
-
-
-
-
- | - {{item.username + '(' + item.loginname + ')'}} -
-
-
- -
- - 工作单位:{{item.unitName}} - 所属工会:{{item.unionName}} - 在职状态:{{item.userState}} - 人员类型:{{item.personType}} - -
- - - -
-
- 当前状态: - {{item.stateName}} -
-
- 查看 - - 编辑 -
-
-
-
-
- -
- - - - - - - + + + + + + + + + +
+ +
+
+
+
+
+ | + {{item.username + '(' + item.loginname + ')'}} +
+
+
+ +
+ + 工作单位:{{item.unitName}} + 所属工会:{{item.unionName}} + 在职状态:{{item.userState}} + 人员类型:{{item.personType}} + +
+ + + +
+
+ 当前状态: + {{item.stateName}} +
+
+ 查看 + + 编辑 +
+
+
+
+
+ +
+ + + + + + +
拒绝申请 同意申请
@@ -258,11 +246,6 @@ layout("/mobile/platform.html"){ this.$toast.fail('请填写审核意见') return } - if (!this.formData.unionId) { - this.$toast.fail('请选择分配工会') - return - } - let msg = '确定要通过此条申请吗?' if (approvalType === 0) { msg = '拒绝后不可撤回,确定要拒绝此条申请吗?' @@ -278,7 +261,6 @@ layout("/mobile/platform.html"){ const resp = await $.post('/platform/member/apply/schoolUnion/audit/approval', { audit: JSON.stringify(this.formData), id: this.id, - unionId: this.formData.unionId }) if (resp.code === 0) { this.$toast.success(resp.msg) diff --git a/src/main/resources/views/mobile/member/apply/submit/index.html b/src/main/resources/views/mobile/member/apply/submit/index.html index 8c6c02b..65b3cf9 100644 --- a/src/main/resources/views/mobile/member/apply/submit/index.html +++ b/src/main/resources/views/mobile/member/apply/submit/index.html @@ -2,404 +2,430 @@ layout("/mobile/platform.html"){ #-->
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
- 家庭主要成员及联系方式 -
-
- -
- - - -
-
- - - - -
-
- 返 回 - 保存申请 - 提交申请 -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ 家庭主要成员及联系方式 +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + +
+
+ 返 回 + 保存申请 + 提交申请 +
+
+ 拒绝申请 + 同意申请 @@ -110,7 +116,7 @@ layout("/layouts/platform.html"){ { prop: "personType", label: "人员类型", sortable: true }, { prop: "unionName", label: "所属工会", sortable: true }, { prop: "unitName", label: "所属单位", sortable: true }, - { prop: "allocationUnionName", label: "分配工会", sortable: true }, + // { prop: "sign", label: "签字" }, { prop: "stateName", label: "当前节点", sortable: true } ], @@ -145,7 +151,7 @@ layout("/layouts/platform.html"){ doApproval(approvalType){ let msg = '确定要通过此条申请吗?' if (approvalType === 0) { - msg = '拒绝后不可撤回,确定要拒绝此条申请吗?' + msg = '确定要拒绝接收此教工的工会关系吗?' } else if (approvalType === 2) { msg = '确定要退回此条申请吗?' } diff --git a/src/main/resources/views/platform/member/apply/common/memberApplyAuditInfo.js b/src/main/resources/views/platform/member/apply/common/memberApplyAuditInfo.js index 0528422..9256c1a 100644 --- a/src/main/resources/views/platform/member/apply/common/memberApplyAuditInfo.js +++ b/src/main/resources/views/platform/member/apply/common/memberApplyAuditInfo.js @@ -28,9 +28,9 @@ const MEMBER_APPLY_AUDIT_INFO = { {{ viewData.personType }} - {{ viewData.member ? '会员' : '非会员' }} - {{ viewData.welfareMember ? '福利会员' : '非福利会员' }} - + + + -
- 无数据 + 暂无
+ + + + + {{ viewData.branchAudit.username }} + + {{ viewData.branchAudit.auditTime }} + + {{ viewData.branchAudit.auditOpinion }} + + + -
校工会审核信息
{{ viewData.schoolAudit.username }} {{ viewData.schoolAudit.auditTime }} - - {{ viewData.allocationUnionName }} - {{ viewData.schoolAudit.auditOpinion }}
- -
分工会接收信息
- - {{ viewData.branchAudit.username }} - - {{ viewData.branchAudit.auditTime }} - - {{ viewData.branchAudit.auditOpinion }} - - -
`, @@ -94,7 +96,6 @@ const MEMBER_APPLY_AUDIT_INFO = { }, methods: { async onOpen(id){ - this.activeName="basicInfo" const resp = await $.post('/platform/member/apply/mine/findMemberApplyRecord', {id}) if (resp.code === 0) { this.viewData = resp.data diff --git a/src/main/resources/views/platform/member/apply/mine/index.html b/src/main/resources/views/platform/member/apply/mine/index.html index 1f3c620..bca1b8b 100644 --- a/src/main/resources/views/platform/member/apply/mine/index.html +++ b/src/main/resources/views/platform/member/apply/mine/index.html @@ -25,13 +25,20 @@ layout("/layouts/platform.html"){ + - + @@ -63,6 +70,7 @@ layout("/layouts/platform.html"){ { prop: "personType", label: "人员类型", sortable: true }, { prop: "unionName", label: "所属工会", sortable: true }, { prop: "unitName", label: "所属单位", sortable: true }, + // { prop: "sign", label: "签字" }, { prop: "stateName", label: "当前节点", sortable: true } ], } @@ -72,6 +80,12 @@ layout("/layouts/platform.html"){ 'member-apply-audit-info': MEMBER_APPLY_AUDIT_INFO }, methods: { + /** + * 导出开卡证明 + */ + doExportProve(){ + window.open("/platform/member/apply/mine/doExportProve") + }, openView(row){ this.$refs.guava.view() this.$nextTick(() => { diff --git a/src/main/resources/views/platform/member/apply/schoolUnionAudit/index.html b/src/main/resources/views/platform/member/apply/schoolUnionAudit/index.html index 858b93d..57cc6f8 100644 --- a/src/main/resources/views/platform/member/apply/schoolUnionAudit/index.html +++ b/src/main/resources/views/platform/member/apply/schoolUnionAudit/index.html @@ -35,12 +35,18 @@ layout("/layouts/platform.html"){ {{ row.allocationUnionName }} 未分配 + @@ -66,23 +72,6 @@ layout("/layouts/platform.html"){ - - - - - - - - - - - - - - - @@ -99,7 +88,7 @@ layout("/layouts/platform.html"){ 取消 - 退回申请 + 拒绝申请 同意申请 @@ -129,7 +118,7 @@ layout("/layouts/platform.html"){ { prop: "personType", label: "人员类型", sortable: true }, { prop: "unionName", label: "所属工会", sortable: true }, { prop: "unitName", label: "所属单位", sortable: true }, - { prop: "allocationUnionName", label: "分配工会", sortable: true }, + // { prop: "sign", label: "签字" }, { prop: "stateName", label: "当前节点", sortable: true } ], @@ -166,11 +155,6 @@ layout("/layouts/platform.html"){ }) }, doApproval(approvalType){ - if (approvalType === 1 && !this.formData.unionId) { - this.$message.warning('请分配工会关系') - return - } - let msg = '确定要通过此条申请吗?' if (approvalType === 0) { msg = '拒绝后不可撤回,确定要拒绝此条申请吗?' diff --git a/src/main/resources/views/platform/member/apply/submit/index.html b/src/main/resources/views/platform/member/apply/submit/index.html index aed089d..f99b4b4 100644 --- a/src/main/resources/views/platform/member/apply/submit/index.html +++ b/src/main/resources/views/platform/member/apply/submit/index.html @@ -3,7 +3,7 @@ layout("/layouts/platform.html"){ #-->
-
入会申请
+
入会申请
提示:字段前带有 " * " 号的请务必填写 @@ -106,12 +106,12 @@ layout("/layouts/platform.html"){ - + - + @@ -171,6 +171,25 @@ layout("/layouts/platform.html"){ + + + + + 我自愿加入中华全国总工会,遵守工会章程,执行工会决议,积极参加工会活动,为全面建成小康社会、把我国建设成为富强民主文明和谐的社会主义现代化国家、实现中华民族伟大复兴的中国梦而奋斗。 + + + + + @@ -196,6 +215,15 @@ layout("/layouts/platform.html"){ formRules: { username: [{required: false, message: "必填", trigger: ["change", "blur"]}], sex: [{required: false, message: "必填", trigger: ["change", "blur"]}], + isVoluntary: [{required: true, message: "必填", trigger: ["change", "blur"]}], + sign: [{required: true, message: "必填", trigger: ["change", "blur"]}], + phone: [ + { + validator: (rule, value, callback) => { + }, + trigger: ["change", "blur"] + } + ], email: [ { validator: (rule, value, callback) => { @@ -280,6 +308,16 @@ layout("/layouts/platform.html"){ .catch() }, doSubmit() { + if (!this.formData.isVoluntary) { + this.$message.error("请勾选入会意愿") + return + } + + // if (!this.formData.sign) { + // this.$message.error("请使用手机钉钉扫描二维码签字") + // return + // } + this.$refs.formRef.validate((valid) => { if (valid) { this.$confirm("提交后将进入审核流程,无法再进行编辑,您确定要提交申请吗?", "提示", { type: "warning" }) @@ -320,6 +358,13 @@ layout("/layouts/platform.html"){ }, init(){ const user = JSON.parse(window.sessionStorage.getItem('user')) + if (user.member) { + this.$message.warning({ + duration: 10000, + showClose: true, + message: '您已加入会员,请勿重复申请' + }); + } this.member = user.member if (this.id) { $.post("/platform/member/apply/submit/findApplyById", { id: this.id }).then((res) => { diff --git a/src/main/resources/views/platform/member/change/branchUnionAudit/index.html b/src/main/resources/views/platform/member/change/branchUnionAudit/index.html index 1b11b77..c5d097c 100644 --- a/src/main/resources/views/platform/member/change/branchUnionAudit/index.html +++ b/src/main/resources/views/platform/member/change/branchUnionAudit/index.html @@ -12,21 +12,17 @@ layout("/layouts/platform.html"){ - - - + + - { + const ids = this.multipleSelection.map((v) => v.id) + const resp = await $.post('/platform/member/change/branchUnion/audit/doBatchApproval', { + data: JSON.stringify(ids) + }) + if (resp.code === 0) { + this.$message.success(resp.msg) + this.pageData() + } else { + this.$message.error(resp.msg) + } + }) + }, openView(row){ this.$refs.guava.view() this.$nextTick(() => { @@ -232,33 +251,6 @@ layout("/layouts/platform.html"){ .join(",") } return null - }, - openAllAudit(){ - if (this.multipleSelection.length === 0){ - this.$message.warning('请选择一条记录') - return - } - this.$confirm('确定要批量审批吗?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }).then(async () => { - const user = JSON.parse(window.sessionStorage.getItem('user')) - this.formData.username = user.username - this.formData.auditTime = moment().format('YYYY-MM-DD HH:mm:ss') - this.formData.auditType = 1 - const ids = this.multipleSelection.map((v) => v.id) - const resp = await $.post('/platform/member/change/branchUnion/audit/allApproval', { - audit: JSON.stringify(this.formData), - ids: JSON.stringify(ids) - }) - if (resp.code === 0) { - this.$message.success(resp.msg) - this.pageData() - } else { - this.$message.error(resp.msg) - } - }) } }, async created() { diff --git a/src/main/resources/views/platform/member/change/common/memberAllChangeInfo.js b/src/main/resources/views/platform/member/change/common/memberAllChangeInfo.js index fc4de9a..8c93676 100644 --- a/src/main/resources/views/platform/member/change/common/memberAllChangeInfo.js +++ b/src/main/resources/views/platform/member/change/common/memberAllChangeInfo.js @@ -26,7 +26,11 @@ const MEMBER_ALL_CHANGE_INFO = { {{ viewData.userState }} {{ viewData.personType }} - + + {{ viewData.schoolTime ? moment(viewData.schoolTime).format("YYYY-MM-DD") : '暂无' }} + {{ viewData.retireDate ? moment(viewData.retireDate).format("YYYY-MM-DD") : '暂无' }} + {{ viewData.leaveSchoolDate ? moment(viewData.leaveSchoolDate).format("YYYY-MM-DD") : '暂无' }} + {{ viewData.member ? '会员' : '非会员' }} {{ viewData.welfareMember ? '福利会员' : '非福利会员' }} diff --git a/src/main/resources/views/platform/member/change/common/memberChange.js b/src/main/resources/views/platform/member/change/common/memberChange.js index 185e279..11f1e58 100644 --- a/src/main/resources/views/platform/member/change/common/memberChange.js +++ b/src/main/resources/views/platform/member/change/common/memberChange.js @@ -66,44 +66,24 @@ const MEMBER_CHANGE = { :disabled="allowFields('position')" maxlength="50"> - - - + + + + + + + + + + + + + + - - + @@ -163,69 +131,68 @@ const MEMBER_CHANGE = { - - - - 福利会员 - 非福利会员 - + + + - - - - - - + + + + + + + + + + + + + + + @@ -366,13 +333,19 @@ const MEMBER_CHANGE = { }, trigger: ["change", "blur"] } - ] + ], + cardNum: [{ required: false, message: "请填写会员服务卡卡号", trigger: ["change", "blur"] }, + { pattern: /^\d{19}$/, message: "会员服务卡卡号必须为19位数字", trigger: ["change", "blur"] }] }, welfareProjectList: [] } }, methods: { + getUnionName(val){ + const data = this.units.find(v => v.id === val) + this.$set(this.formData, 'unionName', data ? data.unionname : '') + }, allowFields(prop) { return !this.allowChangeFields.map(v => v.code).includes(prop) }, @@ -411,7 +384,6 @@ const MEMBER_CHANGE = { this.user = JSON.parse(window.sessionStorage.getItem('user')) } this.getFormDataValue(this.id) - console.log(this.formData) this.allowChangeFields = await getDictOptions("ALLOW_CHANGE_FIELDS") if (this.$auth.hasRoleOr('sysadmin, SchoolUnionMemberAdmin, SchoolUnionAdmin')) { this.units = await getUnits() diff --git a/src/main/resources/views/platform/member/change/common/memberChangeAuditInfo.js b/src/main/resources/views/platform/member/change/common/memberChangeAuditInfo.js index 7cbbee8..d0acc76 100644 --- a/src/main/resources/views/platform/member/change/common/memberChangeAuditInfo.js +++ b/src/main/resources/views/platform/member/change/common/memberChangeAuditInfo.js @@ -26,13 +26,11 @@ const MEMBER_CHANGE_AUDIT_INFO = { {{ viewData.userState }} {{ viewData.personType }} - - - + + + {{ viewData.schoolTime ? moment(viewData.schoolTime).format("YYYY-MM-DD") : '暂无' }} + {{ viewData.retireDate ? moment(viewData.retireDate).format("YYYY-MM-DD") : '暂无' }} + {{ viewData.leaveSchoolDate ? moment(viewData.leaveSchoolDate).format("YYYY-MM-DD") : '暂无' }} {{ viewData.member ? '会员' : '非会员' }} {{ viewData.welfareMember ? '福利会员' : '非福利会员' }} @@ -114,7 +112,6 @@ const MEMBER_CHANGE_AUDIT_INFO = { }, methods: { async onOpen(id){ - this.activeName="basicInfo" const resp = await $.post('/platform/member/change/mine/findMemberChangeRecord', {id}) if (resp.code === 0) { this.viewData = resp.data diff --git a/src/main/resources/views/platform/member/change/manage/addUser.js b/src/main/resources/views/platform/member/change/manage/addUser.js new file mode 100644 index 0000000..ddfa5bd --- /dev/null +++ b/src/main/resources/views/platform/member/change/manage/addUser.js @@ -0,0 +1,236 @@ +const ADD_USER = { + template: /*language=HTML*/ ` +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 关 闭 + 提 交 + +
+ `, + data() { + return { + formData: {}, + units: [], + formRules: { + loginname: [{required: true, message: '请输入工号', trigger: ['blur', 'change']}], + username: [{required: true, message: '请输入姓名', trigger: ['blur', 'change']}], + sex: [{required: true, message: '请输入性别', trigger: ['blur', 'change']}], + userState: [{required: true, message: '请选择在职状态', trigger: ['blur', 'change']}], + personType: [{required: true, message: '请选择人员类型', trigger: ['blur', 'change']}], + unitid: [{required: true, message: '请选择工作单位', trigger: ['blur', 'change']}], + email: [ + { + validator: (rule, value, callback) => { + if (!value) { + callback(); + } else if (/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value)) { + callback(); + } else { + callback(new Error("邮箱格式错误")); + } + }, + trigger: ["change", "blur"] + } + ], + idCard: [ + { + validator: (rule, value, callback) => { + if (!value) { + // 如果值为空,直接通过校验 + callback(); + } else if (/^[1-9]\d{5}(18|19|20)?\d{2}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}(\d|[Xx])$/.test(value)) { + // 18位身份证号码格式正确 + callback(); + } else if (/^[1-9]\d{7}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) { + // 15位身份证号码格式正确 + callback(); + } else if (/^[1-9]\d{5}(18|19|20)?\d{2}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) { + // 外国人身份证号码格式正确(18位) + callback(); + } else if (/^[1-9]\d{7}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) { + // 外国人身份证号码格式正确(15位) + callback(); + } else { + // 格式错误,返回错误信息 + callback(new Error("身份证号码格式错误")); + } + }, + trigger: ["change", "blur"] + } + ], + mobile: [ + { + validator: (rule, value, callback) => { + if (!value) { + // 如果值为空,直接通过校验 + callback(); + } else if (/^[1][345789][0-9]{9}$/.test(value)) { + // 手机号格式正确 + callback(); + } else if (/^\d+-\d+$/.test(value) && value.length <= 16) { + // 座机号格式正确 + callback(); + } else { + // 格式错误,返回错误信息 + callback(new Error(value.includes('-') ? '座机号码格式错误' : '手机号码格式错误')); + } + }, + trigger: ["change", "blur"] + } + ], + } + } + }, + methods: { + getUnionName(val){ + const data = this.units.find(v => v.id === val) + this.$set(this.formData, 'unionName', data ? data.unionname : '') + }, + doSubmit() { + this.$refs.formRef.validate((valid) => { + if (valid) { + // 确认要提交吗? + this.$confirm('请您确保人员信息准确无误,您确定要提交吗?', '提示', { + type: 'warning' + }).then(() => { + this.$emit('do-submit', this.formData) + }) + } + }); + }, + // 校验工号是否存在 + async validLoginName(){ + const resp = await $.post('/platform/member/change/mange/validLoginName', {loginName: this.formData.loginname}) + if (resp.code === 0) { + if (resp.data > 0) { + this.$message.warning('该工号已存在,请重新输入') + this.$set(this.formData, 'loginname', '') + } + } else { + this.$message.warning('操作失败') + this.$set(this.formData, 'loginname', '') + } + }, + } +} diff --git a/src/main/resources/views/platform/member/change/manage/index.html b/src/main/resources/views/platform/member/change/manage/index.html index 693aced..682deba 100644 --- a/src/main/resources/views/platform/member/change/manage/index.html +++ b/src/main/resources/views/platform/member/change/manage/index.html @@ -87,16 +87,16 @@ layout("/layouts/platform.html"){
-
-
人员类型:
+
变更类型:
@@ -194,17 +194,17 @@ layout("/layouts/platform.html"){ --> - - - - - - - - - - - + + + + + + + + + + + + 添加非库内人员 @@ -524,13 +525,18 @@ layout("/layouts/platform.html"){ :loading="selectUserLoading">确定 - + + + + +
diff --git a/src/main/resources/views/platform/member/inquire/Integrate.html b/src/main/resources/views/platform/member/inquire/Integrate.html index bb7beb8..9982799 100644 --- a/src/main/resources/views/platform/member/inquire/Integrate.html +++ b/src/main/resources/views/platform/member/inquire/Integrate.html @@ -255,8 +255,29 @@ layout("/layouts/platform.html"){ - - + + + 查询时间: + + + + + 在职状态选择时,在职查询入会时间;离退休查询退休时间;离校查询离校时间;同时选择多个状态将同时查询三种时间 + + + + 系统角色: @@ -342,6 +363,15 @@ layout("/layouts/platform.html"){ @change="determineEndDate" placeholder="选择结束日期"> + + @@ -573,6 +603,10 @@ layout("/layouts/platform.html"){ startDate: '', endDate: '', memberType:2, + birthMonth: '', + commonDate: [], + commonStartDate: '', + commonEndDate: '', }, personTypeOptions: [], @@ -625,6 +659,16 @@ layout("/layouts/platform.html"){ 'user-cnd': httpVueLoader('/components/plugins/UserCnd.vue'), }, methods: { + doSetCommonDate(val){ + if(val && ['在职','离退休','离校'].some(item => this.pageForm.userStates.includes(item))){ + this.pageForm.commonStartDate = val[0] + this.pageForm.commonEndDate = val[1] + } else { + this.pageForm.commonStartDate = '' + this.pageForm.commonEndDate = '' + } + this.doSearch() + }, async allIsWelfareMember() { this.welfareTitle = "提醒:您将【" + this.pageForm.totalCount + "】位会员设置为福利会员" this.addWelfareDialogVisible = true @@ -669,6 +713,7 @@ layout("/layouts/platform.html"){ const preparedBys = JSON.stringify(this.pageForm.preparedBys) window.location.href = loc() + "/doExport?unionId=" + this.pageForm.unionId + "&unitId=" + this.pageForm.unitId + "&year=" + this.pageForm.year + + "&birthMonth=" + this.pageForm.birthMonth + "&memberStatus=" + memberStatus + "&personTypes=" + personTypes + "&userStates=" + userStates @@ -695,7 +740,10 @@ layout("/layouts/platform.html"){ const { startDate, endDate, + birthMonth, campus, + commonStartDate, + commonEndDate, memberType, reverseSelection, memberSearchName, @@ -705,8 +753,9 @@ layout("/layouts/platform.html"){ window.location.href = loc() + "/doExportByUnion?=searchName=" + this.pageForm.searchName + "&searchKeyword=" + this.pageForm.searchKeyword + "&unitId=" + unitId + "&unionId=" + unionId + "&unionGroupId=" + unionGroupId + "&threeUnitId=" + threeUnitId + "&sexTypes=" + sexTypes + "&memberType=" + memberType - + "&roleIds=" + roleIds + "&age=" + age + "&year=" + this.pageForm.year + "&memberStatus=" + memberStatus - + "&startDate=" + (startDate ? this.getDate(startDate) : '') + "&endDate=" + (endDate ? this.getDate(endDate) : '') + "&campus=" + (campus ? campus : '') + + "&roleIds=" + roleIds + "&age=" + age + "&year=" + this.pageForm.year + "&memberStatus=" + memberStatus + "&birthMonth=" + birthMonth + + "&startDate=" + (startDate ? this.getDate(startDate) : '') + "&endDate=" + (endDate ? this.getDate(endDate) : '') + + "&campus=" + (campus ? campus : '') + "&commonStartDate=" + commonStartDate + "&commonEndDate=" + commonEndDate + "&reverseSelection=" + (reverseSelection ? reverseSelection : '') + "&memberSearchName=" + (memberSearchName ? memberSearchName : '') + "&memberSearchKeyWord=" + (memberSearchKeyWord ? memberSearchKeyWord : '') + "&personTypes=" + personTypes + "&userStates=" + userStates + "&preparedBys=" + preparedBys + "&props=" + JSON.stringify(props) @@ -858,6 +907,10 @@ layout("/layouts/platform.html"){ this.pageForm.reverseSelection = false this.pageForm.startDate = '' this.pageForm.endDate = '' + this.pageForm.commonDate = '' + this.pageForm.commonStartDate = '' + this.pageForm.commonEndDate = '' + this.doSearch() }, tagClick(key, val) {