Lius
2024-11-04 d603739c0320f355cfc3152865918729fea790de
license
已添加16个文件
已修改15个文件
1752 ■■■■■ 文件已修改
lxzn-boot-base-core/pom.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/LicenseConfig.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/AbstractServerInfos.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/CustomKeyStoreParam.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LicenseCheckInterceptor.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LicenseCheckListener.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LicenseManagerHolder.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LicenseVerify.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LinuxServerInfos.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/WindowsServerInfos.java 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/entity/CustomLicenseManager.java 270 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/entity/LicenseCheckModel.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/entity/LicenseVerifyParam.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/CurrentElectricDto.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalElectricJob.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalSpindleJob.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentWorklineMapper.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentXYZMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentWorklineMapper.xml 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentXYZMapper.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentWorkLineService.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentXYZService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentWorkLineServiceImpl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentXYZServiceImpl.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOeeInfoServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/screen/service/impl/MdcLargeScreenServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/config/license/LicenseCreator.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/config/license/LicenseCreatorParam.java 155 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/base/controller/LicenseController.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-boot-base-core/pom.xml
@@ -226,6 +226,12 @@
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-kotlin</artifactId>
        </dependency>
        <!--生成license-->
        <dependency>
            <groupId>de.schlichtherle.truelicense</groupId>
            <artifactId>truelicense-core</artifactId>
            <version>1.33</version>
        </dependency>
    </dependencies>
</project>
lxzn-boot-base-core/src/main/java/org/jeecg/config/LicenseConfig.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package org.jeecg.config;
import org.jeecg.config.license.LicenseCheckInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
/**
 * @Author: lius
 * @Description: License拦截器配置
 * @DateTime: 17:55 2024/11/2
 */
@Configuration
public class LicenseConfig implements WebMvcConfigurer {
    @Resource
    private LicenseCheckInterceptor licenseCheckInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加要拦截的url
        registry.addInterceptor(licenseCheckInterceptor)
                // æ‹¦æˆªçš„路径
                .addPathPatterns("/**")
                // æ”¾è¡Œçš„路径
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**", "/doc.html")//swagger
                .excludePathPatterns("/base/license/**");//生成license和获取服务器硬件信息
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/AbstractServerInfos.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,129 @@
package org.jeecg.config.license;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jeecg.config.license.entity.LicenseCheckModel;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
/**
 * @Author: lius
 * @ClassName AbstractServerInfos
 * @date 2024/11/2 16:00
 */
public abstract class AbstractServerInfos {
    private static Logger logger = LogManager.getLogger(AbstractServerInfos.class);
    /**
     * ç»„装需要额外校验的License参数
     *
     * @return entity.vo.LicenseCheckModel
     */
    public LicenseCheckModel getServerInfos() {
        LicenseCheckModel result = new LicenseCheckModel();
        try {
            result.setIpAddress(this.getIpAddress());
            result.setMacAddress(this.getMacAddress());
            result.setCpuSerial(this.getCPUSerial());
            result.setMainBoardSerial(this.getMainBoardSerial());
        } catch (Exception e) {
            logger.error("获取服务器硬件信息失败", e);
        }
        return result;
    }
    /**
     * èŽ·å–IP地址
     *
     * @return java.util.List<java.lang.String>
     */
    protected abstract List<String> getIpAddress() throws Exception;
    /**
     * èŽ·å–Mac地址
     *
     * @return java.util.List<java.lang.String>
     */
    protected abstract List<String> getMacAddress() throws Exception;
    /**
     * èŽ·å–CPU序列号
     *
     * @return java.lang.String
     */
    protected abstract String getCPUSerial() throws Exception;
    /**
     * èŽ·å–ä¸»æ¿åºåˆ—å·
     *
     * @return java.lang.String
     */
    protected abstract String getMainBoardSerial() throws Exception;
    /**
     * èŽ·å–å½“å‰æœåŠ¡å™¨æ‰€æœ‰ç¬¦åˆæ¡ä»¶çš„InetAddress
     *
     * @return java.util.List<java.net.InetAddress>
     */
    protected List<InetAddress> getLocalAllInetAddress() throws Exception {
        List<InetAddress> result = new ArrayList<>(4);
        // éåŽ†æ‰€æœ‰çš„ç½‘ç»œæŽ¥å£
        for (Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements(); ) {
            NetworkInterface iface = (NetworkInterface) networkInterfaces.nextElement();
            // åœ¨æ‰€æœ‰çš„æŽ¥å£ä¸‹å†éåކIP
            for (Enumeration inetAddresses = iface.getInetAddresses(); inetAddresses.hasMoreElements(); ) {
                InetAddress inetAddr = (InetAddress) inetAddresses.nextElement();
                //排除LoopbackAddress、SiteLocalAddress、LinkLocalAddress、MulticastAddress类型的IP地址
                if (!inetAddr.isLoopbackAddress() /*&& !inetAddr.isSiteLocalAddress()*/
                        && !inetAddr.isLinkLocalAddress() && !inetAddr.isMulticastAddress()) {
                    result.add(inetAddr);
                }
            }
        }
        return result;
    }
    /**
     * èŽ·å–æŸä¸ªç½‘ç»œæŽ¥å£çš„Mac地址
     *
     * @return void
     */
    protected String getMacByInetAddress(InetAddress inetAddr) {
        try {
            byte[] mac = NetworkInterface.getByInetAddress(inetAddr).getHardwareAddress();
            StringBuffer stringBuffer = new StringBuffer();
            for (int i = 0; i < mac.length; i++) {
                if (i != 0) {
                    stringBuffer.append("-");
                }
                //将十六进制byte转化为字符串
                String temp = Integer.toHexString(mac[i] & 0xff);
                if (temp.length() == 1) {
                    stringBuffer.append("0" + temp);
                } else {
                    stringBuffer.append(temp);
                }
            }
            return stringBuffer.toString().toUpperCase();
        } catch (SocketException e) {
            e.printStackTrace();
        }
        return null;
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/CustomKeyStoreParam.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,63 @@
package org.jeecg.config.license;
import de.schlichtherle.license.AbstractKeyStoreParam;
import java.io.*;
/**
 * @Author: lius
 * @ClassName CustomKeyStoreParam
 * @date 2024/11/2 16:00
 */
public class CustomKeyStoreParam extends AbstractKeyStoreParam {
    /**
     * å…¬é’¥/私钥在磁盘上的存储路径
     */
    private String storePath;
    private String alias;
    private String storePwd;
    private String keyPwd;
    public CustomKeyStoreParam(Class clazz, String resource, String alias, String storePwd, String keyPwd) {
        super(clazz, resource);
        this.storePath = resource;
        this.alias = alias;
        this.storePwd = storePwd;
        this.keyPwd = keyPwd;
    }
    @Override
    public String getAlias() {
        return alias;
    }
    @Override
    public String getStorePwd() {
        return storePwd;
    }
    @Override
    public String getKeyPwd() {
        return keyPwd;
    }
    /**
     * å¤å†™de.schlichtherle.license.AbstractKeyStoreParam的getStream()方法<br/>
     * ç”¨äºŽå°†å…¬ç§é’¥å­˜å‚¨æ–‡ä»¶å­˜æ”¾åˆ°å…¶ä»–磁盘位置而不是项目中
     *
     * @param
     * @return java.io.InputStream
     */
    @Override
    public InputStream getStream() throws IOException {
        final InputStream in = new FileInputStream(new File(storePath));
        if (null == in) {
            throw new FileNotFoundException(storePath);
        }
        return in;
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LicenseCheckInterceptor.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,84 @@
package org.jeecg.config.license;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: lius
* @Description: ä½¿ç”¨æ‹¦æˆªå™¨æ‹¦æˆªè¯·æ±‚,验证证书的可用性
* @DateTime: 2024/11/2 16:00
*/
@Component
public class LicenseCheckInterceptor implements HandlerInterceptor {
    private static Logger log = LoggerFactory.getLogger(LicenseCheckListener.class);
    /**
     * è¿›å…¥controller层之前拦截请求
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("进入拦截器,验证证书可使用性");
        LicenseVerify licenseVerify = new LicenseVerify();
        //校验证书是否有效
        boolean verifyResult = licenseVerify.verify();
        if(verifyResult){
            log.info("验证成功,证书可用");
            return true;
        }else{
            log.info("验证失败,证书无效");
            response.setContentType("application/json;charset=utf-8");
            Map<String,String> result = new HashMap<>(1);
            result.put("result","您的证书无效,请核查服务器是否取得授权或重新申请证书!");
            response.getWriter().write(JSON.toJSONString(result));
            return false;
        }
    }
    /**
     * å¤„理请求完成后视图渲染之前的处理操作
     * @param request
     * @param response
     * @param handler
     * @param modelAndView
     * @throws Exception
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
//        log.info("处理请求完成后视图渲染之前的处理操作");
    }
    /**
     * è§†å›¾æ¸²æŸ“之后的操作
     * @param request
     * @param response
     * @param handler
     * @param ex
     * @throws Exception
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
//        log.info("视图渲染之后的操作");
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LicenseCheckListener.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,77 @@
package org.jeecg.config.license;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.config.license.entity.LicenseVerifyParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
/**
 * @Author: lius
 * @ClassName LicenseCheckListener
 * @date 2024/11/2 16:00
 */
@Component
public class LicenseCheckListener implements ApplicationListener<ContextRefreshedEvent> {
    private static Logger logger = LoggerFactory.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) {
            if (StringUtils.isNotBlank(licensePath)) {
                logger.info("++++++++ å¼€å§‹å®‰è£…证书 ++++++++");
                LicenseVerifyParam param = new LicenseVerifyParam();
                param.setSubject(subject);
                param.setPublicAlias(publicAlias);
                param.setStorePass(storePass);
                param.setLicensePath(licensePath);
                param.setPublicKeysStorePath(publicKeysStorePath);
                LicenseVerify licenseVerify = new LicenseVerify();
                //安装证书
                licenseVerify.install(param);
                logger.info("++++++++ è¯ä¹¦å®‰è£…结束 ++++++++");
            }
        }
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LicenseManagerHolder.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package org.jeecg.config.license;
import de.schlichtherle.license.LicenseManager;
import de.schlichtherle.license.LicenseParam;
import org.jeecg.config.license.entity.CustomLicenseManager;
/**
 * @Author: lius
 * @ClassName LicenseManagerHolder
 * @date 2024/11/2 16:00
 */
public class LicenseManagerHolder {
    private static volatile LicenseManager LICENSE_MANAGER;
    public static LicenseManager getInstance(LicenseParam param){
        if(LICENSE_MANAGER == null){
            synchronized (LicenseManagerHolder.class){
                if(LICENSE_MANAGER == null){
                    LICENSE_MANAGER = new CustomLicenseManager(param);
                }
            }
        }
        return LICENSE_MANAGER;
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LicenseVerify.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,87 @@
package org.jeecg.config.license;
import de.schlichtherle.license.*;
import org.jeecg.config.license.entity.LicenseVerifyParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.prefs.Preferences;
/**
 * @Author: lius
 * @ClassName LicenseVerify
 * @Description å®‰è£…授权证书
 * @date 2024/11/2 16:00
 */
public class LicenseVerify {
    private static final Logger logger = LoggerFactory.getLogger(LicenseVerify.class);
    /**
     * å®‰è£…License证书
     */
    public synchronized LicenseContent install(LicenseVerifyParam param){
        LicenseContent result = null;
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //1. å®‰è£…证书
        try{
            LicenseManager licenseManager = LicenseManagerHolder.getInstance(initLicenseParam(param));
            licenseManager.uninstall();
            result = licenseManager.install(new File(param.getLicensePath()));
            logger.info(MessageFormat.format("证书安装成功,证书有效期:{0} - {1}",format.format(result.getNotBefore()),format.format(result.getNotAfter())));
        }catch (Exception e){
            logger.error("证书安装失败!",e);
        }
        return result;
    }
    /**
     * æ ¡éªŒLicense证书
     * @return boolean
     */
    public boolean verify(){
        LicenseManager licenseManager = LicenseManagerHolder.getInstance(null);
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //2. æ ¡éªŒè¯ä¹¦
        try {
            LicenseContent licenseContent = licenseManager.verify();
            logger.info(MessageFormat.format("证书校验通过,证书有效期:{0} - {1}",format.format(licenseContent.getNotBefore()),format.format(licenseContent.getNotAfter())));
            return true;
        }catch (Exception e){
            logger.error("证书校验失败!",e);
            return false;
        }
    }
    /**
     * åˆå§‹åŒ–证书生成参数
     * @param param License校验类需要的参数
     * @return de.schlichtherle.license.LicenseParam
     */
    private LicenseParam initLicenseParam(LicenseVerifyParam param){
        Preferences preferences = Preferences.userNodeForPackage(LicenseVerify.class);
        CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());
        KeyStoreParam publicStoreParam = new CustomKeyStoreParam(LicenseVerify.class
                ,param.getPublicKeysStorePath()
                ,param.getPublicAlias()
                ,param.getStorePass()
                ,null);
        return new DefaultLicenseParam(param.getSubject()
                ,preferences
                ,publicStoreParam
                ,cipherParam);
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/LinuxServerInfos.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,89 @@
package org.jeecg.config.license;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.List;
import java.util.stream.Collectors;
/**
 * @Author: lius
 * @ClassName LinuxServerInfos
 * @date 2024/11/2 16:00
 */
public class LinuxServerInfos extends AbstractServerInfos{
    @Override
    protected List<String> getIpAddress() throws Exception {
        List<String> result = null;
        //获取所有网络接口
        List<InetAddress> inetAddresses = getLocalAllInetAddress();
        if(inetAddresses != null && inetAddresses.size() > 0){
            result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
        }
        return result;
    }
    @Override
    protected List<String> getMacAddress() throws Exception {
        List<String> result = null;
        //1. èŽ·å–æ‰€æœ‰ç½‘ç»œæŽ¥å£
        List<InetAddress> inetAddresses = getLocalAllInetAddress();
        if(inetAddresses != null && inetAddresses.size() > 0){
            //2. èŽ·å–æ‰€æœ‰ç½‘ç»œæŽ¥å£çš„Mac地址
            result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
        }
        return result;
    }
    @Override
    protected String getCPUSerial() throws Exception {
        //序列号
        String serialNumber = "";
        //使用dmidecode命令获取CPU序列号
        String[] shell = {"/bin/bash","-c","dmidecode -t processor | grep 'ID' | awk -F ':' '{print $2}' | head -n 1"};
        Process process = Runtime.getRuntime().exec(shell);
        process.getOutputStream().close();
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line = reader.readLine().trim();
        if(StringUtils.isNotBlank(line)){
            serialNumber = line;
        }
        reader.close();
        return serialNumber;
    }
    @Override
    protected String getMainBoardSerial() throws Exception {
        //序列号
        String serialNumber = "";
        //使用dmidecode命令获取主板序列号
        String[] shell = {"/bin/bash","-c","dmidecode | grep 'Serial Number' | awk -F ':' '{print $2}' | head -n 1"};
        Process process = Runtime.getRuntime().exec(shell);
        process.getOutputStream().close();
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line = reader.readLine().trim();
        if(StringUtils.isNotBlank(line)){
            serialNumber = line;
        }
        reader.close();
        return serialNumber;
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/WindowsServerInfos.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,88 @@
package org.jeecg.config.license;
import java.net.InetAddress;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
/**
 * @Author: lius
 * @ClassName WindowsServerInfos
 * @date 2024/11/2 16:00
 */
public class WindowsServerInfos extends AbstractServerInfos{
        @Override
        protected List<String> getIpAddress() throws Exception {
            List<String> result = null;
            //获取所有网络接口
            List<InetAddress> inetAddresses = getLocalAllInetAddress();
            if(inetAddresses != null && inetAddresses.size() > 0){
                result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
            }
            return result;
        }
        @Override
        protected List<String> getMacAddress() throws Exception {
            List<String> result = null;
            //1. èŽ·å–æ‰€æœ‰ç½‘ç»œæŽ¥å£
            List<InetAddress> inetAddresses = getLocalAllInetAddress();
            if(inetAddresses != null && inetAddresses.size() > 0){
                //2. èŽ·å–æ‰€æœ‰ç½‘ç»œæŽ¥å£çš„Mac地址
                result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
            }
            return result;
        }
        @Override
        protected String getCPUSerial() throws Exception {
            //序列号
            String serialNumber = "";
            //使用WMIC获取CPU序列号
            Process process = Runtime.getRuntime().exec("wmic cpu get processorid");
            process.getOutputStream().close();
            Scanner scanner = new Scanner(process.getInputStream());
            if(scanner.hasNext()){
                scanner.next();
            }
            if(scanner.hasNext()){
                serialNumber = scanner.next().trim();
            }
            scanner.close();
            return serialNumber;
        }
        @Override
        protected String getMainBoardSerial() throws Exception {
            //序列号
            String serialNumber = "";
            //使用WMIC获取主板序列号
            Process process = Runtime.getRuntime().exec("wmic baseboard get serialnumber");
            process.getOutputStream().close();
            Scanner scanner = new Scanner(process.getInputStream());
            if(scanner.hasNext()){
                scanner.next();
            }
            if(scanner.hasNext()){
                serialNumber = scanner.next().trim();
            }
            scanner.close();
            return serialNumber;
        }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/entity/CustomLicenseManager.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,270 @@
package org.jeecg.config.license.entity;
import de.schlichtherle.license.*;
import de.schlichtherle.xml.GenericCertificate;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jeecg.config.license.AbstractServerInfos;
import org.jeecg.config.license.LinuxServerInfos;
import org.jeecg.config.license.WindowsServerInfos;
import java.beans.XMLDecoder;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;
/**
 * @Author: lius
 * @ClassName CustomLicenseManager
 * @date 2024/11/2 16:00
 */
public class CustomLicenseManager extends LicenseManager {
    private static Logger logger = LogManager.getLogger(CustomLicenseManager.class);
    //XML编码
    private static final String XML_CHARSET = "UTF-8";
    //默认BUFSIZE
    private static final int DEFAULT_BUFSIZE = 8 * 1024;
    public CustomLicenseManager() {
    }
    public CustomLicenseManager(LicenseParam param) {
        super(param);
    }
    /**
     * å¤å†™create方法
     *
     * @param
     * @return byte[]
     */
    @Override
    protected synchronized byte[] create(
            LicenseContent content,
            LicenseNotary notary)
            throws Exception {
        initialize(content);
        this.validateCreate(content);
        final GenericCertificate certificate = notary.sign(content);
        return getPrivacyGuard().cert2key(certificate);
    }
    /**
     * å¤å†™install方法,其中validate方法调用本类中的validate方法,校验IP地址、Mac地址等其他信息
     *
     * @param
     * @return de.schlichtherle.license.LicenseContent
     */
    @Override
    protected synchronized LicenseContent install(
            final byte[] key,
            final LicenseNotary notary)
            throws Exception {
        final GenericCertificate certificate = getPrivacyGuard().key2cert(key);
        notary.verify(certificate);
        final LicenseContent content = (LicenseContent) this.load(certificate.getEncoded());
        this.validate(content);
        setLicenseKey(key);
        setCertificate(certificate);
        return content;
    }
    /**
     * å¤å†™verify方法,调用本类中的validate方法,校验IP地址、Mac地址等其他信息
     *
     * @param
     * @return de.schlichtherle.license.LicenseContent
     */
    @Override
    protected synchronized LicenseContent verify(final LicenseNotary notary)
            throws Exception {
        GenericCertificate certificate = getCertificate();
        // Load license key from preferences,
        final byte[] key = getLicenseKey();
        if (null == key) {
            throw new NoLicenseInstalledException(getLicenseParam().getSubject());
        }
        certificate = getPrivacyGuard().key2cert(key);
        notary.verify(certificate);
        final LicenseContent content = (LicenseContent) this.load(certificate.getEncoded());
        this.validate(content);
        setCertificate(certificate);
        return content;
    }
    /**
     * æ ¡éªŒç”Ÿæˆè¯ä¹¦çš„参数信息
     *
     * @param content è¯ä¹¦æ­£æ–‡
     */
    protected synchronized void validateCreate(final LicenseContent content)
            throws LicenseContentException {
        final LicenseParam param = getLicenseParam();
        final Date now = new Date();
        final Date notBefore = content.getNotBefore();
        final Date notAfter = content.getNotAfter();
        if (null != notAfter && now.after(notAfter)) {
            throw new LicenseContentException("证书失效时间不能早于当前时间");
        }
        if (null != notBefore && null != notAfter && notAfter.before(notBefore)) {
            throw new LicenseContentException("证书生效时间不能晚于证书失效时间");
        }
        final String consumerType = content.getConsumerType();
        if (null == consumerType) {
            throw new LicenseContentException("用户类型不能为空");
        }
    }
    /**
     * å¤å†™validate方法,增加IP地址、Mac地址等其他信息校验
     *
     * @param content LicenseContent
     */
    @Override
    protected synchronized void validate(final LicenseContent content)
            throws LicenseContentException {
        //1. é¦–先调用父类的validate方法
        super.validate(content);
        //2. ç„¶åŽæ ¡éªŒè‡ªå®šä¹‰çš„License参数
        //License中可被允许的参数信息
        LicenseCheckModel expectedCheckModel = (LicenseCheckModel) content.getExtra();
        //当前服务器真实的参数信息
        LicenseCheckModel serverCheckModel = getServerInfos();
        if (expectedCheckModel != null && serverCheckModel != null) {
            //校验IP地址
            if (!checkIpAddress(expectedCheckModel.getIpAddress(), serverCheckModel.getIpAddress())) {
                throw new LicenseContentException("当前服务器的IP没在授权范围内");
            }
            //校验Mac地址
            if (!checkIpAddress(expectedCheckModel.getMacAddress(), serverCheckModel.getMacAddress())) {
                throw new LicenseContentException("当前服务器的Mac地址没在授权范围内");
            }
            //校验主板序列号
            if (!checkSerial(expectedCheckModel.getMainBoardSerial(), serverCheckModel.getMainBoardSerial())) {
                throw new LicenseContentException("当前服务器的主板序列号没在授权范围内");
            }
            //校验CPU序列号
            if (!checkSerial(expectedCheckModel.getCpuSerial(), serverCheckModel.getCpuSerial())) {
                throw new LicenseContentException("当前服务器的CPU序列号没在授权范围内");
            }
        } else {
            throw new LicenseContentException("不能获取服务器硬件信息");
        }
    }
    /**
     * é‡å†™XMLDecoder解析XML
     *
     * @param encoded XML类型字符串
     * @return java.lang.Object
     */
    private Object load(String encoded) {
        BufferedInputStream inputStream = null;
        XMLDecoder decoder = null;
        try {
            inputStream = new BufferedInputStream(new ByteArrayInputStream(encoded.getBytes(XML_CHARSET)));
            decoder = new XMLDecoder(new BufferedInputStream(inputStream, DEFAULT_BUFSIZE), null, null);
            return decoder.readObject();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } finally {
            try {
                if (decoder != null) {
                    decoder.close();
                }
                if (inputStream != null) {
                    inputStream.close();
                }
            } catch (Exception e) {
                logger.error("XMLDecoder解析XML失败", e);
            }
        }
        return null;
    }
    /**
     * èŽ·å–å½“å‰æœåŠ¡å™¨éœ€è¦é¢å¤–æ ¡éªŒçš„License参数
     *
     * @return demo.LicenseCheckModel
     */
    private LicenseCheckModel getServerInfos() {
        //操作系统类型
        String osName = System.getProperty("os.name").toLowerCase();
        AbstractServerInfos abstractServerInfos = null;
        //根据不同操作系统类型选择不同的数据获取方法
        if (osName.startsWith("windows")) {
            abstractServerInfos = new WindowsServerInfos();
        } else if (osName.startsWith("linux")) {
            abstractServerInfos = new LinuxServerInfos();
        } else {//其他服务器类型
            abstractServerInfos = new LinuxServerInfos();
        }
        return abstractServerInfos.getServerInfos();
    }
    /**
     * æ ¡éªŒå½“前服务器的IP/Mac地址是否在可被允许的IP范围内<br/>
     * å¦‚果存在IP在可被允许的IP/Mac地址范围内,则返回true
     *
     * @return boolean
     */
    private boolean checkIpAddress(List<String> expectedList, List<String> serverList) {
        if (expectedList != null && expectedList.size() > 0) {
            if (serverList != null && serverList.size() > 0) {
                for (String expected : expectedList) {
                    if (serverList.contains(expected.trim())) {
                        return true;
                    }
                }
            }
            return false;
        } else {
            return true;
        }
    }
    /**
     * æ ¡éªŒå½“前服务器硬件(主板、CPU等)序列号是否在可允许范围内
     *
     * @return boolean
     */
    private boolean checkSerial(String expectedSerial, String serverSerial) {
        if (StringUtils.isNotBlank(expectedSerial)) {
            if (StringUtils.isNotBlank(serverSerial)) {
                if (expectedSerial.equals(serverSerial)) {
                    return true;
                }
            }
            return false;
        } else {
            return true;
        }
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/entity/LicenseCheckModel.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,62 @@
package org.jeecg.config.license.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
/**
 * @Author: lius
 * @ClassName LicenseCheckModel
 * @date 2024/11/2 16:00
 */
@ApiModel("设备信息实体类")
public class LicenseCheckModel implements Serializable {
    private static final long serialVersionUID = -2314678441082223148L;
    @ApiModelProperty("可被允许的IP地址")
    private List<String> ipAddress;
    @ApiModelProperty("可被允许的MAC地址")
    private List<String> macAddress;
    @ApiModelProperty("可被允许的CPU序列号")
    private String cpuSerial;
    @ApiModelProperty("可被允许的主板序列号")
    private String mainBoardSerial;
    public List<String> getIpAddress() {
        return ipAddress;
    }
    public void setIpAddress(List<String> ipAddress) {
        this.ipAddress = ipAddress;
    }
    public List<String> getMacAddress() {
        return macAddress;
    }
    public void setMacAddress(List<String> macAddress) {
        this.macAddress = macAddress;
    }
    public String getCpuSerial() {
        return cpuSerial;
    }
    public void setCpuSerial(String cpuSerial) {
        this.cpuSerial = cpuSerial;
    }
    public String getMainBoardSerial() {
        return mainBoardSerial;
    }
    public void setMainBoardSerial(String mainBoardSerial) {
        this.mainBoardSerial = mainBoardSerial;
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/license/entity/LicenseVerifyParam.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,67 @@
package org.jeecg.config.license.entity;
import io.swagger.annotations.ApiModelProperty;
/**
 * @Author: lius
 * @ClassName LicenseVerifyParam
 * @date 2024/11/2 16:00
 */
public class LicenseVerifyParam {
    @ApiModelProperty("证书subject")
    private String subject;
    @ApiModelProperty("公钥别称")
    private String publicAlias;
    @ApiModelProperty("访问公钥库的密码")
    private String storePass;
    @ApiModelProperty("证书生成路径")
    private String licensePath;
    @ApiModelProperty("密钥库存储路径")
    private String publicKeysStorePath;
    public String getSubject() {
        return subject;
    }
    public void setSubject(String subject) {
        this.subject = subject;
    }
    public String getPublicAlias() {
        return publicAlias;
    }
    public void setPublicAlias(String publicAlias) {
        this.publicAlias = publicAlias;
    }
    public String getStorePass() {
        return storePass;
    }
    public void setStorePass(String storePass) {
        this.storePass = storePass;
    }
    public String getLicensePath() {
        return licensePath;
    }
    public void setLicensePath(String licensePath) {
        this.licensePath = licensePath;
    }
    public String getPublicKeysStorePath() {
        return publicKeysStorePath;
    }
    public void setPublicKeysStorePath(String publicKeysStorePath) {
        this.publicKeysStorePath = publicKeysStorePath;
    }
}
lxzn-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
@@ -98,6 +98,7 @@
        filterChainDefinitionMap.put("/sys/getLoginQrcode/**", "anon"); //登录二维码
        filterChainDefinitionMap.put("/sys/getQrcodeToken/**", "anon"); //监听扫码
        filterChainDefinitionMap.put("/sys/checkAuth", "anon"); //授权接口排除
        filterChainDefinitionMap.put("/base/license/**", "anon"); //生成license和获取服务器硬件信息
        filterChainDefinitionMap.put("/", "anon");
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/CurrentElectricDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package org.jeecg.modules.mdc.dto;
import lombok.Data;
import java.util.Date;
/**
 * @author Lius
 * @date 2024/11/1 15:00
 */
@Data
public class CurrentElectricDto {
    /**
     * é‡‡é›†æ—¶é—´
     */
    private Date collectTime;
    /**
     * è®¾å¤‡ç¼–号
     */
    private String equipmentID;
    /**
     * dao解析数据使用
     */
    private String currentValue;
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalElectricJob.java
@@ -3,7 +3,7 @@
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.modules.mdc.dto.CurrentElectricHistoryDto;
import org.jeecg.modules.mdc.dto.CurrentElectricDto;
import org.jeecg.modules.mdc.dto.EquipmentMachiningHistoryDto;
import org.jeecg.modules.mdc.dto.MachineXYZHistoryDto;
import org.jeecg.modules.mdc.entity.Equipment;
@@ -54,13 +54,10 @@
    private IEquipmentElectricStatisticalService equipmentElectricStatisticalService;
    @Resource
    private ICurrentXYZHistoryService currentXYZHistoryService;
    private IEquipmentWorkLineService equipmentWorkLineService;
    @Resource
    private IMachineXYZHistoryService machineXYZHistoryService;
    @Resource
    private IEquipmentMachiningHistoryService equipmentMachiningHistoryService;
    private IEquipmentXYZService equipmentXYZService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
@@ -81,35 +78,38 @@
                List<DictModel> dictList = sysDictService.queryEnableDictItemsByCode(CommonConstant.AXIS_TYPE);
                if (dictList != null && !dictList.isEmpty()) {
                    for (Equipment equipment : equipmentList) {
                        if (equipment.getDrivetype().equals("SIEMENSOpcUa")) {
                            String saveTableName = equipment.getSavetablename();
                        Date lastDate = equipmentElectricStatisticalService.getMaxDate(equipment.getEquipmentid());
                        if (lastDate == null) {
                            Date minCollectTime = currentXYZHistoryService.getMinDate(equipment.getEquipmentid());
                                Date minCollectTime = equipmentWorkLineService.getMinDate(saveTableName);
                            if (minCollectTime == null) {
                                continue;
                            }
                            initDate = DateUtils.removeTime(minCollectTime);
                            } else {
                                initDate = DateUtils.plusTime(lastDate, 1);
                        }
                        for (DictModel dictModel : dictList) {
                            electricStatistical = new EquipmentElectricStatistical();
                            Integer axisType = Integer.parseInt(dictModel.getValue());
                            CurrentElectricHistoryDto currentElectricHistoryDto = currentXYZHistoryService.getMaxElectric(equipment.getEquipmentid(), axisType, initDate, DateUtils.plusTime(initDate, 1));
                            if (currentElectricHistoryDto == null || currentElectricHistoryDto.getEquipmentID() == null || currentElectricHistoryDto.getCollectTime() == null) {
                                initDate = DateUtils.plusTime(initDate, 1);
                                CurrentElectricDto currentElectricDto = equipmentWorkLineService.getMaxElectric(saveTableName, axisType, initDate, DateUtils.plusTime(initDate, 1));
                                if (currentElectricDto == null) {
                                continue;
                            }
                            electricStatistical.setAxistype(axisType);
                            electricStatistical.setEquipmentid(equipment.getEquipmentid());
                            electricStatistical.setEquipmentname(equipment.getEquipmentname());
                            electricStatistical.setElectrictime(currentElectricHistoryDto.getCollectTime());
                            electricStatistical.setElectricvalue(currentElectricHistoryDto.getCurrentValue());
                                electricStatistical.setElectrictime(currentElectricDto.getCollectTime());
                                electricStatistical.setElectricvalue(currentElectricDto.getCurrentValue());
                            electricStatistical.setCreatedate(initDate);
                            EquipmentMachiningHistoryDto machiningHistoryDto = equipmentMachiningHistoryService.getNearTimeSpindleLoad(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1), currentElectricHistoryDto.getCollectTime());
                                EquipmentMachiningHistoryDto machiningHistoryDto = equipmentWorkLineService.getNearTimeSpindleLoad(saveTableName, initDate, DateUtils.plusTime(initDate, 1), currentElectricDto.getCollectTime());
                            if (machiningHistoryDto != null) {
                                electricStatistical.setSpindlespeed(machiningHistoryDto.getSpindleSpeed());
                                electricStatistical.setSpindleload(machiningHistoryDto.getSpindleLoad());
                                electricStatistical.setSpindletime(machiningHistoryDto.getCollectTime());
                            }
                            MachineXYZHistoryDto machineXYZHistoryDto = machineXYZHistoryService.getNearAxisType(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1), currentElectricHistoryDto.getCollectTime());
                                MachineXYZHistoryDto machineXYZHistoryDto = equipmentXYZService.getNearAxisType(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1), currentElectricDto.getCollectTime());
                            if (machineXYZHistoryDto != null) {
                                electricStatistical.setAxistime(machineXYZHistoryDto.getCollectTime());
                                if (axisType == 1) {
@@ -128,6 +128,7 @@
                        }
                    }
                }
                }
                if(!resultList.isEmpty()) {
                    equipmentElectricStatisticalService.saveBatch(resultList);
                }
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/StatisticalSpindleJob.java
@@ -5,10 +5,7 @@
import org.jeecg.modules.mdc.dto.MachineXYZHistoryDto;
import org.jeecg.modules.mdc.entity.Equipment;
import org.jeecg.modules.mdc.entity.EquipmentSpindleStatistical;
import org.jeecg.modules.mdc.service.IEquipmentMachiningHistoryService;
import org.jeecg.modules.mdc.service.IEquipmentService;
import org.jeecg.modules.mdc.service.IEquipmentSpindleStatisticalService;
import org.jeecg.modules.mdc.service.IMachineXYZHistoryService;
import org.jeecg.modules.mdc.service.*;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.util.ThrowableUtil;
import org.jeecg.modules.quartz.entity.QuartzJob;
@@ -55,6 +52,12 @@
    @Resource
    private IMachineXYZHistoryService machineXYZHistoryService;
    @Resource
    private IEquipmentWorkLineService equipmentWorkLineService;
    @Resource
    private IEquipmentXYZService equipmentXYZService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        SysQuartzLog quartzLog = new SysQuartzLog();
@@ -72,17 +75,21 @@
                EquipmentSpindleStatistical spindleStatistical;
                List<EquipmentSpindleStatistical> resultList = new ArrayList<>();
                for (Equipment equipment : equipmentList) {
                    if (!equipment.getDrivetype().equals("CurrentState")) {
                        String saveTableName = equipment.getSavetablename();
                    Date lastDate = equipmentSpindleStatisticalService.getMaxDate(equipment.getEquipmentid());
                    if (lastDate == null) {
                        Date minCollectTime = equipmentMachiningHistoryService.getMinDate(equipment.getEquipmentid());
                            Date minCollectTime = equipmentWorkLineService.getMinDate(saveTableName);
                        if (minCollectTime == null) {
                            continue;
                        }
                        initDate = DateUtils.removeTime(minCollectTime);
                        } else {
                            initDate = DateUtils.plusTime(lastDate, 1);
                    }
                    spindleStatistical = new EquipmentSpindleStatistical();
                    EquipmentMachiningHistoryDto machiningHistoryDto = equipmentMachiningHistoryService.getMaxSpindleLoad(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1));
                        EquipmentMachiningHistoryDto machiningHistoryDto = equipmentWorkLineService.getMaxSpindleLoad(saveTableName, initDate, DateUtils.plusTime(initDate, 1));
                    if(machiningHistoryDto == null || machiningHistoryDto.getEquipmentID() == null || machiningHistoryDto.getCollectTime() == null) {
                        continue;
                    }
@@ -92,7 +99,7 @@
                    spindleStatistical.setEquipmentname(equipment.getEquipmentname());
                    spindleStatistical.setSpindleload(machiningHistoryDto.getSpindleLoad());
                    spindleStatistical.setSpindletime(machiningHistoryDto.getCollectTime());
                    MachineXYZHistoryDto machineXYZHistoryDto = machineXYZHistoryService.getNearAxisType(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1), machiningHistoryDto.getCollectTime());
                        MachineXYZHistoryDto machineXYZHistoryDto = equipmentXYZService.getNearAxisType(equipment.getEquipmentid(), initDate, DateUtils.plusTime(initDate, 1), machiningHistoryDto.getCollectTime());
                    if(machineXYZHistoryDto != null) {
                        spindleStatistical.setAxistime(machineXYZHistoryDto.getCollectTime());
                        spindleStatistical.setAxisx(machineXYZHistoryDto.getXMachine());
@@ -103,6 +110,7 @@
                    }
                    resultList.add(spindleStatistical);
                }
                }
                if (!resultList.isEmpty()) {
                    equipmentSpindleStatisticalService.saveBatch(resultList);
                }
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentWorklineMapper.java
@@ -4,7 +4,9 @@
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.mdc.dto.CurrentElectricDto;
import org.jeecg.modules.mdc.dto.EquipmentMachingDto;
import org.jeecg.modules.mdc.dto.EquipmentMachiningHistoryDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentDto;
import org.springframework.stereotype.Repository;
@@ -52,4 +54,16 @@
    @InterceptorIgnore(tenantLine = "1")
    Map<String, Object> getDataList(@Param("tableName") String saveTableName);
    @InterceptorIgnore(tenantLine = "1")
    Date getMinDate(@Param("tableName") String saveTableName);
    @InterceptorIgnore(tenantLine = "1")
    CurrentElectricDto getMaxElectric(@Param("tableName") String saveTableName, @Param("axisType") Integer axisType, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
    @InterceptorIgnore(tenantLine = "1")
    EquipmentMachiningHistoryDto getNearTimeSpindleLoad(@Param("tableName") String tableName, @Param("startDate")Date startDate, @Param("endDate")Date endDate, @Param("nearDate")Date nearDate);
    @InterceptorIgnore(tenantLine = "1")
    EquipmentMachiningHistoryDto getMaxSpindleLoad(@Param("tableName") String tableName, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentXYZMapper.java
@@ -2,7 +2,10 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.mdc.dto.MachineXYZHistoryDto;
import org.jeecg.modules.mdc.entity.EquipmentXYZ;
import java.util.Date;
/**
 * @author: LiuS
@@ -11,4 +14,6 @@
public interface EquipmentXYZMapper extends BaseMapper<EquipmentXYZ> {
    EquipmentXYZ findByEquipmentId(@Param("equipmentId") String equipmentId);
    MachineXYZHistoryDto getNearAxisType(@Param("equipmentId") String equipmentId, @Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("nearDate") Date nearDate);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentWorklineMapper.xml
@@ -25,4 +25,80 @@
    <select id="getDataList" resultType="java.util.Map">
        select top 1 [${tableName}].* from [${tableName}] order by CollectTime  desc
    </select>
    <select id="getMinDate" resultType="java.util.Date">
        SELECT TOP 1 CollectTime from [${tableName}] ORDER BY CollectTime ASC
    </select>
    <select id="getMaxElectric" resultType="org.jeecg.modules.mdc.dto.CurrentElectricDto">
        SELECT TOP 1
        <if test="axisType != null and axisType != '' and axisType == 1">
            ABS( actualCurrentX ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        <if test="axisType != null and axisType != '' and axisType == 2">
            ABS( actualCurrentY ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        <if test="axisType != null and axisType != '' and axisType == 3">
            ABS( actualCurrentZ ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        <if test="axisType != null and axisType != '' and axisType == 4">
            ABS( actualCurrentA ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        <if test="axisType != null and axisType != '' and axisType == 5">
            ABS( actualCurrentB ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        FROM
            [${tableName}]
        WHERE
        <if test="axisType != null and axisType != '' and axisType == 1">
            ABS( actualCurrentX ) = ( SELECT MAX ( ABS( actualCurrentX ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
        <if test="axisType != null and axisType != '' and axisType == 2">
            ABS( actualCurrentY ) = ( SELECT MAX ( ABS( actualCurrentY ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
        <if test="axisType != null and axisType != '' and axisType == 3">
            ABS( actualCurrentZ ) = ( SELECT MAX ( ABS( actualCurrentZ ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
        <if test="axisType != null and axisType != '' and axisType == 4">
            ABS( actualCurrentA ) = ( SELECT MAX ( ABS( actualCurrentA ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
        <if test="axisType != null and axisType != '' and axisType == 5">
            ABS( actualCurrentB ) = ( SELECT MAX ( ABS( actualCurrentB ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
    </select>
    <select id="getNearTimeSpindleLoad" resultType="org.jeecg.modules.mdc.dto.EquipmentMachiningHistoryDto">
        SELECT TOP 1
            CollectTime collectTime,
            spindleload,
            spindlespeed
        FROM
            [${tableName}]
        WHERE
            CollectTime BETWEEN #{startDate} AND #{endDate}
        ORDER BY
            ABS( DATEDIFF( SECOND, CollectTime, #{nearDate} ) )
    </select>
    <select id="getMaxSpindleLoad" resultType="org.jeecg.modules.mdc.dto.EquipmentMachiningHistoryDto">
        SELECT TOP 1
            CollectTime collectTime,
            EquipmentID equipmentID,
            spindleload spindleLoad,
            spindlespeed spindleSpeed
        FROM
            [${tableName}]
        WHERE
            ABS( spindleload ) = ( SELECT MAX ( ABS( spindleload ) ) spindleload FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentXYZMapper.xml
@@ -12,4 +12,22 @@
        ORDER BY
            CollectTime DESC
    </select>
    <select id="getNearAxisType" resultType="org.jeecg.modules.mdc.dto.MachineXYZHistoryDto">
        SELECT TOP 1
            CollectTime collectTime,
            EquipmentID equipmentID,
            Xmachine xMachine,
            Ymachine yMachine,
            Zmachine zMachine,
            Amachine aMachine,
            Bmachine bMachine
        FROM
            EquipmentXYZ
        WHERE
            EquipmentID = #{equipmentId}
          AND CollectTime BETWEEN #{startDate} AND #{endDate}
        ORDER BY
            ABS( DATEDIFF( SECOND, CollectTime, #{nearDate} ) )
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentWorkLineService.java
@@ -1,6 +1,8 @@
package org.jeecg.modules.mdc.service;
import org.jeecg.modules.mdc.dto.CurrentElectricDto;
import org.jeecg.modules.mdc.dto.EquipmentMachingDto;
import org.jeecg.modules.mdc.dto.EquipmentMachiningHistoryDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentDto;
import java.util.Date;
@@ -34,6 +36,7 @@
    /**
     * æŸ¥æ‰¾æ³•兰克设备运行的程序号
     *
     * @param drivetype
     * @param equipmentid
     * @param startTime
@@ -44,6 +47,7 @@
    /**
     * æŸ¥è¯¢æ³•拉克设备加工工件开始时间
     *
     * @param saveTableName
     * @param productCount
     * @return
@@ -52,6 +56,7 @@
    /**
     * æŸ¥è¯¢æ³•拉克设备加工工件结束时间
     *
     * @param saveTableName
     * @param productCount
     * @return
@@ -60,8 +65,49 @@
    /**
     * èŽ·å–è®¾å¤‡è¿è¡Œæ•°æ®
     *
     * @param saveTableName
     * @return
     */
    Map<String, Object> getDataList(String saveTableName);
    /**
     * æŸ¥è¯¢å•表第一条数据时间
     *
     * @param saveTableName
     * @return
     */
    Date getMinDate(String saveTableName);
    /**
     * æŸ¥è¯¢è½´æœ€å¤§ç”µæµ
     *
     * @param saveTableName
     * @param axisType
     * @param startDate
     * @param endDate
     * @return
     */
    CurrentElectricDto getMaxElectric(String saveTableName, Integer axisType, Date startDate, Date endDate);
    /**
     * æŸ¥è¯¢æ—¶é—´ç‚¹æœ€è¿‘的一条数据
     *
     * @param tableName
     * @param startDate
     * @param endDate
     * @param nearDate
     * @return
     */
    EquipmentMachiningHistoryDto getNearTimeSpindleLoad(String tableName, Date startDate, Date endDate, Date nearDate);
    /**
     * æŸ¥è¯¢æœ€å¤§ä¸»è½´è´Ÿè½½
     *
     * @param tableName
     * @param startDate
     * @param endDate
     * @return
     */
    EquipmentMachiningHistoryDto getMaxSpindleLoad(String tableName, Date startDate, Date endDate);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentXYZService.java
@@ -1,7 +1,10 @@
package org.jeecg.modules.mdc.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.mdc.dto.MachineXYZHistoryDto;
import org.jeecg.modules.mdc.entity.EquipmentXYZ;
import java.util.Date;
/**
 * @author: LiuS
@@ -11,4 +14,6 @@
    EquipmentXYZ getByEquipmentId(String equipmentId);
    EquipmentXYZ findByEquipmentId(String equipmentId);
    MachineXYZHistoryDto getNearAxisType(String equipmentId, Date startDate, Date endDate, Date nearDate);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentWorkLineServiceImpl.java
@@ -1,6 +1,8 @@
package org.jeecg.modules.mdc.service.impl;
import org.jeecg.modules.mdc.dto.CurrentElectricDto;
import org.jeecg.modules.mdc.dto.EquipmentMachingDto;
import org.jeecg.modules.mdc.dto.EquipmentMachiningHistoryDto;
import org.jeecg.modules.mdc.dto.MdcEquipmentDto;
import org.jeecg.modules.mdc.mapper.EquipmentWorklineMapper;
import org.jeecg.modules.mdc.service.IEquipmentWorkLineService;
@@ -86,6 +88,30 @@
        }
    }
    @Override
    public Date getMinDate(String saveTableName) {
        try {
            return equipmentWorkLineMapper.getMinDate(saveTableName);
        } catch (Exception e) {
            return null;
        }
    }
    @Override
    public CurrentElectricDto getMaxElectric(String saveTableName, Integer axisType, Date startDate, Date endDate) {
        return equipmentWorkLineMapper.getMaxElectric(saveTableName, axisType, startDate, endDate);
    }
    @Override
    public EquipmentMachiningHistoryDto getNearTimeSpindleLoad(String tableName, Date startDate, Date endDate, Date nearDate) {
        return equipmentWorkLineMapper.getNearTimeSpindleLoad(tableName, startDate, endDate, nearDate);
    }
    @Override
    public EquipmentMachiningHistoryDto getMaxSpindleLoad(String tableName, Date startDate, Date endDate) {
        return equipmentWorkLineMapper.getMaxSpindleLoad(tableName, startDate, endDate);
    }
    private List<EquipmentMachingDto> convertData(List<Map<String, Object>> list) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        List<EquipmentMachingDto> dto = new ArrayList<>();
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentXYZServiceImpl.java
@@ -2,10 +2,13 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.mdc.dto.MachineXYZHistoryDto;
import org.jeecg.modules.mdc.entity.EquipmentXYZ;
import org.jeecg.modules.mdc.mapper.EquipmentXYZMapper;
import org.jeecg.modules.mdc.service.IEquipmentXYZService;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
 * @author: LiuS
@@ -22,4 +25,9 @@
    public EquipmentXYZ findByEquipmentId(String equipmentId) {
        return this.baseMapper.findByEquipmentId(equipmentId);
    }
    @Override
    public MachineXYZHistoryDto getNearAxisType(String equipmentId, Date startDate, Date endDate, Date nearDate) {
        return this.baseMapper.getNearAxisType(equipmentId, startDate, endDate, nearDate);
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOeeInfoServiceImpl.java
@@ -105,6 +105,9 @@
            }
            queryWrapper.orderByAsc(MdcEquipment::getEquipmentName);
            List<MdcEquipment> equipmentList = mdcEquipmentService.list(queryWrapper);
            vo.setStartTime(DateUtils.format(DateUtils.toDate(vo.getStartTime(), DateUtils.STRDATE), DateUtils.STR_DATE));
            vo.setEndTime(DateUtils.format(DateUtils.toDate(vo.getEndTime(), DateUtils.STRDATE), DateUtils.STR_DATE));
            //查询oee数据
            List<MdcOeeInfo> oeeList = this.baseMapper.oeeList(vo);
            //数据处理
@@ -134,7 +137,7 @@
                    BigDecimal oeeRate = BigDecimal.ZERO;
                    if (!mdcOeeInfoList.isEmpty()) {
                        BigDecimal count = mdcOeeInfoList.stream().map(MdcOeeInfo::getOeeRate).reduce(BigDecimal.ZERO, BigDecimal::add);
                        oeeRate = count.divide(new BigDecimal(mdcOeeInfoList.size()), 2, RoundingMode.HALF_UP);
                        oeeRate = count.divide(new BigDecimal(mdcOeeInfoList.size()), 4, RoundingMode.HALF_UP);
                        mdcOeeResultDto.setOeeRate(oeeRate);
                    }
                    long rate = oeeRate.multiply(new BigDecimal("100")).longValue();
@@ -190,8 +193,8 @@
                    .eq(MdcProductDayschedule::getEquipmentId, equipment.getEquipmentid()));
            if (productDayScheduleList != null && !productDayScheduleList.isEmpty()) {
                MdcProductDayschedule mdcProductDayschedule;
                MdcOeeInfo mdcOeeInfo = new MdcOeeInfo();
                for (MdcShiftSub mdcShiftSub : mdcShiftSubList) {
                    MdcOeeInfo mdcOeeInfo = new MdcOeeInfo();
                    String id = mdcShiftSub.getId();
                    if (productDayScheduleList.stream().anyMatch(productDayschedule -> productDayschedule.getOrderId().substring(8, 10).equals(id))) {
                        mdcOeeInfo.setEquipmentId(equipment.getEquipmentid());
@@ -241,11 +244,13 @@
                            continue;
                        }
                        mdcOeeInfo.setScheduleNum(mdcComponentInfo.getScheduleNum());
                        BigDecimal oeeRate = mdcOeeInfo.getProcessLong().multiply(new BigDecimal(mdcOeeInfo.getPlanNum())).multiply(new BigDecimal(mdcOeeInfo.getQualityNum()))
                                        .divide(mdcEquipmentStatisticalShiftInfo.getTotalLong(), 2, RoundingMode.HALF_UP)
                                        .divide(new BigDecimal(mdcOeeInfo.getScheduleNum()), 2, RoundingMode.HALF_UP)
                                        .divide(new BigDecimal(mdcOeeInfo.getCompleteNum()), 2, RoundingMode.HALF_UP);
                        BigDecimal oeeRate = BigDecimal.ZERO;
                        if (!mdcOeeInfo.getCompleteNum().equals(0)) {
                            oeeRate = mdcOeeInfo.getProcessLong().multiply(new BigDecimal(mdcOeeInfo.getPlanNum())).multiply(new BigDecimal(mdcOeeInfo.getQualityNum()))
                                    .divide(mdcEquipmentStatisticalShiftInfo.getTotalLong(), 4, RoundingMode.HALF_UP)
                                    .divide(new BigDecimal(mdcOeeInfo.getScheduleNum()), 4, RoundingMode.HALF_UP)
                                    .divide(new BigDecimal(mdcOeeInfo.getCompleteNum()), 4, RoundingMode.HALF_UP);
                        }
                        mdcOeeInfo.setOeeRate(oeeRate);
                        result.add(mdcOeeInfo);
                    }
@@ -256,5 +261,4 @@
            this.saveBatch(result);
        }
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/screen/service/impl/MdcLargeScreenServiceImpl.java
@@ -125,7 +125,7 @@
                equipmentRateDto.setEquipmentName(mdcEfficiencyDto.getEquipmentName());
                equipmentRateDto.setOpenRate(mdcEfficiencyDto.getOpenRate().multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
                equipmentRateDto.setUtilizationRate(mdcEfficiencyDto.getUtilizationRate().multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
                if (!equipmentRateDto.getOpenRate().equals(BigDecimal.ZERO) || !equipmentRateDto.getUtilizationRate().equals(BigDecimal.ZERO)) {
                if (!(equipmentRateDto.getOpenRate().compareTo(BigDecimal.ZERO) == 0) && !(equipmentRateDto.getUtilizationRate().compareTo(BigDecimal.ZERO) == 0)) {
                    result.add(equipmentRateDto);
                }
            }
@@ -149,7 +149,7 @@
                meu.setDate(new StringBuilder(mdcEfficiencyDto.getTheDate().substring(4, 8)).insert(2, "-").toString());
                BigDecimal equipmentCount = mdcLargeScreenMapper.findEquipmentCount(yesterday);
                meu.setUtilizationRate(mdcEfficiencyDto.getProcessLong().divide(equipmentCount.multiply(new BigDecimal("86400")), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
                if (!meu.getUtilizationRate().equals(BigDecimal.ZERO)) {
                if (!(meu.getUtilizationRate().compareTo(BigDecimal.ZERO) == 0)) {
                    result.add(meu);
                }
            }
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/config/license/LicenseCreator.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,98 @@
package org.jeecg.config.license;
import de.schlichtherle.license.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jeecg.config.license.entity.CustomLicenseManager;
import javax.security.auth.x500.X500Principal;
import java.io.File;
import java.text.MessageFormat;
import java.util.prefs.Preferences;
/**
 * @Author: ljh
 * @ClassName LicenseCreator
 * @Description TODO
 * @date 2022/12/9 11:14
 * @Version 1.0
 */
public class LicenseCreator {
    private static Logger logger = LogManager.getLogger(LicenseCreator.class);
    private final static X500Principal DEFAULT_HOLDER_AND_ISSUER = new X500Principal("CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN");
    private LicenseCreatorParam param;
    public LicenseCreator(LicenseCreatorParam param) {
        this.param = param;
    }
    /**
     * ç”ŸæˆLicense证书
     *
     * @return boolean
     */
    public boolean generateLicense() {
        try {
            LicenseManager licenseManager = new CustomLicenseManager(initLicenseParam());
            LicenseContent licenseContent = initLicenseContent();
            licenseManager.store(licenseContent, new File(param.getLicensePath()));
            return true;
        } catch (Exception e) {
            logger.error(MessageFormat.format("证书生成失败:{0}", param), e);
            return false;
        }
    }
    /**
     * åˆå§‹åŒ–证书生成参数
     *
     * @return de.schlichtherle.license.LicenseParam
     */
    private LicenseParam initLicenseParam() {
        Preferences preferences = Preferences.userNodeForPackage(LicenseCreator.class);
        //设置对证书内容加密的秘钥
        CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());
        KeyStoreParam privateStoreParam = new CustomKeyStoreParam(LicenseCreator.class
                , param.getPrivateKeysStorePath()
                , param.getPrivateAlias()
                , param.getStorePass()
                , param.getKeyPass());
        LicenseParam licenseParam = new DefaultLicenseParam(param.getSubject()
                , preferences
                , privateStoreParam
                , cipherParam);
        return licenseParam;
    }
    /**
     * è®¾ç½®è¯ä¹¦ç”Ÿæˆæ­£æ–‡ä¿¡æ¯
     *
     * @return de.schlichtherle.license.LicenseContent
     */
    private LicenseContent initLicenseContent() {
        LicenseContent licenseContent = new LicenseContent();
        licenseContent.setHolder(DEFAULT_HOLDER_AND_ISSUER);
        licenseContent.setIssuer(DEFAULT_HOLDER_AND_ISSUER);
        licenseContent.setSubject(param.getSubject());
        licenseContent.setIssued(param.getIssuedTime());
        licenseContent.setNotBefore(param.getIssuedTime());
        licenseContent.setNotAfter(param.getExpiryTime());
        licenseContent.setConsumerType(param.getConsumerType());
        licenseContent.setConsumerAmount(param.getConsumerAmount());
        licenseContent.setInfo(param.getDescription());
        //扩展校验服务器硬件信息
        licenseContent.setExtra(param.getLicenseCheckModel());
        return licenseContent;
    }
}
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/config/license/LicenseCreatorParam.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,155 @@
package org.jeecg.config.license;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.jeecg.config.license.entity.LicenseCheckModel;
import java.io.Serializable;
import java.util.Date;
/**
 * @Author: lius
 * @ClassName LicenseCreatorParam
 * @date 2024/11/2 17:02
 */
@ApiModel("生成证书实体类")
public class LicenseCreatorParam implements Serializable {
    private static final long serialVersionUID = 2832129012982731724L;
    @ApiModelProperty("证书subject")
    private String subject;
    @ApiModelProperty("密钥别称")
    private String privateAlias;
    @ApiModelProperty("密钥密码")
    private String keyPass;
    @ApiModelProperty("访问秘钥库的密码")
    private String storePass;
    @ApiModelProperty("证书生成路径")
    private String licensePath;
    @ApiModelProperty("密钥库存储路径")
    private String privateKeysStorePath;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("证书生效时间")
    private Date issuedTime = new Date();
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("证书失效时间")
    private Date expiryTime;
    @ApiModelProperty("用户类型")
    private String consumerType = "user";
    @ApiModelProperty("用户数量")
    private Integer consumerAmount = 1;
    @ApiModelProperty("描述信息")
    private String description = "";
    @ApiModelProperty("额外的服务器硬件校验信息")
    private LicenseCheckModel licenseCheckModel;
    public String getSubject() {
        return subject;
    }
    public void setSubject(String subject) {
        this.subject = subject;
    }
    public String getPrivateAlias() {
        return privateAlias;
    }
    public void setPrivateAlias(String privateAlias) {
        this.privateAlias = privateAlias;
    }
    public String getKeyPass() {
        return keyPass;
    }
    public void setKeyPass(String keyPass) {
        this.keyPass = keyPass;
    }
    public String getStorePass() {
        return storePass;
    }
    public void setStorePass(String storePass) {
        this.storePass = storePass;
    }
    public String getLicensePath() {
        return licensePath;
    }
    public void setLicensePath(String licensePath) {
        this.licensePath = licensePath;
    }
    public String getPrivateKeysStorePath() {
        return privateKeysStorePath;
    }
    public void setPrivateKeysStorePath(String privateKeysStorePath) {
        this.privateKeysStorePath = privateKeysStorePath;
    }
    public Date getIssuedTime() {
        return issuedTime;
    }
    public void setIssuedTime(Date issuedTime) {
        this.issuedTime = issuedTime;
    }
    public Date getExpiryTime() {
        return expiryTime;
    }
    public void setExpiryTime(Date expiryTime) {
        this.expiryTime = expiryTime;
    }
    public String getConsumerType() {
        return consumerType;
    }
    public void setConsumerType(String consumerType) {
        this.consumerType = consumerType;
    }
    public Integer getConsumerAmount() {
        return consumerAmount;
    }
    public void setConsumerAmount(Integer consumerAmount) {
        this.consumerAmount = consumerAmount;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public LicenseCheckModel getLicenseCheckModel() {
        return licenseCheckModel;
    }
    public void setLicenseCheckModel(LicenseCheckModel licenseCheckModel) {
        this.licenseCheckModel = licenseCheckModel;
    }
}
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/base/controller/LicenseController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,96 @@
package org.jeecg.modules.base.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.config.license.*;
import org.jeecg.config.license.entity.LicenseCheckModel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
 * @Author: lius
 * @ClassName LicenseController
 * @date 2024/11/2 17:35
 */
@Slf4j
@Api(tags = "license证书")
@RestController
@RequestMapping("/base/license")
public class LicenseController {
    /**
     * è¯ä¹¦ç”Ÿæˆè·¯å¾„
     */
    @Value("${license.licensePath}")
    private String licensePath;
    /**
    * @Author: lius
    * @Description: èŽ·å–æœåŠ¡å™¨ç¡¬ä»¶ä¿¡æ¯
    * @DateTime: 17:35 2024/11/2
    * @Params:  osName ç³»ç»Ÿç±»åž‹ windows或linux
    * @Return
    */
    @AutoLog(value = "获取服务器硬件信息")
    @ApiOperation("获取服务器硬件信息")
    @GetMapping("/getServerInfos/{osName}")
    public LicenseCheckModel getServerInfos(@PathVariable String osName) {
        //操作系统类型
        if (StringUtils.isBlank(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 LinuxServerInfos();
        }
        return abstractServerInfos.getServerInfos();
    }
    /**
    * @Author: lius
    * @Description: ç”Ÿæˆè¯ä¹¦
    * @DateTime: 17:35 2024/11/2
    */
    @AutoLog(value = "生成证书")
    @ApiOperation("生成证书")
    @PostMapping("/generateLicense")
    public Map<String, Object> generateLicense(@RequestBody LicenseCreatorParam param) {
        Map<String, Object> resultMap = new HashMap<>(2);
        if (StringUtils.isBlank(param.getLicensePath())) {
            param.setLicensePath(licensePath);
        }
        LicenseCreator licenseCreator = new LicenseCreator(param);
        boolean result = licenseCreator.generateLicense();
        if (result) {
            resultMap.put("result", "ok");
            resultMap.put("msg", param);
        } else {
            resultMap.put("result", "error");
            resultMap.put("msg", "证书文件生成失败!");
        }
        return resultMap;
    }
}
lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml
@@ -126,15 +126,16 @@
        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
      datasource:
        master:
          url: jdbc:sqlserver://192.168.124.118:1433;databasename=LXZN_TEST_YITUO
          url: jdbc:sqlserver://localhost:1433;databasename=LXZN_MDC_YITUO
#          url: jdbc:sqlserver://192.168.124.118:1433;databasename=LXZN_TEST_YITUO
          username: sa
          password: 123
          driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
        mesSoAdb:
          url: jdbc:sqlserver://192.168.124.118:1433;databasename=SOADB
          username: sa
          password: 123
          driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
#        mesSoAdb:
#          url: jdbc:sqlserver://192.168.124.118:1433;databasename=SOADB
#          username: sa
#          password: 123
#          driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
  #redis é…ç½®
  redis:
    database: 0
@@ -296,3 +297,10 @@
  namespace: http://service.server.webservice.example.com
  statusMethod: equipmentStatus
  rateMethod: equipmentRate
license:
  subject: license_lyyt
  publicAlias: publicCert
  storePass: lxzn1688
  licensePath: F:/license/license.lic
  publicKeysStorePath: F:/license/publicCerts.keystore
  uploadPath: F:/LicenseDemo/