#
luxiaotao1123
2023-12-19 54c4b03976baced12fb81a62177f730f912c613a
#
9个文件已添加
2 文件已重命名
1个文件已删除
1个文件已修改
921 ■■■■■ 已修改文件
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/CodeRes.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/dto/PowerDto.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/entity/Parameter.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/enums/HtmlNavIconType.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/param/BaseParam.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/param/PageParam.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/properties/OSinfo.java 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/properties/SysOsType.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/properties/SystemProperties.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/HostController.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/utils/RandomValidateCodeUtil.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/web/AuthController.java 342 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/WmsBoot.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/CodeRes.java
New file
@@ -0,0 +1,15 @@
package com.zy.asrs.common.domain;
import com.zy.asrs.framework.common.BaseRes;
public interface CodeRes extends BaseRes {
    // user
    String USER_10001 = "10001-账号不存在";
    String USER_10002 = "10002-账号已被禁用";
    String USER_10003 = "10003-密码错误";
    String PICK_600 = "600-拣料任务";
    String NO_COMB_700 = "700-请先组托";
}
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/dto/PowerDto.java
New file
@@ -0,0 +1,17 @@
package com.zy.asrs.common.domain.dto;
import lombok.Data;
import java.util.List;
/**
 * Created by vincent on 2020-05-12
 */
@Data
public class PowerDto {
    private String two;
    private List<String> three;
}
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/entity/Parameter.java
New file
@@ -0,0 +1,66 @@
package com.zy.asrs.common.domain.entity;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.sys.entity.Config;
import com.zy.asrs.common.sys.service.ConfigService;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 基础配置中心。可通过刷新指定接口刷新相关配置
 */
@Data
public class Parameter {
    private volatile static Parameter instance = null;
    private Parameter(){
    }
    public static Parameter get(){
        if (instance == null){
            synchronized (Parameter.class){
                instance = reset();
                return instance;
            }
        }
        return instance;
    }
    /**
     * 重置
     */
    public static Parameter reset() {
        ConfigService configService = SpringUtils.getBean(ConfigService.class);
        List<Config> configs = configService.list(new LambdaQueryWrapper<Config>().eq(Config::getStatus, "1"));
        Map<String, Object> data = new HashMap<>();
        for (Config config : configs) {
            if (config.getType() == 1) {
                data.put(config.getCode(), String.valueOf(config.getValue()));
            } else {
                data.put(config.getCode(), JSON.parse(config.getValue()));
            }
        }
        instance = Cools.conver(data, Parameter.class);
        return instance;
    }
    // 验证码开关
    private String codeSwitch;
    // 库位初始化口令
    private String locMastInitPwd;
    // 打包下线
    private String packDown;
    // erp上报
    private String erpReport;
}
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/enums/HtmlNavIconType.java
New file
@@ -0,0 +1,51 @@
package com.zy.asrs.common.domain.enums;
public enum HtmlNavIconType {
    INDEX("index", "layui-icon-home"),
    SYSTEM("system", "layui-icon-component"),
    SET("set", "layui-icon-set"),
    MERCHANT("merchant", "layui-icon-user"),
    DEVELOP("develop", "layui-icon-util"),
    STOCK("stock", "layui-icon-templeate-1"),
    LOG_REPORT("logReport", "layui-icon-read"),
    IO_WORK("ioWork", "layui-icon-flag"),
    WORK_FLOW("workFlow", "layui-icon-form"),
    BASE("base", "layui-icon-file"),
    ORDER("erp", "layui-icon-senior"),
    SENSOR("sensor", "layui-icon-engine"),
    ;
    private String code;
    private String icon;
    HtmlNavIconType(String code, String icon){
        this.code = code;
        this.icon = icon;
    }
    public static String get(String code) {
        for (HtmlNavIconType type : HtmlNavIconType.values()){
            if (type.code.equals(code)){
                return type.icon;
            }
        }
        return "layui-icon-file-b";
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getIcon() {
        return icon;
    }
    public void setIcon(String icon) {
        this.icon = icon;
    }
}
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/param/BaseParam.java
File was renamed from zy-asrs-common/src/main/java/com/zy/asrs/common/domain/BaseParam.java
@@ -1,4 +1,4 @@
package com.zy.asrs.common.domain;
package com.zy.asrs.common.domain.param;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
zy-asrs-common/src/main/java/com/zy/asrs/common/domain/param/PageParam.java
File was renamed from zy-asrs-common/src/main/java/com/zy/asrs/common/domain/PageParam.java
@@ -1,4 +1,4 @@
package com.zy.asrs.common.domain;
package com.zy.asrs.common.domain.param;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
zy-asrs-common/src/main/java/com/zy/asrs/common/properties/OSinfo.java
New file
@@ -0,0 +1,134 @@
package com.zy.asrs.common.properties;
/**
 * Created by vincent on 2020/8/1
 */
public class OSinfo {
    private static final String OS = System.getProperty("os.name").toLowerCase();
    private static final OSinfo _instance = new OSinfo();
    private SysOsType sysOsType;
    private OSinfo(){}
    public static boolean isLinux(){
        return OS.contains("linux");
    }
    public static boolean isMacOS(){
        return OS.contains("mac") &&OS.indexOf("os")>0&& !OS.contains("x");
    }
    public static boolean isMacOSX(){
        return OS.contains("mac") &&OS.indexOf("os")>0&&OS.indexOf("x")>0;
    }
    public static boolean isWindows(){
        return OS.contains("windows");
    }
    public static boolean isOS2(){
        return OS.contains("os/2");
    }
    public static boolean isSolaris(){
        return OS.contains("solaris");
    }
    public static boolean isSunOS(){
        return OS.contains("sunos");
    }
    public static boolean isMPEiX(){
        return OS.contains("mpe/ix");
    }
    public static boolean isHPUX(){
        return OS.contains("hp-ux");
    }
    public static boolean isAix(){
        return OS.contains("aix");
    }
    public static boolean isOS390(){
        return OS.contains("os/390");
    }
    public static boolean isFreeBSD(){
        return OS.contains("freebsd");
    }
    public static boolean isIrix(){
        return OS.contains("irix");
    }
    public static boolean isDigitalUnix(){
        return OS.contains("digital") &&OS.indexOf("unix")>0;
    }
    public static boolean isNetWare(){
        return OS.contains("netware");
    }
    public static boolean isOSF1(){
        return OS.contains("osf1");
    }
    public static boolean isOpenVMS(){
        return OS.contains("openvms");
    }
    /**
     * 获取操作系统名字
     * @return 操作系统名
     */
    public static SysOsType getOSname(){
        if(isAix()){
            _instance.sysOsType = SysOsType.AIX;
        }else if (isDigitalUnix()) {
            _instance.sysOsType = SysOsType.Digital_Unix;
        }else if (isFreeBSD()) {
            _instance.sysOsType = SysOsType.FreeBSD;
        }else if (isHPUX()) {
            _instance.sysOsType = SysOsType.HP_UX;
        }else if (isIrix()) {
            _instance.sysOsType = SysOsType.Irix;
        }else if (isLinux()) {
            _instance.sysOsType = SysOsType.Linux;
        }else if (isMacOS()) {
            _instance.sysOsType = SysOsType.Mac_OS;
        }else if (isMacOSX()) {
            _instance.sysOsType = SysOsType.Mac_OS_X;
        }else if (isMPEiX()) {
            _instance.sysOsType = SysOsType.MPEiX;
        }else if (isNetWare()) {
            _instance.sysOsType = SysOsType.NetWare_411;
        }else if (isOpenVMS()) {
            _instance.sysOsType = SysOsType.OpenVMS;
        }else if (isOS2()) {
            _instance.sysOsType = SysOsType.OS2;
        }else if (isOS390()) {
            _instance.sysOsType = SysOsType.OS390;
        }else if (isOSF1()) {
            _instance.sysOsType = SysOsType.OSF1;
        }else if (isSolaris()) {
            _instance.sysOsType = SysOsType.Solaris;
        }else if (isSunOS()) {
            _instance.sysOsType = SysOsType.SunOS;
        }else if (isWindows()) {
            _instance.sysOsType = SysOsType.Windows;
        }else{
            _instance.sysOsType = SysOsType.Others;
        }
        return _instance.sysOsType;
    }
    public static void main(String[] args) {
        System.out.println(OSinfo.getOSname());// 获取系统类型
        System.out.println(OSinfo.isWindows());// 判断是否为windows系统
    }
}
zy-asrs-common/src/main/java/com/zy/asrs/common/properties/SysOsType.java
New file
@@ -0,0 +1,49 @@
package com.zy.asrs.common.properties;
public enum SysOsType {
    Any("any", null),
    Linux("Linux", null),
    Mac_OS("Mac OS", null),
    Mac_OS_X("Mac OS X", null),
    Windows("Windows", "D:\\licensed.txt"),
    OS2("OS/2", null),
    Solaris("Solaris", null),
    SunOS("SunOS", null),
    MPEiX("MPE/iX", null),
    HP_UX("HP-UX", null),
    AIX("AIX", null),
    OS390("OS/390", null),
    FreeBSD("FreeBSD", null),
    Irix("Irix", null),
    Digital_Unix("Digital Unix", null),
    NetWare_411("NetWare", null),
    OSF1("OSF1", null),
    OpenVMS("OpenVMS", null),
    Others("Others", null);
    private String description;
    private String activationCodePath;
    SysOsType(String desc, String activationCodePath) {
        this.description = desc;
        this.activationCodePath = activationCodePath;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getActivationCodePath() {
        return activationCodePath;
    }
    public void setActivationCodePath(String activationCodePath) {
        this.activationCodePath = activationCodePath;
    }
}
zy-asrs-common/src/main/java/com/zy/asrs/common/properties/SystemProperties.java
New file
@@ -0,0 +1,79 @@
package com.zy.asrs.common.properties;
import com.zy.asrs.framework.common.AesUtils;
import com.zy.asrs.framework.common.DateUtils;
import java.io.*;
import java.util.Date;
/**
 * Created by vincent on 2020/8/1
 */
public class SystemProperties {
    // 激活码加密盐 -- 16位
    public static final String SALT = "123456789qwertyu";
    // 系统激活状态 (默认未激活)
    public static boolean SYSTEM_ACTIVATION = Boolean.FALSE;
    public static String getActivationCode(String fileName){
        StringBuilder activationCode = new StringBuilder();
        try {
            FileReader f = new FileReader(fileName);
            BufferedReader buf = new BufferedReader(f);
            String s;
            while ((s = buf.readLine()) != null) {
                activationCode.append(s);
            }
            f.close();
            buf.close();
        } catch (FileNotFoundException ignore) {
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("读取WMS系统激活码失败!!!\n读取路径 " + fileName);
        }
        return activationCode.toString();
    }
    public static boolean saveActivationCode(String filePath, String code){
        try {
            // 防止文件建立或读取失败,用catch捕捉错误并打印,也可以throw
            File file = new File(filePath);// 相对路径,如果没有则要建立一个新的output。txt文件
            if (file.exists()) {
                file.delete();
            }
            boolean newFile = file.createNewFile();// 创建新文件
            if (newFile) {
                String sets = "attrib +H \"" + file.getAbsolutePath() + "\"";
                Runtime.getRuntime().exec(sets);
                BufferedWriter out = new BufferedWriter(new FileWriter(file, true));
                out.write(code); // \r\n即为换行
                out.flush(); // 把缓存区内容压入文件
                out.close(); // 最后记得关闭文件
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("写入WMS系统激活码失败!!!\n路径 " + filePath);
        }
        return true;
    }
    // 生成激活码
    public static void main(String[] args) {
        String timeStr = "2021-08-01 17:48:35";
        Date exprTime = DateUtils.convert(timeStr);
        String code = AesUtils.encrypt(DateUtils.convert(exprTime, DateUtils.yyyyMMddHHmmss), SystemProperties.SALT);
        System.out.println("激活码:"+code);
        System.out.println("有效期至:"+timeStr);
//        saveActivationCode(SysOsType.Windows.getActivationCodePath(), code);
//        String activationCode = getActivationCode(OSinfo.getOSname().getActivationCodePath());
//        String decrypt = AesUtils.decrypt(activationCode, "123456789qwertyu");
//        Date convert = DateUtils.convert(decrypt, DateUtils.yyyyMMddHHmmss);
//        System.out.println(DateUtils.convert(convert));
    }
}
zy-asrs-common/src/main/java/com/zy/asrs/common/sys/controller/HostController.java
File was deleted
zy-asrs-common/src/main/java/com/zy/asrs/common/utils/RandomValidateCodeUtil.java
New file
@@ -0,0 +1,122 @@
package com.zy.asrs.common.utils;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
public class RandomValidateCodeUtil {
    public static final Map<String, String> code = new ConcurrentHashMap<>();
    private static String randString = "0123456789ABCDEFGHJKLMNPRSTUVWXYZ";//随机产生数字与字母组合的字符串
    private static int width = 60;// 图片宽
    private static int height = 27;// 图片高
    private static int lineSize = 40;// 干扰线数量
    private static int stringNum = 4;// 随机产生字符数量
    private static Random random = new Random();
    /**
     * 获得字体
     */
    private static Font getFont() {
        return new Font("Fixedsys", Font.CENTER_BASELINE, 18);
    }
    /**
     * 获得颜色
     */
    private static Color getRandColor(int fc, int bc) {
        if (fc > 255)
            fc = 255;
        if (bc > 255)
            bc = 255;
        int r = fc + random.nextInt(bc - fc - 16);
        int g = fc + random.nextInt(bc - fc - 14);
        int b = fc + random.nextInt(bc - fc - 18);
        return new Color(r, g, b);
    }
    public static void init() {
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
        Graphics g = image.getGraphics();// 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作
        g.fillRect(0, 0, width, height);//图片大小
        g.setFont(new Font("Times New Roman", Font.PLAIN, 18));//字体大小
        g.setColor(getRandColor(110, 133));//字体颜色
        // 绘制干扰线
        for (int i = 0; i <= lineSize; i++) {
            drowLine(g);
        }
        // 绘制随机字符
        String randomString = "";
        for (int i = 1; i <= stringNum; i++) {
            randomString = drowString(g, randomString, i);
        }
        g.dispose();
    }
    /**
     * 生成随机图片
     */
    public static void getRandcode(String sd, HttpServletResponse response) {
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
        Graphics g = image.getGraphics();// 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作
        g.fillRect(0, 0, width, height);//图片大小
        g.setFont(new Font("Times New Roman", Font.PLAIN, 18));//字体大小
        g.setColor(getRandColor(110, 133));//字体颜色
        // 绘制干扰线
        for (int i = 0; i <= lineSize; i++) {
            drowLine(g);
        }
        // 绘制随机字符
        String randomString = "";
        for (int i = 1; i <= stringNum; i++) {
            randomString = drowString(g, randomString, i);
        }
        code.put(sd, randomString);
        g.dispose();
        try {
            ImageIO.write(image, "JPEG", response.getOutputStream());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 绘制字符串
     */
    private static String drowString(Graphics g, String randomString, int i) {
        g.setFont(getFont());
        g.setColor(new Color(random.nextInt(101), random.nextInt(111), random
                .nextInt(121)));
        String rand = String.valueOf(getRandomString(random.nextInt(randString
                .length())));
        randomString += rand;
        g.translate(random.nextInt(3), random.nextInt(3));
        g.drawString(rand, 13 * (i-1)+2, 16);
        return randomString;
    }
    /**
     * 绘制干扰线
     */
    private static void drowLine(Graphics g) {
        int x = random.nextInt(width);
        int y = random.nextInt(height);
        int xl = random.nextInt(13);
        int yl = random.nextInt(15);
        g.drawLine(x, y, x + xl, y + yl);
    }
    /**
     * 获取随机的字符
     */
    public static String getRandomString(int num) {
        return String.valueOf(randString.charAt(num));
    }
}
zy-asrs-common/src/main/java/com/zy/asrs/common/web/AuthController.java
New file
@@ -0,0 +1,342 @@
package com.zy.asrs.common.web;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.domain.CodeRes;
import com.zy.asrs.common.domain.dto.PowerDto;
import com.zy.asrs.common.domain.entity.Parameter;
import com.zy.asrs.common.domain.enums.HtmlNavIconType;
import com.zy.asrs.common.properties.OSinfo;
import com.zy.asrs.common.properties.SystemProperties;
import com.zy.asrs.common.sys.entity.*;
import com.zy.asrs.common.sys.service.*;
import com.zy.asrs.common.utils.RandomValidateCodeUtil;
import com.zy.asrs.framework.annotations.ManagerAuth;
import com.zy.asrs.framework.common.AesUtils;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.DateUtils;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.framework.exception.CoolException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
/**
 * Created by vincent on 2019-07-30
 */
@RestController
public class AuthController extends BaseController {
    @Value("${super.pwd}")
    private String superPwd;
    @Autowired
    private UserService userService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private UserLoginService userLoginService;
    @Autowired
    private ResourceService resourceService;
    @Autowired
    private RoleResourceService roleResourceService;
    @RequestMapping("/login.action")
    @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "登录")
    public R loginAction(String username, String password){
        if (username.equals("super") && password.equals(Cools.md5(superPwd))) {
            Map<String, Object> res = new HashMap<>();
            res.put("username", username);
            res.put("token", Cools.enToken(System.currentTimeMillis() + username, superPwd));
            return R.ok(res);
        }
        LambdaQueryWrapper<User> userWrapper = new LambdaQueryWrapper<>();
        userWrapper.eq(User::getUsername, username);
        User user = userService.getOne(userWrapper);
        if (Cools.isEmpty(user)){
            return R.parse(CodeRes.USER_10001);
        }
        if (user.getStatus()!=1){
            return R.parse(CodeRes.USER_10002);
        }
        if (!user.getPassword().equals(password)){
            return R.parse(CodeRes.USER_10003);
        }
        String token = Cools.enToken(System.currentTimeMillis() + username, user.getPassword());
        userLoginService.remove(new LambdaQueryWrapper<UserLogin>().eq(UserLogin::getUserId, user.getId()));
        UserLogin userLogin = new UserLogin();
        userLogin.setUserId(user.getId());
        userLogin.setToken(token);
        userLogin.setCreateTime(new Date());
        userLoginService.save(userLogin);
        Map<String, Object> res = new HashMap<>();
        res.put("username", user.getUsername());
        res.put("token", token);
        return R.ok(res);
    }
    @RequestMapping("/code/switch.action")
    public R code() {
        return R.ok().add(Parameter.get().getCodeSwitch());
    }
    @RequestMapping("/code.action")
    public void code(@RequestParam String sd, HttpServletResponse response) {
        RandomValidateCodeUtil.getRandcode(sd, response);
    }
    @RequestMapping("/code.do")
    public String codeDo(@RequestParam String sd) throws Exception {
        String code = null;
        int time = 0;
        while (time < 3000) {
            code = RandomValidateCodeUtil.code.get(sd);
            if (!Cools.isEmpty(code)){
                break;
            } else {
                Thread.sleep(10);
                time = time + 100;
            }
        }
        RandomValidateCodeUtil.code.remove(sd);
        return code;
    }
    @RequestMapping("/user/detail/auth")
    @ManagerAuth
    public R userDetail(){
        return R.ok(userService.getById(getUserId()));
    }
    @RequestMapping("/menu/auth")
    @ManagerAuth
    public R menu(){
        // 获取所有一级菜单
        List<Resource> oneLevel;
        User user = null;
        LambdaQueryWrapper<Resource> resourceWrapper;
        if (getUserId() == 9527) {
            oneLevel = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getLevel, 1).orderByAsc(Resource::getSort));
            resourceWrapper = new LambdaQueryWrapper<Resource>().eq(Resource::getLevel, 2).eq(Resource::getStatus, 1).orderByAsc(Resource::getSort);
        } else {
            // 激活码验证
            if (!SystemProperties.SYSTEM_ACTIVATION) {
                return R.ok();
            }
            oneLevel = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getLevel, 1).eq(Resource::getStatus, 1).orderByAsc(Resource::getSort));
            // 获取当前用户的所有二级菜单
            user = userService.getById(getUserId());
            List<RoleResource> roleResources = roleResourceService.list(new LambdaQueryWrapper<RoleResource>().eq(RoleResource::getRoleId, user.getRoleId()));
            List<Long> resourceIds = new ArrayList<>();
            roleResources.forEach(roleResource -> resourceIds.add(roleResource.getResourceId()));
            if (resourceIds.isEmpty()){
                return R.ok();
            }
            resourceWrapper = new LambdaQueryWrapper<Resource>().in(Resource::getId, resourceIds).eq(Resource::getLevel, 2).eq(Resource::getStatus, 1).orderByAsc(Resource::getSort);
        }
        List<Resource> twoLevel = resourceService.list(resourceWrapper);
        List<Map<String, Object>> result = new ArrayList<>();
        for (Resource menu : oneLevel) {
            Map<String, Object> map = new HashMap<>();
            List<Resource> subMenu = new ArrayList<>();
            Iterator<Resource> iterator = twoLevel.iterator();
            while (iterator.hasNext()) {
                Resource resource = iterator.next();
                if (resource.getResourceId() != null && resource.getResourceId().equals(menu.getId())) {
                    // 是否拥有查看权限
                    if (getUserId() != 9527) {
                        Resource view = resourceService.getOne(new LambdaQueryWrapper<Resource>().eq(Resource::getResourceId, resource.getId()).like(Resource::getCode, "#view"));
                        if (!Cools.isEmpty(view)){
                            RoleResource param = new RoleResource();
                            param.setResourceId(view.getId());
                            param.setRoleId(user.getRoleId());
                            if (null == roleResourceService.getOne(new LambdaQueryWrapper<>(param))){
                                continue;
                            }
                        }
                    }
                    subMenu.add(resource);
                    iterator.remove();
                }
            }
            if (subMenu.isEmpty()) {
                continue;
            }
            map.put("menuId", menu.getId());
            map.put("menuCode", menu.getCode());
            map.put("menuIcon", HtmlNavIconType.get(menu.getCode()));
            map.put("menu", menu.getName());
            map.put("subMenu", subMenu);
            result.add(map);
        }
        return R.ok(result);
    }
    @RequestMapping("/power/list/auth")
    @ManagerAuth
    public R powerList(){
        List<Resource> oneLevels = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getLevel, 1).eq(Resource::getStatus, 1).orderByAsc(Resource::getSort));
        List<Map> result = new ArrayList<>();
        // 一级
        for (Resource oneLevel : oneLevels){
            List<Map> twoLevelsList = new ArrayList<>();
            Map<String, Object> oneLevelMap = new HashMap<>();
            oneLevelMap.put("title", oneLevel.getName());
            oneLevelMap.put("id", oneLevel.getId());
            oneLevelMap.put("spread", true);
            oneLevelMap.put("children", twoLevelsList);
            List<Resource> twoLevels = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getResourceId, oneLevel.getId()).eq(Resource::getLevel, 2).eq(Resource::getStatus, 1).orderByAsc(Resource::getSort));
            // 二级
            for (Resource twoLevel : twoLevels){
                Map<String, Object> twoLevelMap = new HashMap<>();
                twoLevelMap.put("title", twoLevel.getName());
                twoLevelMap.put("id", twoLevel.getId());
                twoLevelMap.put("spread", false);
                List<Map> threeLevelsList = new ArrayList<>();
                twoLevelMap.put("children", threeLevelsList);
                // 三级
                List<Resource> threeLevels = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getResourceId, twoLevel.getId()).eq(Resource::getLevel, 3).eq(Resource::getStatus, 1).orderByAsc(Resource::getSort));
                for (Resource threeLevel : threeLevels){
                    Map<String, Object> threeLevelMap = new HashMap<>();
                    threeLevelMap.put("title", threeLevel.getName());
                    threeLevelMap.put("id", threeLevel.getId());
                    threeLevelMap.put("checked", false);
                    threeLevelsList.add(threeLevelMap);
                }
                twoLevelsList.add(twoLevelMap);
            }
            result.add(oneLevelMap);
        }
        return R.ok(result);
    }
    @RequestMapping(value = "/power/{roleId}/auth")
    @ManagerAuth
    public R get(@PathVariable("roleId") Long roleId) {
        List<Object> result = new ArrayList<>();
        // 菜单
        List<RoleResource> roleResources = roleResourceService.list(new LambdaQueryWrapper<RoleResource>().eq(RoleResource::getRoleId, roleId));
        for (RoleResource roleResource : roleResources){
            Resource resource = resourceService.getById(roleResource.getResourceId());
            if (!Cools.isEmpty(resource)){
                if (resource.getLevel() == 3){
                    result.add(resource.getId());
                }
            }
        }
        return R.ok(result);
    }
    @RequestMapping("/power/auth")
    @ManagerAuth(memo = "授权")
    @Transactional
    public R power(Long roleId, String powers){
        Role role = roleService.getById(roleId);
        Long leaderId = role.getLeader();
        roleResourceService.remove(new LambdaQueryWrapper<RoleResource>().eq(RoleResource::getRoleId, roleId));
        if (!Cools.isEmpty(powers)){
            List<PowerDto> dtos = JSON.parseArray(powers, PowerDto.class);
            for (PowerDto dto : dtos) {
                Resource resource = resourceService.getOne(new LambdaQueryWrapper<Resource>().eq(Resource::getId, dto.getTwo()).eq(Resource::getLevel, 2));
                if (!Cools.isEmpty(resource)) {
                    // 校验上级权限
                    if (leaderId != null) {
                        RoleResource roleResource = roleResourceService.getOne(new LambdaQueryWrapper<RoleResource>().eq(RoleResource::getRoleId, leaderId).eq(RoleResource::getResourceId, resource.getId()));
                        if (null == roleResource) {
                            throw new CoolException(resource.getName().concat("无法授权给").concat(role.getName()));
                        }
                    }
                    RoleResource roleResource = new RoleResource();
                    roleResource.setRoleId(roleId);
                    roleResource.setResourceId(resource.getId());
                    roleResourceService.save(roleResource);
                }
                for (String three : dto.getThree()){
                    Resource resource1 = resourceService.getOne(new LambdaQueryWrapper<Resource>().eq(Resource::getId, three).eq(Resource::getLevel, 3));
                    if (!Cools.isEmpty(resource1)) {
                        // 校验上级权限
                        if (leaderId != null) {
                            RoleResource roleResource = roleResourceService.getOne(new LambdaQueryWrapper<RoleResource>().eq(RoleResource::getRoleId, leaderId).eq(RoleResource::getResourceId, resource1.getId()));
                            if (null == roleResource) {
                                throw new CoolException(resource.getName().concat("的").concat(resource1.getName().concat("无法授权给").concat(role.getName())));
                            }
                        }
                        RoleResource roleResource = new RoleResource();
                        roleResource.setRoleId(roleId);
                        roleResource.setResourceId(resource1.getId());
                        roleResourceService.save(roleResource);
                    }
                }
            }
        }
        return R.ok();
    }
    @RequestMapping(value = "/power/menu/{resourceId}/auth")
    @ManagerAuth
    public R buttonResource(@PathVariable("resourceId") Long resourceId) {
        List<Resource> resources;
        if (getUserId() == 9527) {
            resources = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getLevel, 3).eq(Resource::getResourceId, resourceId));
        } else {
            resources = roleResourceService.getMenuButtomResource(resourceId, getUserId());
        }
        for (Resource resource : resources) {
            resource.setCode(resource.getCode().split("#")[1]);
        }
        return R.ok(resources);
    }
    @GetMapping(value = "/system/activation/auth")
    public R activation() {
        if (SystemProperties.SYSTEM_ACTIVATION) {
            String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath());
            String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT);
            if (null == timeStr) {
                SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
                return R.error();
            }
            Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
            if (new Date().getTime() < exprTime.getTime()) {
                return R.ok().add(DateUtils.convert(exprTime));
            } else {
                SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
                return R.error();
            }
        } else {
            return R.error();
        }
    }
    @PostMapping(value = "/system/secret/auth")
    @ManagerAuth
    public R systemSecret(@RequestParam(value = "secret") String secret) {
        if (Cools.isEmpty(secret)) {
            return R.error("请输入激活码");
        }
        // 验证激活码
        String timeStr = AesUtils.decrypt(secret, SystemProperties.SALT);
        if (null == timeStr) {
            return R.error("激活码错误");
        }
        Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
        if (new Date().getTime() >= exprTime.getTime()) {
            return R.error("激活码已失效");
        }
        boolean result = SystemProperties.saveActivationCode(OSinfo.getOSname().getActivationCodePath(), secret);
        if (!result) {
            return R.error("激活失败");
        }
        SystemProperties.SYSTEM_ACTIVATION = Boolean.TRUE;
        return R.ok("激活成功,有效期至"+DateUtils.convert(exprTime));
    }
}
zy-asrs-wms/src/main/java/com/zy/asrs/wms/WmsBoot.java
@@ -1,5 +1,6 @@
package com.zy.asrs.wms;
import com.zy.asrs.common.utils.RandomValidateCodeUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -11,6 +12,7 @@
public class WmsBoot {
    public static void main(String[] args) {
        RandomValidateCodeUtil.init();
        SpringApplication.run(WmsBoot.class, args);
    }