smart-man-boot/pom.xml
@@ -134,16 +134,7 @@ <artifactId>smart-starter-social</artifactId> <version>1.0.0</version> </dependency> <!-- --> <!-- --> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-ui</artifactId> @@ -397,6 +388,13 @@ <!--<version>1.1.0-SNAPSHOT</version>--> <version>1.0.4</version> </dependency> <!--åæå¯é¥è®¤è¯--> <dependency> <groupId>com.qianwen</groupId> <artifactId>license-common</artifactId> <version>1.0.0</version> </dependency> <!-- å¾çå缩 --> <dependency> <groupId>net.coobird</groupId> @@ -511,6 +509,14 @@ <artifactId>jfreechart</artifactId> <version>1.5.5</version> </dependency> <!--lincenseéªè¯--> <dependency> <groupId>de.schlichtherle.truelicense</groupId> <artifactId>truelicense-core</artifactId> <version>1.33</version> </dependency> </dependencies> <build> smart-man-boot/src/main/java/com/qianwen/smartman/common/config/InterceptorConfig.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,19 @@ package com.qianwen.smartman.common.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.qianwen.smartman.common.interceptor.LicenseCheckInterceptor; @Configuration public class InterceptorConfig implements WebMvcConfigurer{ @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LicenseCheckInterceptor()); } } smart-man-boot/src/main/java/com/qianwen/smartman/common/interceptor/LicenseCheckInterceptor.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,39 @@ package com.qianwen.smartman.common.interceptor; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import com.alibaba.fastjson.JSON; import com.qianwen.license.common.LicenseVerify; /** * licenseæ ¡éªæ¦æª */ public class LicenseCheckInterceptor extends HandlerInterceptorAdapter{ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { LicenseVerify licenseVerify = new LicenseVerify(); //æ ¡éªè¯ä¹¦æ¯å¦ææ boolean verifyResult = licenseVerify.verify(); if(verifyResult){ return true; }else{ response.setContentType("application/json;charset=utf8"); response.setCharacterEncoding("utf-8"); Map<String,String> result = new HashMap<>(1); result.put("success", "false"); result.put("msg","æ¨çè¯ä¹¦æ æï¼è¯·æ ¸æ¥æå¡å¨æ¯å¦å徿ææéæ°ç³è¯·è¯ä¹¦ï¼"); response.getWriter().write(JSON.toJSONString(result));//throw new ServiceException("æ¨çè¯ä¹¦æ æï¼è¯·æ ¸æ¥æå¡å¨æ¯å¦å徿ææéæ°ç³è¯·è¯ä¹¦ï¼"); return false; } } } smart-man-boot/src/main/java/com/qianwen/smartman/common/license/LicenseWrapper.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,27 @@ package com.qianwen.smartman.common.license; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONValidator; import com.qianwen.license.common.LicenseExtraModel; import com.qianwen.license.common.LicenseVerify; @Component public class LicenseWrapper { //@Autowired //private LicenseVerify licenseVerify; public long getWorkstationAmount() { LicenseVerify licenseVerify = new LicenseVerify(); LicenseExtraModel model = (LicenseExtraModel)licenseVerify.getContent().getExtra(); if(JSONValidator.from(model.getExtData()).validate()) { JSONObject jsonObj = JSONObject.parseObject(model.getExtData()) ; return jsonObj.getLong("workstationAmount"); }else { return 0; } } } smart-man-boot/src/main/java/com/qianwen/smartman/common/runner/InitRunner.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,65 @@ package com.qianwen.smartman.common.runner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; import com.qianwen.license.common.LicenseVerify; import com.qianwen.license.common.LicenseVerifyParam; @Component public class InitRunner implements ApplicationRunner { private static final Logger log = LoggerFactory.getLogger(InitRunner.class); @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 run(ApplicationArguments args) throws Exception { //å®è£ è¯ä¹¦ initLicense(); } void initLicense() { 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); log.info("++++++++ è¯ä¹¦å®è£ ç»æ ++++++++"); } } smart-man-boot/src/main/java/com/qianwen/smartman/modules/smis/service/impl/WorkstationServiceImpl.java
@@ -29,6 +29,7 @@ import com.alibaba.excel.write.merge.AbstractMergeStrategy; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -42,10 +43,11 @@ import com.qianwen.core.mp.support.Query; import com.qianwen.core.oss.model.BladeFile; import com.qianwen.core.secure.utils.AuthUtil; import com.qianwen.core.tool.utils.CollectionUtil; import com.qianwen.core.tool.utils.DateUtil; import com.qianwen.core.tool.utils.Func; import com.qianwen.core.tool.utils.StringUtil; import com.qianwen.license.common.LicenseExtraModel; import com.qianwen.license.common.LicenseVerify; import com.qianwen.smartman.common.cache.DictCache; import com.qianwen.smartman.common.cache.cps.WorkstationCache; import com.qianwen.smartman.common.constant.CalendarConstant; @@ -59,6 +61,7 @@ import com.qianwen.smartman.common.enums.DictEnum; import com.qianwen.smartman.common.enums.StatusType; import com.qianwen.smartman.common.enums.WcsDataTypeEnums; import com.qianwen.smartman.common.license.LicenseWrapper; import com.qianwen.smartman.common.mqtt.MqttMessageSender; import com.qianwen.smartman.common.utils.Lambda; import com.qianwen.smartman.common.utils.MessageUtils; @@ -147,6 +150,8 @@ private MqttMessageSender mqttMsgSender; @Autowired private WorkstationDatapointsService wsDpService; @Autowired private LicenseWrapper licenseWrapper; private final String NAME = "é»è®¤å·¥ä½å°"; private final Integer SORT = 1; @@ -186,6 +191,9 @@ @Override @Transactional(rollbackFor = {Exception.class}) public WorkstationVO submit(WorkstationSubmitVO workstationSubmitVO) { checkLicenseCount(); checkWorkstation(workstationSubmitVO); if (Func.isEmpty(workstationSubmitVO.getId())) { checkUnableWorkstation(workstationSubmitVO); @@ -229,6 +237,18 @@ } return workstationVO; } void checkLicenseCount() { Wrapper<Workstation> wrapper = Wrappers.lambdaQuery(Workstation.class).eq(Workstation::getIsDeleted, 0); Long count = workstationMapper.selectCount(wrapper); Long machineAmount = licenseWrapper.getWorkstationAmount(); if(count >= machineAmount) { throw new ServiceException("工使°è¶ è¿è®¸å¯ä¸éæ°:"+ machineAmount); } } /* private void submitWorkstationFtpDirectory(WorkstationSubmitVO workstationSubmitVO, Workstation workstation) { if (Func.isEmpty(workstationSubmitVO.getId()) && Func.isNotEmpty(workstationSubmitVO.getFtpDirectoryType())) { smart-man-boot/src/main/java/com/qianwen/smartman/modules/workinghour/controller/LicenseTestController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,40 @@ package com.qianwen.smartman.modules.workinghour.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import com.qianwen.core.boot.ctrl.BladeController; import com.qianwen.core.scanner.modular.stereotype.ApiResource; import com.qianwen.core.tenant.annotation.NonDS; import com.qianwen.core.tool.api.R; import com.qianwen.license.common.LicenseExtraModel; import com.qianwen.license.common.LicenseVerify; import de.schlichtherle.license.LicenseContent; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Api(value = "å·¥æ¶åæ", tags = {"å·¥æ¶åæ"}) @RestController @ApiResource({"test"}) @NonDS @Validated public class LicenseTestController extends BladeController { private Logger log = LoggerFactory.getLogger(this.getClass()); @GetMapping({"/licmcount"}) @ApiOperation("æµè¯ææ") public R<Object> licmcount() { LicenseVerify licenseVerify = new LicenseVerify(); LicenseContent model = licenseVerify.getContent(); return R.data(model.getExtra()); } } smart-man-boot/src/main/java/com/qianwen/smartman/modules/workinghour/controller/PartWorkHourController.java
@@ -68,7 +68,7 @@ try { return R.data(partWorkingHourExportService.export(id)); } catch (Exception e) { log.error("导åºå ¬å¼æ°æ®é误",e); log.error("导åºå ¬æ¶æ°æ®é误",e); return R.fail(e.getMessage()); } smart-man-boot/src/main/resources/application.yml
@@ -17,6 +17,12 @@ name: smartman-api banner: location: classpath:smartbanner.txt resources: static-locations: static thymeleaf: cache: false mvc: static-path-pattern: classpath:/static/** redis: ##redis åæºç¯å¢é ç½® host: ${redis.host} @@ -275,6 +281,7 @@ - /blade-cps/group/groupWorkstation/jimu - /blade-fms/order/process/issued - /blade-cps/test/** - /test/* #ææè®¤è¯é ç½® auth: - method: ALL @@ -349,36 +356,12 @@ - FlowMapper - SuperNewCollectMapper # rocketmq é 置项ï¼å¯¹åº RocketMQProperties é 置类 rocketmq: name-server: ${rocketmq-name-server} # RocketMQ Namesrv # Producer é 置项 producer: group: masterlink-default-producer-group # é»è®¤ç产è åç»ï¼æå¥½ä½¿ç¨åèªæç¡®åç» send-message-timeout: 3000 # åéæ¶æ¯è¶ æ¶æ¶é´ï¼åä½ï¼æ¯«ç§ãé»è®¤ä¸º 3000 ã compress-message-body-threshold: 4096 # æ¶æ¯å缩éå¼ï¼å½æ¶æ¯ä½ç大å°è¶ è¿è¯¥éå¼åï¼è¿è¡æ¶æ¯å缩ãé»è®¤ä¸º 4 * 1024B max-message-size: 4194304 # æ¶æ¯ä½çæå¤§å 许大å°ããé»è®¤ä¸º 4 * 1024 * 1024B retry-times-when-send-failed: 2 # 忥åéæ¶æ¯æ¶ï¼å¤±è´¥éè¯æ¬¡æ°ãé»è®¤ä¸º 2 次ã retry-times-when-send-async-failed: 2 # 弿¥åéæ¶æ¯æ¶ï¼å¤±è´¥éè¯æ¬¡æ°ãé»è®¤ä¸º 2 次ã retry-next-server: false # åéæ¶æ¯ç» Broker æ¶ï¼å¦æåéå¤±è´¥ï¼æ¯å¦éè¯å¦å¤ä¸å° Broker ãé»è®¤ä¸º false enable-msg-trace: true # æ¯å¦å¼å¯æ¶æ¯è½¨è¿¹åè½ãé»è®¤ä¸º true å¼å¯ã customized-trace-topic: BLADE_RMQ_SYS_TRACE_TOPIC # èªå®ä¹æ¶æ¯è½¨è¿¹ç Topic ãé»è®¤ä¸º RMQ_SYS_TRACE_TOPIC ã message: posting: workstation-aggregate: topic: workstation-aggregate-topic consumer: workstation-aggregate-comsumer --- spring: resources: static-locations: static thymeleaf: cache: false mvc: static-path-pattern: classpath:/static/** license: subject: user #ä¸»ä½ - 注æä¸»ä½è¦ä¸çæè¯ä¹¦ç主ä½ä¸è´ä¸è´ï¼ä¸ç¶éªè¯éè¿ä¸äº publicAlias: publiccert #å ¬é¥å«ç§° storePass: a1b2c3 #访é®å ¬é¥åºçå¯ç licensePath: D:\lictest\ctest.lic #licenseä½ç½® publicKeysStorePath: D:\lictest\publicCerts.store #å ¬é¥ä½ç½® forest: bean-id: config0 # å¨springä¸ä¸æä¸beançid, é»è®¤å¼ä¸ºforestConfiguration backend: okhttp3 # å端HTTP APIï¼ okhttp3 ãæ¯æ`okhttp3`/`httpclient`ã