Browse Source

添加审批代码

juxin_zhenghao 1 week ago
parent
commit
d9b9995c97

+ 1 - 1
pom.xml

@@ -179,7 +179,7 @@
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <version>${spring-boot.version}</version>
                 <configuration>
-                    <mainClass>com.friday.manager.ManagerApplication</mainClass>
+                    <mainClass>com.ruoyi.business.Main</mainClass>
                     <executable>true</executable>
                     <layout>ZIP</layout>
                     <excludeGroupIds>

+ 1 - 1
src/main/java/com/ruoyi/business/controller/LicenseController.java

@@ -17,7 +17,7 @@ public class LicenseController {
     @GetMapping("/create")
     public String createLicenseAAA(@RequestParam(value = "type") String type,
     @RequestParam(value = "machineCode") String machineCode) {
-       return licenseService.createLicense(type,machineCode);
+       return licenseService.createLicense(type.toUpperCase(),machineCode);
     }
 
 }

+ 39 - 1
src/main/java/com/ruoyi/business/service/impl/licenseServiceImpl.java

@@ -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;
+        }
     }
 }

+ 3 - 0
src/main/resources/application.yml

@@ -1,5 +1,8 @@
 server:
   port: 9623
 
+jsPath:  E:\workspace\jx\workSpace\approval\ApprovalHelper_key\cl.js
+#jsPath:   /my/ApprovalHelper_key/cl.js
+