From c418e3761883b907b17bcdadb14953508ea65724 Mon Sep 17 00:00:00 2001 From: Paidax Date: Fri, 13 Dec 2024 09:37:20 +0800 Subject: [PATCH] commit --- .../v/nutz/base/config/ThreadPoolConfig.java | 125 ++ .../v/nutz/base/utils/ManyAddOrRenewUtil.java | 82 + .../platform/sys/SysUnitMangeController.java | 3 +- .../service/UserPatUpService.java | 2 + .../service/impl/UserPartUpServiceImpl.java | 39 + .../ext/beetl/BeetlCustomResourceLoader.java | 78 + .../basic/ActivityBasicScopeController.java | 2 +- .../nutz/zhgh/data/constant/HMCFieldCode.java | 10 +- .../v/nutz/zhgh/data/constant/SourceData.java | 18 +- .../service/impl/SourceUserServiceImpl.java | 68 +- .../FundsReimbursementViewController.java | 2 +- .../MemberInquireIntegrateController.java | 53 - .../vuex-persistedstate.umd.js | 172 +++ .../assets/platform/plugins/vuex/vuex.js | 1334 +++++++++++++++++ .../resources/views/layouts/platform.html | 2 - .../platform/member/inquire/Integrate.html | 137 +- .../views/platform/sys/dict/index.html | 60 +- .../views/platform/sys/home/appModule.js | 18 +- .../views/platform/sys/home/test.html | 60 - .../views/platform/sys/menu/index.html | 8 +- 20 files changed, 2043 insertions(+), 230 deletions(-) create mode 100644 src/main/java/io/v/nutz/base/config/ThreadPoolConfig.java create mode 100644 src/main/java/io/v/nutz/base/utils/ManyAddOrRenewUtil.java create mode 100644 src/main/java/io/v/nutz/web/commons/ext/beetl/BeetlCustomResourceLoader.java create mode 100644 src/main/resources/static/assets/platform/plugins/vuex-persistedstate/vuex-persistedstate.umd.js create mode 100644 src/main/resources/static/assets/platform/plugins/vuex/vuex.js delete mode 100644 src/main/resources/views/platform/sys/home/test.html diff --git a/src/main/java/io/v/nutz/base/config/ThreadPoolConfig.java b/src/main/java/io/v/nutz/base/config/ThreadPoolConfig.java new file mode 100644 index 0000000..80c3e26 --- /dev/null +++ b/src/main/java/io/v/nutz/base/config/ThreadPoolConfig.java @@ -0,0 +1,125 @@ +package io.v.nutz.base.config; + +import lombok.extern.slf4j.Slf4j; +import org.nutz.dao.Dao; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.Lang; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; + +/** + * @version 1.0 + * @Author zzr + * @name:ThreadPoolConfig + * @Date 2024/12/6 14:35 + * @注释 + */ +@Slf4j +@IocBean +public class ThreadPoolConfig { + + @Inject + private Dao dao; + + /** + * 核心线程数(默认线程数) + */ + private static final int CORE_POOL_SIZE = 2 * Runtime.getRuntime().availableProcessors() + 1; + + /** + * 最大线程数 + */ + private static final int MAX_POOL_SIZE = 128; + + /** + * 允许线程空闲时间(单位:默认为秒) + */ + private static final int KEEP_ALIVE_TIME = 5; + + /** + * 任务的等待时间 + */ + private static final int AWAIT_TERMINATION_TIME = 30; + + /** + * 缓冲队列数 + */ + private static final int QUEUE_CAPACITY = 1200; + + /** + * 线程池名前缀 + */ + private static final String THREAD_NAME_PREFIX = "dd3s-thread-pool"; + + /** + * bean的名称,默认为首字母小写的方法名 + * spring管理的线程池,顶级父类也是Executor + */ + @IocBean(name = "executorService") + public ThreadPoolTaskExecutor executorService() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(CORE_POOL_SIZE); + executor.setMaxPoolSize(MAX_POOL_SIZE); + executor.setQueueCapacity(QUEUE_CAPACITY); + executor.setKeepAliveSeconds(KEEP_ALIVE_TIME); + executor.setThreadNamePrefix(THREAD_NAME_PREFIX); + executor.setAwaitTerminationSeconds(AWAIT_TERMINATION_TIME); + executor.setWaitForTasksToCompleteOnShutdown(true); + + // 线程池对拒绝任务的处理策略 + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + executor.initialize(); + return executor; + } + + /** + * 异步执行 + * + * @param list 泛型list,任意实体类集合 + * @param batchSize 期望单次操作的数量,默认200 + * @param mode insert插入 ; update更新 ; insertOrUpdate插入或更新 + * @param isFastInsertOrUpdateIgnoreNull mode为新增此值为true代表fastInsert;mode为修改时此值为true代表updateIgnoreNull + * @param + */ + public void asyncExecute(List list, Integer batchSize, String mode, boolean isFastInsertOrUpdateIgnoreNull) { + if (Lang.isEmpty(list)) { + return; + } + if (batchSize == null || batchSize <= 0) { + batchSize = 200; + } + for (int i = 0; i < list.size(); i += batchSize) { + final int end = Math.min(i + batchSize, list.size()); + List batch = list.subList(i, end); + executorService().execute(() -> { + try { + switch(mode) { + case "insert" -> { + if (isFastInsertOrUpdateIgnoreNull) { + dao.fastInsert(batch); + } else { + dao.insert(batch); + } + } + case "update" -> { + if (isFastInsertOrUpdateIgnoreNull) { + dao.updateIgnoreNull(batch); + } else { + dao.update(batch); + } + } + case "insertOrUpdate" -> dao.insertOrUpdate(batch); + } + } catch (Exception e) { + // 日志记录异常信息 + System.err.println("Error occurred while inserting batch: " + e.getMessage()); + e.printStackTrace(); + } + }); + } + } + +} diff --git a/src/main/java/io/v/nutz/base/utils/ManyAddOrRenewUtil.java b/src/main/java/io/v/nutz/base/utils/ManyAddOrRenewUtil.java new file mode 100644 index 0000000..4689e0c --- /dev/null +++ b/src/main/java/io/v/nutz/base/utils/ManyAddOrRenewUtil.java @@ -0,0 +1,82 @@ +package io.v.nutz.base.utils; + +import io.v.nutz.base.config.ThreadPoolConfig; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; + +import java.util.List; + +/** + * @version 1.0 + * @Author zzr + * @name:ManyAddOrRenewUtil + * @Date 2024/7/24 16:16 + * @注释 + */ +@IocBean +public class ManyAddOrRenewUtil { + + @Inject + private ThreadPoolConfig threadPoolConfig; + + + /** + * 批量快速插入,异步执行 + * + * @param list 泛型list,任意实体类集合 + * @param batchSize 期望单次操作的数量,默认200 + * @param + */ + public void asyncExecuteFastInsert(List list, Integer batchSize) { + threadPoolConfig.asyncExecute(list, batchSize, "insert", true); + } + + + /** + * 批量插入(非快速),异步执行 + * + * @param list 泛型list,任意实体类集合 + * @param batchSize 期望单次操作的数量,默认200 + * @param + */ + public void asyncExecuteInsert(List list, Integer batchSize) { + threadPoolConfig.asyncExecute(list, batchSize, "insert", true); + } + + + /** + * 批量修改(忽略空值),异步执行 + * + * @param list 泛型list,任意实体类集合 + * @param batchSize 期望单次操作的数量,默认200 + * @param + */ + public void asyncExecuteUpdateIgnoreNull(List list, Integer batchSize) { + threadPoolConfig.asyncExecute(list, batchSize, "update", true); + } + + + /** + * 批量修改(不忽略空值),异步执行 + * + * @param list 泛型list,任意实体类集合 + * @param batchSize 期望单次操作的数量,默认200 + * @param + */ + public void asyncExecuteUpdate(List list, Integer batchSize) { + threadPoolConfig.asyncExecute(list, batchSize, "update", false); + } + + + /** + * 新增或修改,异步执行 + * + * @param list 泛型list,任意实体类集合 + * @param batchSize 期望单次操作的数量,默认200 + * @param + */ + public void asyncExecuteInsertOrUpdate(List list, Integer batchSize) { + threadPoolConfig.asyncExecute(list, batchSize, "insertOrUpdate", false); + } + +} diff --git a/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysUnitMangeController.java b/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysUnitMangeController.java index 5873daa..ce2fd89 100644 --- a/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysUnitMangeController.java +++ b/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysUnitMangeController.java @@ -110,6 +110,7 @@ public class SysUnitMangeController { public Object pageData(@Param(value = "parentId", required = false) String parentId, PageForm pageForm) { CndPlus cnd = CndPlus.create(); cnd.andEx("parentId", "=", parentId); + cnd.asc("location"); return sysUnitService.list(pageForm, cnd); } @@ -211,7 +212,7 @@ public class SysUnitMangeController { private AsyncService asyncService; private List child(String parentId) { - List units = sysUnitService.query(Cnd.where("parentId", "=", parentId)); + List units = sysUnitService.query(Cnd.where("parentId", "=", parentId).asc("location")); units.forEach(unit -> { unit.setChild(child(unit.getId())); diff --git a/src/main/java/io/v/nutz/web/commons/controller/userpartupdate/service/UserPatUpService.java b/src/main/java/io/v/nutz/web/commons/controller/userpartupdate/service/UserPatUpService.java index 72bd2c4..cfbe3f8 100644 --- a/src/main/java/io/v/nutz/web/commons/controller/userpartupdate/service/UserPatUpService.java +++ b/src/main/java/io/v/nutz/web/commons/controller/userpartupdate/service/UserPatUpService.java @@ -13,4 +13,6 @@ public interface UserPatUpService extends ViService { void largeDataInsert(List list); void renewUserState(); + + void deleteNotInSourceUser(); } diff --git a/src/main/java/io/v/nutz/web/commons/controller/userpartupdate/service/impl/UserPartUpServiceImpl.java b/src/main/java/io/v/nutz/web/commons/controller/userpartupdate/service/impl/UserPartUpServiceImpl.java index cd7b12b..5c28060 100644 --- a/src/main/java/io/v/nutz/web/commons/controller/userpartupdate/service/impl/UserPartUpServiceImpl.java +++ b/src/main/java/io/v/nutz/web/commons/controller/userpartupdate/service/impl/UserPartUpServiceImpl.java @@ -3,12 +3,18 @@ package io.v.nutz.web.commons.controller.userpartupdate.service.impl; import cn.hutool.core.collection.CollectionUtil; import io.v.nutz.base.service.impl.ViServiceImpl; import io.v.nutz.base.utils.DateUtil; +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.web.commons.controller.userpartupdate.models.UserPartUp; import io.v.nutz.web.commons.controller.userpartupdate.service.UserPatUpService; import io.v.nutz.sys.models.Sys_dict; import io.v.nutz.sys.services.SysDictService; +import io.v.nutz.zhgh.data.model.UserSource; import lombok.extern.slf4j.Slf4j; import org.nutz.aop.interceptor.ioc.TransAop; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; import org.nutz.dao.Dao; import org.nutz.dao.Sqls; import org.nutz.dao.impl.NutTxDao; @@ -17,6 +23,7 @@ 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 java.util.ArrayList; import java.util.List; @@ -143,4 +150,36 @@ public class UserPartUpServiceImpl extends ViServiceImpl implements sysDictService.clearCache(); } + + + @Override + @Aop(TransAop.READ_COMMITTED) + public void deleteNotInSourceUser() { + Sql maxPullTimeSql = Sqls.create("select pullTime from user_source GROUP BY pullTime ORDER BY pullTime desc LIMIT 1"); + maxPullTimeSql.setCallback(Sqls.callback.map()); + dao().execute(maxPullTimeSql); + NutMap map = (NutMap) maxPullTimeSql.getResult(); + + // 修改不在人事库的人员状态 + Sql querySql = Sqls.create("select id,loginname from sys_user where loginname not in (select loginname from user_source where pullTime = @pullTime) and loginname != 'superadmin'") + .setParam("pullTime", map.getString("pullTime")); + querySql.setCallback(Sqls.callback.maps()); + dao().execute(querySql); + List list = (List) querySql.getResult(); + + if (Lang.isEmpty(list)) { + return; + } + + List userIdList = list.stream().map(v -> v.getString("id")).toList(); + List userLoginNameList = list.stream().map(v -> v.getString("loginname")).toList(); + + // 修改不在人事库人员的状态 + dao().update(Sys_user.class, Chain.make("userState", "非人事库人员").add("personType", "非人事库人员") + .add("member", 0).add("welfareMember", 0), + Cnd.where("loginname", "in", userLoginNameList)); + + // 去除不在人事库的人员角色,只保留公共角色 + dao().clear(Sys_user_role.class, Cnd.where("userId", "in", userIdList).and("roleId", "!=", Roles.PUBLIC)); + } } diff --git a/src/main/java/io/v/nutz/web/commons/ext/beetl/BeetlCustomResourceLoader.java b/src/main/java/io/v/nutz/web/commons/ext/beetl/BeetlCustomResourceLoader.java new file mode 100644 index 0000000..2362589 --- /dev/null +++ b/src/main/java/io/v/nutz/web/commons/ext/beetl/BeetlCustomResourceLoader.java @@ -0,0 +1,78 @@ +package io.v.nutz.web.commons.ext.beetl; + +import org.beetl.core.Resource; +import org.beetl.core.misc.BeetlUtil; +import org.beetl.core.resource.ClasspathResource; +import org.beetl.core.resource.ClasspathResourceLoader; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class BeetlCustomResourceLoader extends ClasspathResourceLoader { + + public Resource getResource(String key) { + Resource resource = new ClasspathResource(key, this.getChildPath(super.getRoot(), key), this); + return resource; + } + + public String getResourceId(Resource resource, String id) { +// return resource == null ? id : BeetlUtil.getRelPath(resource.getId(), id); + return getRelPath(resource.getId(), id); + } + + /** + * 增加判断相对路径 + * 光见鬼 + */ + private String getRelPath(String siblings, String resourceId) { + // 参数校验 + if (resourceId == null || resourceId.isEmpty()) { + throw new RuntimeException("资源ID为空,参数错"); + } + + // 如果是绝对路径,直接返回(以 / 或 \ 开头) + if (resourceId.charAt(0) == '\\' || resourceId.charAt(0) == '/') { + if (BeetlUtil.isOutsideOfRoot(resourceId)) { + throw new RuntimeException("不能访问外部文件或者模板"); + } + return resourceId; + } + + // 处理相对路径 + String baseDir = siblings; + // 如果siblings是文件路径,获取其所在目录 + int lastSeparatorIndex = Math.max(siblings.lastIndexOf('/'), siblings.lastIndexOf('\\')); + if (lastSeparatorIndex > 0) { + baseDir = siblings.substring(0, lastSeparatorIndex + 1); + } + + // 分割路径 + String[] parts = resourceId.replace('\\', '/').split("/"); + List baseParts = new ArrayList<>( + Arrays.asList(baseDir.replace('\\', '/').split("/")) + ); + baseParts.removeIf(String::isEmpty); + + // 处理 ../ 和 ./ + for (String part : parts) { + if ("..".equals(part)) { + if (!baseParts.isEmpty()) { + baseParts.remove(baseParts.size() - 1); + } + } else if (!".".equals(part) && !part.isEmpty()) { + baseParts.add(part); + } + } + + // 组合最终路径 + String result = "/" + String.join("/", baseParts); + + // 检查是否访问外部文件 + if (BeetlUtil.isOutsideOfRoot(result)) { + throw new RuntimeException("不能访问外部文件或者模板"); + } + return result; + } + +} diff --git a/src/main/java/io/v/nutz/zhgh/activity/controller/basic/ActivityBasicScopeController.java b/src/main/java/io/v/nutz/zhgh/activity/controller/basic/ActivityBasicScopeController.java index e7fc981..ff4bc95 100644 --- a/src/main/java/io/v/nutz/zhgh/activity/controller/basic/ActivityBasicScopeController.java +++ b/src/main/java/io/v/nutz/zhgh/activity/controller/basic/ActivityBasicScopeController.java @@ -308,7 +308,7 @@ public class ActivityBasicScopeController { COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'sys_user' - AND TABLE_SCHEMA = 'zhgh_jiangnan' + AND TABLE_SCHEMA = 'zhgh_hmc' """); List sqlDataList = activityBasicScopeService.listMap(sql); // sqlDataList.forEach(v -> v.put("DATA_TYPE", new String((byte[]) v.get("DATA_TYPE")))); diff --git a/src/main/java/io/v/nutz/zhgh/data/constant/HMCFieldCode.java b/src/main/java/io/v/nutz/zhgh/data/constant/HMCFieldCode.java index d63b86a..835405e 100644 --- a/src/main/java/io/v/nutz/zhgh/data/constant/HMCFieldCode.java +++ b/src/main/java/io/v/nutz/zhgh/data/constant/HMCFieldCode.java @@ -62,10 +62,6 @@ public class HMCFieldCode { * 学位码 */ static Map ACADEMIC_DEGREE_CODE = new HashMap<>() {{ - put("260", "医学博士专业学位"); - put("270", "理学博士专业学位"); - put("390", "医学硕士专业学位"); - put("391", "理学硕士专业学位"); put("2", "博士"); put("201", "哲学博士学位"); put("202", "经济学博士学位"); @@ -80,9 +76,10 @@ public class HMCFieldCode { put("211", "军事学博士学位"); put("212", "管理学博士学位"); put("245", "临床医学博士专业学位"); - put("380", "农业硕士专业学位"); put("248", "兽医博士专业学位"); put("250", "口腔医学博士专业学位"); + put("260", "医学博士专业学位"); + put("270", "理学博士专业学位"); put("3", "硕士"); put("301", "哲学硕士学位"); put("302", "经济学硕士学位"); @@ -108,6 +105,9 @@ public class HMCFieldCode { put("350", "口腔医学硕士专业学位"); put("351", "公共卫生硕士专业学位"); put("352", "军事硕士专业学位"); + put("380", "农业硕士专业学位"); + put("390", "医学硕士专业学位"); + put("391", "理学硕士专业学位"); put("4", "学士"); put("401", "哲学学士学位"); put("402", "经济学学士学位"); 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 0452c00..aaf7cf7 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 @@ -27,7 +27,7 @@ import java.util.Map; * * @author 1V * @date 2021/3/4 - * @since 浙江财经 + * @since 杭州医学院 */ public interface SourceData { @@ -45,13 +45,11 @@ public interface SourceData { // Assert.isTrue(jsonResult.getBoolean("success"), jsonResult.getString("data")); } -/* *//** - * 在职状态码 - *//* - Map USER_STATE_CODE = new HashMap<>() {{ - put("100", "在职状态"); - put("200", "不在职状态"); - }};*/ + /** + * 不进系统人员 + */ + List NOT_ENTERING_USER = List.of("退休人员", "兼职教师", "非全日用工(项目临聘)", "服务外包和其他人员", + "教学编制2", "教学教师(附属医院)", "教学编制", "离休人员", "临时人员", "非全日制工", "博士后(在职)"); /** * 接口中的数据跟SourceUser的对应关系 @@ -116,6 +114,9 @@ public interface SourceData { // checkSuccess(map); List data = map.getAsList("data", NutMap.class); for (NutMap row : data) { + if (NOT_ENTERING_USER.contains(row.getString("RYFLMC"))) { + continue; + } Map entity = new HashMap(500); row.forEach((k, v) -> { @@ -148,6 +149,7 @@ public interface SourceData { put("DWH", new String[]{"id", "unitcode"}); put("DWMC", new String[]{"name"}); put("SJDWH", new String[]{"parentId"}); + put("PX", new String[]{"location"}); }}; /** diff --git a/src/main/java/io/v/nutz/zhgh/data/service/impl/SourceUserServiceImpl.java b/src/main/java/io/v/nutz/zhgh/data/service/impl/SourceUserServiceImpl.java index 3c3803a..8e83ed1 100644 --- a/src/main/java/io/v/nutz/zhgh/data/service/impl/SourceUserServiceImpl.java +++ b/src/main/java/io/v/nutz/zhgh/data/service/impl/SourceUserServiceImpl.java @@ -3,6 +3,7 @@ package io.v.nutz.zhgh.data.service.impl; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; +import io.v.nutz.base.utils.ManyAddOrRenewUtil; import io.v.nutz.base.utils.Roles; import io.v.nutz.sys.models.Sys_user_role; import io.v.nutz.sys.services.SysUserRoleService; @@ -59,22 +60,23 @@ public class SourceUserServiceImpl extends ViServiceImpl implements super(dao); } + // 是会员的人员类型 + private final List MEMBER_PERSON_TYPE = List.of("事业编制(员额)", "事业编制", "校聘编外", "同工同酬", "学校编制", "博士后(统招)"); + @Inject private AsyncService asyncService; - @Inject private SysUserService sysUserService; - @Inject private HistoryUserService historyUserService; - @Inject private UserPatUpService userPatUpService; @Inject private SysRoleService sysRoleService; - @Inject private SysUserRoleService sysUserRoleService; + @Inject + private ManyAddOrRenewUtil manyAddOrRenewUtil; @Override @Aop(TransAop.READ_COMMITTED) @@ -97,7 +99,7 @@ public class SourceUserServiceImpl extends ViServiceImpl implements List sources = new ArrayList<>(); - List histories = new ArrayList<>(); + List histories = new CopyOnWriteArrayList<>(); Map userPartMap = new HashMap<>(); if (Strings.isNotBlank(partGroupId)) { @@ -117,16 +119,20 @@ public class SourceUserServiceImpl extends ViServiceImpl implements AtomicReference filterColumnDao = new AtomicReference<>(dao()); - //全部更新时,要修改的用户表 - List needDoUpdateList = new ArrayList<>(); - //新增的用户 - List needInitUserList = new ArrayList<>(); - //添加角色的用户 - List userRoles = new ArrayList<>(); + // 全部更新时,要修改的用户表 + List needDoUpdateList = new CopyOnWriteArrayList<>(); + // 新增的用户 + List needInitUserList = new CopyOnWriteArrayList<>(); + // 添加角色的用户 + List userRoles = new CopyOnWriteArrayList<>(); + // 添加会员角色 + List addMemberUserIds = new CopyOnWriteArrayList<>(); + // 移除会员角色 + List deleteMemberUserIds = new CopyOnWriteArrayList<>(); // 创建一个固定大小的线程池 可以根据服务器性能调整线程池大小 int numberOfThreads = Runtime.getRuntime().availableProcessors() * 2; - List> futures = new ArrayList<>(); + List> futures = new CopyOnWriteArrayList<>(); // 每批处理的数据量,可以根据实际情况调整 int batchSize = 200; @@ -142,11 +148,25 @@ public class SourceUserServiceImpl extends ViServiceImpl implements source.setWelfareMember(null); Sys_user user = userMap.get(source.getLoginname().toLowerCase()); + if (MEMBER_PERSON_TYPE.contains(source.getPersonType()) && "在职".equals(source.getUserState())) { + source.setMember(1); + source.setWelfareMember(1); + if (Lang.isNotEmpty(user) && user.getMember() == 1) { + + } else { + addMemberUserIds.add(Lang.isNotEmpty(user) ? user.getId() : source.getId()); + } + } else { + source.setMember(0); + source.setWelfareMember(0); + deleteMemberUserIds.add(Lang.isNotEmpty(user) ? user.getId() : source.getId()); + } + Sys_user u = new Sys_user(); BeanUtils.copyProperties(source, u); switch (sourceType) { case "all" -> { - //复制属性到一个新的user对象 + // 复制属性到一个新的user对象 u.setId(user == null ? source.getId() : user.getId()); if (user != null) { needDoUpdateList.add(u); @@ -195,6 +215,22 @@ public class SourceUserServiceImpl extends ViServiceImpl implements sysUserRoleService.insert(userRoles); } + // 添加会员角色 + if (Lang.isNotEmpty(addMemberUserIds)) { + String memberRoleId = Roles.MEMBER; + List list = addMemberUserIds.stream().map(v -> { + Sys_user_role userRole = new Sys_user_role(); + userRole.setUserId(v); + userRole.setRoleId(memberRoleId); + return userRole; + }).toList(); + manyAddOrRenewUtil.asyncExecuteInsert(list, 200); + } + // 不是定义的personType的人员,去除会员角色 + if (Lang.isNotEmpty(deleteMemberUserIds)) { + dao().clear(Sys_user_role.class, Cnd.where("userId", "in", deleteMemberUserIds).and("roleId", "=", Roles.MEMBER)); + } + // Collection updateColumns = SourceData.USER_FIELD_RELATION.values(); if ("part".equals(sourceType)) { @@ -203,10 +239,12 @@ public class SourceUserServiceImpl extends ViServiceImpl implements massUpdatesAsync(needDoUpdateList, false, null); } - //历史记录表插入数据 + // 历史记录表插入数据 historyUserService.dao().fastInsert(histories); - //人员状态及在职状态更新 + // 人员状态及在职状态更新 userPatUpService.renewUserState(); + // 修改不在人事库的人员,删除角色 + userPatUpService.deleteNotInSourceUser(); //清除缓存 // sysUserService.clearCache(); // sysRoleService.clearCache(); diff --git a/src/main/java/io/v/nutz/zhgh/jf/controller/Funds/FundsReimbursementViewController.java b/src/main/java/io/v/nutz/zhgh/jf/controller/Funds/FundsReimbursementViewController.java index fa2d8a5..b116e2a 100644 --- a/src/main/java/io/v/nutz/zhgh/jf/controller/Funds/FundsReimbursementViewController.java +++ b/src/main/java/io/v/nutz/zhgh/jf/controller/Funds/FundsReimbursementViewController.java @@ -17,7 +17,7 @@ import org.nutz.mvc.annotation.Ok; public class FundsReimbursementViewController { @At("") - @Ok("beetl:/platform/jf/funds/fundsReimbursementview.html") + @Ok("beetl:/platform/jf/Funds/fundsReimbursementview.html") @RequiresPermissions("sys.jf.funds.reimbursementview") public void index() { } diff --git a/src/main/java/io/v/nutz/zhgh/member/controller/inquire/MemberInquireIntegrateController.java b/src/main/java/io/v/nutz/zhgh/member/controller/inquire/MemberInquireIntegrateController.java index 49a5c5a..f1f450a 100644 --- a/src/main/java/io/v/nutz/zhgh/member/controller/inquire/MemberInquireIntegrateController.java +++ b/src/main/java/io/v/nutz/zhgh/member/controller/inquire/MemberInquireIntegrateController.java @@ -455,59 +455,6 @@ public class MemberInquireIntegrateController { @Param(value = "memberSearchKeyWord", required = false) String memberSearchKeyWord, String props) { try { -// int yyyy = Calendar.getInstance().get(Calendar.YEAR); -// CndPlus cnd = CndPlus.create(); -// Sql sql = Sqls.create(""" -// SELECT -// *, -// unitname, -// unionname, -// unitcode, -// unioncode -// FROM -// $table -// $condition -// """); -// -// if (year == yyyy) { -// sql.setVar("table", "user"); -// } else { -// sql.setVar("table", "member_his"); -// cnd.andEX("year", "=", year); -// } -// -// cnd.and("member", "=", 1); -// if (ShiroUtil.hasAnyRoles("sysadmin,A06,H03")) { -// cnd.andEX("unionid", "=", unionId); -// } else { -// cnd.andEX("unionid", "=", Vi.getUnionId()); -// } -// cnd.andEX("unitid", "=", unitId); -// if (memberStatus != null) { -// if (Json.fromJsonAsArray(Integer.class, memberStatus).length > 0) { -// cnd.andEX("memberStatus", "in", Json.fromJsonAsArray(Integer.class, memberStatus)); -// } else { -// List status = new ArrayList<>(); -// status.add(MemberStatus.NORMAL.getCode()); -// status.add(MemberStatus.TURN_IN.getCode()); -// status.add(MemberStatus.RESTORE.getCode()); -// SqlExpressionGroup group = new SqlExpressionGroup(); -// group.and("memberStatus", "in", status); -// group.or("memberStatus", "IS", null); -// cnd.and(group); -// } -// } -// -// if (personTypes != null && Json.fromJsonAsArray(String.class, personTypes).length > 0) { -// cnd.andEX("personType", "in", Json.fromJsonAsArray(String.class, personTypes)); -// } -// if (userStates != null && Json.fromJsonAsArray(String.class, userStates).length > 0) { -// cnd.andEX("userState", "in", Json.fromJsonAsArray(String.class, userStates)); -// } -// cnd.asc("unitcode"); -// cnd.asc("unioncode"); -// cnd.asc("memberJoinTime"); -// sql.setCondition(cnd); int yyyy = Calendar.getInstance().get(Calendar.YEAR); Cnd cnd = MemberUtils.getCnd(null, startDate, endDate, unionId, unitId, personTypes, userStates, memberTypes, sexTypes, age, null, roleIds, null, null, memberStatus, threeUnitId, unionGroupId, reverseSelection, null, null, campus); diff --git a/src/main/resources/static/assets/platform/plugins/vuex-persistedstate/vuex-persistedstate.umd.js b/src/main/resources/static/assets/platform/plugins/vuex-persistedstate/vuex-persistedstate.umd.js new file mode 100644 index 0000000..806fe13 --- /dev/null +++ b/src/main/resources/static/assets/platform/plugins/vuex-persistedstate/vuex-persistedstate.umd.js @@ -0,0 +1,172 @@ +!(function (e, r) { + "object" == typeof exports && "undefined" != typeof module + ? (module.exports = r()) + : "function" == typeof define && define.amd + ? define(r) + : ((e || self).createPersistedState = r()) +})(this, function () { + var e = function (e) { + return ( + (function (e) { + return !!e && "object" == typeof e + })(e) && + !(function (e) { + var t = Object.prototype.toString.call(e) + return ( + "[object RegExp]" === t || + "[object Date]" === t || + (function (e) { + return e.$$typeof === r + })(e) + ) + })(e) + ) + }, + r = "function" == typeof Symbol && Symbol.for ? Symbol.for("react.element") : 60103 + function t(e, r) { + return !1 !== r.clone && r.isMergeableObject(e) ? u(Array.isArray(e) ? [] : {}, e, r) : e + } + function n(e, r, n) { + return e.concat(r).map(function (e) { + return t(e, n) + }) + } + function o(e) { + return Object.keys(e).concat( + (function (e) { + return Object.getOwnPropertySymbols + ? Object.getOwnPropertySymbols(e).filter(function (r) { + return e.propertyIsEnumerable(r) + }) + : [] + })(e) + ) + } + function c(e, r) { + try { + return r in e + } catch (e) { + return !1 + } + } + function u(r, i, a) { + ;((a = a || {}).arrayMerge = a.arrayMerge || n), (a.isMergeableObject = a.isMergeableObject || e), (a.cloneUnlessOtherwiseSpecified = t) + var f = Array.isArray(i) + return f === Array.isArray(r) + ? f + ? a.arrayMerge(r, i, a) + : (function (e, r, n) { + var i = {} + return ( + n.isMergeableObject(e) && + o(e).forEach(function (r) { + i[r] = t(e[r], n) + }), + o(r).forEach(function (o) { + ;(function (e, r) { + return c(e, r) && !(Object.hasOwnProperty.call(e, r) && Object.propertyIsEnumerable.call(e, r)) + })(e, o) || + (i[o] = + c(e, o) && n.isMergeableObject(r[o]) + ? (function (e, r) { + if (!r.customMerge) return u + var t = r.customMerge(e) + return "function" == typeof t ? t : u + })(o, n)(e[o], r[o], n) + : t(r[o], n)) + }), + i + ) + })(r, i, a) + : t(i, a) + } + u.all = function (e, r) { + if (!Array.isArray(e)) throw new Error("first argument should be an array") + return e.reduce(function (e, t) { + return u(e, t, r) + }, {}) + } + var i = u + return function (e) { + var r = (e = e || {}).storage || (window && window.localStorage), + t = e.key || "vuex" + function n(e, r) { + var t = r.getItem(e) + try { + return "string" == typeof t ? JSON.parse(t) : "object" == typeof t ? t : void 0 + } catch (e) {} + } + function o() { + return !0 + } + function c(e, r, t) { + return t.setItem(e, JSON.stringify(r)) + } + function u(e, r) { + return Array.isArray(r) + ? r.reduce(function (r, t) { + return (function (e, r, t, n) { + return ( + !/^(__proto__|constructor|prototype)$/.test(r) && + ((r = r.split ? r.split(".") : r.slice(0)).slice(0, -1).reduce(function (e, r) { + return (e[r] = e[r] || {}) + }, e)[r.pop()] = t), + e + ) + })( + r, + t, + ((n = e), + void 0 === + (n = ((o = t).split ? o.split(".") : o).reduce(function (e, r) { + return e && e[r] + }, n)) + ? void 0 + : n) + ) + var n, o + }, {}) + : e + } + function a(e) { + return function (r) { + return e.subscribe(r) + } + } + ;( + e.assertStorage || + function () { + r.setItem("@@", 1), r.removeItem("@@") + } + )(r) + var f, + s = function () { + return (e.getState || n)(t, r) + } + return ( + e.fetchBeforeUse && (f = s()), + function (n) { + e.fetchBeforeUse || (f = s()), + "object" == typeof f && + null !== f && + (n.replaceState( + e.overwrite + ? f + : i(n.state, f, { + arrayMerge: + e.arrayMerger || + function (e, r) { + return r + }, + clone: !1 + }) + ), + (e.rehydrated || function () {})(n)), + (e.subscriber || a)(n)(function (n, i) { + ;(e.filter || o)(n) && (e.setState || c)(t, (e.reducer || u)(i, e.paths), r) + }) + } + ) + } +}) +//# sourceMappingURL=vuex-persistedstate.umd.js.map diff --git a/src/main/resources/static/assets/platform/plugins/vuex/vuex.js b/src/main/resources/static/assets/platform/plugins/vuex/vuex.js new file mode 100644 index 0000000..fe3df8f --- /dev/null +++ b/src/main/resources/static/assets/platform/plugins/vuex/vuex.js @@ -0,0 +1,1334 @@ +/*! + * vuex v3.6.2 + * (c) 2021 Evan You + * @license MIT + */ +;(function (global, factory) { + typeof exports === "object" && typeof module !== "undefined" + ? (module.exports = factory()) + : typeof define === "function" && define.amd + ? define(factory) + : ((global = typeof globalThis !== "undefined" ? globalThis : global || self), (global.Vuex = factory())) +})(this, function () { + "use strict" + + function applyMixin(Vue) { + var version = Number(Vue.version.split(".")[0]) + + if (version >= 2) { + Vue.mixin({ beforeCreate: vuexInit }) + } else { + // override init and inject vuex init procedure + // for 1.x backwards compatibility. + var _init = Vue.prototype._init + Vue.prototype._init = function (options) { + if (options === void 0) options = {} + + options.init = options.init ? [vuexInit].concat(options.init) : vuexInit + _init.call(this, options) + } + } + + /** + * Vuex init hook, injected into each instances init hooks list. + */ + + function vuexInit() { + var options = this.$options + // store injection + if (options.store) { + this.$store = typeof options.store === "function" ? options.store() : options.store + } else if (options.parent && options.parent.$store) { + this.$store = options.parent.$store + } + } + } + + var target = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {} + var devtoolHook = target.__VUE_DEVTOOLS_GLOBAL_HOOK__ + + function devtoolPlugin(store) { + if (!devtoolHook) { + return + } + + store._devtoolHook = devtoolHook + + devtoolHook.emit("vuex:init", store) + + devtoolHook.on("vuex:travel-to-state", function (targetState) { + store.replaceState(targetState) + }) + + store.subscribe( + function (mutation, state) { + devtoolHook.emit("vuex:mutation", mutation, state) + }, + { prepend: true } + ) + + store.subscribeAction( + function (action, state) { + devtoolHook.emit("vuex:action", action, state) + }, + { prepend: true } + ) + } + + /** + * Get the first item that pass the test + * by second argument function + * + * @param {Array} list + * @param {Function} f + * @return {*} + */ + function find(list, f) { + return list.filter(f)[0] + } + + /** + * Deep copy the given object considering circular structure. + * This function caches all nested objects and its copies. + * If it detects circular structure, use cached copy to avoid infinite loop. + * + * @param {*} obj + * @param {Array} cache + * @return {*} + */ + function deepCopy(obj, cache) { + if (cache === void 0) cache = [] + + // just return if obj is immutable value + if (obj === null || typeof obj !== "object") { + return obj + } + + // if obj is hit, it is in circular structure + var hit = find(cache, function (c) { + return c.original === obj + }) + if (hit) { + return hit.copy + } + + var copy = Array.isArray(obj) ? [] : {} + // put the copy into cache at first + // because we want to refer it in recursive deepCopy + cache.push({ + original: obj, + copy: copy + }) + + Object.keys(obj).forEach(function (key) { + copy[key] = deepCopy(obj[key], cache) + }) + + return copy + } + + /** + * forEach for object + */ + function forEachValue(obj, fn) { + Object.keys(obj).forEach(function (key) { + return fn(obj[key], key) + }) + } + + function isObject(obj) { + return obj !== null && typeof obj === "object" + } + + function isPromise(val) { + return val && typeof val.then === "function" + } + + function assert(condition, msg) { + if (!condition) { + throw new Error("[vuex] " + msg) + } + } + + function partial(fn, arg) { + return function () { + return fn(arg) + } + } + + // Base data struct for store's module, package with some attribute and method + var Module = function Module(rawModule, runtime) { + this.runtime = runtime + // Store some children item + this._children = Object.create(null) + // Store the origin module object which passed by programmer + this._rawModule = rawModule + var rawState = rawModule.state + + // Store the origin module's state + this.state = (typeof rawState === "function" ? rawState() : rawState) || {} + } + + var prototypeAccessors = { namespaced: { configurable: true } } + + prototypeAccessors.namespaced.get = function () { + return !!this._rawModule.namespaced + } + + Module.prototype.addChild = function addChild(key, module) { + this._children[key] = module + } + + Module.prototype.removeChild = function removeChild(key) { + delete this._children[key] + } + + Module.prototype.getChild = function getChild(key) { + return this._children[key] + } + + Module.prototype.hasChild = function hasChild(key) { + return key in this._children + } + + Module.prototype.update = function update(rawModule) { + this._rawModule.namespaced = rawModule.namespaced + if (rawModule.actions) { + this._rawModule.actions = rawModule.actions + } + if (rawModule.mutations) { + this._rawModule.mutations = rawModule.mutations + } + if (rawModule.getters) { + this._rawModule.getters = rawModule.getters + } + } + + Module.prototype.forEachChild = function forEachChild(fn) { + forEachValue(this._children, fn) + } + + Module.prototype.forEachGetter = function forEachGetter(fn) { + if (this._rawModule.getters) { + forEachValue(this._rawModule.getters, fn) + } + } + + Module.prototype.forEachAction = function forEachAction(fn) { + if (this._rawModule.actions) { + forEachValue(this._rawModule.actions, fn) + } + } + + Module.prototype.forEachMutation = function forEachMutation(fn) { + if (this._rawModule.mutations) { + forEachValue(this._rawModule.mutations, fn) + } + } + + Object.defineProperties(Module.prototype, prototypeAccessors) + + var ModuleCollection = function ModuleCollection(rawRootModule) { + // register root module (Vuex.Store options) + this.register([], rawRootModule, false) + } + + ModuleCollection.prototype.get = function get(path) { + return path.reduce(function (module, key) { + return module.getChild(key) + }, this.root) + } + + ModuleCollection.prototype.getNamespace = function getNamespace(path) { + var module = this.root + return path.reduce(function (namespace, key) { + module = module.getChild(key) + return namespace + (module.namespaced ? key + "/" : "") + }, "") + } + + ModuleCollection.prototype.update = function update$1(rawRootModule) { + update([], this.root, rawRootModule) + } + + ModuleCollection.prototype.register = function register(path, rawModule, runtime) { + var this$1 = this + if (runtime === void 0) runtime = true + + { + assertRawModule(path, rawModule) + } + + var newModule = new Module(rawModule, runtime) + if (path.length === 0) { + this.root = newModule + } else { + var parent = this.get(path.slice(0, -1)) + parent.addChild(path[path.length - 1], newModule) + } + + // register nested modules + if (rawModule.modules) { + forEachValue(rawModule.modules, function (rawChildModule, key) { + this$1.register(path.concat(key), rawChildModule, runtime) + }) + } + } + + ModuleCollection.prototype.unregister = function unregister(path) { + var parent = this.get(path.slice(0, -1)) + var key = path[path.length - 1] + var child = parent.getChild(key) + + if (!child) { + { + console.warn("[vuex] trying to unregister module '" + key + "', which is " + "not registered") + } + return + } + + if (!child.runtime) { + return + } + + parent.removeChild(key) + } + + ModuleCollection.prototype.isRegistered = function isRegistered(path) { + var parent = this.get(path.slice(0, -1)) + var key = path[path.length - 1] + + if (parent) { + return parent.hasChild(key) + } + + return false + } + + function update(path, targetModule, newModule) { + { + assertRawModule(path, newModule) + } + + // update target module + targetModule.update(newModule) + + // update nested modules + if (newModule.modules) { + for (var key in newModule.modules) { + if (!targetModule.getChild(key)) { + { + console.warn("[vuex] trying to add a new module '" + key + "' on hot reloading, " + "manual reload is needed") + } + return + } + update(path.concat(key), targetModule.getChild(key), newModule.modules[key]) + } + } + } + + var functionAssert = { + assert: function (value) { + return typeof value === "function" + }, + expected: "function" + } + + var objectAssert = { + assert: function (value) { + return typeof value === "function" || (typeof value === "object" && typeof value.handler === "function") + }, + expected: 'function or object with "handler" function' + } + + var assertTypes = { + getters: functionAssert, + mutations: functionAssert, + actions: objectAssert + } + + function assertRawModule(path, rawModule) { + Object.keys(assertTypes).forEach(function (key) { + if (!rawModule[key]) { + return + } + + var assertOptions = assertTypes[key] + + forEachValue(rawModule[key], function (value, type) { + assert(assertOptions.assert(value), makeAssertionMessage(path, key, type, value, assertOptions.expected)) + }) + }) + } + + function makeAssertionMessage(path, key, type, value, expected) { + var buf = key + " should be " + expected + ' but "' + key + "." + type + '"' + if (path.length > 0) { + buf += ' in module "' + path.join(".") + '"' + } + buf += " is " + JSON.stringify(value) + "." + return buf + } + + var Vue // bind on install + + var Store = function Store(options) { + var this$1 = this + if (options === void 0) options = {} + + // Auto install if it is not done yet and `window` has `Vue`. + // To allow users to avoid auto-installation in some cases, + // this code should be placed here. See #731 + if (!Vue && typeof window !== "undefined" && window.Vue) { + install(window.Vue) + } + + { + assert(Vue, "must call Vue.use(Vuex) before creating a store instance.") + assert(typeof Promise !== "undefined", "vuex requires a Promise polyfill in this browser.") + assert(this instanceof Store, "store must be called with the new operator.") + } + + var plugins = options.plugins + if (plugins === void 0) plugins = [] + var strict = options.strict + if (strict === void 0) strict = false + + // store internal state + this._committing = false + this._actions = Object.create(null) + this._actionSubscribers = [] + this._mutations = Object.create(null) + this._wrappedGetters = Object.create(null) + this._modules = new ModuleCollection(options) + this._modulesNamespaceMap = Object.create(null) + this._subscribers = [] + this._watcherVM = new Vue() + this._makeLocalGettersCache = Object.create(null) + + // bind commit and dispatch to self + var store = this + var ref = this + var dispatch = ref.dispatch + var commit = ref.commit + this.dispatch = function boundDispatch(type, payload) { + return dispatch.call(store, type, payload) + } + this.commit = function boundCommit(type, payload, options) { + return commit.call(store, type, payload, options) + } + + // strict mode + this.strict = strict + + var state = this._modules.root.state + + // init root module. + // this also recursively registers all sub-modules + // and collects all module getters inside this._wrappedGetters + installModule(this, state, [], this._modules.root) + + // initialize the store vm, which is responsible for the reactivity + // (also registers _wrappedGetters as computed properties) + resetStoreVM(this, state) + + // apply plugins + plugins.forEach(function (plugin) { + return plugin(this$1) + }) + + var useDevtools = options.devtools !== undefined ? options.devtools : Vue.config.devtools + if (useDevtools) { + devtoolPlugin(this) + } + } + + var prototypeAccessors$1 = { state: { configurable: true } } + + prototypeAccessors$1.state.get = function () { + return this._vm._data.$$state + } + + prototypeAccessors$1.state.set = function (v) { + { + assert(false, "use store.replaceState() to explicit replace store state.") + } + } + + Store.prototype.commit = function commit(_type, _payload, _options) { + var this$1 = this + + // check object-style commit + var ref = unifyObjectStyle(_type, _payload, _options) + var type = ref.type + var payload = ref.payload + var options = ref.options + + var mutation = { type: type, payload: payload } + var entry = this._mutations[type] + if (!entry) { + { + console.error("[vuex] unknown mutation type: " + type) + } + return + } + this._withCommit(function () { + entry.forEach(function commitIterator(handler) { + handler(payload) + }) + }) + + this._subscribers + .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe + .forEach(function (sub) { + return sub(mutation, this$1.state) + }) + + if (options && options.silent) { + console.warn("[vuex] mutation type: " + type + ". Silent option has been removed. " + "Use the filter functionality in the vue-devtools") + } + } + + Store.prototype.dispatch = function dispatch(_type, _payload) { + var this$1 = this + + // check object-style dispatch + var ref = unifyObjectStyle(_type, _payload) + var type = ref.type + var payload = ref.payload + + var action = { type: type, payload: payload } + var entry = this._actions[type] + if (!entry) { + { + console.error("[vuex] unknown action type: " + type) + } + return + } + + try { + this._actionSubscribers + .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe + .filter(function (sub) { + return sub.before + }) + .forEach(function (sub) { + return sub.before(action, this$1.state) + }) + } catch (e) { + { + console.warn("[vuex] error in before action subscribers: ") + console.error(e) + } + } + + var result = + entry.length > 1 + ? Promise.all( + entry.map(function (handler) { + return handler(payload) + }) + ) + : entry[0](payload) + + return new Promise(function (resolve, reject) { + result.then( + function (res) { + try { + this$1._actionSubscribers + .filter(function (sub) { + return sub.after + }) + .forEach(function (sub) { + return sub.after(action, this$1.state) + }) + } catch (e) { + { + console.warn("[vuex] error in after action subscribers: ") + console.error(e) + } + } + resolve(res) + }, + function (error) { + try { + this$1._actionSubscribers + .filter(function (sub) { + return sub.error + }) + .forEach(function (sub) { + return sub.error(action, this$1.state, error) + }) + } catch (e) { + { + console.warn("[vuex] error in error action subscribers: ") + console.error(e) + } + } + reject(error) + } + ) + }) + } + + Store.prototype.subscribe = function subscribe(fn, options) { + return genericSubscribe(fn, this._subscribers, options) + } + + Store.prototype.subscribeAction = function subscribeAction(fn, options) { + var subs = typeof fn === "function" ? { before: fn } : fn + return genericSubscribe(subs, this._actionSubscribers, options) + } + + Store.prototype.watch = function watch(getter, cb, options) { + var this$1 = this + + { + assert(typeof getter === "function", "store.watch only accepts a function.") + } + return this._watcherVM.$watch( + function () { + return getter(this$1.state, this$1.getters) + }, + cb, + options + ) + } + + Store.prototype.replaceState = function replaceState(state) { + var this$1 = this + + this._withCommit(function () { + this$1._vm._data.$$state = state + }) + } + + Store.prototype.registerModule = function registerModule(path, rawModule, options) { + if (options === void 0) options = {} + + if (typeof path === "string") { + path = [path] + } + + { + assert(Array.isArray(path), "module path must be a string or an Array.") + assert(path.length > 0, "cannot register the root module by using registerModule.") + } + + this._modules.register(path, rawModule) + installModule(this, this.state, path, this._modules.get(path), options.preserveState) + // reset store to update getters... + resetStoreVM(this, this.state) + } + + Store.prototype.unregisterModule = function unregisterModule(path) { + var this$1 = this + + if (typeof path === "string") { + path = [path] + } + + { + assert(Array.isArray(path), "module path must be a string or an Array.") + } + + this._modules.unregister(path) + this._withCommit(function () { + var parentState = getNestedState(this$1.state, path.slice(0, -1)) + Vue.delete(parentState, path[path.length - 1]) + }) + resetStore(this) + } + + Store.prototype.hasModule = function hasModule(path) { + if (typeof path === "string") { + path = [path] + } + + { + assert(Array.isArray(path), "module path must be a string or an Array.") + } + + return this._modules.isRegistered(path) + } + + Store.prototype.hotUpdate = function hotUpdate(newOptions) { + this._modules.update(newOptions) + resetStore(this, true) + } + + Store.prototype._withCommit = function _withCommit(fn) { + var committing = this._committing + this._committing = true + fn() + this._committing = committing + } + + Object.defineProperties(Store.prototype, prototypeAccessors$1) + + function genericSubscribe(fn, subs, options) { + if (subs.indexOf(fn) < 0) { + options && options.prepend ? subs.unshift(fn) : subs.push(fn) + } + return function () { + var i = subs.indexOf(fn) + if (i > -1) { + subs.splice(i, 1) + } + } + } + + function resetStore(store, hot) { + store._actions = Object.create(null) + store._mutations = Object.create(null) + store._wrappedGetters = Object.create(null) + store._modulesNamespaceMap = Object.create(null) + var state = store.state + // init all modules + installModule(store, state, [], store._modules.root, true) + // reset vm + resetStoreVM(store, state, hot) + } + + function resetStoreVM(store, state, hot) { + var oldVm = store._vm + + // bind store public getters + store.getters = {} + // reset local getters cache + store._makeLocalGettersCache = Object.create(null) + var wrappedGetters = store._wrappedGetters + var computed = {} + forEachValue(wrappedGetters, function (fn, key) { + // use computed to leverage its lazy-caching mechanism + // direct inline function use will lead to closure preserving oldVm. + // using partial to return function with only arguments preserved in closure environment. + computed[key] = partial(fn, store) + Object.defineProperty(store.getters, key, { + get: function () { + return store._vm[key] + }, + enumerable: true // for local getters + }) + }) + + // use a Vue instance to store the state tree + // suppress warnings just in case the user has added + // some funky global mixins + var silent = Vue.config.silent + Vue.config.silent = true + store._vm = new Vue({ + data: { + $$state: state + }, + computed: computed + }) + Vue.config.silent = silent + + // enable strict mode for new vm + if (store.strict) { + enableStrictMode(store) + } + + if (oldVm) { + if (hot) { + // dispatch changes in all subscribed watchers + // to force getter re-evaluation for hot reloading. + store._withCommit(function () { + oldVm._data.$$state = null + }) + } + Vue.nextTick(function () { + return oldVm.$destroy() + }) + } + } + + function installModule(store, rootState, path, module, hot) { + var isRoot = !path.length + var namespace = store._modules.getNamespace(path) + + // register in namespace map + if (module.namespaced) { + if (store._modulesNamespaceMap[namespace] && true) { + console.error("[vuex] duplicate namespace " + namespace + " for the namespaced module " + path.join("/")) + } + store._modulesNamespaceMap[namespace] = module + } + + // set state + if (!isRoot && !hot) { + var parentState = getNestedState(rootState, path.slice(0, -1)) + var moduleName = path[path.length - 1] + store._withCommit(function () { + { + if (moduleName in parentState) { + console.warn( + '[vuex] state field "' + moduleName + '" was overridden by a module with the same name at "' + path.join(".") + '"' + ) + } + } + Vue.set(parentState, moduleName, module.state) + }) + } + + var local = (module.context = makeLocalContext(store, namespace, path)) + + module.forEachMutation(function (mutation, key) { + var namespacedType = namespace + key + registerMutation(store, namespacedType, mutation, local) + }) + + module.forEachAction(function (action, key) { + var type = action.root ? key : namespace + key + var handler = action.handler || action + registerAction(store, type, handler, local) + }) + + module.forEachGetter(function (getter, key) { + var namespacedType = namespace + key + registerGetter(store, namespacedType, getter, local) + }) + + module.forEachChild(function (child, key) { + installModule(store, rootState, path.concat(key), child, hot) + }) + } + + /** + * make localized dispatch, commit, getters and state + * if there is no namespace, just use root ones + */ + function makeLocalContext(store, namespace, path) { + var noNamespace = namespace === "" + + var local = { + dispatch: noNamespace + ? store.dispatch + : function (_type, _payload, _options) { + var args = unifyObjectStyle(_type, _payload, _options) + var payload = args.payload + var options = args.options + var type = args.type + + if (!options || !options.root) { + type = namespace + type + if (!store._actions[type]) { + console.error("[vuex] unknown local action type: " + args.type + ", global type: " + type) + return + } + } + + return store.dispatch(type, payload) + }, + + commit: noNamespace + ? store.commit + : function (_type, _payload, _options) { + var args = unifyObjectStyle(_type, _payload, _options) + var payload = args.payload + var options = args.options + var type = args.type + + if (!options || !options.root) { + type = namespace + type + if (!store._mutations[type]) { + console.error("[vuex] unknown local mutation type: " + args.type + ", global type: " + type) + return + } + } + + store.commit(type, payload, options) + } + } + + // getters and state object must be gotten lazily + // because they will be changed by vm update + Object.defineProperties(local, { + getters: { + get: noNamespace + ? function () { + return store.getters + } + : function () { + return makeLocalGetters(store, namespace) + } + }, + state: { + get: function () { + return getNestedState(store.state, path) + } + } + }) + + return local + } + + function makeLocalGetters(store, namespace) { + if (!store._makeLocalGettersCache[namespace]) { + var gettersProxy = {} + var splitPos = namespace.length + Object.keys(store.getters).forEach(function (type) { + // skip if the target getter is not match this namespace + if (type.slice(0, splitPos) !== namespace) { + return + } + + // extract local getter type + var localType = type.slice(splitPos) + + // Add a port to the getters proxy. + // Define as getter property because + // we do not want to evaluate the getters in this time. + Object.defineProperty(gettersProxy, localType, { + get: function () { + return store.getters[type] + }, + enumerable: true + }) + }) + store._makeLocalGettersCache[namespace] = gettersProxy + } + + return store._makeLocalGettersCache[namespace] + } + + function registerMutation(store, type, handler, local) { + var entry = store._mutations[type] || (store._mutations[type] = []) + entry.push(function wrappedMutationHandler(payload) { + handler.call(store, local.state, payload) + }) + } + + function registerAction(store, type, handler, local) { + var entry = store._actions[type] || (store._actions[type] = []) + entry.push(function wrappedActionHandler(payload) { + var res = handler.call( + store, + { + dispatch: local.dispatch, + commit: local.commit, + getters: local.getters, + state: local.state, + rootGetters: store.getters, + rootState: store.state + }, + payload + ) + if (!isPromise(res)) { + res = Promise.resolve(res) + } + if (store._devtoolHook) { + return res.catch(function (err) { + store._devtoolHook.emit("vuex:error", err) + throw err + }) + } else { + return res + } + }) + } + + function registerGetter(store, type, rawGetter, local) { + if (store._wrappedGetters[type]) { + { + console.error("[vuex] duplicate getter key: " + type) + } + return + } + store._wrappedGetters[type] = function wrappedGetter(store) { + return rawGetter( + local.state, // local state + local.getters, // local getters + store.state, // root state + store.getters // root getters + ) + } + } + + function enableStrictMode(store) { + store._vm.$watch( + function () { + return this._data.$$state + }, + function () { + { + assert(store._committing, "do not mutate vuex store state outside mutation handlers.") + } + }, + { deep: true, sync: true } + ) + } + + function getNestedState(state, path) { + return path.reduce(function (state, key) { + return state[key] + }, state) + } + + function unifyObjectStyle(type, payload, options) { + if (isObject(type) && type.type) { + options = payload + payload = type + type = type.type + } + + { + assert(typeof type === "string", "expects string as the type, but found " + typeof type + ".") + } + + return { type: type, payload: payload, options: options } + } + + function install(_Vue) { + if (Vue && _Vue === Vue) { + { + console.error("[vuex] already installed. Vue.use(Vuex) should be called only once.") + } + return + } + Vue = _Vue + applyMixin(Vue) + } + + /** + * Reduce the code which written in Vue.js for getting the state. + * @param {String} [namespace] - Module's namespace + * @param {Object|Array} states # Object's item can be a function which accept state and getters for param, you can do something for state and getters in it. + * @param {Object} + */ + var mapState = normalizeNamespace(function (namespace, states) { + var res = {} + if (!isValidMap(states)) { + console.error("[vuex] mapState: mapper parameter must be either an Array or an Object") + } + normalizeMap(states).forEach(function (ref) { + var key = ref.key + var val = ref.val + + res[key] = function mappedState() { + var state = this.$store.state + var getters = this.$store.getters + if (namespace) { + var module = getModuleByNamespace(this.$store, "mapState", namespace) + if (!module) { + return + } + state = module.context.state + getters = module.context.getters + } + return typeof val === "function" ? val.call(this, state, getters) : state[val] + } + // mark vuex getter for devtools + res[key].vuex = true + }) + return res + }) + + /** + * Reduce the code which written in Vue.js for committing the mutation + * @param {String} [namespace] - Module's namespace + * @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept another params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function. + * @return {Object} + */ + var mapMutations = normalizeNamespace(function (namespace, mutations) { + var res = {} + if (!isValidMap(mutations)) { + console.error("[vuex] mapMutations: mapper parameter must be either an Array or an Object") + } + normalizeMap(mutations).forEach(function (ref) { + var key = ref.key + var val = ref.val + + res[key] = function mappedMutation() { + var args = [], + len = arguments.length + while (len--) args[len] = arguments[len] + + // Get the commit method from store + var commit = this.$store.commit + if (namespace) { + var module = getModuleByNamespace(this.$store, "mapMutations", namespace) + if (!module) { + return + } + commit = module.context.commit + } + return typeof val === "function" ? val.apply(this, [commit].concat(args)) : commit.apply(this.$store, [val].concat(args)) + } + }) + return res + }) + + /** + * Reduce the code which written in Vue.js for getting the getters + * @param {String} [namespace] - Module's namespace + * @param {Object|Array} getters + * @return {Object} + */ + var mapGetters = normalizeNamespace(function (namespace, getters) { + var res = {} + if (!isValidMap(getters)) { + console.error("[vuex] mapGetters: mapper parameter must be either an Array or an Object") + } + normalizeMap(getters).forEach(function (ref) { + var key = ref.key + var val = ref.val + + // The namespace has been mutated by normalizeNamespace + val = namespace + val + res[key] = function mappedGetter() { + if (namespace && !getModuleByNamespace(this.$store, "mapGetters", namespace)) { + return + } + if (!(val in this.$store.getters)) { + console.error("[vuex] unknown getter: " + val) + return + } + return this.$store.getters[val] + } + // mark vuex getter for devtools + res[key].vuex = true + }) + return res + }) + + /** + * Reduce the code which written in Vue.js for dispatch the action + * @param {String} [namespace] - Module's namespace + * @param {Object|Array} actions # Object's item can be a function which accept `dispatch` function as the first param, it can accept anthor params. You can dispatch action and do any other things in this function. specially, You need to pass anthor params from the mapped function. + * @return {Object} + */ + var mapActions = normalizeNamespace(function (namespace, actions) { + var res = {} + if (!isValidMap(actions)) { + console.error("[vuex] mapActions: mapper parameter must be either an Array or an Object") + } + normalizeMap(actions).forEach(function (ref) { + var key = ref.key + var val = ref.val + + res[key] = function mappedAction() { + var args = [], + len = arguments.length + while (len--) args[len] = arguments[len] + + // get dispatch function from store + var dispatch = this.$store.dispatch + if (namespace) { + var module = getModuleByNamespace(this.$store, "mapActions", namespace) + if (!module) { + return + } + dispatch = module.context.dispatch + } + return typeof val === "function" ? val.apply(this, [dispatch].concat(args)) : dispatch.apply(this.$store, [val].concat(args)) + } + }) + return res + }) + + /** + * Rebinding namespace param for mapXXX function in special scoped, and return them by simple object + * @param {String} namespace + * @return {Object} + */ + var createNamespacedHelpers = function (namespace) { + return { + mapState: mapState.bind(null, namespace), + mapGetters: mapGetters.bind(null, namespace), + mapMutations: mapMutations.bind(null, namespace), + mapActions: mapActions.bind(null, namespace) + } + } + + /** + * Normalize the map + * normalizeMap([1, 2, 3]) => [ { key: 1, val: 1 }, { key: 2, val: 2 }, { key: 3, val: 3 } ] + * normalizeMap({a: 1, b: 2, c: 3}) => [ { key: 'a', val: 1 }, { key: 'b', val: 2 }, { key: 'c', val: 3 } ] + * @param {Array|Object} map + * @return {Object} + */ + function normalizeMap(map) { + if (!isValidMap(map)) { + return [] + } + return Array.isArray(map) + ? map.map(function (key) { + return { key: key, val: key } + }) + : Object.keys(map).map(function (key) { + return { key: key, val: map[key] } + }) + } + + /** + * Validate whether given map is valid or not + * @param {*} map + * @return {Boolean} + */ + function isValidMap(map) { + return Array.isArray(map) || isObject(map) + } + + /** + * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map. + * @param {Function} fn + * @return {Function} + */ + function normalizeNamespace(fn) { + return function (namespace, map) { + if (typeof namespace !== "string") { + map = namespace + namespace = "" + } else if (namespace.charAt(namespace.length - 1) !== "/") { + namespace += "/" + } + return fn(namespace, map) + } + } + + /** + * Search a special module from store by namespace. if module not exist, print error message. + * @param {Object} store + * @param {String} helper + * @param {String} namespace + * @return {Object} + */ + function getModuleByNamespace(store, helper, namespace) { + var module = store._modulesNamespaceMap[namespace] + if (!module) { + console.error("[vuex] module namespace not found in " + helper + "(): " + namespace) + } + return module + } + + // Credits: borrowed code from fcomb/redux-logger + + function createLogger(ref) { + if (ref === void 0) ref = {} + var collapsed = ref.collapsed + if (collapsed === void 0) collapsed = true + var filter = ref.filter + if (filter === void 0) + filter = function (mutation, stateBefore, stateAfter) { + return true + } + var transformer = ref.transformer + if (transformer === void 0) + transformer = function (state) { + return state + } + var mutationTransformer = ref.mutationTransformer + if (mutationTransformer === void 0) + mutationTransformer = function (mut) { + return mut + } + var actionFilter = ref.actionFilter + if (actionFilter === void 0) + actionFilter = function (action, state) { + return true + } + var actionTransformer = ref.actionTransformer + if (actionTransformer === void 0) + actionTransformer = function (act) { + return act + } + var logMutations = ref.logMutations + if (logMutations === void 0) logMutations = true + var logActions = ref.logActions + if (logActions === void 0) logActions = true + var logger = ref.logger + if (logger === void 0) logger = console + + return function (store) { + var prevState = deepCopy(store.state) + + if (typeof logger === "undefined") { + return + } + + if (logMutations) { + store.subscribe(function (mutation, state) { + var nextState = deepCopy(state) + + if (filter(mutation, prevState, nextState)) { + var formattedTime = getFormattedTime() + var formattedMutation = mutationTransformer(mutation) + var message = "mutation " + mutation.type + formattedTime + + startMessage(logger, message, collapsed) + logger.log("%c prev state", "color: #9E9E9E; font-weight: bold", transformer(prevState)) + logger.log("%c mutation", "color: #03A9F4; font-weight: bold", formattedMutation) + logger.log("%c next state", "color: #4CAF50; font-weight: bold", transformer(nextState)) + endMessage(logger) + } + + prevState = nextState + }) + } + + if (logActions) { + store.subscribeAction(function (action, state) { + if (actionFilter(action, state)) { + var formattedTime = getFormattedTime() + var formattedAction = actionTransformer(action) + var message = "action " + action.type + formattedTime + + startMessage(logger, message, collapsed) + logger.log("%c action", "color: #03A9F4; font-weight: bold", formattedAction) + endMessage(logger) + } + }) + } + } + } + + function startMessage(logger, message, collapsed) { + var startMessage = collapsed ? logger.groupCollapsed : logger.group + + // render + try { + startMessage.call(logger, message) + } catch (e) { + logger.log(message) + } + } + + function endMessage(logger) { + try { + logger.groupEnd() + } catch (e) { + logger.log("—— log end ——") + } + } + + function getFormattedTime() { + var time = new Date() + return ( + " @ " + pad(time.getHours(), 2) + ":" + pad(time.getMinutes(), 2) + ":" + pad(time.getSeconds(), 2) + "." + pad(time.getMilliseconds(), 3) + ) + } + + function repeat(str, times) { + return new Array(times + 1).join(str) + } + + function pad(num, maxLength) { + return repeat("0", maxLength - num.toString().length) + num + } + + var index_cjs = { + Store: Store, + install: install, + version: "3.6.2", + mapState: mapState, + mapMutations: mapMutations, + mapGetters: mapGetters, + mapActions: mapActions, + createNamespacedHelpers: createNamespacedHelpers, + createLogger: createLogger + } + + return index_cjs +}) diff --git a/src/main/resources/views/layouts/platform.html b/src/main/resources/views/layouts/platform.html index f5fb708..ba16777 100644 --- a/src/main/resources/views/layouts/platform.html +++ b/src/main/resources/views/layouts/platform.html @@ -336,7 +336,6 @@