commit
ae90307a23
515 changed files with 37550 additions and 0 deletions
@ -0,0 +1,21 @@ |
||||
# http://editorconfig.org |
||||
root = true |
||||
|
||||
# 空格替代Tab缩进在各种编辑工具下效果一致 |
||||
[*] |
||||
indent_style = space |
||||
indent_size = 4 |
||||
charset = utf-8 |
||||
end_of_line = lf |
||||
trim_trailing_whitespace = true |
||||
insert_final_newline = true |
||||
|
||||
[*.java] |
||||
indent_style = tab |
||||
|
||||
[*.{json,yml}] |
||||
indent_size = 2 |
||||
|
||||
[*.md] |
||||
insert_final_newline = false |
||||
trim_trailing_whitespace = false |
@ -0,0 +1,27 @@ |
||||
# maven # |
||||
target |
||||
|
||||
logs |
||||
|
||||
# windows # |
||||
Thumbs.db |
||||
|
||||
# Mac # |
||||
.DS_Store |
||||
|
||||
# eclipse # |
||||
.settings |
||||
.project |
||||
.classpath |
||||
.log |
||||
*.class |
||||
|
||||
# idea # |
||||
.idea |
||||
*.iml |
||||
|
||||
# Package Files # |
||||
*.jar |
||||
*.war |
||||
*.ear |
||||
/target |
@ -0,0 +1,14 @@ |
||||
FROM anapsix/alpine-java:8_server-jre_unlimited |
||||
|
||||
|
||||
RUN mkdir -p /control |
||||
|
||||
WORKDIR /control |
||||
|
||||
EXPOSE 8800 |
||||
|
||||
ADD ./target/smart-om-system.jar ./app.jar |
||||
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"] |
||||
|
||||
CMD ["--spring.profiles.active=test"] |
@ -0,0 +1,191 @@ |
||||
Apache License |
||||
Version 2.0, January 2004 |
||||
http://www.apache.org/licenses/ |
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||
|
||||
1. Definitions. |
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and |
||||
distribution as defined by Sections 1 through 9 of this document. |
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright |
||||
owner that is granting the License. |
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities |
||||
that control, are controlled by, or are under common control with that entity. |
||||
For the purposes of this definition, "control" means (i) the power, direct or |
||||
indirect, to cause the direction or management of such entity, whether by |
||||
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||
outstanding shares, or (iii) beneficial ownership of such entity. |
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising |
||||
permissions granted by this License. |
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including |
||||
but not limited to software source code, documentation source, and configuration |
||||
files. |
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or |
||||
translation of a Source form, including but not limited to compiled object code, |
||||
generated documentation, and conversions to other media types. |
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made |
||||
available under the License, as indicated by a copyright notice that is included |
||||
in or attached to the work (an example is provided in the Appendix below). |
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that |
||||
is based on (or derived from) the Work and for which the editorial revisions, |
||||
annotations, elaborations, or other modifications represent, as a whole, an |
||||
original work of authorship. For the purposes of this License, Derivative Works |
||||
shall not include works that remain separable from, or merely link (or bind by |
||||
name) to the interfaces of, the Work and Derivative Works thereof. |
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version |
||||
of the Work and any modifications or additions to that Work or Derivative Works |
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work |
||||
by the copyright owner or by an individual or Legal Entity authorized to submit |
||||
on behalf of the copyright owner. For the purposes of this definition, |
||||
"submitted" means any form of electronic, verbal, or written communication sent |
||||
to the Licensor or its representatives, including but not limited to |
||||
communication on electronic mailing lists, source code control systems, and |
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for |
||||
the purpose of discussing and improving the Work, but excluding communication |
||||
that is conspicuously marked or otherwise designated in writing by the copyright |
||||
owner as "Not a Contribution." |
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf |
||||
of whom a Contribution has been received by Licensor and subsequently |
||||
incorporated within the Work. |
||||
|
||||
2. Grant of Copyright License. |
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby |
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, |
||||
irrevocable copyright license to reproduce, prepare Derivative Works of, |
||||
publicly display, publicly perform, sublicense, and distribute the Work and such |
||||
Derivative Works in Source or Object form. |
||||
|
||||
3. Grant of Patent License. |
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby |
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, |
||||
irrevocable (except as stated in this section) patent license to make, have |
||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where |
||||
such license applies only to those patent claims licensable by such Contributor |
||||
that are necessarily infringed by their Contribution(s) alone or by combination |
||||
of their Contribution(s) with the Work to which such Contribution(s) was |
||||
submitted. If You institute patent litigation against any entity (including a |
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a |
||||
Contribution incorporated within the Work constitutes direct or contributory |
||||
patent infringement, then any patent licenses granted to You under this License |
||||
for that Work shall terminate as of the date such litigation is filed. |
||||
|
||||
4. Redistribution. |
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works thereof |
||||
in any medium, with or without modifications, and in Source or Object form, |
||||
provided that You meet the following conditions: |
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of |
||||
this License; and |
||||
You must cause any modified files to carry prominent notices stating that You |
||||
changed the files; and |
||||
You must retain, in the Source form of any Derivative Works that You distribute, |
||||
all copyright, patent, trademark, and attribution notices from the Source form |
||||
of the Work, excluding those notices that do not pertain to any part of the |
||||
Derivative Works; and |
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any |
||||
Derivative Works that You distribute must include a readable copy of the |
||||
attribution notices contained within such NOTICE file, excluding those notices |
||||
that do not pertain to any part of the Derivative Works, in at least one of the |
||||
following places: within a NOTICE text file distributed as part of the |
||||
Derivative Works; within the Source form or documentation, if provided along |
||||
with the Derivative Works; or, within a display generated by the Derivative |
||||
Works, if and wherever such third-party notices normally appear. The contents of |
||||
the NOTICE file are for informational purposes only and do not modify the |
||||
License. You may add Your own attribution notices within Derivative Works that |
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work, |
||||
provided that such additional attribution notices cannot be construed as |
||||
modifying the License. |
||||
You may add Your own copyright statement to Your modifications and may provide |
||||
additional or different license terms and conditions for use, reproduction, or |
||||
distribution of Your modifications, or for any such Derivative Works as a whole, |
||||
provided Your use, reproduction, and distribution of the Work otherwise complies |
||||
with the conditions stated in this License. |
||||
|
||||
5. Submission of Contributions. |
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted |
||||
for inclusion in the Work by You to the Licensor shall be under the terms and |
||||
conditions of this License, without any additional terms or conditions. |
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of |
||||
any separate license agreement you may have executed with Licensor regarding |
||||
such Contributions. |
||||
|
||||
6. Trademarks. |
||||
|
||||
This License does not grant permission to use the trade names, trademarks, |
||||
service marks, or product names of the Licensor, except as required for |
||||
reasonable and customary use in describing the origin of the Work and |
||||
reproducing the content of the NOTICE file. |
||||
|
||||
7. Disclaimer of Warranty. |
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor provides the |
||||
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, |
||||
including, without limitation, any warranties or conditions of TITLE, |
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are |
||||
solely responsible for determining the appropriateness of using or |
||||
redistributing the Work and assume any risks associated with Your exercise of |
||||
permissions under this License. |
||||
|
||||
8. Limitation of Liability. |
||||
|
||||
In no event and under no legal theory, whether in tort (including negligence), |
||||
contract, or otherwise, unless required by applicable law (such as deliberate |
||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be |
||||
liable to You for damages, including any direct, indirect, special, incidental, |
||||
or consequential damages of any character arising as a result of this License or |
||||
out of the use or inability to use the Work (including but not limited to |
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or |
||||
any and all other commercial damages or losses), even if such Contributor has |
||||
been advised of the possibility of such damages. |
||||
|
||||
9. Accepting Warranty or Additional Liability. |
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may choose to |
||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or |
||||
other liability obligations and/or rights consistent with this License. However, |
||||
in accepting such obligations, You may act only on Your own behalf and on Your |
||||
sole responsibility, not on behalf of any other Contributor, and only if You |
||||
agree to indemnify, defend, and hold each Contributor harmless for any liability |
||||
incurred by, or claims asserted against, such Contributor by reason of your |
||||
accepting any such warranty or additional liability. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
APPENDIX: How to apply the Apache License to your work |
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate |
||||
notice, with the fields enclosed by brackets "{}" replaced with your own |
||||
identifying information. (Don't include the brackets!) The text should be |
||||
enclosed in the appropriate comment syntax for the file format. We also |
||||
recommend that a file or class name and description of purpose be included on |
||||
the same "printed page" as the copyright notice for easier identification within |
||||
third-party archives. |
||||
|
||||
Copyright 2020 DafX (https://dafx.vip) |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
You may obtain a copy of the License at |
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Unless required by applicable law or agreed to in writing, software |
||||
distributed under the License is distributed on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
See the License for the specific language governing permissions and |
||||
limitations under the License. |
@ -0,0 +1 @@ |
||||
java -jar app.jar |
@ -0,0 +1,76 @@ |
||||
#!/bin/bash |
||||
|
||||
#设置jar文件名 |
||||
APP_NAME=app.jar |
||||
|
||||
#使用说明,用来提示输入参数 |
||||
usage() { |
||||
echo "Usage: sh 执行脚本.sh [start|stop|restart|status]" |
||||
exit 1 |
||||
} |
||||
|
||||
#检查程序是否在运行 |
||||
is_exist(){ |
||||
pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' ` |
||||
#如果不存在返回1,存在返回0 |
||||
if [ -z "${pid}" ]; then |
||||
return 1 |
||||
else |
||||
return 0 |
||||
fi |
||||
} |
||||
|
||||
#启动方法 |
||||
start(){ |
||||
is_exist |
||||
if [ $? -eq "0" ]; then |
||||
echo "${APP_NAME} is already running. pid=${pid} ." |
||||
else |
||||
nohup java -jar $APP_NAME > /dev/null 2>&1 & |
||||
fi |
||||
} |
||||
|
||||
#停止方法 |
||||
stop(){ |
||||
is_exist |
||||
if [ $? -eq "0" ]; then |
||||
kill -9 $pid |
||||
else |
||||
echo "${APP_NAME} is not running" |
||||
fi |
||||
} |
||||
|
||||
#输出运行状态 |
||||
status(){ |
||||
is_exist |
||||
if [ $? -eq "0" ]; then |
||||
echo "${APP_NAME} is running. Pid is ${pid}" |
||||
else |
||||
echo "${APP_NAME} is NOT running." |
||||
fi |
||||
} |
||||
|
||||
#重启 |
||||
restart(){ |
||||
stop |
||||
start |
||||
} |
||||
|
||||
#根据输入参数,选择执行对应方法,不输入则执行使用说明 |
||||
case "$1" in |
||||
"start") |
||||
start |
||||
;; |
||||
"stop") |
||||
stop |
||||
;; |
||||
"status") |
||||
status |
||||
;; |
||||
"restart") |
||||
restart |
||||
;; |
||||
*) |
||||
usage |
||||
;; |
||||
esac |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,115 @@ |
||||
|
||||
-- ---------------------------- |
||||
-- 创建数据权限表 |
||||
-- ---------------------------- |
||||
CREATE TABLE `sys_scope_data` ( |
||||
`id` bigint(20) NOT NULL COMMENT '主键', |
||||
`menu_id` bigint(20) NULL DEFAULT NULL COMMENT '菜单主键', |
||||
`resource_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '资源编号', |
||||
`scope_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据权限名称', |
||||
`scope_field` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据权限字段', |
||||
`scope_class` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据权限类名', |
||||
`scope_column` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据权限字段', |
||||
`scope_type` int(2) NULL DEFAULT NULL COMMENT '数据权限类型', |
||||
`scope_value` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据权限值域', |
||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据权限备注', |
||||
`create_user` bigint(20) NULL DEFAULT NULL COMMENT '创建人', |
||||
`create_dept` bigint(20) NULL DEFAULT NULL COMMENT '创建部门', |
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', |
||||
`update_user` bigint(20) NULL DEFAULT NULL COMMENT '修改人', |
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间', |
||||
`status` int(2) NULL DEFAULT NULL COMMENT '状态', |
||||
`is_deleted` int(2) NULL DEFAULT NULL COMMENT '是否已删除', |
||||
PRIMARY KEY (`id`) USING BTREE |
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据权限表'; |
||||
|
||||
|
||||
-- ---------------------------- |
||||
-- 创建数据权限角色表 |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `sys_role_scope`; |
||||
CREATE TABLE `sys_role_scope` ( |
||||
`id` bigint(20) NOT NULL COMMENT '主键', |
||||
`scope_id` bigint(20) NULL DEFAULT NULL COMMENT '数据权限id', |
||||
`role_id` bigint(20) NULL DEFAULT NULL COMMENT '角色id', |
||||
PRIMARY KEY (`id`) USING BTREE |
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci; |
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1; |
||||
|
||||
-- ---------------------------- |
||||
-- 部门表增加字段 |
||||
-- ---------------------------- |
||||
ALTER TABLE `sys_dept` |
||||
ADD COLUMN `ancestors` varchar(2000) NULL COMMENT '祖级列表' AFTER `parent_id`; |
||||
|
||||
UPDATE `sys_dept` SET `tenant_id` = '000000', `parent_id` = 0, `ancestors` = '0', `dept_name` = '刀锋科技', `full_name` = '江苏刀锋科技有限公司', `sort` = 1, `remark` = NULL, `is_deleted` = 0 WHERE `id` = 1123598813738675201; |
||||
UPDATE `sys_dept` SET `tenant_id` = '000000', `parent_id` = 1123598813738675201, `ancestors` = '0,1123598813738675201', `dept_name` = '常州刀锋', `full_name` = '常州刀锋科技有限公司', `sort` = 1, `remark` = NULL, `is_deleted` = 0 WHERE `id` = 1123598813738675202; |
||||
UPDATE `sys_dept` SET `tenant_id` = '000000', `parent_id` = 1123598813738675201, `ancestors` = '0,1123598813738675201', `dept_name` = '苏州刀锋', `full_name` = '苏州刀锋科技有限公司', `sort` = 1, `remark` = NULL, `is_deleted` = 0 WHERE `id` = 1123598813738675203; |
||||
|
||||
-- ---------------------------- |
||||
-- 增加字典项 |
||||
-- ---------------------------- |
||||
INSERT INTO `sys_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675231, 0, 'data_scope_type', -1, '数据权限', 8, NULL, 0); |
||||
INSERT INTO `sys_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675232, 1123598814738675231, 'data_scope_type', 1, '全部可见', 1, NULL, 0); |
||||
INSERT INTO `sys_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675233, 1123598814738675231, 'data_scope_type', 2, '本人可见', 2, NULL, 0); |
||||
INSERT INTO `sys_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675234, 1123598814738675231, 'data_scope_type', 3, '所在机构可见', 3, NULL, 0); |
||||
INSERT INTO `sys_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675235, 1123598814738675231, 'data_scope_type', 4, '所在机构及子级可见', 4, NULL, 0); |
||||
INSERT INTO `sys_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675236, 1123598814738675231, 'data_scope_type', 5, '自定义', 5, NULL, 0); |
||||
|
||||
|
||||
-- ---------------------------- |
||||
-- 增加权限管理模块 |
||||
-- ---------------------------- |
||||
INSERT INTO `sys_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) VALUES (1123598815738675307, 0, 'authority', '权限管理', 'menu', '/authority', 'iconfont icon-bofangqi-suoping', 98, 1, 0, 1, '', 0); |
||||
|
||||
-- ---------------------------- |
||||
-- 角色管理迁移至权限管理 |
||||
-- ---------------------------- |
||||
DELETE FROM `sys_menu` WHERE ID = 1123598815738675208; |
||||
INSERT INTO `sys_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) VALUES (1123598815738675308, 1123598815738675307, 'role', '角色管理', 'menu', '/authority/role', 'iconfont iconicon_boss', 1, 1, 0, 1, NULL, 0); |
||||
UPDATE `sys_menu` SET `parent_id` = 1123598815738675308, `code` = 'role_add', `name` = '新增', `alias` = 'add', `path` = '/authority/role/add', `source` = 'plus', `sort` = 1, `category` = 2, `action` = 1, `is_open` = 1, `remark` = NULL, `is_deleted` = 0 WHERE `id` = 1123598815738675241; |
||||
UPDATE `sys_menu` SET `parent_id` = 1123598815738675308, `code` = 'role_edit', `name` = '修改', `alias` = 'edit', `path` = '/authority/role/edit', `source` = 'form', `sort` = 2, `category` = 2, `action` = 2, `is_open` = 1, `remark` = NULL, `is_deleted` = 0 WHERE `id` = 1123598815738675242; |
||||
UPDATE `sys_menu` SET `parent_id` = 1123598815738675308, `code` = 'role_delete', `name` = '删除', `alias` = 'delete', `path` = '/api/daf-system/role/remove', `source` = 'delete', `sort` = 3, `category` = 2, `action` = 3, `is_open` = 1, `remark` = NULL, `is_deleted` = 0 WHERE `id` = 1123598815738675243; |
||||
UPDATE `sys_menu` SET `parent_id` = 1123598815738675308, `code` = 'role_view', `name` = '查看', `alias` = 'view', `path` = '/authority/role/view', `source` = 'file-text', `sort` = 4, `category` = 2, `action` = 2, `is_open` = 1, `remark` = NULL, `is_deleted` = 0 WHERE `id` = 1123598815738675244; |
||||
|
||||
|
||||
-- ---------------------------- |
||||
-- 增加数据权限及接口权限独立菜单 |
||||
-- ---------------------------- |
||||
INSERT INTO `sys_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) VALUES (1123598815738675309, 1123598815738675307, 'data_scope', '数据权限', 'menu', '/authority/datascope', 'iconfont icon-shujuzhanshi2', 2, 1, 0, 1, '', 0); |
||||
INSERT INTO `sys_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) VALUES (1123598815738675310, 1123598815738675309, 'data_scope_setting', '权限配置', 'setting', NULL, 'setting', 1, 2, 2, 1, NULL, 0); |
||||
|
||||
|
||||
-- ---------------------------- |
||||
-- 增加数据权限及菜单权限 |
||||
-- ---------------------------- |
||||
INSERT INTO `sys_role_menu`(`id`, `menu_id`, `role_id`) VALUES (1455363615489028098, 1123598815738675307, 1123598816738675201); |
||||
INSERT INTO `sys_role_menu`(`id`, `menu_id`, `role_id`) VALUES (1455363615505805313, 1123598815738675309, 1123598816738675201); |
||||
INSERT INTO `sys_role_menu`(`id`, `menu_id`, `role_id`) VALUES (1455363615518388225, 1123598815738675310, 1123598816738675201); |
||||
|
||||
|
||||
-- ---------------------------- |
||||
-- 增加create_dept字段并赋默认值 |
||||
-- ---------------------------- |
||||
ALTER TABLE `sys_client` |
||||
ADD COLUMN `create_dept` bigint(20) NULL COMMENT '创建部门' AFTER `create_user`; |
||||
ALTER TABLE `sys_notice` |
||||
ADD COLUMN `create_dept` bigint(20) NULL COMMENT '创建部门' AFTER `create_user`; |
||||
ALTER TABLE `sys_param` |
||||
ADD COLUMN `create_dept` bigint(20) NULL COMMENT '创建部门' AFTER `create_user`; |
||||
ALTER TABLE `sys_tenant` |
||||
ADD COLUMN `create_dept` bigint(20) NULL COMMENT '创建部门' AFTER `create_user`; |
||||
ALTER TABLE `sys_user` |
||||
ADD COLUMN `create_dept` bigint(20) NULL COMMENT '创建部门' AFTER `create_user`; |
||||
|
||||
UPDATE `sys_client` SET create_dept = 1123598813738675201 WHERE create_dept IS NULL; |
||||
UPDATE `sys_notice` SET create_dept = 1123598813738675201 WHERE create_dept IS NULL; |
||||
UPDATE `sys_param` SET create_dept = 1123598813738675201 WHERE create_dept IS NULL; |
||||
UPDATE `sys_tenant` SET create_dept = 1123598813738675201 WHERE create_dept IS NULL; |
||||
UPDATE `sys_user` SET create_dept = 1123598813738675201 WHERE create_dept IS NULL; |
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,238 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<groupId>com.energy.control</groupId> |
||||
<artifactId>smart-om-system</artifactId> |
||||
<packaging>jar</packaging> |
||||
<version>3.5.0</version> |
||||
|
||||
<properties> |
||||
<daf.tool.version>0.3.2-SNAPSHOT</daf.tool.version> |
||||
|
||||
<java.version>1.8</java.version> |
||||
|
||||
<knife4j.version>2.0.9</knife4j.version> |
||||
<mybatis.plus.version>3.5.2</mybatis.plus.version> |
||||
<protostuff.version>1.6.0</protostuff.version> |
||||
<captcha.version>1.6.2</captcha.version> |
||||
<easyexcel.version>2.2.6</easyexcel.version> |
||||
|
||||
<spring.boot.version>2.7.1</spring.boot.version> |
||||
<spring.plugin.version>2.0.0.RELEASE</spring.plugin.version> |
||||
<spring.platform.version>Cairo-SR8</spring.platform.version> |
||||
<mapstruct.version>1.4.1.Final</mapstruct.version> |
||||
</properties> |
||||
|
||||
<dependencyManagement> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.plugin</groupId> |
||||
<artifactId>spring-plugin-core</artifactId> |
||||
<version>${spring.plugin.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.plugin</groupId> |
||||
<artifactId>spring-plugin-metadata</artifactId> |
||||
<version>${spring.plugin.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-dependencies</artifactId> |
||||
<version>${spring.boot.version}</version> |
||||
<type>pom</type> |
||||
<scope>import</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.spring.platform</groupId> |
||||
<artifactId>platform-bom</artifactId> |
||||
<version>${spring.platform.version}</version> |
||||
<type>pom</type> |
||||
<scope>import</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
</dependencyManagement> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-boot</artifactId> |
||||
<version>${daf.tool.version}</version> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-cloud</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.postgresql</groupId> |
||||
<artifactId>postgresql</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-csv</artifactId> |
||||
<version>1.9.0</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.opencsv</groupId> |
||||
<artifactId>opencsv</artifactId> |
||||
<version>5.6</version> <!-- 使用最新版本 --> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-trace-starter</artifactId> |
||||
<version>${daf.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-develop</artifactId> |
||||
<version>${daf.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-oss</artifactId> |
||||
<version>${daf.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-report</artifactId> |
||||
<version>${daf.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-social</artifactId> |
||||
<version>${daf.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-datascope</artifactId> |
||||
<version>${daf.tool.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.github.xiaoymin</groupId> |
||||
<artifactId>knife4j-spring-ui</artifactId> |
||||
<version>${knife4j.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.github.whvcse</groupId> |
||||
<artifactId>easy-captcha</artifactId> |
||||
<version>${captcha.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>easyexcel</artifactId> |
||||
<version>3.1.1</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.dayu.daf</groupId> |
||||
<artifactId>dayu-core-test</artifactId> |
||||
<version>${daf.tool.version}</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.mapstruct</groupId> |
||||
<artifactId>mapstruct</artifactId> |
||||
<version>${mapstruct.version}</version> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<finalName>smart-om-system</finalName> |
||||
<resources> |
||||
<resource> |
||||
<directory>src/main/resources</directory> |
||||
</resource> |
||||
<resource> |
||||
<directory>src/main/java</directory> |
||||
<includes> |
||||
<include>**/*.xml</include> |
||||
</includes> |
||||
</resource> |
||||
</resources> |
||||
<pluginManagement> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
<version>${spring.boot.version}</version> |
||||
<configuration> |
||||
<finalName>${project.build.finalName}</finalName> |
||||
</configuration> |
||||
<executions> |
||||
<execution> |
||||
<goals> |
||||
<goal>repackage</goal> |
||||
</goals> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
</plugins> |
||||
</pluginManagement> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>3.8.1</version> |
||||
<configuration> |
||||
<source>${java.version}</source> |
||||
<target>${java.version}</target> |
||||
<encoding>UTF-8</encoding> |
||||
<compilerArgs> |
||||
<arg>-parameters</arg> |
||||
</compilerArgs> |
||||
<annotationProcessorPaths> |
||||
<path> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<version>1.18.24</version> |
||||
</path> |
||||
<path> |
||||
<groupId>org.mapstruct</groupId> |
||||
<artifactId>mapstruct-processor</artifactId> |
||||
<version>${mapstruct.version}</version> |
||||
</path> |
||||
<path> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok-mapstruct-binding</artifactId> |
||||
<version>0.2.0</version> |
||||
</path> |
||||
</annotationProcessorPaths> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
<repositories> |
||||
<repository> |
||||
<id>aliyun-repos</id> |
||||
<url>https://maven.aliyun.com/nexus/content/groups/public/</url> |
||||
<snapshots> |
||||
<enabled>false</enabled> |
||||
</snapshots> |
||||
</repository> |
||||
</repositories> |
||||
|
||||
<pluginRepositories> |
||||
<pluginRepository> |
||||
<id>aliyun-plugin</id> |
||||
<url>https://maven.aliyun.com/nexus/content/groups/public/</url> |
||||
<snapshots> |
||||
<enabled>false</enabled> |
||||
</snapshots> |
||||
</pluginRepository> |
||||
</pluginRepositories> |
||||
|
||||
</project> |
@ -0,0 +1,40 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy; |
||||
|
||||
import com.dayu.daf.core.launch.DafApplication; |
||||
import com.dayu.daf.core.secure.config.SecureConfiguration; |
||||
import org.energy.common.constant.LauncherConstant; |
||||
import org.mybatis.spring.annotation.MapperScan; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
|
||||
/** |
||||
* 启动器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@EnableScheduling |
||||
@SpringBootApplication(exclude = SecureConfiguration.class) |
||||
@MapperScan("org/energy/**/mapper") |
||||
public class Application { |
||||
|
||||
public static void main(String[] args) { |
||||
DafApplication.run(LauncherConstant.APPLICATION_NAME, Application.class, args); |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,34 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.common.cache; |
||||
|
||||
/** |
||||
* 缓存名 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface CacheNames { |
||||
|
||||
String NOTICE_ONE = "notice:one"; |
||||
|
||||
String DICT_VALUE = "dict:value"; |
||||
String DICT_LIST = "dict:list"; |
||||
|
||||
String CAPTCHA_KEY = "daf:auth::captcha:"; |
||||
|
||||
String DEL_USER_ID = "user:del:"; |
||||
|
||||
} |
@ -0,0 +1,52 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.common.config; |
||||
|
||||
|
||||
import com.dayu.daf.core.secure.registry.SecureRegistry; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
||||
/** |
||||
* Daf配置 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
public class DafConfiguration implements WebMvcConfigurer { |
||||
|
||||
@Bean |
||||
public SecureRegistry secureRegistry() { |
||||
SecureRegistry secureRegistry = new SecureRegistry(); |
||||
secureRegistry.setEnabled(true); |
||||
secureRegistry.excludePathPatterns("/daf-auth/**"); |
||||
secureRegistry.excludePathPatterns("/daf-system/menu/auth-routes"); |
||||
secureRegistry.excludePathPatterns("/daf-system/tenant/info"); |
||||
secureRegistry.excludePathPatterns("/doc.html"); |
||||
secureRegistry.excludePathPatterns("/js/**"); |
||||
secureRegistry.excludePathPatterns("/webjars/**"); |
||||
secureRegistry.excludePathPatterns("/swagger-resources/**"); |
||||
return secureRegistry; |
||||
} |
||||
|
||||
@Override |
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) { |
||||
registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,42 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.common.config; |
||||
|
||||
import com.dayu.daf.core.report.datasource.ReportDataSource; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import javax.sql.DataSource; |
||||
|
||||
/** |
||||
* 报表配置类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@ConditionalOnProperty(value = "report.enabled", havingValue = "true", matchIfMissing = true) |
||||
public class DafReportConfiguration { |
||||
|
||||
/** |
||||
* 自定义报表可选数据源 |
||||
*/ |
||||
@Bean |
||||
public ReportDataSource reportDataSource(DataSource dataSource) { |
||||
return new ReportDataSource(dataSource); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,119 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.common.config; |
||||
|
||||
import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; |
||||
import com.google.common.collect.Lists; |
||||
import lombok.AllArgsConstructor; |
||||
import com.dayu.daf.core.launch.constant.AppConstant; |
||||
import com.dayu.daf.core.secure.DafUser; |
||||
import com.dayu.daf.core.swagger.EnableSwagger; |
||||
import com.dayu.daf.core.swagger.SwaggerProperties; |
||||
import com.dayu.daf.core.swagger.SwaggerUtil; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import springfox.documentation.builders.ApiInfoBuilder; |
||||
import springfox.documentation.builders.PathSelectors; |
||||
import springfox.documentation.service.*; |
||||
import springfox.documentation.spi.DocumentationType; |
||||
import springfox.documentation.spi.service.contexts.SecurityContext; |
||||
import springfox.documentation.spring.web.plugins.Docket; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Swagger配置类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@EnableSwagger |
||||
@AllArgsConstructor |
||||
public class SwaggerConfiguration { |
||||
|
||||
/** |
||||
* 引入swagger配置类 |
||||
*/ |
||||
private final SwaggerProperties swaggerProperties; |
||||
|
||||
/** |
||||
* 引入Knife4j扩展类 |
||||
*/ |
||||
private final OpenApiExtensionResolver openApiExtensionResolver; |
||||
|
||||
@Bean |
||||
public Docket deskDocket() { |
||||
return docket("工作台模块", Collections.singletonList(AppConstant.BASE_PACKAGES + ".modules.desk")); |
||||
} |
||||
|
||||
@Bean |
||||
public Docket authDocket() { |
||||
return docket("授权模块", Collections.singletonList(AppConstant.BASE_PACKAGES + ".modules.auth")); |
||||
} |
||||
|
||||
@Bean |
||||
public Docket sysDocket() { |
||||
return docket("系统模块", |
||||
Arrays.asList(AppConstant.BASE_PACKAGES + ".modules.system", AppConstant.BASE_PACKAGES + ".modules.resource")); |
||||
} |
||||
|
||||
private Docket docket(String groupName, List<String> basePackages) { |
||||
return new Docket(DocumentationType.SWAGGER_2) |
||||
.groupName(groupName) |
||||
.apiInfo(apiInfo()) |
||||
.ignoredParameterTypes(DafUser.class) |
||||
.select() |
||||
.apis(SwaggerUtil.basePackages(basePackages)) |
||||
.paths(PathSelectors.any()) |
||||
.build().securityContexts(securityContexts()).securitySchemes(securitySchemas()) |
||||
.extensions(openApiExtensionResolver.buildExtensions(groupName)); |
||||
} |
||||
|
||||
private List<SecurityContext> securityContexts() { |
||||
return Collections.singletonList(SecurityContext.builder() |
||||
.securityReferences(defaultAuth()) |
||||
.forPaths(PathSelectors.regex("^.*$")) |
||||
.build()); |
||||
} |
||||
|
||||
List<SecurityReference> defaultAuth() { |
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverywhere"); |
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; |
||||
authorizationScopes[0] = authorizationScope; |
||||
return Lists.newArrayList(new SecurityReference(SwaggerUtil.clientInfo().getName(), authorizationScopes), |
||||
new SecurityReference(SwaggerUtil.dafAuth().getName(), authorizationScopes), |
||||
new SecurityReference(SwaggerUtil.dafTenant().getName(), authorizationScopes)); |
||||
} |
||||
|
||||
private List<SecurityScheme> securitySchemas() { |
||||
return Lists.newArrayList(SwaggerUtil.clientInfo(), SwaggerUtil.dafAuth(), SwaggerUtil.dafTenant()); |
||||
} |
||||
|
||||
private ApiInfo apiInfo() { |
||||
return new ApiInfoBuilder() |
||||
.title(swaggerProperties.getTitle()) |
||||
.description(swaggerProperties.getDescription()) |
||||
.license(swaggerProperties.getLicense()) |
||||
.licenseUrl(swaggerProperties.getLicenseUrl()) |
||||
.termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl()) |
||||
.contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail())) |
||||
.version(swaggerProperties.getVersion()) |
||||
.build(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,50 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.common.constant; |
||||
|
||||
/** |
||||
* 通用常量 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface CommonConstant { |
||||
|
||||
/** |
||||
* sword 系统名 |
||||
*/ |
||||
String SWORD_NAME = "sword"; |
||||
|
||||
/** |
||||
* saber 系统名 |
||||
*/ |
||||
String SABER_NAME = "saber"; |
||||
|
||||
/** |
||||
* 顶级父节点id |
||||
*/ |
||||
Long TOP_PARENT_ID = 0L; |
||||
|
||||
/** |
||||
* 顶级父节点名称 |
||||
*/ |
||||
String TOP_PARENT_NAME = "顶级"; |
||||
|
||||
/** |
||||
* 默认密码 |
||||
*/ |
||||
String DEFAULT_PASSWORD = "123456"; |
||||
|
||||
} |
@ -0,0 +1,63 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.common.constant; |
||||
|
||||
import com.dayu.daf.core.launch.constant.AppConstant; |
||||
|
||||
/** |
||||
* 通用常量 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface LauncherConstant { |
||||
|
||||
/** |
||||
* app name |
||||
*/ |
||||
String APPLICATION_NAME = AppConstant.APPLICATION_NAME_PREFIX + "api"; |
||||
|
||||
/** |
||||
* sentinel dev 地址 |
||||
*/ |
||||
String SENTINEL_DEV_ADDR = "127.0.0.1:8858"; |
||||
|
||||
/** |
||||
* sentinel prod 地址 |
||||
*/ |
||||
String SENTINEL_PROD_ADDR = "192.168.186.129:8858"; |
||||
|
||||
/** |
||||
* sentinel test 地址 |
||||
*/ |
||||
String SENTINEL_TEST_ADDR = "192.168.186.129:8858"; |
||||
|
||||
/** |
||||
* 动态获取sentinel地址 |
||||
* |
||||
* @param profile 环境变量 |
||||
* @return addr |
||||
*/ |
||||
static String sentinelAddr(String profile) { |
||||
switch (profile) { |
||||
case (AppConstant.PROD_CODE): |
||||
return SENTINEL_PROD_ADDR; |
||||
case (AppConstant.TEST_CODE): |
||||
return SENTINEL_TEST_ADDR; |
||||
default: |
||||
return SENTINEL_DEV_ADDR; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,37 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.common.launch; |
||||
|
||||
import org.energy.common.constant.LauncherConstant; |
||||
import com.dayu.daf.core.launch.service.LauncherService; |
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
|
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* 启动参数拓展 |
||||
* |
||||
* @author smallchil |
||||
*/ |
||||
public class LauncherServiceImpl implements LauncherService { |
||||
|
||||
@Override |
||||
public void launcher(SpringApplicationBuilder builder, String appName, String profile) { |
||||
Properties props = System.getProperties(); |
||||
props.setProperty("spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,25 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.common.tool; |
||||
|
||||
/** |
||||
* 通用工具类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public class CommonUtil { |
||||
|
||||
} |
@ -0,0 +1,66 @@ |
||||
package org.energy.core.config; |
||||
|
||||
|
||||
import com.dayu.daf.core.secure.aspect.AuthAspect; |
||||
import com.dayu.daf.core.secure.interceptor.ClientInterceptor; |
||||
import com.dayu.daf.core.secure.props.DafSecureProperties; |
||||
import com.dayu.daf.core.secure.props.DafTokenProperties; |
||||
import com.dayu.daf.core.secure.provider.ClientDetailsServiceImpl; |
||||
import com.dayu.daf.core.secure.provider.IClientDetailsService; |
||||
import com.dayu.daf.core.secure.registry.SecureRegistry; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.core.interceptor.EnergySecureInterceptor; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.core.annotation.Order; |
||||
import org.springframework.jdbc.core.JdbcTemplate; |
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
||||
/** |
||||
* 安全配置类 |
||||
* |
||||
* @author Dayu |
||||
*/ |
||||
@Order |
||||
@Configuration |
||||
@AllArgsConstructor |
||||
@EnableConfigurationProperties({DafSecureProperties.class, DafTokenProperties.class}) |
||||
public class EnergySecureConfiguration implements WebMvcConfigurer { |
||||
|
||||
private final SecureRegistry secureRegistry; |
||||
|
||||
private final DafSecureProperties secureProperties; |
||||
|
||||
private final JdbcTemplate jdbcTemplate; |
||||
|
||||
@Autowired |
||||
private EnergySecureInterceptor energySecureInterceptor; |
||||
|
||||
@Override |
||||
public void addInterceptors(InterceptorRegistry registry) { |
||||
secureProperties.getClient().forEach(cs -> registry.addInterceptor(new ClientInterceptor(cs.getClientId())).addPathPatterns(cs.getPathPatterns())); |
||||
|
||||
if (secureRegistry.isEnabled()) { |
||||
registry.addInterceptor(energySecureInterceptor) |
||||
.excludePathPatterns(secureRegistry.getExcludePatterns()) |
||||
.excludePathPatterns(secureRegistry.getDefaultExcludePatterns()) |
||||
.excludePathPatterns(secureProperties.getSkipUrl()); |
||||
} |
||||
} |
||||
|
||||
@Bean |
||||
public AuthAspect authAspect() { |
||||
return new AuthAspect(); |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean(IClientDetailsService.class) |
||||
public IClientDetailsService clientDetailsService() { |
||||
return new ClientDetailsServiceImpl(jdbcTemplate); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,53 @@ |
||||
package org.energy.core.interceptor; |
||||
|
||||
import com.dayu.daf.core.secure.DafUser; |
||||
import com.dayu.daf.core.secure.utils.SecureUtil; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.api.ResultCode; |
||||
import com.dayu.daf.core.tool.constant.DafConstant; |
||||
import com.dayu.daf.core.tool.jackson.JsonUtil; |
||||
import com.dayu.daf.core.tool.utils.RedisUtil; |
||||
import com.dayu.daf.core.tool.utils.WebUtil; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.energy.common.cache.CacheNames; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.servlet.AsyncHandlerInterceptor; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.util.Objects; |
||||
|
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
@Component |
||||
public class EnergySecureInterceptor implements AsyncHandlerInterceptor { |
||||
|
||||
private RedisUtil redisUtil; |
||||
|
||||
@Override |
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { |
||||
DafUser dafUser = SecureUtil.getUser(); |
||||
Object userId = null; |
||||
if (dafUser != null) { |
||||
userId = redisUtil.get(CacheNames.DEL_USER_ID + dafUser.getUserId()); |
||||
} |
||||
if (null != dafUser && userId == null) { |
||||
return true; |
||||
} else { |
||||
log.warn("签名认证失败,请求接口:{},请求IP:{},请求参数:{}", request.getRequestURI(), WebUtil.getIP(request), JsonUtil.toJson(request.getParameterMap())); |
||||
R result = R.fail(ResultCode.UN_AUTHORIZED); |
||||
response.setCharacterEncoding(DafConstant.UTF_8); |
||||
response.setHeader(DafConstant.CONTENT_TYPE_NAME, MediaType.APPLICATION_JSON_VALUE); |
||||
response.setStatus(HttpServletResponse.SC_OK); |
||||
try { |
||||
response.getWriter().write(Objects.requireNonNull(JsonUtil.toJson(result))); |
||||
} catch (IOException ex) { |
||||
log.error(ex.getMessage()); |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,72 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.energy.core.log.config; |
||||
|
||||
import com.dayu.daf.core.launch.props.DafProperties; |
||||
import com.dayu.daf.core.launch.server.ServerInfo; |
||||
import com.dayu.daf.core.log.aspect.ApiLogAspect; |
||||
import com.dayu.daf.core.log.logger.DafLogger; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.core.log.event.ApiLogListener; |
||||
import org.energy.core.log.event.ErrorLogListener; |
||||
import org.energy.core.log.event.UsualLogListener; |
||||
import org.energy.modules.system.service.ILogService; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* 日志工具自动配置 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@AllArgsConstructor |
||||
@ConditionalOnWebApplication |
||||
//@AutoConfigureBefore(LogUsualMapper.class)
|
||||
public class DafLogToolAutoConfiguration { |
||||
|
||||
private final ILogService logService; |
||||
private final ServerInfo serverInfo; |
||||
private final DafProperties dafProperties; |
||||
|
||||
@Bean(value = "energyApiLogAspect") |
||||
public ApiLogAspect apiLogAspect() { |
||||
return new ApiLogAspect(); |
||||
} |
||||
|
||||
@Bean(value = "energyDafLogger") |
||||
public DafLogger dafLogger() { |
||||
return new DafLogger(); |
||||
} |
||||
|
||||
@Bean(value = "energyApiLogListener") |
||||
public ApiLogListener apiLogListener() { |
||||
return new ApiLogListener(logService, serverInfo, dafProperties); |
||||
} |
||||
|
||||
@Bean(value = "energyErrorEventListener") |
||||
public ErrorLogListener errorEventListener() { |
||||
return new ErrorLogListener(logService, serverInfo, dafProperties); |
||||
} |
||||
|
||||
@Bean(value = "energyDafEventListener") |
||||
public UsualLogListener dafEventListener() { |
||||
return new UsualLogListener(logService, serverInfo, dafProperties); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,59 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.energy.core.log.event; |
||||
|
||||
import com.dayu.daf.core.launch.props.DafProperties; |
||||
import com.dayu.daf.core.launch.server.ServerInfo; |
||||
import com.dayu.daf.core.log.constant.EventConstant; |
||||
import com.dayu.daf.core.log.event.ApiLogEvent; |
||||
import com.dayu.daf.core.log.model.LogApi; |
||||
import com.dayu.daf.core.log.utils.LogAbstractUtil; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.energy.modules.system.service.ILogService; |
||||
import org.springframework.context.event.EventListener; |
||||
import org.springframework.core.annotation.Order; |
||||
import org.springframework.scheduling.annotation.Async; |
||||
|
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* 异步监听日志事件 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class ApiLogListener { |
||||
|
||||
private final ILogService logService; |
||||
private final ServerInfo serverInfo; |
||||
private final DafProperties dafProperties; |
||||
|
||||
|
||||
@Async |
||||
@Order |
||||
@EventListener(ApiLogEvent.class) |
||||
public void saveApiLog(ApiLogEvent event) { |
||||
Map<String, Object> source = (Map<String, Object>) event.getSource(); |
||||
LogApi logApi = (LogApi) source.get(EventConstant.EVENT_LOG); |
||||
LogAbstractUtil.addOtherInfoToLog(logApi, dafProperties, serverInfo); |
||||
logService.saveApiLog(logApi); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,56 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.core.log.event; |
||||
|
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.energy.modules.system.service.ILogService; |
||||
import com.dayu.daf.core.launch.props.DafProperties; |
||||
import com.dayu.daf.core.launch.server.ServerInfo; |
||||
import com.dayu.daf.core.log.constant.EventConstant; |
||||
import com.dayu.daf.core.log.event.ErrorLogEvent; |
||||
import com.dayu.daf.core.log.model.LogError; |
||||
import com.dayu.daf.core.log.utils.LogAbstractUtil; |
||||
import org.springframework.context.event.EventListener; |
||||
import org.springframework.core.annotation.Order; |
||||
import org.springframework.scheduling.annotation.Async; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 异步监听错误日志事件 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class ErrorLogListener { |
||||
|
||||
private final ILogService logService; |
||||
private final ServerInfo serverInfo; |
||||
private final DafProperties dafProperties; |
||||
|
||||
@Async |
||||
@Order |
||||
@EventListener(ErrorLogEvent.class) |
||||
public void saveErrorLog(ErrorLogEvent event) { |
||||
Map<String, Object> source = (Map<String, Object>) event.getSource(); |
||||
LogError logError = (LogError) source.get(EventConstant.EVENT_LOG); |
||||
LogAbstractUtil.addOtherInfoToLog(logError, dafProperties, serverInfo); |
||||
logService.saveErrorLog(logError); |
||||
} |
||||
} |
@ -0,0 +1,57 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.core.log.event; |
||||
|
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.energy.modules.system.service.ILogService; |
||||
import com.dayu.daf.core.launch.props.DafProperties; |
||||
import com.dayu.daf.core.launch.server.ServerInfo; |
||||
import com.dayu.daf.core.log.constant.EventConstant; |
||||
import com.dayu.daf.core.log.event.UsualLogEvent; |
||||
import com.dayu.daf.core.log.model.LogUsual; |
||||
import com.dayu.daf.core.log.utils.LogAbstractUtil; |
||||
import org.springframework.context.event.EventListener; |
||||
import org.springframework.core.annotation.Order; |
||||
import org.springframework.scheduling.annotation.Async; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 异步监听日志事件 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class UsualLogListener { |
||||
|
||||
private final ILogService logService; |
||||
private final ServerInfo serverInfo; |
||||
private final DafProperties dafProperties; |
||||
|
||||
@Async |
||||
@Order |
||||
@EventListener(UsualLogEvent.class) |
||||
public void saveUsualLog(UsualLogEvent event) { |
||||
Map<String, Object> source = (Map<String, Object>) event.getSource(); |
||||
LogUsual logUsual = (LogUsual) source.get(EventConstant.EVENT_LOG); |
||||
LogAbstractUtil.addOtherInfoToLog(logUsual, dafProperties, serverInfo); |
||||
logService.saveUsualLog(logUsual); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,61 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.core.secure; |
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import org.energy.modules.system.vo.MenuVO; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* AuthInfo |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@ApiModel(description = "认证信息") |
||||
public class AuthInfo { |
||||
@ApiModelProperty(value = "令牌") |
||||
private String accessToken; |
||||
@ApiModelProperty(value = "令牌类型") |
||||
private String tokenType; |
||||
@ApiModelProperty(value = "刷新令牌") |
||||
private String refreshToken; |
||||
@ApiModelProperty(value = "用户ID") |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long userId; |
||||
@ApiModelProperty(value = "租户ID") |
||||
private String tenantId; |
||||
@ApiModelProperty(value = "第三方系统ID") |
||||
private String oauthId; |
||||
@ApiModelProperty(value = "头像") |
||||
private String avatar = "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"; |
||||
@ApiModelProperty(value = "角色名") |
||||
private String authority; |
||||
@ApiModelProperty(value = "用户名") |
||||
private String userName; |
||||
@ApiModelProperty(value = "账号名") |
||||
private String account; |
||||
@ApiModelProperty(value = "过期时间") |
||||
private long expiresIn; |
||||
@ApiModelProperty(value = "许可证") |
||||
private String license = "powered by daf"; |
||||
private List<MenuVO> roleMenus; |
||||
} |
@ -0,0 +1,488 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.core.secure.utils; |
||||
|
||||
import io.jsonwebtoken.Claims; |
||||
import io.jsonwebtoken.JwtBuilder; |
||||
import io.jsonwebtoken.Jwts; |
||||
import io.jsonwebtoken.SignatureAlgorithm; |
||||
import lombok.SneakyThrows; |
||||
import com.dayu.daf.core.launch.constant.TokenConstant; |
||||
import com.dayu.daf.core.secure.DafUser; |
||||
import com.dayu.daf.core.secure.TokenInfo; |
||||
import com.dayu.daf.core.secure.constant.SecureConstant; |
||||
import com.dayu.daf.core.secure.exception.SecureException; |
||||
import com.dayu.daf.core.secure.props.DafTokenProperties; |
||||
import com.dayu.daf.core.secure.provider.IClientDetails; |
||||
import com.dayu.daf.core.secure.provider.IClientDetailsService; |
||||
import com.dayu.daf.core.tool.constant.RoleConstant; |
||||
import com.dayu.daf.core.tool.utils.*; |
||||
|
||||
import javax.crypto.spec.SecretKeySpec; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.security.Key; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* Secure工具类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public class SecureUtil { |
||||
private static final String sys_USER_REQUEST_ATTR = "_sys_USER_REQUEST_ATTR_"; |
||||
|
||||
private final static String HEADER = TokenConstant.HEADER; |
||||
private final static String BEARER = TokenConstant.BEARER; |
||||
private final static String ACCOUNT = TokenConstant.ACCOUNT; |
||||
private final static String USER_ID = TokenConstant.USER_ID; |
||||
private final static String ROLE_ID = TokenConstant.ROLE_ID; |
||||
private final static String DEPT_ID = TokenConstant.DEPT_ID; |
||||
private final static String USER_NAME = TokenConstant.USER_NAME; |
||||
private final static String ROLE_NAME = TokenConstant.ROLE_NAME; |
||||
private final static String TENANT_ID = TokenConstant.TENANT_ID; |
||||
private final static String CLIENT_ID = TokenConstant.CLIENT_ID; |
||||
private final static Integer AUTH_LENGTH = TokenConstant.AUTH_LENGTH; |
||||
private static IClientDetailsService CLIENT_DETAILS_SERVICE; |
||||
private static DafTokenProperties TOKEN_PROPERTIES; |
||||
private static String BASE64_SECURITY; |
||||
|
||||
|
||||
/** |
||||
* 获取客户端服务类 |
||||
* |
||||
* @return clientDetailsService |
||||
*/ |
||||
private static IClientDetailsService getClientDetailsService() { |
||||
if (CLIENT_DETAILS_SERVICE == null) { |
||||
CLIENT_DETAILS_SERVICE = SpringUtil.getBean(IClientDetailsService.class); |
||||
} |
||||
return CLIENT_DETAILS_SERVICE; |
||||
} |
||||
|
||||
/** |
||||
* 获取配置类 |
||||
* |
||||
* @return jwtProperties |
||||
*/ |
||||
private static DafTokenProperties getTokenProperties() { |
||||
if (TOKEN_PROPERTIES == null) { |
||||
TOKEN_PROPERTIES = SpringUtil.getBean(DafTokenProperties.class); |
||||
} |
||||
return TOKEN_PROPERTIES; |
||||
} |
||||
|
||||
/** |
||||
* 获取Token签名 |
||||
* |
||||
* @return String |
||||
*/ |
||||
private static String getBase64Security() { |
||||
if (BASE64_SECURITY == null) { |
||||
BASE64_SECURITY = Base64.getEncoder().encodeToString(getTokenProperties().getSignKey().getBytes(Charsets.UTF_8)); |
||||
} |
||||
return BASE64_SECURITY; |
||||
} |
||||
|
||||
/** |
||||
* 获取用户信息 |
||||
* |
||||
* @return DafUser |
||||
*/ |
||||
public static DafUser getUser() { |
||||
HttpServletRequest request = WebUtil.getRequest(); |
||||
if (request == null) { |
||||
return null; |
||||
} |
||||
// 优先从 request 中获取
|
||||
Object DafUser = request.getAttribute(sys_USER_REQUEST_ATTR); |
||||
if (DafUser == null) { |
||||
DafUser = getUser(request); |
||||
if (DafUser != null) { |
||||
// 设置到 request 中
|
||||
request.setAttribute(sys_USER_REQUEST_ATTR, DafUser); |
||||
} |
||||
} |
||||
return (DafUser) DafUser; |
||||
} |
||||
|
||||
/** |
||||
* 获取用户信息 |
||||
* |
||||
* @param request request |
||||
* @return DafUser |
||||
*/ |
||||
public static DafUser getUser(HttpServletRequest request) { |
||||
Claims claims = getClaims(request); |
||||
if (claims == null) { |
||||
return null; |
||||
} |
||||
String clientId = Func.toStr(claims.get(SecureUtil.CLIENT_ID)); |
||||
Long userId = Func.toLong(claims.get(SecureUtil.USER_ID)); |
||||
String tenantId = Func.toStr(claims.get(SecureUtil.TENANT_ID)); |
||||
String roleId = Func.toStr(claims.get(SecureUtil.ROLE_ID)); |
||||
String deptId = Func.toStr(claims.get(SecureUtil.DEPT_ID)); |
||||
String account = Func.toStr(claims.get(SecureUtil.ACCOUNT)); |
||||
String roleName = Func.toStr(claims.get(SecureUtil.ROLE_NAME)); |
||||
String userName = Func.toStr(claims.get(SecureUtil.USER_NAME)); |
||||
DafUser DafUser = new DafUser(); |
||||
DafUser.setClientId(clientId); |
||||
DafUser.setUserId(userId); |
||||
DafUser.setTenantId(tenantId); |
||||
DafUser.setAccount(account); |
||||
DafUser.setRoleId(roleId); |
||||
DafUser.setDeptId(deptId); |
||||
DafUser.setRoleName(roleName); |
||||
DafUser.setUserName(userName); |
||||
return DafUser; |
||||
} |
||||
|
||||
/** |
||||
* 是否为超管 |
||||
* |
||||
* @return boolean |
||||
*/ |
||||
public static boolean isAdministrator() { |
||||
return StringUtil.containsAny(getUserRole(), RoleConstant.ADMIN); |
||||
} |
||||
|
||||
/** |
||||
* 获取用户id |
||||
* |
||||
* @return userId |
||||
*/ |
||||
public static Long getUserId() { |
||||
DafUser user = getUser(); |
||||
return (null == user) ? -1 : user.getUserId(); |
||||
} |
||||
|
||||
/** |
||||
* 获取用户id |
||||
* |
||||
* @param request request |
||||
* @return userId |
||||
*/ |
||||
public static Long getUserId(HttpServletRequest request) { |
||||
DafUser user = getUser(request); |
||||
return (null == user) ? -1 : user.getUserId(); |
||||
} |
||||
|
||||
/** |
||||
* 获取用户账号 |
||||
* |
||||
* @return userAccount |
||||
*/ |
||||
public static String getUserAccount() { |
||||
DafUser user = getUser(); |
||||
return (null == user) ? StringPool.EMPTY : user.getAccount(); |
||||
} |
||||
|
||||
/** |
||||
* 获取用户账号 |
||||
* |
||||
* @param request request |
||||
* @return userAccount |
||||
*/ |
||||
public static String getUserAccount(HttpServletRequest request) { |
||||
DafUser user = getUser(request); |
||||
return (null == user) ? StringPool.EMPTY : user.getAccount(); |
||||
} |
||||
|
||||
/** |
||||
* 获取用户名 |
||||
* |
||||
* @return userName |
||||
*/ |
||||
public static String getUserName() { |
||||
DafUser user = getUser(); |
||||
return (null == user) ? StringPool.EMPTY : user.getUserName(); |
||||
} |
||||
|
||||
/** |
||||
* 获取用户名 |
||||
* |
||||
* @param request request |
||||
* @return userName |
||||
*/ |
||||
public static String getUserName(HttpServletRequest request) { |
||||
DafUser user = getUser(request); |
||||
return (null == user) ? StringPool.EMPTY : user.getUserName(); |
||||
} |
||||
|
||||
/** |
||||
* 获取用户角色 |
||||
* |
||||
* @return userName |
||||
*/ |
||||
public static String getUserRole() { |
||||
DafUser user = getUser(); |
||||
return (null == user) ? StringPool.EMPTY : user.getRoleName(); |
||||
} |
||||
|
||||
/** |
||||
* 获取用角色 |
||||
* |
||||
* @param request request |
||||
* @return userName |
||||
*/ |
||||
public static String getUserRole(HttpServletRequest request) { |
||||
DafUser user = getUser(request); |
||||
return (null == user) ? StringPool.EMPTY : user.getRoleName(); |
||||
} |
||||
|
||||
/** |
||||
* 获取租户ID |
||||
* |
||||
* @return tenantId |
||||
*/ |
||||
public static String getTenantId() { |
||||
DafUser user = getUser(); |
||||
return (null == user) ? StringPool.EMPTY : user.getTenantId(); |
||||
} |
||||
|
||||
/** |
||||
* 获取租户ID |
||||
* |
||||
* @param request request |
||||
* @return tenantId |
||||
*/ |
||||
public static String getTenantId(HttpServletRequest request) { |
||||
DafUser user = getUser(request); |
||||
return (null == user) ? StringPool.EMPTY : user.getTenantId(); |
||||
} |
||||
|
||||
/** |
||||
* 获取客户端id |
||||
* |
||||
* @return tenantId |
||||
*/ |
||||
public static String getClientId() { |
||||
DafUser user = getUser(); |
||||
return (null == user) ? StringPool.EMPTY : user.getClientId(); |
||||
} |
||||
|
||||
/** |
||||
* 获取客户端id |
||||
* |
||||
* @param request request |
||||
* @return tenantId |
||||
*/ |
||||
public static String getClientId(HttpServletRequest request) { |
||||
DafUser user = getUser(request); |
||||
return (null == user) ? StringPool.EMPTY : user.getClientId(); |
||||
} |
||||
|
||||
/** |
||||
* 获取Claims |
||||
* |
||||
* @param request request |
||||
* @return Claims |
||||
*/ |
||||
public static Claims getClaims(HttpServletRequest request) { |
||||
String auth = request.getHeader(SecureUtil.HEADER); |
||||
if (StringUtil.isNotBlank(auth) && auth.length() > AUTH_LENGTH) { |
||||
String headStr = auth.substring(0, 6).toLowerCase(); |
||||
if (headStr.compareTo(SecureUtil.BEARER) == 0) { |
||||
auth = auth.substring(7); |
||||
return SecureUtil.parseJWT(auth); |
||||
} |
||||
} else { |
||||
String parameter = request.getParameter(SecureUtil.HEADER); |
||||
if (StringUtil.isNotBlank(parameter)) { |
||||
return SecureUtil.parseJWT(parameter); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 获取请求头 |
||||
* |
||||
* @return header |
||||
*/ |
||||
public static String getHeader() { |
||||
return getHeader(Objects.requireNonNull(WebUtil.getRequest())); |
||||
} |
||||
|
||||
/** |
||||
* 获取请求头 |
||||
* |
||||
* @param request request |
||||
* @return header |
||||
*/ |
||||
public static String getHeader(HttpServletRequest request) { |
||||
return request.getHeader(HEADER); |
||||
} |
||||
|
||||
/** |
||||
* 解析jsonWebToken |
||||
* |
||||
* @param jsonWebToken jsonWebToken |
||||
* @return Claims |
||||
*/ |
||||
public static Claims parseJWT(String jsonWebToken) { |
||||
try { |
||||
return Jwts.parserBuilder() |
||||
.setSigningKey(Base64.getDecoder().decode(getBase64Security())).build() |
||||
.parseClaimsJws(jsonWebToken).getBody(); |
||||
} catch (Exception ex) { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 创建令牌 |
||||
* |
||||
* @param user user |
||||
* @param audience audience |
||||
* @param issuer issuer |
||||
* @param tokenType tokenType |
||||
* @return jwt |
||||
*/ |
||||
public static TokenInfo createJWT(Map<String, String> user, String audience, String issuer, String tokenType) { |
||||
|
||||
String[] tokens = extractAndDecodeHeader(); |
||||
assert tokens.length == 2; |
||||
String clientId = tokens[0]; |
||||
String clientSecret = tokens[1]; |
||||
|
||||
// 获取客户端信息
|
||||
IClientDetails clientDetails = clientDetails(clientId); |
||||
|
||||
// 校验客户端信息
|
||||
if (!validateClient(clientDetails, clientId, clientSecret)) { |
||||
throw new SecureException("客户端认证失败!"); |
||||
} |
||||
|
||||
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; |
||||
|
||||
long nowMillis = System.currentTimeMillis(); |
||||
Date now = new Date(nowMillis); |
||||
|
||||
//生成签名密钥
|
||||
byte[] apiKeySecretBytes = Base64.getDecoder().decode(getBase64Security()); |
||||
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName()); |
||||
|
||||
//添加构成JWT的类
|
||||
JwtBuilder builder = Jwts.builder().setHeaderParam("typ", "JWT") |
||||
.setIssuer(issuer) |
||||
.setAudience(audience) |
||||
.signWith(signingKey); |
||||
|
||||
//设置JWT参数
|
||||
user.forEach(builder::claim); |
||||
|
||||
//设置应用id
|
||||
builder.claim(CLIENT_ID, clientId); |
||||
|
||||
//添加Token过期时间
|
||||
long expireMillis; |
||||
if (tokenType.equals(TokenConstant.ACCESS_TOKEN)) { |
||||
expireMillis = clientDetails.getAccessTokenValidity() * 1000; |
||||
} else if (tokenType.equals(TokenConstant.REFRESH_TOKEN)) { |
||||
expireMillis = clientDetails.getRefreshTokenValidity() * 1000; |
||||
} else { |
||||
expireMillis = getExpire(); |
||||
} |
||||
long expMillis = nowMillis + expireMillis; |
||||
Date exp = new Date(expMillis); |
||||
builder.setExpiration(exp).setNotBefore(now); |
||||
|
||||
// 组装Token信息
|
||||
TokenInfo tokenInfo = new TokenInfo(); |
||||
tokenInfo.setToken(builder.compact()); |
||||
tokenInfo.setExpire((int) expireMillis / 1000); |
||||
|
||||
return tokenInfo; |
||||
} |
||||
|
||||
/** |
||||
* 获取过期时间(次日凌晨3点) |
||||
* |
||||
* @return expire |
||||
*/ |
||||
public static long getExpire() { |
||||
Calendar cal = Calendar.getInstance(); |
||||
cal.add(Calendar.DAY_OF_YEAR, 1); |
||||
cal.set(Calendar.HOUR_OF_DAY, 3); |
||||
cal.set(Calendar.SECOND, 0); |
||||
cal.set(Calendar.MINUTE, 0); |
||||
cal.set(Calendar.MILLISECOND, 0); |
||||
return cal.getTimeInMillis() - System.currentTimeMillis(); |
||||
} |
||||
|
||||
/** |
||||
* 客户端信息解码 |
||||
*/ |
||||
@SneakyThrows |
||||
public static String[] extractAndDecodeHeader() { |
||||
// 获取请求头客户端信息
|
||||
String header = Objects.requireNonNull(WebUtil.getRequest()).getHeader(SecureConstant.BASIC_HEADER_KEY); |
||||
header = Func.toStr(header).replace(SecureConstant.BASIC_HEADER_PREFIX_EXT, SecureConstant.BASIC_HEADER_PREFIX); |
||||
if (!header.startsWith(SecureConstant.BASIC_HEADER_PREFIX)) { |
||||
throw new SecureException("No client information in request header"); |
||||
} |
||||
byte[] base64Token = header.substring(6).getBytes(Charsets.UTF_8_NAME); |
||||
|
||||
byte[] decoded; |
||||
try { |
||||
decoded = Base64.getDecoder().decode(base64Token); |
||||
} catch (IllegalArgumentException var7) { |
||||
throw new RuntimeException("Failed to decode basic authentication token"); |
||||
} |
||||
|
||||
String token = new String(decoded, Charsets.UTF_8_NAME); |
||||
int index = token.indexOf(StringPool.COLON); |
||||
if (index == -1) { |
||||
throw new RuntimeException("Invalid basic authentication token"); |
||||
} else { |
||||
return new String[]{token.substring(0, index), token.substring(index + 1)}; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取请求头中的客户端id |
||||
*/ |
||||
public static String getClientIdFromHeader() { |
||||
String[] tokens = extractAndDecodeHeader(); |
||||
assert tokens.length == 2; |
||||
return tokens[0]; |
||||
} |
||||
|
||||
/** |
||||
* 获取客户端信息 |
||||
* |
||||
* @param clientId 客户端id |
||||
* @return clientDetails |
||||
*/ |
||||
private static IClientDetails clientDetails(String clientId) { |
||||
return getClientDetailsService().loadClientByClientId(clientId); |
||||
} |
||||
|
||||
/** |
||||
* 校验Client |
||||
* |
||||
* @param clientId 客户端id |
||||
* @param clientSecret 客户端密钥 |
||||
* @return boolean |
||||
*/ |
||||
private static boolean validateClient(IClientDetails clientDetails, String clientId, String clientSecret) { |
||||
if (clientDetails != null) { |
||||
return StringUtil.equals(clientId, clientDetails.getClientId()) && StringUtil.equals(clientSecret, clientDetails.getClientSecret()); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,112 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.controller; |
||||
|
||||
import com.wf.captcha.SpecCaptcha; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.modules.system.entity.UserInfo; |
||||
import org.energy.common.cache.CacheNames; |
||||
import org.energy.core.secure.AuthInfo; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.support.Kv; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import com.dayu.daf.core.tool.utils.RedisUtil; |
||||
import com.dayu.daf.core.tool.utils.WebUtil; |
||||
import org.energy.modules.auth.granter.ITokenGranter; |
||||
import org.energy.modules.auth.granter.TokenGranterBuilder; |
||||
import org.energy.modules.auth.granter.TokenParameter; |
||||
import org.energy.modules.auth.utils.TokenUtil; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
/** |
||||
* 认证模块 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("daf-auth") |
||||
@Api(value = "用户授权认证", tags = "授权接口") |
||||
public class AuthController { |
||||
|
||||
private RedisUtil redisUtil; |
||||
|
||||
|
||||
@PostMapping("token") |
||||
@ApiOperation(value = "获取认证token", notes = "传入租户ID:tenantId,账号:account,密码:password") |
||||
public R<AuthInfo> token(@ApiParam(value = "授权类型", required = true) @RequestParam(defaultValue = "password", required = false) String grantType, |
||||
@ApiParam(value = "刷新令牌") @RequestParam(required = false) String refreshToken, |
||||
@ApiParam(value = "租户ID", required = true) @RequestParam(defaultValue = "000000", required = false) String tenantId, |
||||
@ApiParam(value = "账号") @RequestParam(required = false) String account, |
||||
@ApiParam(value = "密码") @RequestParam(required = false) String password) { |
||||
|
||||
String userType = Func.toStr(WebUtil.getRequest().getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE); |
||||
|
||||
TokenParameter tokenParameter = new TokenParameter(); |
||||
tokenParameter.getArgs().set("tenantId", tenantId) |
||||
.set("account", account) |
||||
.set("password", password) |
||||
.set("grantType", grantType) |
||||
.set("refreshToken", refreshToken) |
||||
.set("userType", userType); |
||||
|
||||
ITokenGranter granter = TokenGranterBuilder.getGranter(grantType); |
||||
UserInfo userInfo = granter.grant(tokenParameter); |
||||
|
||||
if (userInfo == null || userInfo.getUser() == null) { |
||||
return R.fail(TokenUtil.USER_NOT_FOUND); |
||||
} |
||||
|
||||
return R.data(TokenUtil.createAuthInfo(userInfo)); |
||||
} |
||||
|
||||
@GetMapping("/captcha") |
||||
@ApiOperation(value = "获取验证码") |
||||
public R<Kv> captcha() { |
||||
SpecCaptcha specCaptcha = new SpecCaptcha(130, 48, 5); |
||||
String verCode = specCaptcha.text().toLowerCase(); |
||||
String key = UUID.randomUUID().toString(); |
||||
// 存入redis并设置过期时间为30分钟
|
||||
redisUtil.set(CacheNames.CAPTCHA_KEY + key, verCode, 30L, TimeUnit.MINUTES); |
||||
// 将key和base64返回给前端
|
||||
return R.data(Kv.init().set("key", key).set("image", specCaptcha.toBase64())); |
||||
} |
||||
|
||||
@PostMapping("scada-token") |
||||
@ApiOperation(value = "获取认证scada-token", notes = "传入") |
||||
public R<AuthInfo> token2(@ApiParam(value = "租户ID", required = true) @RequestParam(defaultValue = "000000", required = false) String tenantId, |
||||
@ApiParam(value = "token") @RequestParam(required = false) String token) { |
||||
String grantType = "scada"; |
||||
TokenParameter tokenParameter = new TokenParameter(); |
||||
tokenParameter.getArgs().set("tenantId", tenantId).set("grantType", grantType).set("token", token); |
||||
ITokenGranter granter = TokenGranterBuilder.getGranter(grantType); |
||||
UserInfo userInfo = granter.grant(tokenParameter); |
||||
|
||||
if (userInfo == null || userInfo.getUser() == null) { |
||||
return R.fail(TokenUtil.USER_NOT_FOUND); |
||||
} |
||||
// success
|
||||
return R.data(TokenUtil.createAuthInfo(userInfo)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,94 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.controller; |
||||
|
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import me.zhyd.oauth.model.AuthCallback; |
||||
import me.zhyd.oauth.model.AuthToken; |
||||
import me.zhyd.oauth.request.AuthRequest; |
||||
import me.zhyd.oauth.utils.AuthStateUtils; |
||||
import com.dayu.daf.core.launch.constant.AppConstant; |
||||
import com.dayu.daf.core.social.props.SocialProperties; |
||||
import com.dayu.daf.core.social.utils.SocialUtil; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* 第三方登陆端点 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Slf4j |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_AUTH_NAME) |
||||
@ConditionalOnProperty(value = "social.enabled", havingValue = "true") |
||||
@Api(value = "第三方登陆", tags = "第三方登陆端点") |
||||
public class SocialController { |
||||
|
||||
private final SocialProperties socialProperties; |
||||
|
||||
/** |
||||
* 授权完毕跳转 |
||||
*/ |
||||
@ApiOperation(value = "授权完毕跳转") |
||||
@RequestMapping("/oauth/render/{source}") |
||||
public void renderAuth(@PathVariable("source") String source, HttpServletResponse response) throws IOException { |
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState()); |
||||
response.sendRedirect(authorizeUrl); |
||||
} |
||||
|
||||
/** |
||||
* 获取认证信息 |
||||
*/ |
||||
@ApiOperation(value = "获取认证信息") |
||||
@RequestMapping("/oauth/callback/{source}") |
||||
public Object login(@PathVariable("source") String source, AuthCallback callback) { |
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
return authRequest.login(callback); |
||||
} |
||||
|
||||
/** |
||||
* 撤销授权 |
||||
*/ |
||||
@ApiOperation(value = "撤销授权") |
||||
@RequestMapping("/oauth/revoke/{source}/{token}") |
||||
public Object revokeAuth(@PathVariable("source") String source, @PathVariable("token") String token) { |
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
return authRequest.revoke(AuthToken.builder().accessToken(token).build()); |
||||
} |
||||
|
||||
/** |
||||
* 续期accessToken |
||||
*/ |
||||
@ApiOperation(value = "续期令牌") |
||||
@RequestMapping("/oauth/refresh/{source}") |
||||
public Object refreshAuth(@PathVariable("source") String source, String token) { |
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
return authRequest.refresh(AuthToken.builder().refreshToken(token).build()); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,44 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.enums; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* 用户类型枚举 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Getter |
||||
@AllArgsConstructor |
||||
public enum DafUserEnum { |
||||
|
||||
/** |
||||
* web |
||||
*/ |
||||
WEB("web", 1), |
||||
|
||||
/** |
||||
* app |
||||
*/ |
||||
APP("app", 2), |
||||
; |
||||
|
||||
final String name; |
||||
final int category; |
||||
|
||||
} |
@ -0,0 +1,76 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.granter; |
||||
|
||||
import com.dayu.daf.core.log.exception.ServiceException; |
||||
import com.dayu.daf.core.tool.utils.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.common.cache.CacheNames; |
||||
import org.energy.modules.auth.enums.DafUserEnum; |
||||
import org.energy.modules.auth.utils.TokenUtil; |
||||
import org.energy.modules.system.entity.UserInfo; |
||||
import org.energy.modules.system.service.IUserService; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
/** |
||||
* 验证码TokenGranter |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class CaptchaTokenGranter implements ITokenGranter { |
||||
|
||||
public static final String GRANT_TYPE = "captcha"; |
||||
|
||||
private IUserService userService; |
||||
private RedisUtil redisUtil; |
||||
|
||||
@Override |
||||
public UserInfo grant(TokenParameter tokenParameter) { |
||||
HttpServletRequest request = WebUtil.getRequest(); |
||||
|
||||
String key = request.getHeader(TokenUtil.CAPTCHA_HEADER_KEY); |
||||
String code = request.getHeader(TokenUtil.CAPTCHA_HEADER_CODE); |
||||
// 获取验证码
|
||||
String redisCode = String.valueOf(redisUtil.get(CacheNames.CAPTCHA_KEY + key)); |
||||
// 判断验证码
|
||||
if (code == null || !StringUtil.equalsIgnoreCase(redisCode, code)) { |
||||
throw new ServiceException(TokenUtil.CAPTCHA_NOT_CORRECT); |
||||
} |
||||
|
||||
String tenantId = tokenParameter.getArgs().getStr("tenantId"); |
||||
String account = tokenParameter.getArgs().getStr("account"); |
||||
String password = tokenParameter.getArgs().getStr("password"); |
||||
UserInfo userInfo = null; |
||||
if (Func.isNoneBlank(account, password)) { |
||||
// 获取用户类型
|
||||
String userType = tokenParameter.getArgs().getStr("userType"); |
||||
// 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
|
||||
if (userType.equals(DafUserEnum.WEB.getName())) { |
||||
userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); |
||||
} else if (userType.equals(DafUserEnum.APP.getName())) { |
||||
userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); |
||||
} else { |
||||
userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); |
||||
} |
||||
} |
||||
return userInfo; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,36 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.granter; |
||||
|
||||
|
||||
import org.energy.modules.system.entity.UserInfo; |
||||
|
||||
/** |
||||
* 授权认证统一接口. |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface ITokenGranter { |
||||
|
||||
/** |
||||
* 获取用户信息 |
||||
* |
||||
* @param tokenParameter 授权参数 |
||||
* @return UserInfo |
||||
*/ |
||||
UserInfo grant(TokenParameter tokenParameter); |
||||
|
||||
} |
@ -0,0 +1,60 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.granter; |
||||
|
||||
import com.dayu.daf.core.tool.utils.DigestUtil; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.modules.auth.enums.DafUserEnum; |
||||
import org.energy.modules.system.entity.UserInfo; |
||||
import org.energy.modules.system.service.IUserService; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* PasswordTokenGranter |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class PasswordTokenGranter implements ITokenGranter { |
||||
|
||||
public static final String GRANT_TYPE = "password"; |
||||
|
||||
private IUserService userService; |
||||
|
||||
@Override |
||||
public UserInfo grant(TokenParameter tokenParameter) { |
||||
String tenantId = tokenParameter.getArgs().getStr("tenantId"); |
||||
String account = tokenParameter.getArgs().getStr("account"); |
||||
String password = tokenParameter.getArgs().getStr("password"); |
||||
UserInfo userInfo = null; |
||||
if (Func.isNoneBlank(account, password)) { |
||||
// 获取用户类型
|
||||
String userType = tokenParameter.getArgs().getStr("userType"); |
||||
// 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
|
||||
if (userType.equals(DafUserEnum.WEB.getName())) { |
||||
userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); |
||||
} else if (userType.equals(DafUserEnum.APP.getName())) { |
||||
userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); |
||||
} else { |
||||
userInfo = userService.userInfo(tenantId, account, DigestUtil.encrypt(password)); |
||||
} |
||||
} |
||||
return userInfo; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,56 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.granter; |
||||
|
||||
import io.jsonwebtoken.Claims; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.modules.system.entity.UserInfo; |
||||
import org.energy.modules.system.service.IUserService; |
||||
import com.dayu.daf.core.launch.constant.TokenConstant; |
||||
import org.energy.core.secure.utils.SecureUtil; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* RefreshTokenGranter |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class RefreshTokenGranter implements ITokenGranter { |
||||
|
||||
public static final String GRANT_TYPE = "refresh_token"; |
||||
|
||||
private IUserService userService; |
||||
|
||||
@Override |
||||
public UserInfo grant(TokenParameter tokenParameter) { |
||||
String grantType = tokenParameter.getArgs().getStr("grantType"); |
||||
String refreshToken = tokenParameter.getArgs().getStr("refreshToken"); |
||||
UserInfo userInfo = null; |
||||
if (Func.isNoneBlank(grantType, refreshToken) && grantType.equals(TokenConstant.REFRESH_TOKEN)) { |
||||
Claims claims = SecureUtil.parseJWT(refreshToken); |
||||
String tokenType = Func.toStr(Objects.requireNonNull(claims).get(TokenConstant.TOKEN_TYPE)); |
||||
if (tokenType.equals(TokenConstant.REFRESH_TOKEN)) { |
||||
userInfo= userService.userInfo(Func.toLong(claims.get(TokenConstant.USER_ID))); |
||||
} |
||||
} |
||||
return userInfo; |
||||
} |
||||
} |
@ -0,0 +1,78 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.granter; |
||||
|
||||
import cn.hutool.core.bean.BeanUtil; |
||||
import cn.hutool.core.codec.Base64; |
||||
import cn.hutool.core.date.DateUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import cn.hutool.crypto.SecureUtil; |
||||
import cn.hutool.json.JSONUtil; |
||||
import com.dayu.daf.core.launch.constant.TokenConstant; |
||||
import com.dayu.daf.core.log.exception.ServiceException; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.modules.auth.properties.ScadaAuthProperties; |
||||
import org.energy.modules.auth.response.ShareAuthResponse; |
||||
import org.energy.modules.auth.utils.AesUtil; |
||||
import org.energy.modules.auth.utils.TokenUtil; |
||||
import org.energy.modules.system.entity.UserInfo; |
||||
import org.energy.modules.system.service.IUserService; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* ScadaTokenGranter |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class ScadaTokenGranter implements ITokenGranter { |
||||
|
||||
public static final String GRANT_TYPE = "scada"; |
||||
|
||||
private IUserService userService; |
||||
|
||||
@Resource |
||||
private ScadaAuthProperties properties; |
||||
|
||||
@Override |
||||
public UserInfo grant(TokenParameter tokenParameter) { |
||||
String token = tokenParameter.getArgs().getStr("token"); |
||||
String tenantId = tokenParameter.getArgs().getStr("tenantId"); |
||||
UserInfo userInfo = null; |
||||
if (Func.isNoneBlank(token)) { |
||||
byte[] tokenByte = Base64.decode(token); |
||||
String decrypt = AesUtil.decrypt(tokenByte, properties.getScadaKey(), properties.getScadaIv()); |
||||
if (StrUtil.isBlank(decrypt)) { |
||||
throw new ServiceException("授权错误"); |
||||
} |
||||
ShareAuthResponse response = BeanUtil.toBean(JSONUtil.parse(decrypt), ShareAuthResponse.class); |
||||
if (DateUtil.compare(new Date(), DateUtil.parseDate(response.getExpires())) > 0) { |
||||
throw new ServiceException("token过期,请重新登录。"); |
||||
} |
||||
String account = response.getUserName(); |
||||
userInfo = userService.userInfo(tenantId, account); |
||||
} else { |
||||
throw new ServiceException("token错误"); |
||||
} |
||||
return userInfo; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,89 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.granter; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import me.zhyd.oauth.model.AuthCallback; |
||||
import me.zhyd.oauth.model.AuthResponse; |
||||
import me.zhyd.oauth.model.AuthUser; |
||||
import me.zhyd.oauth.request.AuthRequest; |
||||
import org.energy.modules.auth.utils.TokenUtil; |
||||
import org.energy.modules.system.entity.UserInfo; |
||||
import org.energy.modules.system.entity.UserOauth; |
||||
import org.energy.modules.system.service.IUserService; |
||||
import com.dayu.daf.core.log.exception.ServiceException; |
||||
import com.dayu.daf.core.social.props.SocialProperties; |
||||
import com.dayu.daf.core.social.utils.SocialUtil; |
||||
import com.dayu.daf.core.tool.utils.BeanUtil; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import com.dayu.daf.core.tool.utils.WebUtil; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* SocialTokenGranter |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class SocialTokenGranter implements ITokenGranter { |
||||
|
||||
public static final String GRANT_TYPE = "social"; |
||||
|
||||
private static final Integer AUTH_SUCCESS_CODE = 2000; |
||||
|
||||
private final IUserService userService; |
||||
private final SocialProperties socialProperties; |
||||
|
||||
@Override |
||||
public UserInfo grant(TokenParameter tokenParameter) { |
||||
HttpServletRequest request = WebUtil.getRequest(); |
||||
String tenantId = Func.toStr(request.getHeader(TokenUtil.TENANT_HEADER_KEY), TokenUtil.DEFAULT_TENANT_ID); |
||||
// 开放平台来源
|
||||
String sourceParameter = request.getParameter("source"); |
||||
// 匹配是否有别名定义
|
||||
String source = socialProperties.getAlias().getOrDefault(sourceParameter, sourceParameter); |
||||
// 开放平台授权码
|
||||
String code = request.getParameter("code"); |
||||
// 开放平台状态吗
|
||||
String state = request.getParameter("state"); |
||||
|
||||
// 获取开放平台授权数据
|
||||
AuthRequest authRequest = SocialUtil.getAuthRequest(source, socialProperties); |
||||
AuthCallback authCallback = new AuthCallback(); |
||||
authCallback.setCode(code); |
||||
authCallback.setState(state); |
||||
AuthResponse authResponse = authRequest.login(authCallback); |
||||
AuthUser authUser; |
||||
if (authResponse.getCode() == AUTH_SUCCESS_CODE) { |
||||
authUser = (AuthUser) authResponse.getData(); |
||||
} else { |
||||
throw new ServiceException("social grant failure, auth response is not success"); |
||||
} |
||||
|
||||
// 组装数据
|
||||
UserOauth userOauth = Objects.requireNonNull(BeanUtil.copy(authUser, UserOauth.class)); |
||||
userOauth.setSource(authUser.getSource()); |
||||
userOauth.setTenantId(tenantId); |
||||
userOauth.setUuid(authUser.getUuid()); |
||||
// 返回UserInfo
|
||||
return userService.userInfo(userOauth); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,62 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.granter; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import com.dayu.daf.core.secure.exception.SecureException; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import com.dayu.daf.core.tool.utils.SpringUtil; |
||||
|
||||
import java.util.Map; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
/** |
||||
* TokenGranterBuilder |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@AllArgsConstructor |
||||
public class TokenGranterBuilder { |
||||
|
||||
/** |
||||
* TokenGranter缓存池 |
||||
*/ |
||||
private static final Map<String, ITokenGranter> GRANTER_POOL = new ConcurrentHashMap<>(); |
||||
|
||||
static { |
||||
GRANTER_POOL.put(PasswordTokenGranter.GRANT_TYPE, SpringUtil.getBean(PasswordTokenGranter.class)); |
||||
GRANTER_POOL.put(CaptchaTokenGranter.GRANT_TYPE, SpringUtil.getBean(CaptchaTokenGranter.class)); |
||||
GRANTER_POOL.put(RefreshTokenGranter.GRANT_TYPE, SpringUtil.getBean(RefreshTokenGranter.class)); |
||||
GRANTER_POOL.put(SocialTokenGranter.GRANT_TYPE, SpringUtil.getBean(SocialTokenGranter.class)); |
||||
GRANTER_POOL.put(ScadaTokenGranter.GRANT_TYPE, SpringUtil.getBean(ScadaTokenGranter.class)); |
||||
} |
||||
|
||||
/** |
||||
* 获取TokenGranter |
||||
* |
||||
* @param grantType 授权类型 |
||||
* @return ITokenGranter |
||||
*/ |
||||
public static ITokenGranter getGranter(String grantType) { |
||||
ITokenGranter tokenGranter = GRANTER_POOL.get(Func.toStr(grantType, PasswordTokenGranter.GRANT_TYPE)); |
||||
if (tokenGranter == null) { |
||||
throw new SecureException("no grantType was found"); |
||||
} else { |
||||
return tokenGranter; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,31 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.granter; |
||||
|
||||
import lombok.Data; |
||||
import com.dayu.daf.core.tool.support.Kv; |
||||
|
||||
/** |
||||
* TokenParameter |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
public class TokenParameter { |
||||
|
||||
private Kv args = Kv.init(); |
||||
|
||||
} |
@ -0,0 +1,25 @@ |
||||
package org.energy.modules.auth.properties; |
||||
|
||||
import lombok.Data; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* 配置类 |
||||
* |
||||
* @author dayu |
||||
*/ |
||||
@Component |
||||
@Data |
||||
public class ScadaAuthProperties { |
||||
@Value("${sso.scada.key}") |
||||
private String scadaKey; |
||||
|
||||
@Value("${sso.scada.iv}") |
||||
private String scadaIv; |
||||
|
||||
} |
@ -0,0 +1,38 @@ |
||||
package org.energy.modules.auth.response; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import lombok.ToString; |
||||
|
||||
/** |
||||
* 分享链接鉴权返回值 |
||||
* |
||||
* @author dayu |
||||
* @since 2024/7/2 16:54 |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
@ToString |
||||
public class ShareAuthResponse { |
||||
|
||||
/** |
||||
* 用户唯一凭证 |
||||
*/ |
||||
private String uid; |
||||
|
||||
/** |
||||
* 用户名称 |
||||
*/ |
||||
private String userName; |
||||
|
||||
/** |
||||
* 角色名称 |
||||
*/ |
||||
private String roleName; |
||||
|
||||
/** |
||||
* 有效期 |
||||
*/ |
||||
private String expires; |
||||
|
||||
} |
@ -0,0 +1,31 @@ |
||||
package org.energy.modules.auth.utils; |
||||
|
||||
import cn.hutool.crypto.Mode; |
||||
import cn.hutool.crypto.Padding; |
||||
import cn.hutool.crypto.symmetric.AES; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
/** |
||||
* Aes 加解密工具类 |
||||
* |
||||
* @author dayu |
||||
**/ |
||||
@Slf4j |
||||
public class AesUtil { |
||||
|
||||
/** |
||||
* 解密 |
||||
*/ |
||||
public static String decrypt(byte[] content, String key, String iv) { |
||||
AES aes = new AES(Mode.CBC, Padding.PKCS5Padding, key.getBytes()); |
||||
aes.setIv(iv.getBytes()); |
||||
try { |
||||
byte[] decryptedBytes = aes.decrypt(content); |
||||
return new String(decryptedBytes); |
||||
} catch (Exception e) { |
||||
log.warn("解密失败", e); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,102 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.auth.utils; |
||||
|
||||
import org.energy.modules.system.entity.User; |
||||
import org.energy.modules.system.entity.UserInfo; |
||||
import com.dayu.daf.core.launch.constant.TokenConstant; |
||||
import org.energy.core.secure.AuthInfo; |
||||
import com.dayu.daf.core.secure.TokenInfo; |
||||
import org.energy.core.secure.utils.SecureUtil; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 认证工具类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public class TokenUtil { |
||||
|
||||
public final static String CAPTCHA_HEADER_KEY = "Captcha-Key"; |
||||
public final static String CAPTCHA_HEADER_CODE = "Captcha-Code"; |
||||
public final static String CAPTCHA_NOT_CORRECT = "验证码不正确"; |
||||
public final static String TENANT_HEADER_KEY = "Tenant-Id"; |
||||
public final static String DEFAULT_TENANT_ID = "000000"; |
||||
public final static String USER_TYPE_HEADER_KEY = "User-Type"; |
||||
public final static String DEFAULT_USER_TYPE = "web"; |
||||
public final static String USER_NOT_FOUND = "用户名或密码错误"; |
||||
public final static String HEADER_KEY = "Authorization"; |
||||
public final static String HEADER_PREFIX = "Basic "; |
||||
public final static String DEFAULT_AVATAR = "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"; |
||||
public final static String SYSTEM_NOT_DATA = "未找到数据"; |
||||
|
||||
/** |
||||
* 创建认证token |
||||
* |
||||
* @param userInfo 用户信息 |
||||
* @return token |
||||
*/ |
||||
public static AuthInfo createAuthInfo(UserInfo userInfo) { |
||||
User user = userInfo.getUser(); |
||||
|
||||
//设置jwt参数
|
||||
Map<String, String> param = new HashMap<>(16); |
||||
param.put(TokenConstant.TOKEN_TYPE, TokenConstant.ACCESS_TOKEN); |
||||
param.put(TokenConstant.TENANT_ID, user.getTenantId()); |
||||
param.put(TokenConstant.OAUTH_ID, userInfo.getOauthId()); |
||||
param.put(TokenConstant.USER_ID, Func.toStr(user.getId())); |
||||
param.put(TokenConstant.ROLE_ID, user.getRoleId()); |
||||
param.put(TokenConstant.DEPT_ID, user.getDeptId()); |
||||
param.put(TokenConstant.ACCOUNT, user.getAccount()); |
||||
param.put(TokenConstant.USER_NAME, user.getAccount()); |
||||
param.put(TokenConstant.ROLE_NAME, Func.join(userInfo.getRoles())); |
||||
|
||||
TokenInfo accessToken = SecureUtil.createJWT(param, "audience", "issuser", TokenConstant.ACCESS_TOKEN); |
||||
AuthInfo authInfo = new AuthInfo(); |
||||
authInfo.setUserId(user.getId()); |
||||
authInfo.setTenantId(user.getTenantId()); |
||||
authInfo.setOauthId(userInfo.getOauthId()); |
||||
authInfo.setAccount(user.getAccount()); |
||||
authInfo.setUserName(user.getRealName()); |
||||
authInfo.setAuthority(Func.join(userInfo.getRoles())); |
||||
authInfo.setAccessToken(accessToken.getToken()); |
||||
authInfo.setExpiresIn(accessToken.getExpire()); |
||||
authInfo.setRefreshToken(createRefreshToken(userInfo).getToken()); |
||||
authInfo.setTokenType(TokenConstant.BEARER); |
||||
authInfo.setLicense(TokenConstant.LICENSE_NAME); |
||||
authInfo.setRoleMenus(userInfo.getRoleMenus()); |
||||
|
||||
return authInfo; |
||||
} |
||||
|
||||
/** |
||||
* 创建refreshToken |
||||
* |
||||
* @param userInfo 用户信息 |
||||
* @return refreshToken |
||||
*/ |
||||
private static TokenInfo createRefreshToken(UserInfo userInfo) { |
||||
User user = userInfo.getUser(); |
||||
Map<String, String> param = new HashMap<>(16); |
||||
param.put(TokenConstant.TOKEN_TYPE, TokenConstant.REFRESH_TOKEN); |
||||
param.put(TokenConstant.USER_ID, Func.toStr(user.getId())); |
||||
return SecureUtil.createJWT(param, "audience", "issuser", TokenConstant.REFRESH_TOKEN); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,60 @@ |
||||
package org.energy.modules.desk.controller; |
||||
|
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.support.Kv; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 首页 |
||||
* |
||||
* @author zhuangqian |
||||
*/ |
||||
@ApiIgnore |
||||
@RestController |
||||
@RequestMapping("/daf-desk/dashboard") |
||||
@AllArgsConstructor |
||||
@Api(value = "首页", tags = "首页") |
||||
public class DashBoardController { |
||||
|
||||
/** |
||||
* 活跃用户 |
||||
* |
||||
* @return |
||||
*/ |
||||
@GetMapping("/activities") |
||||
@ApiOperation(value = "活跃用户", notes = "活跃用户") |
||||
public R activities() { |
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>(); |
||||
Map<String, Object> map1 = new HashMap<>(16); |
||||
map1.put("id", "trend-1"); |
||||
map1.put("updatedAt", "2019-01-01"); |
||||
map1.put("user", Kv.init().set("name", "曲丽丽").set("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png")); |
||||
map1.put("group", Kv.init().set("name", "高逼格设计天团").set("link", "http://github.com/")); |
||||
map1.put("project", Kv.init().set("name", "六月迭代").set("link", "http://github.com/")); |
||||
map1.put("template", "在 @{group} 新建项目 @{project}"); |
||||
list.add(map1); |
||||
|
||||
Map<String, Object> map2 = new HashMap<>(16); |
||||
map2.put("id", "trend-2"); |
||||
map2.put("updatedAt", "2019-01-01"); |
||||
map2.put("user", Kv.init().set("name", "付小小").set("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png")); |
||||
map2.put("group", Kv.init().set("name", "高逼格设计天团").set("link", "http://github.com/")); |
||||
map2.put("project", Kv.init().set("name", "七月月迭代").set("link", "http://github.com/")); |
||||
map2.put("template", "在 @{group} 新建项目 @{project}"); |
||||
list.add(map2); |
||||
|
||||
return R.data(list); |
||||
} |
||||
} |
@ -0,0 +1,244 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.desk.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiSort; |
||||
import io.swagger.annotations.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.common.cache.CacheNames; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
import com.dayu.daf.core.mp.support.Condition; |
||||
import com.dayu.daf.core.mp.support.Query; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import org.energy.modules.desk.entity.Notice; |
||||
import org.energy.modules.desk.service.INoticeService; |
||||
import org.energy.modules.desk.vo.NoticeVO; |
||||
import org.energy.modules.desk.wrapper.NoticeWrapper; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/daf-desk/notice") |
||||
@AllArgsConstructor |
||||
@ApiSort(2) |
||||
@Api(value = "用户博客", tags = "博客接口") |
||||
public class NoticeController extends DafController implements CacheNames { |
||||
|
||||
private INoticeService noticeService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入notice") |
||||
public R<NoticeVO> detail(Notice notice) { |
||||
Notice detail = noticeService.getOne(Condition.getQueryWrapper(notice)); |
||||
return R.data(NoticeWrapper.build().entityVO(detail)); |
||||
} |
||||
|
||||
/** |
||||
* 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"), |
||||
@ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string") |
||||
}) |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入notice") |
||||
public R<IPage<NoticeVO>> list(@ApiIgnore @RequestParam Map<String, Object> notice, Query query) { |
||||
IPage<Notice> pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, Notice.class)); |
||||
return R.data(NoticeWrapper.build().pageVO(pages)); |
||||
} |
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "新增", notes = "传入notice") |
||||
public R save(@RequestBody Notice notice) { |
||||
return R.status(noticeService.save(notice)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "修改", notes = "传入notice") |
||||
public R update(@RequestBody Notice notice) { |
||||
return R.status(noticeService.updateById(notice)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "新增或修改", notes = "传入notice") |
||||
public R submit(@RequestBody Notice notice) { |
||||
return R.status(noticeService.saveOrUpdate(notice)); |
||||
} |
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入notice") |
||||
public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { |
||||
boolean temp = noticeService.deleteLogic(Func.toLongList(ids)); |
||||
return R.status(temp); |
||||
} |
||||
|
||||
/** |
||||
* 获取消息 |
||||
* |
||||
* @return |
||||
*/ |
||||
@GetMapping("/notices") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "消息", notes = "消息") |
||||
public R notices() { |
||||
List<Map<String, String>> list = new ArrayList<>(); |
||||
Map<String, String> map1 = new HashMap<>(16); |
||||
map1.put("logo", "https://spring.io/img/homepage/icon-spring-framework.svg"); |
||||
map1.put("title", "SpringBoot"); |
||||
map1.put("description", "现在的web项目几乎都会用到spring框架,而要使用spring难免需要配置大量的xml配置文件,而 springboot的出现解 决了这一问题,一个项目甚至不用部署到服务器上直接开跑,真像springboot所说:“just run”。"); |
||||
map1.put("member", "Chill"); |
||||
map1.put("href", "http://spring.io/projects/spring-boot"); |
||||
list.add(map1); |
||||
|
||||
Map<String, String> map2 = new HashMap<>(16); |
||||
map2.put("logo", "https://spring.io/img/homepage/icon-spring-cloud.svg"); |
||||
map2.put("title", "SpringCloud"); |
||||
map2.put("description", "SpringCloud是基于SpringBoot的一整套实现微服务的框架。他提供了微服务开发所需的配置管理、服务发现、断路器、智能路由、微代理、控制总线、全局锁、决策竞选、分布式会话和集群状态管理等组件。"); |
||||
map2.put("member", "Chill"); |
||||
map2.put("href", "http://spring.io/projects/spring-cloud"); |
||||
list.add(map2); |
||||
|
||||
Map<String, String> map3 = new HashMap<>(16); |
||||
map3.put("logo", "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1546359961068&di=05ff9406e6675ca9a58a525a7e7950b9&imgtype=jpg&src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D575314515%2C4268715674%26fm%3D214%26gp%3D0.jpg"); |
||||
map3.put("title", "Mybatis"); |
||||
map3.put("description", "MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息,将接口和 Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。"); |
||||
map3.put("member", "Chill"); |
||||
map3.put("href", "http://www.mybatis.org/mybatis-3/getting-started.html"); |
||||
list.add(map3); |
||||
|
||||
Map<String, String> map4 = new HashMap<>(16); |
||||
map4.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"); |
||||
map4.put("title", "React"); |
||||
map4.put("description", "React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设Instagram 的网站。做出来以后,发现这套东西很好用,就在2013年5月开源了。"); |
||||
map4.put("member", "Chill"); |
||||
map4.put("href", "https://reactjs.org/"); |
||||
list.add(map4); |
||||
|
||||
Map<String, String> map5 = new HashMap<>(16); |
||||
map5.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png"); |
||||
map5.put("title", "Ant Design"); |
||||
map5.put("description", "蚂蚁金服体验技术部经过大量的项目实践和总结,沉淀出设计语言 Ant Design,这可不单纯只是设计原则、控件规范和视觉尺寸,还配套有前端代码实现方案。也就是说采用Ant Design后,UI设计和前端界面研发可同步完成,效率大大提升。"); |
||||
map5.put("member", "Chill"); |
||||
map5.put("href", "https://ant.design/docs/spec/introduce-cn"); |
||||
list.add(map5); |
||||
|
||||
Map<String, String> map6 = new HashMap<>(16); |
||||
map6.put("logo", "https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png"); |
||||
map6.put("title", "Ant Design Pro"); |
||||
map6.put("description", "Ant Design Pro 是一个企业级开箱即用的中后台前端/设计解决方案。符合阿里追求的'敏捷的前端+强大的中台'的思想。"); |
||||
map6.put("member", "Chill"); |
||||
map6.put("href", "https://pro.ant.design"); |
||||
list.add(map6); |
||||
|
||||
return R.data(list); |
||||
} |
||||
|
||||
/** |
||||
* 获取我的消息 |
||||
* |
||||
* @return |
||||
*/ |
||||
@GetMapping("/my-notices") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "消息", notes = "消息") |
||||
public R myNotices() { |
||||
List<Map<String, String>> list = new ArrayList<>(); |
||||
Map<String, String> map1 = new HashMap<>(16); |
||||
map1.put("id", "000000001"); |
||||
map1.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png"); |
||||
map1.put("title", "你收到了 14 份新周报"); |
||||
map1.put("datetime", "2018-08-09"); |
||||
map1.put("type", "notification"); |
||||
list.add(map1); |
||||
|
||||
Map<String, String> map2 = new HashMap<>(16); |
||||
map2.put("id", "000000002"); |
||||
map2.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png"); |
||||
map2.put("title", "你推荐的 曲妮妮 已通过第三轮面试"); |
||||
map2.put("datetime", "2018-08-08"); |
||||
map2.put("type", "notification"); |
||||
list.add(map2); |
||||
|
||||
|
||||
Map<String, String> map3 = new HashMap<>(16); |
||||
map3.put("id", "000000003"); |
||||
map3.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg"); |
||||
map3.put("title", "曲丽丽 评论了你"); |
||||
map3.put("description", "描述信息描述信息描述信息"); |
||||
map3.put("datetime", "2018-08-07"); |
||||
map3.put("type", "message"); |
||||
map3.put("clickClose", "true"); |
||||
list.add(map3); |
||||
|
||||
|
||||
Map<String, String> map4 = new HashMap<>(16); |
||||
map4.put("id", "000000004"); |
||||
map4.put("avatar", "https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg"); |
||||
map4.put("title", "朱偏右 回复了你"); |
||||
map4.put("description", "这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像"); |
||||
map4.put("type", "message"); |
||||
map4.put("datetime", "2018-08-07"); |
||||
map4.put("clickClose", "true"); |
||||
list.add(map4); |
||||
|
||||
|
||||
Map<String, String> map5 = new HashMap<>(16); |
||||
map5.put("id", "000000005"); |
||||
map5.put("title", "任务名称"); |
||||
map5.put("description", "任务需要在 2018-01-12 20:00 前启动"); |
||||
map5.put("extra", "未开始"); |
||||
map5.put("status", "todo"); |
||||
map5.put("type", "event"); |
||||
list.add(map5); |
||||
|
||||
return R.data(list); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,75 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.desk.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import com.dayu.daf.core.mp.base.BaseEntity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@TableName("sys_notice") |
||||
public class Notice extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键id |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.ASSIGN_ID) |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 标题 |
||||
*/ |
||||
@ApiModelProperty(value = "标题") |
||||
private String title; |
||||
|
||||
/** |
||||
* 通知类型 |
||||
*/ |
||||
@ApiModelProperty(value = "通知类型") |
||||
private Integer category; |
||||
|
||||
/** |
||||
* 发布日期 |
||||
*/ |
||||
@ApiModelProperty(value = "发布日期") |
||||
private Date releaseTime; |
||||
|
||||
/** |
||||
* 内容 |
||||
*/ |
||||
@ApiModelProperty(value = "内容") |
||||
private String content; |
||||
|
||||
|
||||
} |
@ -0,0 +1,46 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.desk.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.desk.entity.Notice; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface NoticeMapper extends BaseMapper<Notice> { |
||||
|
||||
/** |
||||
* 前N条数据 |
||||
* @param number |
||||
* @return |
||||
*/ |
||||
List<Notice> topList(Integer number); |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* @param page |
||||
* @param notice |
||||
* @return |
||||
*/ |
||||
List<Notice> selectNoticePage(IPage page, Notice notice); |
||||
|
||||
} |
@ -0,0 +1,39 @@ |
||||
<?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="org.energy.modules.desk.mapper.NoticeMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="noticeResultMap" type="org.energy.modules.desk.entity.Notice"> |
||||
<result column="id" property="id"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="status" property="status"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="release_time" property="releaseTime"/> |
||||
<result column="title" property="title"/> |
||||
<result column="content" property="content"/> |
||||
</resultMap> |
||||
|
||||
<!-- 通用查询结果列 --> |
||||
<sql id="baseColumnList"> |
||||
select id, |
||||
create_user AS createUser, |
||||
create_time AS createTime, |
||||
update_user AS updateUser, |
||||
update_time AS updateTime, |
||||
status, |
||||
is_deleted AS isDeleted, |
||||
title, content |
||||
</sql> |
||||
|
||||
<select id="topList" resultMap="noticeResultMap"> |
||||
select * from sys_notice limit #{number} |
||||
</select> |
||||
|
||||
<select id="selectNoticePage" resultMap="noticeResultMap"> |
||||
select * from sys_notice where title like concat('%', #{notice.title}, '%') and is_deleted = 0 |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,37 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.desk.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import org.energy.modules.desk.entity.Notice; |
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface INoticeService extends BaseService<Notice> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* @param page |
||||
* @param notice |
||||
* @return |
||||
*/ |
||||
IPage<Notice> selectNoticePage(IPage<Notice> page, Notice notice); |
||||
|
||||
} |
@ -0,0 +1,38 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.desk.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.dayu.daf.core.mp.base.BaseServiceImpl; |
||||
import org.energy.modules.desk.entity.Notice; |
||||
import org.energy.modules.desk.mapper.NoticeMapper; |
||||
import org.energy.modules.desk.service.INoticeService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Service |
||||
public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> implements INoticeService { |
||||
|
||||
@Override |
||||
public IPage<Notice> selectNoticePage(IPage<Notice> page, Notice notice) { |
||||
return page.setRecords(baseMapper.selectNoticePage(page, notice)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,20 @@ |
||||
package org.energy.modules.desk.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.energy.modules.desk.entity.Notice; |
||||
|
||||
/** |
||||
* 通知公告视图类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class NoticeVO extends Notice { |
||||
|
||||
@ApiModelProperty(value = "通知类型名") |
||||
private String categoryName; |
||||
|
||||
} |
@ -0,0 +1,50 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.desk.wrapper; |
||||
|
||||
import org.energy.modules.system.service.IDictService; |
||||
import com.dayu.daf.core.mp.support.DafEntityWrapper; |
||||
import com.dayu.daf.core.tool.utils.BeanUtil; |
||||
import com.dayu.daf.core.tool.utils.SpringUtil; |
||||
import org.energy.modules.desk.entity.Notice; |
||||
import org.energy.modules.desk.vo.NoticeVO; |
||||
|
||||
/** |
||||
* Notice包装类,返回视图层所需的字段 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public class NoticeWrapper extends DafEntityWrapper<Notice, NoticeVO> { |
||||
|
||||
private static IDictService dictService; |
||||
|
||||
static { |
||||
dictService = SpringUtil.getBean(IDictService.class); |
||||
} |
||||
|
||||
public static NoticeWrapper build() { |
||||
return new NoticeWrapper(); |
||||
} |
||||
|
||||
@Override |
||||
public NoticeVO entityVO(Notice notice) { |
||||
NoticeVO noticeVO = BeanUtil.copy(notice, NoticeVO.class); |
||||
String categoryName = dictService.getValue("notice", noticeVO.getCategory()); |
||||
noticeVO.setCategoryName(categoryName); |
||||
return noticeVO; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,154 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.*; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.modules.develop.service.ICodeService; |
||||
import org.energy.modules.develop.service.IDatasourceService; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
import com.dayu.daf.core.launch.constant.AppConstant; |
||||
import com.dayu.daf.core.mp.support.Condition; |
||||
import com.dayu.daf.core.mp.support.Query; |
||||
import com.dayu.daf.core.secure.annotation.PreAuth; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.constant.RoleConstant; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import com.dayu.daf.core.develop.support.DafCodeGenerator; |
||||
import org.energy.modules.develop.entity.Code; |
||||
import org.energy.modules.develop.entity.Datasource; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.Collection; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@ApiIgnore |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/code") |
||||
@Api(value = "代码生成", tags = "代码生成") |
||||
//@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
|
||||
public class CodeController extends DafController { |
||||
|
||||
private ICodeService codeService; |
||||
private IDatasourceService datasourceService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入code") |
||||
public R<Code> detail(Code code) { |
||||
Code detail = codeService.getOne(Condition.getQueryWrapper(code)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam(name = "codeName", value = "模块名", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "tableName", value = "表名", paramType = "query", dataType = "string"), |
||||
@ApiImplicitParam(name = "modelName", value = "实体名", paramType = "query", dataType = "string") |
||||
}) |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入code") |
||||
public R<IPage<Code>> list(@ApiIgnore @RequestParam Map<String, Object> code, Query query) { |
||||
IPage<Code> pages = codeService.page(Condition.getPage(query), Condition.getQueryWrapper(code, Code.class)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "新增或修改", notes = "传入code") |
||||
public R submit(@Valid @RequestBody Code code) { |
||||
return R.status(codeService.submit(code)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(codeService.removeByIds(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 复制 |
||||
*/ |
||||
@PostMapping("/copy") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "复制", notes = "传入id") |
||||
public R copy(@ApiParam(value = "主键", required = true) @RequestParam Long id) { |
||||
Code code = codeService.getById(id); |
||||
code.setId(null); |
||||
code.setCodeName(code.getCodeName() + "-copy"); |
||||
return R.status(codeService.save(code)); |
||||
} |
||||
|
||||
/** |
||||
* 代码生成 |
||||
*/ |
||||
@PostMapping("/gen-code") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "代码生成", notes = "传入ids") |
||||
public R genCode(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @RequestParam(defaultValue = "sword") String system) { |
||||
Collection<Code> codes = codeService.listByIds(Func.toLongList(ids)); |
||||
codes.forEach(code -> { |
||||
DafCodeGenerator generator = new DafCodeGenerator(); |
||||
// 设置数据源
|
||||
Datasource datasource = datasourceService.getById(code.getDatasourceId()); |
||||
generator.setDriverName(datasource.getDriverClass()); |
||||
generator.setUrl(datasource.getUrl()); |
||||
generator.setUsername(datasource.getUsername()); |
||||
generator.setPassword(datasource.getPassword()); |
||||
// 设置基础配置
|
||||
generator.setSystemName(system); |
||||
generator.setServiceName(code.getServiceName()); |
||||
generator.setPackageName(code.getPackageName()); |
||||
generator.setPackageDir(code.getApiPath()); |
||||
generator.setPackageWebDir(code.getWebPath()); |
||||
generator.setTablePrefix(Func.toStrArray(code.getTablePrefix())); |
||||
generator.setIncludeTables(Func.toStrArray(code.getTableName())); |
||||
// 设置是否继承基础业务字段
|
||||
generator.setHasSuperEntity(code.getBaseMode() == 2); |
||||
// 控制器添加服务名前缀
|
||||
generator.setHasServiceName(Boolean.TRUE); |
||||
// 设置是否开启包装器模式
|
||||
generator.setHasWrapper(code.getWrapMode() == 2); |
||||
generator.run(); |
||||
}); |
||||
return R.success("代码生成成功"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,126 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.energy.modules.develop.service.IDatasourceService; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
import com.dayu.daf.core.launch.constant.AppConstant; |
||||
import com.dayu.daf.core.mp.support.Condition; |
||||
import com.dayu.daf.core.mp.support.Query; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import org.energy.modules.develop.entity.Datasource; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 数据源配置表 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(AppConstant.APPLICATION_DEVELOP_NAME + "/datasource") |
||||
@Api(value = "数据源配置表", tags = "数据源配置表接口") |
||||
public class DatasourceController extends DafController { |
||||
|
||||
private IDatasourceService datasourceService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入datasource") |
||||
public R<Datasource> detail(Datasource datasource) { |
||||
Datasource detail = datasourceService.getOne(Condition.getQueryWrapper(datasource)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 数据源配置表 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入datasource") |
||||
public R<IPage<Datasource>> list(Datasource datasource, Query query) { |
||||
IPage<Datasource> pages = datasourceService.page(Condition.getPage(query), Condition.getQueryWrapper(datasource)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 数据源配置表 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入datasource") |
||||
public R save(@Valid @RequestBody Datasource datasource) { |
||||
return R.status(datasourceService.save(datasource)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 数据源配置表 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入datasource") |
||||
public R update(@Valid @RequestBody Datasource datasource) { |
||||
return R.status(datasourceService.updateById(datasource)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 数据源配置表 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入datasource") |
||||
public R submit(@Valid @RequestBody Datasource datasource) { |
||||
datasource.setUrl(datasource.getUrl().replace("&", "&")); |
||||
return R.status(datasourceService.saveOrUpdate(datasource)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 数据源配置表 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(datasourceService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 数据源列表 |
||||
*/ |
||||
@GetMapping("/select") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "下拉数据源", notes = "查询列表") |
||||
public R<List<Datasource>> select() { |
||||
List<Datasource> list = datasourceService.list(); |
||||
return R.data(list); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,125 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("sys_code") |
||||
@ApiModel(value = "Code对象", description = "Code对象") |
||||
public class Code implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.ASSIGN_ID) |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 数据源主键 |
||||
*/ |
||||
@ApiModelProperty(value = "数据源主键") |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long datasourceId; |
||||
|
||||
/** |
||||
* 模块名称 |
||||
*/ |
||||
@ApiModelProperty(value = "服务名称") |
||||
private String serviceName; |
||||
|
||||
/** |
||||
* 模块名称 |
||||
*/ |
||||
@ApiModelProperty(value = "模块名称") |
||||
private String codeName; |
||||
|
||||
/** |
||||
* 表名 |
||||
*/ |
||||
@ApiModelProperty(value = "表名") |
||||
private String tableName; |
||||
|
||||
/** |
||||
* 实体名 |
||||
*/ |
||||
@ApiModelProperty(value = "表前缀") |
||||
private String tablePrefix; |
||||
|
||||
/** |
||||
* 主键名 |
||||
*/ |
||||
@ApiModelProperty(value = "主键名") |
||||
private String pkName; |
||||
|
||||
/** |
||||
* 基础业务模式 |
||||
*/ |
||||
@ApiModelProperty(value = "基础业务模式") |
||||
private Integer baseMode; |
||||
|
||||
/** |
||||
* 包装器模式 |
||||
*/ |
||||
@ApiModelProperty(value = "包装器模式") |
||||
private Integer wrapMode; |
||||
|
||||
/** |
||||
* 后端包名 |
||||
*/ |
||||
@ApiModelProperty(value = "后端包名") |
||||
private String packageName; |
||||
|
||||
/** |
||||
* 后端路径 |
||||
*/ |
||||
@ApiModelProperty(value = "后端路径") |
||||
private String apiPath; |
||||
|
||||
/** |
||||
* 前端路径 |
||||
*/ |
||||
@ApiModelProperty(value = "前端路径") |
||||
private String webPath; |
||||
|
||||
/** |
||||
* 是否已删除 |
||||
*/ |
||||
@TableLogic |
||||
@ApiModelProperty(value = "是否已删除") |
||||
private Integer isDeleted; |
||||
|
||||
|
||||
} |
@ -0,0 +1,82 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import com.dayu.daf.core.mp.base.BaseEntity; |
||||
|
||||
/** |
||||
* 数据源配置表实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("sys_datasource") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "Datasource对象", description = "数据源配置表") |
||||
public class Datasource extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.ASSIGN_ID) |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 名称 |
||||
*/ |
||||
@ApiModelProperty(value = "名称") |
||||
private String name; |
||||
/** |
||||
* 驱动类 |
||||
*/ |
||||
@ApiModelProperty(value = "驱动类") |
||||
private String driverClass; |
||||
/** |
||||
* 连接地址 |
||||
*/ |
||||
@ApiModelProperty(value = "连接地址") |
||||
private String url; |
||||
/** |
||||
* 用户名 |
||||
*/ |
||||
@ApiModelProperty(value = "用户名") |
||||
private String username; |
||||
/** |
||||
* 密码 |
||||
*/ |
||||
@ApiModelProperty(value = "密码") |
||||
private String password; |
||||
/** |
||||
* 备注 |
||||
*/ |
||||
@ApiModelProperty(value = "备注") |
||||
private String remark; |
||||
|
||||
|
||||
} |
@ -0,0 +1,28 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.energy.modules.develop.entity.Code; |
||||
|
||||
/** |
||||
* Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface CodeMapper extends BaseMapper<Code> { |
||||
|
||||
} |
@ -0,0 +1,22 @@ |
||||
<?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="org.energy.modules.develop.mapper.CodeMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="codeResultMap" type="org.energy.modules.develop.entity.Code"> |
||||
<id column="id" property="id"/> |
||||
<result column="datasource_id" property="datasourceId"/> |
||||
<result column="service_name" property="serviceName"/> |
||||
<result column="code_name" property="codeName"/> |
||||
<result column="table_name" property="tableName"/> |
||||
<result column="pk_name" property="pkName"/> |
||||
<result column="base_mode" property="baseMode"/> |
||||
<result column="wrap_mode" property="wrapMode"/> |
||||
<result column="table_prefix" property="tablePrefix"/> |
||||
<result column="package_name" property="packageName"/> |
||||
<result column="api_path" property="apiPath"/> |
||||
<result column="web_path" property="webPath"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
</resultMap> |
||||
|
||||
</mapper> |
@ -0,0 +1,28 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.energy.modules.develop.entity.Datasource; |
||||
|
||||
/** |
||||
* 数据源配置表 Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface DatasourceMapper extends BaseMapper<Datasource> { |
||||
|
||||
} |
@ -0,0 +1,22 @@ |
||||
<?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="org.energy.modules.develop.mapper.DatasourceMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="datasourceResultMap" type="org.energy.modules.develop.entity.Datasource"> |
||||
<result column="id" property="id"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="create_dept" property="createDept"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="status" property="status"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="driver_class" property="driverClass"/> |
||||
<result column="url" property="url"/> |
||||
<result column="username" property="username"/> |
||||
<result column="password" property="password"/> |
||||
<result column="remark" property="remark"/> |
||||
</resultMap> |
||||
|
||||
</mapper> |
@ -0,0 +1,37 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.service; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import org.energy.modules.develop.entity.Code; |
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface ICodeService extends IService<Code> { |
||||
|
||||
/** |
||||
* 提交 |
||||
* |
||||
* @param code |
||||
* @return |
||||
*/ |
||||
boolean submit(Code code); |
||||
|
||||
} |
@ -0,0 +1,28 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.service; |
||||
|
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import org.energy.modules.develop.entity.Datasource; |
||||
|
||||
/** |
||||
* 数据源配置表 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface IDatasourceService extends BaseService<Datasource> { |
||||
|
||||
} |
@ -0,0 +1,39 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.dayu.daf.core.tool.constant.DafConstant; |
||||
import org.energy.modules.develop.entity.Code; |
||||
import org.energy.modules.develop.mapper.CodeMapper; |
||||
import org.energy.modules.develop.service.ICodeService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Service |
||||
public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements ICodeService { |
||||
|
||||
@Override |
||||
public boolean submit(Code code) { |
||||
code.setIsDeleted(DafConstant.DB_NOT_DELETED); |
||||
return saveOrUpdate(code); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,32 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.develop.service.impl; |
||||
|
||||
import com.dayu.daf.core.mp.base.BaseServiceImpl; |
||||
import org.energy.modules.develop.entity.Datasource; |
||||
import org.energy.modules.develop.mapper.DatasourceMapper; |
||||
import org.energy.modules.develop.service.IDatasourceService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 数据源配置表 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Service |
||||
public class DatasourceServiceImpl extends BaseServiceImpl<DatasourceMapper, Datasource> implements IDatasourceService { |
||||
|
||||
} |
@ -0,0 +1,250 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.inspection.controller; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.dayu.daf.core.log.annotation.ApiLog; |
||||
import com.dayu.daf.core.tool.constant.DafConstant; |
||||
import com.xkcoding.http.util.StringUtil; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import lombok.AllArgsConstructor; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.validation.Valid; |
||||
|
||||
import com.dayu.daf.core.mp.support.Condition; |
||||
import com.dayu.daf.core.mp.support.Query; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import lombok.SneakyThrows; |
||||
import org.apache.commons.codec.Charsets; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.excel.InspectionObjectExcel; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.leger.excel.EquipmentLedgerExcel; |
||||
import org.energy.modules.leger.vo.EquipmentLedgerVO; |
||||
import org.energy.modules.system.util.DataUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.inspection.entity.InspectionObject; |
||||
import org.energy.modules.inspection.vo.InspectionObjectVO; |
||||
import org.energy.modules.inspection.service.IInspectionObjectService; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.net.URLEncoder; |
||||
import java.time.LocalDate; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 巡检对象一览 控制器 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-11 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/inspection/inspectionobject") |
||||
@Api(value = "巡检对象一览", tags = "巡检对象一览接口") |
||||
public class InspectionObjectController extends DafController { |
||||
|
||||
private IInspectionObjectService inspectionObjectService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入inspectionObject") |
||||
public R<InspectionObject> detail(InspectionObject inspectionObject) { |
||||
InspectionObject detail = inspectionObjectService.getOne(Condition.getQueryWrapper(inspectionObject)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 巡检对象一览 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionObject") |
||||
public R<IPage<InspectionObject>> list(InspectionObject inspectionObject, Query query) { |
||||
QueryWrapper<InspectionObject> qw = new QueryWrapper<>(); |
||||
qw.orderByAsc("object_No"); |
||||
if (StringUtil.isNotEmpty(inspectionObject.getObjectNo())) { |
||||
qw.lambda().like(InspectionObject::getObjectNo, inspectionObject.getObjectNo()); |
||||
} |
||||
if (StringUtil.isNotEmpty(inspectionObject.getObjectName())) { |
||||
qw.lambda().like(InspectionObject::getObjectName, inspectionObject.getObjectName()); |
||||
} |
||||
if (null != inspectionObject.getStation()) { |
||||
qw.lambda().eq(InspectionObject::getStation, inspectionObject.getStation()); |
||||
} |
||||
if (null != inspectionObject.getIstatus()) { |
||||
qw.lambda().eq(InspectionObject::getIstatus, inspectionObject.getIstatus()); |
||||
} |
||||
if (StringUtil.isNotEmpty(inspectionObject.getObjectArea())){ |
||||
qw.lambda().like(InspectionObject::getObjectArea, inspectionObject.getObjectArea()); |
||||
} |
||||
IPage<InspectionObject> pages = inspectionObjectService.page(Condition.getPage(query), qw); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 巡检对象一览 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionObject") |
||||
public R<IPage<InspectionObjectVO>> page(InspectionObjectVO inspectionObject, Query query) { |
||||
IPage<InspectionObjectVO> pages = inspectionObjectService.selectInspectionObjectPage(Condition.getPage(query), inspectionObject); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 巡检对象一览 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入inspectionObject") |
||||
public R save(@Valid @RequestBody InspectionObject inspectionObject) { |
||||
return R.status(inspectionObjectService.save(inspectionObject)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 巡检对象一览 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入inspectionObject") |
||||
public R update(@Valid @RequestBody InspectionObject inspectionObject) { |
||||
return R.status(inspectionObjectService.updateById(inspectionObject)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 巡检对象一览 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入inspectionObject") |
||||
public R submit(@Valid @RequestBody InspectionObject inspectionObject) { |
||||
inspectionObject.setIstatus(1); |
||||
String date = LocalDate.now().toString().replace("-",""); |
||||
String maxNo = inspectionObjectService.getMaxNo("'%" + date + "%'"); |
||||
int number; |
||||
if (StringUtil.isNotEmpty(maxNo)){ |
||||
number = Integer.parseInt(maxNo.substring(9)); |
||||
number++; |
||||
}else{ |
||||
number = 1; |
||||
} |
||||
String numFormat = String.format("%04d", number); |
||||
String no = "D" + date + numFormat; |
||||
inspectionObject.setObjectNo(no); |
||||
return R.status(inspectionObjectService.saveOrUpdate(inspectionObject)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 巡检对象一览 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(inspectionObjectService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
/** |
||||
* 生效 |
||||
*/ |
||||
@PostMapping("/takeEffect") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "生效", notes = "传入ids") |
||||
public R takeEffect(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return this.updateInspectionObject(1, "", ids); |
||||
} |
||||
|
||||
/** |
||||
* 失效 |
||||
*/ |
||||
@PostMapping("/lapse") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiOperation(value = "失效", notes = "传入ids") |
||||
public R lapse(@ApiParam(value = "主键集合", required = true) @RequestParam String ids,@ApiParam(value = "取消原因", required = true) @RequestParam String reason) { |
||||
return this.updateInspectionObject(0, reason, ids); |
||||
} |
||||
|
||||
/** |
||||
* 生效OR失效 |
||||
*/ |
||||
public R updateInspectionObject(Integer status, String reason, String ids) { |
||||
List<InspectionObject> list = new ArrayList<>(); |
||||
for (String id : ids.split(",")) { |
||||
InspectionObject inspectionObject = new InspectionObject(); |
||||
inspectionObject.setId(Long.parseLong(id)); |
||||
inspectionObject.setCancelReason(reason); |
||||
inspectionObject.setIstatus(status); |
||||
list.add(inspectionObject); |
||||
} |
||||
return R.status(inspectionObjectService.updateBatchById(list)); |
||||
} |
||||
|
||||
/** |
||||
* 导出 |
||||
*/ |
||||
@SneakyThrows |
||||
@GetMapping("export") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiOperation(value = "导出", notes = "传入") |
||||
@ApiLog |
||||
public void exportInspectionObject(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) { |
||||
InspectionObjectVO vo = DataUtils.mapToEntity(entity, InspectionObjectVO::new); |
||||
List<InspectionObjectExcel> list = inspectionObjectService.export(vo); |
||||
response.setContentType("application/vnd.ms-excel"); |
||||
response.setCharacterEncoding(Charsets.UTF_8.name()); |
||||
String fileName = URLEncoder.encode("巡检对象数据导出", Charsets.UTF_8.name()); |
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
||||
EasyExcel.write(response.getOutputStream(), InspectionObjectExcel.class).sheet("巡检对象").doWrite(list); |
||||
} |
||||
|
||||
/** |
||||
* 获取对象编号 |
||||
*/ |
||||
@GetMapping("/getObjectList") |
||||
@ApiOperationSupport(order = 11) |
||||
@ApiOperation(value = "获取对象编号", notes = "获取对象编号") |
||||
public R<List<InspectionObject>> getObjectNoList() { |
||||
List<InspectionObject> routeList = inspectionObjectService.getObjectList(); |
||||
return R.data(routeList); |
||||
} |
||||
|
||||
/** |
||||
* 获取对象编号 |
||||
*/ |
||||
@GetMapping("/getDetailList") |
||||
@ApiOperationSupport(order = 12) |
||||
@ApiOperation(value = "获取对象信息", notes = "获取对象信息") |
||||
public R<InspectionObject> getDetailList(String objectNo) { |
||||
InspectionObject DetailList = inspectionObjectService.getDetailList("'" + objectNo + "'"); |
||||
return R.data(DetailList); |
||||
} |
||||
} |
@ -0,0 +1,246 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.inspection.controller; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.dayu.daf.core.log.annotation.ApiLog; |
||||
import com.xkcoding.http.util.StringUtil; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import lombok.AllArgsConstructor; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.validation.Valid; |
||||
|
||||
import com.dayu.daf.core.mp.support.Condition; |
||||
import com.dayu.daf.core.mp.support.Query; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import lombok.SneakyThrows; |
||||
import org.apache.commons.codec.Charsets; |
||||
import org.energy.modules.inspection.excel.InspectionPlanExcel; |
||||
import org.energy.modules.system.util.DataUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.inspection.entity.InspectionPlan; |
||||
import org.energy.modules.inspection.vo.InspectionPlanVO; |
||||
import org.energy.modules.inspection.service.IInspectionPlanService; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.net.URLEncoder; |
||||
import java.time.LocalDate; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 巡检计划 控制器 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/inspection/inspectionplan") |
||||
@Api(value = "巡检计划", tags = "巡检计划接口") |
||||
public class InspectionPlanController extends DafController { |
||||
|
||||
private IInspectionPlanService inspectionPlanService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入inspectionPlan") |
||||
public R<InspectionPlan> detail(InspectionPlan inspectionPlan) { |
||||
InspectionPlan detail = inspectionPlanService.getOne(Condition.getQueryWrapper(inspectionPlan)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 巡检计划 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionPlan") |
||||
public R<IPage<InspectionPlan>> list(InspectionPlan inspectionPlan, Query query) { |
||||
QueryWrapper<InspectionPlan> qw = new QueryWrapper<>(); |
||||
qw.orderByAsc("plan_no"); |
||||
if (StringUtil.isNotEmpty(inspectionPlan.getPlanNo())) { |
||||
qw.lambda().like(InspectionPlan::getPlanNo, inspectionPlan.getPlanNo()); |
||||
} |
||||
if (StringUtil.isNotEmpty(inspectionPlan.getPlanName())) { |
||||
qw.lambda().like(InspectionPlan::getPlanName, inspectionPlan.getPlanName()); |
||||
} |
||||
if (StringUtil.isNotEmpty(inspectionPlan.getPeriodType())) { |
||||
qw.lambda().like(InspectionPlan::getPeriodType, inspectionPlan.getPeriodType()); |
||||
} |
||||
if (null != inspectionPlan.getPlanStatus()) { |
||||
qw.lambda().eq(InspectionPlan::getPlanStatus, inspectionPlan.getPlanStatus()); |
||||
} |
||||
IPage<InspectionPlan> pages = inspectionPlanService.page(Condition.getPage(query), qw); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 巡检计划 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionPlan") |
||||
public R<IPage<InspectionPlanVO>> page(InspectionPlanVO inspectionPlan, Query query) { |
||||
IPage<InspectionPlanVO> pages = inspectionPlanService.selectInspectionPlanPage(Condition.getPage(query), inspectionPlan); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 巡检计划 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入inspectionPlan") |
||||
public R save(@Valid @RequestBody InspectionPlan inspectionPlan) { |
||||
return R.status(inspectionPlanService.save(inspectionPlan)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 巡检计划 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入inspectionPlan") |
||||
public R update(@Valid @RequestBody InspectionPlan inspectionPlan) { |
||||
return R.status(inspectionPlanService.updateById(inspectionPlan)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 巡检计划 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入inspectionPlan") |
||||
public R submit(@Valid @RequestBody InspectionPlan inspectionPlan) { |
||||
inspectionPlan.setPlanStatus(1); |
||||
String date = LocalDate.now().toString().replace("-",""); |
||||
String maxNo = inspectionPlanService.getMaxNo(date); |
||||
int number; |
||||
if (StringUtil.isNotEmpty(maxNo)){ |
||||
number = Integer.parseInt(maxNo.substring(9)); |
||||
number++; |
||||
}else{ |
||||
number = 1; |
||||
} |
||||
String numFormat = String.format("%04d", number); |
||||
String no = "J" + date + numFormat; |
||||
inspectionPlan.setPlanNo(no); |
||||
return R.status(inspectionPlanService.saveOrUpdate(inspectionPlan)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 巡检计划 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(inspectionPlanService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 生效 |
||||
*/ |
||||
@PostMapping("/takeEffect") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "生效", notes = "传入ids") |
||||
public R takeEffect(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return this.updateInspectionPlan(1, "", ids); |
||||
} |
||||
|
||||
/** |
||||
* 失效 |
||||
*/ |
||||
@PostMapping("/lapse") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiOperation(value = "失效", notes = "传入ids") |
||||
public R lapse(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @ApiParam(value = "取消原因", required = true) @RequestParam String reason) { |
||||
return this.updateInspectionPlan(0, reason, ids); |
||||
} |
||||
|
||||
/** |
||||
* 生效OR失效 |
||||
*/ |
||||
public R updateInspectionPlan(Integer status, String reason, String ids) { |
||||
List<InspectionPlan> list = new ArrayList<>(); |
||||
for (String id : ids.split(",")) { |
||||
InspectionPlan inspectionPlan = new InspectionPlan(); |
||||
inspectionPlan.setId(Long.parseLong(id)); |
||||
inspectionPlan.setCancelReason(reason); |
||||
inspectionPlan.setPlanStatus(status); |
||||
list.add(inspectionPlan); |
||||
} |
||||
return R.status(inspectionPlanService.updateBatchById(list)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 导出 |
||||
*/ |
||||
@SneakyThrows |
||||
@GetMapping("export") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiOperation(value = "导出", notes = "传入") |
||||
@ApiLog |
||||
public void exportInspectionRoute(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) { |
||||
entity.remove("daf-auth"); |
||||
InspectionPlan vo = DataUtils.mapToEntity(entity, InspectionPlan::new); |
||||
List<InspectionPlanExcel> list = inspectionPlanService.export(vo); |
||||
response.setContentType("application/vnd.ms-excel"); |
||||
response.setCharacterEncoding(Charsets.UTF_8.name()); |
||||
String fileName = URLEncoder.encode("巡检计划数据导出", Charsets.UTF_8.name()); |
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
||||
EasyExcel.write(response.getOutputStream(), InspectionPlanExcel.class).sheet("巡检计划").doWrite(list); |
||||
} |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
@GetMapping("/getPlanList") |
||||
@ApiOperationSupport(order = 11) |
||||
@ApiOperation(value = "获取路线编号", notes = "获取路线编号") |
||||
public R<List<InspectionPlan>> getPlanList() { |
||||
List<InspectionPlan> routeList = inspectionPlanService.getPlanList(); |
||||
return R.data(routeList); |
||||
} |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
@GetMapping("/getDetail") |
||||
@ApiOperationSupport(order = 12) |
||||
@ApiOperation(value = "获取路线信息", notes = "获取路线信息") |
||||
public R<InspectionPlan> getDetail(String planNo) { |
||||
InspectionPlan detail = inspectionPlanService.getDetail(planNo); |
||||
return R.data(detail); |
||||
} |
||||
} |
@ -0,0 +1,151 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.inspection.controller; |
||||
|
||||
import com.xkcoding.http.util.StringUtil; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import lombok.AllArgsConstructor; |
||||
import javax.validation.Valid; |
||||
|
||||
import com.dayu.daf.core.mp.support.Condition; |
||||
import com.dayu.daf.core.mp.support.Query; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import org.energy.modules.inspection.entity.InspectionTasks; |
||||
import org.energy.modules.leger.entity.InventoryDocument; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.inspection.entity.InspectionResult; |
||||
import org.energy.modules.inspection.vo.InspectionResultVO; |
||||
import org.energy.modules.inspection.service.IInspectionResultService; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检结果 控制器 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/inspection/inspectionresult") |
||||
@Api(value = "巡检结果", tags = "巡检结果接口") |
||||
public class InspectionResultController extends DafController { |
||||
|
||||
private IInspectionResultService inspectionResultService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入inspectionResult") |
||||
public R<InspectionResult> detail(InspectionResult inspectionResult) { |
||||
InspectionResult detail = inspectionResultService.getOne(Condition.getQueryWrapper(inspectionResult)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 巡检结果 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionResult") |
||||
public R<IPage<InspectionResult>> list(InspectionResult inspectionResult, Query query) { |
||||
IPage<InspectionResult> pages = inspectionResultService.page(Condition.getPage(query), Condition.getQueryWrapper(inspectionResult)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 巡检结果 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionResult") |
||||
public R<IPage<InspectionResultVO>> page(InspectionResultVO inspectionResult, Query query) { |
||||
IPage<InspectionResultVO> pages = inspectionResultService.selectInspectionResultPage(Condition.getPage(query), inspectionResult); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 巡检结果 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入inspectionResult") |
||||
public R save(@Valid @RequestBody InspectionResult inspectionResult) { |
||||
return R.status(inspectionResultService.save(inspectionResult)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 巡检结果 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入inspectionResult") |
||||
public R update(@Valid @RequestBody InspectionResult inspectionResult) { |
||||
return R.status(inspectionResultService.updateById(inspectionResult)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 巡检结果 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入inspectionResult") |
||||
public R submit(@Valid @RequestBody InspectionResult inspectionResult) { |
||||
String maxResultNo = inspectionResultService.getMaxResultNo("'%" + inspectionResult.getTaskNo() + "%'"); |
||||
int number; |
||||
if (StringUtil.isNotEmpty(maxResultNo)){ |
||||
number = Integer.parseInt(maxResultNo.substring(13)); |
||||
number++; |
||||
}else{ |
||||
number = 1; |
||||
} |
||||
String numFormat = String.format("%04d", number); |
||||
String resultNo = inspectionResult.getTaskNo() + numFormat; |
||||
inspectionResult.setResultNo(resultNo); |
||||
return R.status(inspectionResultService.saveOrUpdate(inspectionResult)); |
||||
} |
||||
|
||||
/** |
||||
* 删除 巡检结果 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(inspectionResultService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 列表 技术参数一览 |
||||
*/ |
||||
@GetMapping("/getList") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "列表", notes = "传入inventoryDocument") |
||||
public R<List<InspectionResult>> getList(InspectionResult inspectionResult) { |
||||
List<InspectionResult> list = inspectionResultService.list(Condition.getQueryWrapper(inspectionResult)); |
||||
return R.data(list); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,248 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.inspection.controller; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.dayu.daf.core.log.annotation.ApiLog; |
||||
import com.xkcoding.http.util.StringUtil; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import lombok.AllArgsConstructor; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.validation.Valid; |
||||
|
||||
import com.dayu.daf.core.mp.support.Condition; |
||||
import com.dayu.daf.core.mp.support.Query; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import lombok.SneakyThrows; |
||||
import org.apache.commons.codec.Charsets; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.system.util.DataUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.vo.InspectionRouteVO; |
||||
import org.energy.modules.inspection.service.IInspectionRouteService; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.net.URLEncoder; |
||||
import java.time.LocalDate; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 巡检路线 控制器 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/inspection/inspectionRoute") |
||||
@Api(value = "巡检路线", tags = "巡检路线接口") |
||||
public class InspectionRouteController extends DafController { |
||||
|
||||
private IInspectionRouteService inspectionRouteService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入inspectionRoute") |
||||
public R<InspectionRoute> detail(InspectionRoute inspectionRoute) { |
||||
InspectionRoute detail = inspectionRouteService.getOne(Condition.getQueryWrapper(inspectionRoute)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 巡检路线 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionRoute") |
||||
public R<IPage<InspectionRoute>> list(InspectionRoute inspectionRoute, Query query) { |
||||
QueryWrapper<InspectionRoute> qw = new QueryWrapper<>(); |
||||
qw.orderByAsc("route_no"); |
||||
if (StringUtil.isNotEmpty(inspectionRoute.getRouteNo())) { |
||||
qw.lambda().like(InspectionRoute::getRouteNo, inspectionRoute.getRouteNo()); |
||||
} |
||||
if (StringUtil.isNotEmpty(inspectionRoute.getRouteName())) { |
||||
qw.lambda().like(InspectionRoute::getRouteName, inspectionRoute.getRouteName()); |
||||
} |
||||
if (StringUtil.isNotEmpty(inspectionRoute.getType())) { |
||||
qw.lambda().like(InspectionRoute::getType, inspectionRoute.getType()); |
||||
} |
||||
if (null != inspectionRoute.getIstatus()) { |
||||
qw.lambda().eq(InspectionRoute::getIstatus, inspectionRoute.getIstatus()); |
||||
} |
||||
IPage<InspectionRoute> pages = inspectionRouteService.page(Condition.getPage(query), qw); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 巡检路线 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionRoute") |
||||
public R<IPage<InspectionRouteVO>> page(InspectionRouteVO inspectionRoute, Query query) { |
||||
IPage<InspectionRouteVO> pages = inspectionRouteService.selectInspectionRoutePage(Condition.getPage(query), inspectionRoute); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 巡检路线 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入inspectionRoute") |
||||
public R save(@Valid @RequestBody InspectionRoute inspectionRoute) { |
||||
return R.status(inspectionRouteService.save(inspectionRoute)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 巡检路线 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入inspectionRoute") |
||||
public R update(@Valid @RequestBody InspectionRoute inspectionRoute) { |
||||
return R.status(inspectionRouteService.updateById(inspectionRoute)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 巡检路线 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入inspectionRoute") |
||||
public R submit(@Valid @RequestBody InspectionRoute inspectionRoute) { |
||||
inspectionRoute.setIstatus(1); |
||||
String date = LocalDate.now().toString().replace("-",""); |
||||
String maxNo = inspectionRouteService.getMaxNo(date); |
||||
int number; |
||||
if (StringUtil.isNotEmpty(maxNo)){ |
||||
number = Integer.parseInt(maxNo.substring(9)); |
||||
number++; |
||||
}else{ |
||||
number = 1; |
||||
} |
||||
String numFormat = String.format("%04d", number); |
||||
String no = "L" + date + numFormat; |
||||
inspectionRoute.setRouteNo(no); |
||||
return R.status(inspectionRouteService.saveOrUpdate(inspectionRoute)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 巡检路线 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(inspectionRouteService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 生效 |
||||
*/ |
||||
@PostMapping("/takeEffect") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "生效", notes = "传入ids") |
||||
public R takeEffect(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return this.updateInspectionRoute(1, "", ids); |
||||
} |
||||
|
||||
/** |
||||
* 失效 |
||||
*/ |
||||
@PostMapping("/lapse") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiOperation(value = "失效", notes = "传入ids") |
||||
public R lapse(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @ApiParam(value = "取消原因", required = true) @RequestParam String reason) { |
||||
return this.updateInspectionRoute(0, reason, ids); |
||||
} |
||||
|
||||
/** |
||||
* 生效OR失效 |
||||
*/ |
||||
public R updateInspectionRoute(Integer status, String reason, String ids) { |
||||
List<InspectionRoute> list = new ArrayList<>(); |
||||
for (String id : ids.split(",")) { |
||||
InspectionRoute inspectionRoute = new InspectionRoute(); |
||||
inspectionRoute.setId(Long.parseLong(id)); |
||||
inspectionRoute.setCancelReason(reason); |
||||
inspectionRoute.setIstatus(status); |
||||
list.add(inspectionRoute); |
||||
} |
||||
return R.status(inspectionRouteService.updateBatchById(list)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 导出 |
||||
*/ |
||||
@SneakyThrows |
||||
@GetMapping("export") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiOperation(value = "导出", notes = "传入") |
||||
@ApiLog |
||||
public void exportInspectionRoute(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) { |
||||
entity.remove("daf-auth"); |
||||
InspectionRoute vo = DataUtils.mapToEntity(entity, InspectionRoute::new); |
||||
List<InspectionRouteExcel> list = inspectionRouteService.export(vo); |
||||
response.setContentType("application/vnd.ms-excel"); |
||||
response.setCharacterEncoding(Charsets.UTF_8.name()); |
||||
String fileName = URLEncoder.encode("巡检路线数据导出", Charsets.UTF_8.name()); |
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
||||
EasyExcel.write(response.getOutputStream(), InspectionRouteExcel.class).sheet("巡检路线").doWrite(list); |
||||
} |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
@GetMapping("/getRouteList") |
||||
@ApiOperationSupport(order = 11) |
||||
@ApiOperation(value = "获取路线编号", notes = "获取路线编号") |
||||
public R<List<InspectionRoute>> getRouteList() { |
||||
List<InspectionRoute> routeList = inspectionRouteService.getRouteList(); |
||||
return R.data(routeList); |
||||
} |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
@GetMapping("/getDetailList") |
||||
@ApiOperationSupport(order = 12) |
||||
@ApiOperation(value = "获取路线信息", notes = "获取路线信息") |
||||
public R<InspectionRoute> getDetailList(String routeNo) { |
||||
InspectionRoute DetailList = inspectionRouteService.getDetailList(routeNo); |
||||
return R.data(DetailList); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,253 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.inspection.controller; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.dayu.daf.core.log.annotation.ApiLog; |
||||
import com.dayu.daf.core.tool.constant.DafConstant; |
||||
import com.xkcoding.http.util.StringUtil; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import lombok.AllArgsConstructor; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.validation.Valid; |
||||
|
||||
import com.dayu.daf.core.mp.support.Condition; |
||||
import com.dayu.daf.core.mp.support.Query; |
||||
import com.dayu.daf.core.tool.api.R; |
||||
import com.dayu.daf.core.tool.utils.Func; |
||||
import lombok.SneakyThrows; |
||||
import org.apache.commons.codec.Charsets; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.inspection.excel.InspectionTasksExcel; |
||||
import org.energy.modules.leger.entity.EquipmentLedger; |
||||
import org.energy.modules.leger.excel.EquipmentLedgerExcel; |
||||
import org.energy.modules.system.util.DataUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.inspection.entity.InspectionTasks; |
||||
import org.energy.modules.inspection.vo.InspectionTasksVO; |
||||
import org.energy.modules.inspection.service.IInspectionTasksService; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.net.URLEncoder; |
||||
import java.time.LocalDate; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 巡检任务 控制器 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/inspection/inspectiontasks") |
||||
@Api(value = "巡检任务", tags = "巡检任务接口") |
||||
public class InspectionTasksController extends DafController { |
||||
|
||||
private IInspectionTasksService inspectionTasksService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入inspectionTasks") |
||||
public R<InspectionTasks> detail(InspectionTasks inspectionTasks) { |
||||
InspectionTasks detail = inspectionTasksService.getOne(Condition.getQueryWrapper(inspectionTasks)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 巡检任务 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionTasks") |
||||
public R<IPage<InspectionTasks>> list(InspectionTasks inspectionTasks, Query query) { |
||||
QueryWrapper<InspectionTasks> qw = new QueryWrapper<>(); |
||||
qw.orderByAsc("task_no"); |
||||
// 场站
|
||||
if (null != inspectionTasks.getStation()) { |
||||
qw.lambda().eq(InspectionTasks::getStation, inspectionTasks.getStation()); |
||||
} |
||||
// 状态
|
||||
if (null != inspectionTasks.getTaskStatus()) { |
||||
qw.lambda().eq(InspectionTasks::getTaskStatus, inspectionTasks.getTaskStatus()); |
||||
} |
||||
// 任务编号
|
||||
if (StringUtil.isNotEmpty(inspectionTasks.getTaskNo())) { |
||||
qw.lambda().like(InspectionTasks::getTaskNo, inspectionTasks.getTaskNo()); |
||||
} |
||||
// 任务名称
|
||||
if (StringUtil.isNotEmpty(inspectionTasks.getTaskName())) { |
||||
qw.lambda().like(InspectionTasks::getTaskName, inspectionTasks.getTaskName()); |
||||
} |
||||
// 任务生成日期
|
||||
if (StringUtil.isNotEmpty(inspectionTasks.getTaskStartDate())) { |
||||
qw.lambda().like(InspectionTasks::getTaskStartDate, inspectionTasks.getTaskStartDate()); |
||||
} |
||||
// 任务完成日期
|
||||
if (StringUtil.isNotEmpty(inspectionTasks.getTaskEndDate())) { |
||||
qw.lambda().like(InspectionTasks::getTaskEndDate, inspectionTasks.getTaskEndDate()); |
||||
} |
||||
// 责任人
|
||||
if (StringUtil.isNotEmpty(inspectionTasks.getResponsiblePerson())) { |
||||
qw.lambda().like(InspectionTasks::getResponsiblePerson, inspectionTasks.getResponsiblePerson()); |
||||
} |
||||
IPage<InspectionTasks> pages = inspectionTasksService.page(Condition.getPage(query), qw); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 巡检任务 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionTasks") |
||||
public R<IPage<InspectionTasksVO>> page(InspectionTasksVO inspectionTasks, Query query) { |
||||
IPage<InspectionTasksVO> pages = inspectionTasksService.selectInspectionTasksPage(Condition.getPage(query), inspectionTasks); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 巡检任务 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入inspectionTasks") |
||||
public R save(@Valid @RequestBody InspectionTasks inspectionTasks) { |
||||
return R.status(inspectionTasksService.save(inspectionTasks)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 巡检任务 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入inspectionTasks") |
||||
public R update(@Valid @RequestBody InspectionTasks inspectionTasks) { |
||||
return R.status(inspectionTasksService.updateById(inspectionTasks)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 巡检任务 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入inspectionTasks") |
||||
public R submit(@Valid @RequestBody InspectionTasks inspectionTasks) { |
||||
inspectionTasks.setTaskStatus(1L); |
||||
String date = LocalDate.now().toString().replace("-",""); |
||||
String maxTaskNo = inspectionTasksService.getMaxTaskNo(date); |
||||
int number; |
||||
if (StringUtil.isNotEmpty(maxTaskNo)){ |
||||
number = Integer.parseInt(maxTaskNo.substring(9)); |
||||
number++; |
||||
}else{ |
||||
number = 1; |
||||
} |
||||
String numFormat = String.format("%04d", number); |
||||
String taskNo = "R" + date + numFormat; |
||||
inspectionTasks.setTaskNo(taskNo); |
||||
return R.status(inspectionTasksService.saveOrUpdate(inspectionTasks)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 巡检任务 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(inspectionTasksService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 启动 巡检任务 |
||||
*/ |
||||
@PostMapping("/action") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "更新", notes = "传入ids") |
||||
public R auditing(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return this.approve("1",ids, ""); |
||||
} |
||||
|
||||
/** |
||||
* 停止 巡检任务 |
||||
*/ |
||||
@PostMapping("/stop") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiOperation(value = "更新", notes = "传入ids") |
||||
public R stop(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @RequestParam String reason) { |
||||
return this.approve("2",ids, reason); |
||||
} |
||||
|
||||
/** |
||||
* 启动OR停止 巡检任务 |
||||
*/ |
||||
public R approve(String status, String ids, String reason) { |
||||
List<InspectionTasks> list = new ArrayList<>(); |
||||
for (String id : ids.split(",")) { |
||||
InspectionTasks inspectionTasks = new InspectionTasks(); |
||||
inspectionTasks.setId(Long.parseLong(id)); |
||||
inspectionTasks.setTaskStatus(Long.parseLong(status)); |
||||
inspectionTasks.setCancelReason(reason); |
||||
list.add(inspectionTasks); |
||||
} |
||||
return R.status(inspectionTasksService.updateBatchById(list)); |
||||
} |
||||
|
||||
/** |
||||
* 导出 |
||||
*/ |
||||
@SneakyThrows |
||||
@GetMapping("export") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiOperation(value = "导出", notes = "传入") |
||||
@ApiLog |
||||
public void exportUser(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) { |
||||
entity.remove("daf-auth"); |
||||
InspectionTasks vo = DataUtils.mapToEntity(entity, InspectionTasks::new); |
||||
List<InspectionTasksExcel> list = inspectionTasksService.export(vo); |
||||
response.setContentType("application/vnd.ms-excel"); |
||||
response.setCharacterEncoding(Charsets.UTF_8.name()); |
||||
String fileName = URLEncoder.encode("巡检任务数据导出", Charsets.UTF_8.name()); |
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
||||
EasyExcel.write(response.getOutputStream(), InspectionTasksExcel.class).sheet("巡检任务").doWrite(list); |
||||
} |
||||
|
||||
@GetMapping("/getListByToolsCodeId") |
||||
@ApiOperationSupport(order = 11) |
||||
@ApiOperation(value = "通过工器具编码获取巡检任务", notes = "通过工器具编码获取巡检任务") |
||||
public R<List<InspectionTasks>> getListByToolsCodeId(String toolsCodeId) { |
||||
List<InspectionTasks> pages = inspectionTasksService.getListByToolsCodeId(toolsCodeId); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package org.energy.modules.inspection.dto; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionObject; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 巡检对象一览数据传输对象实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-11 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class InspectionObjectDTO extends InspectionObject { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package org.energy.modules.inspection.dto; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionPlan; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 巡检计划数据传输对象实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class InspectionPlanDTO extends InspectionPlan { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package org.energy.modules.inspection.dto; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionResult; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 巡检结果数据传输对象实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class InspectionResultDTO extends InspectionResult { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package org.energy.modules.inspection.dto; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 巡检路线数据传输对象实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class InspectionRouteDTO extends InspectionRoute { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package org.energy.modules.inspection.dto; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionTasks; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 巡检任务数据传输对象实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class InspectionTasksDTO extends InspectionTasks { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,83 @@ |
||||
package org.energy.modules.inspection.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.dayu.daf.core.mp.base.BaseEntity; |
||||
import java.io.Serializable; |
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
|
||||
/** |
||||
* 巡检对象一览实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-11 |
||||
*/ |
||||
@Data |
||||
@TableName("i_inspection_object") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "InspectionObject对象", description = "巡检对象一览") |
||||
public class InspectionObject extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "主键") |
||||
private Long id; |
||||
/** |
||||
* 对象编号 |
||||
*/ |
||||
@ApiModelProperty(value = "对象编号") |
||||
private String objectNo; |
||||
/** |
||||
* 对象名称 |
||||
*/ |
||||
@ApiModelProperty(value = "对象名称") |
||||
private String objectName; |
||||
/** |
||||
* 场站 |
||||
*/ |
||||
@ApiModelProperty(value = "场站") |
||||
private Integer station; |
||||
/** |
||||
* 对象状态 |
||||
*/ |
||||
@ApiModelProperty(value = "对象状态") |
||||
private Integer istatus; |
||||
/** |
||||
* 对象类型 |
||||
*/ |
||||
@ApiModelProperty(value = "对象类型") |
||||
private String objectType; |
||||
/** |
||||
* 对象区域 |
||||
*/ |
||||
@ApiModelProperty(value = "对象区域") |
||||
private String objectArea; |
||||
|
||||
/** |
||||
* KKS编号 |
||||
*/ |
||||
@ApiModelProperty(value = "KKS编号") |
||||
private String kksNo; |
||||
|
||||
/** |
||||
* KKS编号 |
||||
*/ |
||||
@ApiModelProperty(value = "工器具编号") |
||||
private String toolsCodeId; |
||||
/** |
||||
* 取消原因 |
||||
*/ |
||||
@ApiModelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
|
||||
|
||||
} |
@ -0,0 +1,86 @@ |
||||
package org.energy.modules.inspection.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.dayu.daf.core.mp.base.BaseEntity; |
||||
import java.io.Serializable; |
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
|
||||
/** |
||||
* 巡检计划实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@Data |
||||
@TableName("i_inspection_plan") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "InspectionPlan对象", description = "巡检计划") |
||||
public class InspectionPlan extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "主键") |
||||
private Long id; |
||||
/** |
||||
* 计划编号 |
||||
*/ |
||||
@ApiModelProperty(value = "计划编号") |
||||
private String planNo; |
||||
/** |
||||
* 计划名称 |
||||
*/ |
||||
@ApiModelProperty(value = "计划名称") |
||||
private String planName; |
||||
/** |
||||
* 场站 |
||||
*/ |
||||
@ApiModelProperty(value = "场站") |
||||
private Integer station; |
||||
/** |
||||
* 计划类型 |
||||
*/ |
||||
@ApiModelProperty(value = "计划类型") |
||||
private String planType; |
||||
/** |
||||
* 周期类型 |
||||
*/ |
||||
@ApiModelProperty(value = "周期类型") |
||||
private String periodType; |
||||
/** |
||||
* 周期值 |
||||
*/ |
||||
@ApiModelProperty(value = "周期值") |
||||
private String periodValue; |
||||
/** |
||||
* 计划起始时间 |
||||
*/ |
||||
@ApiModelProperty(value = "计划起始时间") |
||||
private String startTime; |
||||
/** |
||||
* 计划终了时间 |
||||
*/ |
||||
@ApiModelProperty(value = "计划终了时间") |
||||
private String endTime; |
||||
/** |
||||
* 计划状态 |
||||
*/ |
||||
@ApiModelProperty(value = "计划状态") |
||||
private Integer planStatus; |
||||
/** |
||||
* 取消原因 |
||||
*/ |
||||
@ApiModelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
|
||||
|
||||
} |
@ -0,0 +1,70 @@ |
||||
package org.energy.modules.inspection.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.dayu.daf.core.mp.base.BaseEntity; |
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
|
||||
/** |
||||
* 巡检结果实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-11 |
||||
*/ |
||||
@Data |
||||
@TableName("i_inspection_result") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "InspectionResult对象", description = "巡检结果") |
||||
public class InspectionResult extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "主键") |
||||
private Long id; |
||||
/** |
||||
* 结果编码 |
||||
*/ |
||||
@ApiModelProperty(value = "结果编码") |
||||
private String resultNo; |
||||
/** |
||||
* 任务编码 |
||||
*/ |
||||
@ApiModelProperty(value = "任务编码") |
||||
private String taskNo; |
||||
/** |
||||
* 任务执行开始时间 |
||||
*/ |
||||
@ApiModelProperty(value = "任务执行开始时间") |
||||
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy/MM/dd HH:mm:ss") |
||||
private LocalDateTime executeStartDate; |
||||
/** |
||||
* 任务执行结束时间 |
||||
*/ |
||||
@ApiModelProperty(value = "任务执行结束时间") |
||||
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy/MM/dd HH:mm:ss") |
||||
private LocalDateTime executeEndDate; |
||||
/** |
||||
* 巡检结果 |
||||
*/ |
||||
@ApiModelProperty(value = "巡检结果") |
||||
private String inspectiontResult; |
||||
/** |
||||
* 巡检报告 |
||||
*/ |
||||
@ApiModelProperty(value = "巡检报告") |
||||
private String inspectionReport; |
||||
|
||||
|
||||
} |
@ -0,0 +1,71 @@ |
||||
package org.energy.modules.inspection.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.dayu.daf.core.mp.base.BaseEntity; |
||||
import java.io.Serializable; |
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
|
||||
/** |
||||
* 巡检路线实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Data |
||||
@TableName("i_inspection_route") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "InspectionRoute对象", description = "巡检路线") |
||||
public class InspectionRoute extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "主键") |
||||
private Long id; |
||||
/** |
||||
* 路线编号 |
||||
*/ |
||||
@ApiModelProperty(value = "路线编号") |
||||
private String routeNo; |
||||
/** |
||||
* 路线名称 |
||||
*/ |
||||
@ApiModelProperty(value = "路线名称") |
||||
private String routeName; |
||||
/** |
||||
* 场站 |
||||
*/ |
||||
@ApiModelProperty(value = "场站") |
||||
private Integer stations; |
||||
/** |
||||
* 类型 |
||||
*/ |
||||
@ApiModelProperty(value = "类型") |
||||
private String type; |
||||
/** |
||||
* 巡检状态 |
||||
*/ |
||||
@ApiModelProperty(value = "巡检状态") |
||||
private Integer istatus; |
||||
/** |
||||
* 维护工厂 |
||||
*/ |
||||
@ApiModelProperty(value = "维护工厂") |
||||
private String factory; |
||||
/** |
||||
* 取消原因 |
||||
*/ |
||||
@ApiModelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
|
||||
|
||||
} |
@ -0,0 +1,121 @@ |
||||
package org.energy.modules.inspection.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.dayu.daf.core.mp.base.BaseEntity; |
||||
import java.io.Serializable; |
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
|
||||
/** |
||||
* 巡检任务实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Data |
||||
@TableName("i_inspection_tasks") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "InspectionTasks对象", description = "巡检任务") |
||||
public class InspectionTasks extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "主键") |
||||
private Long id; |
||||
/** |
||||
* 任务编码 |
||||
*/ |
||||
@ApiModelProperty(value = "任务编码") |
||||
private String taskNo; |
||||
/** |
||||
* 对象编码 |
||||
*/ |
||||
@ApiModelProperty(value = "对象编码") |
||||
private String objectNo; |
||||
/** |
||||
* 路线编码 |
||||
*/ |
||||
@ApiModelProperty(value = "路线编码") |
||||
private String routeNo; |
||||
/** |
||||
* 计划编码 |
||||
*/ |
||||
@ApiModelProperty(value = "计划编码") |
||||
private String planNo; |
||||
/** |
||||
* 任务名称 |
||||
*/ |
||||
@ApiModelProperty(value = "任务名称") |
||||
private String taskName; |
||||
/** |
||||
* 场站 |
||||
*/ |
||||
@ApiModelProperty(value = "场站") |
||||
private Long station; |
||||
/** |
||||
* 责任人 |
||||
*/ |
||||
@ApiModelProperty(value = "责任人") |
||||
private String responsiblePerson; |
||||
/** |
||||
* 任务生成日期时间 |
||||
*/ |
||||
@ApiModelProperty(value = "任务生成日期时间") |
||||
private String taskStartDate; |
||||
/** |
||||
* 任务结束日期时间 |
||||
*/ |
||||
@ApiModelProperty(value = "任务结束日期时间") |
||||
private String taskEndDate; |
||||
/** |
||||
* 取消原因 |
||||
*/ |
||||
@ApiModelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
/** |
||||
* 任务状态 |
||||
*/ |
||||
@ApiModelProperty(value = "任务状态") |
||||
private Long taskStatus; |
||||
/** |
||||
* 对象名称 |
||||
*/ |
||||
@ApiModelProperty(value = "对象名称") |
||||
private String objectName; |
||||
/** |
||||
* 对象类型 |
||||
*/ |
||||
@ApiModelProperty(value = "对象类型") |
||||
private String objectType; |
||||
/** |
||||
* 路线名称 |
||||
*/ |
||||
@ApiModelProperty(value = "路线名称") |
||||
private String routeName; |
||||
/** |
||||
* 路线类型 |
||||
*/ |
||||
@ApiModelProperty(value = "路线类型") |
||||
private String routeType; |
||||
/** |
||||
* 计划名称 |
||||
*/ |
||||
@ApiModelProperty(value = "计划名称") |
||||
private String planName; |
||||
/** |
||||
* 计划类型 |
||||
*/ |
||||
@ApiModelProperty(value = "计划类型") |
||||
private String planType; |
||||
|
||||
|
||||
} |
@ -0,0 +1,53 @@ |
||||
package org.energy.modules.inspection.excel; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@Data |
||||
@ColumnWidth(25) |
||||
@HeadRowHeight(20) |
||||
@ContentRowHeight(16) |
||||
public class InspectionObjectExcel implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "对象编号") |
||||
private String objectNo; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "对象名称") |
||||
private String objectName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "场站") |
||||
private String station; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "对象类型") |
||||
private String objectType; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "对象区域") |
||||
private String objectArea; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "对象状态") |
||||
private String istatus; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "KKS编号") |
||||
private String kksNo; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "工器具台账编码") |
||||
private String toolsCodeId; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
} |
@ -0,0 +1,73 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.inspection.excel; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* EquipmentLedge model export |
||||
* @author edwong |
||||
*/ |
||||
@Data |
||||
@ColumnWidth(25) |
||||
@HeadRowHeight(20) |
||||
@ContentRowHeight(16) |
||||
public class InspectionPlanExcel implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "计划编号") |
||||
private String planNo; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "计划名称") |
||||
private String planName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "计划类型") |
||||
private String planType; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "周期类型") |
||||
private String periodType; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "周期值") |
||||
private String periodValue; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "计划起始时间") |
||||
private String startTime; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "计划终了时间") |
||||
private String endTime; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "状态") |
||||
private String planStatusName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
|
||||
} |
@ -0,0 +1,61 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.inspection.excel; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* EquipmentLedge model export |
||||
* @author edwong |
||||
*/ |
||||
@Data |
||||
@ColumnWidth(25) |
||||
@HeadRowHeight(20) |
||||
@ContentRowHeight(16) |
||||
public class InspectionRouteExcel implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "路线编号") |
||||
private String routeNo; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "路线名称") |
||||
private String routeName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "类型") |
||||
private String type; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "巡检状态") |
||||
private String istatusName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "维护工厂") |
||||
private String factory; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
|
||||
} |
@ -0,0 +1,70 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.energy.modules.inspection.excel; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* EquipmentLedge model export |
||||
* @author edwong |
||||
*/ |
||||
@Data |
||||
@ColumnWidth(25) |
||||
@HeadRowHeight(20) |
||||
@ContentRowHeight(16) |
||||
public class InspectionTasksExcel implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "任务编号") |
||||
private String taskNo; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "任务名称") |
||||
private String taskName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "场站") |
||||
private String stationExt; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "任务生成日期") |
||||
private String taskStartDate; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "任务完成日期") |
||||
private String taskEndDate; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "责任人") |
||||
private String responsiblePerson; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "状态") |
||||
private String taskStatusExt; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
|
||||
|
||||
} |
@ -0,0 +1,48 @@ |
||||
package org.energy.modules.inspection.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.energy.modules.inspection.entity.InspectionObject; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.excel.InspectionObjectExcel; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.inspection.vo.InspectionObjectVO; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检对象一览 Mapper 接口 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-11 |
||||
*/ |
||||
public interface InspectionObjectMapper extends BaseMapper<InspectionObject> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionObject |
||||
* @return |
||||
*/ |
||||
List<InspectionObjectVO> selectInspectionObjectPage(IPage page, InspectionObjectVO inspectionObject); |
||||
|
||||
List<InspectionObjectExcel> exportData(@Param("vo") InspectionObjectVO inspectionObject); |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
List<InspectionObject> getObjectList(); |
||||
|
||||
/** |
||||
* 获取最大编号 |
||||
*/ |
||||
String getMaxNo(String date); |
||||
|
||||
/** |
||||
* 获取路线的信息 |
||||
*/ |
||||
InspectionObject getDetailList(String routeNo); |
||||
|
||||
} |
@ -0,0 +1,72 @@ |
||||
<?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="org.energy.modules.inspection.mapper.InspectionObjectMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="inspectionObjectResultMap" type="org.energy.modules.inspection.entity.InspectionObject"> |
||||
<id column="id" property="id"/> |
||||
<result column="status" property="status"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="object_no" property="objectNo"/> |
||||
<result column="object_name" property="objectName"/> |
||||
<result column="station" property="station"/> |
||||
<result column="istatus" property="istatus"/> |
||||
<result column="object_type" property="objectType"/> |
||||
<result column="object_area" property="objectArea"/> |
||||
<result column="kks_no" property="kksNo"/> |
||||
<result column="tools_code_id" property="tools_code_id"/> |
||||
<result column="cancel_reason" property="cancelReason"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<select id="selectInspectionObjectPage" resultMap="inspectionObjectResultMap"> |
||||
select * from i_inspection_object where is_deleted = 0 |
||||
</select> |
||||
|
||||
<select id="exportData" resultType="org.energy.modules.inspection.excel.InspectionObjectExcel"> |
||||
Select |
||||
object_no |
||||
, object_area |
||||
, kks_no |
||||
, object_type |
||||
, cancel_reason |
||||
,station |
||||
,istatus |
||||
,object_name |
||||
, tools_code_id |
||||
FROM i_inspection_object a |
||||
where a.is_deleted = 0 |
||||
<if test="vo.objectNo != null and vo.objectNo != ''"> |
||||
and a.object_no LIKE CONCAT('%', #{vo.objectNo}, '%') |
||||
</if> |
||||
<if test="vo.objectName != null and vo.objectName != ''"> |
||||
AND a.object_name LIKE CONCAT('%', #{vo.objectName}, '%') |
||||
</if> |
||||
<if test="vo.objectArea != null and vo.objectArea != ''"> |
||||
AND a.object_area LIKE CONCAT('%', #{vo.objectArea}, '%') |
||||
</if> |
||||
<if test="vo.istatus != null and vo.istatus != ''"> |
||||
and a.istatus = #{vo.istatus} |
||||
</if> |
||||
<if test="vo.station != null and vo.station != ''"> |
||||
and a.station = #{vo.station} |
||||
</if> |
||||
</select> |
||||
|
||||
<select id="getObjectList" resultMap="inspectionObjectResultMap"> |
||||
select object_no from i_inspection_object where is_deleted = 0 and istatus = 1 |
||||
</select> |
||||
|
||||
<select id="getMaxNo" resultType="java.lang.String"> |
||||
SELECT max(object_no) |
||||
FROM i_inspection_object where object_no like ${date} |
||||
</select> |
||||
|
||||
<select id="getDetailList" resultMap="inspectionObjectResultMap"> |
||||
select object_name, object_type , station from i_inspection_object where object_no = ${object_no} and is_deleted = 0 |
||||
</select> |
||||
</mapper> |
@ -0,0 +1,45 @@ |
||||
package org.energy.modules.inspection.mapper; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.energy.modules.inspection.entity.InspectionPlan; |
||||
import org.energy.modules.inspection.excel.InspectionPlanExcel; |
||||
import org.energy.modules.inspection.vo.InspectionPlanVO; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检计划 Mapper 接口 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
public interface InspectionPlanMapper extends BaseMapper<InspectionPlan> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionPlan |
||||
* @return |
||||
*/ |
||||
List<InspectionPlanVO> selectInspectionPlanPage(IPage page, InspectionPlanVO inspectionPlan); |
||||
|
||||
List<InspectionPlanExcel> exportData(@Param("entity") InspectionPlan inspectionPlan); |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
List<InspectionPlan> getPlanList(); |
||||
|
||||
/** |
||||
* 获取最大编号 |
||||
*/ |
||||
String getMaxNo(String date); |
||||
|
||||
/** |
||||
* 获取路线的信息 |
||||
*/ |
||||
InspectionPlan getDetail(String planNo); |
||||
|
||||
} |
@ -0,0 +1,64 @@ |
||||
<?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="org.energy.modules.inspection.mapper.InspectionPlanMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="inspectionPlanResultMap" type="org.energy.modules.inspection.entity.InspectionPlan"> |
||||
<id column="id" property="id"/> |
||||
<result column="status" property="status"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="plan_no" property="planNo"/> |
||||
<result column="plan_name" property="planName"/> |
||||
<result column="station" property="station"/> |
||||
<result column="plan_type" property="planType"/> |
||||
<result column="period_type" property="periodType"/> |
||||
<result column="period_value" property="periodValue"/> |
||||
<result column="start_time" property="startTime"/> |
||||
<result column="end_time" property="endTime"/> |
||||
<result column="plan_status" property="planStatus"/> |
||||
<result column="cancel_reason" property="cancelReason"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<select id="selectInspectionPlanPage" resultMap="inspectionPlanResultMap"> |
||||
select * from i_inspection_plan where is_deleted = 0 |
||||
</select> |
||||
|
||||
<select id="exportData" resultType="org.energy.modules.inspection.excel.InspectionPlanExcel"> |
||||
SELECT plan_no, plan_name, plan_type, period_type, period_value, start_time, end_time, cancel_reason |
||||
, dic2.dict_value AS plan_status_name |
||||
FROM i_inspection_plan a |
||||
LEFT JOIN sys_dict dic2 ON dic2.code = 'istatus' AND dic2.dict_key = a.plan_status AND dic2.is_deleted = '0' |
||||
WHERE a.is_deleted = 0 |
||||
<if test="entity.planNo != null and entity.planNo != ''"> |
||||
AND a.plan_no LIKE CONCAT('%', #{entity.planNo}, '%') |
||||
</if> |
||||
<if test="entity.planName != null and entity.planName != ''"> |
||||
AND a.plan_name LIKE CONCAT('%', #{entity.planName}, '%') |
||||
</if> |
||||
<if test="entity.periodType != null and entity.periodType != ''"> |
||||
AND a.period_type LIKE CONCAT('%', #{entity.periodType}, '%') |
||||
</if> |
||||
<if test="entity.planStatus != null and entity.planStatus != ''"> |
||||
AND a.plan_status = #{entity.planStatus} |
||||
</if> |
||||
</select> |
||||
|
||||
<select id="getPlanList" resultMap="inspectionPlanResultMap"> |
||||
select plan_no from i_inspection_plan where is_deleted = 0 and plan_status = '1' |
||||
</select> |
||||
|
||||
<select id="getMaxNo" resultType="java.lang.String"> |
||||
SELECT max(plan_no) |
||||
FROM i_inspection_plan where plan_no like CONCAT('%', #{date}, '%') |
||||
</select> |
||||
|
||||
<select id="getDetail" resultMap="inspectionPlanResultMap"> |
||||
select plan_name, plan_type from i_inspection_plan where plan_no = #{plan_no} |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,31 @@ |
||||
package org.energy.modules.inspection.mapper; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionResult; |
||||
import org.energy.modules.inspection.vo.InspectionResultVO; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检结果 Mapper 接口 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-11 |
||||
*/ |
||||
public interface InspectionResultMapper extends BaseMapper<InspectionResult> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionResult |
||||
* @return |
||||
*/ |
||||
List<InspectionResultVO> selectInspectionResultPage(IPage page, InspectionResultVO inspectionResult); |
||||
|
||||
/** |
||||
* 获取最大结果编号 |
||||
*/ |
||||
String getMaxResultNo(String taskNo); |
||||
|
||||
} |
@ -0,0 +1,31 @@ |
||||
<?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="org.energy.modules.inspection.mapper.InspectionResultMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="inspectionResultResultMap" type="org.energy.modules.inspection.entity.InspectionResult"> |
||||
<id column="id" property="id"/> |
||||
<result column="status" property="status"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="result_no" property="resultNo"/> |
||||
<result column="task_no" property="taskNo"/> |
||||
<result column="execute_start_date" property="executeStartDate"/> |
||||
<result column="execute_end_date" property="executeEndDate"/> |
||||
<result column="inspectiont_result" property="inspectiontResult"/> |
||||
<result column="inspection_report" property="inspectionReport"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<select id="selectInspectionResultPage" resultMap="inspectionResultResultMap"> |
||||
select * from i_inspection_result where is_deleted = 0 |
||||
</select> |
||||
|
||||
<select id="getMaxResultNo" resultType="java.lang.String"> |
||||
select max(result_no) from i_inspection_result where result_no like ${taskNo} |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,45 @@ |
||||
package org.energy.modules.inspection.mapper; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.inspection.vo.InspectionRouteVO; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检路线 Mapper 接口 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
public interface InspectionRouteMapper extends BaseMapper<InspectionRoute> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionRoute |
||||
* @return |
||||
*/ |
||||
List<InspectionRouteVO> selectInspectionRoutePage(IPage page, InspectionRouteVO inspectionRoute); |
||||
|
||||
List<InspectionRouteExcel> exportData(@Param("entity") InspectionRoute inspectionRoute); |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
List<InspectionRoute> getRouteList(); |
||||
|
||||
/** |
||||
* 获取最大编号 |
||||
*/ |
||||
String getMaxNo(String date); |
||||
|
||||
/** |
||||
* 获取路线的信息 |
||||
*/ |
||||
InspectionRoute getDetailList(String routeNo); |
||||
} |
@ -0,0 +1,61 @@ |
||||
<?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="org.energy.modules.inspection.mapper.InspectionRouteMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="inspectionRouteResultMap" type="org.energy.modules.inspection.entity.InspectionRoute"> |
||||
<id column="id" property="id"/> |
||||
<result column="status" property="status"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="route_no" property="routeNo"/> |
||||
<result column="route_name" property="routeName"/> |
||||
<result column="stations" property="stations"/> |
||||
<result column="type" property="type"/> |
||||
<result column="istatus" property="istatus"/> |
||||
<result column="factory" property="factory"/> |
||||
<result column="cancel_reason" property="cancelReason"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<select id="selectInspectionRoutePage" resultMap="inspectionRouteResultMap"> |
||||
select * from i_inspection_route where is_deleted = 0 |
||||
</select> |
||||
|
||||
<select id="exportData" resultType="org.energy.modules.inspection.excel.InspectionRouteExcel"> |
||||
SELECT a.route_no, a.route_name, a.type, a.factory, a.cancel_reason |
||||
, dic2.dict_value AS istatus_name |
||||
FROM i_inspection_route a |
||||
LEFT JOIN sys_dict dic2 ON dic2.code = 'istatus' AND dic2.dict_key = a.istatus AND dic2.is_deleted = '0' |
||||
WHERE a.is_deleted = 0 |
||||
<if test="entity.routeNo != null and entity.routeNo != ''"> |
||||
AND a.route_no LIKE CONCAT('%', #{entity.routeNo}, '%') |
||||
</if> |
||||
<if test="entity.routeName != null and entity.routeName != ''"> |
||||
AND a.route_name LIKE CONCAT('%', #{entity.routeName}, '%') |
||||
</if> |
||||
<if test="entity.type != null and entity.type != ''"> |
||||
AND a.type LIKE CONCAT('%', #{entity.type}, '%') |
||||
</if> |
||||
<if test="entity.istatus != null and entity.istatus != ''"> |
||||
AND a.istatus = #{entity.istatus} |
||||
</if> |
||||
</select> |
||||
|
||||
<select id="getRouteList" resultMap="inspectionRouteResultMap"> |
||||
select route_no from i_inspection_route where is_deleted = 0 and istatus = 1 |
||||
</select> |
||||
|
||||
<select id="getMaxNo" resultType="java.lang.String"> |
||||
SELECT max(route_no) |
||||
FROM i_inspection_route where route_no like CONCAT('%', #{date}, '%') |
||||
</select> |
||||
|
||||
<select id="getDetailList" resultMap="inspectionRouteResultMap"> |
||||
select route_name, type from i_inspection_route where route_no = #{route_no} and is_deleted = 0 |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,44 @@ |
||||
package org.energy.modules.inspection.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.energy.modules.inspection.entity.InspectionTasks; |
||||
import org.energy.modules.inspection.excel.InspectionTasksExcel; |
||||
import org.energy.modules.inspection.vo.InspectionTasksVO; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.leger.entity.EquipmentLedger; |
||||
import org.energy.modules.leger.excel.EquipmentLedgerExcel; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检任务 Mapper 接口 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
public interface InspectionTasksMapper extends BaseMapper<InspectionTasks> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionTasks |
||||
* @return |
||||
*/ |
||||
List<InspectionTasksVO> selectInspectionTasksPage(IPage page, InspectionTasksVO inspectionTasks); |
||||
|
||||
/** |
||||
* 导出 |
||||
*/ |
||||
List<InspectionTasksExcel> exportData(@Param("entity") InspectionTasks inspectionTasks); |
||||
|
||||
/** |
||||
* 获取最大任务编号 |
||||
*/ |
||||
String getMaxTaskNO(String date); |
||||
|
||||
List<InspectionTasks> getListByToolsCodeId(String toolsCodeId); |
||||
|
||||
} |
@ -0,0 +1,88 @@ |
||||
<?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="org.energy.modules.inspection.mapper.InspectionTasksMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="inspectionTasksResultMap" type="org.energy.modules.inspection.entity.InspectionTasks"> |
||||
<id column="id" property="id"/> |
||||
<result column="status" property="status"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="task_no" property="taskNo"/> |
||||
<result column="object_no" property="objectNo"/> |
||||
<result column="route_no" property="routeNo"/> |
||||
<result column="plan_no" property="planNo"/> |
||||
<result column="task_name" property="taskName"/> |
||||
<result column="station" property="station"/> |
||||
<result column="responsible_person" property="responsiblePerson"/> |
||||
<result column="task_start_date" property="taskStartDate"/> |
||||
<result column="task_end_date" property="taskEndDate"/> |
||||
<result column="cancel_reason" property="cancelReason"/> |
||||
<result column="task_status" property="taskStatus"/> |
||||
<result column="object_name" property="objectName"/> |
||||
<result column="object_type" property="objectType"/> |
||||
<result column="route_name" property="routeName"/> |
||||
<result column="route_type" property="routeType"/> |
||||
<result column="plan_name" property="planName"/> |
||||
<result column="plan_type" property="planType"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<select id="selectInspectionTasksPage" resultMap="inspectionTasksResultMap"> |
||||
select * from i_inspection_tasks where is_deleted = 0 |
||||
</select> |
||||
|
||||
<select id="exportData" resultType="org.energy.modules.inspection.excel.InspectionTasksExcel"> |
||||
SELECT a.task_no, a.task_name, dic1.dict_value AS stationExt, a.task_start_date |
||||
, a.task_end_date, a.responsible_person, dic2.dict_value AS taskStatusExt |
||||
, a.cancel_reason |
||||
FROM i_inspection_tasks a |
||||
LEFT JOIN sys_dict dic1 ON dic1.code = 'station' AND dic1.dict_key = a.station AND dic1.is_deleted = '0' |
||||
LEFT JOIN sys_dict dic2 ON dic2.code = 'task_status' AND dic2.dict_key = a.task_status AND dic2.is_deleted = '0' |
||||
WHERE a.is_deleted = 0 |
||||
<if test="entity.taskNo != null and entity.taskNo != ''"> |
||||
AND a.task_no LIKE CONCAT('%', #{entity.taskNo}, '%') |
||||
</if> |
||||
<if test="entity.taskName != null and entity.taskName != ''"> |
||||
AND a.task_name LIKE CONCAT('%', #{entity.taskName}, '%') |
||||
</if> |
||||
<if test="entity.station != null and entity.station != ''"> |
||||
AND a.station = #{entity.station} |
||||
</if> |
||||
<if test="entity.taskStartDate != null and entity.taskStartDate != ''"> |
||||
AND a.task_start_date LIKE CONCAT('%', #{entity.taskStartDate}, '%') |
||||
</if> |
||||
<if test="entity.taskEndDate != null and entity.taskEndDate != ''"> |
||||
AND a.task_end_date LIKE CONCAT('%', #{entity.taskEndDate}, '%') |
||||
</if> |
||||
<if test="entity.responsiblePerson != null and entity.responsiblePerson != ''"> |
||||
AND a.responsible_person LIKE CONCAT('%', #{entity.responsiblePerson}, '%') |
||||
</if> |
||||
<if test="entity.taskStatus != null and entity.taskStatus != ''"> |
||||
AND a.task_status = #{entity.taskStatus} |
||||
</if> |
||||
</select> |
||||
|
||||
<select id="getMaxTaskNO" resultType="java.lang.String"> |
||||
SELECT max(task_no) |
||||
FROM i_inspection_tasks where task_no like CONCAT('%', #{date}, '%') |
||||
</select> |
||||
|
||||
<select id="getListByToolsCodeId" resultMap="inspectionTasksResultMap"> |
||||
select |
||||
task.* |
||||
from |
||||
i_inspection_tasks task |
||||
inner join i_inspection_object obj |
||||
on obj.object_type = '工器具' |
||||
and obj.object_no = task.object_no |
||||
and obj.is_deleted = '0' |
||||
where |
||||
task.is_deleted = '0' |
||||
and obj.tools_code_id = #{toolsCodeId} |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,57 @@ |
||||
package org.energy.modules.inspection.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import org.energy.modules.inspection.entity.InspectionObject; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.excel.InspectionObjectExcel; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.inspection.vo.InspectionObjectVO; |
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检对象一览 服务类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-11 |
||||
*/ |
||||
public interface IInspectionObjectService extends BaseService<InspectionObject> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionObject |
||||
* @return |
||||
*/ |
||||
IPage<InspectionObjectVO> selectInspectionObjectPage(IPage<InspectionObjectVO> page, InspectionObjectVO inspectionObject); |
||||
|
||||
/** |
||||
* 获取导出数据 |
||||
* |
||||
* @param inspectionObject |
||||
* @return |
||||
*/ |
||||
List<InspectionObjectExcel> export(InspectionObjectVO inspectionObject); |
||||
|
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
List<InspectionObject> getObjectList(); |
||||
|
||||
/** |
||||
* 获取最大任务编号 |
||||
* |
||||
* @param date |
||||
*/ |
||||
String getMaxNo(String date); |
||||
|
||||
/** |
||||
* 获取路线的信息 |
||||
*/ |
||||
InspectionObject getDetailList(String objectNo); |
||||
|
||||
} |
@ -0,0 +1,53 @@ |
||||
package org.energy.modules.inspection.service; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionPlan; |
||||
import org.energy.modules.inspection.excel.InspectionPlanExcel; |
||||
import org.energy.modules.inspection.vo.InspectionPlanVO; |
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检计划 服务类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
public interface IInspectionPlanService extends BaseService<InspectionPlan> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionPlan |
||||
* @return |
||||
*/ |
||||
IPage<InspectionPlanVO> selectInspectionPlanPage(IPage<InspectionPlanVO> page, InspectionPlanVO inspectionPlan); |
||||
|
||||
/** |
||||
* 获取导出数据 |
||||
* |
||||
* @param inspectionRoute |
||||
* @return |
||||
*/ |
||||
List<InspectionPlanExcel> export(InspectionPlan inspectionRoute); |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
List<InspectionPlan> getPlanList(); |
||||
|
||||
/** |
||||
* 获取最大任务编号 |
||||
* |
||||
* @param date |
||||
*/ |
||||
String getMaxNo(String date); |
||||
|
||||
/** |
||||
* 获取路线的信息 |
||||
*/ |
||||
InspectionPlan getDetail(String planNo); |
||||
|
||||
} |
@ -0,0 +1,32 @@ |
||||
package org.energy.modules.inspection.service; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionResult; |
||||
import org.energy.modules.inspection.vo.InspectionResultVO; |
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
/** |
||||
* 巡检结果 服务类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
public interface IInspectionResultService extends BaseService<InspectionResult> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionResult |
||||
* @return |
||||
*/ |
||||
IPage<InspectionResultVO> selectInspectionResultPage(IPage<InspectionResultVO> page, InspectionResultVO inspectionResult); |
||||
|
||||
/** |
||||
* 获取最大结果编号 |
||||
* |
||||
* @param taskNo |
||||
*/ |
||||
String getMaxResultNo(String taskNo); |
||||
|
||||
} |
@ -0,0 +1,46 @@ |
||||
package org.energy.modules.inspection.service; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.vo.InspectionRouteVO; |
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检路线 服务类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
public interface IInspectionRouteService extends BaseService<InspectionRoute> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionRoute |
||||
* @return |
||||
*/ |
||||
IPage<InspectionRouteVO> selectInspectionRoutePage(IPage<InspectionRouteVO> page, InspectionRouteVO inspectionRoute); |
||||
|
||||
List<InspectionRouteExcel> export(InspectionRoute InspectionRoute); |
||||
|
||||
/** |
||||
* 获取路线编号 |
||||
*/ |
||||
List<InspectionRoute> getRouteList(); |
||||
|
||||
/** |
||||
* 获取最大任务编号 |
||||
* |
||||
* @param date |
||||
*/ |
||||
String getMaxNo(String date); |
||||
|
||||
/** |
||||
* 获取路线的信息 |
||||
*/ |
||||
InspectionRoute getDetailList(String routeNo); |
||||
} |
@ -0,0 +1,47 @@ |
||||
package org.energy.modules.inspection.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.entity.InspectionTasks; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.inspection.excel.InspectionTasksExcel; |
||||
import org.energy.modules.inspection.vo.InspectionTasksVO; |
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.energy.modules.leger.entity.EquipmentLedger; |
||||
import org.energy.modules.leger.excel.EquipmentLedgerExcel; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检任务 服务类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
public interface IInspectionTasksService extends BaseService<InspectionTasks> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionTasks |
||||
* @return |
||||
*/ |
||||
IPage<InspectionTasksVO> selectInspectionTasksPage(IPage<InspectionTasksVO> page, InspectionTasksVO inspectionTasks); |
||||
|
||||
/** |
||||
* 获取导出数据 |
||||
*/ |
||||
List<InspectionTasksExcel> export(InspectionTasks InspectionTasks); |
||||
|
||||
/** |
||||
* 获取最大任务编号 |
||||
* |
||||
* @param date |
||||
*/ |
||||
String getMaxTaskNo(String date); |
||||
|
||||
List<InspectionTasks> getListByToolsCodeId(String toolsCodeId); |
||||
|
||||
} |
@ -0,0 +1,64 @@ |
||||
package org.energy.modules.inspection.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import io.micrometer.core.instrument.util.StringUtils; |
||||
import org.energy.modules.inspection.entity.InspectionObject; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.excel.InspectionObjectExcel; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.inspection.vo.InspectionObjectVO; |
||||
import org.energy.modules.inspection.mapper.InspectionObjectMapper; |
||||
import org.energy.modules.inspection.service.IInspectionObjectService; |
||||
import com.dayu.daf.core.mp.base.BaseServiceImpl; |
||||
import org.energy.modules.leger.excel.EquipmentLedgerExcel; |
||||
import org.energy.modules.system.service.IDictService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检对象一览 服务实现类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-11 |
||||
*/ |
||||
@Service |
||||
public class InspectionObjectServiceImpl extends BaseServiceImpl<InspectionObjectMapper, InspectionObject> implements IInspectionObjectService { |
||||
@Autowired |
||||
IDictService dictService; |
||||
|
||||
@Override |
||||
public IPage<InspectionObjectVO> selectInspectionObjectPage(IPage<InspectionObjectVO> page, InspectionObjectVO inspectionObject) { |
||||
return page.setRecords(baseMapper.selectInspectionObjectPage(page, inspectionObject)); |
||||
} |
||||
@Override |
||||
public List<InspectionObjectExcel> export(InspectionObjectVO inspectionObject) { |
||||
List<InspectionObjectExcel> list = baseMapper.exportData(inspectionObject); |
||||
list.forEach(item -> { |
||||
if (StringUtils.isNotEmpty(item.getStation())) |
||||
item.setStation(dictService.getValue("station", Integer.parseInt(item.getStation()))); |
||||
if (StringUtils.isNotEmpty(item.getIstatus())) |
||||
item.setIstatus(dictService.getValue("istatus", Integer.parseInt(item.getIstatus()))); |
||||
}); |
||||
return list; |
||||
} |
||||
@Override |
||||
public List<InspectionObject> getObjectList() { |
||||
List<InspectionObject> list = baseMapper.getObjectList(); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public String getMaxNo(String date){ |
||||
String maxNo = baseMapper.getMaxNo(date); |
||||
return maxNo; |
||||
} |
||||
|
||||
@Override |
||||
public InspectionObject getDetailList(String objectNo) { |
||||
InspectionObject DetailList = baseMapper.getDetailList(objectNo); |
||||
return DetailList; |
||||
} |
||||
} |
@ -0,0 +1,52 @@ |
||||
package org.energy.modules.inspection.service.impl; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionPlan; |
||||
import org.energy.modules.inspection.excel.InspectionPlanExcel; |
||||
import org.energy.modules.inspection.vo.InspectionPlanVO; |
||||
import org.energy.modules.inspection.mapper.InspectionPlanMapper; |
||||
import org.energy.modules.inspection.service.IInspectionPlanService; |
||||
import com.dayu.daf.core.mp.base.BaseServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检计划 服务实现类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@Service |
||||
public class InspectionPlanServiceImpl extends BaseServiceImpl<InspectionPlanMapper, InspectionPlan> implements IInspectionPlanService { |
||||
|
||||
@Override |
||||
public IPage<InspectionPlanVO> selectInspectionPlanPage(IPage<InspectionPlanVO> page, InspectionPlanVO inspectionPlan) { |
||||
return page.setRecords(baseMapper.selectInspectionPlanPage(page, inspectionPlan)); |
||||
} |
||||
|
||||
@Override |
||||
public List<InspectionPlanExcel> export(InspectionPlan inspectionPlan) { |
||||
List<InspectionPlanExcel> list = baseMapper.exportData(inspectionPlan); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public List<InspectionPlan> getPlanList() { |
||||
List<InspectionPlan> list = baseMapper.getPlanList(); |
||||
return list; |
||||
} |
||||
|
||||
@Override |
||||
public String getMaxNo(String date){ |
||||
String maxNo = baseMapper.getMaxNo(date); |
||||
return maxNo; |
||||
} |
||||
|
||||
@Override |
||||
public InspectionPlan getDetail(String planNo) { |
||||
InspectionPlan detail = baseMapper.getDetail(planNo); |
||||
return detail; |
||||
} |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue