| | |
| | | </parent> |
| | | <groupId>com.zy</groupId> |
| | | <artifactId>asrs</artifactId> |
| | | <version>1.0.0</version> |
| | | <version>1.1.1</version> |
| | | <packaging>war</packaging> |
| | | |
| | | <properties> |
| | | <java.version>1.8</java.version> |
| | | <cool.version>1.0.0</cool.version> |
| | | <cool.version>1.1.1</cool.version> |
| | | <mysql-driver.version>5.1.47</mysql-driver.version> |
| | | <mybatis-plus.version>2.3.2</mybatis-plus.version> |
| | | <fastjson.version>1.2.58</fastjson.version> |
| | |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.zy.common.properties.SystemProperties; |
| | | import com.zy.common.utils.Http; |
| | | import com.zy.system.entity.*; |
| | | import com.zy.system.service.*; |
| | |
| | | userLoginService.updateById(userLogin); |
| | | // 操作日志 |
| | | if (!Cools.isEmpty(memo)) { |
| | | // 进行激活判断 |
| | | if (!SystemProperties.SYSTEM_ACTIVATION) { |
| | | Http.response(response, BaseRes.NO_ACTIVATION); |
| | | return false; |
| | | } |
| | | // 记录操作日志 |
| | | OperateLog operateLog = new OperateLog(); |
| | | operateLog.setAction(Cools.isEmpty(memo)?request.getRequestURI():memo); |
| | | operateLog.setIp(request.getRemoteAddr()); |
New file |
| | |
| | | package com.zy.common.model.enums; |
| | | |
| | | public enum SysOsType { |
| | | |
| | | Any("any", null), |
| | | Linux("Linux", null), |
| | | Mac_OS("Mac OS", null), |
| | | Mac_OS_X("Mac OS X", null), |
| | | Windows("Windows", "D:\\激活码.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; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.properties; |
| | | |
| | | import com.zy.common.model.enums.SysOsType; |
| | | |
| | | /** |
| | | * 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系统 |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.properties; |
| | | |
| | | import com.core.common.AesUtils; |
| | | |
| | | import java.io.*; |
| | | |
| | | /** |
| | | * 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 (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) { |
| | | 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 code = AesUtils.encrypt("20200801152500", SystemProperties.SALT); |
| | | System.out.println(code); |
| | | // 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)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.common.task; |
| | | |
| | | import com.core.common.AesUtils; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.common.properties.OSinfo; |
| | | import com.zy.common.properties.SystemProperties; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 系统激活任务 |
| | | */ |
| | | @Component |
| | | public class ActivateScheduler { |
| | | |
| | | @Scheduled(cron = "0/1 * 8 * * ? ") |
| | | @PostConstruct |
| | | private void execute(){ |
| | | // 获取激活码 |
| | | String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath()); |
| | | if (!Cools.isEmpty(activationCode)) { |
| | | // 获取有效期 |
| | | String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT); |
| | | if (null == timeStr) { |
| | | SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE; |
| | | return; |
| | | } |
| | | Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss); |
| | | if (new Date().getTime() < exprTime.getTime()) { |
| | | SystemProperties.SYSTEM_ACTIVATION = Boolean.TRUE; |
| | | } else { |
| | | SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE; |
| | | } |
| | | } else { |
| | | SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.PowerDto; |
| | | import com.zy.common.model.enums.HtmlNavIconType; |
| | | import com.zy.common.properties.OSinfo; |
| | | import com.zy.common.properties.SystemProperties; |
| | | import com.zy.common.utils.RandomValidateCodeUtil; |
| | | import com.zy.system.entity.*; |
| | | import com.zy.system.service.*; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | 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(memo = "更新秘钥") |
| | | @ManagerAuth |
| | | public R systemSecret(@RequestParam(value = "secret") String secret) { |
| | | return R.ok(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)); |
| | | } |
| | | |
| | | } |
| | |
| | | ,note: function(othis){ |
| | | var mobile = admin.screen() < 2 |
| | | ,note = layui.data(setter.tableName).note; |
| | | |
| | | // 获取激活状态 |
| | | var activation = false; |
| | | var exprTime; |
| | | $.ajax({ |
| | | url: baseUrl+"/system/activation/auth", |
| | | dataType:'json', |
| | | method: 'GET', |
| | | async: false, |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | activation = true; |
| | | exprTime = res.data; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | events.note.index = admin.popup({ |
| | | title: 'WMS 秘钥' |
| | | title: (activation?"已激活(有效期至"+exprTime+")":"Activation Code(未激活)") |
| | | // title: 'license' |
| | | ,shade: 0 |
| | | ,offset: [ |
| | |
| | | ,skin: 'layadmin-note layui-anim layui-anim-upbit' |
| | | ,content: '<textarea placeholder="内容"></textarea>' |
| | | ,resize: false |
| | | ,btn: ['添加', '取消'] |
| | | ,btn: [(activation?"更新":"立即激活"), '取消'] |
| | | ,success: function(layero, index){ |
| | | var textarea = layero.find('textarea') |
| | | ,value = note === undefined ? '' : note; |
| | |
| | | $.ajax({ |
| | | url: baseUrl+"/system/secret/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: "secret="+note, |
| | | data: "secret="+$("#LAY_adminNote").children("textarea").val(), |
| | | dataType:'json', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | console.log(note) |
| | | if (res.code === 200) { |
| | | layer.msg(res.msg) |
| | | layer.msg(res.msg); |
| | | layer.close(index); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/login"; |
| | | } else { |
| | |
| | | } |
| | | } |
| | | }); |
| | | layer.close(index); |
| | | } |
| | | ,btn2: function(index, layero){ |
| | | layer.close(index); |
| | |
| | | <link rel="icon" type="image/x-icon" href="../static/image/log.png" /> |
| | | <link rel="stylesheet" href="../static/layuiadmin/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../static/layuiadmin/style/admin.css" media="all"> |
| | | <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../static/js/common.js"></script> |
| | | <script type="text/javascript" src="../static/layuiadmin/layui/layui.js"></script> |
| | | <style> |
| | | .layui-layout-admin .layui-footer { |
| | | box-sizing: border-box; |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../static/js/common.js"></script> |
| | | <script src="../static/layuiadmin/layui/layui.js"></script> |
| | | <script> |
| | | layui.config({ |
| | | base: '../static/layuiadmin/' //静态资源所在路径 |
| | |
| | | mvn install:install-file -Dfile=framework-1.0.0.jar -DgroupId=cn.cool -DartifactId=framework -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true |
| | | mvn install:install-file -Dfile=framework-1.1.1.jar -DgroupId=cn.cool -DartifactId=framework -Dversion=1.1.1 -Dpackaging=jar -DgeneratePom=true |