From e39abeb283b5ceb725a825251b51ba23ca8d17c5 Mon Sep 17 00:00:00 2001 From: zhangzhiqiang Date: Tue, 6 Dec 2022 15:08:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0sso=E4=BB=A3=E7=A0=811?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CodeDetailServiceImpl.java | 2 +- .../service/impl/GenCodeServiceImpl.java | 2 +- .../service/impl/GridFieldServiceImpl.java | 2 +- .../system/service/impl/GridServiceImpl.java | 2 +- .../service/impl/MonitorServiceImpl.java | 2 +- .../system/service/impl/RedisServiceImpl.java | 2 +- .../rest/AuthorizationController.java | 7 - .../sso/system/service/CodeDetailService.java | 22 -- .../nl/sso/system/service/GenCodeService.java | 46 ----- .../sso/system/service/GridFieldService.java | 68 ------- .../nl/sso/system/service/GridService.java | 53 ----- .../nl/sso/system/service/MonitorService.java | 31 --- .../nl/sso/system/service/RedisService.java | 35 ---- .../service/impl/CodeDetailServiceImpl.java | 77 ------- .../service/impl/GenCodeServiceImpl.java | 180 ----------------- .../service/impl/GridFieldServiceImpl.java | 145 -------------- .../system/service/impl/GridServiceImpl.java | 114 ----------- .../service/impl/MonitorServiceImpl.java | 189 ------------------ .../system/service/impl/RedisServiceImpl.java | 83 -------- .../service/vo/RedisKeyDefineRespVO.java | 40 ---- .../system/service/vo/RedisMonitorRespVO.java | 47 ----- 21 files changed, 6 insertions(+), 1143 deletions(-) delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/CodeDetailService.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/GenCodeService.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/GridFieldService.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/GridService.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/MonitorService.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/RedisService.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/CodeDetailServiceImpl.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GenCodeServiceImpl.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GridFieldServiceImpl.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GridServiceImpl.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/MonitorServiceImpl.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/RedisServiceImpl.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/vo/RedisKeyDefineRespVO.java delete mode 100644 lms/nladmin-system/src/main/java/org/nl/sso/system/service/vo/RedisMonitorRespVO.java diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/CodeDetailServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/CodeDetailServiceImpl.java index 03cab5dff..c8c7bbf60 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/CodeDetailServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/CodeDetailServiceImpl.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Service; import java.util.Date; import java.util.Map; -//@Service +@Service @RequiredArgsConstructor @CacheConfig(cacheNames = "codeDetail") public class CodeDetailServiceImpl implements CodeDetailService { diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java index e5f6e4544..703863649 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GenCodeServiceImpl.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -//@Service +@Service @RequiredArgsConstructor @CacheConfig(cacheNames = "genCode") public class GenCodeServiceImpl implements GenCodeService { diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridFieldServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridFieldServiceImpl.java index 2ec828b09..820ab2ea3 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridFieldServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridFieldServiceImpl.java @@ -26,7 +26,7 @@ import java.util.Map; * @Description: 表格字段实现类 * @Date: 2022-08-01 */ -//@Service +@Service @RequiredArgsConstructor @Slf4j public class GridFieldServiceImpl implements GridFieldService { diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridServiceImpl.java index e02a158d5..e54ef2f92 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/GridServiceImpl.java @@ -24,7 +24,7 @@ import java.util.Map; * @Description: 表格服务实现类 * @Date: 2022-08-01 */ -//@Service +@Service @RequiredArgsConstructor @Slf4j public class GridServiceImpl implements GridService { diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/MonitorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/MonitorServiceImpl.java index c170fe223..3e7b55c34 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/MonitorServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/MonitorServiceImpl.java @@ -44,7 +44,7 @@ import java.util.Map; * @author Zheng Jie * @date 2020-05-02 */ -//@Service +@Service public class MonitorServiceImpl implements MonitorService { private final DecimalFormat df = new DecimalFormat("0.00"); diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/RedisServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/RedisServiceImpl.java index c7bcf2db0..b27f22ea1 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/RedisServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/system/service/impl/RedisServiceImpl.java @@ -22,7 +22,7 @@ import java.util.*; * @Description: Redis监控的实现类 * @Date: 2022-08-04 */ -//@Service +@Service @RequiredArgsConstructor @Slf4j public class RedisServiceImpl implements RedisService { diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/security/rest/AuthorizationController.java b/lms/nladmin-system/src/main/java/org/nl/sso/security/rest/AuthorizationController.java index 659d5cd43..7ab5ef4cb 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/security/rest/AuthorizationController.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/security/rest/AuthorizationController.java @@ -132,13 +132,6 @@ public class AuthorizationController { return ResponseEntity.ok(authInfo); } - private UserDto getById(Long user_id) { - WQLObject userTab = WQLObject.getWQLObject("sys_user"); - JSONObject user = userTab.query("user_id = '" + user_id + "'").uniqueResult(0); - UserDto userDto = user.toJavaObject(UserDto.class); - return userDto; - - } @ApiOperation("获取用户信息") @GetMapping(value = "/info") diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/CodeDetailService.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/CodeDetailService.java deleted file mode 100644 index dbf857e26..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/CodeDetailService.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.nl.sso.system.service; - -import com.alibaba.fastjson.JSONObject; -import org.springframework.data.domain.Pageable; - -import java.util.Map; - -public interface CodeDetailService { - /** - * 分页查询 - * @param form 条件 - * @param pageable 分页参数 - * @return / - */ - JSONObject queryAll(Map form, Pageable pageable); - - public void create(Map form); - - public void delete(String id); - - public void update(JSONObject json); -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GenCodeService.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GenCodeService.java deleted file mode 100644 index 00c66fd0c..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GenCodeService.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.nl.sso.system.service; - -import com.alibaba.fastjson.JSONObject; -import org.springframework.data.domain.Pageable; - -import java.util.Map; -import java.util.Set; - -public interface GenCodeService { - /** - * 分页查询 - * - * @param form 条件 - * @param pageable 分页参数 - * @return / - */ - JSONObject queryAll(Map form, Pageable pageable); - - /** - * 新增编码 - * @param form - */ - public void create(Map form); - - /** - * 删除编码 - * @param ids - */ - public void delete(Set ids); - - /** - * 更新编码 - * @param json - */ - public void update(JSONObject json); - - public String codeDemo(Map form); - - /** - * 根据编码获取id - * @param code - * @return - */ - public String queryIdByCode(String code); - -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GridFieldService.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GridFieldService.java deleted file mode 100644 index 365f53bb5..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GridFieldService.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.nl.sso.system.service; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import org.nl.modules.system.service.dto.GridFieldDto; -import org.springframework.data.domain.Pageable; - -import java.util.Map; - -/** - * @Author: lyd - * @Description: 表格字段服务 - * @Date: 2022-08-01 - */ -public interface GridFieldService { - /** - * 查询数据分页 - * @param whereJson 条件 - * @param page 分页参数 - * @return Map - */ - Map queryAll(Map whereJson, Pageable page); - - /** - * 创建 - * @param dto - */ - void create(GridFieldDto dto); - - /** - * 根据ID查询 - * @param id ID - * @return Param - */ - GridFieldDto findById(String id); - - /** - * 编辑 - * @param dto - */ - void update(GridFieldDto dto); - - /** - * 批量删除 - * @param ids - */ - void deleteAll(String[] ids); - - /** - * 批量添加数据 - * @param json - */ - void batchAdd(JSONObject json); - - /** - * 根据grid_id获取所有字段信息 - * @param id - * @return - */ - JSONArray getGridFieldsById(String id); - - /** - * 根据grid_code获取所有字段信息 - * @param grid_code - * @return - */ - JSONArray getGridFieldsByCode(String grid_code); -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GridService.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GridService.java deleted file mode 100644 index 74ae1c522..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/GridService.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.nl.sso.system.service; - -import com.alibaba.fastjson.JSONArray; -import org.nl.modules.system.service.dto.GridDto; -import org.springframework.data.domain.Pageable; - -import java.util.Map; - -/** - * @Author: lyd - * @Description: 表格服务接口 - * @Date: 2022-08-01 - */ -public interface GridService { - /** - * 查询数据分页 - * @param whereJson 条件 - * @param page 分页参数 - * @return Map - */ - Map queryAll(Map whereJson, Pageable page); - - /** - * 创建 - * @param dto - */ - void create(GridDto dto); - - /** - * 根据ID查询 - * @param id ID - * @return Param - */ - GridDto findById(String id); - - /** - * 编辑 - * @param dto - */ - void update(GridDto dto); - - /** - * 批量删除 - * @param ids - */ - void deleteAll(String[] ids); - - /** - * 下拉选择表格 - * @return - */ - JSONArray getGridList(); -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/MonitorService.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/MonitorService.java deleted file mode 100644 index e47e61a57..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/MonitorService.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nl.sso.system.service; - -import java.util.Map; - -/** - * @author Zheng Jie - * @date 2020-05-02 - */ -public interface MonitorService { - - /** - * 查询数据分页 - * @return Map - */ - Map getServers(); -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/RedisService.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/RedisService.java deleted file mode 100644 index fc2320452..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/RedisService.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nl.sso.system.service; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * @Author: lyd - * @Description: Redis监控的服务 - * @Date: 2022-08-04 - */ -public interface RedisService { - /** - * 获取redis的信息 - * @return - */ - JSONObject getRedisMonitorInfo(); - - /** - * 获得 Redis Key 模板列表 - * @return - */ - JSONObject getKeyDefineList(); - - /** - * 获取所有的键值信息 - * @return - */ - JSONArray getKeyValueList(); - - /** - * 删除redis缓存数据 - * @param ids - */ - void deleteByKey(String[] ids); -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/CodeDetailServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/CodeDetailServiceImpl.java deleted file mode 100644 index d53bff3f4..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/CodeDetailServiceImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.nl.sso.system.service.impl; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import org.nl.modules.system.service.CodeDetailService; -import org.nl.modules.wql.core.bean.ResultBean; -import org.nl.modules.wql.core.bean.WQLObject; -import org.nl.modules.wql.util.WqlUtil; -import org.nl.sso.tools.SecurityUtils; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.Map; - -@Service -@RequiredArgsConstructor -public class CodeDetailServiceImpl implements CodeDetailService { - @Override - public JSONObject queryAll(Map form, Pageable pageable) { - String where = "code_rule_id = '"+form.get("id")+"'"; - ResultBean rb = WQLObject.getWQLObject("sys_code_rule_detail").pagequery(WqlUtil.getHttpContext(pageable), where, "sort_num desc "); - final JSONObject json = rb.pageResult(); - return json; - } - - @Override - public void create(Map form) { - JSONObject json = new JSONObject(); - String id = IdUtil.simpleUUID(); - String now = DateUtil.now(); - json.put("id",id); - json.put("type",form.get("type")); - json.put("init_value",form.get("init_value")); - json.put("current_value",form.get("init_value")); - json.put("max_value",form.get("max_value")); - json.put("step",form.get("step")); - json.put("fillchar",form.get("fillchar")); - json.put("format",form.get("format")); - json.put("length",form.get("length")); - json.put("sort_num",form.get("sort_num")+""); - json.put("remark",form.get("remark")); - Map dict = (Map) form.get("dict"); - json.put("code_rule_id",dict.get("id")); - json.put("is_active","1"); - json.put("is_delete","0"); - - json.put("create_id", SecurityUtils.getCurrentUserId()); - json.put("create_name", SecurityUtils.getCurrentNickName()); - json.put("create_time", now); - if(form.get("type").equals("02")){ - Date date = DateUtil.date(); - String format = (String) form.get("format"); - String now_date = DateUtil.format(date, format); - json.put("init_value",now_date); - json.put("current_value",now_date); - } - WQLObject.getWQLObject("sys_code_rule_detail").insert(json); - } - - @Override - public void delete(String id) { - WQLObject.getWQLObject("sys_code_rule_detail").delete("id = '"+id+"'"); - } - - @Override - public void update(JSONObject json) { - String now = DateUtil.now(); - json.put("update_time",now); - json.put("update_optid", SecurityUtils.getCurrentUserId()); - json.put("update_optname", SecurityUtils.getCurrentNickName()); - WQLObject.getWQLObject("sys_code_rule_detail").update(json); - } -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GenCodeServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GenCodeServiceImpl.java deleted file mode 100644 index ffd1af43d..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GenCodeServiceImpl.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.nl.sso.system.service.impl; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import org.nl.modules.common.exception.BadRequestException; -import org.nl.sso.tools.SecurityUtils; -import org.nl.modules.system.service.GenCodeService; -import org.nl.modules.wql.core.bean.ResultBean; -import org.nl.modules.wql.core.bean.WQLObject; -import org.nl.modules.wql.util.WqlUtil; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -@Service -@RequiredArgsConstructor -public class GenCodeServiceImpl implements GenCodeService { - @Override - public JSONObject queryAll(Map form, Pageable pageable) { - String where = "1=1"; - if (form.get("blurry") != null) { - where = "code like '%" + (String) form.get("blurry") + "%' OR name = '%" + form.get("blurry") + "%'"; - } - ResultBean rb = WQLObject.getWQLObject("sys_code_rule").pagequery(WqlUtil.getHttpContext(pageable), where, "code desc "); - final JSONObject json = rb.pageResult(); - JSONArray ja = json.getJSONArray("content"); - JSONArray new_ja = new JSONArray(); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = ja.getJSONObject(i); - HashMap map = new HashMap(); - map.put("code", jo.getString("code")); - map.put("flag", "0"); - String demo = this.codeDemo(map); - jo.put("demo", demo); - new_ja.add(jo); - } - json.put("content", new_ja); - return json; - } - - @Override - public void create(Map form) { - Long currentUserId = SecurityUtils.getCurrentUserId(); - String currentUsername = SecurityUtils.getCurrentUsername(); - WQLObject wql = WQLObject.getWQLObject("sys_code_rule"); - JSONObject json = new JSONObject(); - String id = IdUtil.simpleUUID(); - String now = DateUtil.now(); - String code = (String) form.get("code"); - JSONObject jo = wql.query("code = '" + code + "'").uniqueResult(0); - if (jo != null){ - throw new BadRequestException("该编码code已存在,请校验!"); - } - json.put("id", id); - json.put("code", form.get("code")); - json.put("name", form.get("name")); - json.put("create_id", currentUserId); - json.put("update_optid", currentUserId); - json.put("create_name", currentUsername); - json.put("update_optname", currentUsername); - json.put("create_time", now); - json.put("update_time", now); - WQLObject.getWQLObject("sys_code_rule").insert(json); - } - - @Override - public void delete(Set ids) { - for (String code : ids) { - WQLObject.getWQLObject("sys_code_rule").delete("id = '" + code + "'"); - WQLObject.getWQLObject("sys_code_rule_detail").delete("code_rule_id = '" + code + "'"); - } - } - - @Override - public void update(JSONObject json) { - WQLObject wql = WQLObject.getWQLObject("sys_code_rule"); - String code = json.getString("code"); - String id = json.getString("id"); - JSONObject jo = wql.query("id <> '"+id+"' and code = '"+code+"'").uniqueResult(0); - if (jo != null){ - throw new BadRequestException("该编码code已存在,请校验!"); - } - String now = DateUtil.now(); - json.put("update_optid", SecurityUtils.getCurrentUserId()); - json.put("update_time", now); - json.put("update_optname", SecurityUtils.getCurrentUsername()); - WQLObject.getWQLObject("sys_code_rule").update(json); - } - - @Override - public synchronized String codeDemo(Map form) { - String code = (String) form.get("code"); - String id = this.queryIdByCode(code); - //如果flag=1就执行更新数据库的操作 - String flag = (String) form.get("flag"); - WQLObject wo = WQLObject.getWQLObject("sys_code_rule_detail"); - JSONArray ja = wo.query("code_rule_id = '" + id + "'", " sort_num").getResultJSONArray(0); - String demo = ""; - boolean is_same = true; - for (int i = 0; i < ja.size(); i++) { - String value = ""; - JSONObject jo = ja.getJSONObject(i); - //固定直接取值 - if (jo.getString("type").equals("01")) { - value = jo.getString("init_value"); - } - //日期判断数据库的值与当前值是否相同来决定顺序的值 - if (jo.getString("type").equals("02")) { - String current_value = jo.getString("current_value"); - Date date = DateUtil.date(); - String format = jo.getString("format"); - String now_date = DateUtil.format(date, format); - if (!now_date.equals(current_value)) { - is_same = false; - } - if (flag.equals("1")) { - jo.put("init_value", now_date); - jo.put("current_value", now_date); - } - value = now_date; - } - //顺序的值:如果日期一样就+步长,等于最大值就归为初始值;日期不一样就归为初始值 - if (jo.getString("type").equals("03")) { - String num_value = ""; - int step = jo.getInteger("step"); - Long max_value = jo.getLong("max_value"); - if (!is_same || (jo.getLongValue("current_value") + step > max_value)) { - num_value = jo.getString("init_value"); - } else { - num_value = (jo.getInteger("current_value") + step) + ""; - } - int size = num_value.length(); - int length = jo.getInteger("length"); - String fillchar = jo.getString("fillchar"); - for (int m = 0; m < (length - size); m++) { - value += fillchar; - } - value += num_value; - if (flag.equals("1")) { - if (!is_same) { - int init_value = jo.getInteger("init_value"); - if (StrUtil.isEmpty((init_value + ""))) { - throw new BadRequestException("请完善编码数值的初始值!"); - } - jo.put("current_value", init_value + ""); - } else { - int num_curr = jo.getInteger("current_value"); - if (num_curr >= max_value) { - num_curr = jo.getInteger("init_value"); - jo.put("current_value", num_curr + ""); - }else{ - jo.put("current_value", (num_curr + step) + ""); - } - } - } - } - demo += value; - if (flag.equals("1")) { - wo.update(jo,"id = '"+jo.getString("id")+"'"); - } - } - return demo; - } - - @Override - public String queryIdByCode(String code) { - JSONObject jo = WQLObject.getWQLObject("sys_code_rule").query("code = '" + code + "'").uniqueResult(0); - String id = jo.getString("id"); - return id; - } - -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GridFieldServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GridFieldServiceImpl.java deleted file mode 100644 index 20c27d054..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/GridFieldServiceImpl.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.nl.sso.system.service.impl; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.modules.common.exception.BadRequestException; -import org.nl.sso.tools.SecurityUtils; -import org.nl.modules.system.service.GridFieldService; -import org.nl.modules.system.service.dto.GridFieldDto; -import org.nl.modules.wql.WQL; -import org.nl.modules.wql.core.bean.WQLObject; -import org.nl.modules.wql.util.WqlUtil; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Author: lyd - * @Description: 表格字段实现类 - * @Date: 2022-08-01 - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class GridFieldServiceImpl implements GridFieldService { - - @Override - public Map queryAll(Map whereJson, Pageable page) { - HashMap map = new HashMap<>(); - String grid_name = (String) whereJson.get("name"); - map.put("flag","1"); - if (StrUtil.isNotEmpty(grid_name)){ - map.put("grid_name","%" + grid_name + "%"); - } - JSONObject json = WQL.getWO("GRIDFIELD").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "sys_grid_field.sort_num"); - return json; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void create(GridFieldDto dto) { - String currentUsername = SecurityUtils.getCurrentUsername(); - Long uid = SecurityUtils.getCurrentUserId(); - String now = DateUtil.now(); - - dto.setId(IdUtil.simpleUUID()); - dto.setCreate_id(uid.toString()); - dto.setUpdate_optid(uid.toString()); - dto.setCreate_name(currentUsername); - dto.setUpdate_optname(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("sys_grid_field"); - JSONObject json = JSONObject.parseObject( JSONObject.toJSONString(dto)); - wo.insert(json); - } - - @Override - public GridFieldDto findById(String id) { - WQLObject wo = WQLObject.getWQLObject("sys_grid_field"); - JSONObject json = wo.query("id ='" + id + "' AND is_delete = '0'").uniqueResult(0); - final GridFieldDto obj = json.toJavaObject(GridFieldDto.class);; - return obj; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(GridFieldDto dto) { - GridFieldDto entity = this.findById(dto.getId()); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_optid(SecurityUtils.getCurrentUserId().toString()); - dto.setUpdate_optname(currentUsername); - - WQLObject wo = WQLObject.getWQLObject("sys_grid_field"); - JSONObject json = JSONObject.parseObject( JSONObject.toJSONString(dto)); - wo.update(json); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteAll(String[] ids) { - WQLObject wo = WQLObject.getWQLObject("sys_grid_field"); - for (String id : ids) { -// GridFieldDto gridFieldDto = this.findById(id); -// gridFieldDto.setIs_delete("1"); -// JSONObject json = JSONObject.parseObject( JSONObject.toJSONString(gridFieldDto)); -// wo.update(json); - wo.delete("grid_id = '" + id + "'"); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void batchAdd(JSONObject json) { - String grid_id = json.getString("grid_id"); - JSONArray fieldDatas = json.getJSONArray("gridFieldData"); - WQLObject wo = WQLObject.getWQLObject("sys_grid_field"); - String currentUsername = SecurityUtils.getCurrentUsername(); - Long currentUserId = SecurityUtils.getCurrentUserId(); - // 先删除原先所有的数据 - wo.delete("grid_id = '" + grid_id + "'"); - // 然后添加 - for (int i=0; i queryAll(Map whereJson, Pageable page) { - WQLObject wo = WQLObject.getWQLObject("sys_grid"); - String where = "1=1"; - if (whereJson.get("name") != null) { - where = "name like ('%" + whereJson.get("name") + "%')"; - } - ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), where, "update_time desc"); - final JSONObject json = rb.pageResult(); - return json; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void create(GridDto dto) { - String currentUsername = SecurityUtils.getCurrentUsername(); - Long uid = SecurityUtils.getCurrentUserId(); - String now = DateUtil.now(); - - dto.setId(IdUtil.simpleUUID()); - dto.setCreate_id(uid.toString()); - dto.setUpdate_optid(uid.toString()); - dto.setCreate_name(currentUsername); - dto.setUpdate_optname(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("sys_grid"); - JSONObject json = JSONObject.parseObject( JSONObject.toJSONString(dto)); - wo.insert(json); - } - - @Override - public GridDto findById(String id) { - WQLObject wo = WQLObject.getWQLObject("sys_grid"); - JSONObject json = wo.query("id = '" + id + "'").uniqueResult(0); - final GridDto obj = json.toJavaObject(GridDto.class);; - return obj; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(GridDto dto) { - GridDto entity = this.findById(dto.getId()); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setUpdate_optid(SecurityUtils.getCurrentUserId().toString()); - dto.setUpdate_time(now); - dto.setUpdate_optname(currentUsername); - - WQLObject wo = WQLObject.getWQLObject("sys_grid"); - JSONObject json = JSONObject.parseObject( JSONObject.toJSONString(dto)); - wo.update(json); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteAll(String[] ids) { - WQLObject wo = WQLObject.getWQLObject("sys_grid"); - WQLObject wqlObject = WQLObject.getWQLObject("sys_grid_field"); - // 删除明细 - for (String grid_id : ids) { - wqlObject.delete("grid_id = '" + grid_id + "'"); - wo.delete("id = '" + grid_id + "'"); - } - } - - @Override - public JSONArray getGridList() { - JSONArray arr = WQLObject.getWQLObject("sys_grid").query().getResultJSONArray(0); - JSONArray result = new JSONArray(); - for (int i = 0; i < arr.size(); i++) { - JSONObject obj = arr.getJSONObject(i); - JSONObject json = new JSONObject(); - json.put("grid_id", obj.getString("id")); - json.put("grid_code", obj.getString("code")); - json.put("grid_name", obj.getString("name")); - result.add(json); - } - return result; - } -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/MonitorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/MonitorServiceImpl.java deleted file mode 100644 index d2b7a709d..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/MonitorServiceImpl.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nl.sso.system.service.impl; - -import cn.hutool.core.date.BetweenFormatter; -import cn.hutool.core.date.DateUtil; -import org.nl.modules.common.utils.ElAdminConstant; -import org.nl.modules.common.utils.FileUtil; -import org.nl.modules.common.utils.StringUtils; -import org.nl.modules.system.service.MonitorService; -import org.springframework.stereotype.Service; -import oshi.SystemInfo; -import oshi.hardware.CentralProcessor; -import oshi.hardware.GlobalMemory; -import oshi.hardware.HardwareAbstractionLayer; -import oshi.hardware.VirtualMemory; -import oshi.software.os.FileSystem; -import oshi.software.os.OSFileStore; -import oshi.software.os.OperatingSystem; -import oshi.util.FormatUtil; -import oshi.util.Util; - -import java.lang.management.ManagementFactory; -import java.text.DecimalFormat; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Zheng Jie - * @date 2020-05-02 - */ -@Service -public class MonitorServiceImpl implements MonitorService { - - private final DecimalFormat df = new DecimalFormat("0.00"); - - @Override - public Map getServers(){ - Map resultMap = new LinkedHashMap<>(8); - try { - SystemInfo si = new SystemInfo(); - OperatingSystem os = si.getOperatingSystem(); - HardwareAbstractionLayer hal = si.getHardware(); - // 系统信息 - resultMap.put("sys", getSystemInfo(os)); - // cpu 信息 - resultMap.put("cpu", getCpuInfo(hal.getProcessor())); - // 内存信息 - resultMap.put("memory", getMemoryInfo(hal.getMemory())); - // 交换区信息 - resultMap.put("swap", getSwapInfo(hal.getMemory())); - // 磁盘 - resultMap.put("disk", getDiskInfo(os)); - resultMap.put("time", DateUtil.format(new Date(), "HH:mm:ss")); - } catch (Exception e) { - e.printStackTrace(); - } - return resultMap; - } - - /** - * 获取磁盘信息 - * @return / - */ - private Map getDiskInfo(OperatingSystem os) { - Map diskInfo = new LinkedHashMap<>(); - FileSystem fileSystem = os.getFileSystem(); - List fsArray = fileSystem.getFileStores(); - String osName = System.getProperty("os.name"); - long available = 0, total = 0; - for (OSFileStore fs : fsArray){ - // windows 需要将所有磁盘分区累加,linux 和 mac 直接累加会出现磁盘重复的问题,待修复 - if(osName.toLowerCase().startsWith(ElAdminConstant.WIN)) { - available += fs.getUsableSpace(); - total += fs.getTotalSpace(); - } else { - available = fs.getUsableSpace(); - total = fs.getTotalSpace(); - break; - } - } - long used = total - available; - diskInfo.put("total", total > 0 ? FileUtil.getSize(total) : "?"); - diskInfo.put("available", FileUtil.getSize(available)); - diskInfo.put("used", FileUtil.getSize(used)); - diskInfo.put("usageRate", df.format(used/(double)total * 100)); - return diskInfo; - } - - /** - * 获取交换区信息 - * @param memory / - * @return / - */ - private Map getSwapInfo(GlobalMemory memory) { - Map swapInfo = new LinkedHashMap<>(); - VirtualMemory virtualMemory = memory.getVirtualMemory(); - long total = virtualMemory.getSwapTotal(); - long used = virtualMemory.getSwapUsed(); - swapInfo.put("total", FormatUtil.formatBytes(total)); - swapInfo.put("used", FormatUtil.formatBytes(used)); - swapInfo.put("available", FormatUtil.formatBytes(total - used)); - if(used == 0){ - swapInfo.put("usageRate", 0); - } else { - swapInfo.put("usageRate", df.format(used/(double)total * 100)); - } - return swapInfo; - } - - /** - * 获取内存信息 - * @param memory / - * @return / - */ - private Map getMemoryInfo(GlobalMemory memory) { - Map memoryInfo = new LinkedHashMap<>(); - memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal())); - memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable())); - memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable())); - memoryInfo.put("usageRate", df.format((memory.getTotal() - memory.getAvailable())/(double)memory.getTotal() * 100)); - return memoryInfo; - } - - /** - * 获取Cpu相关信息 - * @param processor / - * @return / - */ - private Map getCpuInfo(CentralProcessor processor) { - Map cpuInfo = new LinkedHashMap<>(); - cpuInfo.put("name", processor.getProcessorIdentifier().getName()); - cpuInfo.put("package", processor.getPhysicalPackageCount() + "个物理CPU"); - cpuInfo.put("core", processor.getPhysicalProcessorCount() + "个物理核心"); - cpuInfo.put("coreNumber", processor.getPhysicalProcessorCount()); - cpuInfo.put("logic", processor.getLogicalProcessorCount() + "个逻辑CPU"); - // CPU信息 - long[] prevTicks = processor.getSystemCpuLoadTicks(); - // 等待1秒... - Util.sleep(1000); - long[] ticks = processor.getSystemCpuLoadTicks(); - long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()]; - long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; - long sys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; - long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()]; - long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; - long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()]; - long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; - long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()]; - long totalCpu = user + nice + sys + idle + iowait + irq + softirq + steal; - cpuInfo.put("used", df.format(100d * user / totalCpu + 100d * sys / totalCpu)); - cpuInfo.put("idle", df.format(100d * idle / totalCpu)); - return cpuInfo; - } - - /** - * 获取系统相关信息,系统、运行天数、系统IP - * @param os / - * @return / - */ - private Map getSystemInfo(OperatingSystem os){ - Map systemInfo = new LinkedHashMap<>(); - // jvm 运行时间 - long time = ManagementFactory.getRuntimeMXBean().getStartTime(); - Date date = new Date(time); - // 计算项目运行时间 5.4.3:BetweenFormater, 5.7.14改名为BetweenFormatter - String formatBetween = DateUtil.formatBetween(date, new Date(), BetweenFormatter.Level.HOUR); - // 系统信息 - systemInfo.put("os", os.toString()); - systemInfo.put("day", formatBetween); - systemInfo.put("ip", StringUtils.getLocalIp()); - return systemInfo; - } -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/RedisServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/RedisServiceImpl.java deleted file mode 100644 index 8f41f57d9..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/RedisServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.nl.sso.system.service.impl; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.modules.system.service.RedisService; -import org.nl.modules.system.service.convert.RedisConvert; -import org.nl.sso.system.service.entity.RedisKeyDefine; -import org.nl.sso.system.service.entity.RedisKeyRegistry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.connection.DataType; -import org.springframework.data.redis.connection.RedisServerCommands; -import org.springframework.data.redis.core.RedisCallback; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Service; - -import java.util.*; - -/** - * @Author: lyd - * @Description: Redis监控的实现类 - * @Date: 2022-08-04 - */ -@Service -@RequiredArgsConstructor -@Slf4j -public class RedisServiceImpl implements RedisService { - - @Autowired - private StringRedisTemplate stringRedisTemplate; - - @Override - public JSONObject getRedisMonitorInfo() { - // 获得 Redis 统计信息 - Properties info = stringRedisTemplate.execute((RedisCallback) RedisServerCommands::info); - Long dbSize = stringRedisTemplate.execute(RedisServerCommands::dbSize); - Properties commandStats = stringRedisTemplate.execute(( - RedisCallback) connection -> connection.info("commandstats")); - assert commandStats != null; // 断言,避免警告 -// System.out.println("info:" + info + " dbsize:" + dbSize + " com:" + commandStats); - // 拼接结果返回 - // 转成实体 - JSONObject json = new JSONObject(); - json.put("info", RedisConvert.INSTANCE.build(info, dbSize, commandStats)); - return json; - } - - @Override - public JSONObject getKeyDefineList() { - List keyDefines = RedisKeyRegistry.list(); - JSONObject json = new JSONObject(); - System.out.println(keyDefines); -// json.put("info", RedisConvert.INSTANCE.convertList(keyDefines)); - return json; - } - - @Override - public JSONArray getKeyValueList() { - JSONArray result = new JSONArray(); - Set keys = stringRedisTemplate.keys("*"); - // 迭代 - Iterator it = keys.iterator(); - while ( it.hasNext() ) { - String key = it.next(); - JSONObject redis = new JSONObject(); - DataType dataType = stringRedisTemplate.type(key); // 数据类型 - String s = stringRedisTemplate.opsForValue().get(key); // 获取值 - Long expire = stringRedisTemplate.getExpire(key); // 获取剩余时间 - redis.put("dataType", dataType); - redis.put("key", key); - redis.put("value", s); - redis.put("expire", expire); - result.add(redis); - } - return result; - } - - @Override - public void deleteByKey(String[] ids) { - stringRedisTemplate.delete(Arrays.asList(ids)); - } -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/vo/RedisKeyDefineRespVO.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/vo/RedisKeyDefineRespVO.java deleted file mode 100644 index 16380c342..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/vo/RedisKeyDefineRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.nl.sso.system.service.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import org.nl.sso.system.service.entity.RedisKeyDefine; - - -import java.time.Duration; - -/** - * @Author: lyd - * @Description: 管理后台 - Redis Key 信息 Response VO - * @Date: 2022-08-04 - */ -@ApiModel("管理后台 - Redis Key 信息 Response VO") -@Data -@Builder -@AllArgsConstructor -public class RedisKeyDefineRespVO { - @ApiModelProperty(value = "Key 模板", required = true, example = "login_user:%s") - private String keyTemplate; - - @ApiModelProperty(value = "Key 类型的枚举", required = true, example = "String") - private RedisKeyDefine.KeyTypeEnum keyType; - - @ApiModelProperty(value = "Value 类型", required = true, example = "java.lang.String") - private Class valueType; - - @ApiModelProperty(value = "超时类型", required = true, example = "1") - private RedisKeyDefine.TimeoutTypeEnum timeoutType; - - @ApiModelProperty(value = "过期时间,单位:毫秒", required = true, example = "1024") - private Duration timeout; - - @ApiModelProperty(value = "备注", required = true, example = "啦啦啦啦~") - private String memo; -} diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/vo/RedisMonitorRespVO.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/vo/RedisMonitorRespVO.java deleted file mode 100644 index 654737983..000000000 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/vo/RedisMonitorRespVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.nl.sso.system.service.vo; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; - -import java.util.List; -import java.util.Properties; - -/** - * @Author: lyd - * @Description: 管理后台 - Redis 监控信息 Response VO - * @Date: 2022-08-04 - */ -@ApiModel("管理后台 - Redis 监控信息 Response VO") -@Data -@Builder -@AllArgsConstructor -public class RedisMonitorRespVO { - @ApiModelProperty(value = "Redis info 指令结果", required = true, notes = "具体字段,查看 Redis 文档") - private Properties info; - - @ApiModelProperty(value = "Redis key 数量", required = true, example = "1024") - private Long dbSize; - - @ApiModelProperty(value = "CommandStat 数组", required = true) - private List commandStats; - - @ApiModel("Redis 命令统计结果") - @Data - @Builder - @AllArgsConstructor - public static class CommandStat { - - @ApiModelProperty(value = "Redis 命令", required = true, example = "get") - private String command; - - @ApiModelProperty(value = "调用次数", required = true, example = "1024") - private Integer calls; - - @ApiModelProperty(value = "消耗 CPU 秒数", required = true, example = "666") - private Long usec; - - } -}