自动化立体仓库 - WMS系统
5189db9d952aac4c5dae65af8adcaf4445b27253..f3f1f118e1ff589bb41b9e8bea5aa8d466bec670
2025-12-30 zhang
1
f3f1f1 对比 | 目录
2025-12-30 Administrator
1
8adf76 对比 | 目录
7个文件已修改
2个文件已删除
474 ■■■■ 已修改文件
.gitignore 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
license.lic 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/handler/GhjtHandler.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/system/controller/LicenseCreatorController.java 262 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/system/entity/license/LicenseCheckListener.java 190 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/license.lic 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -32,4 +32,4 @@
### LOG ###
stock
LOG_PATH_IS_UNDEFINED
LOG_PATH_IS_UNDEFINED
license.lic
Binary files differ
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -49,9 +49,9 @@
    // 二楼堆垛机对应入库站点
    private static final int[] secondFloorIn = new int[]{0, 2061, 2064, 2067, 2070, 2073, 2076};
    // 堆垛机对应一楼出库站点
    private static final int[] secondFloorOut = new int[]{0, 3002, 3003, 3006, 3008, 3009, 3012};
    private static final int[] secondFloorOut = new int[]{0, 3002, 3003, 3006, 3008, 3009, 3011};
    // 堆垛机对应一楼入库站点
    private static final int[] oneFloorIn = new int[]{0, 3001, 3004, 3005, 3007, 3010, 3011};
    private static final int[] oneFloorIn = new int[]{0, 3001, 3004, 3005, 3007, 3010, 3012};
    @Autowired
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -805,7 +805,7 @@
                case 22:
                case 23:
                case 24:
                    souresStaNo = 3012;
                    souresStaNo = 3011;
                    break;
                default:
            }
src/main/java/com/zy/asrs/task/handler/GhjtHandler.java
@@ -71,10 +71,10 @@
    private CommonService commonService;
    // 堆垛机对应一楼出库站点
    private static final int[] oneFloorOutSite = new int[]{0,3002,3003,3006,3008,3009,3012};
    private static final int[] oneFloorOutSite = new int[]{0,3002,3003,3006,3008,3009,3011};
    // 堆垛机对应一楼入库站点
    private static final int[] oneFloorInSite = new int[]{0,3001,3004,3005,3007,3010,3011};
    private static final int[] oneFloorInSite = new int[]{0,3001,3004,3005,3007,3010,3012};
    public void startCkrwPushGwcs(WrkMast wrkMast) {
src/main/java/com/zy/system/controller/LicenseCreatorController.java
@@ -1,131 +1,131 @@
package com.zy.system.controller;
import com.core.annotations.ManagerAuth;
import com.core.common.AesUtils;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.zy.common.properties.OSinfo;
import com.zy.common.properties.SystemProperties;
import com.zy.system.entity.license.*;
import de.schlichtherle.license.LicenseContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.util.ClassUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.prefs.Preferences;
/**
 *
 * 用于生成证书文件,不能放在给客户部署的代码里
 */
@RestController
@RequestMapping("/license")
public class LicenseCreatorController {
    @Value("${license.licensePath}")
    private String licensePath;
    @Autowired
    private LicenseCheckListener licenseCheckListener;
    /**
     * 获取服务器硬件信息
     * @param osName 操作系统类型,如果为空则自动判断
     */
    @RequestMapping(value = "/getServerInfos",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public LicenseCheck getServerInfos(@RequestParam(value = "osName",required = false) String osName) {
        //操作系统类型
        if(Cools.isEmpty(osName)){
            osName = System.getProperty("os.name");
        }
        osName = osName.toLowerCase();
        AbstractServerInfos abstractServerInfos = null;
        //根据不同操作系统类型选择不同的数据获取方法
        if (osName.startsWith("windows")) {
            abstractServerInfos = new WindowsServerInfos();
        } else if (osName.startsWith("linux")) {
//            abstractServerInfos = new LinuxServerInfos();
        }else{//其他服务器类型
            abstractServerInfos = new WindowsServerInfos();
        }
        return abstractServerInfos.getServerInfos();
    }
    /**
     * 获取许可证有效期天数
     */
    @RequestMapping(value = "/getLicenseDays")
    public R getLicenseDays() {
        // 获取激活码
        String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath());
        if (!Cools.isEmpty(activationCode)) {
            // 获取有效期
            String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT);
            if (null == timeStr) {
                return R.error();
            }
            Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
            if (new Date().getTime() < exprTime.getTime()) {
                Date start = new Date();
                Long starTime = start.getTime();
                Long endTime = exprTime.getTime();
                Long num = endTime - starTime;//时间戳相差的毫秒数
                int day = (int) (num / 24 / 60 / 60 / 1000);
                return R.ok().add(day);
            }
        }
        return R.error();
    }
    @RequestMapping(value = "/updateLicense")
    public R updateLicense(@RequestParam("file") MultipartFile[] files){
        MultipartFile file = files[0];
        String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath();
        File licensePathFile = new File(licensePathFileName);
        //服务器端保存的文件对象
        File serverFile = new File(licensePathFile.getPath());
        if (serverFile.exists()) {
            try {
                serverFile.delete();//存在文件,删除
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        try {
            //创建文件
            serverFile.createNewFile();
            //将上传的文件写入到服务器端文件内
            file.transferTo(serverFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        //重新加载许可证
        boolean loadedLicense = licenseCheckListener.loadLicense();
        if (loadedLicense) {
            return R.ok();
        }
        return R.error("许可证更新失败");
    }
}
//package com.zy.system.controller;
//
//import com.core.annotations.ManagerAuth;
//import com.core.common.AesUtils;
//import com.core.common.Cools;
//import com.core.common.DateUtils;
//import com.core.common.R;
//import com.zy.common.properties.OSinfo;
//import com.zy.common.properties.SystemProperties;
//import com.zy.system.entity.license.*;
//import de.schlichtherle.license.LicenseContent;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.http.MediaType;
//import org.springframework.util.ClassUtils;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.File;
//import java.io.IOException;
//import java.text.SimpleDateFormat;
//import java.time.temporal.ChronoUnit;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.prefs.Preferences;
//
///**
// *
// * 用于生成证书文件,不能放在给客户部署的代码里
// */
//@RestController
//@RequestMapping("/license")
//public class LicenseCreatorController {
//
//    //@Value("${license.licensePath}")
//    private String licensePath;
//
//    @Autowired
//    private LicenseCheckListener licenseCheckListener;
//
//    /**
//     * 获取服务器硬件信息
//     * @param osName 操作系统类型,如果为空则自动判断
//     */
//    @RequestMapping(value = "/getServerInfos",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
//    public LicenseCheck getServerInfos(@RequestParam(value = "osName",required = false) String osName) {
//        //操作系统类型
//        if(Cools.isEmpty(osName)){
//            osName = System.getProperty("os.name");
//        }
//        osName = osName.toLowerCase();
//
//        AbstractServerInfos abstractServerInfos = null;
//
//        //根据不同操作系统类型选择不同的数据获取方法
//        if (osName.startsWith("windows")) {
//            abstractServerInfos = new WindowsServerInfos();
//        } else if (osName.startsWith("linux")) {
////            abstractServerInfos = new LinuxServerInfos();
//        }else{//其他服务器类型
//            abstractServerInfos = new WindowsServerInfos();
//        }
//
//        return abstractServerInfos.getServerInfos();
//    }
//
//    /**
//     * 获取许可证有效期天数
//     */
//    @RequestMapping(value = "/getLicenseDays")
//    public R getLicenseDays() {
//
//        // 获取激活码
//        String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath());
//        if (!Cools.isEmpty(activationCode)) {
//            // 获取有效期
//            String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT);
//            if (null == timeStr) {
//                return R.error();
//            }
//            Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
//            if (new Date().getTime() < exprTime.getTime()) {
//                Date start = new Date();
//                Long starTime = start.getTime();
//                Long endTime = exprTime.getTime();
//                Long num = endTime - starTime;//时间戳相差的毫秒数
//                int day = (int) (num / 24 / 60 / 60 / 1000);
//                return R.ok().add(day);
//            }
//        }
//        return R.error();
//    }
//
//    @RequestMapping(value = "/updateLicense")
//    public R updateLicense(@RequestParam("file") MultipartFile[] files){
//        MultipartFile file = files[0];
//
//        String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath();
//        File licensePathFile = new File(licensePathFileName);
//        //服务器端保存的文件对象
//        File serverFile = new File(licensePathFile.getPath());
//        if (serverFile.exists()) {
//            try {
//                serverFile.delete();//存在文件,删除
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//
//        try {
//            //创建文件
//            serverFile.createNewFile();
//            //将上传的文件写入到服务器端文件内
//            file.transferTo(serverFile);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//
//        //重新加载许可证
//        boolean loadedLicense = licenseCheckListener.loadLicense();
//        if (loadedLicense) {
//            return R.ok();
//        }
//        return R.error("许可证更新失败");
//    }
//
//}
src/main/java/com/zy/system/entity/license/LicenseCheckListener.java
@@ -1,95 +1,95 @@
package com.zy.system.entity.license;
import com.core.common.Cools;
import de.schlichtherle.license.LicenseContent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import java.io.File;
/**
 * 在项目启动时安装证书
 */
@Component
public class LicenseCheckListener implements ApplicationListener<ContextRefreshedEvent> {
    private static Logger logger = LogManager.getLogger(LicenseCheckListener.class);
    /**
     * 证书subject
     */
    @Value("${license.subject}")
    private String subject;
    /**
     * 公钥别称
     */
    @Value("${license.publicAlias}")
    private String publicAlias;
    /**
     * 访问公钥库的密码
     */
    @Value("${license.storePass}")
    private String storePass;
    /**
     * 证书生成路径
     */
    @Value("${license.licensePath}")
    private String licensePath;
    /**
     * 密钥库存储路径
     */
    @Value("${license.publicKeysStorePath}")
    private String publicKeysStorePath;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        //root application context 没有parent
        ApplicationContext context = event.getApplicationContext().getParent();
        if(context == null){
            loadLicense();
        }
    }
    //加载证书
    public boolean loadLicense() {
        if(!Cools.isEmpty(licensePath)){
            logger.info("++++++++ 开始加载许可证 ++++++++");
            try {
                String publicKeysStoreFileName = this.getClass().getClassLoader().getResource(publicKeysStorePath).getPath();
                File publicKeysStoreFile = new File(publicKeysStoreFileName);
                String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath();
                File licensePathFile = new File(licensePathFileName);
                LicenseVerifyParam param = new LicenseVerifyParam();
                param.setSubject(subject);
                param.setPublicAlias(publicAlias);
                param.setStorePass(storePass);
                param.setLicensePath(licensePathFile.getPath());
                param.setPublicKeysStorePath(publicKeysStoreFile.getPath());
                LicenseVerify licenseVerify = new LicenseVerify();
                //安装证书
                LicenseContent install = licenseVerify.install(param);
                logger.info("++++++++ 许可证加载结束 ++++++++");
//                return install != null;
                return true;
            } catch (Exception e) {
                return false;
            }
        }
        return false;
    }
}
//package com.zy.system.entity.license;
//
//import com.core.common.Cools;
//import de.schlichtherle.license.LicenseContent;
//import org.apache.logging.log4j.LogManager;
//import org.apache.logging.log4j.Logger;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationListener;
//import org.springframework.context.event.ContextRefreshedEvent;
//import org.springframework.stereotype.Component;
//
//import java.io.File;
//
///**
// * 在项目启动时安装证书
// */
//@Component
//public class LicenseCheckListener implements ApplicationListener<ContextRefreshedEvent> {
//    private static Logger logger = LogManager.getLogger(LicenseCheckListener.class);
//
//    /**
//     * 证书subject
//     */
//    @Value("${license.subject}")
//    private String subject;
//
//    /**
//     * 公钥别称
//     */
//    @Value("${license.publicAlias}")
//    private String publicAlias;
//
//    /**
//     * 访问公钥库的密码
//     */
//    @Value("${license.storePass}")
//    private String storePass;
//
//    /**
//     * 证书生成路径
//     */
//    @Value("${license.licensePath}")
//    private String licensePath;
//
//    /**
//     * 密钥库存储路径
//     */
//    @Value("${license.publicKeysStorePath}")
//    private String publicKeysStorePath;
//
//    @Override
//    public void onApplicationEvent(ContextRefreshedEvent event) {
//        //root application context 没有parent
//        ApplicationContext context = event.getApplicationContext().getParent();
//        if(context == null){
//            loadLicense();
//        }
//    }
//
//    //加载证书
//    public boolean loadLicense() {
//        if(!Cools.isEmpty(licensePath)){
//            logger.info("++++++++ 开始加载许可证 ++++++++");
//
//            try {
//                String publicKeysStoreFileName = this.getClass().getClassLoader().getResource(publicKeysStorePath).getPath();
//                File publicKeysStoreFile = new File(publicKeysStoreFileName);
//
//                String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath();
//                File licensePathFile = new File(licensePathFileName);
//
//                LicenseVerifyParam param = new LicenseVerifyParam();
//                param.setSubject(subject);
//                param.setPublicAlias(publicAlias);
//                param.setStorePass(storePass);
//                param.setLicensePath(licensePathFile.getPath());
//                param.setPublicKeysStorePath(publicKeysStoreFile.getPath());
//
//                LicenseVerify licenseVerify = new LicenseVerify();
//                //安装证书
//                LicenseContent install = licenseVerify.install(param);
//
//                logger.info("++++++++ 许可证加载结束 ++++++++");
//
////                return install != null;
//                return true;
//            } catch (Exception e) {
//                return false;
//            }
//        }
//
//        return false;
//    }
//}
src/main/resources/application.yml
@@ -27,7 +27,7 @@
      maxRequestSize: 100MB
mybatis-plus:
  mapper-locations: classpath:mapper/*.xml
  mapper-locations: classpath:mapper/*.xml
#  global-config:
#    field-strategy: 0
#  configuration:
@@ -42,13 +42,7 @@
swagger:
  enable: false
#License相关配置
license:
  subject: ghjtasrs
  publicAlias: publicCert
  storePass: public_zhongyang_123456789
  licensePath: license.lic
  publicKeysStorePath: publicCerts.keystore
# 下位机配置
wcs-slave:
src/main/resources/license.lic
Binary files differ