Browse Source

完成接口

master
liuchen864 8 months ago
parent
commit
573a712c63
  1. 117
      win-admin/src/main/java/com/win/web/controller/base/CommandController.java
  2. 116
      win-admin/src/main/java/com/win/web/controller/base/ShellController.java
  3. 22
      win-admin/src/main/resources/application-dev.yml
  4. 7
      win-admin/src/main/resources/application-prod.yml
  5. 7
      win-admin/src/main/resources/application-test.yml
  6. 117
      win-admin/src/main/resources/logback-spring.xml
  7. 34
      win-system/src/main/java/com/win/system/service/LinuxAccessService.java

117
win-admin/src/main/java/com/win/web/controller/base/CommandController.java

@ -1,6 +1,7 @@
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;
@ -76,18 +77,112 @@ public class CommandController {
return (AjaxResult) method.invoke(this, body);
}
public AjaxResult poreceipt(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "purchaseorder/poreceipt/");
}
public AjaxResult projectdetail(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "project/projectdetail/");
}
public AjaxResult itemmaster(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "items/itemmaster/");
}
public AjaxResult inventorydetail(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "inventory/inventorydetail/");
}
public AjaxResult podetexport(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "puchaseorder/podetexport/");
}
public AjaxResult exportsupplier(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "supplier/exportsupplier/");
}
public AjaxResult discretepo(String body) throws IOException, InterruptedException {
JSONObject jsonObject = JSONObject.parseObject(body);
jsonObject = JSONObject.parseObject(jsonObject.getString("dsDescreteOrder"));
String domain = jsonObject.getString("domain");
if(domain == null || domain.isEmpty()) {
return AjaxResult.error(HttpStatus.DOMAIN_ERROR, "域不能为空");
}
String companyCode = jsonObject.getString("company_code");
if(companyCode == null || companyCode.isEmpty()) {
return AjaxResult.error(HttpStatus.COMPANY_CODE_ERROR, "公司编码不能为空");
}
return linuxAccessService.executeCommand(domain, companyCode, "purchaseorder/discretepo/", jsonObject);
return linuxAccessService.executeCommand(body, "purchaseorder/discretepo/");
}
public AjaxResult custrequiredschedule(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "customer/custrequiredschedule/");
}
public AjaxResult qadgrirexport(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "qadgrir/qadgrirexport/");
}
public AjaxResult Unplannedissue(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "transactions/Unplannedissue/");
}
public AjaxResult supplierschedule(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "supplier/supplierschedule/");
}
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/");
}
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/");
}
public AjaxResult supplierasn(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "supplier/supplierasn/");
}
public AjaxResult supplierinvoicebalance(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "supplier/supplierinvoicebalance/");
}
public AjaxResult createsupplierinvoice(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "supplierinvoice/createsupplierinvoice/");
}
public AjaxResult loadbommstr(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "bommstr/loadbommstr/");
}
public AjaxResult costcenterdetail(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "costcenter/costcenterdetail/");
}
public AjaxResult salesorderexport(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "salesorder/salesorderexport/");
}
public AjaxResult costdetail(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "cost/costdetail/");
}
public AjaxResult exportcustomer(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "customer/exportcustomer/");
}
public AjaxResult routingdetail(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "routing/routingdetail/");
}
public AjaxResult productionschedule(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "production/productionschedule/");
}
public AjaxResult intransfer(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "transactions/intransfer/");
}
public AjaxResult loadbommastr(String body) throws IOException, InterruptedException {
return linuxAccessService.executeCommand(body, "bom/loadbommastr/");
}
}

116
win-admin/src/main/java/com/win/web/controller/base/ShellController.java

@ -78,18 +78,112 @@ public class ShellController {
return (AjaxResult) method.invoke(this, body);
}
public AjaxResult poreceipt(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "purchaseorder/poreceipt/");
}
public AjaxResult projectdetail(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "project/projectdetail/");
}
public AjaxResult itemmaster(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "items/itemmaster/");
}
public AjaxResult inventorydetail(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "inventory/inventorydetail/");
}
public AjaxResult podetexport(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "puchaseorder/podetexport/");
}
public AjaxResult exportsupplier(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "supplier/exportsupplier/");
}
public AjaxResult discretepo(String body) throws JSchException, IOException {
JSONObject jsonObject = JSONObject.parseObject(body);
jsonObject = JSONObject.parseObject(jsonObject.getString("dsDescreteOrder"));
String domain = jsonObject.getString("domain");
if(domain == null || domain.isEmpty()) {
return AjaxResult.error(HttpStatus.DOMAIN_ERROR, "域不能为空");
}
String companyCode = jsonObject.getString("company_code");
if(companyCode == null || companyCode.isEmpty()) {
return AjaxResult.error(HttpStatus.COMPANY_CODE_ERROR, "公司编码不能为空");
}
return linuxAccessService.executeShell(domain, companyCode, "purchaseorder/discretepo/", jsonObject);
return linuxAccessService.executeShell(body, "purchaseorder/discretepo/");
}
public AjaxResult custrequiredschedule(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "customer/custrequiredschedule/");
}
public AjaxResult qadgrirexport(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "qadgrir/qadgrirexport/");
}
public AjaxResult Unplannedissue(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "transactions/Unplannedissue/");
}
public AjaxResult supplierschedule(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "supplier/supplierschedule/");
}
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/");
}
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/");
}
public AjaxResult supplierasn(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "supplier/supplierasn/");
}
public AjaxResult supplierinvoicebalance(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "supplier/supplierinvoicebalance/");
}
public AjaxResult createsupplierinvoice(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "supplierinvoice/createsupplierinvoice/");
}
public AjaxResult loadbommstr(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "bommstr/loadbommstr/");
}
public AjaxResult costcenterdetail(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "costcenter/costcenterdetail/");
}
public AjaxResult salesorderexport(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "salesorder/salesorderexport/");
}
public AjaxResult costdetail(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "cost/costdetail/");
}
public AjaxResult exportcustomer(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "customer/exportcustomer/");
}
public AjaxResult routingdetail(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "routing/routingdetail/");
}
public AjaxResult productionschedule(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "production/productionschedule/");
}
public AjaxResult intransfer(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "transactions/intransfer/");
}
public AjaxResult loadbommastr(String body) throws JSchException, IOException {
return linuxAccessService.executeShell(body, "bom/loadbommastr/");
}
}

22
win-admin/src/main/resources/application-dev.yml

@ -148,25 +148,3 @@ swagger:
enabled: true
# 请求前缀
pathMapping: /
shell:
jlht:
qad-domain: JLHT
company-code: CCWININ
server-id: master
ip: 222.169.228.163
port: 6122
linux-id: mfg
linux-password: mfgpro
qad-user: mfg
qad-password: Qadwin1
jlht2:
qad-domain: JLHT2
company-code: CCWININ
server-id: master
ip: 222.169.228.163
port: 6122
linux-id: mfg
linux-password: mfgpro
qad-user: mfg
qad-password: Qadwin1

7
win-admin/src/main/resources/application-prod.yml

@ -148,10 +148,3 @@ swagger:
enabled: false
# 请求前缀
pathMapping: /
# flowable相关表
flowable:
# true 会对数据库中所有表进行更新操作。如果表不存在,则自动创建(建议开发时使用)
database-schema-update: false
# 关闭定时任务JOB
async-executor-activate: false

7
win-admin/src/main/resources/application-test.yml

@ -148,10 +148,3 @@ swagger:
enabled: true
# 请求前缀
pathMapping: /
# flowable相关表
flowable:
# true 会对数据库中所有表进行更新操作。如果表不存在,则自动创建(建议开发时使用)
database-schema-update: false
# 关闭定时任务JOB
async-executor-activate: false

117
win-admin/src/main/resources/logback-spring.xml

@ -27,6 +27,29 @@
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-debug.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-debug.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 7天 -->
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>DEBUG</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
@ -34,8 +57,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60-->
<maxHistory>60</maxHistory>
<!-- 日志最大的历史 7-->
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
@ -50,21 +73,22 @@
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 系统日志输出 -->
<appender name="file_warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-warn.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60-->
<maxHistory>60</maxHistory>
<fileNamePattern>${log.path}/sys-warn.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 7-->
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<level>WARN</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
@ -72,37 +96,66 @@
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60-->
<maxHistory>60</maxHistory>
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 7-->
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR,FATAL</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.hc" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="error">
<appender-ref ref="console" />
</root>
<!-- dev环境 -->
<springProfile name="local,dev,default">
<root level="DEBUG">
<appender-ref ref="console"/>
<appender-ref ref="file_debug"/>
<appender-ref ref="file_info"/>
<appender-ref ref="file_warn"/>
<appender-ref ref="file_error"/>
</root>
</springProfile>
<springProfile name="test">
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="file_info"/>
<appender-ref ref="file_warn"/>
<appender-ref ref="file_error"/>
</root>
</springProfile>
<springProfile name="prod">
<root level="INFO">
<appender-ref ref="file_info"/>
<appender-ref ref="file_warn"/>
<appender-ref ref="file_error"/>
</root>
</springProfile>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<logger name="org.springframework" level="WARN" />
<logger name="org.apache" level="INFO" />
<logger name="com.baomidou" level="INFO" />
<logger name="org.mybatis" level="INFO" />
<logger name="org.hibernate" level="INFO" />
<logger name="com.win.module.eam.controller" level="INFO" />
<logger name="io.netty" level="WARN" />
<logger name="org.redisson" level="WARN" />
<logger name="org.mapstruct" level="WARN" />
<logger name="org.flowable" level="WARN" />
<logger name="reactor.netty" level="WARN" />
<logger name="de.codecentric.boot" level="WARN" />
<logger name="com.alibaba" level="WARN" />
<logger name="org.quartz" level="WARN" />
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>

34
win-system/src/main/java/com/win/system/service/LinuxAccessService.java

@ -59,14 +59,23 @@ public class LinuxAccessService extends ServiceImpl<LinuxAccessMapper, LinuxAcce
/**
* 执行shell脚本
*
* @param domain
* @param companyCode 公司编码
* @param jsonObject 传输对象
* @param body 参数
* @param uri uri
* @return 执行结果
* @throws JSchException shell异常
* @throws IOException io异常
*/
public AjaxResult executeShell(String domain, String companyCode, String uri, JSONObject jsonObject) throws JSchException, IOException {
public AjaxResult executeShell(String body, String uri) throws JSchException, IOException {
JSONObject jsonObject = JSONObject.parseObject(body);
jsonObject = JSONObject.parseObject(jsonObject.getString("dsDescreteOrder"));
String domain = jsonObject.getString("domain");
if(domain == null || domain.isEmpty()) {
return AjaxResult.error(HttpStatus.DOMAIN_ERROR, "域不能为空");
}
String companyCode = jsonObject.getString("company_code");
if(companyCode == null || companyCode.isEmpty()) {
return AjaxResult.error(HttpStatus.COMPANY_CODE_ERROR, "公司编码不能为空");
}
QueryWrapper<LinuxAccess> linuxAccessQueryWrapper = new QueryWrapper<>();
linuxAccessQueryWrapper.eq("company_code", companyCode);
linuxAccessQueryWrapper.eq("uri", uri);
@ -123,14 +132,23 @@ public class LinuxAccessService extends ServiceImpl<LinuxAccessMapper, LinuxAcce
/**
* 执行命令行
*
* @param domain
* @param companyCode 公司编码
* @param jsonObject 传输对象
* @param body 参数
* @param uri uri
* @return 执行结果
* @throws InterruptedException 命令行异常
* @throws IOException io异常
*/
public AjaxResult executeCommand(String domain, String companyCode, String uri, JSONObject jsonObject) throws IOException, InterruptedException {
public AjaxResult executeCommand(String body, String uri) throws IOException, InterruptedException {
JSONObject jsonObject = JSONObject.parseObject(body);
jsonObject = JSONObject.parseObject(jsonObject.getString("dsDescreteOrder"));
String domain = jsonObject.getString("domain");
if(domain == null || domain.isEmpty()) {
return AjaxResult.error(HttpStatus.DOMAIN_ERROR, "域不能为空");
}
String companyCode = jsonObject.getString("company_code");
if(companyCode == null || companyCode.isEmpty()) {
return AjaxResult.error(HttpStatus.COMPANY_CODE_ERROR, "公司编码不能为空");
}
QueryWrapper<LinuxAccess> linuxAccessQueryWrapper = new QueryWrapper<>();
linuxAccessQueryWrapper.eq("company_code", companyCode);
linuxAccessQueryWrapper.eq("uri", uri);

Loading…
Cancel
Save