|
@@ -7,14 +7,26 @@ import com.ruoyi.business.entity.MachineLicenseAcquireReqDto;
|
|
|
import com.ruoyi.business.service.LicenseService;
|
|
|
import com.ruoyi.business.util.DESUtils;
|
|
|
import com.ruoyi.business.util.SM2Utils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.context.MessageSource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+
|
|
|
@Service
|
|
|
public class licenseServiceImpl implements LicenseService {
|
|
|
|
|
|
public static int DELAY_DAY = 15 ;
|
|
|
|
|
|
+ @Value("${jsPath}")
|
|
|
+ private String jsPath;
|
|
|
+
|
|
|
+ public licenseServiceImpl(MessageSource messageSource) {
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String createLicense(String type,String licenseCode) {
|
|
|
if("DZ".equals(type)){
|
|
@@ -65,6 +77,32 @@ public class licenseServiceImpl implements LicenseService {
|
|
|
* @return
|
|
|
*/
|
|
|
private String createLicenseForSP(String licenseCode) {
|
|
|
- return null;
|
|
|
+ try {
|
|
|
+ DateTime endTime = DateUtil.offset(DateUtil.date(), DateField.DAY_OF_YEAR, DELAY_DAY);
|
|
|
+ String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ System.out.println("到期时间:" + endTimeStr);
|
|
|
+ String command = "node".concat(" ").concat(jsPath)
|
|
|
+ .concat(" ").concat(licenseCode).concat(" ").concat(endTimeStr);
|
|
|
+ // 启动Node.js进程
|
|
|
+ Process process = Runtime.getRuntime().exec(command);
|
|
|
+
|
|
|
+ // 读取Node.js进程的输出
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
|
+ String line;
|
|
|
+ char buffer[] = new char[1024];
|
|
|
+ int byteRead;
|
|
|
+ StringBuilder result = new StringBuilder();
|
|
|
+ while ((byteRead =reader.read(buffer)) != -1) {
|
|
|
+ result.append(buffer,0,byteRead);
|
|
|
+ }
|
|
|
+ System.out.println("Node.js输出:" + result);
|
|
|
+ // 等待进程结束
|
|
|
+ int exitCode = process.waitFor();
|
|
|
+ System.out.println("Exited with code: " + exitCode);
|
|
|
+ return result.toString();
|
|
|
+ } catch (IOException | InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|