From 660d4a42f88b0575f27c1d167028ee5b7abb54e8 Mon Sep 17 00:00:00 2001 From: liuchen864 <23082234@qq.com> Date: Tue, 19 Mar 2024 11:23:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/base/CommandController.java | 65 +++++++----------- .../web/controller/base/ShellController.java | 67 ++++++++----------- .../src/main/resources/application-test.yml | 40 +++++------ .../system/service/LinuxAccessService.java | 13 ++-- 4 files changed, 80 insertions(+), 105 deletions(-) diff --git a/win-admin/src/main/java/com/win/web/controller/base/CommandController.java b/win-admin/src/main/java/com/win/web/controller/base/CommandController.java index d603518..ffa28a6 100644 --- a/win-admin/src/main/java/com/win/web/controller/base/CommandController.java +++ b/win-admin/src/main/java/com/win/web/controller/base/CommandController.java @@ -1,16 +1,11 @@ package com.win.web.controller.base; -import com.alibaba.fastjson2.JSONObject; -import com.jcraft.jsch.JSchException; import com.win.common.annotation.Log; import com.win.common.constant.HttpStatus; import com.win.common.core.domain.AjaxResult; import com.win.common.enums.BusinessType; import com.win.common.utils.ProfileUtil; -import com.win.common.utils.command.CommandUtil; -import com.win.common.utils.shell.ShellVo; import com.win.system.service.LinuxAccessService; -import com.win.web.config.ShellConfig; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -70,7 +65,7 @@ public class CommandController { } List activeProfile = ProfileUtil.getActiveProfile(); //dev环境不校验签名 - if(!activeProfile.contains("dev") && !StringUtils.equals(sign, computeSign.toUpperCase())) { + if(/*!activeProfile.contains("dev") && */!StringUtils.equals(sign, computeSign.toUpperCase())) { return AjaxResult.error(HttpStatus.SIGN_ERROR, "签名不正确"); } Method method = this.getClass().getMethod(interfaceName, String.class); @@ -78,111 +73,103 @@ public class CommandController { } public AjaxResult poreceipt(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "purchaseorder/poreceipt/"); + return linuxAccessService.executeCommand(body, "purchaseorder/poreceipt/", "dsPoreceiver"); } public AjaxResult projectdetail(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "project/projectdetail/"); + return linuxAccessService.executeCommand(body, "project/projectdetail/", "dsSearchCondition"); } public AjaxResult itemmaster(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "items/itemmaster/"); + return linuxAccessService.executeCommand(body, "items/itemmaster/", "dsItemmaster"); } public AjaxResult inventorydetail(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "inventory/inventorydetail/"); + return linuxAccessService.executeCommand(body, "inventory/inventorydetail/", "dsSearchCondition"); } public AjaxResult podetexport(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "puchaseorder/podetexport/"); + return linuxAccessService.executeCommand(body, "puchaseorder/podetexport/", "dsSearchCondition"); } public AjaxResult exportsupplier(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "supplier/exportsupplier/"); + return linuxAccessService.executeCommand(body, "supplier/exportsupplier/", "dsSearchCondition"); } public AjaxResult discretepo(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "purchaseorder/discretepo/"); + return linuxAccessService.executeCommand(body, "purchaseorder/discretepo/", "dsDescreteOrder"); } public AjaxResult custrequiredschedule(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "customer/custrequiredschedule/"); + return linuxAccessService.executeCommand(body, "customer/custrequiredschedule/", "dsSearchCondition"); } public AjaxResult qadgrirexport(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "qadgrir/qadgrirexport/"); + return linuxAccessService.executeCommand(body, "qadgrir/qadgrirexport/", "dsSearchCondition"); } public AjaxResult Unplannedissue(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "transactions/Unplannedissue/"); + return linuxAccessService.executeCommand(body, "transactions/Unplannedissue/", "dsUnplanISRC"); } public AjaxResult supplierschedule(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "supplier/supplierschedule/"); + return linuxAccessService.executeCommand(body, "supplier/supplierschedule/", "dsSearchCondition"); } public AjaxResult bommastr(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "bom/bommastr/"); - } - - public AjaxResult itemsiteLocdetail(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "items/itemsiteLocdetail/"); + return linuxAccessService.executeCommand(body, "bom/bommastr/", "dsBommaster"); } public AjaxResult backflush(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "workorder/backflush/"); - } - - public AjaxResult itemsiteplandetail(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "items/itemsiteplandetail/"); + return linuxAccessService.executeCommand(body, "workorder/backflush/", "dsBackflushMaster"); } public AjaxResult supplierasn(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "supplier/supplierasn/"); + return linuxAccessService.executeCommand(body, "supplier/supplierasn/", "dsttsupplierasn"); } public AjaxResult supplierinvoicebalance(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "supplier/supplierinvoicebalance/"); + return linuxAccessService.executeCommand(body, "supplier/supplierinvoicebalance/", "dsSearchCondition"); } public AjaxResult createsupplierinvoice(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "supplierinvoice/createsupplierinvoice/"); + return linuxAccessService.executeCommand(body, "supplierinvoice/createsupplierinvoice/", "dsSupplierInvoice"); } public AjaxResult loadbommstr(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "bommstr/loadbommstr/"); + return linuxAccessService.executeCommand(body, "bommstr/loadbommstr/", "dsBommaster"); } public AjaxResult costcenterdetail(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "costcenter/costcenterdetail/"); + return linuxAccessService.executeCommand(body, "costcenter/costcenterdetail/", "dsSearchCondition"); } public AjaxResult salesorderexport(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "salesorder/salesorderexport/"); + return linuxAccessService.executeCommand(body, "salesorder/salesorderexport/", "dsSearchCondition"); } public AjaxResult costdetail(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "cost/costdetail/"); + return linuxAccessService.executeCommand(body, "cost/costdetail/", "dsSearchCondition"); } public AjaxResult exportcustomer(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "customer/exportcustomer/"); + return linuxAccessService.executeCommand(body, "customer/exportcustomer/", "dsSearchCondition"); } public AjaxResult routingdetail(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "routing/routingdetail/"); + return linuxAccessService.executeCommand(body, "routing/routingdetail/", "dsRouting"); } public AjaxResult productionschedule(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "production/productionschedule/"); + return linuxAccessService.executeCommand(body, "production/productionschedule/", "dsSearchCondition"); } public AjaxResult intransfer(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "transactions/intransfer/"); + return linuxAccessService.executeCommand(body, "transactions/intransfer/", "dsinvtransfer"); } public AjaxResult loadbommastr(String body) throws IOException, InterruptedException { - return linuxAccessService.executeCommand(body, "bom/loadbommastr/"); + return linuxAccessService.executeCommand(body, "bom/loadbommastr/", "dsBommaster"); } } diff --git a/win-admin/src/main/java/com/win/web/controller/base/ShellController.java b/win-admin/src/main/java/com/win/web/controller/base/ShellController.java index 4363e2d..373d48d 100644 --- a/win-admin/src/main/java/com/win/web/controller/base/ShellController.java +++ b/win-admin/src/main/java/com/win/web/controller/base/ShellController.java @@ -1,17 +1,12 @@ package com.win.web.controller.base; -import com.alibaba.fastjson2.JSONObject; import com.jcraft.jsch.JSchException; -import com.jcraft.jsch.Session; import com.win.common.annotation.Log; import com.win.common.constant.HttpStatus; import com.win.common.core.domain.AjaxResult; import com.win.common.enums.BusinessType; import com.win.common.utils.ProfileUtil; -import com.win.common.utils.shell.ShellUtil; -import com.win.common.utils.shell.ShellVo; import com.win.system.service.LinuxAccessService; -import com.win.web.config.ShellConfig; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -62,7 +57,7 @@ public class ShellController { return AjaxResult.error(HttpStatus.TIMESTAMP_ERROR, "时间戳不正确"); } String tmp = interfaceName + body + "Wenyin@2024" + timestamp; - String computeSign = DigestUtils.md5DigestAsHex(tmp.getBytes()); + String computeSign = DigestUtils.md5DigestAsHex(tmp.getBytes()).toUpperCase(); long tenTimestamp = timestamp + (10 * 60 * 1000); // 计算10分钟后的时间戳 long currentTimestamp = System.currentTimeMillis(); // 获取当前时间戳 //过期 @@ -71,7 +66,7 @@ public class ShellController { } List activeProfile = ProfileUtil.getActiveProfile(); //dev环境不校验签名 - if(!activeProfile.contains("dev") && !StringUtils.equals(sign, computeSign.toUpperCase())) { + if(/*!activeProfile.contains("dev") && */!StringUtils.equals(sign, computeSign)) { return AjaxResult.error(HttpStatus.SIGN_ERROR, "签名不正确"); } Method method = this.getClass().getMethod(interfaceName, String.class); @@ -79,111 +74,103 @@ public class ShellController { } public AjaxResult poreceipt(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "purchaseorder/poreceipt/"); + return linuxAccessService.executeShell(body, "purchaseorder/poreceipt/", "dsPoreceiver"); } public AjaxResult projectdetail(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "project/projectdetail/"); + return linuxAccessService.executeShell(body, "project/projectdetail/", "dsSearchCondition"); } public AjaxResult itemmaster(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "items/itemmaster/"); + return linuxAccessService.executeShell(body, "items/itemmaster/", "dsItemmaster"); } public AjaxResult inventorydetail(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "inventory/inventorydetail/"); + return linuxAccessService.executeShell(body, "inventory/inventorydetail/", "dsSearchCondition"); } public AjaxResult podetexport(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "puchaseorder/podetexport/"); + return linuxAccessService.executeShell(body, "puchaseorder/podetexport/", "dsSearchCondition"); } public AjaxResult exportsupplier(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "supplier/exportsupplier/"); + return linuxAccessService.executeShell(body, "supplier/exportsupplier/", "dsSearchCondition"); } public AjaxResult discretepo(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "purchaseorder/discretepo/"); + return linuxAccessService.executeShell(body, "purchaseorder/discretepo/", "dsDescreteOrder"); } public AjaxResult custrequiredschedule(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "customer/custrequiredschedule/"); + return linuxAccessService.executeShell(body, "customer/custrequiredschedule/", "dsSearchCondition"); } public AjaxResult qadgrirexport(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "qadgrir/qadgrirexport/"); + return linuxAccessService.executeShell(body, "qadgrir/qadgrirexport/", "dsSearchCondition"); } public AjaxResult Unplannedissue(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "transactions/Unplannedissue/"); + return linuxAccessService.executeShell(body, "transactions/Unplannedissue/", "dsUnplanISRC"); } public AjaxResult supplierschedule(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "supplier/supplierschedule/"); + return linuxAccessService.executeShell(body, "supplier/supplierschedule/", "dsSearchCondition"); } public AjaxResult bommastr(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "bom/bommastr/"); - } - - public AjaxResult itemsiteLocdetail(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "items/itemsiteLocdetail/"); + return linuxAccessService.executeShell(body, "bom/bommastr/", "dsBommaster"); } public AjaxResult backflush(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "workorder/backflush/"); - } - - public AjaxResult itemsiteplandetail(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "items/itemsiteplandetail/"); + return linuxAccessService.executeShell(body, "workorder/backflush/", "dsBackflushMaster"); } public AjaxResult supplierasn(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "supplier/supplierasn/"); + return linuxAccessService.executeShell(body, "supplier/supplierasn/", "dsttsupplierasn"); } public AjaxResult supplierinvoicebalance(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "supplier/supplierinvoicebalance/"); + return linuxAccessService.executeShell(body, "supplier/supplierinvoicebalance/", "dsSearchCondition"); } public AjaxResult createsupplierinvoice(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "supplierinvoice/createsupplierinvoice/"); + return linuxAccessService.executeShell(body, "supplierinvoice/createsupplierinvoice/", "dsSupplierInvoice"); } public AjaxResult loadbommstr(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "bommstr/loadbommstr/"); + return linuxAccessService.executeShell(body, "bommstr/loadbommstr/", "dsBommaster"); } public AjaxResult costcenterdetail(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "costcenter/costcenterdetail/"); + return linuxAccessService.executeShell(body, "costcenter/costcenterdetail/", "dsSearchCondition"); } public AjaxResult salesorderexport(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "salesorder/salesorderexport/"); + return linuxAccessService.executeShell(body, "salesorder/salesorderexport/", "dsSearchCondition"); } public AjaxResult costdetail(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "cost/costdetail/"); + return linuxAccessService.executeShell(body, "cost/costdetail/", "dsSearchCondition"); } public AjaxResult exportcustomer(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "customer/exportcustomer/"); + return linuxAccessService.executeShell(body, "customer/exportcustomer/", "dsSearchCondition"); } public AjaxResult routingdetail(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "routing/routingdetail/"); + return linuxAccessService.executeShell(body, "routing/routingdetail/", "dsRouting"); } public AjaxResult productionschedule(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "production/productionschedule/"); + return linuxAccessService.executeShell(body, "production/productionschedule/", "dsSearchCondition"); } public AjaxResult intransfer(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "transactions/intransfer/"); + return linuxAccessService.executeShell(body, "transactions/intransfer/", "dsinvtransfer"); } public AjaxResult loadbommastr(String body) throws JSchException, IOException { - return linuxAccessService.executeShell(body, "bom/loadbommastr/"); + return linuxAccessService.executeShell(body, "bom/loadbommastr/", "dsBommaster"); } } diff --git a/win-admin/src/main/resources/application-test.yml b/win-admin/src/main/resources/application-test.yml index 5486dcf..b0f8f99 100644 --- a/win-admin/src/main/resources/application-test.yml +++ b/win-admin/src/main/resources/application-test.yml @@ -1,7 +1,7 @@ # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8080 + port: 23112 servlet: # 应用的访问路径 context-path: / @@ -47,23 +47,23 @@ spring: master: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://dev.ccwin-in.com:23113/qad?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: learun - password: Microdoft@2021 + url: jdbc:mysql://localhost:22050/qad?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: Root@123# # 读数据源 slave0: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://dev.ccwin-in.com:23113/qad?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: learun - password: Microdoft@2021 + url: jdbc:mysql://localhost:22050/qad?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: Root@123# # 读数据源 slave1: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://dev.ccwin-in.com:23113/qad?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: learun - password: Microdoft@2021 + url: jdbc:mysql://localhost:22050/qad?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: Root@123# # 读写分离类型,如: Static,Dynamic rules: readwrite-splitting: @@ -80,14 +80,14 @@ spring: datasource: dynamic: strict: true + primary: master datasource: - ccwin: - driver-class-name: com.mysql.cj.jdbc.Driver + master: type: com.alibaba.druid.pool.DruidDataSource - url: jdbc:mysql://dev.ccwin-in.com:23113/qad?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: learun - password: Microdoft@2021 - primary: qad + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:22050/qad?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: Root@123# # 资源信息 messages: # 国际化资源文件路径 @@ -111,11 +111,11 @@ spring: # redis 配置 redis: # 地址 - host: dev.ccwin-in.com + host: localhost # 端口,默认为6379 - port: 23114 + port: 6379 # 数据库索引 - database: 1 + database: 0 # 密码 password: # 连接超时时间 @@ -145,6 +145,6 @@ token: # Swagger配置 swagger: # 是否开启swagger - enabled: true + enabled: false # 请求前缀 pathMapping: / diff --git a/win-system/src/main/java/com/win/system/service/LinuxAccessService.java b/win-system/src/main/java/com/win/system/service/LinuxAccessService.java index f1e7738..4c7d99a 100644 --- a/win-system/src/main/java/com/win/system/service/LinuxAccessService.java +++ b/win-system/src/main/java/com/win/system/service/LinuxAccessService.java @@ -10,14 +10,13 @@ import com.win.common.constant.HttpStatus; import com.win.common.core.domain.AjaxResult; import com.win.common.utils.command.CommandUtil; import com.win.common.utils.shell.ShellUtil; -import com.win.common.utils.shell.ShellVo; +import com.win.system.domain.LinuxAccess; import com.win.system.domain.QadAccess; +import com.win.system.mapper.LinuxAccessMapper; import com.win.system.mapper.QadAccessMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.win.system.mapper.LinuxAccessMapper; -import com.win.system.domain.LinuxAccess; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; @@ -61,13 +60,14 @@ public class LinuxAccessService extends ServiceImpl