动作参数取值范围+角色配置权限

This commit is contained in:
2026-04-30 15:16:48 +08:00
parent 0bc6dd7761
commit 05770f7e56
177 changed files with 13913 additions and 9863 deletions

View File

@@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Annotation profile for Rc-autoplc-backend" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="false">
<entry name="$PROJECT_DIR$/../../../../maven/maven-respository/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar" />
</processorPath>
<module name="rczn-common" />
<module name="rczn-admin" />
<module name="rczn-autoplc" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="rczn-admin" options="-parameters" />
<module name="rczn-autoplc" options="-parameters" />
<module name="rczn-common" options="-parameters" />
</option>
</component>
</project>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/rczn-admin/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/rczn-autoplc/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/rczn-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="ias-snapshots" />
<option name="name" value="Infinite Automation Snapshot Repository" />
<option name="url" value="https://maven.mangoautomation.net/repository/ias-snapshot/" />
</remote-repository>
<remote-repository>
<option name="id" value="spring-milestones" />
<option name="name" value="Spring Milestones" />
<option name="url" value="https://repo.spring.io/milestone" />
</remote-repository>
<remote-repository>
<option name="id" value="spring-releases" />
<option name="name" value="Spring Releases" />
<option name="url" value="https://repo.spring.io/release" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="ias-releases" />
<option name="name" value="Infinite Automation Release Repository" />
<option name="url" value="https://maven.mangoautomation.net/repository/ias-release/" />
</remote-repository>
</component>
</project>

View File

@@ -1,124 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

54
rc_autoplc_backend/.idea/workspace.xml generated Normal file
View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="d47bc58e-d36b-422c-92c6-393c467a25d3" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="useMavenConfig" value="true" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectId" id="37uy9ngFoDUVUddX8Yg9afHWRsn" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d47bc58e-d36b-422c-92c6-393c467a25d3" name="Changes" comment="" />
<created>1767767108230</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1767767108230</updated>
<workItem from="1767767109651" duration="29000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>

View File

@@ -85,16 +85,16 @@ distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a userBusy through
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive userBusy interface displays "Appropriate Legal Notices"
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the userBusy that there is no warranty for the work (except to the
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of userBusy commands or options, such as a
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
@@ -215,7 +215,7 @@ terms of section 4, provided that you also meet all of these conditions:
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive userBusy interfaces, each must display
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
@@ -287,9 +287,9 @@ tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular userBusy, "normally used" refers to a
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular userBusy or of the way in which the particular userBusy
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent

View File

@@ -35,8 +35,3 @@
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
#### 增加日志生成:
1. 2026-4-3用户登录日志信息
2. 2026-4-3SOP用户操作日志信息
3. 2026-4-3基础数据功能岛、SOP序列用户操作增-删-改)日志

View File

@@ -23,7 +23,7 @@
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - userBusy and password for downloading maven
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.12</version>
<version>3.4.12</version>
<relativePath/>
</parent>
@@ -30,7 +30,6 @@
<jwt.version>4.4.0</jwt.version>
<knife4j.version>4.5.0</knife4j.version>
<jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version>
<lombok.version>1.18.30</lombok.version>
</properties>
<!-- 使用 dependencyManagement 管理项目特定版本 -->
@@ -76,34 +75,6 @@
<version>${jakarta.servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<!-- 在父模块的 dependencyManagement 中添加 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.15.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.github.s7connector</groupId>
<artifactId>s7connector</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.12.0</version>
</dependency>
</dependencies>
</dependencyManagement>
@@ -113,7 +84,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
@@ -122,7 +92,6 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>

View File

@@ -67,12 +67,6 @@
<scope>runtime</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-starter-common</artifactId>-->
<!-- <version>2.3.0</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<!-- 工具类 -->
<dependency>
<groupId>org.projectlombok</groupId>
@@ -85,7 +79,10 @@
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
@@ -95,12 +92,6 @@
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<!-- modbus4j 核心依赖Java8+Spring Boot2/3均兼容 -->
<!-- <dependency>-->
<!-- <groupId>com.infiniteautomation</groupId>-->
<!-- <artifactId>modbus4j</artifactId>-->
<!-- <version>3.0.3</version>-->
<!-- </dependency>-->
<!-- 测试依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -3,11 +3,9 @@ package com.rczn;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@ComponentScan(value = "com.rczn.*")
@EnableScheduling
public class RcznAdminApplication {
public static void main(String[] args) {

View File

@@ -1,10 +1,6 @@
package com.rczn.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -21,25 +17,4 @@ public class CorsConfig implements WebMvcConfigurer {
.allowCredentials(true) // 允许携带Cookie
.maxAge(3600); // 预检请求缓存1小时
}
@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
// 1. 允许前端源(不要用*和withCredentials=true配合需指定具体源或用allowedOriginPatterns
config.addAllowedOriginPattern("*");
// 2. 允许携带凭证和前端withCredentials=true对应
config.setAllowCredentials(true);
// 3. 允许所有请求方法包含OPTIONS
config.addAllowedMethod("*");
// 4. 允许所有请求头包含Authorization
config.addAllowedHeader("*");
// 5. 预检请求缓存时间减少OPTIONS请求次数
config.setMaxAge(3600L);
// 配置生效路径
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}

View File

@@ -1,38 +0,0 @@
package com.rczn.config;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class Knife4jConfig {
@Bean
public OpenAPI customOpenAPI() {
// 1. 声明JWT认证规则
String securitySchemeName = "Authorization";
return new OpenAPI()
// 2. 文档基础信息(可选)
.info(new Info()
.title("XX自动化编程系统API")
.version("1.0.0")
.description("集成JWT认证的Knife4j接口文档"))
// 3. 配置全局认证规则所有接口默认需要Token
.addSecurityItem(new SecurityRequirement().addList(securitySchemeName))
// 4. 定义Token的传递方式请求头+Bearer格式
.components(new Components()
.addSecuritySchemes(securitySchemeName,
new SecurityScheme()
.name(securitySchemeName)
.type(SecurityScheme.Type.HTTP) // HTTP认证
.scheme("bearer") // Bearer格式
.bearerFormat("JWT") // Token类型为JWT
.in(SecurityScheme.In.HEADER) // 放在请求头
)
);
}
}

View File

@@ -1,55 +0,0 @@
package com.rczn.config;
import com.rczn.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
// 必须启用@Configuration让Spring扫描到
@Configuration
public class WebConfig implements WebMvcConfigurer {
// 必须注入拦截器(取消注释)
@Autowired
LoginInterceptor loginInterceptor;
// 注册拦截器
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor)
// 拦截所有请求
.addPathPatterns("/**")
// 放行Swagger/Knife4j所有相关路径关键补充/doc.html
.excludePathPatterns(
// Knife4j自定义UI路径核心
"/doc.html",
// Swagger UI页面相关
"/swagger-ui/**",
"/webjars/**",
// SpringDoc接口文档数据相关
"/v3/api-docs/**",
"/v3/api-docs.yaml",
// 旧版Swagger兼容
"/swagger-resources/**",
"/swagger-ui.html"
)
// 放行登录/注册接口
.excludePathPatterns("/user/login", "/user/register");
}
// 静态资源映射适配Knife4j+SpringDoc
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// Knife4j静态资源核心补充
registry.addResourceHandler("/doc.html")
.addResourceLocations("classpath:/META-INF/resources/");
// Swagger UI静态资源
registry.addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springdoc-openapi-ui/");
// Webjars通用资源
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}

View File

@@ -1,16 +1,15 @@
package com.rczn.rcznautoplc.controller;
package com.rczn.controller;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.rcznautoplc.service.ManageLogService;
import com.rczn.system.domain.ManageLog;
import com.rczn.system.service.ManageLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@@ -44,12 +43,8 @@ public class ManageLogController {
@RequestParam(required = false) String logName,
@RequestParam(required = false) String logType,
@RequestParam(required = false) Long createId,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime logWritetimeStart,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime logWritetimeEnd) {
@RequestParam(required = false) LocalDateTime logWritetimeStart,
@RequestParam(required = false) LocalDateTime logWritetimeEnd) {
// 构建查询条件空字段自动忽略
ManageLog query = new ManageLog();

View File

@@ -9,7 +9,6 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -22,8 +21,12 @@ import java.util.List;
@Tag(name = "角色管理", description = "角色增删改查接口(支持分页+多条件查询+编码唯一性校验)")
public class RoleController {
@Autowired
RoleService roleService;
private final RoleService roleService;
// 构造器注入
public RoleController(RoleService roleService) {
this.roleService = roleService;
}
/**
* 1. 分页查询角色(多条件模糊查询)

View File

@@ -1,65 +0,0 @@
package com.rczn.controller;
import com.rczn.domain.Result;
import com.rczn.system.domain.RolePermission;
import com.rczn.system.domain.query.RolePermissionQuery;
import com.rczn.system.service.RolePermissionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/rolePermission")
@Tag(name = "角色权限管理", description = "角色权限关联接口")
public class RolePermissionController {
@Autowired
RolePermissionService rolePermissionService;
@GetMapping("/listByRoleId/{roleId}")
@Operation(summary = "根据角色ID查询权限ID列表")
public Result getListByRoleId(
@Parameter(name = "roleId", required = true) @PathVariable Integer roleId) {
List<RolePermission> list = rolePermissionService.selectListByRoleId(roleId);
return Result.success(list);
}
@PostMapping("/add")
@Operation(summary = "给角色添加权限")
public Result add(@RequestBody RolePermissionQuery rolePermission) {
if (rolePermission.getRoleId() == null || rolePermission.getPermissionId() == null) {
return Result.error("角色ID和权限ID不能为空");
}
try {
RolePermission rolePermissionEntity = new RolePermission();
rolePermissionEntity.setRoleId(rolePermission.getRoleId());
rolePermissionEntity.setPermissionId(rolePermission.getPermissionId());
rolePermissionService.insert(rolePermissionEntity);
return Result.success("添加成功");
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping("/del")
@Operation(summary = "删除角色权限关联")
public Result delete(
@RequestParam Integer roleId,
@RequestParam(required = false) Integer permissionId) {
boolean success = rolePermissionService.delete(roleId, permissionId);
return success ? Result.success("删除成功") : Result.error("删除失败");
}
@DeleteMapping("/clearByRoleId/{roleId}")
@Operation(summary = "清空某个角色的所有权限")
public Result clearByRoleId(
@Parameter(name = "roleId", required = true) @PathVariable Integer roleId) {
rolePermissionService.deleteByRoleId(roleId);
return Result.success("清空成功");
}
}

View File

@@ -1,109 +0,0 @@
package com.rczn.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.Result;
import com.rczn.system.domain.SysDicData;
import com.rczn.system.service.SysDicDataService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/sysDicData")
@Tag(name = "字典数据管理", description = "字典数据增删改查+分页查询+按类型查询接口")
public class SysDicDataController {
@Autowired
private SysDicDataService sysDicDataService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询字典数据", description = "支持字典类型ID、标签、值查询")
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "dicId", description = "字典类型ID可选", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "dicLabel", description = "数据标签(可选,模糊查询)", required = false, example = "运行", in = ParameterIn.QUERY),
@Parameter(name = "dicValue", description = "数据值(可选,模糊查询)", required = false, example = "1", in = ParameterIn.QUERY)
})
public Result getDicDataPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer dicId,
@RequestParam(required = false) String dicLabel,
@RequestParam(required = false) String dicValue) {
PageInfo<SysDicData> pageBean = sysDicDataService.selectPage(pageNum, pageSize, dicId, dicLabel, dicValue);
return Result.success(pageBean);
}
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询字典数据", description = "支持字典类型ID、标签、值查询")
@Parameters({
@Parameter(name = "dicId", description = "字典类型ID可选", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "dicLabel", description = "数据标签(可选,模糊查询)", required = false, example = "运行", in = ParameterIn.QUERY),
@Parameter(name = "dicValue", description = "数据值(可选,模糊查询)", required = false, example = "1", in = ParameterIn.QUERY)
})
public Result getList(
@RequestParam(required = false) Integer dicId,
@RequestParam(required = false) String dicLabel,
@RequestParam(required = false) String dicValue) {
List<SysDicData> list = sysDicDataService.selectList( dicId, dicLabel, dicValue);
return Result.success(list);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个字典数据", description = "根据字典数据ID查询详情")
public Result getDicDataById(@PathVariable Long id) {
SysDicData sysDicData = sysDicDataService.selectById(id);
return sysDicData != null ? Result.success(sysDicData) : Result.error("字典数据不存在");
}
@GetMapping(value = "/listByDicId/{dicId}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "按字典类型ID查询数据列表", description = "查询指定字典类型下的所有有效数据")
public Result getDicDataByDicId(@PathVariable Integer dicId) {
try {
List<SysDicData> list = sysDicDataService.selectByDicId(dicId);
return Result.success(list);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增字典数据", description = "字典类型ID、数据标签为必填项")
public Result addDicData(@RequestBody SysDicData sysDicData) {
try {
Long dicDataId = sysDicDataService.insert(sysDicData);
return Result.success(dicDataId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改字典数据", description = "需传入字典数据ID其他字段可选非空则更新")
public Result updateDicData(@RequestBody SysDicData sysDicData) {
try {
Boolean success = sysDicDataService.update(sysDicData);
return success ? Result.success(true) : Result.error("修改失败(字典数据不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除字典数据", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteDicData(@PathVariable Long id) {
try {
Boolean success = sysDicDataService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(字典数据不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -1,95 +0,0 @@
package com.rczn.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.Result;
import com.rczn.system.domain.SysDicType;
import com.rczn.system.service.SysDicTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/sysDicType")
@Tag(name = "字典类型管理", description = "字典类型增删改查+分页查询接口")
public class SysDicTypeController {
@Autowired
private SysDicTypeService sysDicTypeService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询字典类型", description = "支持字典名称、编码模糊查询")
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "dicName", description = "字典名称(可选,模糊查询)", required = false, example = "设备状态", in = ParameterIn.QUERY),
@Parameter(name = "dicCode", description = "字典编码(可选,模糊查询)", required = false, example = "DEV_STATUS", in = ParameterIn.QUERY)
})
public Result getDicTypePage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) String dicName,
@RequestParam(required = false) String dicCode) {
PageInfo<SysDicType> pageBean = sysDicTypeService.selectPage(pageNum, pageSize, dicName, dicCode);
return Result.success(pageBean);
}
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询字典类型列表", description = "支持字典名称、编码模糊查询")
@Parameters({
@Parameter(name = "dicName", description = "字典名称(可选,模糊查询)", required = false, example = "设备状态", in = ParameterIn.QUERY),
@Parameter(name = "dicCode", description = "字典编码(可选,模糊查询)", required = false, example = "DEV_STATUS", in = ParameterIn.QUERY)
})
public Result getList(
@RequestParam(required = false) String dicName,
@RequestParam(required = false) String dicCode) {
List<SysDicType> list = sysDicTypeService.selectList( dicName, dicCode);
return Result.success(list);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个字典类型", description = "根据字典类型ID查询详情")
public Result getDicTypeById(@PathVariable Long id) {
SysDicType sysDicType = sysDicTypeService.selectById(id);
return sysDicType != null ? Result.success(sysDicType) : Result.error("字典类型不存在");
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增字典类型", description = "字典名称为必填项")
public Result addDicType(@RequestBody SysDicType sysDicType) {
try {
Long dicTypeId = sysDicTypeService.insert(sysDicType);
return Result.success(dicTypeId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改字典类型", description = "需传入字典类型ID其他字段可选非空则更新")
public Result updateDicType(@RequestBody SysDicType sysDicType) {
try {
Boolean success = sysDicTypeService.update(sysDicType);
return success ? Result.success(true) : Result.error("修改失败(字典类型不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除字典类型", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteDicType(@PathVariable Long id) {
try {
Boolean success = sysDicTypeService.deleteById(id);
return success ? Result.success(true) : Result.error("删除失败(字典类型不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -1,128 +0,0 @@
package com.rczn.controller;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.Role;
import com.rczn.system.service.SysPermissionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 权限管理 APIMyBatis 树形结构实现)
*/
@RestController
@RequestMapping("/permission")
@Tag(name = "权限管理", description = "权限增删改查接口(树形结构)")
public class SysPermissionController {
@Autowired
private SysPermissionService sysPermissionService;
/**
* 1. 分页查询权限(多条件模糊查询)
*/
@GetMapping("/listPage")
@Operation(summary = "分页查询权限", description = "支持角色名、角色编码模糊查询页码从1开始")
@Parameters({
@Parameter(name = "pageNum", description = "页码必填从1开始", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "parentId", description = "父级ID可选", required = false, example = "0", in = ParameterIn.QUERY),
@Parameter(name = "permissionName", description = "权限名称(模糊查询,可选)", required = false, example = "用户添加", in = ParameterIn.QUERY)
})
public Result<PageBean<Permission>> getRolePage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer parentId,
@RequestParam(required = false) String permissionName) {
PageBean<Permission> pageBean = sysPermissionService.selectRolePage(pageNum, pageSize, parentId,permissionName);
return Result.success(pageBean);
}
/**
* 1. 查询权限树形结构列表
*/
@GetMapping("/list")
@Operation(summary = "查询权限树形列表", description = "返回权限树形结构parentId为0或null为顶级")
public Result<List<Permission>> getPermissionList() {
List<Permission> treeList = sysPermissionService.getPermissionList();
return Result.success(treeList);
}
/**
* 1. 查询权限树形结构列表
*/
// @GetMapping("/listByParentId/{parentId}")
// @Operation(summary = "查询权限树形列表", description = "返回权限树形结构parentId为0或null为顶级")
// public Result<List<Permission>> getPermissionListByParentId(@PathVariable Integer parentId) {
// List<Permission> treeList = sysPermissionService.getPermissionListByParentId(parentId);
// return Result.success(treeList);
// }
/**
* 2. 根据ID查询单个权限
*/
@GetMapping("/getById/{id}")
@Operation(summary = "查询单个权限", description = "根据权限ID查询详情")
public Result getPermissionById(
@Parameter(name = "id", description = "权限ID", required = true, example = "1", in = ParameterIn.PATH)
@PathVariable Integer id) {
Permission permission = sysPermissionService.getPermissionById(id);
if (permission == null) {
return Result.error("权限ID" + id + " 不存在");
}
return Result.success(permission);
}
/**
* 3. 新增权限
*/
@PostMapping("/add")
@Operation(summary = "新增权限", description = "提交权限信息创建新权限")
public Result addPermission(
@Parameter(name = "permission", description = "权限信息", required = true)
@RequestBody Permission permission) {
boolean success = sysPermissionService.addPermission(permission);
return success ? Result.success("新增权限成功") : Result.error("新增失败");
}
/**
* 4. 修改权限
*/
@PutMapping("/update")
@Operation(summary = "修改权限", description = "传入权限ID和需要修改的字段")
public Result updatePermission(
@Parameter(name = "permission", description = "权限信息必须包含ID", required = true)
@RequestBody Permission permission) {
try {
boolean success = sysPermissionService.updatePermission(permission);
return success ? Result.success("修改权限成功") : Result.error("修改失败(权限不存在)");
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
/**
* 5. 根据ID删除权限逻辑删除
*/
@DeleteMapping("/del/{id}")
@Operation(summary = "删除权限", description = "根据权限ID逻辑删除")
public Result deletePermission(
@Parameter(name = "id", description = "权限ID", required = true, example = "1", in = ParameterIn.PATH)
@PathVariable Integer id) {
boolean success = sysPermissionService.deletePermission(id);
return success ? Result.success("删除权限成功") : Result.error("删除失败(权限不存在)");
}
}

View File

@@ -1,33 +1,18 @@
package com.rczn.controller;
import com.fasterxml.jackson.databind.annotation.JsonAppend;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.rcznautoplc.domain.RecordInfo;
import com.rczn.rcznautoplc.service.ManageLogService;
import com.rczn.rcznautoplc.service.RecordInfoService;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.User;
import com.rczn.system.service.UserService;
import com.rczn.utils.JwtUtil;
import com.rczn.utils.Md5Util;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 用户管理 CRUD APIMyBatis+PageHelper 实现)
@@ -132,108 +117,4 @@ public class UserController {
Boolean success = userService.deleteById(id);
return success ? Result.success("删除用户成功") : Result.error("删除失败(用户不存在)");
}
@PostMapping("/register")
@Operation(summary = "注册", description = "用户名必须是2-16位的字母、数字、下划线或减号")
public Result register(@Pattern(regexp = "^[a-zA-Z0-9_-]{2,16}$", message = "用户名必须是2-16位的字母、数字、下划线或减号")
@Parameter(
name = "username",
description = "用户名"
)
@RequestParam
String username,
@Parameter(
name = "password",
description = "密码..."
)
@RequestParam
String password) {
//查询数据库是否有该用户
User user = userService.findeUserByUsername(username);
//注册
if (user == null) {
//如果用户不存在,则注册
int result = userService.register(username, password);
return Result.success("用户注册成功");
} else {
//用户存在,返回错误信息
return Result.error("该用户名已存在!");
}
}
@GetMapping("/getUserByUsername")
public Result getUserByUsername(String username) {
User user = userService.findeUserByUsername(username);
if (user == null) {
return Result.error("该用户不存在!");
} else {
return Result.success(user);
}
}
@Autowired
ManageLogService manageLogService;
@PostMapping("/login")
@Operation(summary = "用户登录接口",description = "根据用户名和密码登录返回JWT Token")
public Result login(
@Parameter(
name = "username",
description = "登录用户名2-16位的字母、数字、下划线或减号",
required = true, // 标记为必填参数
example = "string"
)
@RequestParam
String username,
@Parameter(
name = "password",
description = "登录密码",
required = true
)
@RequestParam
String password) {
//TODO 登录逻辑
//查询数据库是否有该用户
User user = userService.findeUserByUsername(username);
//登录
if (user == null) {
//如果用户不存在,返回错误信息
return Result.error("该用户不存在!");
} else {
//校验密码:
String encryptPassword = user.getPassword();
if (encryptPassword.equals(password)) {
//登录成功,增加登录日志:
LocalDateTime loginTime = LocalDateTime.now();
ManageLog info = new ManageLog();
info.setCreateId(user.getId());
info.setLogName("登录日志");
info.setLogType("登录日志");//1登录日志、2SOP操作日志、3基础数据操作日志
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("用户名:").append(user.getUserName()).append(",登录操作时间:").append(loginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
info.setLogContent(stringBuilder.toString());
info.setCreateTime(loginTime);
manageLogService.insert(info);
// if (Md5Util.checkPassword(password, encryptPassword)) {
//生产token
Map<String, Object> claims = new HashMap<>();
claims.put("id", user.getId());
claims.put("username", user.getUserName());
//获取权限列表:
List<Permission> permissions = userService.findUserPermissions(user.getId());
List<String> permissionList = permissions.stream().map(Permission::getPermissionCode).collect(Collectors.toList());
claims.put("permissions", permissionList);
String jwtToken = JwtUtil.genToken(claims);
//密码正确,返回成功信息
return Result.success(jwtToken);
} else {
//密码错误,返回错误信息
return Result.error("密码错误!");
}
}
}
}

View File

@@ -1,8 +1,8 @@
package com.rczn.rcznautoplc.domain;
package com.rczn.system.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class ManageLog extends BaseBean {

View File

@@ -1,31 +1,16 @@
package com.rczn.system.domain;
import com.rczn.domain.BaseBean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.List;
public class Permission extends BaseBean{
private Integer parentId;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Permission extends BaseBean {
private String permissionName;
private String permissionCode;
// 树形结构子节点 ✅
private List<Permission> children;
// getter & setter
public Integer getParentId() { return parentId; }
public void setParentId(Integer parentId) { this.parentId = parentId; }
public String getPermissionName() { return permissionName; }
public void setPermissionName(String permissionName) { this.permissionName = permissionName; }
public String getPermissionCode() { return permissionCode; }
public void setPermissionCode(String permissionCode) { this.permissionCode = permissionCode; }
// children
public List<Permission> getChildren() {
return children;
}
public void setChildren(List<Permission> children) {
this.children = children;
}
}
private String permissionCode;}

View File

@@ -1,52 +0,0 @@
package com.rczn.system.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
/**
* 字典数据实体类
* 对应表sys_dic_data
*/
public class SysDicData extends BaseBean {
// 字典类型id外键
private Integer dicId;
// 数据标签
private String dicLabel;
// 数据字典值
private String dicValue;
public SysDicData() {
}
public SysDicData(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
// getter/setter
public Integer getDicId() {
return dicId;
}
public void setDicId(Integer dicId) {
this.dicId = dicId;
}
public String getDicLabel() {
return dicLabel;
}
public void setDicLabel(String dicLabel) {
this.dicLabel = dicLabel;
}
public String getDicValue() {
return dicValue;
}
public void setDicValue(String dicValue) {
this.dicValue = dicValue;
}
}

View File

@@ -1,41 +0,0 @@
package com.rczn.system.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
/**
* 字典类型实体类
* 对应表sys_dic_type
*/
public class SysDicType extends BaseBean {
// 字典名称(必填)
private String dicName;
// 字典编码
private String dicCode;
public SysDicType() {
}
public SysDicType(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
// getter/setter
public String getDicName() {
return dicName;
}
public void setDicName(String dicName) {
this.dicName = dicName;
}
public String getDicCode() {
return dicCode;
}
public void setDicCode(String dicCode) {
this.dicCode = dicCode;
}
}

View File

@@ -1,34 +0,0 @@
package com.rczn.system.domain.query;
public class RolePermissionQuery {
//角色id
private Integer roleId;
//权限id
private Integer permissionId;
public RolePermissionQuery(Integer roleId, Integer permissionId) {
this.roleId = roleId;
this.permissionId = permissionId;
}
public RolePermissionQuery() {
}
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
public Integer getPermissionId() {
return permissionId;
}
public void setPermissionId(Integer permissionId) {
this.permissionId = permissionId;
}
}

View File

@@ -1,8 +1,7 @@
package com.rczn.rcznautoplc.mapper;
package com.rczn.system.mapper;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.system.domain.ManageLog;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper // 标记为 MyBatis Mapper 接口确保被 Spring 扫描

View File

@@ -1,18 +0,0 @@
package com.rczn.system.mapper;
import com.rczn.system.domain.RolePermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface RolePermissionMapper {
List<RolePermission> selectListByRoleId(@Param("roleId") Integer roleId);
int insert(RolePermission rolePermission);
int delete(@Param("roleId") Integer roleId, @Param("permissionId") Integer permissionId);
int deleteByRoleId(@Param("roleId") Integer roleId);
}

View File

@@ -1,39 +0,0 @@
package com.rczn.system.mapper;
import com.rczn.system.domain.SysDicData;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface SysDicDataMapper {
/**
* 新增字典数据
*/
int insert(SysDicData sysDicData);
/**
* 修改字典数据
*/
int update(SysDicData sysDicData);
/**
* 逻辑删除字典数据
*/
int deleteById(Long id);
/**
* 根据ID查询字典数据
*/
SysDicData selectById(Long id);
/**
* 分页查询字典数据(参数可选)
*/
List<SysDicData> selectPage(SysDicData sysDicData);
/**
* 根据字典类型ID查询字典数据列表
*/
List<SysDicData> selectByDicId(Integer dicId);
}

View File

@@ -1,34 +0,0 @@
package com.rczn.system.mapper;
import com.rczn.system.domain.SysDicType;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface SysDicTypeMapper {
/**
* 新增字典类型
*/
int insert(SysDicType sysDicType);
/**
* 修改字典类型
*/
int update(SysDicType sysDicType);
/**
* 逻辑删除字典类型
*/
int deleteById(Long id);
/**
* 根据ID查询字典类型
*/
SysDicType selectById(Long id);
/**
* 分页查询字典类型(参数可选)
*/
List<SysDicType> selectPage(SysDicType sysDicType);
}

View File

@@ -1,52 +0,0 @@
package com.rczn.system.mapper;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface SysPermissionMapper {
/**
* 分页查询角色(支持角色名/角色编码模糊查询)
*/
List<Permission> selectPermissionPage(
@Param("parentId") Integer parentId,
@Param("permissionName") String permissionName);
/**
* 查询总条数(支持模糊查询条件)
*/
Long selectTotal(
@Param("parentId") Integer parentId,
@Param("permissionName") String permissionName);
/**
* 查询所有权限(未删除)
*/
List<Permission> selectPermissionList();
/**
* 根据ID查询
*/
Permission selectPermissionById(Integer id);
/**
* 新增
*/
int insertPermission(Permission permission);
/**
* 修改
*/
int updatePermission(Permission permission);
/**
* 逻辑删除
*/
int deletePermissionById(Integer id);
}

View File

@@ -1,11 +1,8 @@
package com.rczn.system.mapper;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
@@ -34,10 +31,4 @@ public interface UserMapper {
@Param("sex") Integer sex,
@Param("delSign") Boolean delSign
);
@Select("SELECT * FROM sys_user WHERE user_name = #{userName}")
User selectByUsername(String userName);
//根据用户id查询出对应的权限列表
List<Permission> findUserPermissions(Long userId);
}

View File

@@ -1,7 +1,7 @@
package com.rczn.rcznautoplc.service;
package com.rczn.system.service;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.system.domain.ManageLog;
public interface ManageLogService {
// 新增日志

View File

@@ -1,15 +0,0 @@
package com.rczn.system.service;
import com.rczn.system.domain.RolePermission;
import java.util.List;
public interface RolePermissionService {
List<RolePermission> selectListByRoleId(Integer roleId);
void insert(RolePermission rolePermission);
boolean delete(Integer roleId, Integer permissionId);
void deleteByRoleId(Integer roleId);
}

View File

@@ -1,44 +0,0 @@
package com.rczn.system.service;
import com.github.pagehelper.PageInfo;
import com.rczn.system.domain.SysDicData;
import java.util.List;
public interface SysDicDataService {
/**
* 分页查询字典数据
*/
PageInfo<SysDicData> selectPage(Integer pageNum, Integer pageSize, Integer dicId, String dicLabel, String dicValue);
/**
* 查询字典数据列表
*/
List<SysDicData> selectList(Integer dicId, String dicLabel, String dicValue);
/**
* 根据ID查询字典数据
*/
SysDicData selectById(Long id);
/**
* 根据字典类型ID查询字典数据列表
*/
List<SysDicData> selectByDicId(Integer dicId);
/**
* 新增字典数据
*/
Long insert(SysDicData sysDicData);
/**
* 修改字典数据
*/
Boolean update(SysDicData sysDicData);
/**
* 逻辑删除字典数据
*/
Boolean deleteById(Long id);
}

View File

@@ -1,40 +0,0 @@
package com.rczn.system.service;
import com.github.pagehelper.PageInfo;
import com.rczn.system.domain.SysDicType;
import java.util.List;
public interface SysDicTypeService {
/**
* 分页查询字典类型
*/
PageInfo<SysDicType> selectPage(Integer pageNum, Integer pageSize, String dicName, String dicCode);
/**
* 查询字典类型列表
*/
List<SysDicType> selectList( String dicName, String dicCode);
/**
* 根据ID查询字典类型
*/
SysDicType selectById(Long id);
/**
* 新增字典类型
*/
Long insert(SysDicType sysDicType);
/**
* 修改字典类型
*/
Boolean update(SysDicType sysDicType);
/**
* 逻辑删除字典类型
*/
Boolean deleteById(Long id);
}

View File

@@ -1,26 +0,0 @@
package com.rczn.system.service;
import com.rczn.domain.PageBean;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.Role;
import java.util.List;
public interface SysPermissionService {
List<Permission> getPermissionList();
//根据父ID查询权限列表
List<Permission> getPermissionListByParentId(Integer parentId);
Permission getPermissionById(Integer id);
boolean addPermission(Permission permission);
boolean updatePermission(Permission permission);
boolean deletePermission(Integer id);
/**
* 1. 分页查询角色(多条件模糊查询)
* @param pageNum
* @param pageSize
* @param permissionName
* @return
*/
PageBean<Permission> selectRolePage(Integer pageNum, Integer pageSize,Integer parentId, String permissionName);
}

View File

@@ -11,13 +11,6 @@ public interface UserRoleService {
Boolean deleteByRoleId(Integer roleId);
UserRole selectById(Long id);
List<UserRole> selectByUserId(Integer userId);
/**
* Selects user roles by the given role ID
*
* @param roleId The ID of the role to search for
* @return List of UserRole objects associated with the given role ID
*/
List<UserRole> selectByRoleId(Integer roleId);
PageBean<UserRole> selectPage(Integer pageNum, Integer pageSize, Integer userId, Integer roleId);
}

View File

@@ -1,7 +1,6 @@
package com.rczn.system.service;
import com.rczn.domain.PageBean;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.User;
import java.util.List;
@@ -54,25 +53,4 @@ public interface UserService {
* @return 是否删除成功true/false
*/
Boolean deleteById(Long id);
/**
* 6. 根据用户名查询用户
* @param username 用户名
* @return 用户实体
*/
User findeUserByUsername(String username);
/**
* 7. 注册用户
* @param username 用户名
* @param password 密码
*/
int register(String username, String password);
/**
* 根据用户id查询出关联的用户权限对象列表
* 表直接的关系是:
* 用户表user--用户权限表user_role--权限表role-- 权限资源表role_resource--资源表resource
*/
List<Permission> findUserPermissions(Long userId);
}

View File

@@ -1,11 +1,12 @@
package com.rczn.rcznautoplc.service.impl;
package com.rczn.system.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.rcznautoplc.mapper.ManageLogMapper;
import com.rczn.rcznautoplc.service.ManageLogService;
import com.rczn.system.domain.ManageLog;
import com.github.pagehelper.PageHelper;
import com.rczn.system.domain.Position;
import com.rczn.system.mapper.ManageLogMapper;
import com.rczn.system.service.ManageLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

View File

@@ -1,42 +0,0 @@
package com.rczn.system.service.impl;
import com.rczn.system.domain.RolePermission;
import com.rczn.system.mapper.RolePermissionMapper;
import com.rczn.system.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class RolePermissionServiceImpl implements RolePermissionService {
@Autowired
RolePermissionMapper rolePermissionMapper;
@Override
public List<RolePermission> selectListByRoleId(Integer roleId) {
return rolePermissionMapper.selectListByRoleId(roleId);
}
@Override
@Transactional
public void insert(RolePermission rolePermission) {
rolePermission.setCreateTime(LocalDateTime.now());
rolePermissionMapper.insert(rolePermission);
}
@Override
@Transactional
public boolean delete(Integer roleId, Integer permissionId) {
return rolePermissionMapper.delete(roleId, permissionId) > 0;
}
@Override
@Transactional
public void deleteByRoleId(Integer roleId) {
rolePermissionMapper.deleteByRoleId(roleId);
}
}

View File

@@ -1,97 +0,0 @@
package com.rczn.system.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.system.domain.SysDicData;
import com.rczn.system.mapper.SysDicDataMapper;
import com.rczn.system.service.SysDicDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SysDicDataServiceImpl implements SysDicDataService {
@Autowired
private SysDicDataMapper sysDicDataMapper;
@Override
public PageInfo<SysDicData> selectPage(Integer pageNum, Integer pageSize, Integer dicId, String dicLabel, String dicValue) {
PageHelper.startPage(pageNum, pageSize);
SysDicData query = new SysDicData();
query.setDicId(dicId);
query.setDicLabel(dicLabel);
query.setDicValue(dicValue);
return new PageInfo<>(sysDicDataMapper.selectPage(query));
}
/**
* 查询字典数据列表
*
* @param dicId
* @param dicLabel
* @param dicValue
*/
@Override
public List<SysDicData> selectList(Integer dicId, String dicLabel, String dicValue) {
SysDicData query = new SysDicData();
query.setDicId(dicId);
query.setDicLabel(dicLabel);
query.setDicValue(dicValue);
return sysDicDataMapper.selectPage(query);
}
@Override
public SysDicData selectById(Long id) {
return sysDicDataMapper.selectById(id);
}
@Override
public List<SysDicData> selectByDicId(Integer dicId) {
if (dicId == null) {
throw new IllegalArgumentException("字典类型ID不能为空");
}
return sysDicDataMapper.selectByDicId(dicId);
}
@Override
public Long insert(SysDicData sysDicData) {
// 校验必填项
if (sysDicData.getDicId() == null) {
throw new IllegalArgumentException("字典类型ID不能为空");
}
if (sysDicData.getDicLabel() == null || sysDicData.getDicLabel().trim().isEmpty()) {
throw new IllegalArgumentException("数据标签不能为空");
}
int count = sysDicDataMapper.insert(sysDicData);
return count > 0 ? sysDicData.getId() : null;
}
@Override
public Boolean update(SysDicData sysDicData) {
if (sysDicData.getId() == null) {
throw new IllegalArgumentException("字典数据ID不能为空");
}
// 校验是否存在
SysDicData exist = sysDicDataMapper.selectById(sysDicData.getId());
if (exist == null) {
return false;
}
int count = sysDicDataMapper.update(sysDicData);
return count > 0;
}
@Override
public Boolean deleteById(Long id) {
if (id == null) {
throw new IllegalArgumentException("字典数据ID不能为空");
}
// 校验是否存在
SysDicData exist = sysDicDataMapper.selectById(id);
if (exist == null) {
return false;
}
int count = sysDicDataMapper.deleteById(id);
return count > 0;
}
}

View File

@@ -1,84 +0,0 @@
package com.rczn.system.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.system.domain.SysDicType;
import com.rczn.system.mapper.SysDicTypeMapper;
import com.rczn.system.service.SysDicTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SysDicTypeServiceImpl implements SysDicTypeService {
@Autowired
private SysDicTypeMapper sysDicTypeMapper;
@Override
public PageInfo<SysDicType> selectPage(Integer pageNum, Integer pageSize, String dicName, String dicCode) {
PageHelper.startPage(pageNum, pageSize);
SysDicType query = new SysDicType();
query.setDicName(dicName);
query.setDicCode(dicCode);
return new PageInfo<>(sysDicTypeMapper.selectPage(query));
}
/**
* 查询字典类型列表
*
* @param dicName
* @param dicCode
*/
@Override
public List<SysDicType> selectList(String dicName, String dicCode) {
SysDicType query = new SysDicType();
query.setDicName(dicName);
query.setDicCode(dicCode);
return sysDicTypeMapper.selectPage(query);
}
@Override
public SysDicType selectById(Long id) {
return sysDicTypeMapper.selectById(id);
}
@Override
public Long insert(SysDicType sysDicType) {
// 校验必填项
if (sysDicType.getDicName() == null || sysDicType.getDicName().trim().isEmpty()) {
throw new IllegalArgumentException("字典名称不能为空");
}
int count = sysDicTypeMapper.insert(sysDicType);
return count > 0 ? sysDicType.getId() : null;
}
@Override
public Boolean update(SysDicType sysDicType) {
if (sysDicType.getId() == null) {
throw new IllegalArgumentException("字典类型ID不能为空");
}
// 校验是否存在
SysDicType exist = sysDicTypeMapper.selectById(sysDicType.getId());
if (exist == null) {
return false;
}
int count = sysDicTypeMapper.update(sysDicType);
return count > 0;
}
@Override
public Boolean deleteById(Long id) {
if (id == null) {
throw new IllegalArgumentException("字典类型ID不能为空");
}
// 校验是否存在
SysDicType exist = sysDicTypeMapper.selectById(id);
if (exist == null) {
return false;
}
int count = sysDicTypeMapper.deleteById(id);
return count > 0;
}
}

View File

@@ -1,140 +0,0 @@
package com.rczn.system.service.impl;
import com.github.pagehelper.PageHelper;
import com.rczn.domain.PageBean;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.Role;
import com.rczn.system.mapper.SysPermissionMapper;
import com.rczn.system.service.SysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class SysPermissionServiceImpl implements SysPermissionService {
@Autowired
private SysPermissionMapper sysPermissionMapper;
@Override
public Permission getPermissionById(Integer id) {
return sysPermissionMapper.selectPermissionById(id);
}
@Override
public boolean addPermission(Permission permission) {
return sysPermissionMapper.insertPermission(permission) > 0;
}
@Override
public boolean updatePermission(Permission permission) {
return sysPermissionMapper.updatePermission(permission) > 0;
}
@Override
public boolean deletePermission(Integer id) {
return sysPermissionMapper.deletePermissionById(id) > 0;
}
/**
* 1. 分页查询角色(多条件模糊查询)
*
* @param pageNum
* @param pageSize
* @param permissionName
* @return
*/
@Override
public PageBean<Permission> selectRolePage(Integer pageNum, Integer pageSize,Integer parentId, String permissionName) {
// 1. PageHelper 设置分页参数
PageHelper.startPage(pageNum, pageSize);
//加一层过滤:
if(parentId == 0){
parentId = null;
}
// 2. 执行查询
List<Permission> permissionList = sysPermissionMapper.selectPermissionPage(parentId,permissionName);
// 3. 查询总条数
Long total = sysPermissionMapper.selectTotal(parentId,permissionName);
// 4. 封装分页结果
return new PageBean<Permission>() {{
setTotal(total);
setItems(permissionList);
}};
}
@Override
public List<Permission> getPermissionList() {
// 1. 查询所有平级权限
List<Permission> allPermissions = sysPermissionMapper.selectPermissionList();
// 2. 找到顶层节点parentId = null 或 0
List<Permission> topNodes = new ArrayList<>();
for (Permission p : allPermissions) {
if (p.getParentId() == null || p.getParentId() == 0) {
topNodes.add(p);
}
}
// 3. 循环给每个顶层节点设置子节点(递归)
for (Permission node : topNodes) {
node.setChildren(findChildren(node, allPermissions));
}
return topNodes;
}
/***
* 根据父ID查询权限列表
* @param parentId
* @return
*/
@Override
public List<Permission> getPermissionListByParentId(Integer parentId) {
// 1. 查询所有平级权限
List<Permission> allPermissions = sysPermissionMapper.selectPermissionList();
// 2. 找到顶层节点parentId = null 或 0
List<Permission> topNodes = new ArrayList<>();
for (Permission p : allPermissions) {
if(parentId == null || parentId == 0){
if (p.getParentId() == null || p.getParentId() == 0) {
topNodes.add(p);
}
}else {
if (p.getParentId() == parentId) {
topNodes.add(p);
}
}
}
// 3. 循环给每个顶层节点设置子节点(递归)
for (Permission node : topNodes) {
node.setChildren(findChildren(node, allPermissions));
}
return topNodes;
}
/**
* 递归查找子节点(最稳妥、最清晰、不会漏)
*/
private List<Permission> findChildren(Permission parent, List<Permission> allList) {
List<Permission> children = new ArrayList<>();
for (Permission p : allList) {
// 子节点的 parentId == 父节点 id
if (parent.getId().equals(p.getParentId()==null?0:p.getParentId().longValue())) {
children.add(p);
// 递归给子节点设置孙子节点
p.setChildren(findChildren(p, allList));
}
}
return children;
}
}

View File

@@ -3,7 +3,6 @@ package com.rczn.system.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rczn.domain.PageBean;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.Position;
import com.rczn.system.domain.UserRole;
import com.rczn.system.mapper.UserRoleMapper;

View File

@@ -3,7 +3,6 @@ package com.rczn.system.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rczn.domain.PageBean;
import com.rczn.system.domain.Permission;
import com.rczn.system.domain.User;
import com.rczn.system.mapper.UserMapper;
import com.rczn.system.service.UserService;
@@ -91,41 +90,4 @@ public class UserServiceImpl implements UserService {
int rows = userMapper.deleteById(id,null);
return rows > 0;
}
/**
* 6. 根据用户名查询用户
*
* @param username 用户名
* @return 用户实体
*/
@Override
public User findeUserByUsername(String username) {
return userMapper.selectByUsername(username);
}
/**
* 7. 注册用户
*
* @param username 用户名
* @param password 密码
*/
@Override
public int register(String username, String password) {
User user = new User();
user.setUserName(username);
user.setPassword(password);
return userMapper.insert(user);
}
/**
* 根据用户id查询出关联的用户权限对象列表
* 表直接的关系是:
* 用户表user--用户权限表user_role--权限表role-- 权限资源表role_resource--资源表resource
*
* @param userId
*/
@Override
public List<Permission> findUserPermissions(Long userId) {
return userMapper.findUserPermissions(userId);
}
}

View File

@@ -14,7 +14,7 @@ spring:
# 数据源配置MySQL 8.x
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://47.116.126.33:3306/rc_autoplc_program?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
url: jdbc:mysql://47.116.126.33:3306/rc_autoplc_program?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: nianke
password: Jy@.niankeCrm2025
# 解决跨域可选配合之前的CorsConfig
@@ -42,12 +42,11 @@ spring:
mybatis:
configuration:
map-underscore-to-camel-case: true # 下划线转驼峰
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 关键SQL 打印到控制台
log-prefix: "[MyBatis] " # 可选:日志前缀,便于区分 SQL 日志
default-statement-timeout: 30 # 可选SQL 执行超时时间(秒)
mapper-locations: classpath:mapper/**/*.xml # 补充指定Mapper.xml文件路径必加
type-aliases-package: com.rczn.**.domain # 补充:实体类别名包(可选)
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 关键SQL 打印到控制台
log-prefix: "[MyBatis] " # 可选:日志前缀,便于区分 SQL 日志
default-statement-timeout: 30 # 可选SQL 执行超时时间(秒)
# HikariCP 连接池配置(关键)
hikari:
@@ -67,22 +66,22 @@ pagehelper:
support-methods-arguments: true # 支持通过 Mapper 接口参数传递分页参数
params: count=countSql # 分页参数名映射
#
## SpringDoc OpenAPI 3 核心配置适配Spring Boot 3.x
#springdoc:
# packages-to-scan: com.rczn # 扫描的基础包Controller所在包
# api-docs:
# enabled: true # 启用/v3/api-docs接口
# path: /v3/api-docs # OpenAPI JSON数据路径默认
# swagger-ui:
# path: /swagger-ui.html # 自定义Swagger UI访问路径兼容Spring Boot 2.x习惯
# tags-sorter: alpha # 标签字母排序
# operations-sorter: alpha # 接口字母排序
# disable-swagger-default-url: true # 禁用默认PetStore示例
# default-flat-param-object: false # 禁用扁平参数对象
# paths-to-exclude: /error, /actuator/** # 排除错误接口/监控接口(可选)
#
## OpenAPI文档基础信息中文正常显示
# SpringDoc OpenAPI 3 核心配置适配Spring Boot 3.x
springdoc:
packages-to-scan: com.rczn # 扫描的基础包Controller所在包
api-docs:
enabled: true # 启用/v3/api-docs接口
path: /v3/api-docs # OpenAPI JSON数据路径默认
swagger-ui:
path: /swagger-ui.html # 自定义Swagger UI访问路径兼容Spring Boot 2.x习惯
tags-sorter: alpha # 标签字母排序
operations-sorter: alpha # 接口字母排序
disable-swagger-default-url: true # 禁用默认PetStore示例
default-flat-param-object: false # 禁用扁平参数对象
paths-to-exclude: /error, /actuator/** # 排除错误接口/监控接口(可选)
# OpenAPI文档基础信息中文正常显示
openapi:
info:
title: XX自动化编程系统API文档
@@ -97,40 +96,6 @@ openapi:
- url: http://47.116.126.33:9090 # 测试环境地址
description: 测试环境
# SpringDoc + Knife4j 核心配置
springdoc:
packages-to-scan: com.rczn # 扫描Controller所在包
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
tags-sorter: alpha
operations-sorter: alpha
paths-to-exclude: /error, /actuator/**
# Knife4j增强配置可选开启中文UI
knife4j:
enable: true
setting:
language: zh_cn # 中文界面
enable-swagger-models: true # 显示模型
enable-document-manage: false # 关闭文档管理(开发环境)
# OpenAPI文档信息
#openapi:
# info:
# title: XX自动化编程系统API文档
# description: SpringBoot 3.x + Knife4j + OpenAPI 3 接口文档
# version: 1.0.0
# contact:
# name: 研发组
# email: xxx@xxx.com
# servers:
# - url: http://localhost:9090
# description: 本地开发环境
# - url: http://47.116.126.33:9090
# description: 测试环境
# Spring Boot 日志核心配置
logging:
# 1. 全局日志级别(可细化到包/类)

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.rczn.rcznautoplc.mapper.ManageLogMapper">
<mapper namespace="com.rczn.system.mapper.ManageLogMapper">
<!-- 公共字段BaseBean 继承的字段) -->
<sql id="baseColumn">
@@ -13,7 +13,7 @@
</sql>
<!-- 结果集映射(关联数据库列与实体类字段) -->
<resultMap id="LogResultMap" type="com.rczn.rcznautoplc.domain.ManageLog">
<resultMap id="LogResultMap" type="com.rczn.system.domain.ManageLog">
<!-- 公共字段映射 -->
<id column="id" property="id"/>
<result column="create_id" property="createId"/>
@@ -107,7 +107,7 @@
</select>
<!-- 5. 分页查询日志(空字段忽略条件) -->
<select id="selectPage" resultMap="LogResultMap" parameterType="com.rczn.rcznautoplc.domain.ManageLog">
<select id="selectPage" resultMap="LogResultMap" parameterType="com.rczn.system.domain.ManageLog">
SELECT
<include refid="baseColumn"/>,
<include refid="logColumn"/>
@@ -144,7 +144,7 @@
</select>
<!-- 6. 查询分页总数(与分页查询条件一致) -->
<select id="selectTotal" resultType="java.lang.Long" parameterType="com.rczn.rcznautoplc.domain.ManageLog">
<select id="selectTotal" resultType="java.lang.Long" parameterType="com.rczn.system.domain.ManageLog">
SELECT COUNT(*)
FROM sys_manage_log
<where>

View File

@@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.rczn.system.mapper.RolePermissionMapper">
<resultMap id="RolePermissionResultMap" type="com.rczn.system.domain.RolePermission">
<id column="id" property="id"/>
<result column="role_id" property="roleId"/>
<result column="permission_id" property="permissionId"/>
</resultMap>
<sql id="baseColumn">
id, role_id, permission_id
</sql>
<select id="selectListByRoleId" resultMap="RolePermissionResultMap">
SELECT <include refid="baseColumn"/>
FROM sys_role_permission
WHERE role_id = #{roleId}
</select>
<insert id="insert">
INSERT INTO sys_role_permission (role_id, permission_id)
VALUES (#{roleId}, #{permissionId})
</insert>
<delete id="delete">
DELETE FROM sys_role_permission
<where>
<if test="roleId != null">
role_id = #{roleId}
</if>
<if test="permissionId != null">
AND permission_id = #{permissionId}
</if>
</where>
</delete>
<delete id="deleteByRoleId">
DELETE FROM sys_role_permission
WHERE role_id = #{roleId}
</delete>
</mapper>

View File

@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.rczn.system.mapper.SysDicDataMapper">
<sql id="baseColumn">
id, create_by, create_time, update_by, update_time, del_sign, remark
</sql>
<sql id="dicDataColumn">
dic_id, dic_label, dic_value
</sql>
<!-- 新增字典数据 -->
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sys_dic_data (
<include refid="dicDataColumn"/>,
create_by, create_time, update_by, update_time, del_sign
) VALUES (
#{dicId}, #{dicLabel}, #{dicValue},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
<!-- 修改字典数据 -->
<update id="update">
UPDATE sys_dic_data
<set>
<if test="dicId != null">dic_id = #{dicId},</if>
<if test="dicLabel != null and dicLabel != ''">dic_label = #{dicLabel},</if>
<if test="dicValue != null and dicValue != ''">dic_value = #{dicValue},</if>
<if test="updateId != null">update_by = #{updateId},</if>
update_time = NOW()
</set>
WHERE id = #{id} AND del_sign = 0
</update>
<!-- 逻辑删除字典数据 -->
<update id="deleteById">
UPDATE sys_dic_data
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<!-- 根据ID查询字典数据 -->
<select id="selectById" resultType="com.rczn.system.domain.SysDicData">
SELECT
<include refid="baseColumn"/>,
<include refid="dicDataColumn"/>
FROM sys_dic_data
WHERE id = #{id} AND del_sign = 0
</select>
<!-- 分页查询字典数据支持按字典类型ID、标签、值查询 -->
<select id="selectPage" resultType="com.rczn.system.domain.SysDicData">
SELECT
<include refid="baseColumn"/>,
<include refid="dicDataColumn"/>
FROM sys_dic_data
WHERE del_sign = 0
<if test="dicId != null">AND dic_id = #{dicId}</if>
<if test="dicLabel != null and dicLabel != ''">AND dic_label LIKE CONCAT('%', #{dicLabel}, '%')</if>
<if test="dicValue != null and dicValue != ''">AND dic_value LIKE CONCAT('%', #{dicValue}, '%')</if>
ORDER BY create_time DESC
</select>
<!-- 根据字典类型ID查询字典数据列表 -->
<select id="selectByDicId" resultType="com.rczn.system.domain.SysDicData">
SELECT
<include refid="baseColumn"/>,
<include refid="dicDataColumn"/>
FROM sys_dic_data
WHERE dic_id = #{dicId} AND del_sign = 0
ORDER BY create_time DESC
</select>
</mapper>

View File

@@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.rczn.system.mapper.SysDicTypeMapper">
<sql id="baseColumn">
id, create_by, create_time, update_by, update_time, del_sign, remark
</sql>
<sql id="dicTypeColumn">
dic_name, dic_code
</sql>
<!-- 新增字典类型 -->
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO sys_dic_type (
<include refid="dicTypeColumn"/>,
create_by, create_time, update_by, update_time, del_sign
) VALUES (
#{dicName}, #{dicCode},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
<!-- 修改字典类型 -->
<update id="update">
UPDATE sys_dic_type
<set>
<if test="dicName != null and dicName != ''">dic_name = #{dicName},</if>
<if test="dicCode != null and dicCode != ''">dic_code = #{dicCode},</if>
<if test="updateId != null">update_by = #{updateId},</if>
update_time = NOW()
</set>
WHERE id = #{id} AND del_sign = 0
</update>
<!-- 逻辑删除字典类型 -->
<update id="deleteById">
UPDATE sys_dic_type
SET del_sign = 1, update_time = NOW()
WHERE id = #{id} AND del_sign = 0
</update>
<!-- 根据ID查询字典类型 -->
<select id="selectById" resultType="com.rczn.system.domain.SysDicType">
SELECT
<include refid="baseColumn"/>,
<include refid="dicTypeColumn"/>
FROM sys_dic_type
WHERE id = #{id} AND del_sign = 0
</select>
<!-- 分页查询字典类型 -->
<select id="selectPage" resultType="com.rczn.system.domain.SysDicType">
SELECT
<include refid="baseColumn"/>,
<include refid="dicTypeColumn"/>
FROM sys_dic_type
WHERE del_sign = 0
<if test="dicName != null and dicName != ''">AND dic_name LIKE CONCAT('%', #{dicName}, '%')</if>
<if test="dicCode != null and dicCode != ''">AND dic_code LIKE CONCAT('%', #{dicCode}, '%')</if>
ORDER BY create_time DESC
</select>
</mapper>

View File

@@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.rczn.system.mapper.SysPermissionMapper">
<resultMap id="PermissionResultMap" type="com.rczn.system.domain.Permission">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="permission_name" property="permissionName"/>
<result column="permission_code" property="permissionCode"/>
<result column="create_id" property="createId"/>
<result column="create_time" property="createTime"/>
<result column="update_id" property="updateId"/>
<result column="update_time" property="updateTime"/>
<result column="del_sign" property="delSign"/>
<result column="remark" property="remark"/>
</resultMap>
<!-- 查询所有 -->
<select id="selectPermissionList" resultMap="PermissionResultMap">
SELECT * FROM sys_permission
WHERE del_sign = 0
</select>
<!-- 根据ID查询 -->
<select id="selectPermissionById" resultMap="PermissionResultMap">
SELECT * FROM sys_permission
WHERE id = #{id} AND del_sign = 0
</select>
<!-- 查询总数量 -->
<select id="selectTotal" resultType="java.lang.Long">
SELECT COUNT(*) FROM sys_permission
WHERE del_sign = 0
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="permissionName != null and permissionName != ''"> AND permission_name LIKE CONCAT('%', #{permissionName}, '%')</if>
</select>
<!-- 根据条件分页查询权限数据: -->
<select id="selectPermissionPage" resultType="com.rczn.system.domain.Permission">
SELECT * FROM sys_permission
WHERE del_sign = 0
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="permissionName != null and permissionName != ''"> AND permission_name LIKE CONCAT('%', #{permissionName}, '%')</if>
</select>
<!-- 新增 -->
<insert id="insertPermission">
INSERT INTO sys_permission
(parent_id, permission_name, permission_code, create_id, remark, del_sign)
VALUES
(#{parentId}, #{permissionName}, #{permissionCode}, #{createId}, #{remark}, 0)
</insert>
<!-- 修改 -->
<update id="updatePermission">
UPDATE sys_permission
SET
parent_id = #{parentId},
permission_name = #{permissionName},
permission_code = #{permissionCode},
update_id = #{updateId},
remark = #{remark}
WHERE id = #{id}
</update>
<!-- 逻辑删除 -->
<update id="deletePermissionById">
UPDATE sys_permission SET del_sign = 1 WHERE id = #{id}
</update>
</mapper>

View File

@@ -198,24 +198,5 @@
</if>
</where>
</select>
<select id="findUserPermissions" resultType="com.rczn.system.domain.Permission">
SELECT
p.*
FROM
sys_user u
JOIN
sys_user_role ur ON u.id = ur.user_id
JOIN
sys_role r ON ur.role_id = r.id
JOIN
sys_role_permission rp ON r.id = rp.role_id
JOIN
sys_permission p ON rp.permission_id = p.id
WHERE
u.id = #{userId}
AND u.del_sign = 0
AND r.del_sign = 0
AND p.del_sign = 0;
</select>
</mapper>

View File

@@ -1,13 +0,0 @@
package com.rczn;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class RcznAdminApplicationTests {
// @Test
void contextLoads() {
}
}

View File

@@ -38,7 +38,6 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
@@ -47,7 +46,12 @@
<version>5.3.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations-jakarta</artifactId>
<version>2.2.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
@@ -65,18 +69,14 @@
<version>7.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models-jakarta</artifactId>
<version>2.2.19</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-common</artifactId>
<version>2.3.0</version>
<scope>compile</scope>
</dependency>
<!-- 这里可以添加PLC通信相关的依赖 -->
<!-- 这里可以添加PLC通信相关的依赖 -->
<!-- 例如:
<dependency>
<groupId>com.github.s7connector</groupId>

View File

@@ -1,28 +0,0 @@
package com.rczn.rcznautoplc.cache;
import java.util.HashMap;
import java.util.Map;
/**
* 1-功能岛>plc地址
* 2-动作单元>plc地址
* 3-参数名字>plc地址
* 三个映射关系Map表
*/
public class IsLandActionParamToPlc {
// 1-功能岛>plc地址:key-功能岛idvalue-功能岛plc地址
public static final Map<Integer, Integer> islandToPlc = new HashMap<>();
// 2-动作单元>plc地址:key-动作单元idvalue-动作单元plc地址
public static final Map<Integer, Integer> actionToPlc = new HashMap<>();
// 3-参数名字>plc地址:key-参数名字value-参数plc地址
public static final Map<String, Integer> paramToPlc = new HashMap<>();
//4-参数id>plc地址:key-参数idvalue-参数plc地址
public static final Map<Integer,Integer> paramIdToPlc = new HashMap<>();
//更新三种数据的方法
//获取spring里面bean
//1-功能岛>plc地址
}

View File

@@ -1,110 +0,0 @@
package com.rczn.rcznautoplc.cache;
//样品准备状态
public class PlcRunStatus {
//定容岛:状态属性:
public static int goodsScanStatus = 0; //货物扫描:0-准备1-扫描完毕
//plc系统运行状态
public static int systemPlcRunStatus = 0; //系统准备:0-未准备1-空闲2-忙4异常
public static int goodsCount = 0;//样品处理数量
public static int goodsCurrentIndex = 0;//当前样品处理索引
//404内照射项目默认样品尿液液体
public static String defaultGoodsName = "尿液";
public static String defaultGoodsType = "液体";
//目标监测物
public static String defaultGoalDetect = "总氮";
public static class PlcRunStatusResponse{
private int goodsScanStatus = 0; //货物扫描:0-准备1-扫描完毕
private int systemPlcRunStatus = 0; //系统准备:0-未准备1-空闲2-忙4异常
private int goodsCount = 0;//样品处理数量
private int goodsCurrentIndex = 0;//当前样品处理索引
private String defaultGoodsName = "尿液";//默认样品名称
private String defaultGoodsType = "液体";//默认样品类型
private String defaultGoalDetect = "总氮";//默认目标监测物
public PlcRunStatusResponse() {
}
public PlcRunStatusResponse(int goodsScanStatus, int systemPlcRunStatus, int goodsCount, int goodsCurrentIndex, String defaultGoodsName, String defaultGoodsType, String defaultGoalDetect) {
this.goodsScanStatus = goodsScanStatus;
this.systemPlcRunStatus = systemPlcRunStatus;
this.goodsCount = goodsCount;
this.goodsCurrentIndex = goodsCurrentIndex;
this.defaultGoodsName = defaultGoodsName;
this.defaultGoodsType = defaultGoodsType;
this.defaultGoalDetect = defaultGoalDetect;
}
public int getGoodsScanStatus() {
return goodsScanStatus;
}
public void setGoodsScanStatus(int goodsScanStatus) {
this.goodsScanStatus = goodsScanStatus;
}
public int getSystemPlcRunStatus() {
return systemPlcRunStatus;
}
public void setSystemPlcRunStatus(int systemPlcRunStatus) {
this.systemPlcRunStatus = systemPlcRunStatus;
}
public int getGoodsCount() {
return goodsCount;
}
public void setGoodsCount(int goodsCount) {
this.goodsCount = goodsCount;
}
public int getGoodsCurrentIndex() {
return goodsCurrentIndex;
}
public void setGoodsCurrentIndex(int goodsCurrentIndex) {
this.goodsCurrentIndex = goodsCurrentIndex;
}
public String getDefaultGoodsName() {
return defaultGoodsName;
}
public void setDefaultGoodsName(String defaultGoodsName) {
this.defaultGoodsName = defaultGoodsName;
}
public String getDefaultGoodsType() {
return defaultGoodsType;
}
public void setDefaultGoodsType(String defaultGoodsType) {
this.defaultGoodsType = defaultGoodsType;
}
public String getDefaultGoalDetect() {
return defaultGoalDetect;
}
public void setDefaultGoalDetect(String defaultGoalDetect) {
this.defaultGoalDetect = defaultGoalDetect;
}
}
}

View File

@@ -1,17 +0,0 @@
package com.rczn.rcznautoplc.cache;
public class RegisterAddrDic {
//主PLC寄存器地址
public final static int goodsScanRegisterArr = 5000;//样品扫描状态寄存器地址:
//整体运转状态:
public final static int wholeRunStatusRegisterArr = 1100;//整体运转状态寄存器地址:
//协议存储地址:
//1-下发plc样品sop指令协议寄存器地址
public final static int downProtcolRegisterArr = 2000;//协议存储寄存器地址:
//2-接收plc处理样品状态数据协议寄存器地址
public final static int upProtcolRegisterArr = 3000;//协议存储寄存器地址:
}

View File

@@ -1,6 +1,5 @@
package com.rczn.rcznautoplc.controller;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.DevInfo;
import com.rczn.rcznautoplc.service.DevInfoService;
import com.github.pagehelper.PageInfo;
@@ -26,7 +25,7 @@ import java.util.Map;
*/
@RestController
@RequestMapping("/devInfo")
@Tag(name = "动作单元管理", description = "设备增删改查+分页查询+全量查询接口")
@Tag(name = "设备管理", description = "设备增删改查+分页查询+全量查询接口")
public class DevInfoController {
@Autowired
@@ -36,15 +35,15 @@ public class DevInfoController {
* 新增设备
*/
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增动作单元", description = "动作单元名称为必填项,其他字段可选(非空则入库)")
@Operation(summary = "新增设备", description = "设备名称为必填项,其他字段可选(非空则入库)")
public ResponseEntity<Map<String, Object>> addDevInfo(
@Parameter(name = "动作单元信息", description = "动作单元新增请求参数", required = true)
@Parameter(name = "设备信息", description = "设备新增请求参数", required = true)
@RequestBody DevInfo devInfo) {
Map<String, Object> result = new HashMap<>();
try {
boolean success = devInfoService.addDevInfo(devInfo);
result.put("success", success);
result.put("message", success ? "动作单元新增成功" : "动作单元新增失败");
result.put("message", success ? "设备新增成功" : "设备新增失败");
return ResponseEntity.ok(result);
} catch (IllegalArgumentException e) {
result.put("success", false);
@@ -61,15 +60,15 @@ public class DevInfoController {
* 根据ID删除设备逻辑删除
*/
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除动作单元", description = "逻辑删除设置delSign=1不物理删除数据")
@Operation(summary = "删除设备", description = "逻辑删除设置delSign=1不物理删除数据")
public ResponseEntity<Map<String, Object>> removeDevInfoById(
@Parameter(name = "id", description = "动作单元ID", required = true, example = "1")
@Parameter(name = "id", description = "设备ID", required = true, example = "1")
@PathVariable Long id) {
Map<String, Object> result = new HashMap<>();
try {
boolean success = devInfoService.removeDevInfoById(id);
result.put("success", success);
result.put("message", success ? "动作单元删除成功" : "动作单元不存在或已删除");
result.put("message", success ? "设备删除成功" : "设备不存在或已删除");
return ResponseEntity.ok(result);
} catch (IllegalArgumentException e) {
result.put("success", false);
@@ -86,15 +85,15 @@ public class DevInfoController {
* 更新设备
*/
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改动作单元", description = "需传入动作单元ID其他字段可选非空则更新")
@Operation(summary = "修改设备", description = "需传入设备ID其他字段可选非空则更新")
public ResponseEntity<Map<String, Object>> updateDevInfo(
@Parameter(name = "动作单元信息", description = "动作单元修改请求参数含ID", required = true)
@Parameter(name = "设备信息", description = "设备修改请求参数含ID", required = true)
@RequestBody DevInfo devInfo) {
Map<String, Object> result = new HashMap<>();
try {
boolean success = devInfoService.updateDevInfo(devInfo);
result.put("success", success);
result.put("message", success ? "动作单元更新成功" : "动作单元不存在或已删除");
result.put("message", success ? "设备更新成功" : "设备不存在或已删除");
return ResponseEntity.ok(result);
} catch (IllegalArgumentException e) {
result.put("success", false);
@@ -108,12 +107,12 @@ public class DevInfoController {
}
/**
* 根据ID查询动作单元
* 根据ID查询设备
*/
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个动作单元", description = "根据动作单元ID查询动作单元完整信息")
@Operation(summary = "查询单个设备", description = "根据设备ID查询设备完整信息")
public ResponseEntity<Map<String, Object>> getDevInfoById(
@Parameter(name = "id", description = "动作单元ID", required = true, example = "1")
@Parameter(name = "id", description = "设备ID", required = true, example = "1")
@PathVariable Long id) {
Map<String, Object> result = new HashMap<>();
try {
@@ -123,7 +122,7 @@ public class DevInfoController {
result.put("data", devInfo);
} else {
result.put("success", false);
result.put("message", "动作单元不存在或已删除");
result.put("message", "设备不存在或已删除");
}
return ResponseEntity.ok(result);
} catch (IllegalArgumentException e) {
@@ -138,29 +137,33 @@ public class DevInfoController {
}
/**
* 分页查询动作单元
* 示例:/devInfo/listPage?pageNum=1&pageSize=10&devName=动作单元1&status=0
* 分页查询设备
* 示例:/devInfo/listPage?pageNum=1&pageSize=10&devName=设备1&status=0
*/
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询动作单元", description = "支持动作单元名称、型号、IP、状态等多条件过滤默认查询未删除动作单元")
@Operation(summary = "分页查询设备", description = "支持设备名称、型号、IP、状态等多条件过滤默认查询未删除设备")
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY)
// @Parameter(name = "devName", description = "设备名称(可选,模糊查询)", required = false, example = "PLC设备", in = ParameterIn.QUERY),
// @Parameter(name = "devModel", description = "设备型号(可选,模糊查询)", required = false, example = "S7-1200", in = ParameterIn.QUERY)
})
public Result getDevInfoPage(
public ResponseEntity<Map<String, Object>> getDevInfoPage(
@ParameterObject // 核心注解:标记该实体类从查询参数取值
@Schema(description = "设备查询条件(可选)") // 补充描述
DevInfo devInfo, // 接收查询条件devName、status等
@RequestParam Integer pageNum,
@RequestParam Integer pageSize) {
Map<String, Object> result = new HashMap<>();
try {
PageInfo<DevInfo> pageInfo = devInfoService.getDevInfoPage(devInfo, pageNum, pageSize);
Result<PageInfo<DevInfo>> success = Result.success(pageInfo);
return success;
result.put("success", true);
result.put("data", pageInfo);
return ResponseEntity.ok(result);
} catch (Exception e) {
return Result.error("数据库异常!");
result.put("success", false);
result.put("message", "服务器异常:" + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result);
}
}

View File

@@ -4,7 +4,6 @@ import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.DevParam;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import com.rczn.rcznautoplc.service.DevParamService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -34,7 +33,6 @@ public class DevParamController {
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "devId", description = "设备ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramTypeData", description = "参数类型(可选,模糊查询)", required = false, example = "耗材,通用", in = ParameterIn.QUERY),
@Parameter(name = "paramName", description = "参数名称(可选,模糊查询)", required = false, example = "温度", in = ParameterIn.QUERY),
@Parameter(name = "paramValue", description = "参数值(可选,模糊查询)", required = false, example = "25", in = ParameterIn.QUERY)
})
@@ -42,10 +40,9 @@ public class DevParamController {
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer devId,
@RequestParam(required = false) String paramTypeData,
@RequestParam(required = false) String paramName,
@RequestParam(required = false) String paramValue) {
PageInfo<DevParam> pageBean = devParamService.selectPage(pageNum, pageSize, devId,paramTypeData, paramName, paramValue);
PageInfo<DevParam> pageBean = devParamService.selectPage(pageNum, pageSize, devId, paramName, paramValue);
return Result.success(pageBean);
}
@@ -56,57 +53,17 @@ public class DevParamController {
@Operation(summary = "查询设备参数", description = "支持设备ID精准查询、参数名称/值模糊查询")
@Parameters({
@Parameter(name = "devId", description = "设备ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramTypeData", description = "参数类型(可选,模糊查询)", required = false, example = "耗材,通用", in = ParameterIn.QUERY),
@Parameter(name = "paramName", description = "参数名称(可选,模糊查询)", required = false, example = "温度", in = ParameterIn.QUERY),
@Parameter(name = "paramValue", description = "参数值(可选,模糊查询)", required = false, example = "25", in = ParameterIn.QUERY)
})
public Result getDevParamPage(
@RequestParam(required = false) Integer devId,
@RequestParam(required = false) String paramTypeData,
@RequestParam(required = false) String paramName,
@RequestParam(required = false) String paramValue) {
DevParamQuery query = new DevParamQuery();
query.setDevId(devId);
query.setParamTypeData(paramTypeData);
query.setParamName(paramName);
query.setParamValue(paramValue);
List<DevParam> pageBean = devParamService.selectList( query);
List<DevParam> pageBean = devParamService.selectList( devId, paramName, paramValue);
return Result.success(pageBean);
}
/**
* 根据条件,查询设备参数
*/
@PostMapping(value = "/addDevId", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "为参数增加设备的devId", description = "为参数增加设备的devId")
@Parameters({
@Parameter(name = "devId", description = "设备ID", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramId", description = "参数Id", required = true, example = "1", in = ParameterIn.QUERY)
})
public Result addDevId(
@RequestParam(required = true) Integer devId,
@RequestParam(required = true) Integer paramId) {
Boolean result = devParamService.addDevId( devId, paramId );
return Result.success(result);
}
/**
* 根据条件,查询设备参数
*/
@PostMapping(value = "/delDevId", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "为参数减少设备的devId", description = "为参数减少设备的devId")
@Parameters({
@Parameter(name = "devId", description = "设备ID", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "paramId", description = "参数Id", required = true, example = "1", in = ParameterIn.QUERY)
})
public Result delDevId(
@RequestParam(required = true) Integer devId,
@RequestParam(required = true) Integer paramId) {
Boolean result = devParamService.reduceDevId( devId, paramId );
return Result.success(result);
}
/**
* 根据ID查询设备参数
*/

View File

@@ -1,13 +1,10 @@
package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.FlowInfo;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.rcznautoplc.domain.UserBusy;
import com.rczn.rcznautoplc.service.FlowInfoService;
import com.rczn.rcznautoplc.service.ManageLogService;
import com.rczn.utils.ThreadLocalUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -17,10 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/flowInfo")
@@ -30,6 +24,7 @@ public class FlowInfoController {
@Autowired
FlowInfoService flowInfoService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询流程信息", description = "支持流程排序精准查询、流程名称/岛屿ID列表模糊查询")
@Parameters({
@@ -76,23 +71,6 @@ public class FlowInfoController {
public Result addFlowInfo(@RequestBody FlowInfo flowInfo) {
try {
Long flowInfoId = flowInfoService.insert(flowInfo);
//记录操作样品执行SOP操作日志
LocalDateTime loginTime = LocalDateTime.now();
ManageLog info = new ManageLog();
// ========== 修复开始 ==========
Map<String, Object> mapClaims = ThreadLocalUtil.get();
UserBusy userBusy = new UserBusy();
userBusy.setId(Long.valueOf( mapClaims.get("id").toString()));
userBusy.setUserName((String) mapClaims.get("username"));
// ========== 修复结束 ==========
info.setCreateId(userBusy.getId());
info.setLogName("基础数据操作日志");
info.setLogType("基础数据操作日志");//1登录日志、2SOP操作日志、3基础数据操作日志
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("用户名:").append(userBusy.getUserName()).append("SOP配置添加操作时间").append(loginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
info.setLogContent(stringBuilder.toString());
info.setCreateTime(loginTime);
manageLogService.insert(info);
return Result.success(flowInfoId);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
@@ -110,31 +88,11 @@ public class FlowInfoController {
}
}
@Autowired
ManageLogService manageLogService;
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除流程信息", description = "逻辑删除设置delSign=1不物理删除数据")
public Result deleteFlowInfo(@PathVariable Long id) {
try {
Boolean success = flowInfoService.deleteById(id);
//记录操作样品执行SOP操作日志
LocalDateTime loginTime = LocalDateTime.now();
ManageLog info = new ManageLog();
// ========== 修复开始 ==========
Map<String, Object> mapClaims = ThreadLocalUtil.get();
UserBusy userBusy = new UserBusy();
userBusy.setId(Long.valueOf( mapClaims.get("id").toString()));
userBusy.setUserName((String) mapClaims.get("username"));
// ========== 修复结束 ==========
info.setCreateId(userBusy.getId());
info.setLogName("基础数据操作日志");
info.setLogType("基础数据操作日志");//1登录日志、2SOP操作日志、3基础数据操作日志
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("用户名:").append(userBusy.getUserName()).append("SOP配置删除操作时间").append(loginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
info.setLogContent(stringBuilder.toString());
info.setCreateTime(loginTime);
manageLogService.insert(info);
return success ? Result.success(true) : Result.error("删除失败(流程信息不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());

View File

@@ -4,21 +4,16 @@ import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.query.GoodsFlowStatusQuery;
import com.rczn.rcznautoplc.service.GoodsFlowStatusService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/goodsFlowStatus")
@Tag(name = "样品流程信息管理", description = "样品流程状态增删改查+分页查询接口")
@@ -33,29 +28,22 @@ public class GoodsFlowStatusController {
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "goodsId", description = "样品ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "flowId", description = "流程ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "islandId", description = "岛屿ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "status", description = "状态可选精准查询0-未执行1-执行10-通过11-失败)", required = false, example = "10", in = ParameterIn.QUERY)
})
public Result getGoodsFlowStatusPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@ParameterObject
@Schema(description = "样品ID、流程ID、岛屿ID、状态精准查询条件")
GoodsFlowStatusQuery goodsFlowStatus) {
PageInfo<GoodsFlowStatus> pageBean = goodsFlowStatusService.selectPage(pageNum, pageSize, goodsFlowStatus);
@RequestParam(required = false) Integer goodsId,
@RequestParam(required = false) Integer flowId,
@RequestParam(required = false) Integer islandId,
@RequestParam(required = false) Integer status) {
PageInfo<GoodsFlowStatus> pageBean = goodsFlowStatusService.selectPage(pageNum, pageSize, goodsId, flowId, islandId, status);
return Result.success(pageBean);
}
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询样品流程状态", description = "支持样品ID、流程ID、岛屿ID、状态等精准查询")
@Parameters({
})
public Result getList(
@ParameterObject
@Schema(description = "样品ID、流程ID、岛屿ID、状态等精准查询条件")
GoodsFlowStatusQuery goodsFlowStatus) {
List<GoodsFlowStatus> list = goodsFlowStatusService.selectList( goodsFlowStatus);
return Result.success(list);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个样品流程状态", description = "根据样品流程状态ID查询详情")
public Result getGoodsFlowStatusById(@PathVariable Long id) {

View File

@@ -4,21 +4,16 @@ import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import com.rczn.rcznautoplc.service.GoodsInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/goodsInfo")
@Tag(name = "样品信息管理", description = "样品信息增删改查+分页查询接口")
@@ -34,37 +29,23 @@ public class GoodsInfoController {
@Operation(summary = "分页查询样品信息", description = "支持样品名称/类型/来源模糊查询、批次精准查询")
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY)
// @Parameter(name = "goodsName", description = "样品名称(可选,模糊查询)", required = false, example = "手机", in = ParameterIn.QUERY),
// @Parameter(name = "goodsType", description = "样品类型(可选,模糊查询)", required = false, example = "电子产品", in = ParameterIn.QUERY),
// @Parameter(name = "goodFrom", description = "样品来源(可选,模糊查询)", required = false, example = "深圳", in = ParameterIn.QUERY),
// @Parameter(name = "goodBatch", description = "样品批次(可选,精准查询)", required = false, example = "202501", in = ParameterIn.QUERY)
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "goodsName", description = "样品名称(可选,模糊查询)", required = false, example = "手机", in = ParameterIn.QUERY),
@Parameter(name = "goodsType", description = "样品类型(可选,模糊查询)", required = false, example = "电子产品", in = ParameterIn.QUERY),
@Parameter(name = "goodFrom", description = "样品来源(可选,模糊查询)", required = false, example = "深圳", in = ParameterIn.QUERY),
@Parameter(name = "goodBatch", description = "样品批次(可选,精准查询)", required = false, example = "202501", in = ParameterIn.QUERY)
})
public Result getGoodsInfoPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@ParameterObject
@Schema(description = "样品信息查询条件(可选)", name = "goodsInfo", required = false)
GoodsInfoQuery goodsInfo) {
PageInfo<GoodsInfo> pageBean = goodsInfoService.selectPage(pageNum, pageSize, goodsInfo);
@RequestParam(required = false) String goodsName,
@RequestParam(required = false) String goodsType,
@RequestParam(required = false) String goodFrom,
@RequestParam(required = false) Integer goodBatch) {
PageInfo<GoodsInfo> pageBean = goodsInfoService.selectPage(pageNum, pageSize, goodsName, goodsType, goodFrom, goodBatch);
return Result.success(pageBean);
}
/**
* 查询样品信息
*/
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询样品信息", description = "支持样品名称/类型/来源模糊查询、批次精准查询")
@Parameters({
})
public Result getList(
@ParameterObject
@Schema(description = "样品信息查询条件(可选)", name = "goodsInfo", required = false)
GoodsInfoQuery goodsInfo) {
List<GoodsInfo> list = goodsInfoService.selectList( goodsInfo);
return Result.success(list);
}
/**
* 根据ID查询样品信息
*/
@@ -89,21 +70,6 @@ public class GoodsInfoController {
}
}
/**
* 扫码新增样品信息
* 扫码信息:样品类型、样品编码、样品名称、样品点位
*/
@PostMapping(value = "/scanAdd", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "扫描新增样品", description = "样品名称、类型、编码、点位为必填项")
public Result scanAdd(@RequestBody GoodsInfo goodsInfo) {
try {
GoodsInfo goodInfoResult = goodsInfoService.insertByScan(goodsInfo);
return Result.success(goodInfoResult);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 修改样品信息
*/

View File

@@ -1,337 +0,0 @@
package com.rczn.rcznautoplc.controller;
import com.rczn.domain.Result;
import com.rczn.modbus.Modbus4jWriteUtils;
import com.rczn.rcznautoplc.cache.PlcRunStatus;
import com.rczn.rcznautoplc.domain.*;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import com.rczn.rcznautoplc.service.*;
import com.rczn.rcznautoplc.utils.PlcConnectMap;
import com.rczn.utils.ThreadLocalUtil;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.code.DataType;
import com.serotonin.modbus4j.exception.ErrorResponseException;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 设备信息 ControllerRESTful API
*/
@RestController
@RequestMapping("/plc")
@Tag(name = "plc设备控制类", description = "plc设备初始化查询控制方法集合")
public class PlcController {
@Autowired
private PlcService plcService;
/**
* 设备连接
*/
@PostMapping(value = "/connect", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "连接设备", description = "连接设备...")
public Result plcConnect(
@ParameterObject
@Schema(description = "plc设备参数")
ModbusConnectObj connectObj) {
ModbusMaster connectorInit;
if(PlcConnectMap.modbusConnectorMap.containsKey(connectObj.getIpAddr())){
return Result.error("设备连接已经存在!");
}
try {
connectorInit = plcService.connectModbus(connectObj);
if(connectorInit != null){
return Result.success(true);
}else {
return Result.error("设备连接失败!");
}
} catch (Exception e) {
return Result.error("设备连接失败!");
}
}
/**
* 向plc寄存器写数据
*/
@PostMapping(value = "/plcWrite", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "连接设备", description = "连接设备...")
public Result plcWrite(
@ParameterObject
@Schema(description = "plc设备参数")
ModbusConnectObj connectObj,
@Parameter
@Schema(description = "寄存器地址", required = true, example = "10000")
@RequestParam int registerAddress,
@Parameter
@Schema(description = "寄存器值", required = true, example = "12345")
@RequestParam int registerValue) {
ModbusMaster connectorInit;
if(PlcConnectMap.modbusConnectorMap.containsKey(connectObj.getIpAddr())){
connectorInit = PlcConnectMap.modbusConnectorMap.get(connectObj.getIpAddr());
try {
Modbus4jWriteUtils.writeHoldingRegister(connectorInit,1,registerAddress,registerValue, DataType.TWO_BYTE_INT_UNSIGNED);
} catch (ModbusTransportException e) {
throw new RuntimeException(e);
} catch (ErrorResponseException e) {
throw new RuntimeException(e);
} catch (ModbusInitException e) {
throw new RuntimeException(e);
}
return Result.error("设备连接已经存在!");
}
try {
connectorInit = plcService.connectModbus(connectObj);
if(connectorInit != null){
//往地址1000里面写入数据
Modbus4jWriteUtils.writeHoldingRegister(connectorInit,1,registerAddress,registerValue, DataType.TWO_BYTE_INT_UNSIGNED);
return Result.success(true);
}else {
return Result.error("设备连接失败!");
}
} catch (Exception e) {
return Result.error("设备连接失败!");
}
}
/**
* 根据ID删除设备逻辑删除
*/
@PostMapping(value = "/run")
@Operation(summary = "运行plc", description = "plc设备运行停止")
public Result runPlc(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Boolean success = plcService.startPlc(ipAddr);
return Result.success(success);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据ID删除设备逻辑删除
*/
@PostMapping(value = "/pause")
@Operation(summary = "暂停运行plc", description = "暂停运行plc")
public Result pausePlc(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Boolean success = plcService.pausePlc(ipAddr);
return Result.success(success);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据设备ip地址停止执行
*/
@PostMapping(value = "/stop")
@Operation(summary = "停止plc", description = "plc设备运行停止")
public Result stop(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Boolean success = plcService.stopPlc(ipAddr);
return Result.success(success);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址故障复位
*/
@PostMapping(value = "/resetError")
@Operation(summary = "plc设备复位故障", description = "plc设备复位故障")
public Result resetError(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Boolean success = plcService.resetErrorPlc(ipAddr);
return Result.success(success);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址获取plc设备状态
*/
@GetMapping(value = "/plcStatus")
@Operation(summary = "plc设备获取状态值", description = "状态值10-就绪11-执行中12-暂停中19已停止20-故障中")
public Result plcStatus(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Integer resultValue = plcService.getPlcStatus(ipAddr);
return Result.success(resultValue);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址获取plc设备状态
*/
@GetMapping(value = "/mastertPlcStatus")
@Operation(summary = "获取主plc状态对象", description = "goodsScanStatus = 0; //货物扫描:0-准备1-扫描完毕;//系统准备:0-未准备1-空闲2-忙4异常")
public Result mastertPlcStatus() {
try {
PlcRunStatus.PlcRunStatusResponse response = new PlcRunStatus.PlcRunStatusResponse();
response.setGoodsScanStatus(PlcRunStatus.goodsScanStatus);
response.setSystemPlcRunStatus(PlcRunStatus.systemPlcRunStatus);
response.setGoodsCount(PlcRunStatus.goodsCount);
response.setGoodsCurrentIndex(PlcRunStatus.goodsCurrentIndex);
response.setDefaultGoodsName(PlcRunStatus.defaultGoodsName);
response.setDefaultGoodsType(PlcRunStatus.defaultGoodsType);
response.setDefaultGoalDetect(PlcRunStatus.defaultGoalDetect);
return Result.success(response);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址设置plc设备模式
* 0-手动模式1-自动模式
*/
@PostMapping(value = "/setModel")
@Operation(summary = "plc设备设置模式", description = "模式值0-手动模式1-自动模式")
public Result setModel(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123", in = ParameterIn.QUERY)
@RequestParam String ipAddr,
@Parameter(name = "model", description = "设备模式值", required = true, example = "0-1", in = ParameterIn.QUERY)
@RequestParam Integer model) {
try {
Boolean resultValue = plcService.setPlcModel(ipAddr,model);
return Result.success(resultValue);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址获取plc设备模式
* 0-手动模式1-自动模式
*/
@GetMapping(value = "/getModel")
@Operation(summary = "plc设备获取模式值", description = "模式值0-手动模式1-自动模式")
public Result getModel(
@Parameter(name = "ipAddr", description = "设备ip地址", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
try {
Integer resultValue = plcService.getPlcModel(ipAddr);
return Result.success(resultValue);
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 更新设备
*/
@GetMapping(value = "/getAll", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "获取全部plc连接对象", description = "获取全部plc连接对象")
public Result getPlcAll() {
Map<String,ModbusMaster> connectorMap = plcService.modbusALlMap();
return Result.success(connectorMap);
}
/**
* 根据ID查询设备
*/
@GetMapping(value = "/getPlcByIp", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "更加ip地址查询plc连接对象", description = "更加ip地址查询plc连接对象")
public Result getConnectByIpaddr(
@Parameter(name = "ipAddr", description = "设备IP", required = true, example = "192.168.1.123")
@RequestParam String ipAddr) {
ModbusMaster connector = plcService.getModbusConnect(ipAddr);
return Result.success(connector);
}
/**
* 查询所有设备(不分页)
*/
@PostMapping(value = "/doAction", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "调用plc设备执行动作", description = "根据plc设备ip执行动作")
public Result doAction(
@RequestParam String ip,
@RequestParam String action
) {
Boolean aBoolean = plcService.doAction(ip, action);
return Result.success(aBoolean);
}
@Autowired
StepInfoService stepInfoService;
@Autowired
GoodsInfoService goodsInfoService;
@Autowired
ManageLogService manageLogService;
@PostMapping(value = "/runFlow")
@Operation(summary = "为样品执行国标" ,description = "为样品执行国标")
public Result doStandGoods(
@RequestParam String plcIp,
@RequestParam Integer flowId,
@RequestParam List<Integer> goodsIds
){
//根据flowId获取步骤信息表
StepInfoQuery stepInfo = new StepInfoQuery();
stepInfo.setFlowId(flowId);
List<StepInfo> stepInfoList = stepInfoService.selectList(stepInfo);
//stepInfoList根据StepInfo里面的stepOrderint排序
stepInfoList.sort(Comparator.comparing(StepInfo::getStepOrder));
//根据goodsIds获取样品信息的 bar_code编码列表
List<GoodsInfo> goodsInfoList = goodsInfoService.selectByIdList(goodsIds);
List<String> barCodeList = goodsInfoList.stream().map(GoodsInfo::getBarCode).collect(Collectors.toList());
Boolean aBoolean = plcService.runSopInfoForGoodsList(plcIp,flowId, barCodeList, stepInfoList);
//记录操作样品执行SOP操作日志
LocalDateTime loginTime = LocalDateTime.now();
ManageLog info = new ManageLog();
// ========== 修复开始 ==========
Map<String, Object> mapClaims = ThreadLocalUtil.get();
UserBusy userBusy = new UserBusy();
userBusy.setId(Long.valueOf( mapClaims.get("id").toString()));
userBusy.setUserName((String) mapClaims.get("username"));
// ========== 修复结束 ==========
info.setCreateId(userBusy.getId());
info.setLogName("SOP操作日志");
info.setLogType("SOP操作日志");//1登录日志、2SOP操作日志、3基础数据操作日志
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("用户名:").append(userBusy.getUserName()).append("SOP执行操作时间").append(loginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
info.setLogContent(stringBuilder.toString());
info.setCreateTime(loginTime);
manageLogService.insert(info);
return Result.success(aBoolean);
}
}

View File

@@ -4,15 +4,12 @@ import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import com.rczn.rcznautoplc.service.StepInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@@ -27,31 +24,35 @@ public class StepInfoController {
@Autowired
StepInfoService stepInfoService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询步骤信息", description = "支持岛屿ID精准查询、步骤名称模糊查询")
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY)
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "islandId", description = "岛屿ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "stepName", description = "步骤名称(可选,模糊查询)", required = false, example = "检测", in = ParameterIn.QUERY)
})
public Result getStepInfoPage(
@ParameterObject // 核心注解:标记该实体类从查询参数取值
@Schema(description = "设备查询条件(可选)") // 补充描述
StepInfoQuery stepInfo,
@RequestParam Integer pageNum,
@RequestParam Integer pageSize
) {
PageInfo<StepInfo> pageBean = stepInfoService.selectPage(pageNum, pageSize, stepInfo);
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer islandId,
@RequestParam(required = false) String stepName) {
PageInfo<StepInfo> pageBean = stepInfoService.selectPage(pageNum, pageSize, islandId, stepName);
return Result.success(pageBean);
}
@GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询步骤信息", description = "支持岛屿ID精准查询、步骤名称模糊查询")
@Parameters({
@Parameter(name = "islandId", description = "岛屿ID可选精准查询", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "stepName", description = "步骤名称(可选,模糊查询)", required = false, example = "检测", in = ParameterIn.QUERY)
})
public Result getStepInfoList(
@ParameterObject // 核心注解:标记该实体类从查询参数取值
@Schema(description = "设备查询条件(可选)") // 补充描述
StepInfoQuery stepInfo) {
List<StepInfo> list = stepInfoService.selectList( stepInfo);
@RequestParam(required = false) Integer islandId,
@RequestParam(required = false) String stepName) {
List<StepInfo> list = stepInfoService.selectList( islandId, stepName);
return Result.success(list);
}
@@ -73,30 +74,6 @@ public class StepInfoController {
}
}
@PostMapping(value = "/batchAdd", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "批量新增步骤信息", description = "岛屿ID、步骤名称为必填项")
public Result batchAddStepInfo(@RequestBody List<StepInfo> stepInfoList) {
try {
stepInfoService.insertBatch(stepInfoList);
return Result.success(true);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
//批量更新步骤信息
@PostMapping(value = "/batchUpdate", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "批量更新步骤信息", description = "岛屿ID、步骤名称为必填项")
public Result batchUpdateStepInfo(@RequestBody List<StepInfo> stepInfoList) {
try {
stepInfoService.updateBatch(stepInfoList);
return Result.success(true);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "修改步骤信息", description = "需传入步骤信息ID其他字段可选非空则更新")
public Result updateStepInfo(@RequestBody StepInfo stepInfo) {
@@ -118,16 +95,4 @@ public class StepInfoController {
return Result.error(e.getMessage());
}
}
//批量删除步骤信息
@DeleteMapping(value = "/batchDel", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "批量删除步骤信息", description = "逻辑删除设置delSign=1不物理删除数据")
public Result batchDeleteStepInfo(@RequestBody List<Long> ids) {
try {
stepInfoService.deleteBatchByIds(ids);
return Result.success(true);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -1,23 +0,0 @@
package com.rczn.rcznautoplc.controller;
import com.rczn.websocket.WebSocketServer;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/websocket")
@Tag(name = "websocket", description = "websocket接口")
public class WebSocketController {
@Autowired
private WebSocketServer webSocketServer;
@RequestMapping("/send/{message}")
public String send(@PathVariable("message") String message){
webSocketServer.onMessage(message,null);
return "success";
}
}

View File

@@ -1,8 +1,6 @@
package com.rczn.rcznautoplc.domain;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
@@ -17,9 +15,6 @@ public class DevInfo extends BaseBean {
//设备型号
private String devModel;
//plc映射地址
private Integer plcAddr;
//设备IP地址
private String ipAddr;
@@ -31,8 +26,6 @@ public class DevInfo extends BaseBean {
private Integer status; // 0-空闲1-运行4-故障
private Integer runModel;//0-手动模式1-自动模式
private String devDesc;
public DevInfo() {
@@ -66,14 +59,6 @@ public class DevInfo extends BaseBean {
this.devModel = devModel;
}
public Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
public String getIpAddr() {
return ipAddr;
}
@@ -114,14 +99,6 @@ public class DevInfo extends BaseBean {
this.status = status;
}
public Integer getRunModel() {
return runModel;
}
public void setRunModel(Integer runModel) {
this.runModel = runModel;
}
public String getDevDesc() {
return devDesc;
}

View File

@@ -1,21 +1,13 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
public class DevParam extends BaseBean {
private String devIds;
//字典类型-参数分类id
private Integer dicDataId;
private Integer devId;
private String paramName;
//plc映射地址
private Integer plcAddr;
private String paramValue;
@@ -24,10 +16,8 @@ public class DevParam extends BaseBean {
private String paramUnit;
private String formType;
private String paramDesc;
@JsonIgnore
private DevInfo devInfo;
public DevParam() {
@@ -37,12 +27,12 @@ public class DevParam extends BaseBean {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
public String getDevIds() {
return devIds;
public Integer getDevId() {
return devId;
}
public void setDevIds(String devIds) {
this.devIds = devIds;
public void setDevId(Integer devId) {
this.devId = devId;
}
public String getParamName() {
@@ -69,22 +59,6 @@ public class DevParam extends BaseBean {
this.paramType = paramType;
}
public Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
public Integer getDicDataId() {
return dicDataId;
}
public void setDicDataId(Integer dicDataId) {
this.dicDataId = dicDataId;
}
public String getParamUnit() {
return paramUnit;
}

View File

@@ -1,9 +1,6 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
@@ -14,8 +11,6 @@ public class GoodsFlowStatus extends BaseBean {
private Integer islandId;
private Integer devId;
private Integer flowSort;
private Integer status; // 0-未执行1-执行10-通过11-失败
@@ -65,14 +60,6 @@ public class GoodsFlowStatus extends BaseBean {
this.flowSort = flowSort;
}
public Integer getDevId() {
return devId;
}
public void setDevId(Integer devId) {
this.devId = devId;
}
public Integer getStatus() {
return status;
}

View File

@@ -1,10 +1,6 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme;
import java.time.LocalDateTime;
@@ -20,25 +16,15 @@ public class GoodsInfo extends BaseBean {
private Integer goodBatch;
//进样点位
private Integer pointNum;
//目标监测物
private String goalDetect;
//条码
private String barCode;
//国标id
private Integer flowId;
private Integer goodsStatus;
private String desc;
public GoodsInfo() {
}
public GoodsInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
public String getGoodsName() {
return goodsName;
}
@@ -79,46 +65,6 @@ public class GoodsInfo extends BaseBean {
this.goodBatch = goodBatch;
}
public Integer getPointNum() {
return pointNum;
}
public void setPointNum(Integer pointNum) {
this.pointNum = pointNum;
}
public String getGoalDetect() {
return goalDetect;
}
public void setGoalDetect(String goalDetect) {
this.goalDetect = goalDetect;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public Integer getFlowId() {
return flowId;
}
public void setFlowId(Integer flowId) {
this.flowId = flowId;
}
public Integer getGoodsStatus() {
return goodsStatus;
}
public void setGoodsStatus(Integer goodsStatus) {
this.goodsStatus = goodsStatus;
}
public String getDesc() {
return desc;
}

View File

@@ -10,9 +10,6 @@ public class IslandInfo extends BaseBean {
private String islandCode;
//plc映射地址
private Integer plcAddr;
private String islandLogo;
private String desc;
@@ -20,6 +17,10 @@ public class IslandInfo extends BaseBean {
public IslandInfo() {
}
public IslandInfo(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
public String getIslandName() {
return islandName;
}
@@ -36,14 +37,6 @@ public class IslandInfo extends BaseBean {
this.islandCode = islandCode;
}
public Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
public String getIslandLogo() {
return islandLogo;
}

View File

@@ -1,9 +1,6 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
@@ -22,10 +19,8 @@ public class IslandParam extends BaseBean {
private String formType;
@JsonIgnore
private IslandInfo islandInfo;
@JsonIgnore
private StepInfo stepInfo;
public IslandParam() {

View File

@@ -1,85 +0,0 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.github.s7connector.api.S7Connector;
import com.serotonin.modbus4j.ModbusMaster;
public class ModbusConnectObj {
/**
* ip地址
*/
private String ipAddr;
/**
* 端口号
*/
private Integer port;
/**
* 机架号
*/
private Integer rack;
/**
* 插槽
*/
private Integer slot;
/**
* 是否是主机
*/
private Boolean host;
public ModbusConnectObj(String ipAddr, Integer port, Integer rack, Integer slot,Boolean host) {
this.ipAddr = ipAddr;
this.port = port;
this.rack = rack;
this.slot = slot;
this.host = host;
}
public ModbusConnectObj() {
}
public String getIpAddr() {
return ipAddr;
}
public void setIpAddr(String ipAddr) {
this.ipAddr = ipAddr;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public Integer getRack() {
return rack;
}
public void setRack(Integer rack) {
this.rack = rack;
}
public Integer getSlot() {
return slot;
}
public void setSlot(Integer slot) {
this.slot = slot;
}
public Boolean getHost() {
return host;
}
public void setHost(Boolean host) {
this.host = host;
}
}

View File

@@ -1,84 +0,0 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.github.s7connector.api.S7Connector;
public class PlcConnectObj {
/**
* ip地址
*/
private String ipAddr;
/**
* 端口号
*/
private Integer port;
/**
* 机架号
*/
private Integer rack;
/**
* 插槽
*/
private Integer slot;
/**
* 连接对象
*/
@JsonBackReference
private S7Connector connector;
public PlcConnectObj(String ipAddr, Integer port, Integer rack, Integer slot, S7Connector connector) {
this.ipAddr = ipAddr;
this.port = port;
this.rack = rack;
this.slot = slot;
this.connector = connector;
}
public PlcConnectObj() {
}
public String getIpAddr() {
return ipAddr;
}
public void setIpAddr(String ipAddr) {
this.ipAddr = ipAddr;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public Integer getRack() {
return rack;
}
public void setRack(Integer rack) {
this.rack = rack;
}
public Integer getSlot() {
return slot;
}
public void setSlot(Integer slot) {
this.slot = slot;
}
public S7Connector getConnector() {
return connector;
}
public void setConnector(S7Connector connector) {
this.connector = connector;
}
}

View File

@@ -1,9 +1,6 @@
package com.rczn.rcznautoplc.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
@@ -20,12 +17,10 @@ public class StepInfo extends BaseBean {
private String paramValue;
private String formType;
private Integer stepOrder;
private String stepName;
private String stepDesc;
@JsonIgnore
private IslandInfo islandInfo;
public StepInfo() {
@@ -99,14 +94,6 @@ public class StepInfo extends BaseBean {
this.islandId = islandId;
}
public Integer getStepOrder() {
return stepOrder;
}
public void setStepOrder(Integer stepOrder) {
this.stepOrder = stepOrder;
}
public String getStepName() {
return stepName;
}

View File

@@ -1,111 +0,0 @@
package com.rczn.rcznautoplc.domain;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class UserBusy extends BaseBean {
private Long id;
private String userName;
private String password;
private String salt;
private String nicke;
private Boolean sex; // 0-女, 1-男
private String emailAddr;
private String address;
public UserBusy() {
}
public UserBusy(Long id, Long createId, LocalDateTime createTime, Long updateId, LocalDateTime updateTime, boolean delSign, String remark) {
super(id, createId, createTime, updateId, updateTime, delSign, remark);
}
@Override
public String toString() {
return "User{" +
"userName='" + userName + '\'' +
", password='" + password + '\'' +
", salt='" + salt + '\'' +
", nicke='" + nicke + '\'' +
", sex=" + sex +
", emailAddr='" + emailAddr + '\'' +
", address='" + address + '\'' +
'}';
}
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
public String getNicke() {
return nicke;
}
public void setNicke(String nicke) {
this.nicke = nicke;
}
public Boolean getSex() {
return sex;
}
public void setSex(Boolean sex) {
this.sex = sex;
}
public String getEmailAddr() {
return emailAddr;
}
public void setEmailAddr(String emailAddr) {
this.emailAddr = emailAddr;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}

View File

@@ -1,122 +0,0 @@
package com.rczn.rcznautoplc.domain.query;
public class DevInfoQuery {
//功能岛外键
private Integer islandId;
//设备名称
private String devName;
//设备型号
private String devModel;
//plc映射地址
private Integer plcAddr;
//设备IP地址
private String ipAddr;
private Integer port;
private String protocolType;
private String company;
private Integer status; // 0-空闲1-运行4-故障
private Integer runModel;//0-手动模式1-自动模式
private String devDesc;
public DevInfoQuery() {
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public String getDevName() {
return devName;
}
public void setDevName(String devName) {
this.devName = devName;
}
public String getDevModel() {
return devModel;
}
public void setDevModel(String devModel) {
this.devModel = devModel;
}
public Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
public String getIpAddr() {
return ipAddr;
}
public void setIpAddr(String ipAddr) {
this.ipAddr = ipAddr;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getProtocolType() {
return protocolType;
}
public void setProtocolType(String protocolType) {
this.protocolType = protocolType;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getRunModel() {
return runModel;
}
public void setRunModel(Integer runModel) {
this.runModel = runModel;
}
public String getDevDesc() {
return devDesc;
}
public void setDevDesc(String devDesc) {
this.devDesc = devDesc;
}
}

View File

@@ -1,87 +0,0 @@
package com.rczn.rcznautoplc.domain.query;
public class DevParamQuery {
private String devIds;
private Integer devId;
private String paramName;
private String paramValue;
private String paramTypeData;
private String paramUnit;
private String formType;
private String paramDesc;
public DevParamQuery() {
}
public Integer getDevId() {
return devId;
}
public void setDevId(Integer devId) {
this.devId = devId;
}
public String getDevIds() {
return devIds;
}
public void setDevIds(String devIds) {
this.devIds = devIds;
}
public String getParamName() {
return paramName;
}
public void setParamName(String paramName) {
this.paramName = paramName;
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public String getParamTypeData() {
return paramTypeData;
}
public void setParamTypeData(String paramTypeData) {
this.paramTypeData = paramTypeData;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public String getParamDesc() {
return paramDesc;
}
public void setParamDesc(String paramDesc) {
this.paramDesc = paramDesc;
}
}

View File

@@ -1,75 +0,0 @@
package com.rczn.rcznautoplc.domain.query;
import com.rczn.domain.BaseBean;
import com.rczn.rcznautoplc.domain.FlowInfo;
import com.rczn.rcznautoplc.domain.IslandInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
public class GoodsFlowStatusQuery {
private Integer goodsId;
private Integer flowId;
private Integer islandId;
private Integer devId;
private Integer flowSort;
private Integer status; // 0-未执行1-执行10-通过11-失败
public GoodsFlowStatusQuery() {
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public Integer getFlowId() {
return flowId;
}
public void setFlowId(Integer flowId) {
this.flowId = flowId;
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public Integer getFlowSort() {
return flowSort;
}
public void setFlowSort(Integer flowSort) {
this.flowSort = flowSort;
}
public Integer getDevId() {
return devId;
}
public void setDevId(Integer devId) {
this.devId = devId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@@ -1,125 +0,0 @@
package com.rczn.rcznautoplc.domain.query;
import com.rczn.domain.BaseBean;
import java.time.LocalDateTime;
public class GoodsInfoQuery extends BaseBean{
private String goodsName;
private String goodsType;
private LocalDateTime incomeTime;
private String goodFrom;
private Integer goodBatch;
private Integer pointNum;
//目标监测物
private String goalDetect;
//条码
private String barCode;
//国标id
private Integer flowId;
private Integer goodsStatus;
private String desc;
public GoodsInfoQuery() {
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getGoodsType() {
return goodsType;
}
public void setGoodsType(String goodsType) {
this.goodsType = goodsType;
}
public LocalDateTime getIncomeTime() {
return incomeTime;
}
public void setIncomeTime(LocalDateTime incomeTime) {
this.incomeTime = incomeTime;
}
public String getGoodFrom() {
return goodFrom;
}
public void setGoodFrom(String goodFrom) {
this.goodFrom = goodFrom;
}
public Integer getGoodBatch() {
return goodBatch;
}
public void setGoodBatch(Integer goodBatch) {
this.goodBatch = goodBatch;
}
public Integer getPointNum() {
return pointNum;
}
public void setPointNum(Integer pointNum) {
this.pointNum = pointNum;
}
public String getGoalDetect() {
return goalDetect;
}
public void setGoalDetect(String goalDetect) {
this.goalDetect = goalDetect;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public Integer getFlowId() {
return flowId;
}
public void setFlowId(Integer flowId) {
this.flowId = flowId;
}
public Integer getGoodsStatus() {
return goodsStatus;
}
public void setGoodsStatus(Integer goodsStatus) {
this.goodsStatus = goodsStatus;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@@ -1,60 +0,0 @@
package com.rczn.rcznautoplc.domain.query;
import com.rczn.domain.BaseBean;
public class IslandInfoQuery {
private String islandName;
private String islandCode;
//plc映射地址
private Integer plcAddr;
private String islandLogo;
private String desc;
public IslandInfoQuery() {
}
public String getIslandName() {
return islandName;
}
public void setIslandName(String islandName) {
this.islandName = islandName;
}
public String getIslandCode() {
return islandCode;
}
public void setIslandCode(String islandCode) {
this.islandCode = islandCode;
}
public Integer getPlcAddr() {
return plcAddr;
}
public void setPlcAddr(Integer plcAddr) {
this.plcAddr = plcAddr;
}
public String getIslandLogo() {
return islandLogo;
}
public void setIslandLogo(String islandLogo) {
this.islandLogo = islandLogo;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@@ -1,84 +0,0 @@
package com.rczn.rcznautoplc.domain.query;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import com.rczn.rcznautoplc.domain.IslandInfo;
import java.time.LocalDateTime;
public class IslandParamQuery {
private Integer islandId;
private Integer stepId;
private String paramName;
private String paramType;
private String paramUnit;
private String paramValue;
private String formType;
public IslandParamQuery() {
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public Integer getStepId() {
return stepId;
}
public void setStepId(Integer stepId) {
this.stepId = stepId;
}
public String getParamName() {
return paramName;
}
public void setParamName(String paramName) {
this.paramName = paramName;
}
public String getParamType() {
return paramType;
}
public void setParamType(String paramType) {
this.paramType = paramType;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
}

View File

@@ -1,118 +0,0 @@
package com.rczn.rcznautoplc.domain.query;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rczn.domain.BaseBean;
import com.rczn.rcznautoplc.domain.IslandInfo;
import java.time.LocalDateTime;
public class StepInfoQuery {
private Integer islandId;
//设备id
private Integer devId;
private Integer flowId;
private String paramName;
private String paramType;
private String paramUnit;
private String paramValue;
private String formType;
private Integer stepOrder;
private String stepName;
private String stepDesc;
public StepInfoQuery() {
}
public Integer getFlowId() {
return flowId;
}
public void setFlowId(Integer flowId) {
this.flowId = flowId;
}
public Integer getDevId() {
return devId;
}
public void setDevId(Integer devId) {
this.devId = devId;
}
public String getParamName() {
return paramName;
}
public void setParamName(String paramName) {
this.paramName = paramName;
}
public String getParamType() {
return paramType;
}
public void setParamType(String paramType) {
this.paramType = paramType;
}
public String getParamUnit() {
return paramUnit;
}
public void setParamUnit(String paramUnit) {
this.paramUnit = paramUnit;
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public String getFormType() {
return formType;
}
public void setFormType(String formType) {
this.formType = formType;
}
public Integer getIslandId() {
return islandId;
}
public void setIslandId(Integer islandId) {
this.islandId = islandId;
}
public Integer getStepOrder() {
return stepOrder;
}
public void setStepOrder(Integer stepOrder) {
this.stepOrder = stepOrder;
}
public String getStepName() {
return stepName;
}
public void setStepName(String stepName) {
this.stepName = stepName;
}
public String getStepDesc() {
return stepDesc;
}
public void setStepDesc(String stepDesc) {
this.stepDesc = stepDesc;
}
}

View File

@@ -1,7 +1,6 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.DevInfo;
import com.rczn.rcznautoplc.domain.query.DevInfoQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -24,8 +23,6 @@ public interface DevInfoMapper {
// 根据ID查询设备未删除
DevInfo selectById(@Param("id") Long id);
//根据设备信息,查询设备信息列表
List<DevInfo> selectList(DevInfoQuery devInfo);
// 分页查询设备(支持多条件过滤)
List<DevInfo> selectPage(DevInfo devInfo);

View File

@@ -1,7 +1,6 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.DevParam;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -32,9 +31,5 @@ public interface DevParamMapper {
/**
* 分页查询设备参数(支持条件过滤)
*/
List<DevParam> selectPage(DevParamQuery devParam);
Boolean addDevId(@Param("devId") Integer devId,@Param("paramId") Integer paramId);
Boolean delDevId(@Param("devId")Integer devId,@Param("paramId") Integer paramId);
List<DevParam> selectPage(DevParam devParam);
}

View File

@@ -1,7 +1,6 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.query.GoodsFlowStatusQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -13,5 +12,5 @@ public interface GoodsFlowStatusMapper {
Boolean update(GoodsFlowStatus goodsFlowStatus);
Boolean deleteById(@Param("id") Long id);
GoodsFlowStatus selectById(@Param("id") Long id);
List<GoodsFlowStatus> selectPage(GoodsFlowStatusQuery goodsFlowStatus);
List<GoodsFlowStatus> selectPage(GoodsFlowStatus goodsFlowStatus);
}

View File

@@ -1,7 +1,6 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -10,16 +9,8 @@ import java.util.List;
@Mapper
public interface GoodsInfoMapper {
Long insert(GoodsInfo goodsInfo);
//批量插入样品数据:
// Long batchInsert(List<GoodsInfo> goodsInfoList);
Boolean update(GoodsInfo goodsInfo);
Boolean deleteById(@Param("id") Long id);
GoodsInfo selectById(@Param("id") Long id);
List<GoodsInfo> selectByIdList(@Param("idList") List<Integer> idList);
GoodsInfo selectByBarCode(@Param("barCode") String barCode);
List<GoodsInfo> selectPage(GoodsInfoQuery goodsInfo);
List<GoodsInfo> selectPage(GoodsInfo goodsInfo);
}

View File

@@ -1,7 +1,6 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.IslandInfo;
import com.rczn.rcznautoplc.domain.query.IslandInfoQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -13,10 +12,5 @@ public interface IslandInfoMapper {
Boolean update(IslandInfo islandInfo);
Boolean deleteById(@Param("id") Long id);
IslandInfo selectById(@Param("id") Long id);
/**
* 查询功能岛信息List
*/
List<IslandInfo> selectList(IslandInfoQuery islandInfoQuery);
List<IslandInfo> selectPage(IslandInfo islandInfo);
}

View File

@@ -1,7 +1,6 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -12,13 +11,6 @@ public interface StepInfoMapper {
Long insert(StepInfo stepInfo);
Boolean update(StepInfo stepInfo);
Boolean deleteById(@Param("id") Long id);
Long deleteBatchByIds(List<Long> ids);
StepInfo selectById(@Param("id") Long id);
List<StepInfo> selectList(StepInfo stepInfo);
List<StepInfo> selectPage(StepInfoQuery stepInfo);
Long insertBatch(List<StepInfo> stepInfoList);
Long updateBatch(List<StepInfo> stepInfoList);
List<StepInfo> selectPage(StepInfo stepInfo);
}

View File

@@ -2,7 +2,6 @@ package com.rczn.rcznautoplc.service;
import com.rczn.rcznautoplc.domain.DevInfo;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.query.DevInfoQuery;
import java.util.List;
@@ -22,15 +21,6 @@ public interface DevInfoService {
// 根据ID查询设备
DevInfo getDevInfoById(Long id);
//根据设备信息查询设备列表数据
/**
* Retrieves a list of device information based on the provided query parameters.
*
* @param devInfo The query parameters used to filter device information
* @return List<DevInfo> A list of device information objects that match the query criteria
*/
List<DevInfo> getDevInfoList(DevInfoQuery devInfo);
// 分页查询设备
PageInfo<DevInfo> getDevInfoPage(DevInfo devInfo, Integer pageNum, Integer pageSize);

View File

@@ -3,7 +3,6 @@ package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.DevParam;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import java.util.List;
@@ -11,9 +10,9 @@ public interface DevParamService {
/**
* 分页查询
*/
PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId,String paramTypeData, String paramName, String paramValue);
PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId, String paramName, String paramValue);
List<DevParam> selectList(DevParamQuery queryParam);
List<DevParam> selectList(Integer devId, String paramName, String paramValue);
/**
* 根据ID查询
@@ -30,16 +29,6 @@ public interface DevParamService {
*/
Boolean update(DevParam devParam);
/**
* 为参数增加devId值
*/
Boolean addDevId(Integer devId, Integer paramId);
/**
* 根据paramId,减少devIds中的devId
*/
Boolean reduceDevId(Integer devId, Integer paramId);
/**
* 逻辑删除
*/

View File

@@ -3,13 +3,9 @@ package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.GoodsFlowStatus;
import com.rczn.rcznautoplc.domain.query.GoodsFlowStatusQuery;
import java.util.List;
public interface GoodsFlowStatusService {
PageInfo<GoodsFlowStatus> selectPage(Integer pageNum, Integer pageSize, GoodsFlowStatusQuery goodsFlowStatus);
List<GoodsFlowStatus> selectList( GoodsFlowStatusQuery goodsFlowStatus);
PageInfo<GoodsFlowStatus> selectPage(Integer pageNum, Integer pageSize, Integer goodsId, Integer flowId, Integer islandId, Integer status);
GoodsFlowStatus selectById(Long id);
Long insert(GoodsFlowStatus goodsFlowStatus);
Boolean update(GoodsFlowStatus goodsFlowStatus);

View File

@@ -1,42 +1,25 @@
package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import java.util.List;
public interface GoodsInfoService {
/**
* 分页查询货物信息
*/
PageInfo<GoodsInfo> selectPage(Integer pageNum, Integer pageSize, GoodsInfoQuery goodsInfo);
/**
* 查询样品信息List
*/
List<GoodsInfo> selectList(GoodsInfoQuery goodsInfo);
PageInfo<GoodsInfo> selectPage(Integer pageNum, Integer pageSize, String goodsName, String goodsType, String goodFrom, Integer goodBatch);
/**
* 根据ID查询货物信息
*/
GoodsInfo selectById(Long id);
/**
* 根据ID列表查询货物列表信息
*/
List<GoodsInfo> selectByIdList(List<Integer> ids);
/**
* 新增货物信息
*/
Long insert(GoodsInfo goodsInfo);
/**
* 扫码新增货物信息
*/
GoodsInfo insertByScan(GoodsInfo goodsInfo);
/**
* 修改货物信息
*/

View File

@@ -2,22 +2,11 @@ package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.IslandInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import com.rczn.rcznautoplc.domain.query.IslandInfoQuery;
import java.util.List;
public interface IslandInfoService {
PageInfo<IslandInfo> selectPage(Integer pageNum, Integer pageSize, String islandName, String islandCode);
IslandInfo selectById(Long id);
/**
* 查询功能岛信息List
*/
List<IslandInfo> selectList(IslandInfoQuery islandInfoQuery);
Long insert(IslandInfo islandInfo);
Boolean update(IslandInfo islandInfo);
Boolean deleteById(Long id);

View File

@@ -1,125 +0,0 @@
package com.rczn.rcznautoplc.service;
import com.github.s7connector.api.S7Connector;
import com.rczn.rcznautoplc.domain.ModbusConnectObj;
import com.rczn.rcznautoplc.domain.PlcConnectObj;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.utils.PlcConnectMap;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import java.util.List;
import java.util.Map;
public interface PlcService {
/**
* 连接plc设备
* @param connectObj-
* @return
*/
PlcConnectObj connect(PlcConnectObj connectObj);
/**
* 连接modbus设备
* @param connectObj-
* @return
*/
ModbusMaster connectModbus(ModbusConnectObj connectObj) throws ModbusInitException, ModbusTransportException;
/**
* 启动plc设备
* @param ipAddr-
* @return
*/
Boolean startPlc(String ipAddr);
/**
* plc设备暂停运行
* @param ipAddr-
* @return
*/
Boolean pausePlc(String ipAddr);
/**
* plc设备故障复位
* @param ipAddr-
* @return
*/
Boolean resetErrorPlc(String ipAddr);
/**
* 根据ip地址获取plc设备状态值
* 0-未连接1-连接11-执行12-暂停19暂停20-故障复位
* @param ipAddr
* @return
*/
Integer getPlcStatus(String ipAddr);
/**
* 根据ip地址设置plc设备模式
* 0-手动1-自动
* @param ipAddr
* @return
*/
Boolean setPlcModel(String ipAddr,Integer modelValue);
/**
* 根据ip地址获取plc设备模式值
* 0-手动1-自动
* @param ipAddr
* @return
*/
Integer getPlcModel(String ipAddr);
/**
* 根据ip地址获取modbus连接设备
*
* @param ipAddr
* @return
*/
public ModbusMaster getModbusConnect(String ipAddr);
/**
* 根据ip地址获取plc设备
* @param ipAddr
* @return
*/
S7Connector getPlc(String ipAddr);
/**
* 获取全部plc连接对象
* @return
*/
Map<String,S7Connector> plcALlMap();
/**
* 获取全部plc连接对象
*
* @return
*/
public Map<String, ModbusMaster> modbusALlMap();
/**
* 执行plc动作
* @param ipAddr
* @param action
* @return
*/
Boolean doAction(String ipAddr,String action);
/**
* 停止plc运行
* @param ipAddr
* @return
*/
Boolean stopPlc(String ipAddr);
/**
* 执行sop信息
* @param sopId
* @param barCodeList
* @param stepInfoList
* @return
*/
Boolean runSopInfoForGoodsList(String plcIp, Integer sopId, List<String> barCodeList,List<StepInfo> stepInfoList);
}

View File

@@ -2,32 +2,14 @@ package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.StepInfo;
import com.rczn.rcznautoplc.domain.query.StepInfoQuery;
import java.util.List;
public interface StepInfoService {
PageInfo<StepInfo> selectPage(Integer pageNum, Integer pageSize, StepInfoQuery stepInfo);
List<StepInfo> selectList( StepInfoQuery stepInfo);
PageInfo<StepInfo> selectPage(Integer pageNum, Integer pageSize, Integer islandId, String stepName);
List<StepInfo> selectList( Integer islandId, String stepName);
StepInfo selectById(Long id);
Long insert(StepInfo stepInfo);
Long insertBatch(List<StepInfo> stepInfoList);
Boolean update(StepInfo stepInfo);
/**
* 批量更新
* @param stepInfoList
* @return
*/
Long updateBatch(List<StepInfo> stepInfoList);
Boolean deleteById(Long id);
/**
* 批量删除
* @param ids
* @return
* @throws Exception
*/
Long deleteBatchByIds(List<Long> ids);
}

View File

@@ -1,7 +1,6 @@
package com.rczn.rcznautoplc.service.impl;
import com.rczn.rcznautoplc.domain.DevInfo;
import com.rczn.rcznautoplc.domain.query.DevInfoQuery;
import com.rczn.rcznautoplc.mapper.DevInfoMapper;
import com.rczn.rcznautoplc.service.DevInfoService;
import com.github.pagehelper.PageHelper;
@@ -30,18 +29,6 @@ public class DevInfoServiceImpl implements DevInfoService {
if (devInfo.getCreateTime() == null) {
devInfo.setCreateTime(java.time.LocalDateTime.now());
}
//判断设备是否是PLCPLC设备只有一个主PLCcompany-主站
if(devInfo.getDevModel().equals("PLC")&&devInfo.getCompany().equals("主站")){
//查询出devModel为PLCcompany为“主站”的设备
DevInfoQuery devInfo1 = new DevInfoQuery();
devInfo1.setDevModel("PLC");
devInfo1.setCompany("主站");
List<DevInfo> devInfoList = devInfoMapper.selectList(devInfo1);
if(devInfoList.size()>0){
//如果存在,报错抛出异常
throw new RuntimeException("主站PLC设备只能有一个");
}
}
// 调用Mapper新增
return devInfoMapper.insert(devInfo) > 0;
}
@@ -64,25 +51,6 @@ public class DevInfoServiceImpl implements DevInfoService {
if (devInfo.getUpdateTime() == null) {
devInfo.setUpdateTime(java.time.LocalDateTime.now());
}
//判断设备是否是PLCPLC设备只有一个主PLCcompany-主站
if(devInfo.getDevModel().equals("PLC")&&devInfo.getCompany().equals("主站")){
//查询出devModel为PLCcompany为“主站”的设备
DevInfoQuery devInfo1 = new DevInfoQuery();
devInfo1.setDevModel("PLC");
devInfo1.setCompany("主站");
List<DevInfo> devInfoList = devInfoMapper.selectList(devInfo1);
if(devInfoList.size()>0){
for (DevInfo devInfo2 : devInfoList)
if(devInfo2.getId().equals(devInfo.getId()))
continue;
else {
//如果存在,报错抛出异常
throw new RuntimeException("主站PLC设备只能有一个");
}
}
}
// 调用Mapper更新
return devInfoMapper.updateById(devInfo) > 0;
}
@@ -93,11 +61,6 @@ public class DevInfoServiceImpl implements DevInfoService {
return devInfoMapper.selectById(id);
}
@Override
public List<DevInfo> getDevInfoList(DevInfoQuery devInfo) {
return devInfoMapper.selectList(devInfo);
}
@Override
public PageInfo<DevInfo> getDevInfoPage(DevInfo devInfo, Integer pageNum, Integer pageSize) {
// 分页参数默认值

View File

@@ -4,7 +4,6 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.DevParam;
import com.rczn.rcznautoplc.domain.query.DevParamQuery;
import com.rczn.rcznautoplc.mapper.DevParamMapper;
import com.rczn.rcznautoplc.service.DevParamService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,13 +18,12 @@ public class DevParamServiceImpl implements DevParamService {
DevParamMapper devParamMapper;
@Override
public PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId, String paramTypeData, String paramName, String paramValue) {
public PageInfo<DevParam> selectPage(Integer pageNum, Integer pageSize, Integer devId, String paramName, String paramValue) {
// 1. 开启分页
PageHelper.startPage(pageNum, pageSize);
// 2. 构建查询条件
DevParamQuery queryParam = new DevParamQuery();
DevParam queryParam = new DevParam();
queryParam.setDevId(devId);
queryParam.setParamTypeData(paramTypeData);
queryParam.setParamName(paramName);
queryParam.setParamValue(paramValue);
// 3. 执行查询
@@ -42,7 +40,12 @@ public class DevParamServiceImpl implements DevParamService {
* @return
*/
@Override
public List<DevParam> selectList(DevParamQuery queryParam) {
public List<DevParam> selectList(Integer devId, String paramName, String paramValue) {
// 1. 构建查询条件
DevParam queryParam = new DevParam();
queryParam.setDevId(devId);
queryParam.setParamName(paramName);
queryParam.setParamValue(paramValue);
// 3. 执行查询
List<DevParam> list = devParamMapper.selectPage(queryParam);
return list;
@@ -58,8 +61,8 @@ public class DevParamServiceImpl implements DevParamService {
@Override
public Long insert(DevParam devParam) {
if (devParam.getDevIds() == null) {
devParam.setDevIds(";");
if (devParam.getDevId() == null) {
throw new IllegalArgumentException("设备ID不能为空");
}
if (devParam.getParamName() == null || devParam.getParamName().isEmpty()) {
throw new IllegalArgumentException("参数名称不能为空");
@@ -75,28 +78,6 @@ public class DevParamServiceImpl implements DevParamService {
return devParamMapper.update(devParam);
}
/**
* 为参数增加devId值
*
* @param devId
* @param paramId
*/
@Override
public Boolean addDevId(Integer devId, Integer paramId) {
return devParamMapper.addDevId(devId, paramId);
}
/**
* 根据paramId,减少devIds中的devId
*
* @param devId
* @param paramId
*/
@Override
public Boolean reduceDevId(Integer devId, Integer paramId) {
return devParamMapper.delDevId(devId, paramId);
}
@Override
public Boolean deleteById(Long id) {
if (id == null) {

View File

@@ -56,8 +56,10 @@ public class FlowInfoServiceImpl implements FlowInfoService {
if (flowInfo.getFlowName() == null || flowInfo.getFlowName().isEmpty()) {
throw new IllegalArgumentException("流程名称不能为空");
}
Long result = flowInfoMapper.insert(flowInfo);
return flowInfo.getId();
if (flowInfo.getFlowIndex() == null) {
throw new IllegalArgumentException("流程排序不能为空");
}
return flowInfoMapper.insert(flowInfo);
}
@Override

Some files were not shown because too many files have changed in this diff Show More