first commit

This commit is contained in:
2026-09-09 11:52:40 +08:00
commit 3295d9be3e
2702 changed files with 673462 additions and 0 deletions
+201
View File
@@ -0,0 +1,201 @@
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:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) 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
(d) 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 {yyyy} {name of copyright owner}
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.
+90
View File
@@ -0,0 +1,90 @@
NutzWk 开源企业级Java Web开发框架
======
[![Build Status](https://travis-ci.org/Wizzercn/NutzWk.png?branch=bootstrap)](https://travis-ci.org/Wizzercn/NutzWk)
[![GitHub release](https://img.shields.io/github/release/Wizzercn/NutzWk.svg)](https://github.com/Wizzercn/NutzWk/releases)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![PowerByNutz](https://img.shields.io/badge/PowerBy-Nutz-green.svg)](https://github.com/nutzam/nutz)
https://nutzwk.wizzer.cn V5演示地址
https://demo.budwk.com V6演示地址
https://budwk.com/donation 捐赠者列表
# 前言
本框架自2012年开始用于商业项目,至今已服务于全国各地公司大大小小数千个项目,行业涉及政务、电商、物联网等,随着个人经验积累及从事行业的不同分别发布了1.x至6.x多个版本,您可以根据项目规模选择不同版本。本项目案例众多,省厅级项目、市级平台、大数据项目、电商平台、物联网平台等等。
我们有强大的后援 —— Nutz 社区支持 https://nutz.cn 及 Nutz 使用手册 https://nutzam.com/core/nutz_preface.html
### QQ交流群
* 1群: 68428921(已满)
* 2群: 24457628
# 版本说明
NutzWk-V5 Mini 微服务单应用版本(一个jar或打成war运行),管理后台 Vue.js + ElementUI,非常适合项目快速开发
* 系统自带多级权限体系、日志系统、缓存系统、定时任务、微信管理、CMS管理、beetl模板语言等基础功能
* 安装必要条件: redis + mysql(支持 MariaDB、Oracle、SqlServer、达梦等)
### 项目启动
* 创建数据库 `budwk-v5-mini` 直接运行 MainLauncher 即可,启动会自动建表初始化数据
* `mvn compile nutzboot:run` mvn运行
* `mvn package nutzboot:shade -Dmaven.javadoc.skip=true -Dmaven.test.skip=true` 生成可执行jar包
* `mvn clean package nutzboot:shade nutzboot:war -Dmaven.javadoc.skip=true -Dmaven.test.skip=true` 生成可执行war包
* 正常启动后访问 http://127.0.0.1:8080/sysadmin 用户名 superadmin 密码 1
# 版本说明
* v6.x - nacos 微服务分布式版本 ```前后端分离,前端 nuxt + vue + elementUI```
* v6.x - zookeeper 微服务分布式版本 ```前后端分离,前端 nuxt + vue + elementUI```
* v6.x - mini 微服务单应用版本(一个 jar 或 war 包) ```前后端分离,前端 nuxt + vue + elementUI```
* v5.x - zookeeper 微服务分布式版本 ```前端 jQuery + bootsrtap 或 jQuery + vue.js + elementUI```
* v5.x - mini 微服务单应用版本(一个 jar 或 war 包) ```前端 jQuery + bootsrtap 或 jQuery + vue.js + elementUI```
* v4.x - 单应用版本(war 包) ```前端 jQuery + bootsrtap```
* v3.x - 单应用版本(war 包) ```前端 jQuery + bootsrtap```
* v1.x - 单应用版本(war 包) ```前端 jQuery + easyUI```
| 版本名称 | 版本特点 | 版本地址 | 运行方式 | 后端主要技术| 前端主要技术 | 浏览器兼容性 |
| ---------|---------| ----------| ----------| ----------|----------|----------|
| BudWk v6.x-nacos | 微服务分布式 + 前后端分离 |[v6.x-nacos](https://github.com/budwk/budwk/tree/v6.x-nacos)| jar,war | nutzboot + dubbo + nacos + shiro | nuxt + vue + elementUI | Chrome,Edge,IE12+ |
| BudWk v6.x-zookeeper | 微服务分布式 + 前后端分离 |[v6.x-zookeeper](https://github.com/budwk/budwk/tree/v6.x-zookeeper)| jar,war | nutzboot + dubbo + zookeeper + shiro | nuxt + vue + elementUI | Chrome,Edge,IE12+ |
| BudWk v6.x-mini | 微服务单应用 + 前后端分离 |[v6.x-mini](https://github.com/budwk/budwk/tree/v6.x-mini)| jar,war | nutzboot + shiro | nuxt + vue + elementUI | Chrome,Edge,IE12+ |
| NutzWk v5.x| 微服务分布式 + 前端混合模式 |[v5.x](https://github.com/Wizzercn/NutzWk/tree/v5.x)| jar,war | nutzboot + dubbo + shiro + beetl | vue + elementUI + jquery 或 jquery + bootstrap 两个版本 | Chrome,IE9+ |
| NutzWk v5.x-mini| 微服务单应用 + 前端混合模式 |[v5.x-mini](https://github.com/Wizzercn/NutzWk/tree/v5.x-mini)| jar,war | nutzboot + shiro + beetl | vue + elementUI + jquery | Chrome,IE9+ |
| NutzWk v4.x| 模块化单应用 |[v4.x](https://github.com/Wizzercn/NutzWk/tree/v4.x)| war | nutz + shiro + beetl | jquery + bootstrap | Chrome,IE7 + |
| NutzWk v3.x| 单应用 |[v3.x](https://github.com/Wizzercn/NutzWk/tree/v3.x)| war | nutz + shiro + beetl 或 velocity 两个版本 | jquery + bootstrap | Chrome,IE7 + |
| NutzWk v1.x| 单应用 |[v1.x](https://github.com/Wizzercn/NutzWk/tree/v1.x)| war | nutz + shiro + velocity | jquery + easyUI | IE6 + |
## 项目部署
* 内置配置文件启动 `nohup java -jar mini.jar &` 带参数 `-Dnutz.profiles.active=prod` 可加载 application-prod.properties 文件
* 外置配置文件启动 `nohup java -Dnutz.boot.configure.properties.dir=/data/budwk/ -jar mini.jar &` 此时加载文件夹所有 *.properties 配置文件
* 生产环境可以使用 [PythonWk](https://github.com/Wizzercn/PythonWk) 进行部署,登陆后台运维中心可在线更新jar包及配置文件等
# 鸣谢
* [@wendal](https://github.com/wendal)
* [@rekoe](https://github.com/Rekoe)
* [@enilu](https://github.com/enilu)
* [@loyalove](https://github.com/loyalove)
* [@threefish](https://github.com/threefish)
# 关于
* 个人提供付费的培训服务,含源码解析、设计思路、疑难解答、项目辅导等
* 联系方式 QQ11624317 微信:wizzer
* 欢迎打赏,以资鼓励 [https://budwk.com/donation](https://budwk.com/donation)
+494
View File
@@ -0,0 +1,494 @@
<?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>
<packaging>jar</packaging>
<groupId>io.v</groupId>
<artifactId>mini</artifactId>
<version>5.3.0</version>
<properties>
<nutzboot.version>2.4.2-SNAPSHOT</nutzboot.version>
<nutz.version>1.r.68-SNAPSHOT</nutz.version>
<mysql-connector-java.version>8.0.16</mysql-connector-java.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
<slf4j.version>1.7.30</slf4j.version>
<logback.version>1.2.3</logback.version>
<easy-captcha.version>1.6.2</easy-captcha.version>
<commons-lang3.version>3.8.1</commons-lang3.version>
<emoji-java.veision>4.0.0</emoji-java.veision>
<jsoup.veision>1.12.1</jsoup.veision>
<pinyin4j.veision>2.5.1</pinyin4j.veision>
<poi.version>4.1.2</poi.version>
<tencentcloud-sdk-java.version>4.0.11</tencentcloud-sdk-java.version>
<lombok.version>1.18.12</lombok.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<v.version>1.0.1</v.version>
</properties>
<url>https://budwk.com</url>
<description>java web development framework, base on budwk and nutz</description>
<developers>
<developer>
<id>wizzercn</id>
<name>Wizzer</name>
<email>wizzer@qq.com</email>
<url>https://wizzer.cn</url>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>io.github.draco1023</groupId>
<artifactId>poi-tl-ext</artifactId>
<version>0.3.17</version>
</dependency>
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.20</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-all-deps</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>vod_api</artifactId>
<version>2.1.5</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<artifactId>bcprov-jdk15on</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>jackson-databind</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
<exclusion>
<artifactId>tencentcloud-sdk-java</artifactId>
<groupId>com.tencentcloudapi</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>
<dependency>
<groupId>io.v</groupId>
<artifactId>vi-nutz</artifactId>
<version>${v.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-lang3</artifactId>
<groupId>org.apache.commons</groupId>
</exclusion>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
<exclusion>
<artifactId>hutool-all</artifactId>
<groupId>cn.hutool</groupId>
</exclusion>
<exclusion>
<artifactId>javax.annotation-api</artifactId>
<groupId>javax.annotation</groupId>
</exclusion>
<exclusion>
<artifactId>juh</artifactId>
<groupId>org.openoffice</groupId>
</exclusion>
<exclusion>
<artifactId>poi</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
<exclusion>
<artifactId>poi-ooxml</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
<exclusion>
<artifactId>poi-ooxml-schemas</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
<exclusion>
<artifactId>ridl</artifactId>
<groupId>org.openoffice</groupId>
</exclusion>
<exclusion>
<artifactId>spring-aop</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>unoil</artifactId>
<groupId>org.openoffice</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.8.0</version>
<!-- <version>3.6.0</version>-->
<!--<exclusions>
<exclusion>
<artifactId>kotlin-stdlib</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</exclusion>
<exclusion>
<artifactId>kotlin-stdlib-common</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</exclusion>
</exclusions>-->
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
<exclusions>
<exclusion>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.56</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-cas</artifactId>
<version>1.6.0</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>${tencentcloud-sdk-java.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
<exclusion>
<artifactId>okhttp</artifactId>
<groupId>com.squareup.okhttp</groupId>
</exclusion>
<exclusion>
<artifactId>okio</artifactId>
<groupId>com.squareup.okio</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>${emoji-java.veision}</version>
</dependency>
<!-- api token web server -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
<exclusions>
<exclusion>
<artifactId>jackson-databind</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>${jsoup.veision}</version>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>${pinyin4j.veision}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!-- json4excel,poi -->
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz-integration-json4excel</artifactId>
<version>${nutz.version}</version>
<exclusions><!-- 手动排除依赖,瘦身 -->
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<artifactId>xmlbeans</artifactId>
<groupId>org.apache.xmlbeans</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-test-junit4</artifactId>
<version>${nutzboot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId>
<version>${easy-captcha.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>-->
<!-- <artifactId>spring-core</artifactId>-->
<!-- <version>4.3.21.RELEASE</version>-->
<!-- </dependency>-->
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-parent</artifactId>
<version>${nutzboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>15</source>
<target>15</target>
<compilerArgs>--enable-preview</compilerArgs>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<encoding>UTF-8</encoding>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.nutz.boot</groupId>
<artifactId>nutzboot-maven-plugin</artifactId>
<version>${nutzboot.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>nutz</id>
<url>https://jfrog.nutz.cn/artifactory/libs-release</url>
</repository>
<repository>
<id>nutz-snapshots</id>
<url>https://jfrog.nutz.cn/artifactory/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nutz-snapshots</id>
<url>https://jfrog.nutz.cn/artifactory/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>
+998
View File
@@ -0,0 +1,998 @@
package io.v.nutz;
import io.v.nutz.proposal.models.ProposalUndertake;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.*;
import io.v.nutz.sys.services.SysTaskService;
import io.v.nutz.sys.services.SysUnitService;
import io.v.nutz.task.services.TaskPlatformService;
import io.v.nutz.web.commons.base.Globals;
import io.v.nutz.web.commons.ext.pubsub.WebPubSub;
import io.v.nutz.web.tags.*;
import org.beetl.core.GroupTemplate;
import org.nutz.boot.NbApp;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.impl.FileSqlManager;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.integration.jedis.JedisAgent;
import org.nutz.integration.shiro.ShiroSessionProvider;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Mirror;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.Mvcs;
import org.nutz.mvc.annotation.*;
import org.quartz.Scheduler;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.servlet.ServletContext;
import java.lang.management.ManagementFactory;
import java.sql.Driver;
import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
/**
* @author wizzer@qq.com
*/
@IocBean(create = "init", depose = "depose")
@Localization(value = "locales/", defaultLocalizationKey = "zh_CN")
@Encoding(input = "UTF-8", output = "UTF-8")
@ChainBy(args = "chain/mvc-chain.json")
@SessionBy(ShiroSessionProvider.class)
@IocBy(args = {
"*io.v.nutz.aop.ViReturnAopLoader",
})
public class MainLauncher {
private static final Log log = Logs.get();
@Inject("refer:$ioc")
private Ioc ioc;
@Inject
private PropertiesProxy conf;
@Inject
private JedisAgent jedisAgent;
@Inject
private WebPubSub webPubSub;//注入一下为了初始化
@Inject
private GroupTemplate groupTemplate;
@Inject
private TaskPlatformService taskPlatformService;
@Inject
private SysTaskService sysTaskService;
@Inject
private Dao dao;
public static void main(String[] args) throws Exception {
NbApp nb = new NbApp().setArgs(args).setPrintProcDoc(true);
nb.getAppContext().setMainPackage("io.v");
nb.run();
}
public static NbApp warMain(ServletContext sc) {
NbApp nb = new NbApp().setPrintProcDoc(true);
nb.getAppContext().setMainPackage("io.v");
return nb;
}
public void init() {
Mvcs.X_POWERED_BY = "BudWK-V5 <budwk.com>";
Globals.AppBase = Mvcs.getServletContext().getContextPath();
Globals.AppRoot = Mvcs.getServletContext().getRealPath("/");
//注册自定义标签
groupTemplate.registerTagFactory("cms_channel_list", () -> ioc.get(CmsChannelListTag.class));
groupTemplate.registerTagFactory("cms_channel", () -> ioc.get(CmsChannelTag.class));
groupTemplate.registerTagFactory("cms_article_list", () -> ioc.get(CmsArticleListTag.class));
groupTemplate.registerTagFactory("cms_article", () -> ioc.get(CmsArticleTag.class));
groupTemplate.registerTagFactory("cms_link_list", () -> ioc.get(CmsLinkListTag.class));
init_sys();
init_task();
initUndertake();
ioc.get(Globals.class);
}
@Inject
private SysUnitService sysUnitService;
@Inject("ProposalUndertake")
private ViService<ProposalUndertake> proposalUndertakeService;
private void initUndertake() {
if (proposalUndertakeService.count() == 0) {
List<Sys_unit> unitLevel2 = sysUnitService.query(Cnd.where("unitlevel", "=", 2).and("parentId", "IS NOT", null).asc("unitcode"));
if (!unitLevel2.isEmpty()) {
unitLevel2.forEach(v -> {
ProposalUndertake undertake = new ProposalUndertake();
undertake.setIsEnable(Boolean.TRUE);
undertake.setUnitCode(v.getUnitcode());
undertake.setUnitName(v.getName());
proposalUndertakeService.insert(undertake);
});
}
}
}
private void init_task() {
if (!dao.exists("sys_qrtz_triggers")) {
//执行Quartz SQL脚本
String dbType = dao.getJdbcExpert().getDatabaseType();
log.debug("dbType:::" + dbType);
FileSqlManager fmq = new FileSqlManager("quartz/" + dbType.toLowerCase() + ".sql");
List<Sql> sqlListq = fmq.createCombo(fmq.keys());
Sql[] sqlsq = sqlListq.toArray(new Sql[sqlListq.size()]);
for (Sql sql : sqlsq) {
dao.execute(sql);
}
}
if (0 == sysTaskService.count()) {
//定时任务示例
Sys_task task = new Sys_task();
task.setDisabled(true);
task.setName("测试任务");
task.setJobClass("io.v.nutz.task.job.TestJob");
task.setCron("*/5 * * * * ?");
task.setData("{\"hi\":\"Wechat:wizzer | send red packets of support,thank u\"}");
task.setNote("微信号:wizzer | 欢迎发送红包以示支持,多谢。。");
sysTaskService.insert(task);
}
}
private void init_sys() {
//通过POJO类创建表结构
try {
Daos.createTablesInPackage(dao, "io.v", false);
//通过POJO类修改表结构
Daos.migration(dao, "io.v", true, false);
} catch (Exception e) {
e.printStackTrace();
}
// 若必要的数据表不存在,则初始化数据库
if (0 == dao.count(Sys_user.class)) {
//初始化配置表
Sys_config conf = new Sys_config();
conf.setConfigKey("AppName");
conf.setConfigValue("BudWk-V5 mini");
conf.setNote("系统名称");
dao.insert(conf);
conf = new Sys_config();
conf.setConfigKey("AppShrotName");
conf.setConfigValue("budwk");
conf.setNote("系统短名称");
dao.insert(conf);
conf = new Sys_config();
conf.setConfigKey("AppDomain");
conf.setConfigValue("http://127.0.0.1:8080");
conf.setNote("系统域名");
dao.insert(conf);
conf = new Sys_config();
conf.setConfigKey("AppFileDomain");
conf.setConfigValue("");
conf.setNote("文件访问域名");
dao.insert(conf);
conf = new Sys_config();
conf.setConfigKey("AppUploadBase");
conf.setConfigValue("/upload");
conf.setNote("文件访问路径");
dao.insert(conf);
conf = new Sys_config();
conf.setConfigKey("SessionOnlyOne");
conf.setConfigValue("true");
conf.setNote("用户登录只允许一个Session实例(为true时退出登录会更新sys_user表在线状态)");
dao.insert(conf);
conf = new Sys_config();
conf.setConfigKey("WebNotification");
conf.setConfigValue("false");
conf.setNote("启用浏览器通知");
dao.insert(conf);
//初始化单位
Sys_unit unit = new Sys_unit();
unit.setPath("0001");
unit.setName("系统管理");
unit.setAliasName("System");
unit.setUnitcode("system");
unit.setLocation(0);
unit.setAddress("银河-太阳系-地球");
unit.setEmail("wizzer@qq.com");
unit.setTelephone("");
unit.setHasChildren(false);
unit.setParentId("");
unit.setWebsite("https://budwk.com");
Sys_unit dbunit = dao.insert(unit);
//初始化菜单
List<Sys_menu> menuList = new ArrayList<Sys_menu>();
Sys_menu menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001");
menu.setName("系统");
menu.setNote("系统");
menu.setAliasName("System");
menu.setIcon("ti-settings");
menu.setLocation(0);
menu.setHref("");
menu.setTarget("");
menu.setShowit(true);
menu.setHasChildren(true);
menu.setParentId("");
menu.setType("menu");
menu.setPermission("sys");
Sys_menu m0 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("00010001");
menu.setName("系统管理");
menu.setNote("系统管理");
menu.setAliasName("Manager");
menu.setIcon("ti-settings");
menu.setLocation(1);
menu.setHref("");
menu.setTarget("");
menu.setShowit(true);
menu.setHasChildren(true);
menu.setParentId(m0.getId());
menu.setType("menu");
menu.setPermission("sys.manager");
Sys_menu m1 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010001");
menu.setName("单位管理");
menu.setAliasName("Unit");
menu.setLocation(0);
menu.setHref("/platform/sys/unit");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.unit");
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu m2 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100010001");
menu.setName("添加单位");
menu.setAliasName("Add");
menu.setLocation(0);
menu.setShowit(false);
menu.setPermission("sys.manager.unit.add");
menu.setParentId(m2.getId());
menu.setType("data");
Sys_menu m21 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100010002");
menu.setName("修改单位");
menu.setAliasName("Edit");
menu.setLocation(0);
menu.setShowit(false);
menu.setPermission("sys.manager.unit.edit");
menu.setParentId(m2.getId());
menu.setType("data");
Sys_menu m22 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100010003");
menu.setName("删除单位");
menu.setAliasName("Delete");
menu.setLocation(0);
menu.setShowit(false);
menu.setPermission("sys.manager.unit.delete");
menu.setParentId(m2.getId());
menu.setType("data");
Sys_menu m23 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010002");
menu.setName("用户管理");
menu.setAliasName("User");
menu.setLocation(0);
menu.setHref("/platform/sys/user");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.user");
menu.setHasChildren(false);
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu m3 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100020001");
menu.setName("添加用户");
menu.setAliasName("Add");
menu.setLocation(0);
menu.setShowit(false);
menu.setPermission("sys.manager.user.add");
menu.setParentId(m3.getId());
menu.setType("data");
Sys_menu m31 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100020002");
menu.setName("修改用户");
menu.setAliasName("Edit");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.user.edit");
menu.setParentId(m3.getId());
menu.setType("data");
Sys_menu m32 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100020003");
menu.setName("删除用户");
menu.setAliasName("Delete");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.user.delete");
menu.setParentId(m3.getId());
menu.setType("data");
Sys_menu m33 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010003");
menu.setName("角色管理");
menu.setAliasName("Role");
menu.setLocation(0);
menu.setHref("/platform/sys/role");
menu.setShowit(true);
menu.setPermission("sys.manager.role");
menu.setTarget("data-pjax");
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu m4 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100030001");
menu.setName("添加角色");
menu.setAliasName("Add");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.role.add");
menu.setParentId(m4.getId());
menu.setType("data");
Sys_menu m41 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100030002");
menu.setName("修改角色");
menu.setAliasName("Edit");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.role.edit");
menu.setParentId(m4.getId());
menu.setType("data");
Sys_menu m42 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100030003");
menu.setName("删除角色");
menu.setAliasName("Delete");
menu.setLocation(3);
menu.setShowit(false);
menu.setPermission("sys.manager.role.delete");
menu.setParentId(m4.getId());
menu.setType("data");
Sys_menu m43 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100030004");
menu.setName("分配菜单");
menu.setAliasName("SetMenu");
menu.setLocation(4);
menu.setShowit(false);
menu.setPermission("sys.manager.role.menu");
menu.setParentId(m4.getId());
menu.setType("data");
Sys_menu m44 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100030005");
menu.setName("分配用户");
menu.setAliasName("SetUser");
menu.setLocation(5);
menu.setShowit(false);
menu.setPermission("sys.manager.role.user");
menu.setParentId(m4.getId());
menu.setType("data");
Sys_menu m45 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010004");
menu.setName("菜单管理");
menu.setAliasName("Menu");
menu.setLocation(0);
menu.setHref("/platform/sys/menu");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.menu");
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu m5 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100040001");
menu.setName("添加菜单");
menu.setAliasName("Add");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.menu.add");
menu.setParentId(m5.getId());
menu.setType("data");
Sys_menu m51 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100040002");
menu.setName("修改菜单");
menu.setAliasName("Edit");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.menu.edit");
menu.setParentId(m5.getId());
menu.setType("data");
Sys_menu m52 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100040003");
menu.setName("删除菜单");
menu.setAliasName("Delete");
menu.setLocation(3);
menu.setShowit(false);
menu.setPermission("sys.manager.menu.delete");
menu.setParentId(m5.getId());
menu.setType("data");
Sys_menu m53 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010005");
menu.setName("系统参数");
menu.setAliasName("Param");
menu.setLocation(0);
menu.setHref("/platform/sys/conf");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.conf");
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu m6 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100050001");
menu.setName("添加参数");
menu.setAliasName("Add");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.conf.add");
menu.setParentId(m6.getId());
menu.setType("data");
Sys_menu m61 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100050002");
menu.setName("修改参数");
menu.setAliasName("Edit");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.conf.edit");
menu.setParentId(m6.getId());
menu.setType("data");
Sys_menu m62 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100050003");
menu.setName("删除参数");
menu.setAliasName("Delete");
menu.setLocation(3);
menu.setShowit(false);
menu.setPermission("sys.manager.conf.delete");
menu.setParentId(m6.getId());
menu.setType("data");
Sys_menu m63 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010006");
menu.setName("日志管理");
menu.setAliasName("Log");
menu.setLocation(0);
menu.setHref("/platform/sys/log");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.log");
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu m7 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100060001");
menu.setName("清除日志");
menu.setAliasName("Delete");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.log.delete");
menu.setParentId(m7.getId());
menu.setType("data");
Sys_menu m71 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010007");
menu.setName("定时任务");
menu.setAliasName("Task");
menu.setLocation(0);
menu.setHref("/platform/sys/task");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.task");
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu m8 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100070001");
menu.setName("添加任务");
menu.setAliasName("Add");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.task.add");
menu.setParentId(m8.getId());
menu.setType("data");
Sys_menu m81 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100070002");
menu.setName("修改任务");
menu.setAliasName("Edit");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.task.edit");
menu.setParentId(m8.getId());
menu.setType("data");
Sys_menu m82 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100070003");
menu.setName("删除任务");
menu.setAliasName("Delete");
menu.setLocation(3);
menu.setShowit(false);
menu.setPermission("sys.manager.task.delete");
menu.setParentId(m8.getId());
menu.setType("data");
Sys_menu m83 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010008");
menu.setName("自定义路由");
menu.setAliasName("Route");
menu.setLocation(0);
menu.setHref("/platform/sys/route");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.route");
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu m9 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100080001");
menu.setName("添加路由");
menu.setAliasName("Add");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.route.add");
menu.setParentId(m9.getId());
menu.setType("data");
Sys_menu m91 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100080002");
menu.setName("修改路由");
menu.setAliasName("Edit");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.route.edit");
menu.setParentId(m9.getId());
menu.setType("data");
Sys_menu m92 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100080003");
menu.setName("删除路由");
menu.setAliasName("Delete");
menu.setLocation(3);
menu.setShowit(false);
menu.setPermission("sys.manager.route.delete");
menu.setParentId(m9.getId());
menu.setType("data");
Sys_menu m93 = dao.insert(menu);
menu = new Sys_menu();
menu.setParentId(m0.getId());
menu.setDisabled(false);
menu.setPath("00010002");
menu.setName("系统配置");
menu.setAliasName("Config");
menu.setType("menu");
menu.setLocation(2);
menu.setIcon("ti-pencil-alt");
menu.setShowit(true);
menu.setPermission("sys.config");
menu.setHasChildren(true);
Sys_menu pp1 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100020001");
menu.setName("数据字典");
menu.setAliasName("Dict");
menu.setLocation(0);
menu.setHref("/platform/sys/dict");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.dict");
menu.setParentId(pp1.getId());
menu.setType("menu");
Sys_menu d = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000200010001");
menu.setName("添加字典");
menu.setAliasName("Add");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.dict.add");
menu.setParentId(d.getId());
menu.setType("data");
Sys_menu d1 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000200010002");
menu.setName("修改字典");
menu.setAliasName("Edit");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.dict.edit");
menu.setParentId(d.getId());
menu.setType("data");
Sys_menu d2 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000200010003");
menu.setName("删除字典");
menu.setAliasName("Delete");
menu.setLocation(3);
menu.setShowit(false);
menu.setPermission("sys.manager.dict.delete");
menu.setParentId(d.getId());
menu.setType("data");
Sys_menu d3 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100020002");
menu.setName("密钥管理");
menu.setAliasName("Api");
menu.setLocation(0);
menu.setHref("/platform/sys/api");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.api");
menu.setParentId(pp1.getId());
menu.setType("menu");
Sys_menu appManger = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000200020001");
menu.setName("添加密钥");
menu.setAliasName("Add");
menu.setLocation(0);
menu.setShowit(false);
menu.setPermission("sys.manager.api.add");
menu.setParentId(appManger.getId());
menu.setType("data");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000200020002");
menu.setName("修改密钥");
menu.setAliasName("Edit");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.api.edit");
menu.setParentId(appManger.getId());
menu.setType("data");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000200020003");
menu.setName("删除密钥");
menu.setAliasName("Delete");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.api.delete");
menu.setParentId(appManger.getId());
menu.setType("data");
dao.insert(menu);
//消息中心及消息管理
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("00010003");
menu.setName("消息中心");
menu.setNote("消息中心");
menu.setAliasName("InnerMsg");
menu.setIcon("ti-bell");
menu.setLocation(0);
menu.setHref("");
menu.setTarget("");
menu.setShowit(true);
menu.setHasChildren(true);
menu.setParentId(m0.getId());
menu.setType("menu");
menu.setPermission("sys.msg");
Sys_menu msg0 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100030001");
menu.setName("全部消息");
menu.setAliasName("All");
menu.setLocation(0);
menu.setHref("/platform/sys/msg/user/all");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.msg.all");
menu.setParentId(msg0.getId());
menu.setType("menu");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100030002");
menu.setName("未读消息");
menu.setAliasName("Unread");
menu.setLocation(1);
menu.setHref("/platform/sys/msg/user/unread");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.msg.unread");
menu.setParentId(msg0.getId());
menu.setType("menu");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100030003");
menu.setName("已读消息");
menu.setAliasName("Read");
menu.setLocation(2);
menu.setHref("/platform/sys/msg/user/read");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.msg.read");
menu.setParentId(msg0.getId());
menu.setType("menu");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100010009");
menu.setName("消息管理");
menu.setAliasName("Msg");
menu.setLocation(0);
menu.setHref("/platform/sys/msg");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.manager.msg");
menu.setParentId(m1.getId());
menu.setType("menu");
Sys_menu msgManger = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100090001");
menu.setName("添加消息");
menu.setAliasName("Add");
menu.setLocation(0);
menu.setShowit(false);
menu.setPermission("sys.manager.msg.add");
menu.setParentId(msgManger.getId());
menu.setType("data");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100090002");
menu.setName("修改消息");
menu.setAliasName("Edit");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.manager.msg.edit");
menu.setParentId(msgManger.getId());
menu.setType("data");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000100090003");
menu.setName("删除消息");
menu.setAliasName("Delete");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.manager.msg.delete");
menu.setParentId(msgManger.getId());
menu.setType("data");
dao.insert(menu);
//运维中心
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("00010004");
menu.setName("运维中心");
menu.setNote("运维中心");
menu.setAliasName("Operation");
menu.setIcon("ti-shield");
menu.setLocation(0);
menu.setHref("");
menu.setTarget("");
menu.setShowit(true);
menu.setHasChildren(true);
menu.setParentId(m0.getId());
menu.setType("menu");
menu.setPermission("sys.operation");
Sys_menu op0 = dao.insert(menu);
//应用管理
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("000100040002");
menu.setName("应用管理");
menu.setAliasName("App");
menu.setLocation(0);
menu.setHref("/platform/sys/app");
menu.setTarget("data-pjax");
menu.setShowit(true);
menu.setPermission("sys.operation.app");
menu.setParentId(op0.getId());
menu.setType("menu");
Sys_menu op02 = dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000400020001");
menu.setName("配置文件管理");
menu.setAliasName("AppConfig");
menu.setLocation(1);
menu.setShowit(false);
menu.setPermission("sys.operation.app.conf");
menu.setParentId(op02.getId());
menu.setType("data");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000400020002");
menu.setName("Jar包管理");
menu.setAliasName("AppJar");
menu.setLocation(2);
menu.setShowit(false);
menu.setPermission("sys.operation.app.jar");
menu.setParentId(op02.getId());
menu.setType("data");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000400020003");
menu.setName("实例管理");
menu.setAliasName("AppInstance");
menu.setLocation(3);
menu.setShowit(false);
menu.setPermission("sys.operation.app.instance");
menu.setParentId(op02.getId());
menu.setType("data");
dao.insert(menu);
menu = new Sys_menu();
menu.setDisabled(false);
menu.setPath("0001000400020004");
menu.setName("修改日志等级");
menu.setAliasName("Loglevel");
menu.setLocation(4);
menu.setShowit(false);
menu.setPermission("sys.operation.app.loglevel");
menu.setParentId(op02.getId());
menu.setType("data");
dao.insert(menu);
//初始化角色
Sys_role role = new Sys_role();
role.setName("公共角色");
role.setCode("public");
role.setAliasName("Public");
role.setNote("All user has role");
role.setUnitid("");
role.setDisabled(false);
dao.insert(role);
role = new Sys_role();
role.setName("系统管理员");
role.setCode("sysadmin");
role.setAliasName("Sysadmin");
role.setNote("System Admin");
role.setUnitid("");
role.setMenus(menuList);
role.setDisabled(false);
Sys_role dbrole = dao.insert(role);
//初始化用户
Sys_user user = new Sys_user();
user.setLoginname("superadmin");
user.setUsername("超级管理员");
user.setCreateAt(System.currentTimeMillis());
//String slat=R.UU32();
//new Sha256Hash("1",ByteSource.Util.bytes(s), 1024).toHex();
user.setSalt("r5tdr01s7uglfokpsdmtu15602");
user.setPassword("1bba9287ebc50b766bff84273d11ccefaa7a8da95d078960f05f116e9d970fb0");
user.setLoginIp("127.0.0.1");
user.setLoginAt(0L);
user.setLoginCount(0);
user.setEmail("wizzer@qq.com");
user.setLoginTheme("palette.3.css");
user.setLoginBoxed(false);
user.setLoginScroll(true);
user.setLoginSidebar(false);
user.setLoginPjax(true);
user.setUnitid(dbunit.getId());
Sys_user dbuser = dao.insert(user);
//不同的插入数据方式(安全)
dao.insert("sys_user_unit", org.nutz.dao.Chain.make("userId", dbuser.getId()).add("unitId", dbunit.getId()));
dao.insert("sys_user_role", Chain.make("userId", dbuser.getId()).add("roleId", dbrole.getId()));
//执行SQL脚本
FileSqlManager fm = new FileSqlManager("db/");
List<Sql> sqlList = fm.createCombo(fm.keys());
Sql[] sqls = sqlList.toArray(new Sql[sqlList.size()]);
for (Sql sql : sqls) {
dao.execute(sql);
}
//菜单关联到角色
dao.execute(Sqls.create("INSERT INTO sys_role_menu(roleId,menuId) SELECT @roleId,id FROM sys_menu").setParam("roleId", dbrole.getId()));
//消息中心放第一个位置
dao.execute(Sqls.create("update sys_menu set location=0 where path='00010003'"));
//初始化自定义路由
Sys_route route = new Sys_route();
route.setDisabled(false);
route.setUrl("/sysadmin");
route.setToUrl("/platform/login");
route.setType("hide");
dao.insert(route);
}
}
public void depose() {
// 非mysql数据库,或多webapp共享mysql驱动的话,以下语句删掉
try {
Mirror.me(Class.forName("com.mysql.jdbc.AbandonedConnectionCleanupThread")).invoke(null, "shutdown");
} catch (Throwable e) {
}
// 解决quartz有时候无法停止的问题
try {
ioc.get(Scheduler.class).shutdown(true);
} catch (Exception e) {
}
// 解决com.alibaba.druid.proxy.DruidDriver和com.mysql.jdbc.Driver在reload时报warning的问题
// 多webapp共享mysql驱动的话,以下语句删掉
Enumeration<Driver> en = DriverManager.getDrivers();
while (en.hasMoreElements()) {
try {
Driver driver = en.nextElement();
String className = driver.getClass().getName();
log.debug("deregisterDriver: " + className);
DriverManager.deregisterDriver(driver);
} catch (Exception e) {
}
}
try {
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName("com.alibaba.druid:type=MockDriver");
if (mbeanServer.isRegistered(objectName))
mbeanServer.unregisterMBean(objectName);
objectName = new ObjectName("com.alibaba.druid:type=DruidDriver");
if (mbeanServer.isRegistered(objectName))
mbeanServer.unregisterMBean(objectName);
} catch (Exception ex) {
}
}
}
@@ -0,0 +1,183 @@
package io.v.nutz.activity.controller.applets;
import io.v.nutz.activity.models.ActivitySchoolApply;
import io.v.nutz.activity.services.ActivitySchoolApplyService;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_user;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.adaptor.JsonAdaptor;
import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.List;
/**
* @author: Aaron
* @create: 2021-03-16 10:19
* @description: 小程序活动
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/applets/list")
public class ActivityListController {
@Inject("Sys_user")
private ViService<Sys_user> sysUserService;
@Inject
private ActivitySchoolService activitySchoolService;
@Inject
private ActivitySchoolApplyService activitySchoolApplyService;
@At
@ViReturn
public Object pageData(PageForm page, String userId, String time) {
Sql sql = Sqls.create("""
SELECT
school.id,
school.`name`,
school.address,
school.applyStartTime,
school.applyEndTime,
school.startTime,
school.endTime,
school.image,
(SELECT count( 1 ) FROM activity_school_apply app WHERE app.activityId = school.id AND app.`status` = 2 ) personNum,
(SELECT count( 1 ) FROM activity_school_apply app WHERE app.activityId = school.id AND ( app.applyUser = @userid OR app.userId = @userid )) > 0 applied
FROM
activity_school school
LEFT JOIN activity_school_apply asa ON asa.activityId = school.id
$condition
""").setParam("userid", userId);
CndPlus cnd = CndPlus.create();
cnd.and("school.close", "!=", true);
cnd.and("school.isSave", "!=", true);
cnd.where().andLike("school.applyWay ", "3");
if (time.equals("recent")) {
cnd.and(new Static("CURRENT_DATE() < school.endTime"));
} else if (time.equals("history")) {
cnd.and(new Static("CURRENT_DATE() > school.endTime"));
}
if (Strings.isNotBlank(userId)) {
cnd.and("asa.applyUser", "=", userId);
}
cnd.groupBy("school.id");
cnd.desc("school.startTime");
sql.setCondition(cnd);
return activitySchoolService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
public Object getActivity(String id, String userId) {
Sql sql = Sqls.create("""
SELECT
school.id,
school.`name`,
school.address,
school.applyStartTime,
school.applyEndTime,
school.startTime,
school.endTime,
school.image,
school.applyWay,
school.eventNotification,
(SELECT count( 1 ) FROM activity_school_apply app WHERE app.activityId = school.id AND app.`status` = 2 ) personNum,
(SELECT count( 1 ) FROM activity_school_apply app WHERE app.activityId = school.id AND ( app.applyUser = @userId OR app.userId = @userid )) > 0 applied
FROM
activity_school school
WHERE
school.id = @id
$condition
""").setParam("id", id).setParam("userId", userId);
return activitySchoolService.fetch(sql);
}
@At
@ViReturn
@AdaptBy(type = JsonAdaptor.class)
public Object doApply(@Param("apply") ActivitySchoolApply apply) {
apply.setStatus(2);
activitySchoolApplyService.insert(apply);
return null;
}
@At
@ViReturn
@AdaptBy(type = JsonAdaptor.class)
public Object doUniteApply(@Param("apply") List<ActivitySchoolApply> apply, @Param("activityId") String activityId, @Param("unionId") String unionId) {
activitySchoolApplyService.clear(Cnd.where("activityId", "=", activityId).and("unionId", "=", unionId));
apply.forEach(v -> {
v.setStatus(2);
v.setActivityId(activityId);
activitySchoolApplyService.insert(v);
});
return null;
}
@At
@ViReturn
@AdaptBy(type = JsonAdaptor.class)
public Object removeApply(@Param("activityId") String activityId, @Param("userId") String userId) {
activitySchoolApplyService.clear(Cnd.where("activityId", "=", activityId).and("applyUser", "=", userId));
return null;
}
@At
@ViReturn
@AdaptBy(type = JsonAdaptor.class)
public Object findUser(@Param("userId") String userId, @Param("searchName") String searchName) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT id applyUser, loginname, username, sex, mobile, unitid unitId, unionid unionId FROM `user` $condition
""").setParam("userId", userId).setParam("roleId", Roles.UNION_MANGER);
cnd.and("unionid", "in", "(SELECT sur.unionid FROM sys_user_role sur WHERE sur.userId = '" + userId + "' AND sur.roleId = '" + Roles.UNION_MANGER + "')");
if (Strings.isNotBlank(searchName)) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.andLike("username", searchName).orLike("loginname", searchName);
cnd.and(group);
}
sql.setCondition(cnd);
return sysUserService.listMap(sql);
}
@At
@ViReturn
@AdaptBy(type = JsonAdaptor.class)
public Object getApplyPerson(@Param("activityId") String activityId, @Param("unionId") String unionId) {
Cnd cnd = Cnd.NEW();
cnd.and("activityId", "=", activityId).and("unionId", "=", unionId);
return activitySchoolApplyService.query(cnd);
}
}
@@ -0,0 +1,565 @@
package io.v.nutz.activity.controller.basic;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivityUserCnd;
import io.v.nutz.activity.models.ActivityUserScope;
import io.v.nutz.activity.services.ActivityBasicScopeService;
import io.v.nutz.activity.template.UserTemp;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.SimpleService;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.sys.models.Sys_role;
import io.v.nutz.util.ViTool;
import io.v.nutz.web.commons.utils.ShiroUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ArrayUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.dao.util.cri.Static;
import org.nutz.integration.jedis.RedisService;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.*;
import org.nutz.mvc.upload.TempFile;
import org.nutz.mvc.upload.UploadAdaptor;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author zxy
* @Description 活动人员分组设置
* @createTime 2022年01月04日 10:15:00
*/
@IocBean
@At("/platform/activity/basic/scope")
@Ok("json:full")
@Slf4j
public class ActivityBasicScopeController {
@Inject
private SimpleService simpleService;
@Inject
private RedisService redisService;
@Inject
private ActivityBasicScopeService activityBasicScopeService;
@Inject
private Dao dao;
@At("")
@Ok("beetl:platform/activity/basic/ActivityScope.html")
@RequiresPermissions("activity.basic.scope")
public void index() {
}
/**
* 查询可以设置活动的人员
*
* @param pageForm 页面形式
* @param unionId 工会id
* @param unitId 单位id
* @param personTypes 人类型
* @param userStates 用户状态
* @param memberTypes 成员类型
* @param sexTypes 性类型
* @param age 年龄
* @param teacherMeetingId 教师会议id
* @param roleIds 角色id
* @param userId 用户id
* @param clubId 俱乐部id
* @param reverseSelection 逆向选择
* @return {@link Object}
*/
@At
@ViReturn
@POST
@RequiresPermissions("activity.basic.scope")
public Object pageData(PageForm pageForm,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "personTypes", required = false) String[] personTypes,
@Param(value = "userStates", required = false) String[] userStates,
@Param(value = "memberTypes", required = false) String[] memberTypes,
@Param(value = "sexTypes", required = false) String[] sexTypes,
@Param(value = "months", required = false) String[] months,
@Param(value = "age", required = false) String[] age,
@Param(value = "teacherMeetingId", required = false) String teacherMeetingId,
@Param(value = "roleIds", required = false) String[] roleIds,
@Param(value = "userId", required = false) String[] userId,
@Param(value = "clubId", required = false) String clubId,
@Param(value = "reverseSelection") boolean reverseSelection,
@Param(value = "activityGroupId", required = false) Integer activityGroupId,
@Param(value = "activityUserCnd", required = false) String activityUserCndStr,
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey) {
Sql sql = Sqls.create("""
SELECT
DISTINCT(u.id) as id,
u.loginname AS loginName,
u.username AS userName,
u.sex,
DATE_FORMAT(u.birthday, '%Y-%m') birthday,
u.mobile,
u.personType,
u.userState,
u.unitname AS unitName,
u.unionname AS unionName,
TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) AS age
FROM
`user` u
LEFT JOIN sys_user_role sur on sur.userid = u.id
LEFT JOIN sys_club_user clubuser ON clubuser.userid=u.id
$condition
""");
try {
Cnd cnd = getCnd(pageForm, unionId, unitId, personTypes, userStates, memberTypes, sexTypes, months, age, teacherMeetingId, roleIds, userId, clubId, reverseSelection, activityGroupId, activityUserCndStr);
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
List<String> loginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
cnd.andEX("u.loginname", "in", loginNames);
}
sql.setCondition(cnd);
return simpleService.list(pageForm, sql);
} catch (NumberFormatException e) {
return Result.error(e.getMessage() + "请输入数字类型的值");
} catch (Exception e) {
return Result.error(e.getMessage());
}
}
/**
* 设置活动人员
*
* @param unionId 工会id
* @param unitId 单位id
* @param personTypes 人员类型
* @param userStates 在职状态
* @return Result
*/
@At
@ViReturn
@POST
@RequiresPermissions("activity.basic.scope")
public Object doSetActivityUser(PageForm pageForm,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "personTypes", required = false) String[] personTypes,
@Param(value = "userStates", required = false) String[] userStates,
@Param(value = "memberTypes", required = false) String[] memberTypes,
@Param(value = "sexTypes", required = false) String[] sexTypes,
@Param(value = "months", required = false) String[] months,
@Param(value = "age", required = false) String[] age,
@Param(value = "activityGroupId", required = false) Integer activityGroupId,
@Param(value = "setGroupType", required = false) Integer setGroupType,
@Param(value = "setGroupId", required = false) Integer setGroupId,
@Param(value = "setGroupName", required = false) String setGroupName,
@Param(value = "teacherMeetingId", required = false) String teacherMeetingId,
@Param(value = "roleIds", required = false) String[] roleIds,
@Param(value = "userId", required = false) String[] userId,
@Param(value = "clubId", required = false) String clubId,
@Param(value = "reverseSelection") boolean reverseSelection,
@Param(value = "activityUserCnd", required = false) String activityUserCndStr,
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey) {
Sql sql = Sqls.create("""
SELECT DISTINCT
( u.id ) AS userId
FROM
`user` u
LEFT JOIN sys_user_role sur ON sur.userid = u.id
LEFT JOIN sys_club_user clubuser ON clubuser.userid=u.id
$condition
""");
Cnd cnd = getCnd(pageForm, unionId, unitId, personTypes, userStates, memberTypes, sexTypes, months, age, teacherMeetingId, roleIds, userId, clubId, reverseSelection, activityGroupId, activityUserCndStr);
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
List<String> loginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
cnd.andEX("u.loginname", "in", loginNames);
}
sql.setCondition(cnd);
sql.setCallback(Sqls.callback.entities());
sql.setEntity(dao.getEntity(ActivityUserScope.class));
dao.execute(sql);
List<ActivityUserScope> list = sql.getList(ActivityUserScope.class);
NutMap groupMap = null;
int maxCount = 0;
if (setGroupType == 1) {
groupMap = simpleService.fetch(Sqls.create("select groupName from activity_user_scope where groupId = @groupId").setParam("groupId", setGroupId));
} else if (setGroupType == 2) {
maxCount = simpleService.count(Sqls.create("select max(groupId) from activity_user_scope"));
}
for (ActivityUserScope userScope : list) {
if (setGroupType == 1) {
userScope.setGroupId(setGroupId);
userScope.setGroupName(groupMap.getString("groupName"));
} else if (setGroupType == 2) {
userScope.setGroupId(maxCount + 1);
userScope.setGroupName(setGroupName);
}
userScope.setCreator((String) ShiroUtil.getPrincipalProperty("id"));
}
if (list.size() < 500) {
dao.insert(list);
return setGroupType == 1 ? setGroupId : maxCount + 1;
}
//多线程插入
activityBasicScopeService.largeDataInsert(list);
return setGroupType == 1 ? setGroupId : maxCount + 1;
}
/**
* 获取组别
*
* @return
*/
@At
@ViReturn
// @RequiresPermissions("activity.basic.scope")
public Object getActivityUserScopeGroup() {
Sql sql = Sqls.create("""
SELECT
groupId,
groupName
FROM
activity_user_scope
$condition
""");
Cnd cnd = Cnd.NEW();
if (!ShiroUtil.hasAnyRoles("sysadmin,H06,H10")) {
if (ShiroUtil.hasAnyRoles(new String[]{"H04", "club01"})) {
cnd.and("creator", "=", ShiroUtil.getPrincipalProperty("id"));
}
}
cnd.and("groupId", "IS NOT", null);
cnd.and("groupName", "IS NOT", null);
cnd.groupBy("groupId");
sql.setCondition(cnd);
return simpleService.listMap(sql);
}
/**
* 查看该人员是否在活动范围中
*
* @param activityGroupId
* @return
*/
@At
@ViReturn
// @RequiresPermissions("activity.basic.scope")
public Object getScopeUser(String activityGroupId, @Param(value = "userId", required = false) String userId) {
String userid = StrUtil.isNotBlank(userId) ? userId : io.v.nutz.util.ShiroUtil.getUserId();
return simpleService.dao().count(ActivityUserScope.class, Cnd.where("groupId", "=", activityGroupId).and("userId", "=", userid));
}
@At
@ViReturn
public Object getRoleListByMenuId(String menuId) {
return simpleService.dao().query(Sys_role.class, Cnd.where("system_name", "=", menuId).desc("code"));
}
/**
* 判断用户权限及获取工会id
*
* @return java.lang.Object
* @author zhf
* @description
*/
@At
@ViReturn
public Object getRolesAndUnion() {
return new NutMap() {{
addv("is_H10", ShiroUtil.hasRole("H10"));
addv("is_A06", ShiroUtil.hasRole("A06"));
addv("is_H04", ShiroUtil.hasRole("H04"));
addv("is_H02", ShiroUtil.hasRole("club01"));
addv("is_H03", ShiroUtil.hasRole("H03"));
addv("is_sysadmin", ShiroUtil.hasRole("sysadmin"));
addv("unionid", Vi.getUnionId());
}};
}
/**
* 获取用户信息表列
* 提供两种方式
*
* @return {@link Object}
*/
@At
@ViReturn
public Object getUserTableColumnInfo() {
try {
//2.从数据库查询
Sql sql = Sqls.create("""
SELECT
COLUMN_NAME,
DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH,
COLUMN_COMMENT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'sys_user'
AND TABLE_SCHEMA = 'gh_nuaa_2021'
""");
List<NutMap> sqlDataList = activityBasicScopeService.listMap(sql);
sqlDataList.forEach(v -> v.put("DATA_TYPE", new String((byte[]) v.get("DATA_TYPE"))));
return sqlDataList;
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
return Result.error(e.getMessage());
}
}
@At
@ViReturn
@RequiresPermissions("activity.basic.scope")
public void doExportUser(PageForm pageForm,
@Param(value = "props", required = false) String props,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "personTypes", required = false) String[] personTypes,
@Param(value = "userStates", required = false) String[] userStates,
@Param(value = "memberTypes", required = false) String[] memberTypes,
@Param(value = "sexTypes", required = false) String[] sexTypes,
@Param(value = "months", required = false) String[] months,
@Param(value = "age", required = false) String[] age,
@Param(value = "teacherMeetingId", required = false) String teacherMeetingId,
@Param(value = "roleIds", required = false) String[] roleIds,
@Param(value = "userId", required = false) String[] userId,
@Param(value = "clubId", required = false) String clubId,
@Param(value = "reverseSelection") boolean reverseSelection,
@Param(value = "activityGroupId", required = false) Integer activityGroupId,
@Param(value = "activityUserCnd", required = false) String activityUserCndStr,
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey,
HttpServletResponse response) {
Sql sql = Sqls.create("""
SELECT
DISTINCT(u.id) as id,
u.loginname AS loginName,
u.username AS userName,
u.sex,
DATE_FORMAT(u.birthday, '%Y-%m-%d') birthday,
u.mobile,
u.personType,
u.userState,
u.unitname AS unitName,
u.unionname AS unionName,
TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) AS age
FROM
`user` u
LEFT JOIN sys_user_role sur on sur.userid = u.id
LEFT JOIN sys_club_user clubuser ON clubuser.userid=u.id
$condition
""");
try {
Cnd cnd = getCnd(pageForm, unionId, unitId, personTypes, userStates, memberTypes, sexTypes, months, age, teacherMeetingId, roleIds, userId, clubId, reverseSelection, activityGroupId, activityUserCndStr);
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
List<String> loginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
cnd.andEX("u.loginname", "in", loginNames);
}
sql.setCondition(cnd);
List<NutMap> map = simpleService.listMap(sql);
List<ExcelExportEntity> entityList = new ArrayList<>();
ExcelExportEntity no = new ExcelExportEntity("序号", "no", 10);
no.setFormat("isAddIndex");
entityList.add(no);
Map<String, String> propMap = Json.fromJson(Map.class, props);
propMap.forEach((k, v) -> {
entityList.add(new ExcelExportEntity(v, k, 40));
});
ViTool.excelResponse(response, "人员名单.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, map);
workbook.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
private Cnd getCnd(PageForm pageForm,
String unionId,
String unitId,
String[] personTypes,
String[] userStates,
String[] memberTypes,
String[] sexTypes,
String[] months,
String[] age,
String teacherMeetingId,
String[] roleIds,
String[] userId,
String clubId,
boolean reverseSelection,
Integer activityGroupId,
String activityUserCndStr) {
String IN_OR_NIN_OP = reverseSelection ? "NOT IN" : "IN";
String EQ_OR_NEQ_OP = reverseSelection ? "!=" : "=";
Cnd cnd = Cnd.NEW();
if (StrUtil.isNotBlank(pageForm.getPageOrderName()) && StrUtil.isNotBlank(pageForm.getPageOrderBy())) {
cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC");
}
if (activityGroupId != null) {
Sql sqlx = Sqls.createf("SELECT userId FROM activity_user_scope where groupId = '%s'", activityGroupId);
cnd.and("u.id", reverseSelection ? "IN" : "NOT IN", sqlx);
}
cnd.andEX("u.id", IN_OR_NIN_OP, userId);
if (Lang.isNotEmpty(memberTypes)) {
if (ArrayUtils.contains(memberTypes, "工会会员")) {
cnd.and("u.member", EQ_OR_NEQ_OP, 1);
}
if (ArrayUtils.contains(memberTypes, "福利会员")) {
cnd.and("u.welfareMember", EQ_OR_NEQ_OP, 1);
}
if (ArrayUtils.contains(memberTypes, "基金会员")) {
cnd.and(new Static(" u.loginname " + IN_OR_NIN_OP + " (select loginname from sick_fund_member)"));
}
}
if (!Lang.isEmptyArray(age)) {
if (!age[1].equals("0")) {
if (reverseSelection) {
cnd.andNot("TIMESTAMPDIFF(YEAR, u.birthday, CURDATE())", "between", age);
} else {
cnd.and("TIMESTAMPDIFF(YEAR, u.birthday, CURDATE())", "between", age);
}
}
}
try {
SqlExpressionGroup sqlExpressionGroup = ActivityUserCnd.formatSql("u", activityUserCndStr, reverseSelection);
if (!sqlExpressionGroup.isEmpty()) {
cnd.and(sqlExpressionGroup);
}
cnd.andEX("u.unionid", EQ_OR_NEQ_OP, unionId);
cnd.andEX("u.unitid", EQ_OR_NEQ_OP, unitId);
cnd.andEX("u.personType", IN_OR_NIN_OP, personTypes);
cnd.andEX("u.userState", IN_OR_NIN_OP, userStates);
cnd.andEX("u.sex", IN_OR_NIN_OP, sexTypes);
cnd.andEX("DATE_FORMAT(u.birthday, '%m')", IN_OR_NIN_OP, months);
cnd.andEX("sur.jdhid", EQ_OR_NEQ_OP, teacherMeetingId);
cnd.andEX("sur.roleid", IN_OR_NIN_OP, roleIds);
cnd.andEX("clubuser.clubid", EQ_OR_NEQ_OP, clubId);
} catch (Exception e) {
throw new RuntimeException(e);
}
return cnd;
}
/**
* 清空查询条件
*
* @param existsLoginNameRedisKey
* @return java.lang.Object
* @author zhf
* @description
*/
@At
@Aop(TransAop.READ_COMMITTED)
@ViReturn
@RequiresPermissions("activity.basic.scope")
public Object clearSearchCnd(String existsLoginNameRedisKey) {
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
redisService.del(existsLoginNameRedisKey);
}
return null;
}
@At
@Aop(TransAop.READ_COMMITTED)
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@RequiresPermissions("activity.basic.scope")
public Object doImport(String groupId, TempFile file) {
String matchUserLoginNamesKey = "ActivityBasicScopeController.doImport.time=" + System.currentTimeMillis();
List<UserTemp> userImportList = ExcelImportUtil.importExcel(file.getFile(), UserTemp.class, new ImportParams());
//判断人员哪些存在哪些不存在
Sql sql = Sqls.queryString("""
SELECT
u.loginname
FROM
sys_user u
""");
dao.execute(sql);
String[] sysLoginNames = (String[]) sql.getResult();
//存在的工号
List<String> existsLoginNames = new ArrayList<>();
for (UserTemp excelUser : userImportList) {
if (ArrayUtil.contains(sysLoginNames, excelUser.getLoginname())) {
existsLoginNames.add(excelUser.getLoginname());
} else {
excelUser.setRemarks("系统查不到此人");
}
}
//匹配不到的用户
List<UserTemp> errorExcelTempUsers = userImportList.stream().filter(v -> StrUtil.isNotBlank(v.getRemarks())).collect(Collectors.toList());
NutMap nutMap = NutMap.NEW();
nutMap.setv("totalCount", userImportList.size());
nutMap.setv("successCount", existsLoginNames.size());
nutMap.setv("errorCount", errorExcelTempUsers.size());
nutMap.setv("errorList", errorExcelTempUsers.stream().map(v -> {
return new NutMap().addv("工号", v.getLoginname()).addv("姓名", v.getUsername()).addv("错误信息", v.getRemarks());
}).collect(Collectors.toList()));
nutMap.setv("existsLoginNameRedisKey", matchUserLoginNamesKey);
//保存存在的工号
if (Lang.isNotEmpty(existsLoginNames)) {
redisService.lpush(matchUserLoginNamesKey, existsLoginNames.toArray(new String[0]));
redisService.expire(matchUserLoginNamesKey, 60 * 3);
}
return Result.success(nutMap);
}
}
@@ -0,0 +1,123 @@
package io.v.nutz.activity.controller.basic;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivityBasicSettings;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.AsyncService;
import io.v.nutz.service.ViService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhf
* @date 2021/2/23 15:44
* @description 活动基础设置
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/basic/basic/settings")
public class ActivityBasicSettingsController {
@Inject("ActivityBasicSettings")
private ViService<ActivityBasicSettings> basicSettingsViService;
@Inject
private AsyncService asyncService;
@At("")
@Ok("beetl:platform/activity/basic/ActivityBasic.html")
@RequiresPermissions("activity.basic.settings")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.basic.settings")
public Object pageData(String parentId, PageForm pageForm) {
CndPlus cnd = CndPlus.create();
cnd.andExcludeEmpty("parentId", "=", parentId);
cnd.asc("code");
return basicSettingsViService.list(pageForm, cnd);
}
@At
@ViReturn
@RequiresPermissions("activity.basic.settings")
public Object getTreeData() {
List list = new ArrayList();
ActivityBasicSettings parentId = basicSettingsViService.fetch(Cnd.where("parentId", "=", "0"));
if (parentId != null) {
parentId.setChild(child(parentId.getId()));
list.add(parentId);
return Result.success().addData(list);
}
return null;
}
private List<ActivityBasicSettings> child(String parentId) {
List<ActivityBasicSettings> basicSettings = basicSettingsViService.query(Cnd.where("parentId", "=", parentId).asc("code"));
basicSettings.forEach(v -> {
v.setChild(child(v.getId()));
});
return basicSettings;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.settings")
public Object doAdd(ActivityBasicSettings activityBasicSettings) {
if (basicSettingsViService.count(Cnd.where("code", "=", activityBasicSettings.getCode())) > 0) {
return Result.error("代码已存在");
}
basicSettingsViService.update(Chain.make("hasChildren", true), Cnd.where("id", "=", activityBasicSettings.getParentId()));
basicSettingsViService.insert(activityBasicSettings);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.settings")
public Object doEditType(ActivityBasicSettings activityBasicSettings) {
basicSettingsViService.updateIgnoreNull(activityBasicSettings);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.settings")
public Object doDelete(String id) {
basicSettingsViService.delete(id);
basicSettingsViService.clear(Cnd.where("parentId", "=", id));
return null;
}
@At
@ViReturn
@RequiresAuthentication
public Object getActivityTwoLevelType(String code) {
ActivityBasicSettings fetch = basicSettingsViService.fetch(Cnd.where("code", "=", code));
List<ActivityBasicSettings> query = basicSettingsViService.query(Cnd.where("parentId", "=", fetch.getId()).asc("code"));
return query;
}
}
@@ -0,0 +1,318 @@
package io.v.nutz.activity.controller.basic;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivityUserScope;
import io.v.nutz.activity.template.UserTemp;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.SimpleService;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.util.ShiroUtil;
import io.v.nutz.util.ViTool;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.integration.jedis.RedisService;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.*;
import org.nutz.mvc.upload.TempFile;
import org.nutz.mvc.upload.UploadAdaptor;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zxy
* @Description TODO
* @createTime 2022年01月04日 10:15:00
*/
@IocBean
@At("/platform/activity/basic/user")
@Ok("json:full")
@Slf4j
public class ActivityBasicUserController {
@Inject
private SimpleService simpleService;
@Inject
private RedisService redisService;
@At("")
@Ok("beetl:platform/activity/basic/ActivityUser.html")
@RequiresPermissions("activity.basic.user")
public void index() {
}
@At
@ViReturn
@POST
@RequiresPermissions("activity.basic.user")
public Object pageData(PageForm pageForm,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "personType", required = false) String personType,
@Param(value = "userState", required = false) String userState,
@Param(value = "groupId", required = false) Integer groupId,
@Param(value = "activityUnionId", required = false) String activityUnionId,
@Param(value = "activityUnitId", required = false) String activityUnitId,
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey) {
Sql sql = Sqls.create("""
SELECT
aus.id,
u.username AS userName,
u.loginname AS loginName,
u.sex,
u.birthday,
u.mobile,
u.personType,
u.userState,
u.unitname AS unitName,
u.unionname AS unionName,
aus.groupId,
aus.groupName,
actun.unionname AS activityUnionName
FROM
activity_user_scope aus
LEFT JOIN `user` u ON u.id = aus.userId
LEFT JOIN activity_basic_unit actit ON actit.id=u.unitid
LEFT JOIN activity_basic_union actun ON actit.unionid=actun.id
$condition
""");
Cnd cnd = Cnd.NEW();
if (StrUtil.isNotBlank(pageForm.getSearchName()) && StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
}
if (StrUtil.isNotBlank(pageForm.getPageOrderName()) && StrUtil.isNotBlank(pageForm.getPageOrderBy())) {
cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC");
}
cnd.andEX("actit.unionid", "=", activityUnionId);
cnd.andEX("actit.id", "=", activityUnitId);
cnd.andEX("aus.groupId", "=", groupId);
cnd.andEX("u.unionid", "=", unionId);
cnd.andEX("u.unitid", "=", unitId);
cnd.andEX("u.personType", "=", personType);
cnd.andEX("u.userState", "=", userState);
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
cnd.andEX("aus.creator", "=", ShiroUtil.getPrincipalProperty("id"));
}
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
List<String> loginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
cnd.andEX("u.loginname", "in", loginNames);
}
sql.setCondition(cnd);
return simpleService.list(pageForm, sql);
}
/**
* 删除一条记录
*
* @param id
* @return
*/
@At
@ViReturn
@RequiresPermissions("activity.basic.user")
public Object doDelete(@Param(value = "id", required = false) String id,
@Param(value = "groupId", required = false) Integer groupId,
@Param(value = "searchKeyword", required = false) String searchKeyword,
@Param(value = "searchName", required = false) String searchName,
@Param(value = "unionId", required = false) String unionId,
@Param(value = "unitId", required = false) String unitId,
@Param(value = "personType", required = false) String personType,
@Param(value = "userState", required = false) String userState,
@Param(value = "existsLoginNameRedisKey", required = false) String existsLoginNameRedisKey) {
List<String> existsLoginNames = new ArrayList<>();
if (StrUtil.isNotBlank(existsLoginNameRedisKey) && redisService.exists(existsLoginNameRedisKey)) {
existsLoginNames = redisService.lrange(existsLoginNameRedisKey, 0, -1);
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
redisService.del(existsLoginNameRedisKey);
}
}
Sql sql = Sqls.create("select id from `user` u $condition");
Cnd userCnd = Cnd.NEW();
if (StrUtil.isNotBlank(searchName) && StrUtil.isNotBlank(searchKeyword)) {
userCnd.and(Cnd.likeEX(searchName, searchKeyword));
}
userCnd.andEX("u.unionid", "=", unionId);
userCnd.andEX("u.unitid", "=", unitId);
userCnd.andEX("u.personType", "=", personType);
userCnd.andEX("u.userState", "=", userState);
userCnd.andEX("u.id", "=", id);
userCnd.andEX("u.loginname", "in", existsLoginNames);
sql.setCondition(userCnd);
Cnd cnd = Cnd.NEW();
cnd.and("groupId", "=", groupId);
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
cnd.andEX("creator", "=", ShiroUtil.getPrincipalProperty("id"));
}
if (StrUtil.isNotBlank(id)) {
cnd.and("id", "=", id);
} else {
cnd.and(new Static("userId in (" + sql + ")"));
}
simpleService.dao().clear(ActivityUserScope.class, cnd);
return null;
}
@At
@Ok("void")
public void doExportUser(Integer groupId, HttpServletResponse response) {
try {
Sql sql = Sqls.create("""
SELECT
u.username AS userName,
u.loginname AS loginName,
u.sex,
u.mobile,
u.unitname AS unitName,
u.unionName AS unionName
FROM
activity_user_scope aus
LEFT JOIN `user` u ON u.id = aus.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.andEX("aus.groupId", "=", groupId);
sql.setCondition(cnd);
List<NutMap> listMap = simpleService.listMap(sql);
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("姓名", "userName", 20));
exportEntities.add(new ExcelExportEntity("工号", "loginName", 20));
exportEntities.add(new ExcelExportEntity("工会", "unionName", 20));
exportEntities.add(new ExcelExportEntity("单位", "unitName", 20));
exportEntities.add(new ExcelExportEntity("手机号码", "mobile", 20));
ViTool.excelResponse(response, "活动分组人员.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), exportEntities, listMap);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Ok("void")
@RequiresPermissions("activity.basic.user")
public void downloadImport(HttpServletResponse response) {
try {
ViTool.excelResponse(response, "人员导入模板.xlsx");
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
entityList.add(new ExcelExportEntity("姓名", "username", 20));
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, new ArrayList<>());
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Aop(TransAop.READ_COMMITTED)
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@RequiresPermissions("activity.basic.user")
public Object doImport(String groupId, TempFile file) {
String matchUserLoginNamesKey = "ActivityBasicUserController.doImport.groupId=" + groupId + "time=" + System.currentTimeMillis();
List<UserTemp> userImportList = ExcelImportUtil.importExcel(file.getFile(), UserTemp.class, new ImportParams());
//判断人员哪些存在哪些不存在
Sql sql = Sqls.queryString("""
SELECT
u.loginname
FROM
activity_user_scope aus
LEFT JOIN sys_user u ON u.id = aus.userId
WHERE
aus.groupId = @groupId
""").setParam("groupId", groupId);
simpleService.execute(sql);
String[] sysLoginNames = (String[]) sql.getResult();
//存在的工号
List<String> existsLoginNames = new ArrayList<>();
for (UserTemp excelUser : userImportList) {
if (ArrayUtil.contains(sysLoginNames, excelUser.getLoginname())) {
existsLoginNames.add(excelUser.getLoginname());
} else {
excelUser.setRemarks("系统查不到此人");
}
}
//匹配不到的用户
List<UserTemp> errorExcelTempUsers = userImportList.stream().filter(v -> StrUtil.isNotBlank(v.getRemarks())).collect(Collectors.toList());
NutMap nutMap = NutMap.NEW();
nutMap.setv("totalCount", userImportList.size());
nutMap.setv("successCount", existsLoginNames.size());
nutMap.setv("errorCount", errorExcelTempUsers.size());
nutMap.setv("errorList", errorExcelTempUsers.stream().map(v -> {
return new NutMap().addv("工号", v.getLoginname()).addv("姓名", v.getUsername()).addv("错误信息", v.getRemarks());
}).collect(Collectors.toList()));
nutMap.setv("existsLoginNameRedisKey", matchUserLoginNamesKey);
//保存存在的工号
if (Lang.isNotEmpty(existsLoginNames)) {
redisService.lpush(matchUserLoginNamesKey, existsLoginNames.toArray(new String[0]));
redisService.expire(matchUserLoginNamesKey, 60 * 3);
}
return Result.success(nutMap);
}
/**
* 清空查询条件
*
* @param existsLoginNameRedisKey
* @return java.lang.Object
* @author zhf
* @description
*/
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("activity.basic.user")
public Object clearSearchCnd(String existsLoginNameRedisKey) {
if (StrUtil.isNotBlank(existsLoginNameRedisKey)) {
redisService.del(existsLoginNameRedisKey);
}
return null;
}
}
@@ -0,0 +1,178 @@
package io.v.nutz.activity.controller.basic;
import io.v.nutz.activity.models.ActivityBasicSettings;
import io.v.nutz.activity.models.ActivityEvent;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Arrays;
/**
* @author zhf
* @date 2021/2/24 14:09
* @description 比赛项目
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/basic/event")
public class ActivityEventController {
//运动类型id
public static final String EXERCISE_TYPE = "f708d6343c9542b791d32532f860d120";
//比赛组别id
public static final String COMPETITION_CATEGORY = "60f9c36cadce493494a2373cc64d216f";
//距离id
public static final String DISTANCE = "d6d9196e87184729abd0dca1bd5df984";
@Inject("ActivityEvent")
private ViService<ActivityEvent> activityEventViService;
@Inject("ActivityBasicSettings")
private ViService<ActivityBasicSettings> basicSettingsViService;
@At("")
@Ok("beetl:platform/activity/basic/ActivityEvent.html")
@RequiresPermissions("activity.basic.event")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object focusGroup() {
return basicSettingsViService.query(Cnd.where("parentId", "=", COMPETITION_CATEGORY).asc("code"));
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object exerciseType() {
return basicSettingsViService.query(Cnd.where("parentId", "=", EXERCISE_TYPE));
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object focusDistance() {
return basicSettingsViService.query(Cnd.where("parentId", "=", DISTANCE).asc("name"));
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object changeExercise_typeList(String exerciseType) {
return basicSettingsViService.query(Cnd.where("parentId", "=", exerciseType));
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object pageData(PageForm page, @Param(value = "group", required = false) String group,@Param(value = "events", required = false) String events,@Param(value = "isMenWomen", required = false) String[] isMenWomen,@Param(value = "activityId", required = false) String activityId) {
Sql sql = Sqls.create("""
SELECT
even.*,
ba.`name` baname,
di.`name` diname,
sp.`name` spname,
exe.`name` exename
FROM
activity_event even
LEFT JOIN activity_school_event ase ON ase.eventId = even.id
LEFT JOIN activity_basic_settings ba ON even.competitionCategory = ba.id
LEFT JOIN activity_basic_settings di ON even.distance = di.id
LEFT JOIN activity_basic_settings sp ON even.sports = sp.id
LEFT JOIN activity_basic_settings exe ON even.exerciseType = exe.id $condition
""");
Cnd cnd = CndPlus.create();
SqlExpressionGroup sqlExpressionGroup = new SqlExpressionGroup();
if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("2"))) {
sqlExpressionGroup.and("even.isMenWomen", "=", 1);
}
if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("3"))) {
sqlExpressionGroup.or("even.isMenWomen", "=", 2);
}
if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("4"))) {
sqlExpressionGroup.and("even.projectType", "=", 1);
}
if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("5"))) {
sqlExpressionGroup.or("even.projectType", "=", 2);
}
if (sqlExpressionGroup.getExps().size() > 0) {
cnd.and(sqlExpressionGroup);
}
cnd.groupBy("even.id");
cnd.andEX("even.competitionCategory", "=", group);
cnd.andEX("exe.id", "=", events);
cnd.andEX("ase.activityId", "=", activityId);
cnd.desc("projectCode");
cnd.asc("projectType");
cnd.desc("baname");
cnd.asc("isMenWomen");
sql.setCondition(cnd);
return activityEventViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object doAdd(ActivityEvent activityEvent) {
activityEvent.setWhetherEnable(true);
activityEventViService.insert(activityEvent);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object doEdit(ActivityEvent activityEvent) {
activityEventViService.update(activityEvent);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object doDelete(String id) {
activityEventViService.delete(id);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object doAssignmentDate(String[] eventIds, String startAgeDate, String endAgeDate) {
for (String eventId : eventIds) {
activityEventViService.update(Chain.make("startAgeDate", startAgeDate).add("endAgeDate", endAgeDate), Cnd.where("id", "=", eventId));
}
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.event")
public Object getProjectCodeIsExist(String projectCode) {
return activityEventViService.fetch(Cnd.where("projectCode", "=", projectCode));
}
}
@@ -0,0 +1,595 @@
package io.v.nutz.activity.controller.basic;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivityBasicUnion;
import io.v.nutz.activity.models.ActivityBasicUnit;
import io.v.nutz.activity.models.ActivitySchoolApply;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.lang.Lang;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.*;
import io.v.nutz.sys.services.SysDictService;
import io.v.nutz.sys.services.SysRoleService;
import io.v.nutz.sys.services.SysUserRoleService;
import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.controller.ViCommonCon;
import io.v.nutz.web.commons.utils.ShiroUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.List;
/**
* TODO
*
* @Author zhf
* @Date 2022/7/28 13:56
*/
@IocBean
@At({"/platform/activity/basic/union", "/platform/activity/basic/union2"})
@Ok("json:full")
@Slf4j
public class ActivityUnionController {
@Inject("ActivityBasicUnion")
private ViService<ActivityBasicUnion> sysUnionService;
@Inject("ActivityBasicUnit")
private ViService<ActivityBasicUnit> sysUnitService;
@At("")
@Ok("beetl:platform/activity/basic/ActivityUnion.html")
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public void index() {
}
private boolean checkRole() {
if (ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
return true;
}
return false;
}
/**
* 修改角色
*
* @param unionid
* @param roleId
* @param userId
* @param type 1 添加 2 删除
* @return
*/
@At
@ViReturn
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object changeSchoolUnionRole(String unionid, String roleId, String roleCode, String userId, int type) {
if (type == 1) {
Sys_user_role role = new Sys_user_role();
role.setUserId(userId);
Sys_role sysRole = sysRoleService.fetch(Cnd.where("code", "=", roleCode));
role.setRoleId(sysRole.getId());
if (Strings.isNotBlank(unionid)) {
role.setUnionid(unionid);
}
sysUserRoleService.insert(role);
} else if (type == 2) {
Cnd cnd = Cnd.where("roleId", "=", roleId).and("userId", "=", userId);
sysUserRoleService.clear(cnd);
}
sysUserService.clearCache();
sysRoleService.clearCache();
return null;
}
/**
* 获取校工会 / 院级工会 的角色/人员
*
* @return
*/
@At
@ViReturn
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object schoolUnionRoles(String unionid, String searchName, String searchKeyword) {
Sql sql = Sqls.create("""
SELECT
role.`name` rolename,
role.id roleid,
u.id,
u.username,
u.loginname,
u.mobile
FROM
sys_user_role sur
LEFT JOIN sys_role role ON sur.roleId = role.id
LEFT JOIN sys_dict dict ON dict.`code` = role.`code`
LEFT JOIN `user` u ON sur.userId = u.id
$condition
order by FIELD( role.`code`, 'wyh01', 'wyh02', 'A06', 'wyh03', 'tamange', 'flwyh01', 'H10', 'xghng', 'xghkj' )
""");
Cnd cnd = Cnd.NEW();
if (Strings.isNotBlank(unionid)) {
cnd.and(new Static("dict.parentId = ( SELECT id FROM sys_dict WHERE `code` = 'GrassrootsCadres' LIMIT 1)"));
cnd.and("u.unionid", "=", unionid);
} else {
cnd.and(new Static("dict.parentId = ( SELECT id FROM sys_dict WHERE `code` = 'SchoolRoles' LIMIT 1)"));
}
if (Lang.notNull(searchName, searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
sql.setCondition(cnd);
return sysDictService.list(sql);
}
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object unionTree() {
try {
ActivityBasicUnit basicUnit = sysUnionService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", Vi.getUnit().getId()));
Record record = new Record();
record.set("unionname", "工会委员会");
if (checkRole()) {
record.set("sysadmin", true);
record.set("childrens", sysUnionService.query(Cnd.NEW().asc("unioncode")));
} else {
record.set("sysadmin", true);
Sql sql = Sqls.create("""
SELECT
gh.*
FROM
activity_basic_union gh
WHERE
gh.id = @id
""").setParam("id", basicUnit.getUnionid());
record.set("childrens", sysUnionService.list(sql));
}
return Result.success().addData(record);
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object unionPageData(String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
try {
ActivityBasicUnit basicUnit = sysUnionService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", Vi.getUnit().getId()));
Sql sql = Sqls.create("SELECT\n" +
"\tgh.*,\n" +
"\tun.isEnable AS unisEnable,\n" +
"\t(SELECT COUNT(*) FROM activity_basic_unit WHERE unionid=gh.id) unitnum,\n" +
"\tGROUP_CONCAT( fzr.username,'(',fzr.loginname,')' ) fzr\n" +
"FROM\n" +
"\tactivity_basic_union gh\n" +
"\tLEFT JOIN sys_union un ON un.id = gh.id\n" +
"\tLEFT JOIN sys_user_role sur ON gh.id = sur.unionid \n" +
"\tAND (sur.roleId = @ghfzrrole)\n" +
"\tLEFT JOIN sys_user fzr ON sur.userId = fzr.id $condition");
sql.setParam("ghfzrrole", Roles.UNION_MANGER);
Cnd cnd = Cnd.NEW();
cnd.groupBy("gh.id");
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.and(searchName, "like", "%" + searchKeyword + "%");
}
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
cnd.and("gh.id", "=", basicUnit.getUnionid());
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.asc("unioncode");
}
sql.setCondition(cnd);
return Result.success().addData(sysUnionService.listPageMap(pageNumber, pageSize, sql));
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
@Inject
private SysDictService sysDictService;
/**
* 添加工会
*
* @param union
* @return
*/
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object doAddUnion(ActivityBasicUnion union) {
try {
union.setSource("activity");
sysUnionService.insert(union);
if (!ShiroUtil.hasAnyRoles("sysadmin.H04")) {
sysUnitService.dao().update(ActivityBasicUnit.class, Chain.make("unionid", union.getId()), Cnd.where("id", "=", Vi.getUnit().getId()));
}
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
/**
* 查看工会信息
*
* @param id
* @return
*/
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object editUnion(String id) {
try {
return Result.success().addData(sysUnionService.fetch(id));
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
/**
* 修改工会
*
* @param union
* @return
*/
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object doEditUnion(ActivityBasicUnion union) {
try {
sysUnionService.update(union);
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
private void flushDict() {
sysDictService.clear(Cnd.where("parentId", "=", ViCommonCon.DICT_UNION_ID));
List<ActivityBasicUnion> unions = sysUnionService.query();
for (ActivityBasicUnion union : unions) {
Sys_dict dict = new Sys_dict();
dict.setParentId(ViCommonCon.DICT_UNION_ID);
dict.setName(union.getUnionname());
dict.setCode(union.getUnioncode());
sysDictService.insert(dict);
}
}
/**
* 删除工会
*
* @param id
* @return
*/
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object doDeleteUnion(String id, boolean flag) {
try {
if (flag) {
sysUnionService.delete(id);
sysUnionService.dao().clear(ActivitySchoolApply.class, Cnd.where("activityUnionId", "=", id));
} else {
List<ActivityBasicUnit> unitList = sysUnitService.query(Cnd.where("unionId", "=", id));
unitList.forEach(v -> {
Sys_unit unit = sysUnionService.dao().fetch(Sys_unit.class, v.getId());
sysUnitService.update(Chain.make("unionid", unit.getUnionid()), Cnd.where("id", "=", unit.getId()));
});
}
//再清除单位对应的工会id
sysUnionService.update("activity_basic_unit", Chain.make("unionid", ""), Cnd.where("unionid", "=", id));
//再删除工会负责人的权限
// sysUnionService.clear("sys_user_role", Cnd.where("unionid", "=", id).and("roleid", "=", Roles.UNION_MANGER));
// flushDict();
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
/**
* 获取工会的用户和负责人
*
* @param id
* @return
*/
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object getUserAndFzr(String id) {
try {
Sql sql = Sqls.create("SELECT u.id,u.username,u.loginname,CONCAT( u.username, '', u.loginname, '','-',u.unitname ) name from `user` u left join activity_basic_unit un on u.unitid=un.id WHERE un.unionid = @id").setParam("id", id);
Sql sql1 = Sqls.create("SELECT u.id,u.username,u.loginname,CONCAT( u.username, '', u.loginname, '','-',u.unitname ) name from `user` u left join activity_basic_unit un on u.unitid=un.id left join sys_user_role sur on u.id = sur.userId WHERE sur.unionid = @id and sur.userId is not null and sur.roleId = @roleid").setParam("id", id).setParam("roleid", Roles.UNION_MANGER);
return Result.success().addData(Record.create().set("data", sysUnionService.list(sql)).set("value", sysUnionService.list(sql1)));
} catch (Exception e) {
return Result.error();
}
}
/**
* 修改工会负责人
*
* @param unionid
* @param userids
* @return
*/
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object doEditFzr(String unionid, String userids) {
try {
//再删除工会负责人的权限
sysUnionService.clear("sys_user_role", Cnd.where("unionid", "=", unionid).and("roleid", "=", Roles.UNION_MANGER));
for (String id : Json.fromJsonAsList(String.class, userids)) {
sysUnionService.insert("sys_user_role", Chain.make("roleid", Roles.UNION_MANGER).add("userid", id).add("unionid", unionid));
}
sysUserService.clearCache();
sysRoleService.clearCache();
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
@At
public Object getUnitsByUnion(String unionid) {
try {
if (Strings.isNotBlank(unionid)) {
return Result.success().addData(sysUnitService.query(Cnd.where("unionid", "=", unionid).and("unitlevel", "=", 2)));
}
return Result.success();
} catch (Exception e) {
return Result.error();
}
}
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object hyPageData(String unitid, String unionid, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
try {
// Sql sql = Sqls.create("SELECT u.id,u.username,u.loginname,u.sex,un.`name` unitname,u.mobile from sys_user u left join sys_unit un on u.unitid = un.id $condition");
Sql sql = Sqls.create("SELECT u.id,u.username,u.loginname,u.sex,u.unitname,u.mobile from member u $condition");
Cnd cnd = Cnd.NEW();
cnd.and("u.unitid", "in", Sqls.create("select id from activity_basic_unit where unionid=@unionid").setParam("unionid", unionid));
// cnd.and("u.unionid", "=", unionid);
if (Strings.isNotBlank(unitid)) {
cnd.and("u.unitid", "=", unitid);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.and(searchName, "like", "%" + searchKeyword + "%");
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.asc("u.unitid");
}
sql.setCondition(cnd);
return Result.success().addData(sysUnionService.listPage(pageNumber, pageSize, sql));
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
@Inject
private SysUserRoleService sysUserRoleService;
@At
@Ok("json")
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object delSpy(String userid, String roleid) {
try {
sysUserRoleService.clear(Cnd.where("userid", "=", userid).and("roleid", "=", roleid));
sysRoleService.clearCache();
return Result.success();
} catch (Exception e) {
return Result.error();
}
}
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object doAddSpy(String[] userids, String[] roleids) {
try {
for (String userid : userids) {
for (String roleid : roleids) {
sysUserRoleService.clear(Cnd.where("userId", "=", userid).and("roleId", "=", roleid));
Sys_user user = sysUserService.fetch(userid);
ActivityBasicUnit unit = sysUnitService.fetch(user.getUnitid());
Sys_user_role sysUserRole = new Sys_user_role();
sysUserRole.setUserId(userid);
sysUserRole.setRoleId(roleid);
sysUserRole.setUnionid(unit.getUnionid());
sysUserRoleService.insert(sysUserRole);
}
}
sysRoleService.clearCache();
return Result.success();
} catch (Exception e) {
return Result.error();
}
}
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object spyPageData(String qxid, String unionid, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
try {
Sql sql = Sqls.create("SELECT\n" +
"\tsur.roleId,\n" +
"\tsur.userId,\n" +
"\tu.username,\n" +
"\tu.loginname,\n" +
"\tun.`name` unitname,\n" +
"\tfgh.unionname,\n" +
"\trole.`name` rolename\n" +
"FROM\n" +
"\t`sys_user_role` sur\n" +
"\tleft join sys_role role on sur.roleId = role.id\n" +
"\tLEFT JOIN sys_user u ON u.id = sur.userId\n" +
"\tLEFT JOIN activity_basic_unit un ON u.unitid = un.id\n" +
"\tLEFT JOIN activity_basic_union fgh ON un.unionid = fgh.id $condition");
Cnd cnd = Cnd.NEW();
cnd.and("un.unionid", "=", unionid);
if (Strings.isNotBlank(qxid)) {
cnd.and("sur.roleId", "=", qxid);
} else {
cnd.and("sur.roleId in (SELECT role.id from sys_dict dict left join sys_role role on dict.`code` = role.`code` WHERE parentId = '" + ViCommonCon.DICT_SPYJS_ID + "') and 1", "=", 1);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.asc("sur.roleId");
}
sql.setCondition(cnd);
return Result.success().addData(sysUnionService.listPage(pageNumber, pageSize, sql));
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
@Inject
private SysRoleService sysRoleService;
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object getDwAndZcdw(String unionid) {
try {
SqlExpressionGroup group = new SqlExpressionGroup();
group.and("unionid", "is", null).or("unionid", "=", "").or("unionid", "=", unionid);
return Result.success().addData(Record.create().set("data", sysUnitService.query(Cnd.where("unitlevel", "=", 2))).set("value", sysUnitService.query(Cnd.where("unionid", "=", unionid).and("unitlevel", "=", 2))));
} catch (Exception e) {
return Result.error();
}
}
/**
* 修改工会组成单位
*
* @param unionid
* @param unitids
* @return
*/
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object doEditZcdw(String unionid, String unitids) {
try {
sysUnitService.execute(Sqls.create("UPDATE activity_basic_unit set unionid = null WHERE unionid=@id").setParam("id", unionid));
for (String id : Json.fromJsonAsList(String.class, unitids)) {
sysUnitService.update(Chain.make("unionid", unionid), Cnd.where("id", "=", id));
}
return Result.success();
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
@Inject
private SysUserService sysUserService;
/**
* 根据关键字和工会id找用户
*
* @param query
* @param unionid
* @return
*/
@At
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object getUserByUnionId(String query, String unionid) {
try {
return Result.success().addData(sysUserService.listPage(1, 50, Sqls.create("SELECT u.id,u.username,u.loginname,u.sex,u.mobile,u.zw,u.email\n" +
"from sys_user u left join activity_basic_unit un on u.unitid = un.id WHERE un.unionid = @unionid and (u.username LIKE @query or u.loginname like @query)").setParam("unionid", unionid).setParam("query", "%" + query + "%")));
} catch (Exception e) {
return Result.error();
}
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object isEnableChange(String id, boolean isEnable) {
sysUnionService.update(Chain.make("isEnable", isEnable), Cnd.where("id", "=", id));
return null;
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object getActivityUnions() {
return sysUnionService.query();
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.basic.union", "activity.basic.union2"}, logical = Logical.OR)
public Object getActivityUnits(String unionId) {
if (Strings.isBlank(unionId)) {
return sysUnitService.dao().query(ActivityBasicUnit.class, Cnd.where("unitlevel", "=", 2).asc("id"));
}
return sysUnitService.dao().query(ActivityBasicUnit.class, Cnd.where("unionid", "=", unionId).and("unitlevel", "=", 2).asc("id"));
}
}
@@ -0,0 +1,212 @@
package io.v.nutz.activity.controller.basic;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivityBasicUnit;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.AsyncService;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_unit;
import io.v.nutz.sys.services.SysUnitClassService;
import io.v.nutz.sys.services.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.ArrayList;
import java.util.List;
/**
* TODO
*
* @Author zhf
* @Date 2022/7/28 10:46
*/
@IocBean
@At("/platform/activity/basic/unit")
@Ok("json:full")
@Slf4j
public class ActivityUnitController {
@Inject("ActivityBasicUnit")
private ViService<ActivityBasicUnit> sysUnitService;
@Inject
private SysUnitClassService sysUnitClassService;
@At("")
@Ok("beetl:platform/activity/basic/ActivityUnit.html")
@RequiresPermissions("activity.basic.unit")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.basic.unit")
public Object pageData(@Param(value = "parentId", required = false) String parentId, PageForm pageForm) {
CndPlus cnd = CndPlus.create();
cnd.andExcludeEmpty("parentId", "=", parentId);
return sysUnitService.list(pageForm, cnd);
}
@At
@ViReturn
@RequiresPermissions("activity.basic.unit")
public Object findOne(String id) {
return sysUnitService.fetch(id);
}
@At
@ViReturn
@RequiresPermissions("activity.basic.unit")
public Object doAdd(ActivityBasicUnit activityBasicUnit) {
if (sysUnitService.count(Cnd.where("unitcode", "=", activityBasicUnit.getUnitcode())) > 0) {
return Result.error("单位代码已存在");
}
sysUnitService.update(Chain.make("hasChildren", true), Cnd.where("id", "=", activityBasicUnit.getParentId()));
sysUnitService.insert(activityBasicUnit);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.unit")
public Object doEdit(Sys_unit sys_unit) {
if (sysUnitService.count(Cnd.where("unitcode", "=", sys_unit.getUnitcode()).and("id", "!=", sys_unit.getId())) > 0) {
return Result.error("单位代码已存在");
}
sysUnitService.update(sys_unit);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.basic.unit")
public Object doDelete(String id) {
ActivityBasicUnit unit = sysUnitService.fetch(id);
int count = sysUnitService.count(Cnd.where("parentId", "=", unit.getParentId()).and("id", "!=", id));
sysUnitService.update(Chain.make("hasChildren", count > 0), Cnd.where("id", "=", unit.getParentId()));
delete(id);
return null;
}
private void delete(String id) {
Cnd cnd = Cnd.where("parentId", "=", id);
List<ActivityBasicUnit> units = sysUnitService.query(cnd);
for (ActivityBasicUnit unit : units) {
delete(unit.getId());
}
sysUnitService.clear(cnd);
sysUnitService.delete(id);
}
/**
* 获取树形数据
*
* @return
*/
@At
@RequiresPermissions("activity.basic.unit")
public Object getUnitTreeData() {
try {
List list = new ArrayList();
ActivityBasicUnit school = sysUnitService.fetch(Cnd.NEW());
if(school == null) {
return Result.success();
}
school.setChild(child(school.getId()));
list.add(school);
return Result.success().addData(list);
} catch (Exception e) {
e.printStackTrace();
return Result.error("获取单位信息失败");
}
}
@Inject
private AsyncService asyncService;
private List<ActivityBasicUnit> child(String parentId) {
List<ActivityBasicUnit> units = sysUnitService.query(Cnd.where("parentId", "=", parentId));
units.forEach(unit -> {
unit.setChild(child(unit.getId()));
});
return units;
}
@At
@Ok("json")
@RequiresPermissions("activity.basic.unit")
public Object getUnit2() {
try {
return Result.success().addData(sysUnitService.query(Cnd.where("unitlevel", "=", 2).asc("location")));
} catch (Exception e) {
return Result.error();
}
}
@Inject
private SysUserService sysUserService;
@At
@ViReturn
@RequiresPermissions("activity.basic.unit")
public Object findPersonByUnitId(PageForm pageForm, String unitId) {
NutMap map = new NutMap();
CndPlus cndPlus = CndPlus.create();
cndPlus.andExcludeEmpty("unitid", "=", unitId);
if (Strings.isNotBlank(pageForm.getSearchName()) && Strings.isNotBlank(pageForm.getSearchKeyword())) {
cndPlus.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
}
cndPlus.asc("member");
Sql sql = Sqls.create("""
SELECT
su.*
FROM
sys_user su
LEFT JOIN sys_user_role sur ON sur.userId = su.id
$condition
""");
CndPlus cndPlus2 = CndPlus.create();
cndPlus2.andExcludeEmpty("sur.roleId", "=", Roles.UNIT_MANGER);
cndPlus2.andExcludeEmpty("su.unitid", "=", unitId);
if (Strings.isNotBlank(pageForm.getSearchName()) && Strings.isNotBlank(pageForm.getSearchKeyword())) {
cndPlus2.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
}
sql.setCondition(cndPlus2);
map.setv("userList", sysUserService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), cndPlus));
map.setv("principal", sysUserService.listMap(sql));
return map;
}
}
@@ -0,0 +1,870 @@
package io.v.nutz.activity.controller.school;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.*;
import io.v.nutz.activity.services.ActivitySchoolApplyService;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.activity.services.ActivitySchoolTeamService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.SimpleService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_unit;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.util.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.aop.interceptor.async.Async;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author: Aaron
* @create: 2021-02-24 16:31
* @description: 活动报名
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/apply")
@RequiresAuthentication
public class ActivityApplyController {
@Inject
private ActivitySchoolService activitySchoolService;
@Inject
protected SysUserService sysUserService;
@Inject
private ActivitySchoolApplyService activitySchoolApplyService;
@Inject
private ActivitySchoolTeamService activitySchoolTeamService;
@Inject
private SimpleService simpleService;
@Inject("ActivitySchoolEvent")
private ViService<ActivitySchoolEvent> activitySchoolEventViService;
@At("")
@Ok("beetl:platform/activity/school/ActivityApply.html")
@RequiresPermissions("activity.apply")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.apply")
public Object applyPageData(PageForm page,
@Param(value = "activityId", required = false) String activityId,
@Param(value = "eventId", required = false) String eventId) {
Cnd cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
apply.*,team.`name`,acts.name actsname,ev.allName
FROM
Activity_School_Apply apply LEFT JOIN activity_school_team team ON apply.teamId=team.id
LEFT JOIN activity_school acts ON acts.id=apply.activityId
LEFT JOIN activity_event ev ON ev.id = apply.eventId $condition
""");
cnd.and("apply.activityUnionId", "=", getUnionId());
/* if (!ShiroUtil.hasAnyRoles("A06,sysadmin")) {
SqlExpressionGroup group = new SqlExpressionGroup();
if (ShiroUtil.hasAnyRoles("H01")) {
group.or("applyUser", "=", ShiroUtil.getPrincipalProperty("id"));
}
if (ShiroUtil.hasAnyRoles("H04")) {
group.or("unionId", "=", getUnionId());
}
cnd.and(group);
}*/
Vi.cndPlus(cnd, "apply.activityId", "=", activityId);
Vi.cndPlus(cnd, "apply.eventId", "=", eventId);
cnd.asc("team.`name`");
cnd.desc("apply.identity");
sql.setCondition(cnd);
return activitySchoolService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
public Object activityData(@Param(value = "year", required = false) Integer year,
@Param(value = "isActivity", required = false) Integer isActivity) {
Sql sql = Sqls.create("""
SELECT
ba.`name` activityLevelName,
school.id,
school.planId,
school.NAME,
school.address,
school.applyStartTime,
school.applyEndTime,
school.startTime,
school.endTime,
school.unitSponsor,
school.unitJointly,
school.gameStyle,
school.funding,
school.applyWay,
school.personType,
school.activityLevel,
school.applyType,
school.athleteQualification,
school.registrationMethod,
school.competitionMethod,
(SELECT count( 1 ) FROM activity_school_apply app WHERE app.activityId = school.id AND app.`status` = 2 ) apply_num,
(SELECT count( 1 ) FROM activity_school_apply app WHERE app.activityId = school.id AND ( app.applyUser = @userid OR app.userId = @userid )) > 0 applyed,
(SELECT COUNT(1) FROM activity_school_apply app WHERE app.activityId=school.id AND app.unionId=@unionId AND app.unionLeader=TRUE) LeaderCount,
(SELECT COUNT(1) FROM activity_school_apply app WHERE app.activityId=school.id AND app.unionId=@unionId AND app.unionCoach=TRUE) CoachCount
FROM
activity_school school
LEFT JOIN activity_basic_settings ba ON ba.`code` = school.activityLevel
$condition
""").setParam("userid", ShiroUtil.getPrincipalProperty("id")).setParam("unionId", getUnionId());
CndPlus cnd = CndPlus.create();
cnd.and("school.close", "!=", true);
cnd.and("school.isSave", "!=", true);
//查询报名中
if (isActivity == 2) {
cnd.and(new Static("now() >applyStartTime and now() < applyEndTime"));
}//查询已结束的
else if (isActivity == 3) {
cnd.and(new Static("now() > school.applyEndTime"));
}
if (!ShiroUtil.hasAnyRoles("H04,sysadmin,gh13")) {
cnd.and(new Static("JSON_CONTAINS(school.applyWay,JSON_ARRAY( 1))>0"));
cnd.and(new Static("(SELECT COUNT(1) FROM activity_user_scope WHERE groupId=school.activityGroupId AND userId='%s') >0".formatted(ShiroUtil.getUserId())));
}
Vi.cndPlus(cnd, "YEAR(school.applyStartTime)", "=", year);
cnd.desc("school.applyStartTime");
sql.setCondition(cnd);
return activitySchoolService.listMap(sql);
}
/**
* 获取这个活动统一报名的信息
*
* @param activityId 活动id
* @return
*/
@At
@ViReturn
@RequiresPermissions("activity.apply")
public Object getUniteApplyInfo(@Param(value = "endAgeDate", required = false) String endAgeDate,
@Param(value = "startAgeDate", required = false) String startAgeDate,
@Param(value = "activityId") String activityId,
@Param(value = "eventId", required = false) String eventId,
@Param(value = "schoolEventId", required = false) String schoolEventId,
@Param(value = "projectType", required = false) String projectType,
@Param(value = "isMenWomen", required = false) Integer isMenWomen) {
String union_id = getUnionId();
Map result = new HashMap();
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
Sys_unit unit = user.getUnit();
//根据当前登入人的单位查询他所属的活动分工会属于哪个
ActivityBasicUnit activityBasicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, unit.getId());
ActivitySchool activity = activitySchoolService.fetch(activityId);
Sql sql = Sqls.create("""
SELECT
u.id,
u.username,
u.unitid,
u.loginname,
u.sex,
u.birthday,
u.mobile,
u.unionid,
un.`name` unitname
FROM
`user` u
LEFT JOIN activity_basic_unit un ON u.unitid = un.id
LEFT JOIN activity_basic_union uni ON un.unionid=uni.id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and(new Static("u.id not in (SELECT IFNULL(app.userId,'') from activity_school_apply app WHERE app.activityId = '" + activityId + "' AND app.eventId='" + eventId + "')"));
cnd.and(new Static("u.id IN (SELECT userId FROM activity_user_scope aus WHERE aus.groupId='" + activity.getActivityGroupId() + "')"));
cnd.and("un.unionid", "=", activityBasicUnit.getUnionid());
if (isMenWomen != null && isMenWomen == 1) cnd.and("u.sex", "=", "");
if (isMenWomen != null && isMenWomen == 2) cnd.and("u.sex", "=", "");
if (Strings.isNotBlank(startAgeDate)) {
cnd.and("u.birthday", ">", startAgeDate);
cnd.and("u.birthday", "<=", endAgeDate);
}
sql.setCondition(cnd);
List<Record> userList = activitySchoolService.list(sql);
userList.forEach(v -> {
if (Strings.isNotBlank(v.getString("birthday"))) {
// v.set("age", cn.hutool.core.date.DateUtil.ageOfNow(v.getString("birthday")));
}
});
result.put("users", userList);
/*AND asa.`status` = 2*/
Sql applySql = Sqls.create("""
SELECT
asa.*
FROM
activity_school_apply asa
LEFT JOIN activity_school_team team ON asa.teamId = team.id
LEFT JOIN sys_unit unit ON asa.unitId = unit.id
WHERE
asa.eventId = @eventId
AND asa.activityId=@activityId
AND asa.activityUnionId = @unionid
AND asa.`status` != 3
ORDER BY
asa.identity DESC,
asa.sex
""").setParam("eventId", eventId).setParam("unionid", union_id).setParam("activityId", activityId);
List<ActivitySchoolApply> list = activitySchoolApplyService.listEntity(applySql);
//团体人数
List<ActivitySchoolApply> awardsModeT = list.stream().filter(v -> v.getAwardsMode().equals("2")).collect(Collectors.toList());
//单项人数
List<ActivitySchoolApply> awardsModeG = list.stream().filter(v -> v.getAwardsMode().equals("1")).collect(Collectors.toList());
list.forEach(v -> {
if (Strings.isNotBlank(v.getBirthday())) {
// v.setAge(cn.hutool.core.date.DateUtil.ageOfNow(v.getBirthday()));
}
});
result.put("list", list);
result.put("awardsModeT", awardsModeT);
result.put("awardsModeG", awardsModeG);
result.put("team", activitySchoolTeamService.query(Cnd.where("eventId", "=", eventId).and("activityId", "=", activityId).asc("location")));
result.put("activity", activity);
List<NutMap> events = (List<NutMap>) getEvents(activityId);
NutMap eve = events.stream().filter(v -> v.getString("id").equals(schoolEventId)).findFirst().orElse(null);
result.put("getEvent", eve);
return result;
}
/**
* 根据活动名称查找小队
*
* @param id
* @return
*/
@At
@ViReturn
public Object getTeamId(String id) {
return activitySchoolTeamService.query(Cnd.where("activityId", "=", id).asc("location"));
}
/**
* 根据活动加项目查找小队
*
* @param activityId
* @return
*/
@At
@ViReturn
public Object getActivityTeamId(String activityId, String eventId) {
return activitySchoolTeamService.query(Cnd.where("activityId", "=", activityId).and("eventId", "=", eventId).asc("location"));
}
/**
* 领队的查找方法
*
* @param keyWord
* @return
*/
@At
@ViReturn
@RequiresPermissions("activity.apply")
public Object leaderSearch(@Param(value = "eventId", required = false) String eventId,
@Param(value = "keyWord", required = false) String keyWord,
@Param(value = "personType", required = false) String personType) {
String union_id = getUnionId();
Sql sql = Sqls.create("""
SELECT
u.id,
u.username,
u.unitid,
u.loginname,
u.sex,
u.mobile,
un.`name` unitname
FROM
sys_user u
LEFT JOIN activity_basic_unit un ON u.unitid = un.id
$condition
""");
Cnd cnd = Cnd.NEW();
if (personType.equals(1)) {
cnd.and("u.member", "=", "1");
}
cnd.and(new Static("u.id not in (SELECT IFNULL(app.userId,'') from activity_school_apply app WHERE app.eventId = '" + eventId + "' AND app.identity = 3)"));
cnd.and("un.unionid", "=", union_id);
cnd.limit(1, 20);
SqlExpressionGroup group = new SqlExpressionGroup();
group.orLike("u.username", keyWord);
group.orLike("u.loginname", keyWord);
cnd.and(group);
sql.setCondition(cnd);
return activitySchoolApplyService.list(sql);
}
/**
* 统一报名
*
* @param applies
* @return
*/
@At
@ViReturn
@RequiresPermissions("activity.apply")
public Object doApply(@Param(value = "data", required = false) ActivitySchoolApply[] applies,
@Param(value = "appliedData3", required = false) ActivitySchoolApply[] applies2,
@Param(value = "eventId", required = false) String eventId,
@Param(value = "pass", required = false) boolean pass) {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
Sys_unit unit = user.getUnit();
String activityId = "";
ActivityBasicUnit basicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", unit.getId()));
ActivityBasicUnion basicUnion = activitySchoolService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", basicUnit.getUnionid()));
ActivityEvent event = activitySchoolEventViService.dao().fetch(ActivityEvent.class, eventId);
for (ActivitySchoolApply apply : applies) {
activityId = applies[0].getActivityId();
apply.setApplyUser(ShiroUtil.getPrincipalProperty("id").toString());
apply.setStatus(pass ? 2 : 0);
apply.setAwardsMode(event.getProjectType());
apply.setApplyDate(DateUtil.getDate());
apply.setActivityUnionId(basicUnit.getUnionid());
apply.setActivityUnionName(basicUnion.getUnionname());
}
for (ActivitySchoolApply apply2 : applies2) {
activityId = applies2[0].getActivityId();
apply2.setApplyUser(ShiroUtil.getPrincipalProperty("id").toString());
apply2.setStatus(pass ? 2 : 0);
apply2.setAwardsMode(event.getProjectType());
apply2.setApplyDate(DateUtil.getDate());
apply2.setActivityUnionId(basicUnit.getUnionid());
apply2.setActivityUnionName(basicUnion.getUnionname());
}
ActivitySchoolApply[] addAll = ArrayUtil.addAll(applies, applies2);
if (addAll.length > 0) {
activitySchoolApplyService.doApplies(activityId, basicUnit.getUnionid(), eventId, Arrays.asList(addAll));
}
/* if (applies2.length > 0) {
activitySchoolApplyService.doApplies(activityId, basicUnit.getUnionid(), eventId, Arrays.asList(applies2));
}*/
return null;
}
/**
* 个人报名
*
* @param personalEnter
* @param teammateEnter
* @return
*/
@At
@ViReturn
@RequiresPermissions("activity.apply")
public Object doAddTeammateEnter(@Param(value = "personalEnter") ActivitySchoolApply personalEnter,
@Param(value = "teammateEnter") ActivitySchoolApply teammateEnter) {
personalEnter.setApplyUser(ShiroUtil.getPrincipalProperty("id").toString());
personalEnter.setStatus(2);
personalEnter.setAwardsMode("2");
personalEnter.setApplyDate(DateUtil.getDate());
if (teammateEnter.getUserId() != null) {
teammateEnter.setApplyUser(ShiroUtil.getPrincipalProperty("id").toString());
teammateEnter.setStatus(2);
teammateEnter.setAwardsMode("2");
teammateEnter.setApplyDate(DateUtil.getDate());
activitySchoolApplyService.insert(teammateEnter);
}
activitySchoolApplyService.insert(personalEnter);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.apply")
public Object doDelete(String id) {
activitySchoolApplyService.delete(id);
return null;
}
private String getUnionId() {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
Sys_unit unit = user.getUnit();
ActivityBasicUnit basicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", unit.getId()));
if (Lang.isEmpty(basicUnit)) {
throw new RuntimeException("请先完善单位信息");
}
ActivityBasicUnion basicUnion = activitySchoolService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", basicUnit.getUnionid()));
return unit == null ? "" : basicUnion.getId();
}
/**
* 根据id查询人
*
* @param userId
* @return
*/
@At
@RequiresPermissions("activity.apply")
public Object getUserData(String userId) {
Sql sql = Sqls.create("""
SELECT
us.sex,
us.username,
us.loginname,
us.mobile,
er.unitid,
er.unitname,
er.unionid,
er.unionname
FROM
sys_user us
LEFT JOIN `user` er ON us.id = er.id WHERE us.id=@userId
""");
sql.setParam("userId", userId);
return Result.success().addData(sysUserService.list(sql).get(0));
}
/**
* 查询该小队报名人数
*
* @param teamId
* @return
*/
@At
@RequiresPermissions("activity.apply")
public Object getActivityCount(String teamId) {
Sql sql = Sqls.create("""
SELECT COUNT(*) FROM activity_school_apply WHERE teamId=@teamId and activityUnionId=@unionId
""");
sql.setParam("teamId", teamId);
sql.setParam("unionId", getUnionId());
return activitySchoolApplyService.count(sql);
}
/**
* 查询该人有没有参加过这个活动
*
* @param eventId
* @return
*/
@At
@RequiresPermissions("activity.apply")
public Object getActivityUserCount(String eventId) {
Sql sql = Sqls.create("""
SELECT COUNT(*) FROM activity_school_apply WHERE userId=@userId and eventId=@eventId
""");
sql.setParam("userId", ShiroUtil.getPrincipalProperty("id"));
sql.setParam("eventId", eventId);
return activitySchoolApplyService.count(sql);
}
@At
@RequiresPermissions("activity.apply")
public Object getUserUnion(String query) {
String union_id = getUnionId();
Sql sql = Sqls.create("select u.* FROM `user` u LEFT JOIN activity_basic_unit un ON u.unitid = un.id $condition");
Cnd cnd = Cnd.NEW();
if (Strings.isNotBlank(query)) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.orLike("u.username", query);
group.orLike("u.loginname", query);
cnd.and(group);
}
cnd.and("un.unionid", "=", union_id);
sql.setCondition(cnd);
return sysUserService.list(sql);
}
@At
@RequiresPermissions("activity.apply")
public Object findUserOne(String id) {
try {
Sql sql = Sqls.create("SELECT\n" +
"\tu.id,u.username,u.unitid,\n" +
"\tu.loginname,\n" +
"\tu.sex,\n" +
"\tu.mobile,\n" +
"\tun.`name` unitname \n" +
"FROM\n" +
"\tsys_user u\n" +
"\tLEFT JOIN sys_unit un ON u.unitid = un.id Where u.id = @id").setParam("id", id);
return Result.success().addData(activitySchoolService.list(sql).get(0));
} catch (Exception e) {
e.printStackTrace();
return Result.error();
}
}
@At
@RequiresPermissions("activity.apply")
public Object doDeleteTeamUser(String id) {
return activitySchoolApplyService.clear(Cnd.where("id", "=", id));
}
@At
public Object getActivits(Integer year) {
return activitySchoolService.query(Cnd.where("YEAR(applyStartTime)", "=", year).desc("applyStartTime"));
}
/**
* 根据活动查询项目
*
* @param activityId
* @return
*/
@At
public Object getEvents(String activityId) {
Cnd cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
act.*,
ev.competitionCategory,
ev.distance,
ev.sports,
ev.projectType,
ev.whetherEnable,
ev.note,
ev.allName,
ev.isMenWomen,
ev.isInterest
FROM
activity_school_event act
LEFT JOIN activity_event ev ON act.eventId = ev.id
$condition
""");
Vi.cndPlus(cnd, "activityId", "=", activityId);
sql.setCondition(cnd);
return activitySchoolService.listMap(sql);
}
@At
@ViReturn
@RequiresPermissions("activity.apply")
public Object joinMemberFamily(String[] applysId) {
for (String s : applysId) {
activitySchoolApplyService.clear(Cnd.where("id", "=", s));
}
return null;
}
@At
@ViReturn
public Object pageData(@Param(value = "applyType", required = false) String applyType,
@Param(value = "isAudit", required = false) String isAudit,
@Param(value = "groupName", required = false) String groupName,
@Param(value = "activityId", required = false) String activityId,
@Param(value = "eventId", required = false) String eventId,
@Param(value = "year", required = false) Integer year, PageForm page,
@Param(value = "isMenWomen", required = false) String[] isMenWomen) {
Cnd cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
ase.*,
school.`name`,
school.applyWay,
school.applyStartTime,
school.applyEndTime,
school.applyType,
school.activityGroupId,
eve.allName,
eve.isInterest,
eve.projectType,
eve.isMenWomen,
(SELECT ast.`name` FROM activity_school_apply app LEFT JOIN activity_school_team ast ON ast.id = app.teamId WHERE app.eventId = ase.eventId AND app.activityId = ase.activityId AND app.userId = @userId) activityTeamName,
(SELECT COUNT(1) FROM activity_school_apply WHERE eventId=ase.eventId AND activityId=ase.activityId and status=2 and activityUnionId=@unionId) applyNum,
(SELECT COUNT(1) FROM activity_school_apply WHERE eventId = ase.eventId AND activityId = ase.activityId AND userId=@userId) userApply,
(SELECT COUNT(1) FROM activity_school_apply WHERE eventId=ase.eventId AND activityId=ase.activityId and status=2) totalApplyNum
FROM
activity_school_event ase
LEFT JOIN activity_school school ON ase.activityId = school.id
LEFT JOIN activity_event eve ON ase.eventId=eve.id
LEFT JOIN activity_basic_settings abs ON abs.id=eve.competitionCategory
$condition
""").setParam("unionId", getUnionId()).setParam("userId", ShiroUtil.getUserId());
if (!ShiroUtil.hasAnyRoles("H04,sysadmin,gh13")) {
cnd.where().andLike("school.applyWay ", "1");
cnd.and(new Static("(SELECT COUNT(1) FROM activity_user_scope WHERE groupId=school.activityGroupId AND userId='%s') >0".formatted(ShiroUtil.getUserId())));
}
Vi.cndPlus(cnd, "abs.`name`", "=", groupName);
//如果不是超级管理员就按男女查询,isMenWomen 1是男2是女projectType 2是团体
/* if (!ShiroUtil.hasAnyRoles("sysadmin,H04,A06")) {
if (StrUtil.isNotBlank(applyType)) {
if (!applyType.equals("1")) {
if (ShiroUtil.getPrincipalProperty("sex").equals("男")) {
cnd.and(new Static("(eve.isMenWomen =1 OR eve.isMenWomen IS NULL )"));
} else {
cnd.and(new Static("(eve.isMenWomen =2 OR eve.isMenWomen IS NULL)"));
}
}
}
}*/
if (Strings.isNotBlank(isAudit)) {
cnd.and(new Static("(SELECT COUNT(1) FROM activity_school_apply WHERE eventId = ase.eventId AND activityId = ase.activityId AND userId='%s')%s0".formatted(ShiroUtil.getUserId(), (isAudit.equals("true") ? ">" : "="))));
}
Vi.cndPlus(cnd, "ase.activityId", "=", activityId);
Vi.cndPlus(cnd, "ase.eventId", "=", eventId);
Vi.cndPlus(cnd, "YEAR(school.applyStartTime)", "=", year);
cnd.asc("eve.projectType").desc("eve.allName");
sql.setCondition(cnd);
return activitySchoolEventViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
/**
* 如果当前项目是综合类活动就添加工会总领队和教练
*
* @param LeaderData
* @param CoachData
* @return
*/
@At
@ViReturn
public Object doLeaderCoachHead(@Param(value = "staffData", required = false) ActivitySchoolApply staffData,
@Param(value = "LeaderData", required = false) ActivitySchoolApply LeaderData,
@Param(value = "CoachData", required = false) ActivitySchoolApply CoachData,
@Param(value = "headData", required = false) ActivitySchoolApply headData,
String activityId) {
activitySchoolApplyService.clear(Cnd.where("activityId", "=", activityId).and("unionStaff", "=", true).and("unionId", "=", getUnionId()));
activitySchoolApplyService.clear(Cnd.where("activityId", "=", activityId).and("unionLeader", "=", true).and("unionId", "=", getUnionId()));
activitySchoolApplyService.clear(Cnd.where("activityId", "=", activityId).and("unionCoach", "=", true).and("unionId", "=", getUnionId()));
activitySchoolApplyService.clear(Cnd.where("activityId", "=", activityId).and("unionHead", "=", true).and("unionId", "=", getUnionId()));
if (staffData.getUserId() != null) {
ActivityBasicUnit basicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", staffData.getUnitId()));
ActivityBasicUnion basicUnion = activitySchoolService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", basicUnit.getUnionid()));
staffData.setApplyUser(ShiroUtil.getPrincipalProperty("id").toString());
staffData.setApplyDate(DateUtil.getDate());
staffData.setUnitname(basicUnit.getName());
staffData.setActivityUnionId(basicUnion.getId());
staffData.setActivityUnionName(basicUnion.getUnionname());
activitySchoolApplyService.insert(staffData);
}
if (LeaderData.getUserId() != null) {
ActivityBasicUnit basicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", LeaderData.getUnitId()));
ActivityBasicUnion basicUnion = activitySchoolService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", basicUnit.getUnionid()));
LeaderData.setApplyUser(ShiroUtil.getPrincipalProperty("id").toString());
LeaderData.setApplyDate(DateUtil.getDate());
LeaderData.setUnitname(basicUnit.getName());
LeaderData.setActivityUnionId(basicUnion.getId());
LeaderData.setActivityUnionName(basicUnion.getUnionname());
activitySchoolApplyService.insert(LeaderData);
}
if (CoachData.getUserId() != null) {
ActivityBasicUnit basicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", CoachData.getUnitId()));
ActivityBasicUnion basicUnion = activitySchoolService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", basicUnit.getUnionid()));
CoachData.setApplyUser(ShiroUtil.getPrincipalProperty("id").toString());
CoachData.setApplyDate(DateUtil.getDate());
CoachData.setUnitname(basicUnit.getName());
CoachData.setActivityUnionId(basicUnion.getId());
CoachData.setActivityUnionName(basicUnion.getUnionname());
activitySchoolApplyService.insert(CoachData);
}
if (headData.getUserId() != null) {
ActivityBasicUnit basicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", headData.getUnitId()));
ActivityBasicUnion basicUnion = activitySchoolService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", basicUnit.getUnionid()));
headData.setApplyUser(ShiroUtil.getPrincipalProperty("id").toString());
headData.setApplyDate(DateUtil.getDate());
headData.setUnitname(basicUnit.getName());
headData.setActivityUnionId(basicUnion.getId());
headData.setActivityUnionName(basicUnion.getUnionname());
activitySchoolApplyService.insert(headData);
}
return null;
}
@At
@ViReturn
public Object getUnionCoachLeaderHead(@Param(value = "activityId", required = false) String activityId) {
Map result = new HashMap();
Sql sql = Sqls.create("""
SELECT apply.*,us.unitname FROM activity_school_apply apply LEFT JOIN `user` us ON us.id=apply.userId WHERE apply.activityId=@activityId and apply.unionId=@unionId
""");
sql.setParam("unionId", getUnionId());
sql.setParam("activityId", activityId);
List<NutMap> list = activitySchoolApplyService.listMap(sql);
NutMap unionCoach = list.stream().filter(v -> {
return v.getBoolean("unionCoach");
}).findFirst().orElse(null);
NutMap unionLeader = list.stream().filter(v -> {
return v.getBoolean("unionLeader");
}).findFirst().orElse(null);
NutMap unionHead = list.stream().filter(v -> {
return v.getBoolean("unionHead");
}).findFirst().orElse(null);
NutMap unionStaff = list.stream().filter(v -> {
return v.getBoolean("unionStaff");
}).findFirst().orElse(null);
result.put("unionCoach", unionCoach);
result.put("unionLeader", unionLeader);
result.put("unionHead", unionHead);
result.put("unionStaff", unionStaff);
List userOptions = List.of();
ArrayList arrayList = new ArrayList<>(userOptions);
if (unionCoach != null) {
arrayList.add(sysUserService.fetch(unionCoach.getString("userId")));
}
if (unionLeader != null) {
arrayList.add(sysUserService.fetch(unionLeader.getString("userId")));
}
if (unionHead != null) {
arrayList.add(sysUserService.fetch(unionHead.getString("userId")));
}
if (unionStaff != null) {
arrayList.add(sysUserService.fetch(unionStaff.getString("userId")));
}
result.put("userOptions", arrayList);
return result;
}
@At
@ViReturn
public Object getActivityData(@Param(value = "activityId", required = false) String activityId) {
return activitySchoolApplyService.query(Cnd.where("activityId", "=", activityId).and("awardsMode", "=", 1));
}
@At
@ViReturn
public Object doDeleteApply(@Param(value = "activityId", required = false) String activityId,
@Param(value = "userId", required = false) String userId,
@Param(value = "eventId", required = false) String eventId) {
return activitySchoolApplyService.clear(Cnd.where("activityId", "=", activityId).and("eventId", "=", eventId).and("userId", "=", userId));
}
/**
* 删除报名人员
*
* @param activityId 活动
* @param userId 用户
* @return
*/
@At
@Async
public Object doDeleteActivityRegister(
@Param(value = "activityId", required = false) String activityId,
@Param(value = "userId", required = false) String userId) {
Cnd cnd = Cnd.where("tissueId", "=", activityId).and("userId", "=", userId);
simpleService.dao().clear(ActivityTissuePerson.class, cnd);
return Result.success();
}
@At
@ViReturn
@RequiresPermissions("activity.apply")
@Ok("json:{ignoreNull:true}")
public Object getSysUser(String queryString, String[] loginnames, String eventId, String activityId) {
Cnd cnd = Cnd.NEW();
cnd.andEX("loginname", "not in", loginnames);
if (StrUtil.isNotBlank(queryString)) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.andLike("username", queryString).orLike("loginname", queryString);
cnd.and(group);
}
cnd.and("unionid", "!=", Vi.getUnionId());
cnd.and(new Static("id not in (select userId from activity_school_apply where activityId ='%s' and eventId='%s')".formatted(activityId, eventId)));
Sql sql = Sqls.create("""
SELECT
id,
loginname,
username,
sex,
unitid,
unionid,
unionname,
birthday
FROM
`user`
$condition
LIMIT 30
""");
sql.setCondition(cnd);
List<NutMap> list = sysUserService.listMap(sql);
return list;
}
}
@@ -0,0 +1,87 @@
package io.v.nutz.activity.controller.school;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.dao.CndPlus;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
/**
* @author: Aaron
* @create: 2021-02-24 16:32
* @description: 活动日历
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/calendar")
@RequiresAuthentication
public class ActivityCalendarController {
@Inject
private ActivitySchoolService activitySchoolService;
@At("")
@Ok("beetl:platform/activity/school/ActivityCalendar.html")
@RequiresPermissions("activity.calendar")
public void index() {
}
@At
@ViReturn
public Object getData() {
CndPlus cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
school.id,
school.`name`,
school.address,
school.applyStartTime,
school.applyEndTime,
school.startTime,
school.endTime,
un.`name` unitName
FROM
activity_school school
LEFT JOIN sys_unit un ON un.id = school.unitSponsor
$condition
""");
cnd.desc("school.startTime");
sql.setCondition(cnd);
return activitySchoolService.listMap(sql);
}
@At
@ViReturn
public Object getWyData() {
Sql sql = Sqls.create("""
SELECT
id,
`name`,
address,
applyStartTime,
applyEndTime,
startTime,
endTime,
type activityType
FROM
activity_tissue
WHERE
signUpMethod = 1
""");
return activitySchoolService.listMap(sql);
}
}
@@ -0,0 +1,695 @@
package io.v.nutz.activity.controller.school;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.hutool.core.util.StrUtil;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
import io.v.nutz.activity.models.*;
import io.v.nutz.activity.services.ActivityPlanService;
import io.v.nutz.activity.services.ActivitySchoolApplyService;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_union;
import io.v.nutz.sys.models.Sys_unit;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysUnionService;
import io.v.nutz.util.ShiroUtil;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* @author: Aaron
* @create: 2021-02-23 14:32
* @description: 活动通用
**/
@At("/platform/activity/common")
@IocBean
@RequiresAuthentication
@Ok("json:full")
public class ActivityCommonController {
/*@Inject
private HdTypeService hdTypeService;*/
@Inject
private SysUnionService sysUnionService;
@Inject
private ActivitySchoolService activitySchoolService;
@Inject
private ActivityPlanService activityPlanService;
@Inject
private ActivitySchoolApplyService activitySchoolApplyService;
@Inject("ActivityEvent")
private ViService<ActivityEvent> activityEventService;
@Inject("ActivitySchoolTeam")
private ViService<ActivitySchoolTeam> activitySchoolTeamViService;
@Inject("ActivitySchoolEvent")
private ViService<ActivitySchoolEvent> activitySchoolEventService;
// @Inject
// private OfficeTemplateUtil officeTemplateUtil;
/**
* 获取活动类型
*
* @return
*/
/* @At
@ViReturn
public Object getType() {
return hdTypeService.query(Cnd.where("parentid", "=", "0").asc("pxbh"));
}*/
@At
@ViReturn
public Object getActivityType() {
return activityPlanService.list(Sqls.create("select * from activity_basic_settings where parentId = 'b3b6bafe6dd74aa8b69691b6b75b50fd' order by code asc"));
}
/**
* 获取小队
*
* @return
*/
@At
@ViReturn
public Object getTeam() {
return activitySchoolTeamViService.query(Cnd.orderBy().asc("location"));
}
/**
* 获取活动项目
*
* @return
*/
@At
@ViReturn
public Object getEvents(Integer type) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
ae.*
FROM
activity_event ae
LEFT JOIN activity_basic_settings ba ON ae.competitionCategory = ba.id
$condition
""");
cnd.and("ae.whetherEnable", "=", 1);
if (type != null && type == 1) {
cnd.and("ae.projectType", "=", 2);
} else if (type != null && type == 3) {
cnd.and("ae.projectType", "=", 1);
}
cnd.and(new Static("""
1=1
ORDER BY
ae.isMenWomen DESC,
CASE
ba.`name`
WHEN '甲组' THEN
1
WHEN '乙组' THEN
2
WHEN '丙组' THEN
3
WHEN '丁组' THEN
4
WHEN '团体' THEN
5
END
"""));
sql.setCondition(cnd);
return activityEventService.listMap(sql);
}
/**
* 获取校级活动计划
*
* @return
*/
@At
@ViReturn
public Object getSchoolActivityPlan(@Param(value = "type", required = false) Integer type) {
return activityPlanService.listMap(Sqls.create("select * from activity_plan where type = @type").setParam("type", type));
}
private String getUnionId() {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
Sys_unit unit = user.getUnit();
return unit == null ? "" : unit.getUnionid();
}
@At
@ViReturn
public Object findOne(String id) {
String unionid = getUnionId();
Sql sql = Sqls.create("""
SELECT
act.*,
plan.`name` plan
FROM
activity_school act
LEFT JOIN activity_plan plan ON act.planId = plan.id
WHERE
act.id = @id
""").setParam("id", id);
NutMap nutMap = activitySchoolService.listMap(sql).get(0);
Sql eventSql = Sqls.create("""
SELECT
ase.*,
ae.allName,
ae.projectType,
sch.applyType
FROM
activity_school_event ase
LEFT JOIN activity_event ae ON ae.id = ase.eventId
LEFT JOIN activity_school sch ON sch.id=ase.activityId
WHERE
activityId = @activityId
""").setParam("activityId", id);
List<NutMap> eventMap = activitySchoolEventService.listMap(eventSql);
nutMap.setv("events", eventMap);
Sql sql1 = Sqls.create("""
SELECT
app.*,
team.`name` team2,
ev.allName
FROM
activity_school_apply app
LEFT JOIN activity_event ev ON app.eventId=ev.id
LEFT JOIN activity_school_team team ON app.teamId = team.id
LEFT JOIN sys_unit unit ON app.unitId = unit.id
WHERE
app.activityId = @id
ORDER BY
ev.allName DESC,
ev.projectType ASC,
team.`name` ASC,
app.sex
""").setParam("id", id);
if (!ShiroUtil.hasAnyRoles("sysadmin,A06") && ShiroUtil.hasRole("H04")) {
sql1.setVar("union", " AND app.unionId = '" + unionid + "' ");
}
List<NutMap> applies = activitySchoolApplyService.listMap(sql1);
List<Integer> applyWay = Json.fromJsonAsList(Integer.class, nutMap.getString("applyWay"));
if (applyWay.stream().anyMatch(v -> v.equals(2))) {
List<NutMap> apply = new ArrayList();
Cnd unionCnd = Cnd.NEW();
if (!ShiroUtil.hasAnyRoles("sysadmin,A06") && ShiroUtil.hasRole("H04")) {
unionCnd.and("id", "=", unionid);
}
List<Sys_union> unions = sysUnionService.query(unionCnd);
for (Sys_union union : unions) {
String union_id = union.getId();
NutMap map = new NutMap();
List<NutMap> applyList = applies.stream().filter(v -> {
return v.getString("unionId").equals(union_id);
}).collect(Collectors.toList());
map.setv("id", union_id);
map.setv("unionname", union.getUnionname());
map.setv("unioncode", union.getUnioncode());
map.setv("num", applyList.size());
map.setv("apply", applyList);
apply.add(map);
}
nutMap.setv("apply", apply);
}
return nutMap;
}
@At
public void exportXlsx(String id, String unionId, HttpServletResponse response) throws IOException {
Sql sql = Sqls.create("""
SELECT
app.username,
app.loginname,
app.identity,
app.activityUnionName unionname,
app.sex,
u.mobile,
u.idCard,
u.userState,
ev.allName,
sc.`name` activityName,
app.`team` team,
app.birthday,
YEAR(CURDATE()) -LEFT(app.birthday,4) age,
GROUP_CONCAT(DISTINCT ev.allName SEPARATOR '、') as allNames,
GROUP_CONCAT(DISTINCT app.identity SEPARATOR '、') as identitys
FROM
`activity_school_apply` app
LEFT JOIN `user` u ON u.id = app.userId
LEFT JOIN activity_event ev ON ev.id = app.eventId
LEFT JOIN activity_school sc ON sc.id=app.activityId
WHERE
activityId = @id
and app.status = 2
$cnd
GROUP BY
app.loginname
ORDER BY
app.activityUnionId DESC,
ev.allName DESC,
app.`team` asc
""").setParam("id", id);
if (Strings.isNotBlank(unionId)) {
sql.setVar("cnd", "and app.activityUnionId='" + unionId + "'");
}
List<Record> list = activitySchoolApplyService.list(sql);
String activityName = list.get(0).getString("activityName");
List<ActivitySchoolApply> excels = new ArrayList<>();
list.forEach(z -> {
ActivitySchoolApply schoolApply = z.toPojo(ActivitySchoolApply.class);
Pattern pattern = Pattern.compile("\"(\\d+)\"");
Matcher matcher = pattern.matcher(schoolApply.getIdentitys());
List<String> numbers = new ArrayList<>();
while (matcher.find()) {
numbers.add(matcher.group(1)); // group(1) 是括号里捕获的数字
}
List<String> intNumbers = new ArrayList<>();
intNumbers.addAll(numbers);
String s = intNumbers.stream().map(personType::getName).collect(Collectors.toList()).toString();
schoolApply.setSf(s.replace("[", "").replace("]", ""));
excels.add(schoolApply);
});
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + new String((activityName + "报名表.xls").getBytes("utf-8"), "ISO8859-1"));
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), ActivitySchoolApply.class, excels);
workbook.write(response.getOutputStream());
}
private static class personType {
private static String getName(String v) {
switch (v) {
case "1":
return "运动员";
case "2":
return "教练";
case "3":
return "领队";
case "4":
return "处级领导";
case "5":
return "替补";
case "6":
return "团长";
case "7":
return "工作人员";
default:
return "";
}
}
}
/**
* 导出
*
* @param id
* @param response
*/
@At
@Ok("void")
public void export(String id, String unionId, HttpServletResponse response) throws IOException {
ActivitySchool activity = activitySchoolService.fetch(id);
Map map = new HashMap();
List list = new ArrayList();
CndPlus unionCnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT * FROM sys_union un $condition
""");
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
if (ShiroUtil.hasRole("H04")) {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
Sys_unit unit = user.getUnit();
unionCnd.and("un.id", "=", unit.getUnionid());
}
} else {
unionCnd.andExcludeEmpty("un.id", "=", unionId);
}
unionCnd.and(new Static("(SELECT count(1) from activity_school_apply app WHERE app.unionId = un.id and app.status = 2 and app.activityId='%s') > 0".formatted(id)));
sql.setCondition(unionCnd);
List<Sys_union> unions = sysUnionService.listEntity(sql);
CndPlus cnd = CndPlus.create();
Sql sql1 = Sqls.create("""
SELECT
ae.allName,
app.*,
team.`name` teamName,
unit.`name` unitName,
gh.unionname AS unionName
FROM
activity_school_apply app
LEFT JOIN activity_event ae ON ae.id = app.eventId
LEFT JOIN activity_school_team team ON app.teamId = team.id
LEFT JOIN sys_unit unit ON app.unitId = unit.id
LEFT JOIN sys_union gh ON gh.id = unit.unionid
$condition
""");
cnd.andExcludeEmpty("app.activityId", "=", id);
cnd.andExcludeEmpty("app.unionId", "=", unionId);
cnd.desc("app.divisionLevelLeadership").asc("team.location").asc("app.sex");
sql1.setCondition(cnd);
List<ActivitySchoolApply> applies = activitySchoolApplyService.listEntity(sql1, ActivitySchoolApply.class);
List<NutMap> mapList = activitySchoolApplyService.listMap(sql1);
for (NutMap apply : mapList) {
String oldUsername = apply.getString("username");
String username = apply.getString("username");
String sex = apply.getString("sex");
boolean unionHead = apply.getBoolean("unionHead");
boolean coach = Json.fromJsonAsList(String.class, apply.getString("identity")).stream().anyMatch(v -> v.equals("2"));
boolean leader = Json.fromJsonAsList(String.class, apply.getString("identity")).stream().anyMatch(v -> v.equals("3"));
boolean substitute = Json.fromJsonAsList(String.class, apply.getString("identity")).stream().anyMatch(v -> v.equals("5"));
boolean divisionLevelLeadership = Json.fromJsonAsList(String.class, apply.getString("identity")).stream().anyMatch(v -> v.equals("4"));
boolean women = "".equals(sex);
if (women || divisionLevelLeadership || coach || leader) {
username += "";
if (women) {
username += "";
}
if (coach && username.equals(oldUsername)) {
username += "教练 ";
}
if (leader && username.equals(oldUsername)) {
username += "领队 ";
}
if (unionHead && username.equals(oldUsername)) {
username += "团长 ";
}
if (substitute && username.equals(oldUsername)) {
username += "替补 ";
}
if (divisionLevelLeadership && username.equals(oldUsername)) {
username += "处级领导 ";
}
username += "";
String subUserName = username.substring(0, username.length() - 2);
if (!women && subUserName.equals(oldUsername)) {
apply.setv("username", oldUsername);
} else {
apply.setv("username", username);
}
// apply.setv("username", (!women && username.equals(oldUsername)) ? oldUsername : username);
}
}
for (Sys_union union : unions) {
String union_id = union.getId();
Map m = new HashMap<>();
m.put("id", union_id);
m.put("name", union.getUnionname());
List<NutMap> users = mapList.stream().filter(v -> {
return v.getString("unionId").equals("2b113edb7e7d4494a9cdfd7672a0ed90");
}).collect(Collectors.toList());
/* List<NutMap> users = mapList.stream().filter(v -> {
return v.getString("unionId").equals(union_id);
}).collect(Collectors.toList());*/
List<NutMap> collect1 = users.stream().filter(v -> v.getString("team") != null).collect(Collectors.toList());
Map<String, List<NutMap>> allName = collect1.stream().collect(Collectors.groupingBy(all -> all.getString("allName"), Collectors.toList()));
LinkedHashMap<String, List<NutMap>> collect = collect1.stream().filter(v -> {
return Json.fromJsonAsList(String.class, v.getString("identity")).stream().anyMatch(x -> x.equals("1") || x.equals("2") || x.equals("3") || x.equals("4") || x.equals("5"));
}).collect(Collectors.groupingBy(record -> record.getString("team"), LinkedHashMap::new, Collectors.toList()));
List<Map> teams = new ArrayList();
List<NutMap> leaderList = new ArrayList<>();
collect.forEach((key, val) -> {
List<NutMap> ydy = val.stream().filter(v -> Json.fromJsonAsList(String.class, v.getString("identity")).stream().anyMatch(x -> x.equals("1") || x.equals("5"))).collect(Collectors.toList());
List<NutMap> coach = val.stream().filter(v -> Json.fromJsonAsList(String.class, v.getString("identity")).stream().anyMatch(x -> x.equals("2"))).collect(Collectors.toList());
List<NutMap> leader = val.stream().filter(v -> Json.fromJsonAsList(String.class, v.getString("identity")).stream().anyMatch(x -> x.equals("3"))).collect(Collectors.toList());
List<NutMap> divisionLevelLeadership = val.stream().filter(v -> Json.fromJsonAsList(String.class, v.getString("identity")).stream().anyMatch(x -> x.equals("4"))).collect(Collectors.toList());
Map mm = new HashMap<>();
mm.put("name", key);
mm.put("coach", coach);
mm.put("leader", leader);
mm.put("divisionLevelLeadership", divisionLevelLeadership);
mm.put("users", ydy);
if (key.equals("第1队") && leader.size() > 0) {
leaderList.add(leader.get(0));
}
teams.add(mm);
});
m.put("id1", teams);
if (activity.getApplyType() == 1) {
m.put("id3", leaderList);
} else {
//教练
List<NutMap> id2 = users.stream().filter(v -> StrUtil.isNotBlank(v.getString("unionCoach")) && v.getBoolean("unionCoach")).collect(Collectors.toList());
m.put("id2", id2);
if (id2.size() > 0) m.put("coachName", "基层工会教练:");
//领队
List<NutMap> id3 = users.stream().filter(v -> StrUtil.isNotBlank(v.getString("unionLeader")) && v.getBoolean("unionLeader")).collect(Collectors.toList());
m.put("id3", id3);
if (id3.size() > 0) m.put("leaderName", "基层工会领队:");
//领队
List<NutMap> id4 = users.stream().filter(v -> StrUtil.isNotBlank(v.getString("unionHead")) && v.getBoolean("unionHead")).collect(Collectors.toList());
m.put("id4", id4);
if (id4.size() > 0) m.put("unionHead", "基层工会团长:");
}
list.add(m);
}
map.put("list", list);
String fileName = activity.getName() + "人员名单";
response.addHeader("Content-Type", "application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + "\".docx");
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
Configure config = Configure.newBuilder().bind("users", policy).build();
String templateUrl = "";
if (activity.getApplyType() == 1) {
// templateUrl = officeTemplateUtil.getPath("activity_list1");
} else if (activity.getApplyType() == 2) {
// templateUrl = officeTemplateUtil.getPath("activity_list");
}
XWPFTemplate.compile(templateUrl, config).render(map).writeAndClose(response.getOutputStream());
;
}
/* @At
public void export(String id, HttpServletResponse response) throws IOException {
ActivitySchool activity = activitySchoolService.fetch(id);
Map map = new HashMap();
List list = new ArrayList();
Cnd unionCnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT * FROM sys_union un $condition
""");
if (!ShiroUtil.hasAnyRoles("sysadmin,A06") && ShiroUtil.hasRole("H04")) {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
Sys_unit unit = user.getUnit();
unionCnd.and("un.id", "=", unit.getUnionid());
}
unionCnd.and(new Static("(SELECT count(1) from activity_school_apply app WHERE app.unionId = un.id and app.status = 2) > 0"));
sql.setCondition(unionCnd);
List<Sys_union> unions = sysUnionService.listEntity(sql);
Sql sql1 = Sqls.create("""
SELECT
app.*,
team.`name` team,
unit.`name` unitname
FROM
activity_school_apply app
LEFT JOIN activity_school_team team ON app.teamId = team.id
LEFT JOIN sys_unit unit ON app.unitId = unit.id
WHERE
app.activityId = @id
ORDER BY
app.divisionLevelLeadership DESC,
app.identity DESC,
team.location ASC,
app.sex
""").setParam("id", id);
List<Record> applies = activitySchoolApplyService.list(sql1);
for (Record apply : applies) {
String username = apply.getString("username");
String sex = apply.getString("sex");
boolean division_level_leadership = Boolean.parseBoolean(apply.getString("divisionLevelLeadership"));
boolean women = "女".equals(sex);
if (women || division_level_leadership) {
username += "";
if (women) {
username += "女";
}
if (division_level_leadership) {
if (women) {
username += " 处级领导";
} else {
username += "处级领导";
}
}
username += "";
apply.set("username", username);
}
}
for (Sys_union union : unions) {
String union_id = union.getId();
Map m = new HashMap<>();
m.put("id", union_id);
m.put("name", union.getUnionname());
List<Record> users = applies.stream().filter(v -> {
return v.getString("unionId").equals(union_id);
}).collect(Collectors.toList());
//运动员
Map<String, List<Record>> collect = users.stream().filter(v -> {
return v.getInt("identity") == 1;
}).collect(Collectors.groupingBy(record -> record.getString("team"), LinkedHashMap::new, Collectors.toList()));
List<Map> teams = new ArrayList();
collect.forEach((key, val) -> {
Map mm = new HashMap<>();
mm.put("name", key);
mm.put("users", val);
teams.add(mm);
});
m.put("id1", teams);
//教练
List<Record> id2 = users.stream().filter(v -> {
return v.getInt("identity") == 2;
}).collect(Collectors.toList());
id2 = id2;
m.put("id2", id2);
//领队
List<Record> id3 = users.stream().filter(v -> {
return v.getInt("identity") == 3;
}).collect(Collectors.toList());
m.put("id3", id3);
list.add(m);
}
map.put("list", list);
String fileName = activity.getName() + "人员名单";
response.addHeader("Content-Type", "application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + "\".docx");
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
Configure config = Configure.newBuilder().bind("users", policy).build();
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/activity/list.docx");
XWPFTemplate.compile(inputStream, config).render(map, response.getOutputStream());
inputStream.close();
}*/
@At
@ViReturn
public Object findOnePlan(String id) {
return activityPlanService.findOne(id);
}
}
@@ -0,0 +1,237 @@
package io.v.nutz.activity.controller.school;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.activity.models.ActivitySchoolApply;
import io.v.nutz.activity.models.SchoolAssignGrades;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.services.SysUnitService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.List;
/**
* Created by djx on 2019/6/28.
* 活动成绩管理Controller
*/
@IocBean
@At("/platform/activity/school/grades")
public class ActivityGradesController {
/* @Inject
private HdXhdService hdXhdService;*/
@Inject
private SysUnitService sysUnitService;
@Inject
private ActivitySchoolService activitySchoolService;
@At("")
@Ok("beetl:platform/activity/school/ActivityGrades.html")
@RequiresPermissions("activity.school.grades")
public void index() {
}
@At
@Ok("json")
@ViReturn
public Object data(String name, String activityId, String eventId, String jsms, String year, int pageNumber, int pageSize) {
Sql sql = Sqls.create("""
SELECT
school.id,
school.planId,
school.`name`,
school.address,
ase.eventId,
school.applyStartTime,
school.applyEndTime,
school.startTime,
school.endTime,
school.unitSponsor,
school.unitJointly,
school.gameStyle,
ase.awardsMode,
school.funding,
school.applyWay,
ase.combinationMethod,
school.personType,
school.activityLevel,
even.allName,
( SELECT COUNT(1) FROM activity_school_apply WHERE eventId=ase.eventId AND activityId=ase.activityId ) applyNum\s
FROM
activity_school school
LEFT JOIN activity_school_event ase ON ase.activityId=school.id
LEFT JOIN activity_event even ON even.id = ase.eventId
$condition
""");
CndPlus cnd = CndPlus.create();
// cnd.and(new Static("CURRENT_DATE() >= school.endTime"));
if (Strings.isNotBlank(name)) {
cnd.where().andLike("school.name", name);
}
if (Strings.isNotBlank(jsms)) {
cnd.and("asa.gameStyle", "=", jsms);
}
cnd.andExcludeEmpty("YEAR(school.startTime)", "=", year);
if (Strings.isNotBlank(activityId)) {
cnd.and("school.id", "=", activityId);
}
if (Strings.isNotBlank(eventId)) {
cnd.and("ase.eventId", "=", eventId);
}
cnd.desc("school.startTime");
sql.setCondition(cnd);
Pagination pagination = activitySchoolService.listPageMap(pageNumber, pageSize, sql);
NutMap map = new NutMap();
map.put("hds", pagination);
map.put("unit", sysUnitService.query(Cnd.where("unitlevel", "=", "2")));
return map;
}
@Inject
private ViService<ActivitySchoolApply> activitySchoolApplyViService;
@At
@Ok("json")
public Object findUnit(String id) {
Sql sql = Sqls.create("""
SELECT
apply.activityId,
apply.unitId,
us.unitname,
apply.id
FROM
activity_school_apply apply
LEFT JOIN `user` us ON apply.unitId = us.unitid
WHERE apply.activityId=@id
GROUP BY
us.unitname
""");
sql.params().set("id", id);
List<Record> re = activitySchoolApplyViService.list(sql);
return Result.success().addData(re);
}
/*查询参赛人员*/
@At
@Ok("json")
public Object findCyRy(String unitid, String hdid) {
Sql sql = Sqls.create("""
SELECT
us.username,
us.sex
FROM
activity_school_apply apply
LEFT JOIN `user` us ON apply.userId = us.id
WHERE identity=1 AND apply.activityId=@hdid AND apply.unitId=@unitid
""").setParam("hdid", hdid).setParam("unitid", unitid);
return Result.success().addData(activitySchoolApplyViService.list(sql));
}
@Inject("SchoolAssignGrades")
private ViService<SchoolAssignGrades> schoolAssignGradesViService;
/*团队获奖设置*/
@At
@Ok("json")
public Object tdDo(@Param("grades") SchoolAssignGrades[] grades, String unitid, String eventId) {
schoolAssignGradesViService.clear(Cnd.where("unitId", "=", unitid).and("eventId", "=", eventId));
schoolAssignGradesViService.insert(grades);
return Result.success();
}
@At
@Ok("json")
public Object findGrUser(String id, String eventId, @Param("searchKeyword") String searchKeyword, @Param("unit") String unit, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
us.unitname,
apply.*
FROM
activity_school_apply apply
LEFT JOIN `user` us ON apply.userId = us.id $condition
""");
Vi.cndPlus(cnd, "apply.activityId", "=", id);
Vi.cndPlus(cnd, "apply.eventId", "=", eventId);
Vi.cndPlus(cnd, "apply.unitId", "=", unit);
Vi.cndPlus(cnd, "apply.userId", "NOT IN", "(SELECT userId FROM school_assign_grades WHERE userId IS NOT NULL)");
SqlExpressionGroup group = new SqlExpressionGroup();
group.orLike("us.username", searchKeyword);
group.orLike("us.loginname", searchKeyword);
cnd.and(group);
sql.setCondition(cnd);
return Result.success().addData(schoolAssignGradesViService.listPage(pageNumber, pageSize, sql));
}
@At
@Ok("json")
public Object findSaveCj(String id, String eventId) {
return Result.success().addData(schoolAssignGradesViService.query(Cnd.where("activityId", "=", id).and("eventId", "=", eventId)));
}
@At
@Ok("json")
public Object findGrCj(String id, String eventId) {
return Result.success().addData(schoolAssignGradesViService.query(Cnd.where("activityId", "=", id).and("eventId", "=", eventId)));
}
/*个人获奖设置*/
@At
@Ok("json")
public Object grjxDo(@Param("grades") SchoolAssignGrades[] grades, String unitid, String eventId) {
/*hdXhdService.clear("hd_hdcj", Cnd.where("hdid", "=", nutMap.getString("hdid")));
List<NutMap> list = Json.fromJsonAsList(NutMap.class, nutMap.getString("data"));
for (int i = 0; i < list.size(); i++) {
NutMap cc = list.get(i);
hdXhdService.insert("hd_hdcj", Chain.make("id", R.UU32()).add("hdid", cc.getString("hdid")).add("userid", cc.getString("userid")).add("mc", cc.getString("mc")).add("unitid", cc.getString("unitid")).add("hdms", cc.getString("hdms")).add("jpmc", cc.getString("jpmc")).add("money", cc.getString("money")).add("jplx", cc.getString("jplx")));
}
if (nutMap.getString("save").equals("1")) {
hdXhdService.update(Chain.make("sftj", "1"), Cnd.where("id", "=", nutMap.getString("hdid")));
}*/
schoolAssignGradesViService.insert(grades);
return Result.success();
}
}
@@ -0,0 +1,315 @@
package io.v.nutz.activity.controller.school;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.activity.models.*;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.result.Result;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_file;
import io.v.nutz.sys.services.SysMsgService;
import io.v.nutz.util.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.List;
/**
* @author: Aaron
* @create: 2021-02-22 14:52
* @description: 活动信息管理
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/school/info/mange")
@RequiresAuthentication
public class ActivityInfoManageController {
@Inject
private ActivitySchoolService activitySchoolService;
@Inject
private Vi vi;
@Inject("ActivitySchoolEvent")
private ViService<ActivitySchoolEvent> activitySchoolEventService;
@Inject
private SysMsgService sysMsgService;
@At("")
@Ok("beetl:platform/activity/school/ActivityManage.html")
@RequiresPermissions("activity.school.info")
public void index() {
}
@At
@ViReturn
public Object pageData(PageForm page,
@Param(value = "year", required = false) Integer year,
@Param(value = "name", required = false) String name,
@Param(value = "gameStyle", required = false) String gameStyle,
@Param(value = "query", required = false) String query,
@Param(value = "activityId", required = false) String activityId,
@Param(value = "activityLevel", required = false) String activityLevel) {
CndPlus cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
cl.`name` clubName,
un.unionname,
ba.`name` activityLevelName,
school.id,
school.planId,
school.name,
school.address,
school.applyStartTime,
school.applyEndTime,
school.startTime,
school.endTime,
school.unitSponsor,
school.unitJointly,
school.gameStyle,
school.funding,
school.applyWay,
school.personType,
school.activityLevel,
school.isSave,
school.activityGroupId,
school.activityCode,
school.foundDate,
school.applyType,
(SELECT COUNT(1) FROM activity_school_apply asa WHERE asa.activityId = school.id && asa.status=2) applyNum
FROM
activity_school school
LEFT JOIN activity_basic_settings ba ON ba.`code` = school.activityLevel
LEFT JOIN sys_union un ON un.id = school.belongUnionId
LEFT JOIN sys_club cl ON cl.id = school.belongClubId
$condition
""");
if ("one".equals(query)) {
cnd.and(new Static("now() > school.applyStartTime and now() < school.applyEndTime"));
} else if ("two".equals(query)) {
cnd.and(new Static("now() > school.applyEndTime and now() < school.startTime"));
} else if ("three".equals(query)) {
cnd.and(new Static("now() > school.startTime and now() < school.endTime"));
} else if ("four".equals(query)) {
cnd.and(new Static("now() > school.endTime"));
}
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
if (ShiroUtil.hasRole("H04")) {
cnd.and("school.belongUnionId", "=", Vi.getUnionId());
}
if (ShiroUtil.hasRole("club01")) {
cnd.and("school.belongClubId", "in", vi.getMangeClubStr());
}
}
cnd.andExcludeEmpty("school.activityLevel", "=", activityLevel);
cnd.andExcludeEmpty("school.gameStyle", "=", gameStyle);
cnd.andExcludeEmpty("YEAR(school.applyStartTime)", "=", year);
cnd.andExcludeEmpty("school.id", "=", activityId);
cnd.desc("school.startTime");
sql.setCondition(cnd);
return activitySchoolService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("activity.school.info")
public Object doAdd(@Param(value = "data", required = false) ActivitySchool activitySchool, @Param(value = "events", required = false) ActivitySchoolEvent[] events) {
List<ActivityBasicUnion> activityBasicUnions = activitySchoolService.dao().query(ActivityBasicUnion.class, Cnd.where("isEnable", "=", true));
ActivityBasicUnit activityBasicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", ShiroUtil.getUnitId()));
if (activitySchool.getActivityLevel() == 40002) {
activitySchool.setBelongUnionId(activityBasicUnit.getUnionid());
}
activitySchool.setFoundDate(DateUtil.getDate());
String id = activitySchoolService.doAdd(activitySchool, events);
activityBasicUnions.forEach(v -> {
ActivityUnion activityUnion = new ActivityUnion();
activityUnion.setActivityId(id);
activityUnion.setUnionname(v.getUnionname());
activitySchoolService.insert(activityUnion);
});
List<Sys_file> image = activitySchool.getImage();
ActivityTissue activityTissue = new ActivityTissue();
activityTissue.setApplyTime(DateUtil.getDate());
activityTissue.setType(activitySchool.getActivityLevel());
activityTissue.setProjectTypeCode("50004");
activityTissue.setActivityCode(activitySchool.getActivityCode());
activityTissue.setName(activitySchool.getName());
activityTissue.setUserId(ShiroUtil.getUserId());
if (activitySchool.getActivityLevel() == 40002) {
activitySchool.setBelongUnionId(activityBasicUnit.getUnionid());
}
activityTissue.setState(3);
activityTissue.setClubId(activitySchool.getBelongClubId());
activityTissue.setAddress(activitySchool.getAddress());
activityTissue.setApplyStartTime(activitySchool.getApplyStartTime());
activityTissue.setApplyEndTime(activitySchool.getApplyEndTime());
activityTissue.setStartTime(activitySchool.getStartTime());
activityTissue.setEndTime(activitySchool.getEndTime());
if (image != null) {
activityTissue.setCover(image.get(0).getId());
}
activitySchoolService.insert(activityTissue);
activitySchoolService.update("activity_tissue", Chain.make("id", activitySchool.getId()), Cnd.where("id", "=", activityTissue.getId()));
activitySchoolEventService.clear(Cnd.where("eventId", "=", "allItems"));
activitySchoolEventService.clear(Cnd.where("eventId", "IS", null));
if (activitySchool.getXlFlag() != null && activitySchool.getXlFlag()) {
String time = activitySchool.getStartTime() + "" + activitySchool.getEndTime();
sysMsgService.sendMsgByActivityGroupId(activitySchool.getId(), activitySchool.getActivityGroupId(), "体育比赛活动", activitySchool.getName(), "/platform/activity/apply", "/mobile/activity/unionActivity", time);
}
return id;
}
@At
@ViReturn
@RequiresPermissions("activity.school.info")
public Object doEdit(@Param(value = "data", required = false) ActivitySchool activitySchool,
@Param(value = "events", required = false) ActivitySchoolEvent[] events) {
ActivitySchool school = activitySchoolService.fetch(activitySchool.getId());
if (school.getActivityLevel() == 40002) {
school.setBelongUnionId(Vi.getUnionId());
}
activitySchoolService.doEdit(activitySchool, events, school.getApplyEndTime());
activitySchoolEventService.clear(Cnd.where("eventId", "=", "allItems"));
activitySchoolEventService.clear(Cnd.where("eventId", "IS", null));
sysMsgService.deleteMsgByActivityId(activitySchool.getId());
if (activitySchool.getXlFlag() != null && activitySchool.getXlFlag()) {
String time = activitySchool.getStartTime() + "" + activitySchool.getEndTime();
sysMsgService.sendMsgByActivityGroupId(activitySchool.getId(), activitySchool.getActivityGroupId(), "体育比赛活动", activitySchool.getName(), "/platform/activity/apply", "/mobile/activity/unionActivity", time);
}
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.school.info")
public Object doDelete(String id) {
activitySchoolService.doDelete(id);
return null;
}
@At
@ViReturn
public Object findOne(String id) {
NutMap nutMap = activitySchoolService.fetch(Sqls.create("SELECT * FROM `activity_school` WHERE id = @id").setParam("id", id));
Sql sql = Sqls.create("""
SELECT
ase.*,
ae.projectType
FROM
activity_school_event ase
LEFT JOIN activity_event ae ON ae.id = ase.eventId
WHERE
ase.activityId = @activityId
""").setParam("activityId", id);
nutMap.setv("schoolEvents", activitySchoolEventService.listMap(sql));
return nutMap;
}
@Inject("ActivityEvent")
private ViService<ActivityEvent> activityEventViService;
@At
@ViReturn
public Object getEventData(String id) {
return activityEventViService.fetch(id);
}
@At
@ViReturn
public Object getEventApply(@Param(value = "activityId", required = false) String activityId,
@Param(value = "eventId", required = false) String[] eventId) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
ev.allName
FROM
activity_school_apply asa LEFT JOIN activity_event ev ON ev.id=asa.eventId
$condition
""");
cnd.and("asa.activityId", "=", activityId);
cnd.and("asa.eventId", "in", eventId);
cnd.groupBy("ev.allName");
sql.setCondition(cnd);
return activityEventViService.list(sql);
}
@At
@ViReturn
@RequiresPermissions("activity.school.info")
public Object doAssignmentDate(@Param(value = "eventIds", required = false) String[] eventIds,
ActivitySchoolEvent[] events) {
for (ActivitySchoolEvent event : events) {
ActivityEvent activityEvent = activityEventViService.fetch(event.getEventId());
if (!event.getEventId().equals("allItems")) {
event.setStartAgeDate(activityEvent.getStartAgeDate());
event.setEndAgeDate(activityEvent.getEndAgeDate());
activitySchoolEventService.updateIgnoreNull(event);
}
}
return Result.success(events);
}
@At
@ViReturn
public Object getUnionLimit(@Param(value = "activityScopeId", required = false) String activityScopeId) {
Sql sql = Sqls.create("""
SELECT
gh.id,
gh.unionname,
gh.unioncode,
(select count(1) from `user` where unionid = gh.id $cnd) as teacherCount,
NULL as ratio,
NULL as limitCount
FROM
sys_union gh
order by gh.unioncode
""");
if (StrUtil.isNotBlank(activityScopeId)) {
sql.setVar("cnd", "AND id in (select userId from activity_user_scope where groupId = '" + activityScopeId + "')");
}
return activitySchoolEventService.listMap(sql);
}
}
@@ -0,0 +1,77 @@
package io.v.nutz.activity.controller.school;
import io.v.nutz.activity.models.ActivityPlan;
import io.v.nutz.activity.services.ActivityPlanService;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
/**
* @author: Aaron
* @create: 2021-03-01 14:26
* @description: 活动计划
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/school/plan")
@RequiresAuthentication
public class ActivityPlanController {
@Inject
private ActivitySchoolService activitySchoolService;
@Inject
private ActivityPlanService activityPlanService;
@At("")
@Ok("beetl:platform/activity/school/ActivityPlan.html")
@RequiresPermissions("activity.plan")
public void index() {
}
@At
@ViReturn
public Object pageData(PageForm page, @Param(value = "year",required = false) String year,
@Param(value = "name",required = false) String name) {
CndPlus cnd = CndPlus.create();
cnd.andExcludeEmpty("ap.type", "=", 1);
return activityPlanService.pageData(page, year, name, null, cnd);
}
@At
@ViReturn
public Object doAdd(String name,String time,String content, String event) {
ActivityPlan activityPlan = new ActivityPlan();
activityPlan.setName(name);
activityPlan.setTime(time);
activityPlan.setContent(content);
activityPlan.setEvent(event);
activityPlan.setType("1");
activityPlanService.insert(activityPlan);
return null;
}
@At
@ViReturn
public Object doEdit(ActivityPlan activityPlan) {
activityPlanService.updateIgnoreNull(activityPlan);
return null;
}
@At
@ViReturn
public Object doDelete(String id) {
activityPlanService.delete(id);
return null;
}
}
@@ -0,0 +1,241 @@
package io.v.nutz.activity.controller.school;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivityResults;
import io.v.nutz.activity.models.ActivitySchoolEvent;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_union;
import io.v.nutz.sys.services.SysUnionService;
import lombok.Data;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author zhf
* @date 2021/5/27 15:57
* @description 奖品名单
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/prize/list")
@RequiresAuthentication
public class ActivityPrizeListController {
@At("")
@Ok("beetl:platform/activity/school/ActivityPrize.html")
@RequiresPermissions("activity.prize.list")
public void index() {
}
@Inject
private SysUnionService sysUnionService;
@Inject("ActivitySchoolEvent")
private ViService<ActivitySchoolEvent> eventViService;
@Inject("ActivityResults")
private ViService<ActivityResults> resultsViService;
private static NutMap nullMap = NutMap.NEW();
;
/**
* 各个分工会奖品
*
* @param activityId
* @param unionId
* @return
*/
@At
@ViReturn
public Object getPrizes(Integer year, String activityId, String unionId) {
Dao dao = resultsViService.dao();
// List<ActivitySchool> activitySchoolList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
//
// Optional<ActivitySchool> ydhOptional = activitySchoolList.stream().filter(v -> v.getName().contains("运动会")).findFirst();
//
// if (ydhOptional.isEmpty()) {
// return Map.of("团体项目", nullMap, "男子项目", nullMap, "女子项目", nullMap, "其他", nullMap);
// }
Sql sql = Sqls.create("""
SELECT
acr.activityId,
ace.allName,
acr.userId,
acr.ranking,
acr.numberOfPeople,
ace.isMenWomen,
acs.`name` as activityName,
u.username,
RIGHT(ace.allName,4) xmlx,
LEFT(ace.allName,2) xblx
FROM activity_school_event acse
left join activity_school acs on acs.id = acse.activityId AND acs.id=@activityId
left join activity_event ace on ace.id = acse.eventId
left join activity_results acr on acr.eventId = acse.eventId
left join sys_user u on u.id = acr.userId
$condition
""").setParam("activityId", activityId);
Cnd cnd = Cnd.NEW();
cnd.and("acr.activityId", "=", activityId);
cnd.and("YEAR(acs.applyStartTime)", "=", year);
// cnd.and("ace.isInterest", "=", 0);
cnd.and("acr.unionId", "=", unionId);
cnd.asc("ace.allName").asc("acr.ranking");
sql.setCondition(cnd);
sql.setCallback(Sqls.callback.maps());
dao.execute(sql);
List<NutMap> allList = sql.getList(NutMap.class);
if (Lang.isEmpty(allList)) {
return Map.of("团体项目", nullMap, "男子项目", nullMap, "女子项目", nullMap, "其他", nullMap);
}
// List<NutMap> yhdlist = allList.stream().filter(v -> v.getString("activityId").equals(ydhOptional.get().getId())).collect(Collectors.toList());
// List<NutMap> otherList = allList.stream().filter(v -> !v.getString("activityId").equals(ydhOptional.get().getId())).collect(Collectors.toList());
Map maleMap = NutMap.NEW();
Map femaleMap = NutMap.NEW();
Map teamMap = NutMap.NEW();
Map otherMap = NutMap.NEW();
// if (Lang.isNotEmpty(yhdlist)) {
Map<String, List<NutMap>> xmlxList = allList.stream().collect(Collectors.groupingBy(v -> v.getString("xmlx")));
if (Lang.isNotEmpty(xmlxList.get("(团体)"))) {
teamMap = xmlxList.get("(团体)").stream().collect(Collectors.groupingBy(v -> v.getString("allName")));
}
if (Lang.isNotEmpty(xmlxList.get("(单项)")) && xmlxList.get("(单项)").stream().anyMatch(v -> v.getString("xblx").equals("男子"))) {
maleMap = xmlxList.get("(单项)").stream().filter(v -> v.getString("xblx").equals("男子")).collect(Collectors.groupingBy(h -> h.getString("allName")));
}
if (Lang.isNotEmpty(xmlxList.get("(单项)")) && xmlxList.get("(单项)").stream().anyMatch(v -> v.getString("xblx").equals("女子"))) {
femaleMap = xmlxList.get("(单项)").stream().filter(v -> v.getString("xblx").equals("女子")).collect(Collectors.groupingBy(h -> h.getString("allName")));
}
return Map.of("团体项目", teamMap, "男子项目", maleMap, "女子项目", femaleMap, "其他", otherMap);
}
@At
@ViReturn
public Object summary(String activityId) {
NutMap map = new NutMap();
List<NutMap> result = new ArrayList<>();
//查询所有的工会
List<Sys_union> query = sysUnionService.query();
for (Sys_union sys_union : query) {
NutMap nutMap = new NutMap();
//记录总人数
int totalPeople = 0;
nutMap.setv("unionname", sys_union.getUnionname());
for (int i = 1; i <= 8; i++) {
Sql sql = Sqls.create("""
SELECT
IFNULL((
SELECT
COUNT( 1 )
FROM
activity_results ar1
WHERE
ar1.activityId = ar2.activityId
AND ar1.ranking = ar2.ranking
AND ar1.isTeamPersonal = 1
AND ar1.unionId = ar2.unionId
),
0
) num,
IFNULL( SUM( numberOfPeople ), 0 ) numberOfPeople
FROM
activity_results ar2 $condition
""");
CndPlus cnd = new CndPlus();
cnd.and("ar2.activityId", "=", activityId);
cnd.and("ar2.ranking", "=", i);
cnd.and("ar2.unionId", "=", sys_union.getId());
cnd.and("ar2.isTeamPersonal", "in", "1,2");
sql.setCondition(cnd);
int number = 0;
List<Record> list = resultsViService.list(sql);
if (list.size() > 0) {
number = list.get(0).getInt("num") + list.get(0).getInt("numberOfPeople");
}
totalPeople += number;
if (i == 1) {
nutMap.setv("one", number);
} else if (i == 2) {
nutMap.setv("two", number);
} else if (i == 3) {
nutMap.setv("three", number);
} else if (i == 4) {
nutMap.setv("four", number);
} else if (i == 5) {
nutMap.setv("fives", number);
} else if (i == 6) {
nutMap.setv("six", number);
} else if (i == 7) {
nutMap.setv("seven", number);
} else if (i == 8) {
nutMap.setv("eight", number);
}
}
nutMap.setv("totalPeople", totalPeople);
result.add(nutMap);
}
map.put("score", result);
return Result.success().addData(map);
}
@Data
private class Ranking {
private int one;
private int two;
private int three;
private int four;
private int fives;
private int six;
private int seven;
private int eight;
}
}
@@ -0,0 +1,464 @@
package io.v.nutz.activity.controller.school;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.controller.school.constant.SchoolActivityApplyExportEntity;
import io.v.nutz.activity.models.*;
import io.v.nutz.activity.services.ActivitySchoolApplyService;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.sys.models.*;
import io.v.nutz.sys.services.SysClubService;
import io.v.nutz.sys.services.SysUnionService;
import io.v.nutz.util.ShiroUtil;
import io.v.nutz.util.ViTool;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.upload.TempFile;
import org.nutz.mvc.upload.UploadAdaptor;
import org.nutz.trans.Molecule;
import org.nutz.trans.Trans;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author: Aaron
* @create: 2021-03-05 10:18
* @description: 报名信息阅览
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/reading")
@RequiresAuthentication
public class ActivityReadingController {
@Inject
private ActivitySchoolService activitySchoolService;
@Inject
private ActivitySchoolApplyService activitySchoolApplyService;
@Inject
private SysUnionService sysUnionService;
@Inject
private SysClubService sysClubService;
@Inject
private BaseService baseService;
@Inject
private Vi vi;
@At("")
@Ok("beetl:platform/activity/school/ActivityReading.html")
@RequiresPermissions("activity.reading")
public void index() {
}
@At
@ViReturn
public Object getNearActivity(Integer year, String activityLevel) {
Cnd cnd = Cnd.NEW();
cnd.and("close", "!=", true);
cnd.and("YEAR(startTime)", "=", year);
cnd.and("activityLevel", "=", activityLevel);
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
if (activityLevel.equals("40002")) {
cnd.and("belongUnionId", "=", getUnionId());
}
if (activityLevel.equals("40003")) {
cnd.and("belongClubId", "in", vi.getMangeClubStr());
}
}
return activitySchoolService.query(cnd.desc("applyEndTime"));
}
@At
@ViReturn
public Object getData(String id, Integer year, String activityLevel) {
String unitId = getUnitId();
String unionid = getUnionId();
ActivityBasicUnit basicUnit = activitySchoolService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", unitId));
ActivityBasicUnion basicUnion = activitySchoolService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", basicUnit.getUnionid()));
ActivitySchool activitySchool = activitySchoolService.fetch(id);
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
app.*,
school.`name` activityName,
school.applyType applyType,
school.belongUnionId belongUnionId,
school.belongClubId belongClubId,
team.`name` team,
unit.`name` unitname,
ev.allName,
ev.id evid,
ev.projectType
FROM
activity_school_apply app
LEFT JOIN activity_school school ON school.id = app.activityId
LEFT JOIN activity_school_team team ON app.teamId = team.id
LEFT JOIN activity_event ev ON ev.id = app.eventId
LEFT JOIN sys_unit unit ON app.unitId = unit.id
$condition
""");
cnd.and("app.activityId", "=", id);
cnd.and("app.status", "=", 2);
// cnd.and("YEAR(app.applyDate)", "=", year);
sql.setCondition(cnd);
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
if (ShiroUtil.hasRole("H04") && activityLevel.equals("40002")) {
cnd.and("app.activityUnionId", "=", basicUnit.getUnionid());
cnd.and("school.belongUnionId", "=", basicUnit.getUnionid());
}
if (ShiroUtil.hasAnyRoles("H02,") && activityLevel.equals("40003")) {
cnd.and("school.belongClubId", "in", vi.getMangeClubStr());
}
}
cnd.desc("ev.allName").asc("ev.projectType").asc("team.`name`");
List<NutMap> applies = activitySchoolApplyService.listMap(sql);
List<NutMap> apply = new ArrayList();
Cnd unionCnd = Cnd.NEW();
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
if (ShiroUtil.hasRole("H04")) {
unionCnd.and("id", "=", basicUnit.getUnionid());
}
}
if (activityLevel.equals("40002")) {
unionCnd.and("id", "=", activitySchool.getBelongUnionId());
}
unionCnd.and("isEnable", "=", true);
unionCnd.asc("unioncode");
if (!activityLevel.equals("40003")) {
List<ActivityBasicUnion> unions = sysUnionService.dao().query(ActivityBasicUnion.class, unionCnd);
for (ActivityBasicUnion union : unions) {
String unionId = union.getId();
NutMap map = new NutMap();
List<NutMap> applyList = applies.stream().filter(v -> {
return v.getString("activityUnionId").equals(unionId);
}).collect(Collectors.toList());
map.setv("id", unionId);
map.setv("unionname", union.getUnionname());
map.setv("unioncode", union.getUnioncode());
map.setv("num", applyList.size());
map.setv("apply", applyList);
apply.add(map);
}
} else {
NutMap map = new NutMap();
Sys_club sysClub = sysClubService.fetch(cnd.where("id", "=", activitySchool.getBelongClubId()));
map.setv("id", sysClub.getId());
map.setv("unionname", sysClub.getName());
map.setv("unioncode", sysClub.getCode());
map.setv("num", applies.size());
map.setv("apply", applies);
apply.add(map);
}
return apply;
}
private String getUnitId() {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
Sys_unit unit = user.getUnit();
String unitId = unit == null ? "" : unit.getId();
return unitId;
}
private String getUnionId() {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
Sys_union unit = user.getUnion();
String unionId = unit == null ? "" : unit.getId();
return unionId;
}
@At
@Ok("void")
@ViReturn
@RequiresAuthentication
public void doExportByEnroll(String id, String unionId, HttpServletResponse response) throws Exception {
//查询该活动的信息
ActivitySchool school = activitySchoolService.fetch(id);
Sys_union sysUnion = sysUnionService.fetch(unionId);
//领队
ActivitySchoolApply leader = activitySchoolApplyService.fetch(Cnd.where("unionLeader", "=", 1).and("activityId", "=", id).and("unionId", "=", unionId));
//教练
ActivitySchoolApply coach = activitySchoolApplyService.fetch(Cnd.where("unionCoach", "=", 1).and("activityId", "=", id).and("unionId", "=", unionId));
//团长
ActivitySchoolApply head = activitySchoolApplyService.fetch(Cnd.where("unionHead", "=", 1).and("activityId", "=", id).and("unionId", "=", unionId));
Sql sql = Sqls.create("""
SELECT
apply.loginname,
apply.username,
apply.sex,
IF(apply.sex='男',1,2) AS sexOrder,
`event`.allName,
groupSetting.`name` AS groupName,
projectNameSetting.location AS projectNameLocation,
IF ( distanceSetting.`name` is NULL, 0,distanceSetting.`name`) AS distance,
(case groupSetting.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 else 5 end) AS groupNameOrder,
CONCAT( IF ( distanceSetting.`name` is NULL, '', CONCAT( distanceSetting.`name`, '米' )), projectNameSetting.`name`) AS projectName,
apply.awardsMode
FROM
`activity_school_apply` apply
LEFT JOIN activity_event `event` ON `event`.id = apply.eventId
LEFT JOIN activity_basic_settings groupSetting ON groupSetting.id = `event`.competitionCategory
LEFT JOIN activity_basic_settings projectNameSetting ON projectNameSetting.id = `event`.sports
LEFT JOIN activity_basic_settings distanceSetting ON distanceSetting.id = `event`.distance
WHERE
apply.activityId = @id
AND apply.unionId = @unionId
AND JSON_CONTAINS(apply.identity,JSON_Array( '1' ))
ORDER BY
FIELD( apply.sex, '男', '女 ' ),
FIELD(groupSetting.`name`,'甲组','乙组','丙组','丁组'),
projectNameSetting.location DESC
""");
sql.setParam("id", id).setParam("unionId", unionId);
List<NutMap> list = activitySchoolApplyService.listMap(sql);
Map<String, List<NutMap>> loginnameMap = list.stream().collect(Collectors.groupingBy(v -> v.getString("loginname")));
List<SchoolActivityApplyExportEntity> exportList = new ArrayList<>();
loginnameMap.forEach((k, v) -> {
SchoolActivityApplyExportEntity entity = new SchoolActivityApplyExportEntity();
for (int i = 0; i < v.size(); i++) {
switch (i) {
case 0 -> {
if (v.get(i).getInt("awardsMode") == 1) {
entity.setUserName(v.get(i).getString("username"));
entity.setSex(v.get(i).getString("sex"));
// entity.setGroupName(v.get(i).getString("groupName"));
entity.setSexOrder(v.get(i).getInt("sexOrder"));
} else {
entity.setUserName(sysUnion.getUnionname());
entity.setSex(null);
// entity.setGroupName("团体");
entity.setSexOrder(3);
}
entity.setGroupName(v.get(i).getString("groupName"));
entity.setAwardsMode(v.get(i).getInt("awardsMode"));
entity.setGroupNameOrder(v.get(i).getInt("groupNameOrder"));
entity.setProjectNameOne(v.get(i).getString("projectName"));
entity.setProjectNameLocation(v.get(i).getInt("projectNameLocation"));
entity.setDistance(v.get(i).getInt("distance"));
}
case 1 -> entity.setProjectNameTwo(v.get(i).getString("projectName"));
case 2 -> entity.setProjectNameThree(v.get(i).getString("projectName"));
case 3 -> entity.setProjectNameFour(v.get(i).getString("projectName"));
case 4 -> entity.setProjectNameFive(v.get(i).getString("projectName"));
case 5 -> entity.setProjectNameSix(v.get(i).getString("projectName"));
}
}
exportList.add(entity);
});
/**
* 排序顺序
* 1.单人还是团体
* 2.性别
* 3.组别
* 4.项目location 对应activity_basic_settings location
* 5.距离 有些项目为空 为空的默认给0 对应activity_basic_settings distance
*/
List<SchoolActivityApplyExportEntity> sortedExportList = exportList.stream().sorted(
Comparator.comparing(SchoolActivityApplyExportEntity::getAwardsMode)
.thenComparing(SchoolActivityApplyExportEntity::getSexOrder)
.thenComparing(SchoolActivityApplyExportEntity::getGroupNameOrder)
.thenComparing(SchoolActivityApplyExportEntity::getProjectNameLocation)
.thenComparing(SchoolActivityApplyExportEntity::getDistance)
).collect(Collectors.toList());
ViTool.excelResponse(response, school.getName() + "报名人员名单.xlsx");
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
exportParams.setTitle("参赛队名:" + sysUnion.getUnionname() + " 团长:" + (head != null ? head.getUsername() : "暂无") + ",领队:" + (leader != null ? leader.getUsername() : "暂无") + ",教练:" + (coach != null ? coach.getUsername() : "暂无"));
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, SchoolActivityApplyExportEntity.class, sortedExportList);
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.close();
}
@At
@RequiresAuthentication
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
public Object importUserActivitys(TempFile file, String activityId) {
try {
Trans.exec(new Molecule<String>() {
@Override
public void run() {
List<ActivityImport.applyUser> applyUsers = ExcelImportUtil.importExcel(file.getFile(), ActivityImport.applyUser.class, new ImportParams());
applyUsers.forEach(v -> {
//首先查询有没有这个人
User user = baseService.dao().fetch(User.class, Cnd.where("loginname", "=", v.getLoginName()));
if (user == null) {
setObj(v.getLoginName() + "此用户不存在请检查");
throw new RuntimeException(v.getLoginName() + "此用户不存在请检查");
}
if (!ShiroUtil.hasAnyRoles("sysadmin,A06,H10")) {
if (!user.getUnionid().equals(getUnionId())) {
setObj(v.getLoginName() + "此用户不是本工会人员");
throw new RuntimeException(v.getLoginName() + "此用户不是本工会人员");
}
}
//根据code查询有没有这个项目
ActivityEvent activityEvent = baseService.dao().fetch(ActivityEvent.class, Cnd.where("projectCode", "=", v.getProjectCode()));
//查询活动单位
ActivityBasicUnit activityBasicUnit = baseService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", user.getUnitid()));
if (activityBasicUnit == null) {
setObj("请检查" + user.getLoginname() + "的活动单位是否正确");
throw new RuntimeException("请检查" + user.getLoginname() + "的活动单位是否正确");
}
//查询活动工会
ActivityBasicUnion basicUnion = activitySchoolService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", activityBasicUnit.getUnionid()));
if (basicUnion == null) {
setObj("请检查" + user.getLoginname() + "的活动单位:" + activityBasicUnit.getName() + "是否有活动工会");
throw new RuntimeException("请检查" + user.getLoginname() + "的活动单位:" + activityBasicUnit.getName() + "是否有活动工会");
}
ActivitySchoolApply activitySchoolApply = new ActivitySchoolApply();
activitySchoolApply.setActivityId(activityId);
activitySchoolApply.setUnitId(user.getUnitid());
activitySchoolApply.setUnionId(user.getUnionid());
activitySchoolApply.setApplyUser(ShiroUtil.getUserId());
activitySchoolApply.setUserId(user.getId());
activitySchoolApply.setLoginname(user.getLoginname());
activitySchoolApply.setUsername(user.getUsername());
activitySchoolApply.setSex(user.getSex());
activitySchoolApply.setMobile(user.getMobile());
activitySchoolApply.setApplyDate(DateUtil.getDate());
activitySchoolApply.setStatus(2);
activitySchoolApply.setUnitname(user.getUnitname());
activitySchoolApply.setActivityUnionId(basicUnion.getId());
activitySchoolApply.setActivityUnionName(basicUnion.getUnionname());
//判断是否有除运动员以外的身份
if (v.getIdentity() != null && v.getIdentity().equals("教练")) {
activitySchoolApply.setUnionCoach(true);
} else if (v.getIdentity() != null && v.getIdentity().equals("领队")) {
activitySchoolApply.setUnionLeader(true);
} else if (v.getIdentity() != null && v.getIdentity().equals("团长")) {
activitySchoolApply.setUnionHead(true);
} else if (v.getIdentity() != null && v.getIdentity().equals("工作人员")) {
activitySchoolApply.setUnionStaff(true);
}
if (v.getProjectCode() == null && v.getIdentity() != null) {
//如果这个人没有报名的项目并且有职位,说明这个人不是运动员,直接加入数据
baseService.insert(activitySchoolApply);
} else {
//否则是运动员
// Integer identity = getIdentity(v.getIdentity());
// activitySchoolApply.setIdentity(List.of(String.valueOf(identity)));
if (activityEvent == null) {
setObj("请检查" + v.getProjectCode() + "项目编号是否存在");
throw new RuntimeException("请检查" + v.getProjectCode() + "项目编号是否存在");
}
//然后在查询这个活动有没有这个项目
ActivitySchoolEvent schoolEvent = baseService.dao().fetch(ActivitySchoolEvent.class, Cnd.where("activityId", "=", activityId).and("eventId", "=", activityEvent.getId()));
if (schoolEvent == null) {
setObj(v.getProjectCode() + "项目编号在此活动中没有,请检查数据是否正确");
throw new RuntimeException(v.getProjectCode() + "项目编号在此活动中没有,请检查数据是否正确");
}
//查询这个人在这次活动的项目中有没有报过,有报过就删除再添加
ActivitySchoolApply schoolApply = baseService.dao().fetch(ActivitySchoolApply.class, Cnd.where("activityId", "=", activityId).and("userId", "=", user.getId()).and("eventId", "=", schoolEvent.getEventId()));
if (schoolApply != null) {
baseService.dao().delete(ActivitySchoolApply.class, schoolApply.getId());
}
//查询这个活动下的项目第一个小队是多少
ActivitySchoolTeam schoolTeam = baseService.dao().fetch(ActivitySchoolTeam.class, Cnd.where("activityId", "=", activityId).and("eventId", "=", schoolEvent.getEventId()).asc("location"));
if (schoolTeam == null && activityEvent.getProjectType().equals("2")) {
setObj("请检查" + v.getProjectCode() + "编号项目下是否存在小队");
throw new RuntimeException("请检查" + v.getProjectCode() + "编号项目下是否存在小队");
}
activitySchoolApply.setEventId(schoolEvent.getEventId());
activitySchoolApply.setAwardsMode(activityEvent.getProjectType());
if (activityEvent.getProjectType().equals("2")) {
activitySchoolApply.setTeamId(schoolTeam.getId());
activitySchoolApply.setTeam(schoolTeam.getName());
}
activitySchoolApply.setIdentity(List.of(String.valueOf(1)));
baseService.insert(activitySchoolApply);
}
});
}
});
return Result.success();
} catch (Throwable e) {
return Result.error(e.getMessage());
}
}
private Integer getIdentity(String identity) {
if (identity.equals("运动员")) {
return 1;
} else if (identity.equals("教练")) {
return 2;
} else if (identity.equals("领队")) {
return 3;
} else if (identity.equals("处级领导")) {
return 4;
} else if (identity.equals("替补")) {
return 5;
}
return 1;
}
}
@@ -0,0 +1,227 @@
package io.v.nutz.activity.controller.school;
import io.v.nutz.activity.models.ActivitySchoolEvent;
import io.v.nutz.activity.services.ActivitySchoolApplyService;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.RCSCloudAPI;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.services.SysUnionService;
import io.v.nutz.util.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author: Aaron
* @create: 2021-03-03 17:27
* @description: 活动报名提醒
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/remind")
@RequiresAuthentication
public class ActivityRemindController {
@Inject
private ActivitySchoolService activitySchoolService;
@Inject("ActivitySchoolEvent")
private ViService<ActivitySchoolEvent> activitySchoolEventViService;
@Inject
private ActivitySchoolApplyService activitySchoolApplyService;
@Inject
private SysUnionService sysUnionService;
@Inject
private Vi vi;
@At("")
@Ok("beetl:platform/activity/school/ActivityRemind.html")
@RequiresPermissions("activity.remind")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.remind")
public Object pageData(PageForm page, @Param(value = "name", required = false) String name,
@Param(value = "activityId", required = false) String activityId) {
Sql sql = Sqls.create("""
SELECT
school.id,
school.planId,
school.`name`,
school.address,
school.applyStartTime,
school.applyEndTime,
school.startTime,
school.endTime,
school.unitSponsor,
school.unitJointly,
school.gameStyle,
school.funding,
school.applyWay,
school.personType,
school.activityLevel,
(SELECT COUNT(1) FROM activity_school_apply asa WHERE asa.activityId = school.id) applyNum
FROM
activity_school school
$condition
""");
CndPlus cnd = CndPlus.create();
cnd.and("school.close", "!=", true);
cnd.and("school.isSave", "!=", true);
cnd.and(new Static("CURRENT_DATE() >= school.applyStartTime AND CURRENT_DATE() <= school.applyEndTime"));
cnd.andExcludeEmpty("school.id", "=", activityId);
if (Strings.isNotBlank(name)) {
cnd.where().andLike("school.name", name);
}
cnd.desc("school.startTime");
sql.setCondition(cnd);
return activitySchoolService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("activity.remind")
public Object getUnionRemind(String activityId) {
Sql sql = Sqls.create("""
SELECT
un.id,
un.unionname,
(
SELECT
GROUP_CONCAT(su.mobile)
FROM
sys_user_role sur
LEFT JOIN sys_user su ON su.id = sur.userId
LEFT JOIN sys_role sr ON sr.id = sur.roleId
WHERE
sur.unionid = un.id
AND sr.id = @roleId
) telephone,
(
SELECT
GROUP_CONCAT(su.username)
FROM
sys_user_role sur
LEFT JOIN sys_user su ON su.id = sur.userId
LEFT JOIN sys_role sr ON sr.id = sur.roleId
WHERE
sur.unionid = un.id
AND sr.id = @roleId
) unionleader,
( SELECT COUNT( 1 ) FROM activity_school_apply asp WHERE asp.unionId = un.id AND asp.activityId = @activityId ) num
FROM
`sys_union` un
ORDER BY
un.unioncode
""").setParam("roleId", Roles.UNION_MANGER).setParam("activityId", activityId);
List<Record> unions = sysUnionService.list(sql);
unions.forEach(v -> {
v.set("users", activitySchoolApplyService.query(Cnd.where("unionId", "=", v.getString("id")).and("activityId", "=", activityId).desc("identity")));
});
return unions;
}
@At
@ViReturn
@RequiresPermissions("activity.remind")
public Object sendRemind(@Param(value = "phone", required = false) String phone,
@Param(value = "unionname", required = false) String unionname) {
String[] pe = phone.split(",");
for (String p : pe) {
RCSCloudAPI.sendTplSms("399ac7a7901c49df9f5939d0f10d566b", p, "@1@=" + unionname + "", "");
}
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.remind")
public Object sendAllRemind(String activityId) {
Sql sql = Sqls.create("""
SELECT
un.id,
un.unionname,
(
SELECT
su.mobile
FROM
sys_user_role sur
LEFT JOIN sys_user su ON su.id = sur.userId
LEFT JOIN sys_role sr ON sr.id = sur.roleId
WHERE
sur.unionid = un.id
AND sr.id = @roleId
) telephone,
( SELECT COUNT( 1 ) FROM activity_school_apply asp WHERE asp.unionId = un.id AND asp.activityId = @activityId ) num
FROM
`sys_union` un
ORDER BY
un.unioncode
""").setParam("roleId", Roles.UNION_MANGER).setParam("activityId", activityId);
List<Record> unions = sysUnionService.list(sql);
List<Record> collect = unions.stream().filter(v -> {
return v.getInt("num") <= 0 && v.getString("telephone") != null;
}).collect(Collectors.toList());
collect.forEach(v -> {
RCSCloudAPI.sendTplSms("399ac7a7901c49df9f5939d0f10d566b", v.getString("telephone"), "@1@=" + v.getString("unionname") + "", "");
});
return null;
}
@At
@ViReturn
public Object getActivitys() {
Cnd cnd = Cnd.NEW();
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
if (ShiroUtil.hasRole("H04")) {
cnd.and("belongUnionId", "=", Vi.getUnionId());
}
if (ShiroUtil.hasRole("club01")) {
cnd.and("belongClubId", "in", vi.getMangeClubStr());
}
}
return activitySchoolService.query(cnd);
}
}
@@ -0,0 +1,320 @@
package io.v.nutz.activity.controller.school;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivityBasicUnion;
import io.v.nutz.activity.models.ActivityBasicUnit;
import io.v.nutz.activity.models.ActivityResults;
import io.v.nutz.activity.models.ActivitySchoolApply;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.util.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.apache.shiro.util.ByteSource;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.random.R;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.trans.Trans;
import java.util.Arrays;
/**
* @author zhf
* @date 2021/5/19 14:58
* @description 运动会成绩录入
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/results/input")
@RequiresAuthentication
public class ActivityResultsController {
@Inject("ActivityResults")
private ViService<ActivityResults> resultsViService;
@Inject("ActivitySchoolApply")
private ViService<ActivitySchoolApply> activitySchoolApplyViService;
@At("")
@Ok("beetl:platform/activity/school/ActivityResults.html")
@RequiresPermissions("activity.results.input")
public void index() {
}
@At
@ViReturn
@RequiresPermissions("activity.results.input")
public Object pageData(@Param(value = "groupName", required = false) String groupName,
PageForm page,
@Param(value = "activityId", required = false) String activityId,
@Param(value = "eventId", required = false) String eventId,
@Param(value = "isMenWomen", required = false) String[] isMenWomen) {
CndPlus cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
ase.id,
ase.activityId,
ase.eventId,
ae.projectType awardsMode,
ae.allName,
ae.isMenWomen,
school.`name` ,
( SELECT COUNT( 1 ) FROM activity_results ar WHERE ar.eventId = ase.eventId and ar.activityId=ase.activityId) rs
FROM
activity_school_event ase
LEFT JOIN activity_event ae ON ase.eventId = ae.id
LEFT JOIN activity_school school ON school.id = ase.activityId
LEFT JOIN activity_basic_settings abs ON abs.id=ae.competitionCategory
$condition
""");
cnd.and("ase.activityId", "=", activityId);
Vi.cndPlus(cnd, "abs.`name`", "=", groupName);
cnd.andExcludeEmpty("ae.id", "=", eventId);
SqlExpressionGroup sqlExpressionGroup = new SqlExpressionGroup();
if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("2"))) {
sqlExpressionGroup.and("ae.isMenWomen", "=", 1);
}
if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("3"))) {
sqlExpressionGroup.or("ae.isMenWomen", "=", 2);
}
if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("4"))) {
sqlExpressionGroup.and("ae.projectType", "=", 1);
}
if (Arrays.stream(isMenWomen).anyMatch(a -> a.equals("5"))) {
sqlExpressionGroup.or("ae.projectType", "=", 2);
}
if (sqlExpressionGroup.getExps().size() > 0) {
cnd.and(sqlExpressionGroup);
}
cnd.desc("allName");
sql.setCondition(cnd);
return resultsViService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions("activity.results.input")
public Object doAdd(@Param(value = "activityResults") ActivityResults[] activityResults, String activityId, String eventId) {
resultsViService.clear(Cnd.where("activityId", "=", activityId).and("eventId", "=", eventId));
resultsViService.insert(activityResults);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.results.input")
public Object doAddUser(ActivitySchoolApply activitySchoolApply) {
Sys_user sysUser = sysUserViService.fetch(Cnd.where("loginname", "=", activitySchoolApply.getLoginname()));
if (sysUser != null && sysUser.getLoginname().equals(activitySchoolApply.getLoginname()) && !sysUser.getUsername().equals(activitySchoolApply.getUsername())) {
return Result.error("工号已存在,请检查姓名和工号是否一致!");
}
if (sysUser == null) {
Trans.exec(() -> {
Sys_user user = new Sys_user();
user.setId(R.UU32());
user.setSalt(R.UU32());
user.setPassword(new Sha256Hash("dd3s@#2022", ByteSource.Util.bytes(R.UU32()), 1024).toHex());
user.setUsername(activitySchoolApply.getUsername());
user.setLoginname(activitySchoolApply.getLoginname());
user.setSex(activitySchoolApply.getSex());
user.setUnitid(activitySchoolApply.getUnitId());
user.setMobile(activitySchoolApply.getMobile());
sysUserViService.insert(user);
ActivityBasicUnit activityBasicUnit = activitySchoolApplyViService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", user.getUnitid()));
ActivityBasicUnion basicUnion = activitySchoolApplyViService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", activityBasicUnit.getUnionid()));
activitySchoolApply.setUserId(user.getId());
activitySchoolApply.setApplyDate(DateUtil.getDate());
activitySchoolApply.setSex(user.getSex());
activitySchoolApply.setUnitId(user.getUnitid());
activitySchoolApply.setActivityUnionId(basicUnion.getId());
activitySchoolApply.setActivityUnionName(basicUnion.getUnionname());
activitySchoolApplyViService.insert(activitySchoolApply);
});
return null;
}
sysUser.setSex(activitySchoolApply.getSex());
sysUserViService.update(sysUser);
ActivityBasicUnit activityBasicUnit = activitySchoolApplyViService.dao().fetch(ActivityBasicUnit.class, Cnd.where("id", "=", sysUser.getUnitid()));
ActivityBasicUnion basicUnion = activitySchoolApplyViService.dao().fetch(ActivityBasicUnion.class, Cnd.where("id", "=", activityBasicUnit.getUnionid()));
activitySchoolApply.setUserId(sysUser.getId());
activitySchoolApply.setApplyUser(ShiroUtil.getUserId());
activitySchoolApply.setApplyDate(DateUtil.getDate());
activitySchoolApply.setUnitId(sysUser.getUnitid());
activitySchoolApply.setActivityUnionId(basicUnion.getId());
activitySchoolApply.setActivityUnionName(basicUnion.getUnionname());
activitySchoolApplyViService.insert(activitySchoolApply);
return null;
}
/**
* 查询个人参赛人员
*
* @param activityId
* @param eventId
* @param isMenWomen
* @return
*/
@At
@ViReturn
@RequiresPermissions("activity.results.input")
public Object getUserList(String activityId,
@Param(value = "eventId", required = false) String eventId,
@Param(value = "isMenWomen", required = false) Integer isMenWomen) {
CndPlus cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
u.id,u.username,u.loginname,u.unionId,
u.unionname,u.sex
FROM
activity_school_apply asa
LEFT JOIN `user` u ON u.id = asa.userId $condition
""");
cnd.and("asa.activityId", "=", activityId);
cnd.and("asa.eventId", "=", eventId);
cnd.and("asa.awardsMode", "=", 1);
if (isMenWomen != null && isMenWomen == 1) cnd.and("u.sex", "=", "");
if (isMenWomen != null && isMenWomen == 2) cnd.and("u.sex", "=", "");
sql.setCondition(cnd);
return activitySchoolApplyViService.listMap(sql);
}
@At
@ViReturn
@RequiresPermissions("activity.results.input")
public Object getUnionDetails(String activityId, String eventId, String unionId) {
return activitySchoolApplyViService.count(Cnd.where("activityId", "=", activityId).and("eventId", "=", eventId).and("unionId", "=", unionId));
}
/**
* 查询团体参赛分工会
*
* @param activityId
* @param eventId
* @return
*/
@At
@ViReturn
@RequiresPermissions("activity.results.input")
public Object getUnionList(@Param(value = "activityId", required = false) String activityId,
@Param(value = "eventId", required = false) String eventId) {
Sql sql = Sqls.create("""
SELECT
un.id,
un.unionname
FROM
activity_school_apply asa
LEFT JOIN sys_union un ON un.id = asa.unionId
WHERE
asa.activityId = @activityId
AND asa.eventId = @eventId
GROUP BY
un.unionname
""").setParam("activityId", activityId).setParam("eventId", eventId);
return activitySchoolApplyViService.list(sql);
}
@Inject("Sys_user")
private ViService<Sys_user> sysUserViService;
/**
* 根据活动项目性别查询有没有获奖人员
*
* @return
*/
@At
@ViReturn
@RequiresPermissions("activity.results.input")
public Object getUserData(@Param(value = "activityId", required = false) String activityId,
@Param(value = "eventId", required = false) String eventId,
@Param(value = "isMenWomen", required = false) Integer isMenWomen) {
CndPlus cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
ar.id,
ar.userId,
ar.activityId,
ar.eventId,
u.username,
u.unionId unionId,
u.unionname,
u.sex,
ar.integral,
ar.numberOfPeople,
ar.ranking,
ar.isTeamPersonal
FROM
`activity_results` ar
LEFT JOIN `user` u ON ar.userId = u.id $condition
""");
cnd.and("ar.activityId", "=", activityId);
cnd.and("ar.eventId", "=", eventId);
if (isMenWomen != null && isMenWomen == 1) cnd.and("u.sex", "=", "");
if (isMenWomen != null && isMenWomen == 2) cnd.and("u.sex", "=", "");
cnd.asc("ar.ranking");
sql.setCondition(cnd);
return resultsViService.listMap(sql);
}
@At
@ViReturn
@RequiresPermissions("activity.results.input")
public Object getUnionData(@Param(value = "activityId", required = false) String activityId,
@Param(value = "eventId", required = false) String eventId) {
Sql sql = Sqls.create("""
SELECT
ar.id,
ar.activityId,
ar.eventId,
ar.ranking,
ar.unionId,
ar.numberOfPeople,
ar.integral,
ar.isTeamPersonal
FROM
activity_results ar
WHERE
ar.isTeamPersonal = 2
AND ar.activityId = @activityId
AND ar.eventId = @eventId
ORDER BY ar.ranking asc
""").setParam("activityId", activityId).setParam("eventId", eventId);
return resultsViService.listMap(sql);
}
}
@@ -0,0 +1,98 @@
package io.v.nutz.activity.controller.school;
import io.v.nutz.activity.services.ActivitySchoolApplyService;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
/**
* @author zhf
* @date 2021/3/4 16:39
* @description 活动审核
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/review")
@RequiresAuthentication
public class ActivityReviewController {
@Inject
private ActivitySchoolService activitySchoolService;
@Inject
private ActivitySchoolApplyService activitySchoolApplyService;
@At("")
@Ok("beetl:platform/activity/school/ActivityReview.html")
@RequiresPermissions("activity.review")
public void index() {
}
@At
@ViReturn
public Object pageData(PageForm page, String name, String events) {
Sql sql = Sqls.create("""
SELECT
apply.id,
apply.loginname,
apply.username,
apply.mobile,
apply.identity,
school.id schoolId,
school.eventsId,
school.applyStartTime,
school.applyEndTime,
school.startTime,
school.endTime,
even.allName
FROM
activity_school_apply apply
LEFT JOIN activity_school school ON apply.activityId = school.id
LEFT JOIN activity_event even ON even.id = school.eventsId
$condition
""");
CndPlus cnd = CndPlus.create();
cnd.and(new Static("CURRENT_DATE() >= school.applyStartTime AND CURRENT_DATE() <= school.applyEndTime"));
cnd.andExcludeEmpty("school.eventsId", "=", events);
if (Strings.isNotBlank(name)) {
cnd.where().andLike("school.name", name);
}
cnd.and("apply.`status`", "=", 1);
cnd.desc("school.startTime");
sql.setCondition(cnd);
return activitySchoolService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
public Object doPassFail(String id, String status) {
Chain chain = Chain.make("status", status);
Cnd cnd = Cnd.where("id", "=", id);
return activitySchoolApplyService.update(chain, cnd);
}
}
@@ -0,0 +1,607 @@
package io.v.nutz.activity.controller.school;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.wizzer.framework.base.Result;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
import io.v.nutz.activity.models.ActivityResults;
import io.v.nutz.activity.models.ActivitySchool;
import io.v.nutz.activity.models.ActivitySchoolEvent;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_union;
import io.v.nutz.sys.services.SysUnionService;
import io.v.nutz.util.ViTool;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* @author zhf
* @date 2021/5/24 14:12
* @description 运动会成绩统计
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/score/statistics")
@RequiresAuthentication
public class ActivityScoreStatisticsController {
@Inject
private SysUnionService sysUnionService;
@Inject("ActivitySchoolEvent")
private ViService<ActivitySchoolEvent> eventViService;
@Inject("ActivityResults")
private ViService<ActivityResults> resultsViService;
@Inject("ActivitySchool")
private ViService<ActivitySchool> schoolViService;
@At("")
@Ok("beetl:platform/activity/school/ScoreStatistics.html")
@RequiresPermissions("activity.score.statistics")
public void index() {
}
@At
@ViReturn
public Object isMaleFemale(String activityId, String sex, Integer awardsMode) {
NutMap map = new NutMap();
List<NutMap> result = new ArrayList<>();
//查询所有的工会
List<Sys_union> query = sysUnionService.query();
CndPlus cndX = new CndPlus();
//查询所有的项目
Sql sqlX = Sqls.create("""
SELECT
ev.id,
ev.eventId,
ba.`name` baname,
eve.projectType awardsMode,
eve.allName label,
eve.isMenWomen
FROM
activity_school_event ev
LEFT JOIN activity_event eve ON ev.eventId = eve.id
LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition
""");
cndX.and("ev.activityId", "=", activityId);
if (awardsMode < 3) {
cndX.and("eve.projectType", "=", awardsMode);
cndX.and("eve.isInterest", "=", false);
cndX.and("eve.isMenWomen", "=", sex.equals("") ? 1 : 2);
}
if (awardsMode == 3) {
cndX.and("eve.isInterest", "=", true);
}
if (awardsMode == 4) {
cndX.and(Cnd.exps("eve.isMenWomen", "=", sex.equals("") ? 1 : 2).or("eve.isMenWomen", "is", null));
}
cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end"));
sqlX.setCondition(cndX);
List<Record> eventList = eventViService.list(sqlX);
//查询每个工会下每个项目的成绩
for (Sys_union sys_union : query) {
NutMap nutMap = new NutMap();
//记录总积分
double totalScore = 0;
nutMap.setv("unionname", sys_union.getUnionname());
for (Record event : eventList) {
Sql sqlC = Sqls.create("""
SELECT
IF ( sum( integral ) IS NULL, 0, sum( integral )) AS integral,
ev.allName,ev.projectType,abs.`name` AS zb,ev.isInterest
FROM
activity_results ar
LEFT JOIN activity_event ev ON ar.eventId = ev.id
LEFT JOIN activity_basic_settings abs ON abs.id=ev.competitionCategory $condition
""");
CndPlus cndC = new CndPlus();
if ((awardsMode == 1 && event.getString("awardsMode").equals("1")) || (awardsMode == 2 && event.getString("awardsMode").equals("2"))) {
cndC.and("ev.isInterest", "=", false);
cndC.and("ev.isMenWomen", "=", sex.equals("") ? 1 : 2);
} else if (awardsMode == 3) {
cndC.and("ev.isInterest", "=", true);
} else if (awardsMode == 4) {
cndC.and(Cnd.exps("ev.isMenWomen", "=", sex.equals("") ? 1 : 2).or("ev.isMenWomen", "is", null));
}
cndC.and("ar.eventId", "=", event.getString("eventid"));
cndC.and("ar.unionid", "=", sys_union.getId());
cndC.and("ar.activityId", "=", activityId);
sqlC.setCondition(cndC);
Double score = 0.0;
List<NutMap> list = resultsViService.listMap(sqlC);
boolean isInterest = list.get(0).getBoolean("isInterest");
if (list.size() > 0) {
score = list.get(0).getDouble("integral");
}
if (list.get(0).getString("allName") != null) {
if (!isInterest) {
nutMap.setv(list.get(0).getString("allName"), score);
} else {
nutMap.setv(list.get(0).getString("allName"), score / 2);
}
}
totalScore += isInterest ? (score / 2) : score;
if (list.get(0).getString("zb") != null) {
nutMap.setv("projectType", list.get(0).getString("projectType"));
nutMap.setv("zb", list.get(0).getString("zb"));
}
}
nutMap.setv("totalScore", totalScore);
result.add(nutMap);
}
map.put("score", result);
map.put("eventList", eventList);
return Result.success().addData(map);
}
@At
@ViReturn
public Object isTopEight(String activityId, String sex, Integer awardsMode) {
NutMap map = new NutMap();
List<Record> result = new ArrayList<>();
CndPlus cndX = new CndPlus();
//查询所有的项目
Sql sqlX = Sqls.create("""
SELECT
ev.id,
ev.eventId,
ba.`name` baname,
eve.projectType awardsMode,
eve.allName label
FROM
activity_school_event ev
LEFT JOIN activity_event eve ON ev.eventId = eve.id
LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition
""");
cndX.and("ev.activityId", "=", activityId);
if (awardsMode == 1) {
cndX.and("eve.isMenWomen", "!=", sex.equals("") ? 2 : 1);
cndX.and("eve.projectType", "=", 1);
} else {
cndX.and("eve.projectType", "=", 2);
}
cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end"));
sqlX.setCondition(cndX);
List<Record> eventList = eventViService.list(sqlX);
Sql sqlC = Sqls.create("");
CndPlus cnd = new CndPlus();
if (awardsMode == 1) {
sqlC = Sqls.create("""
SELECT
CONCAT( apply.username, '(', apply.activityUnionName, ')' ) username,
ar.integral,
ar.ranking,
eve.allName
FROM
activity_results ar
LEFT JOIN activity_event eve ON ar.eventId = eve.id
LEFT JOIN activity_school_apply apply ON apply.userId = ar.userId
AND ar.activityId = apply.activityId $condition
""");
cnd.and("ar.isTeamPersonal", "=", awardsMode);
cnd.and("apply.sex", "=", sex);
cnd.and("ar.activityId", "=", activityId);
cnd.and("ar.ranking", "<=", 8);
cnd.groupBy("ar.id");
} else {
sqlC = Sqls.create("""
SELECT
CONCAT(sun.unionname) username,
eve.allName,ar.ranking
FROM
activity_results ar
LEFT JOIN activity_event eve ON ar.eventId = eve.id
LEFT JOIN sys_union sun ON sun.id = ar.unionId $condition
""");
cnd.and("ar.isTeamPersonal", "=", awardsMode);
cnd.and("ar.activityId", "=", activityId);
cnd.and("ar.ranking", "<=", 8);
}
sqlC.setCondition(cnd);
List<Record> list = resultsViService.list(sqlC);
map.put("userList", list);
map.put("eventList", eventList);
return Result.success().addData(map);
}
@At
@ViReturn
public Object getActivitys(Integer year) {
return schoolViService.query(Cnd.where("YEAR(applyEndTime)", "=", year));
}
@At
@ViReturn
public Object isScoreTopEight(String activityId, String sex) {
NutMap map = new NutMap();
List<NutMap> result = new ArrayList<>();
CndPlus cndX = new CndPlus();
//查询所有的项目
Sql sqlX = Sqls.create("""
SELECT
ev.id,
ev.eventId,
ba.`name` baname,
eve.projectType awardsMode,
eve.allName label
FROM
activity_school_event ev
LEFT JOIN activity_event eve ON ev.eventId = eve.id
LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition
""");
cndX.and("ev.activityId", "=", activityId);
cndX.and(Cnd.exps("eve.isMenWomen", "=", sex.equals("") ? 1 : 2).or("eve.isMenWomen", "is", null));
cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end"));
sqlX.setCondition(cndX);
List<Record> eventList = eventViService.list(sqlX);
//查询所有的工会
List<Sys_union> query = sysUnionService.query();
for (Sys_union sys_union : query) {
NutMap nutMap = new NutMap();
//记录总积分
double totalScore = 0;
nutMap.setv("unionname", sys_union.getUnionname());
for (Record event : eventList) {
Sql sqlC = Sqls.create("""
SELECT
IF ( sum( integral ) IS NULL, 0, sum( integral )) AS integral,
ev.allName,ev.isInterest
FROM
activity_results ar
LEFT JOIN activity_event ev ON ar.eventId = ev.id $condition
""");
CndPlus cndC = new CndPlus();
cndC.and(Cnd.exps("ev.isMenWomen", "=", sex.equals("") ? 1 : 2).or("ev.isMenWomen", "is", null));
cndC.and("ar.unionid", "=", sys_union.getId());
cndC.and("ar.eventId", "=", event.getString("eventid"));
cndC.and("ar.activityId", "=", activityId);
sqlC.setCondition(cndC);
Double score = 0.0;
List<NutMap> list = resultsViService.listMap(sqlC);
boolean isInterest = list.get(0).getBoolean("isInterest");
if (list.size() > 0) {
score = list.get(0).getDouble("integral");
}
totalScore += isInterest ? (score / 2) : score;
}
nutMap.setv("totalScore", totalScore);
result.add(nutMap);
}
map.put("score", result);
return Result.success().addData(map);
}
@At
@ViReturn
public Object getAnnualResults(Integer year) {
ArrayList<Map> resultMap = new ArrayList<>();
Dao dao = sysUnionService.dao();
List<Sys_union> unionList = sysUnionService.query();
List<ActivitySchool> activitySchoolList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
List<String> labelList = activitySchoolList.stream().map(v -> v.getName()).collect(Collectors.toList());
labelList.add(0, "分工会");
unionList.forEach(u -> {
NutMap unionMap = Lang.obj2nutmap(u);
AtomicReference<Double> scoreSum = new AtomicReference<>((double) 0);
activitySchoolList.forEach(x -> {
Sql sql = Sqls.create("""
SELECT sum(integral) as sumScore FROM `activity_results` ar
where ar.activityId = @activityId and ar.unionId = @unionId
""");
sql.setParam("activityId", x.getId());
sql.setParam("unionId", u.getId());
sql.setCallback(Sqls.callback.map());
dao.execute(sql);
NutMap scoreMap = (NutMap) sql.getResult();
double score = scoreMap.getDouble("sumScore");
scoreSum.updateAndGet(v -> new Double((v + score)));
unionMap.put(x.getName(), score);
});
unionMap.put("总分", scoreSum.get());
unionMap.put("分工会", unionMap.getString("unionname"));
resultMap.add(unionMap);
});
labelList.add("总分");
return Map.of("label", labelList, "score", resultMap);
}
@At
@ViReturn
public Object getYear8(Integer isMenWomen, Integer year) {
ArrayList<Map> resultMap = new ArrayList<>();
// int isMenWomen = sex.equals("男") ? 1 : 2;
Dao dao = sysUnionService.dao();
List<Sys_union> unionList = sysUnionService.query();
List<ActivitySchool> activityList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
List<String> activityIdList = activityList.stream().map(ActivitySchool::getId).collect(Collectors.toList());
List<String> activityNameList = activityList.stream().map(ActivitySchool::getName).collect(Collectors.toList());
List<String> eventIdList = dao.query(ActivitySchoolEvent.class, Cnd.where("activityId", "in", activityIdList)).stream().map(v -> v.getEventId()).collect(Collectors.toList());
activityNameList.add(0, "分工会");
Sql sql = Sqls.create("""
SELECT
ae.isMenWomen,
ae.isInterest,
ar.integral,
ar.unionId,
ar.activityId
FROM
activity_event ae
LEFT JOIN activity_results ar ON ar.eventId = ae.id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("ae.id", "in", eventIdList);
cnd.and("ar.activityId", "in", activityIdList);
sql.setCondition(cnd);
sql.setCallback(Sqls.callback.maps());
dao.execute(sql);
List<NutMap> list = sql.getList(NutMap.class);
unionList.forEach(u -> {
NutMap unionMap = Lang.obj2nutmap(u);
AtomicReference<Double> scoreSum = new AtomicReference<>((double) 0);
activityList.forEach(a -> {
double sexScore = list.stream().filter(x -> x.getString("unionId").equals(u.getId()) && x.getInt("isMenWomen") == isMenWomen && x.getString("activityId").equals(a.getId())).mapToDouble(h -> h.getDouble("integral")).sum();
double qwScore = list.stream().filter(x -> x.getString("unionId").equals(u.getId()) && x.getInt("isInterest") == 1 && x.getString("activityId").equals(a.getId())).mapToDouble(h -> h.getDouble("integral")).sum();
scoreSum.updateAndGet(v -> new Double((double) (v + (sexScore + (qwScore * 0.5)))));
unionMap.put(a.getName(), sexScore + (qwScore * 0.5));
});
unionMap.put("总分", scoreSum.get());
unionMap.put("分工会", unionMap.getString("unionname"));
resultMap.add(unionMap);
});
activityNameList.add("总分");
return Map.of("label", activityNameList, "score", resultMap);
}
@At
@ViReturn
public void doGetYear8(HttpServletResponse response, Integer isMenWomen, Integer year) throws Exception {
List<NutMap> result = new ArrayList<>();
List<Sys_union> unionList = sysUnionService.query();
unionList.forEach(u -> {
NutMap nutMap = new NutMap();
nutMap.setv("unionname", u.getUnionname());
double score = 0;
for (int i = 1; i <= 2; i++) {
Sql sql = Sqls.create("""
SELECT
SUM( ar.integral ) score
FROM
activity_results ar
LEFT JOIN activity_event eve ON ar.eventId = eve.id
LEFT JOIN activity_school `as` ON `as`.id = ar.activityId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("YEAR ( `as`.applyStartTime )", "=", year);
cnd.and("ar.unionId", "=", u.getId());
if (i == 1) {
cnd.and("eve.isMenWomen", "=", isMenWomen);
sql.setCondition(cnd);
List<NutMap> list = resultsViService.listMap(sql);
score += list.get(0).getDouble("score");
} else {
cnd.and("eve.isInterest", "=", 1);
sql.setCondition(cnd);
List<NutMap> list = resultsViService.listMap(sql);
score += list.get(0).getDouble("score") * 0.5;
}
}
nutMap.setv("score", score);
result.add(nutMap);
});
List<NutMap> scoreList = result.stream().sorted(Comparator.comparing(ActivityScoreStatisticsController::getDouble).reversed()).collect(Collectors.toList()).subList(0, 8);
for (int i = 0; i < scoreList.size(); i++) {
scoreList.get(i).put("ranking", i + 1);
}
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
Configure config = Configure.newBuilder().bind("scoreList", policy).build();
HashMap<String, Object> map = new HashMap<>();
map.put("year", year);
map.put("sex", isMenWomen == 1 ? '男' : '女');
map.put("scoreList", scoreList);
String fileName = "%s年运动会%s子积分表".formatted(year, isMenWomen == 1 ? '男' : '女');
response.addHeader("Content-Type", "application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\".docx");
// XWPFTemplate.compile(officeTemplateUtil.getPath("activity_getYear8"), config).render(map).writeAndClose(response.getOutputStream());;
}
public static Double getDouble(NutMap o) {
return o.getDouble("score");
}
@At
@Ok("void")
@ViReturn
public void doExport8ByActivity(HttpServletResponse response, String activityId, Integer isMenWomen) throws Exception {
List<NutMap> result = new ArrayList<>();
List<Sys_union> unionList = sysUnionService.query();
unionList.forEach(u -> {
NutMap nutMap = new NutMap();
nutMap.setv("unionname", u.getUnionname());
double score = 0;
for (int i = 1; i <= 2; i++) {
Sql sql = Sqls.create("""
SELECT
SUM( ar.integral ) score
FROM
activity_results ar
LEFT JOIN activity_event eve ON ar.eventId = eve.id
LEFT JOIN activity_school `as` ON `as`.id = ar.activityId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("activityId", "=", activityId);
cnd.and("ar.unionId", "=", u.getId());
if (i == 1) {
cnd.and("eve.isMenWomen", "=", isMenWomen);
sql.setCondition(cnd);
List<NutMap> list = resultsViService.listMap(sql);
score += list.get(0).getDouble("score");
} else {
cnd.and("eve.isInterest", "=", 1);
sql.setCondition(cnd);
List<NutMap> list = resultsViService.listMap(sql);
score += list.get(0).getDouble("score") * 0.5;
}
}
nutMap.setv("score", score);
result.add(nutMap);
});
List<NutMap> scoreList = result.stream().sorted(Comparator.comparing(ActivityScoreStatisticsController::getDouble).reversed()).collect(Collectors.toList()).subList(0, 8);
for (int i = 0; i < scoreList.size(); i++) {
scoreList.get(i).put("ranking", i + 1);
}
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
Configure config = Configure.newBuilder().bind("scoreList", policy).build();
HashMap<String, Object> map = new HashMap<>();
map.put("sex", isMenWomen == 1 ? '男' : '女');
map.put("scoreList", scoreList);
String fileName = "%s子积分表".formatted(isMenWomen == 1 ? '男' : '女');
response.addHeader("Content-Type", "application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\".docx");
// XWPFTemplate.compile(officeTemplateUtil.getPath("activity_getYear8"), config).render(map, response.getOutputStream());
}
@At
@Ok("void")
@ViReturn
public void doExcelCj(String activityId, String unionId, HttpServletResponse response) throws IOException {
Sql sql = Sqls.create("""
SELECT
un.unioncode,
un.unionname,
us.loginname,
us.username,
us.sex,
eve.projectCode,
abs.`name` competitionCategoryName,
eve.allName,
ar.integral,
CEILING(
IF
( us.loginname IS NOT NULL, ar.integral, ar.integral / 2 )) jf,
ar.ranking
FROM
activity_results ar
LEFT JOIN activity_event eve ON ar.eventId = eve.id
LEFT JOIN activity_basic_settings abs ON abs.id = eve.competitionCategory
LEFT JOIN activity_school_apply apply ON apply.userId = ar.userId
AND ar.activityId = apply.activityId
LEFT JOIN sys_union un ON un.id = ar.unionId
LEFT JOIN sys_user us ON us.id = ar.userId
$condition
ORDER BY
un.unioncode ASC,
us.sex DESC,
FIELD( abs.`name`, '甲组', '乙组', '丙组', '丁组', '团体' ) ASC
""");
Cnd cnd = Cnd.NEW();
cnd.and("ar.activityId", "=", activityId);
cnd.andEX("ar.unionId", "=", unionId);
cnd.groupBy("ar.id");
sql.setCondition(cnd);
List<NutMap> list = schoolViService.listMap(sql);
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("分工会代码", "unioncode", 40));
entityList.add(new ExcelExportEntity("分工会名称", "unionname", 20));
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
entityList.add(new ExcelExportEntity("姓名", "username", 20));
entityList.add(new ExcelExportEntity("性别", "sex", 20));
entityList.add(new ExcelExportEntity("项目代码", "projectCode", 20));
entityList.add(new ExcelExportEntity("组别", "competitionCategoryName", 20));
entityList.add(new ExcelExportEntity("项目名称", "allName", 40));
entityList.add(new ExcelExportEntity("成绩", "integral", 20));
entityList.add(new ExcelExportEntity("名次", "ranking", 20));
entityList.add(new ExcelExportEntity("积分", "jf", 20));
ViTool.excelResponse(response, "成绩名单.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, list);
workbook.write(response.getOutputStream());
}
}
@@ -0,0 +1,482 @@
package io.v.nutz.activity.controller.school;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import io.v.nutz.activity.models.ActivitySchool;
import io.v.nutz.activity.models.ActivitySchoolEvent;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.sys.models.Sys_union;
import io.v.nutz.sys.services.SysUnionService;
import io.v.nutz.util.ViTool;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@IocBean
@Ok("json:full")
@At("/platform/activity/statistics/export")
@RequiresAuthentication
public class ActivityStatisticsTypeExportController {
@Inject
private SysUnionService sysUnionService;
@Inject
private BaseService baseService;
@Ok("void")
@At
public void getYear8(Integer isMenWomen, Integer year, HttpServletResponse response) {
ArrayList<Map> resultMap = new ArrayList<>();
List<Sys_union> unionList = sysUnionService.query();
List<ActivitySchool> activityList = baseService.dao().query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
List<String> activityIdList = activityList.stream().map(ActivitySchool::getId).collect(Collectors.toList());
List<String> activityNameList = activityList.stream().map(ActivitySchool::getName).collect(Collectors.toList());
List<String> eventIdList = baseService.dao().query(ActivitySchoolEvent.class, Cnd.where("activityId", "in", activityIdList)).stream().map(v -> v.getEventId()).collect(Collectors.toList());
activityNameList.add(0, "分工会");
Sql sql = Sqls.create("""
SELECT
ae.isMenWomen,
ae.isInterest,
ar.integral,
ar.unionId,
ar.activityId
FROM
activity_event ae
LEFT JOIN activity_results ar ON ar.eventId = ae.id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("ae.id", "in", eventIdList);
cnd.and("ar.activityId", "in", activityIdList);
sql.setCondition(cnd);
List<NutMap> list = baseService.listMap(sql);
unionList.forEach(u -> {
NutMap unionMap = Lang.obj2nutmap(u);
AtomicReference<Double> scoreSum = new AtomicReference<>((double) 0);
activityList.forEach(a -> {
double sexScore = list.stream().filter(x -> x.getString("unionId").equals(u.getId()) && x.getInt("isMenWomen") == isMenWomen && x.getString("activityId").equals(a.getId())).mapToDouble(h -> h.getDouble("integral")).sum();
double qwScore = list.stream().filter(x -> x.getString("unionId").equals(u.getId()) && x.getInt("isInterest") == 1 && x.getString("activityId").equals(a.getId())).mapToDouble(h -> h.getDouble("integral")).sum();
scoreSum.updateAndGet(v -> new Double((double) (v + (sexScore + (qwScore * 0.5)))));
unionMap.put(a.getName(), sexScore + (qwScore * 0.5));
});
unionMap.put("总分", scoreSum.get());
unionMap.put("分工会", unionMap.getString("unionname"));
resultMap.add(unionMap);
});
activityNameList.add("总分");
resultMap.sort(Comparator.comparing((Map m) -> (new BigDecimal(m.get("总分").toString()))).reversed());
for (int i = 0; i < resultMap.size(); i++) {
resultMap.get(i).put("名次", i + 1);
}
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("名次", "名次", 20));
activityNameList.forEach(v -> {
entityList.add(new ExcelExportEntity(v, v, 40));
});
try {
ViTool.excelResponse(response, "年度" + (isMenWomen == 1 ? "男子" : "女子") + "团体总分.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, resultMap);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@Ok("void")
@At
public void getAnnualResults(Integer year, HttpServletResponse response) {
ArrayList<Map> resultMap = new ArrayList<>();
Dao dao = sysUnionService.dao();
List<Sys_union> unionList = sysUnionService.query();
List<ActivitySchool> activitySchoolList = dao.query(ActivitySchool.class, Cnd.where("YEAR(applyStartTime)", "=", year));
List<String> labelList = activitySchoolList.stream().map(v -> v.getName()).collect(Collectors.toList());
labelList.add(0, "分工会");
unionList.forEach(u -> {
NutMap unionMap = Lang.obj2nutmap(u);
AtomicReference<Double> scoreSum = new AtomicReference<>((double) 0);
activitySchoolList.forEach(x -> {
Sql sql = Sqls.create("""
SELECT sum(integral) as sumScore FROM `activity_results` ar
where ar.activityId = @activityId and ar.unionId = @unionId
""");
sql.setParam("activityId", x.getId());
sql.setParam("unionId", u.getId());
sql.setCallback(Sqls.callback.map());
dao.execute(sql);
NutMap scoreMap = (NutMap) sql.getResult();
double score = scoreMap.getDouble("sumScore");
scoreSum.updateAndGet(v -> new Double((v + score)));
unionMap.put(x.getName(), score);
});
unionMap.put("总分", scoreSum.get());
unionMap.put("分工会", unionMap.getString("unionname"));
resultMap.add(unionMap);
});
labelList.add("总分");
resultMap.sort(Comparator.comparing((Map m) -> (new BigDecimal(m.get("总分").toString()))).reversed());
for (int i = 0; i < resultMap.size(); i++) {
resultMap.get(i).put("名次", i + 1);
}
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("名次", "名次", 20));
labelList.forEach(v -> {
entityList.add(new ExcelExportEntity(v, v, 40));
});
try {
ViTool.excelResponse(response, "年度团体总分.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, resultMap);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Ok("void")
public void isMaleFemale(String activityId, String sex, Integer awardsMode, HttpServletResponse response) {
NutMap map = new NutMap();
List<NutMap> result = new ArrayList<>();
//查询所有的工会
List<Sys_union> query = sysUnionService.query();
CndPlus cndX = new CndPlus();
//查询所有的项目
Sql sqlX = Sqls.create("""
SELECT
ev.id,
ev.eventId,
ba.`name` baname,
eve.projectType awardsMode,
eve.allName label,
eve.isMenWomen
FROM
activity_school_event ev
LEFT JOIN activity_event eve ON ev.eventId = eve.id
LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition
""");
cndX.and("ev.activityId", "=", activityId);
if (awardsMode < 3) {
cndX.and("eve.projectType", "=", awardsMode);
cndX.and("eve.isInterest", "=", false);
cndX.and("eve.isMenWomen", "=", sex.equals("") ? 1 : 2);
}
if (awardsMode == 3) {
cndX.and("eve.isInterest", "=", true);
}
if (awardsMode == 4) {
cndX.and(Cnd.exps("eve.isMenWomen", "=", sex.equals("") ? 1 : 2).or("eve.isMenWomen", "is", null));
}
cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end"));
sqlX.setCondition(cndX);
List<Record> eventList = baseService.list(sqlX);
//查询每个工会下每个项目的成绩
for (Sys_union sys_union : query) {
NutMap nutMap = new NutMap();
//记录总积分
double totalScore = 0;
nutMap.setv("unionname", sys_union.getUnionname());
for (Record event : eventList) {
Sql sqlC = Sqls.create("""
SELECT
IF ( sum( integral ) IS NULL, 0, sum( integral )) AS integral,
ev.allName,ev.projectType,abs.`name` AS zb,ev.isInterest
FROM
activity_results ar
LEFT JOIN activity_event ev ON ar.eventId = ev.id
LEFT JOIN activity_basic_settings abs ON abs.id=ev.competitionCategory $condition
""");
CndPlus cndC = new CndPlus();
if ((awardsMode == 1 && event.getString("awardsMode").equals("1")) || (awardsMode == 2 && event.getString("awardsMode").equals("2"))) {
cndC.and("ev.isInterest", "=", false);
cndC.and("ev.isMenWomen", "=", sex.equals("") ? 1 : 2);
} else if (awardsMode == 3) {
cndC.and("ev.isInterest", "=", true);
} else if (awardsMode == 4) {
cndC.and(Cnd.exps("ev.isMenWomen", "=", sex.equals("") ? 1 : 2).or("ev.isMenWomen", "is", null));
}
cndC.and("ar.eventId", "=", event.getString("eventid"));
cndC.and("ar.unionid", "=", sys_union.getId());
cndC.and("ar.activityId", "=", activityId);
sqlC.setCondition(cndC);
Double score = 0.0;
List<NutMap> list = baseService.listMap(sqlC);
boolean isInterest = list.get(0).getBoolean("isInterest");
if (list.size() > 0) {
score = list.get(0).getDouble("integral");
}
if (list.get(0).getString("allName") != null) {
if (!isInterest) {
nutMap.setv(list.get(0).getString("allName"), score);
} else {
nutMap.setv(list.get(0).getString("allName"), score / 2);
}
}
totalScore += isInterest ? (score / 2) : score;
if (list.get(0).getString("zb") != null) {
nutMap.setv("projectType", list.get(0).getString("projectType"));
nutMap.setv("zb", list.get(0).getString("zb"));
}
}
nutMap.setv("totalScore", totalScore);
result.add(nutMap);
}
result.sort(Comparator.comparing((Map m) -> (new BigDecimal(m.get("totalScore").toString()))).reversed());
for (int i = 0; i < result.size(); i++) {
result.get(i).put("名次", i + 1);
}
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("名次", "名次", 20));
entityList.add(new ExcelExportEntity("分工会", "unionname", 40));
eventList.forEach(v -> {
entityList.add(new ExcelExportEntity(v.getString("label"), v.getString("label"), 40));
});
entityList.add(new ExcelExportEntity("总分", "totalScore", 40));
try {
ViTool.excelResponse(response, "分工会" + sex + "项目积分.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, result);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Ok("void")
public void isTopEight(String activityId, String sex, Integer awardsMode, HttpServletResponse response) {
NutMap map = new NutMap();
List<Record> result = new ArrayList<>();
CndPlus cndX = new CndPlus();
//查询所有的项目
Sql sqlX = Sqls.create("""
SELECT
ev.id,
ev.eventId,
ba.`name` baname,
eve.projectType awardsMode,
eve.allName label
FROM
activity_school_event ev
LEFT JOIN activity_event eve ON ev.eventId = eve.id
LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition
""");
cndX.and("ev.activityId", "=", activityId);
if (awardsMode == 1) {
cndX.and("eve.isMenWomen", "!=", sex.equals("") ? 2 : 1);
cndX.and("eve.projectType", "=", 1);
} else {
cndX.and("eve.projectType", "=", 2);
}
cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end"));
sqlX.setCondition(cndX);
List<Record> eventList = baseService.list(sqlX);
List<NutMap> nutMaps = new ArrayList<>();
for (int i = 0; i < 8; i++) {
NutMap nutMap = new NutMap();
Sql sqlC = Sqls.create("");
CndPlus cnd = new CndPlus();
if (awardsMode == 1) {
sqlC = Sqls.create("""
SELECT
CONCAT( apply.username, '(', apply.activityUnionName, ')' ) username,
ar.integral,
ar.ranking,
eve.allName
FROM
activity_results ar
LEFT JOIN activity_event eve ON ar.eventId = eve.id
LEFT JOIN activity_school_apply apply ON apply.userId = ar.userId
AND ar.activityId = apply.activityId $condition
""");
cnd.and("ar.isTeamPersonal", "=", awardsMode);
cnd.and("apply.sex", "=", sex);
cnd.and("ar.activityId", "=", activityId);
cnd.and("ar.ranking", "=", i + 1);
cnd.groupBy("ar.id");
} else {
sqlC = Sqls.create("""
SELECT
CONCAT(sun.unionname) username,
eve.allName,ar.ranking
FROM
activity_results ar
LEFT JOIN activity_event eve ON ar.eventId = eve.id
LEFT JOIN sys_union sun ON sun.id = ar.unionId $condition
""");
cnd.and("ar.isTeamPersonal", "=", awardsMode);
cnd.and("ar.activityId", "=", activityId);
cnd.and("ar.ranking", "=", i + 1);
}
sqlC.setCondition(cnd);
List<Record> list = baseService.list(sqlC);
list.forEach(l -> {
nutMap.setv(l.getString("allName"), l.getString("username"));
});
nutMaps.add(nutMap);
}
for (int i = 0; i < nutMaps.size(); i++) {
nutMaps.get(i).put("名次", i + 1);
}
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("名次", "名次", 20));
eventList.forEach(v -> {
entityList.add(new ExcelExportEntity(v.getString("label"), v.getString("label"), 40));
});
String sex2 = awardsMode == 2 ? "团体" : sex.equals("") ? "男子" : "女子";
try {
ViTool.excelResponse(response, sex2 + "项目前八.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, nutMaps);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Ok("void")
public void isScoreTopEight(String activityId, String sex, HttpServletResponse response) {
NutMap map = new NutMap();
List<NutMap> result = new ArrayList<>();
CndPlus cndX = new CndPlus();
//查询所有的项目
Sql sqlX = Sqls.create("""
SELECT
ev.id,
ev.eventId,
ba.`name` baname,
eve.projectType awardsMode,
eve.allName label
FROM
activity_school_event ev
LEFT JOIN activity_event eve ON ev.eventId = eve.id
LEFT JOIN activity_basic_settings ba ON eve.competitionCategory = ba.id $condition
""");
cndX.and("ev.activityId", "=", activityId);
cndX.and(Cnd.exps("eve.isMenWomen", "=", sex.equals("") ? 1 : 2).or("eve.isMenWomen", "is", null));
cndX.and(new Static("1=1 order by case ba.`name` when '甲组' then 1 when '乙组' then 2 when '丙组' then 3 when '丁组' then 4 when '团体' then 5 end"));
sqlX.setCondition(cndX);
List<Record> eventList = baseService.list(sqlX);
//查询所有的工会
List<Sys_union> query = sysUnionService.query();
for (Sys_union sys_union : query) {
NutMap nutMap = new NutMap();
//记录总积分
double totalScore = 0;
nutMap.setv("unionname", sys_union.getUnionname());
for (Record event : eventList) {
Sql sqlC = Sqls.create("""
SELECT
IF ( sum( integral ) IS NULL, 0, sum( integral )) AS integral,
ev.allName,ev.isInterest
FROM
activity_results ar
LEFT JOIN activity_event ev ON ar.eventId = ev.id $condition
""");
CndPlus cndC = new CndPlus();
cndC.and(Cnd.exps("ev.isMenWomen", "=", sex.equals("") ? 1 : 2).or("ev.isMenWomen", "is", null));
cndC.and("ar.unionid", "=", sys_union.getId());
cndC.and("ar.eventId", "=", event.getString("eventid"));
cndC.and("ar.activityId", "=", activityId);
sqlC.setCondition(cndC);
Double score = 0.0;
List<NutMap> list = baseService.listMap(sqlC);
boolean isInterest = list.get(0).getBoolean("isInterest");
if (list.size() > 0) {
score = list.get(0).getDouble("integral");
}
totalScore += isInterest ? (score / 2) : score;
}
nutMap.setv("totalScore", totalScore);
result.add(nutMap);
}
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("名次", "名次", 20));
entityList.add(new ExcelExportEntity("分工会", "unionname", 40));
entityList.add(new ExcelExportEntity("总分", "totalScore", 40));
result.sort(Comparator.comparing((Map m) -> (new BigDecimal(m.get("totalScore").toString()))).reversed());
for (int i = 0; i < result.size(); i++) {
result.get(i).put("名次", i + 1);
}
try {
ViTool.excelResponse(response, "分工会" + sex + "子总分.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, result);
workbook.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,73 @@
package io.v.nutz.activity.controller.school.constant;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* TODO
*
* @Author zhf
* @Date 2022/7/11 15:48
*/
@Data
@Accessors(chain = true)
public class SchoolActivityApplyExportEntity {
@Excel(name = "号码", width = 20d)
private String number;
@Excel(name = "姓名", width = 20d)
private String userName;
@Excel(name = "性别", width = 20d)
private String sex;
private Integer sexOrder;
@Excel(name = "组别", width = 20d)
private String groupName;
private Integer groupNameOrder;
@Excel(name = "项目1", width = 20d)
private String projectNameOne;
@Excel(name = "报名成绩", width = 20d)
private String scoreOne;
@Excel(name = "项目2", width = 20d)
private String projectNameTwo;
@Excel(name = "报名成绩", width = 20d)
private String scoreTwo;
@Excel(name = "项目3", width = 20d)
private String projectNameThree;
@Excel(name = "报名成绩", width = 20d)
private String scoreThree;
@Excel(name = "项目4", width = 20d)
private String projectNameFour;
@Excel(name = "报名成绩", width = 20d)
private String scoreFour;
@Excel(name = "项目5", width = 20d)
private String projectNameFive;
@Excel(name = "报名成绩", width = 20d)
private String scoreFive;
@Excel(name = "项目6", width = 20d)
private String projectNameSix;
@Excel(name = "报名成绩", width = 20d)
private String scoreSix;
@Excel(name = "身高", width = 20d)
private String height;
@Excel(name = "体重", width = 20d)
private String weight;
@Excel(name = "备注", width = 20d)
private String remark;
@Excel(name = "身份证", width = 20d)
private String idCard;
@Excel(name = "注册号", width = 20d)
private String registerNum;
private Integer awardsMode;
private Integer projectNameLocation;
private int distance;
}
@@ -0,0 +1,144 @@
package io.v.nutz.activity.controller.site;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivityType;
import io.v.nutz.activity.services.ActivityCommonService;
import io.v.nutz.activity.services.ActivityTypeService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.modules.models.AuditState;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Author JyuHsin
* @Date 2022/5/11
* @Description
*/
@IocBean
@At("/platform/activity/site/type")
public class ActivityTypeController {
@Inject
private Dao dao;
@Inject
private ActivityTypeService activityTypeService;
@Inject
private ActivityCommonService activityCommonService;
@At("")
@Ok("beetl:/platform/activity/site/SiteType.html")
@RequiresPermissions("activity.site.type")
public void index(HttpServletRequest request) {
}
@At("/findAll")
@Ok("json:full")
@ViReturn
public Object findAll() {
List<ActivityType> meetingTypeList = dao.query(ActivityType.class, Cnd.NEW().asc("sortNum"));
dao.fetchLinks(meetingTypeList, "^auditStateList$");
for (ActivityType ActivityType : meetingTypeList) {
List<AuditState> auditStateList = ActivityType.getAuditStateList();
dao.fetchLinks(auditStateList, "^auditStateUserList$");
}
return meetingTypeList;
}
@At("/doHandle")
@Ok("json:full")
@ViReturn
public Object doHandle(@Param("data") String data) {
ActivityType activityType = Json.fromJson(ActivityType.class, data);
if (null == activityType.getId()) {
int count = dao.count(AuditState.class, Cnd.where("module", "=", activityType.getModuleName()));
if (count > 0) {
return Result.error("模块名称已存在,换一个试试");
}
activityTypeService.add(activityType);
} else {
activityTypeService.edit(activityType);
}
return null;
}
@At("/delete/?")
@Ok("json:full")
@ViReturn
public Object delete(Integer id) {
if (id == 1) {
return Result.error("此记录不可删除");
}
dao.clear(ActivityType.class, Cnd.where("id", "=", id));
return null;
}
@At("/findUserList")
@Ok("json:full")
@ViReturn
public Object findUserList(@Param("keyWords") String[] keyWords) {
Sql sql = Sqls.create("""
SELECT
id,
username,
loginname,
mobile,
sex,
unitname,
unionname,
unionid,
unitid
FROM
`user`
$condition
""");
Cnd cnd = Cnd.NEW();
SqlExpressionGroup seg = new SqlExpressionGroup();
for (String keyWord : keyWords) {
seg.andLike("loginname", keyWord);
seg.orLike("username", keyWord);
}
cnd.and(seg);
sql.setCondition(cnd);
return Daos.query(dao, sql.toString(), Sqls.callback.maps());
}
@At
@Ok("json:full")
@ViReturn
public Object findMaxStateId() {
return activityTypeService.findMaxStateId();
}
@At
@Ok("json:full")
@ViReturn
public Object checkStateId(@Param("stateId") Integer stateId, @Param("stateIndex") Integer stateIndex) {
if (stateId == null) {
return Result.error("参数错误");
}
int count = dao.count(AuditState.class, Cnd.where("stateId", "=", stateId));
if (count == 0) {
return Result.success().addData(stateId);
} else {
return Result.success(activityTypeService.findMaxStateId() + 10 * stateIndex);
}
}
}
@@ -0,0 +1,91 @@
package io.v.nutz.activity.controller.site;
import io.v.nutz.activity.models.ActivitySiteInfo;
import io.v.nutz.activity.services.SiteInfoService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
/**
* @author: Aaron
* @create: 2020-12-13 09:39
* @description: 场地管理
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/site/mange")
@RequiresAuthentication
public class SiteManageController {
@Inject
private SiteInfoService siteInfoService;
@At("")
@Ok("beetl:platform/activity/site/SiteManage.html")
@RequiresPermissions("activity.site.manage")
public void index() {
}
@At
@ViReturn
public Object pageData(String siteType, Integer year, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
Cnd cnd = Cnd.NEW();
if (year != null && year != 0) {
cnd.and("YEAR(create_time)", "=", year);
}
if (Strings.isNotBlank(siteType)) {
cnd.and("typeId", "=", siteType);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.desc("create_time");
}
return siteInfoService.listPage(pageNumber, pageSize, cnd);
}
@At
@ViReturn
public Object doAdd(@Param("data") ActivitySiteInfo activitySiteInfo) {
siteInfoService.insert(activitySiteInfo);
return null;
}
@At
@ViReturn
public Object doEdit(@Param("data") ActivitySiteInfo activitySiteInfo) {
siteInfoService.updateIgnoreNull(activitySiteInfo);
return null;
}
@At
@ViReturn
public Object doDelete(String id) {
siteInfoService.delete(id);
return null;
}
@At
@ViReturn
public Object findOneSite(String id) {
return siteInfoService.fetch(id);
}
}
@@ -0,0 +1,102 @@
package io.v.nutz.activity.controller.site;
import io.v.nutz.activity.services.SiteReserveService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.util.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.List;
import java.util.stream.Collectors;
/**
* @FileName io.v.nutz.activity.controller.site.SiteRecordController
* @Description: 预约记录查询
* @Author zxc
* @Date 2022/5/19:15:21
* @Version V1.0
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/site/record")
@RequiresAuthentication
public class SiteRecordController {
@Inject
private SiteReserveService siteReserveService;
@At("")
@Ok("beetl:platform/activity/site/SiteRecord.html")
@RequiresPermissions("activity.site.record")
public void index() {
}
@At
@ViReturn
public Object pageData(String month, String siteType, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
asr.*,
asi.`name` site_name,
ass.`stateName` state_name,
ass.`stateColor` state_color,
ass.stateAuditType,
count(sqid) days,
GROUP_CONCAT(reserve_day order by reserve_day asc) concat_day
FROM
activity_site_reserve asr
LEFT JOIN
activity_site_info asi ON asi.id = asr.site_id
LEFT JOIN
audit_state ass ON ass.stateId = asr.reserve_state
LEFT JOIN
sys_user u on u.id = asr.reserve_person_id
$condition
""");
if (ShiroUtil.hasAnyRoles(new String[]{"gh10"})) {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
cnd.and("u.unitid", "=", user.getUnitid());
}
if (Strings.isNotBlank(siteType)) {
cnd.and("asi.typeId", "=", siteType);
}
if (Strings.isNotBlank(month)) {
cnd.and("left(reserve_day, 7)", "=", month);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.asc("asr.reserve_state").desc("u.unitid");
}
cnd.groupBy("sqid");
sql.setCondition(cnd);
return siteReserveService.listPage(pageNumber, pageSize, sql);
}
}
@@ -0,0 +1,378 @@
package io.v.nutz.activity.controller.site;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.activity.models.ActivitySiteInfo;
import io.v.nutz.activity.models.ActivitySiteReserve;
import io.v.nutz.activity.services.ActivityCommonService;
import io.v.nutz.activity.services.SiteInfoService;
import io.v.nutz.activity.services.SiteReserveService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.SendMsg;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysUnitService;
import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.util.ShiroUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.Strings;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author: Aaron
* @create: 2020-12-13 14:33
* @description: 场地预约
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/site/reserve")
@RequiresAuthentication
public class SiteReserveController {
@Inject
private SiteInfoService siteInfoService;
@Inject
private SiteReserveService siteReserveService;
@Inject
private SysUserService sysUserService;
@Inject
private ActivityCommonService activityCommonService;
@Inject
private SysUnitService sysUnitService;
@Inject
private SendMsg sendMsg;
@At("")
@Ok("beetl:platform/activity/site/SiteReserve.html")
@RequiresPermissions("activity.site.reserve")
public void index() {
}
@At
@ViReturn
public Object pageData(String siteType, String time, String siteId, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
asr.*,
asi.`name` site_name,
ass.`stateName` state_name,
ass.`stateColor` state_color,
ass.stateAuditType,
count(sqid) days,
GROUP_CONCAT(reserve_day order by reserve_day asc) concat_day
FROM
activity_site_reserve asr
LEFT JOIN
activity_site_info asi ON asi.id = asr.site_id
LEFT JOIN
audit_state ass ON ass.stateId = asr.reserve_state
$condition
""");
if (ShiroUtil.hasAnyRoles(new String[]{"H01", "public"})) {
cnd.and("reserve_person_id", "=", ShiroUtil.getPrincipalProperty("id"));
}
if (Strings.isNotBlank(time)) {
cnd.and("left(asr.reserve_day, 7)", "=", time);
}
if (Strings.isNotBlank(siteId)) {
cnd.and("site_id", "=", siteId);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.asc("asr.reserve_state").desc("asr.reserve_day");
}
if (Strings.isNotBlank(siteType)) {
cnd.and("typeId", "=", siteType);
}
cnd.groupBy("sqid");
sql.setCondition(cnd);
return siteReserveService.listPage(pageNumber, pageSize, sql);
}
@At
@ViReturn
public Object doDelete(String id, Integer op) {
ActivitySiteReserve fetch = siteReserveService.fetch(id);
if (op == 1) {
siteReserveService.clear(Cnd.NEW().and("sqid", "=", fetch.getSqid()));
} else if (op == 2) {
//siteReserveService.update(Chain.make("reserve_state", 50), Cnd.where("id", "=", id));
siteReserveService.clear(Cnd.NEW().and("sqid", "=", fetch.getSqid()));
}
return null;
}
@At
public Object isCanRollBack(String id) {
//根据活动id查询第一个审核节点
ActivitySiteReserve fetch = siteReserveService.fetch(id);
String moduleName = activityCommonService.findModuleNameByActivityId(fetch.getSite_id());
Integer stateCode = activityCommonService.findStartStateCodeByModuleName(moduleName);
return fetch.getReserve_state() > stateCode;
}
@At
@ViReturn
public Object doAdd(@Param("data") ActivitySiteReserve activitySiteReserve, @Param("days") String[] days) {
String r = R.UU32();
activitySiteReserve.setSqid(r);
String moduleName = activityCommonService.findModuleNameByActivityId(activitySiteReserve.getSite_id());
Integer stateCode = activityCommonService.findStartStateCodeByModuleName(moduleName);
if (stateCode == null) {
return null;
}
ActivitySiteInfo siteInfo = siteInfoService.fetch(activitySiteReserve.getSite_id());
for (String d : days) {
if (siteInfoService.isInCloseDates(siteInfo, d)) {
return Result.error(siteInfoService.getCloseDateMessage(siteInfo));
}
activitySiteReserve.setReserve_day(d);
//查询这个人是否已经预约这个时间段
int count = siteReserveService.count("activity_site_reserve", Cnd.NEW().and("reserve_person_id", "=", ShiroUtil.getPrincipalProperty("id"))
.and("reserve_day", "=", activitySiteReserve.getReserve_day()).and("start_time", "=", activitySiteReserve.getStart_time())
.and("end_time", "=", activitySiteReserve.getEnd_time()));
if (count > 0) {
return Result.error("您已预约该时间段!");
}
activitySiteReserve.setReserve_state(stateCode);
activitySiteReserve.setReserve_person_id(ShiroUtil.getPrincipalProperty("id").toString());
siteReserveService.insert(activitySiteReserve);
}
//发送微信提醒审核人
//查询状态码对应的审核人
Sql sql = Sqls.create("""
select userId,u.loginname,u.username from audit_state_user asu
left join `user` u on u.id = asu.userId left join audit_state s on s.stateId=asu.stateId $condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("asu.stateId", "=", stateCode);
cnd.and("s.stateAuditType", "=", "0");
if("infantRoom".equals(moduleName)) {
//获取当前登录人的单位id
String unitId = ShiroUtil.getPrincipalProperty("unitid").toString();
cnd.and("u.unitid", "=", unitId);
}
sql.setCondition(cnd);
List<Record> list = siteReserveService.list(sql);
list.forEach(item -> {
String content = "%s老师您好!%s老师预约%s使用%s,请您通过门户网站或企业微信登录智慧工会平台进行审核。"
.formatted(item.getString("username"),
activitySiteReserve.getReserve_person(),
StringUtils.join(days, ","),
siteInfo.getName());
sendMsg.pushWeChatMsg("场地预约", content, item.getString("loginname"));
});
return null;
}
@At
@ViReturn
public Object findAllOpenSite(String time, String siteType) {
String sb = "SELECT " +
"asi.*," +
" (select unitname from `user` where username = asi.contact_person) as unitname," +
"( SELECT count( 1 ) FROM activity_site_reserve WHERE site_id = asi.id AND reserve_state = (select stateId from audit_state where module = (select moduleName from activity_type where id = asi.typeId) and stateAuditType = 3) ";
if (StrUtil.isNotBlank(time)) {
sb += " AND left(reserve_day, 7) = '" + time + "'";
}
sb += " ) count FROM activity_site_info asi $condition ";
Sql sql = Sqls.create(sb);
Cnd cnd = Cnd.NEW();
cnd.and("state", "=", true);
if (StrUtil.isNotBlank(siteType)) {
cnd.and("typeId", "=", siteType);
}
sql.setCondition(cnd);
return siteInfoService.list(sql);
}
@At
public Object findUser(String keywords) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("SELECT ur.username,ur.id,ut.name unit_name,ur.unitid,ur.mobile FROM sys_user ur LEFT JOIN sys_unit ut ON ut.id=ur.unitid $condition LIMIT 0,30 ");
if (Strings.isNotBlank(keywords)) {
cnd.where().orLike("loginname", keywords).orLike("username", keywords);
}
sql.setCondition(cnd);
List<Record> list = sysUserService.list(sql);
return Result.success().addData(list);
}
@At
@ViReturn
public Object findReserveInfo(String siteId, String day) {
Sql sql = Sqls.create("SELECT ar.*,`as`.stateAuditType FROM activity_site_reserve ar left join audit_state `as` on ar.reserve_state=`as`.stateId $condition");
String moduleName = activityCommonService.findModuleNameByActivityId(siteId);
//根据moduleName找审核失败的数据
Sql s = Sqls.create("""
select
stateId
from
audit_state
where
stateAuditType = 1 and
module = @module
""").setParam("module", moduleName);
List<Record> list = siteReserveService.list(s);
List<String> stateList = list.stream().map(o -> o.getString("stateId")).collect(Collectors.toList());
Cnd cnd = Cnd.NEW();
cnd.and("site_id", "=", siteId);
if (StrUtil.isNotBlank(day)) {
cnd.and("reserve_day", "=", day);
cnd.and("reserve_state", "not in ", stateList);
}
sql.setCondition(cnd);
return siteReserveService.list(sql);
}
@At
@ViReturn
public Object checkReserve(String reserve_day, String start_time, String end_time, String site_id) {
Cnd cnd = Cnd.NEW();
cnd.and("site_id", "=", site_id)
.and("reserve_state", "!=", 40)
.and("reserve_day", "=", reserve_day);
SqlExpressionGroup group = new SqlExpressionGroup();
group.or("start_time", "<=", start_time).and("end_time", ">=", start_time);
group.or("start_time", "<=", end_time).and("start_time", ">=", end_time);
cnd.and(group);
return siteReserveService.count(cnd);
}
@At
@ViReturn
public Object findOne(String id) {
ActivitySiteReserve fetch = siteReserveService.fetch(id);
Sql sql = Sqls.create("""
SELECT
asr.*,
asi.`name` site_name,
ass.`stateName` state_name,
ass.stateAuditType,
su.username,
sm.username smusername,
su.sex,
su.loginname,
count(sqid) days,
GROUP_CONCAT(reserve_day order by reserve_day asc) concat_day
FROM
activity_site_reserve asr
LEFT JOIN activity_site_info asi ON asi.id = asr.site_id
LEFT JOIN audit_state ass ON ass.stateId = asr.reserve_state
LEFT JOIN sys_user su ON su.id = asr.reserve_person_id
LEFT JOIN sys_user sm ON sm.id = asr.site_manager_id
WHERE
asr.sqid = @id
group by sqid
""").setParam("id", fetch.getSqid());
Record record = siteReserveService.list(sql).get(0);
String auditList = record.getString("auditList");
if (auditList != null) {
List<NutMap> nutMaps = Json.fromJsonAsList(NutMap.class, auditList);
nutMaps.forEach(item -> {
item.put("auditListName", item.getBoolean("auditState") ? "审核通过" : "审核拒绝");
Sys_user auditUSer = sysUserService.fetch(item.getString("auditUser"));
item.put("auditUserName", auditUSer.getUsername());
item.put("auditUserUnionName", sysUnitService.fetch(auditUSer.getUnitid()).getName());
Sql sqlStr = Sqls.create("select stateName from audit_state where stateId = '" + item.getString("stateCode") + "'");
Record re = sysUserService.list(sqlStr).get(0);
item.put("auditStateName", re.getString("stateName"));
});
record.put("auditListTable", nutMaps);
} else {
record.put("auditListTable", new ArrayList<>());
}
Cnd cnd = Cnd.NEW();
String site_id = record.getString("site_id");
String reserve_day = record.getString("reserve_day");
String moduleName = activityCommonService.findModuleNameByActivityId(record.getString("site_id"));
//根据moduleName找审核失败的数据
Sql s = Sqls.create("""
select
stateId
from
audit_state
where
stateAuditType = 1 and
module = @module
""").setParam("module", moduleName);
List<Record> list = siteReserveService.list(s);
List<String> stateList = list.stream().map(o -> o.getString("stateId")).collect(Collectors.toList());
Sql i = Sqls.create("""
SELECT
ar.*,
`as`.stateAuditType
FROM
activity_site_reserve ar
left join audit_state `as` on `as`.stateId = ar.reserve_state
$condition
""");
cnd.and("site_id", "=", site_id)
//.and("reserve_day", "=", reserve_day)
.and("reserve_state", "not in", stateList);
i.setCondition(cnd);
List<Record> list1 = siteReserveService.list(i);
record.set("site_info", list1);
return record;
}
}
@@ -0,0 +1,209 @@
package io.v.nutz.activity.controller.site;
import io.v.nutz.activity.models.ActivitySiteInfo;
import io.v.nutz.activity.models.ActivitySiteReserve;
import io.v.nutz.activity.services.ActivityCommonService;
import io.v.nutz.activity.services.SiteInfoService;
import io.v.nutz.activity.services.SiteReserveService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.utils.SendMsg;
import io.v.nutz.modules.models.Audit;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.util.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author: Aaron
* @create: 2020-12-15 13:52
* @description: 预约审核
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/site/review")
@RequiresAuthentication
public class SiteReviewController {
@Inject
private SiteInfoService siteInfoService;
@Inject
private SiteReserveService siteReserveService;
@Inject
private ActivityCommonService activityCommonService;
@Inject
private SendMsg sendMsg;
@Inject
private SysUserService sysUserService;
@At("")
@Ok("beetl:platform/activity/site/SiteReview.html")
@RequiresPermissions("activity.site.review")
public void index() {
}
@At
@ViReturn
public Object pageData(String month, String siteType, String searchName, String searchKeyword, int pageNumber, int pageSize, String pageOrderName, String pageOrderBy, Boolean isAudit) {
Cnd cnd = Cnd.NEW();
Sql sql = Sqls.create("""
SELECT
asr.*,
asi.`name` site_name,
ass.`stateName` state_name,
ass.`stateColor` state_color,
ass.stateAuditType,
count(sqid) days,
GROUP_CONCAT(reserve_day order by reserve_day asc) concat_day
FROM
activity_site_reserve asr
LEFT JOIN
activity_site_info asi ON asi.id = asr.site_id
LEFT JOIN
audit_state ass ON ass.stateId = asr.reserve_state
LEFT JOIN
sys_user u on u.id = asr.reserve_person_id
$condition
""");
if (ShiroUtil.hasAnyRoles(new String[]{"gh10"})) {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
cnd.and("u.unitid", "=", user.getUnitid());
}
if (isAudit != null) {
if (isAudit) {
//查询已审核
cnd.and(new Static("JSON_CONTAINS(auditList, JSON_OBJECT('auditUser', '" + ShiroUtil.getPrincipalProperty("id") + "'))"));
} else {
//查询未审核,获取当前用户可以审核的节点
Sql s = Sqls.create("""
select stateId from audit_state_user where userId=@userId
""").setParam("userId", ShiroUtil.getPrincipalProperty("id"));
List<Record> sList = siteReserveService.list(s);
List<String> stateList = sList.stream().map(o -> o.getString("stateId")).collect(Collectors.toList());
cnd.and("reserve_state", "in", stateList);
}
}
if (Strings.isNotBlank(siteType)) {
cnd.and("asi.typeId", "=", siteType);
}
if (Strings.isNotBlank(month)) {
cnd.and("left(reserve_day, 7)", "=", month);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderName)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
} else {
cnd.asc("asr.reserve_state").desc("u.unitid");
}
cnd.groupBy("sqid");
sql.setCondition(cnd);
return siteReserveService.listPage(pageNumber, pageSize, sql);
}
@At
@ViReturn
public Object doReview(String[] id, Audit audit, Boolean isPass) {
siteReserveService.insert(audit);
for (String s : id) {
ActivitySiteReserve fetch = siteReserveService.fetch(s);
Integer stateCode = fetch.getReserve_state();
Integer afterStateCode = activityCommonService.findAfterStateCode(stateCode, isPass);
List<ActivitySiteReserve> reserves = siteReserveService.query(Cnd.NEW().and("sqid", "=", fetch.getSqid()));
String days = "";
for (ActivitySiteReserve siteReserve : reserves) {
siteReserve.setReserve_state(afterStateCode);
List<NutMap> auditList = siteReserve.getAuditList();
if (Lang.isEmpty(auditList)) {
auditList = new ArrayList<>();
}
auditList.add(NutMap.NEW().addv("stateCode", stateCode).addv("auditId", audit.getId())
.addv("auditUser", ShiroUtil.getPrincipalProperty("id"))
.addv("auditState", isPass)
.addv("auditOption", audit.getAuditOpinion())
);
siteReserve.setAuditList(auditList);
days += siteReserve.getReserve_day() + ",";
siteReserveService.update(siteReserve);
}
days = days.substring(0, days.length() - 1);
Integer successCode = activityCommonService.findSuccessStateCode(fetch.getSite_id());
ActivitySiteInfo siteInfo = siteInfoService.fetch(fetch.getSite_id());
if (afterStateCode.equals(successCode) && siteInfo.getTypeId() == 1) {
String content = "%s老师您好!您提交的%s使用申请已通过审批,在预约使用期间可刷校园卡进入母婴室,如有疑问,欢迎咨询校工会曾钰媛梦 (025-84897447)。"
.formatted(fetch.getReserve_person(), siteInfo.getName());
Sys_user user = sysUserService.fetch(fetch.getReserve_person_id());
sendMsg.pushWeChatMsg("场地预约", content, user.getLoginname());
} else if (!afterStateCode.equals(successCode)) {
//发送微信提醒审核人
//查询状态码对应的审核人
Sql sql = Sqls.create("""
select userId,u.loginname,u.username from audit_state_user asu
left join `user` u on u.id = asu.userId left join audit_state s on s.stateId=asu.stateId $condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("asu.stateId", "=", afterStateCode);
cnd.and("s.stateAuditType", "=", "0");
String moduleName = activityCommonService.findModuleNameByActivityId(fetch.getSite_id());
if ("infantRoom".equals(moduleName) && afterStateCode < 1930) {
//获取当前登录人的单位id
String unitId = ShiroUtil.getPrincipalProperty("unitid").toString();
cnd.and("u.unitid", "=", unitId);
}
sql.setCondition(cnd);
List<Record> list = siteReserveService.list(sql);
for (Record item : list) {
String content = "%s老师您好!%s老师预约%s使用%s,请您通过门户网站或企业微信登录智慧工会平台进行审核。"
.formatted(item.getString("username"),
fetch.getReserve_person(),
days,
siteInfo.getName());
sendMsg.pushWeChatMsg("场地预约", content, item.getString("loginname"));
}
}
}
return null;
}
}
@@ -0,0 +1,110 @@
package io.v.nutz.activity.controller.union;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.activity.models.ActivityTissue;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.Audit;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.util.ShiroUtil;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
/**
* TODO
*
* @Author zhf
* @Date 2022/12/4 9:31
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/audit")
public class ActivityAuditController {
@Inject
private BaseService baseService;
@At("/union")
@Ok("beetl:platform/activity/union/unionActivityAudit.html")
@RequiresPermissions("activity.union.audit")
public void unionIndex() {
}
@At("/club")
@Ok("beetl:platform/activity/union/clubActivityAudit.html")
@RequiresPermissions("activity.club.audit")
public void clubIndex() {
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.club.audit", "activity.union.audit", "activity.union.audit"}, logical = Logical.OR)
public Object pageData(PageForm page, boolean state,
@Param(value = "year") String year,
@Param(value = "name") String name,
@Param(value = "unionId") String unionId,
@Param(value = "type") Integer type) {
CndPlus cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
tissue.*,
uni.unionname ,
club.`name` clubName,
abs.`name` projectTypeName
FROM
activity_tissue tissue
LEFT JOIN sys_union uni ON uni.id = tissue.unionId
LEFT JOIN sys_club club ON club.id = tissue.clubId
LEFT JOIN activity_basic_settings abs ON abs.`code`=tissue.projectTypeCode
$condition
""");
cnd.andExcludeEmpty("YEAR(tissue.startTime)", "=", year);
cnd.andExcludeEmpty("tissue.unionId", "=", unionId);
cnd.andExcludeEmpty("tissue.type", "=", type);
cnd.andExcludeEmpty("tissue.state", state ? ">" : "=", 1);
if (Strings.isNotBlank(name)) {
cnd.where().andLike("tissue.name", name);
}
if (StrUtil.isNotBlank(page.getPageOrderName()) && StrUtil.isNotBlank(page.getPageOrderBy())) {
cnd.orderBy(page.getPageOrderName(), page.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC");
} else {
cnd.desc("tissue.startTime");
}
sql.setCondition(cnd);
return baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.club.audit", "activity.union.audit", "activity.union.audit"}, logical = Logical.OR)
public Object doReview(String id, boolean flag, Audit audit) {
audit.setLoginname(ShiroUtil.getPrincipalProperty("loginname").toString());
baseService.insert(audit);
baseService.dao().update(ActivityTissue.class, Chain.make("state", flag ? 3 : 2).add("auditId", audit.getId()), Cnd.where("id", "=", id));
return null;
}
}
@@ -0,0 +1,119 @@
package io.v.nutz.activity.controller.union;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.activity.models.ActivityTissue;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.SimpleService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.util.Calendar;
/**
* @author zhf
* @date 2021/11/2 10:07
* @description
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/apply")
public class ActivityUnionApplyController {
@Inject
private SimpleService simpleService;
@Inject
private BaseService baseService;
@At("/union")
@Ok("beetl:platform/activity/union/unionActivityApply.html")
@RequiresPermissions("activity.union.apply")
public void unionIndex() {
}
@At("/club")
@Ok("beetl:platform/activity/union/clubActivityApply.html")
@RequiresPermissions("activity.club.apply")
public void clubIndex() {
}
@At("/school")
@Ok("beetl:platform/activity/union/schoolActivityApply.html")
@RequiresPermissions("activity.school.apply")
public void schoolIndex() {
}
private static final NutMap activityCodeMap = new NutMap() {{
put("40002", "JC");
put("40003", "XH");
put("40001", "GH");
}};
/**
* 活动编号生成
*
* @param activity_type
* @return
*/
@At
@ViReturn
public Object generateActivityCode(String activity_type) {
Cnd cnd = Cnd.NEW();
int year = Calendar.getInstance().get(Calendar.YEAR);
cnd.and("LEFT(activityCode,6)", "=", year + activityCodeMap.getString(activity_type));
String code = String.format("%03d", baseService.dao().count(ActivityTissue.class, cnd) + 1);
return year + activityCodeMap.getString(activity_type) + code;
}
@At
@ViReturn
public Object getUnionData(@Param(value = "activityScopeGroupId") String activityScopeGroupId) {
if (StrUtil.isBlank(activityScopeGroupId)) {
Sql sql = Sqls.create("""
SELECT
gh.id,
gh.unionname,
count( u.id ) AS teacherCount
FROM
sys_union gh
LEFT JOIN `user` u ON u.unionid = gh.id
GROUP BY
gh.id
""");
return simpleService.listMap(sql);
} else {
// count( u.id ) AS unionNum,
Sql sql = Sqls.create("""
SELECT
gh.id,
gh.unionname,
( SELECT count( 1 ) FROM `user` WHERE id IN ( SELECT userid FROM activity_user_scope WHERE groupId = @activityScopeGroupId ) AND unionId = gh.id ) as teacherCount
FROM
sys_union gh
LEFT JOIN `user` u ON u.unionid = gh.id
GROUP BY
gh.id
""");
sql.setParam("activityScopeGroupId", activityScopeGroupId);
return simpleService.listMap(sql);
}
}
}
@@ -0,0 +1,321 @@
package io.v.nutz.activity.controller.union;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
import io.v.nutz.activity.models.ActivityTissue;
import io.v.nutz.activity.models.ActivityTissuePerson;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.activity.services.ActivityTissueService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import io.v.nutz.sys.models.Sys_user;
import io.v.nutz.sys.services.SysMsgService;
import io.v.nutz.util.ShiroUtil;
import io.v.nutz.util.ViTool;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.nutz.trans.Trans;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author: Aaron
* @create: 2021-03-08 16:07
* @description: 分工会活动信息管理
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/info/mange")
public class ActivityUnionManageController {
@Inject
private Vi vi;
@Inject
private ActivitySchoolService activitySchoolService;
@Inject
private ActivityTissueService activityTissueService;
@Inject("Sys_user")
private ViService<Sys_user> sysUserService;
@Inject
private SysMsgService sysMsgService;
@Inject("ActivityTissuePerson")
private ViService<ActivityTissuePerson> tissuePersonService;
@At("/union")
@Ok("beetl:platform/activity/union/unionActivity.html")
@RequiresPermissions("activity.union.info")
public void unionIndex() {
}
@At("/club")
@Ok("beetl:platform/activity/union/clubActivity.html")
@RequiresPermissions("activity.club.info")
public void clubIndex() {
}
@At("/school")
@Ok("beetl:platform/activity/union/schoolActivity.html")
@RequiresPermissions("activity.school.info2")
public void schoolIndex() {
}
@At
@ViReturn
@RequiresAuthentication
public Object pageData(PageForm page, @Param(value = "year") String year,
@Param(value = "name") String name,
@Param(value = "unionId") String unionId,
@Param(value = "type") Integer type) {
return activityTissueService.pageData(page, year, name, unionId, type);
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.union.info", "activity.club.info", "activity.school.info2"}, logical = Logical.OR)
public Object findUser(@Param(value = "serachWord") String serachWord,
@Param(value = "activity_type") Integer activity_type) {
CndPlus cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT id userId,username userName,loginname loginName,sex,mobile,unitname unitName,unionname unionName FROM `user` $condition
""");
if (!ShiroUtil.hasRole("sysadmin")) {
if (activity_type == 40002) {
cnd.and("unionId", "=", vi.getUnionId());
} else if (activity_type == 40003) {
cnd.and("id", "in", " SELECT userid FROM sys_club_user WHERE clubid = '%s' ".formatted(vi.getClubId()));
}
}
if (Strings.isNotBlank(serachWord)) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.andLike("username", serachWord);
group.orLike("loginname", serachWord);
cnd.and(group);
}
cnd.limit(1, 30);
sql.setCondition(cnd);
return sysUserService.listMap(sql);
}
/**
* 校工会添加
*
* @param tissue
* @return
*/
@At
@ViReturn
@RequiresPermissions(value = {"activity.union.info", "activity.club.info", "activity.school.info2"}, logical = Logical.OR)
public Object doAdd(@Param(value = "tissue") ActivityTissue tissue) {
tissue.setUserId(ShiroUtil.getUserId());
tissue.setApplyTime(DateUtil.getDate());
String title = "校工会文化活动";
String url = "/platform/activity/info/mange/school";
if (tissue.getType() == 40002) {
tissue.setState(1);
tissue.setUnionId(Vi.getUnionId());
title = "分工会活动";
url = "/platform/activity/info/mange/union";
} else if (tissue.getType() == 40003) {
tissue.setState(1);
tissue.setClubId(vi.getClubId());
title = "协会活动";
url = "/platform/activity/info/mange/club";
} else {
tissue.setState(3);
}
Trans.exec(() -> {
activityTissueService.insertWith(tissue, "tissuePersonList");
tissue.getGoods().forEach(v -> {
v.setActivityCode(tissue.getActivityCode());
v.setReid(tissue.getId());
});
activitySchoolService.dao().insert(tissue.getGoods());
tissue.getCover();
});
if (tissue.getXlFlag() != null && tissue.getXlFlag()) {
String time = tissue.getStartTime() + "" + tissue.getEndTime();
sysMsgService.sendMsgByActivityGroupId(tissue.getId(), tissue.getGroupId(), title, tissue.getName(), url, "/mobile/activity/unionActivity", time);
}
return null;
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.union.info", "activity.club.info", "activity.school.info2"}, logical = Logical.OR)
public Object doEdit(@Param("tissue") ActivityTissue tissue) {
activityTissueService.doEdit(tissue);
String title = "校工会文化活动";
String url = "/platform/activity/info/mange/school";
if (tissue.getType() == 40002) {
title = "分工会活动";
url = "/platform/activity/info/mange/union";
} else if (tissue.getType() == 40003) {
title = "协会活动";
url = "/platform/activity/info/mange/club";
}
sysMsgService.deleteMsgByActivityId(tissue.getId());
if (tissue.getXlFlag() != null && tissue.getXlFlag()) {
String time = tissue.getStartTime() + "" + tissue.getEndTime();
sysMsgService.sendMsgByActivityGroupId(tissue.getId(), tissue.getGroupId(), title, tissue.getName(), url, "/mobile/activity/unionActivity", time);
}
return null;
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.union.info", "activity.club.info", "activity.school.info2"}, logical = Logical.OR)
public Object doDelete(String id) {
activityTissueService.doDelete(id);
return null;
}
@At
@ViReturn
public Object findOne(String id) {
return activityTissueService.findOne(id);
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.union.info", "activity.club.info", "activity.school.info2"}, logical = Logical.OR)
public Object searchTissueUser(String id, @Param(value = "search") String search) {
Cnd cnd = Cnd.NEW();
cnd.and("tissueId", "=", id);
if (Strings.isNotBlank(search)) {
SqlExpressionGroup group = new SqlExpressionGroup();
group.andLike("userName", search);
group.orLike("loginName", search);
cnd.and(group);
}
return tissuePersonService.query(cnd);
}
@At
@RequiresPermissions(value = {"activity.union.info", "activity.club.info", "activity.school.info2"}, logical = Logical.OR)
public void export(String id, HttpServletResponse response) throws IOException {
try {
Sql sql = Sqls.create("""
SELECT
tissue.*,
uni.unionname,
club.`name` clubName
FROM
activity_tissue tissue
LEFT JOIN sys_union uni ON uni.id = tissue.unionId
LEFT JOIN sys_club club ON club.id = tissue.clubId
WHERE
tissue.id = @id
""").setParam("id", id);
NutMap nutMap = activityTissueService.fetch(sql);
List<ActivityTissuePerson> personList = tissuePersonService.query(Cnd.where("tissueId", "=", nutMap.getString("id")));
nutMap.setv("users", personList);
nutMap.setv("unitName", nutMap.getString("unionname") != null ? nutMap.getString("unionname") : nutMap.getString("clubName"));
nutMap.setv("time", new SimpleDateFormat("yyyy年MM月dd日").format(new Date()));
String fileName = nutMap.getString("name") + "活动登记表";
nutMap.setv("fileName", fileName);
response.addHeader("Content-Type", "application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + "\".docx");
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
Configure config = Configure.newBuilder().bind("users", policy).build();
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/activity/tissue.docx");
XWPFTemplate.compile(inputStream, config).render(nutMap, response.getOutputStream());
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
@At
@Ok("void")
@RequiresPermissions(value = {"activity.union.info", "activity.club.info", "activity.school.info2"}, logical = Logical.OR)
public void doExportUser(String id, @Param(value = "unionId") String unionId, HttpServletResponse response) throws IOException {
Sql sql = Sqls.create("""
SELECT
u.id,
u.loginname,
u.username,
u.unitname,
u.unionname,
u.sex,
u.mobile,
atp.applyDateTime
FROM
`activity_tissue_person` atp
LEFT JOIN `user` u ON u.id = atp.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("atp.tissueId", "=", id);
cnd.andEX("u.unionId", "=", unionId);
sql.setCondition(cnd);
List<ActivityTissuePerson> tissuePeople = tissuePersonService.listEntity(sql);
List<ExcelExportEntity> entityList = new ArrayList<>();
entityList.add(new ExcelExportEntity("姓名", "userName", 20));
entityList.add(new ExcelExportEntity("工号", "loginName", 20));
entityList.add(new ExcelExportEntity("性别", "sex", 20));
entityList.add(new ExcelExportEntity("联系方式", "mobile", 20));
entityList.add(new ExcelExportEntity("单位", "unitName", 20));
entityList.add(new ExcelExportEntity("工会", "unionName", 20));
try {
ViTool.excelResponse(response, "参赛人数.xls");
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, tissuePeople);
workbook.write(response.getOutputStream());
} catch (Exception e) {
}
}
}
@@ -0,0 +1,136 @@
package io.v.nutz.activity.controller.union;
import io.v.nutz.activity.models.ActivityPlan;
import io.v.nutz.activity.services.ActivityPlanService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
/**
* @author: Aaron
* @create: 2021-03-08 16:08
* @description: 分工会活动计划管理
**/
@IocBean
@Ok("json:full")
@At("/platform/activity/plan")
public class ActivityUnionPlanController {
@Inject
private Vi vi;
@Inject
private ActivityPlanService activityPlanService;
@At("/union")
@Ok("beetl:platform/activity/union/unionPlan.html")
@RequiresPermissions("activityYear.union.plan")
public void unionIndex() {
}
@At("/addUnionPlan")
@Ok("beetl:platform/activity/union/addUnionPlan.html")
@RequiresPermissions("activityYear.union.addPlan")
public void addUnionPlan() {
}
@At("/club")
@Ok("beetl:platform/activity/union/clubPlan.html")
@RequiresPermissions("activityYear.club.plan")
public void clubIndex() {
}
@At("/addClubPlan")
@Ok("beetl:platform/activity/union/addClubPlan.html")
@RequiresPermissions("activityYear.club.addPlan")
public void addClubPlan() {
}
@At("/school")
@Ok("beetl:platform/activity/union/schoolPlan.html")
@RequiresPermissions("activityYear.school.plan")
public void schoolIndex() {
}
@At("/addSchoolPlan")
@Ok("beetl:platform/activity/union/addSchoolPlan.html")
@RequiresPermissions("activityYear.school.addPlan")
public void addSchoolPlan() {
}
@At
@ViReturn
@RequiresPermissions(value = {"activityYear.club.plan", "activityYear.school.plan", "activityYear.union.plan"}, logical = Logical.OR)
public Object pageData(PageForm page,
@Param(value = "year") String year,
@Param(value = "name") String name,
@Param(value = "tissueId") String tissueId,
@Param(value = "type") Integer type) {
CndPlus cnd = CndPlus.create();
cnd.and("ap.type", "=", type);
return activityPlanService.pageData(page, year, name, tissueId, cnd);
}
@At
@ViReturn
@RequiresPermissions(value = {"activityYear.school.addPlan", "activityYear.union.addPlan", "activityYear.club.addPlan"}, logical = Logical.OR)
public Object doAdd(@Param(value = "name") String name,
@Param(value = "time") String time,
@Param(value = "content") String content,
@Param(value = "event") String event,
@Param(value = "type") String type,
@Param(value = "money") Double money,
@Param(value = "activityType") String activityType) {
ActivityPlan activityPlan = new ActivityPlan();
activityPlan.setName(name);
activityPlan.setMoney(money);
activityPlan.setTime(time);
activityPlan.setContent(content);
activityPlan.setEvent(event);
activityPlan.setActivityType(activityType);
if (type.equals("40002")) {
activityPlan.setType("40002");
activityPlan.setTissueId(Vi.getUnionId());
} else if (type.equals("40003")) {
activityPlan.setType("40003");
activityPlan.setTissueId(vi.getClubId());
} else {
activityPlan.setType("40001");
}
activityPlanService.insert(activityPlan);
return null;
}
@At
@ViReturn
@RequiresPermissions(value = {"activityYear.school.addPlan", "activityYear.union.addPlan", "activityYear.club.addPlan"}, logical = Logical.OR)
public Object doEdit(ActivityPlan activityPlan) {
activityPlanService.updateIgnoreNull(activityPlan);
return null;
}
@At
@ViReturn
@RequiresPermissions(value = {"activityYear.club.plan", "activityYear.school.plan", "activityYear.union.plan"}, logical = Logical.OR)
public Object doDelete(String id) {
activityPlanService.delete(id);
return null;
}
@At
@ViReturn
@RequiresPermissions(value = {"activityYear.club.plan", "activityYear.school.plan", "activityYear.union.plan"}, logical = Logical.OR)
public Object findOne(String id) {
return activityPlanService.fetch(id);
}
}
@@ -0,0 +1,102 @@
package io.v.nutz.activity.controller.union;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.activity.models.ActivityTissue;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.modules.models.PageForm;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
/**
* @ClassName ActivityUnionUserStatisticsController
* @Description TODO
* @Author zhf
* @Date 2023/7/5 10:29
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/user/statistics")
public class ActivityUnionUserStatisticsController {
@At("/union")
@Ok("beetl:platform/activity/union/unionStatisticsActivity.html")
@RequiresPermissions("activity.union.user.statistics")
public void unionIndex() {
}
@At("/club")
@Ok("beetl:platform/activity/union/clubStatisticsActivity.html")
@RequiresPermissions("activity.club.user.statistics")
public void clubIndex() {
}
@At("/school")
@Ok("beetl:platform/activity/union/schoolStatisticsActivity.html")
@RequiresPermissions("activity.school.user.statistics")
public void schoolIndex() {
}
@Inject
private BaseService baseService;
@At
@ViReturn
@RequiresPermissions(value = {"activity.school.user.statistics", "activity.club.user.statistics", "activity.union.user.statistics"}, logical = Logical.OR)
public Object pageData(PageForm page,
@Param(value = "activityId") String activityId,
@Param(value = "unionId") String unionId) {
Sql sql = Sqls.create("""
SELECT
u.id,
u.loginname,
u.username,
u.unitname,
u.unionname,
u.sex,
u.mobile,
atp.applyDateTime
FROM
`activity_tissue_person` atp
LEFT JOIN `user` u ON u.id = atp.userId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("atp.tissueId", "=", activityId);
cnd.andEX("u.unionId", "=", unionId);
if (Strings.isNotBlank(page.getSearchName()) && Strings.isNotBlank(page.getSearchKeyword())) {
cnd.where().andLike(page.getSearchName(), page.getSearchKeyword());
}
if (StrUtil.isNotBlank(page.getPageOrderName()) && StrUtil.isNotBlank(page.getPageOrderBy())) {
cnd.orderBy(page.getPageOrderName(), page.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC");
} else {
cnd.desc("atp.applyDateTime");
}
sql.setCondition(cnd);
return baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@At
@ViReturn
@RequiresPermissions(value = {"activity.school.user.statistics", "activity.club.user.statistics", "activity.union.user.statistics"}, logical = Logical.OR)
public Object getActivityByYearOrType(@Param(value = "year") Integer year,
@Param(value = "type") Integer type) {
return baseService.dao().query(ActivityTissue.class, Cnd.where("type", "=", type).andEX("YEAR(startTime)", "=", year).desc("startTime"));
}
}
@@ -0,0 +1,208 @@
package io.v.nutz.activity.controller.union;
import cn.hutool.core.util.StrUtil;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.activity.models.ActivityYearSummary;
import io.v.nutz.activity.services.ActivityYearSummaryService;
import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.util.ShiroUtil;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.boot.starter.ftp.FtpService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author JyuHsin
* @Date 2022/6/29
* @Description
*/
@IocBean
@Ok("json:full")
@At("/platform/activity/yearSummary")
public class ActivityUnionYearSummaryController {
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Inject
private BaseService baseService;
@Inject
private FtpService ftpService;
@Inject
private Vi vi;
@Inject
private ActivityYearSummaryService activityYearSummaryService;
@At("/union")
@Ok("beetl:platform/activity/summary/union/unionSummary.html")
@RequiresPermissions("activityYear.union.summary")
public void unionIndex() {
}
@At("/addUnionSummary")
@Ok("beetl:platform/activity/summary/union/addSummary.html")
@RequiresPermissions("activityYear.union.addSummary")
public void addUnionSummary() {
}
@At("/club")
@Ok("beetl:platform/activity/summary/club/clubSummary.html")
@RequiresPermissions("activityYear.club.summary")
public void clubIndex() {
}
@At("/addClubSummary")
@Ok("beetl:platform/activity/summary/club/addSummary.html")
@RequiresPermissions("activityYear.club.addSummary")
public void addClubSummary() {
}
@At("/school")
@Ok("beetl:platform/activity/summary/school/schoolSummary.html")
@RequiresPermissions("activityYear.school.summary")
public void schoolIndex() {
}
@At("/addSchoolSummary")
@Ok("beetl:platform/activity/summary/school/addSummary.html")
@RequiresPermissions("activityYear.school.addSummary")
public void addSchoolSummary() {
}
@At
@ViReturn
@RequiresPermissions(value = {"activityYear.school.summary", "activityYear.union.summary", "activityYear.club.summary"}, logical = Logical.OR)
public Object pageData(@Param(value = "year") String year,
@Param(value = "tissueId")String tissueId,
@Param(value = "summaryType")String summaryType,
@Param(value = "pageSize")Integer pageSize,
@Param(value = "pageNumber")Integer pageNumber,
@Param(value = "summaryFrom")String summaryFrom) {
Cnd cnd = Cnd.NEW();
String str = "select " +
" su.*," +
" year(su.ctime) as `year`, " +
" dic.name as typename," +
" u.username ";
if ("2".equals(summaryFrom)) {
str += ",un.unionname as name";
}
if ("3".equals(summaryFrom)) {
str += ",club.name as name";
}
str += " from activity_summary su ";
str += " left join `user` u on su.userId = u.id";
if ("2".equals(summaryFrom)) {
str += " left join sys_union un on su.tissueId = un.id";
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
cnd.and("su.tissueId", "=", Vi.getUnionId());
}
}
if ("3".equals(summaryFrom)) {
str += " left join sys_club club on su.tissueId = club.id";
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "A06"})) {
cnd.and("su.tissueId", "=", vi.getClubId());
}
}
str += " left join sys_dict dic on su.summaryType = dic.id ";
str += " $condition";
Sql sql = Sqls.create(str);
if (StrUtil.isNotBlank(year)) {
cnd.and("year(su.ctime)", "=", year);
}
if (StrUtil.isNotBlank(tissueId)) {
cnd.and("su.tissueId", "=", tissueId);
}
if (StrUtil.isNotBlank(summaryType)) {
cnd.and("su.summaryType", "=", summaryType);
}
if (StrUtil.isNotBlank(summaryFrom)) {
cnd.and("su.summaryFrom", "=", summaryFrom);
}
sql.setCondition(cnd);
return activityYearSummaryService.listPageMap(pageNumber, pageSize, sql);
}
@At
@Ok("json")
@RequiresPermissions(value = {"activityYear.school.addSummary", "activityYear.union.addSummary", "activityYear.club.addSummary"}, logical = Logical.OR)
public Object doHandle(@Param("..") ActivityYearSummary activityYearSummary) {
try {
if (activityYearSummary.getId() == null) {
activityYearSummary.setCtime(SIMPLE_DATE_FORMAT.format(new Date()));
activityYearSummaryService.insert(activityYearSummary);
} else {
activityYearSummaryService.updateIgnoreNull(activityYearSummary);
}
return Result.success().addMsg("上传成功!");
} catch (Exception e) {
e.printStackTrace();
return Result.error().addMsg("上传失败!");
}
}
@At
@ViReturn
@RequiresPermissions(value = {"activityYear.school.summary", "activityYear.union.summary", "activityYear.club.summary"}, logical = Logical.OR)
public Object findOne(String id) {
Sql sql = Sqls.create("""
select su.*,u.username,u.loginname from
activity_summary su
left join
`user` u on su.userId = u.id
$condition
""");
sql.setCondition(Cnd.NEW().and("su.id", "=", id));
return activityYearSummaryService.fetch(sql);
}
@At
@ViReturn
@RequiresPermissions(value = {"activityYear.school.summary", "activityYear.union.summary", "activityYear.club.summary"}, logical = Logical.OR)
public Object doDelete(String id) {
ActivityYearSummary summary = activityYearSummaryService.fetch(id);
List<NutMap> files = summary.getFiles();
for (NutMap file : files) {
Record filedata = baseService.dao().fetch("sys_file", Cnd.where("id", "=", id));
if (filedata != null) {
baseService.clear("sys_file", Cnd.where("id", "=", file.getString("id")));
ftpService.delete(filedata.getString("filepath"));
}
}
activityYearSummaryService.delete(id);
return Result.success();
}
@At
public Object getMyClub() {
Sql sql = Sqls.create("""
SELECT sur.stid FROM sys_user_role sur
$condition
""");
sql.setCondition(Cnd.NEW().and("sur.userId", "=", ShiroUtil.getPrincipalProperty("id")).and("sur.roleId", "=", Roles.CLUB_FZR));
List<Record> list = baseService.list(sql);
List<String> stids = list.stream().map(x -> x.getString("stid")).collect(Collectors.toList());
return stids;
}
}
@@ -0,0 +1,28 @@
package io.v.nutz.activity.models;
import io.v.nutz.annontation.SelectEnum;
@SelectEnum
public enum ActivityAuditTypeEnum {
ALL("ALL", "不限制"),
CLUB("CLUB", "审核本协会"),
DW("DW", "审核本单位"),
FGH("FGH", "审核本分工会");
public String value;
public String desc;
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
private ActivityAuditTypeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
}
@@ -0,0 +1,63 @@
package io.v.nutz.activity.models;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
import java.util.List;
/**
* @author zhf
* @date 2021/2/23 15:36
* @description 活动基础设置
*/
@Data
@Table("activity_basic_settings")
public class ActivityBasicSettings extends BaseModel implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("父级ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String parentId;
@Column
@Comment("代码")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String code;
@Column
@Comment("名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String name;
@Column
@Comment("备注")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String note;
@Column
@Comment("有子节点")
private boolean hasChildren;
@Column
@Comment("排序字段")
@Prev({
@SQL(db = DB.MYSQL, value = "SELECT IFNULL(MAX(location),0)+1 FROM activity_basic_settings"),
@SQL(db = DB.ORACLE, value = "SELECT COALESCE(MAX(location),0)+1 FROM activity_basic_settings")
})
private Integer location;
private List<ActivityBasicSettings> child;
}
@@ -0,0 +1,32 @@
package io.v.nutz.activity.models;
import io.v.nutz.sys.models.Sys_union;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
/**
* TODO
*
* @Author zhf
* @Date 2022/7/28 13:49
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Table
public class ActivityBasicUnion extends Sys_union {
@Column
@Name
@Comment("工会id")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true, nullEffective = true)
private String id;
@Column
@Comment("添加来源")
@ColDefine(type = ColType.VARCHAR, width = 20)
private String source;
}
@@ -0,0 +1,133 @@
package io.v.nutz.activity.models;
import io.v.nutz.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.io.Serializable;
import java.util.List;
/**
* TODO
*
* @Author zhf
* @Date 2022/7/28 10:57
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table
@TableIndexes({@Index(name = "INDEX_SYS_UNIT_PATH", fields = {"path"}, unique = true),
@Index(name = "INDEX_SYS_UNIT_UNITCODE", fields = {"unitcode"}, unique = true),
@Index(name = "INDEX_SYS_UNION", fields = {"unionid"}, unique = false),
})
public class ActivityBasicUnit extends BaseModel implements Serializable {
private static final long serialVersionUID = 1L;
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(els = {@EL("uuid()")})
private String id;
@Column
@Comment("父级ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String parentId;
@Column
@Comment("树路径")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String path;
@Column
@Comment("单位名称")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String name;
@Column
@Comment("单位别名")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String aliasName;
@Column
@Comment("机构编码")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unitcode;
@Column
@Comment("单位介绍")
@ColDefine(type = ColType.VARCHAR, width = 255)
private String note;
@Column
@Comment("单位地址")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String address;
@Column
@Comment("联系电话")
@ColDefine(type = ColType.VARCHAR, width = 20)
private String telephone;
@Column
@Comment("单位邮箱")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String email;
@Column
@Comment("单位网站")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String website;
@Column
@Comment("排序字段")
@Prev({
@SQL(db = DB.MYSQL, value = "SELECT IFNULL(MAX(location),0)+1 FROM sys_unit"),
@SQL(db = DB.ORACLE, value = "SELECT COALESCE(MAX(location),0)+1 FROM sys_unit")
})
private Integer location;
@Column
@Comment("有子节点")
private boolean hasChildren;
@Column
@Comment("单位logo")
@ColDefine(type = ColType.VARCHAR, width = 255)
private String logo;
@Column
@Comment("单位级别")
@ColDefine(type = ColType.INT, width = 3)
private int unitlevel;
@Column
@Comment("工会id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionid;
@Column
@Comment("所属校区")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String xqid;
@Column
@Comment("所属类别id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String classid;
@Column
@Comment("福利单位id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String welfareUnitId;
private List<ActivityBasicUnit> child;
}
@@ -0,0 +1,90 @@
package io.v.nutz.activity.models;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
/**
* @author zhf
* @date 2021/2/24 14:29
* @description 比赛组别
*/
@Data
@Table("activity_event")
public class ActivityEvent extends BaseModel implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("比赛组别")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String competitionCategory;
@Column
@Comment("距离")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String distance;
@Column
@Comment("运动项目")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String sports;
@Column
@Comment("项目类型")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String projectType;
@Column
@Comment("比赛项目编号")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String projectCode;
@Column
@Comment("男女分组")
@ColDefine(type = ColType.INT, width = 50)
private Integer isMenWomen;
@Column
@Comment("是否趣味")
@ColDefine(type = ColType.BOOLEAN)
private boolean isInterest;
@Column
@Comment("属于那个运动类型")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String exerciseType;
@Column
@Comment("项目全名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String allName;
@Column
@Comment("开始时间")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String startAgeDate;
@Column
@Comment("结束时间")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String endAgeDate;
@Column
@Comment("是否启用")
@ColDefine(type = ColType.BOOLEAN)
private Boolean whetherEnable;
@Column
@Comment("备注")
@ColDefine(type = ColType.TEXT)
private String note;
}
@@ -0,0 +1,28 @@
package io.v.nutz.activity.models;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import lombok.experimental.Accessors;
public interface ActivityImport {
@Data
@Accessors(chain = true)
class applyUser {
@Excel(name = "工会", width = 20d)
private String unionName;
@Excel(name = "工号", width = 20d)
private String loginName;
@Excel(name = "姓名", width = 20d)
private String userName;
@Excel(name = "性别", width = 20d)
private String sex;
@Excel(name = "项目编号", width = 20d)
private String projectCode;
@Excel(name = "身份", width = 20d)
private String identity;
}
}
@@ -0,0 +1,68 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
/**
* @author: Aaron
* @create: 2021-03-01 14:29
* @description: 活动计划
**/
@Data
@Table("activity_plan")
public class ActivityPlan {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("计划名称")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String name;
@Column
@Comment("计划时间")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String time;
@Column
@Comment("项目数组")
@ColDefine(type = ColType.VARCHAR, width = 500)
private String event;
@Column
@Comment("项目id")
@ColDefine(type = ColType.VARCHAR, width = 500)
private String eventId;
@Column
@Comment("计划内容")
@ColDefine(type = ColType.TEXT)
private String content;
@Column
@Comment("预算费用")
@ColDefine(type = ColType.FLOAT)
private Double money;
@Column
@Comment("计划类型(1-校活动、2-分工会活动、3协会社团活动)")
@ColDefine(type = ColType.VARCHAR, width = 7)
private String type;
@Column
@Comment("分工会ID或社团ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String tissueId;
@Column
@Comment("活动类型")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityType;
}
@@ -0,0 +1,75 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
/**
* @author zhf
* @date 2021/5/19 14:43
* @description 运动会成绩
*/
@Data
@Table("activity_results")
public class ActivityResults implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
/**
* 单项活动使用
*/
@Column
@Comment("用户id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userId;
@Column
@Comment("用户男女")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String sex;
@Column
@Comment("对应的活动")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityId;
@Column
@Comment("对应的项目")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String eventId;
@Column
@Comment("名次")
@ColDefine(type = ColType.INT, width = 2)
private Integer ranking;
@Column
@Comment("工会id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionId;
@Column
@Comment("人数")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String numberOfPeople;
@Column
@Comment("积分")
@ColDefine(type = ColType.FLOAT, width = 5)
private double integral;
@Column
@Comment("个人1团队2")
@ColDefine(type = ColType.INT, width = 2)
private Integer isTeamPersonal;
}
@@ -0,0 +1,195 @@
package io.v.nutz.activity.models;
import cn.wizzer.framework.base.model.BaseModel;
import io.v.nutz.sys.models.Sys_file;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
import java.util.List;
/**
* @author: Aaron
* @create: 2021-02-22 11:31
* @description: 校级活动
*/
@Data
@Table("activity_school")
public class ActivitySchool extends BaseModel implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("关联计划")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String planId;
@Column
@Comment("活动名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String name;
@Column
@Comment("活动地址")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String address;
@Column
@Comment("关联活动类型")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String typeId;
@Column
@Comment("活动编号")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String activityCode;
@Column
@Comment("报名开始时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String applyStartTime;
@Column
@Comment("报名结束时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String applyEndTime;
@Column
@Comment("活动开始时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String startTime;
@Column
@Comment("活动结束时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String endTime;
@Column
@Comment("关联主办单位")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> unitSponsor;
@Column
@Comment("关联承办单位")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> undertakeUnit;
@Column
@Comment("关联协办单位")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> unitJointly;
@Column
@Comment("活动项目")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> eventsIds;
@Column
@Comment("活动方式(1:竞赛 2:非竞赛)")
@ColDefine(type = ColType.INT, width = 2)
private Integer gameStyle;
@Column
@Comment("活动类型(2:综合类活动 1:单一活动)")
@ColDefine(type = ColType.INT, width = 2)
private Integer applyType;
@Column
@Comment("可报名范围组别")
@ColDefine(type = ColType.VARCHAR, width = 32)
private Integer activityGroupId;
@Column
@Comment("经费预算")
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
private Double funding;
@Column
@Comment("报名方式(1:个人 2:分工会 3:小程序)")
@ColDefine(type = ColType.MYSQL_JSON)
private List<Integer> applyWay;
@Column
@Comment("报名人员类型(1:会员 2:普通教职工)")
@ColDefine(type = ColType.INT, width = 2)
private Integer personType;
@Column
@Comment("运动员资格(竞赛)")
@ColDefine(type = ColType.TEXT)
private String athleteQualification;
@Column
@Comment("报名方法(竞赛)")
@ColDefine(type = ColType.TEXT)
private String registrationMethod;
@Column
@Comment("竞赛方法(竞赛)")
@ColDefine(type = ColType.TEXT)
private String competitionMethod;
@Column
@Comment("奖励方法(竞赛)")
@ColDefine(type = ColType.TEXT)
private String rewardMethod;
@Column
@Comment("注意事项(竞赛)")
@ColDefine(type = ColType.TEXT)
private String precautions;
@Column
@Comment("活动通知(非竞赛)")
@ColDefine(type = ColType.TEXT)
private String eventNotification;
@Column
@Comment("是否关闭")
@ColDefine(type = ColType.BOOLEAN)
private Boolean close;
@Column
@Comment("活动级别(40001-校级、40002-分工会、40003-社团或协会)")
@ColDefine(type = ColType.INT, width = 10)
private Integer activityLevel;
@Column
@Comment("是否保存")
@ColDefine(type = ColType.BOOLEAN)
private Integer isSave;
@Column
@Comment("小程序活动封面")
@ColDefine(type = ColType.MYSQL_JSON)
private List<Sys_file> image;
@Many(field = "activityId")
private List<ActivitySchoolEvent> schoolEvents;
@Column
@Comment("活动所属工会")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String belongUnionId;
@Column
@Comment("活动所属社团")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String belongClubId;
@Column
@Comment("创建时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String foundDate;
@Column
@Comment("是否发送系统消息")
@ColDefine(type = ColType.BOOLEAN)
private Boolean xlFlag;
}
@@ -0,0 +1,196 @@
package io.v.nutz.activity.models;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
import java.util.List;
/**
* @author: Aaron
* @create: 2021-02-22 11:31
* @description: 校活动报名
*/
@Data
@Table("activity_school_apply")
@TableIndexes({
@Index(name = "ASA_ACTIVITY", fields = {"activityId"}, unique = false),
@Index(name = "ASA_UNIT", fields = {"unitId"}, unique = false),
@Index(name = "ASA_UNION", fields = {"unionId"}, unique = false),
@Index(name = "ASA_USER", fields = {"userId"}, unique = false),
@Index(name = "ASA_APPLYUSER", fields = {"userId"}, unique = false),
})
public class ActivitySchoolApply implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("对应的活动")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityId;
@Column
@Comment("对应的项目")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String eventId;
@Column
@Comment("对应的是单项还是团体(1是个人2是团体)")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String awardsMode;
@Column
@Comment("所属队")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String teamId;
@Column
@Comment("所属单位")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unitId;
@Column
@Comment("所属工会")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionId;
@Column
@Comment("所属活动工会")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityUnionId;
@Column
@Comment("所属活动工会名称")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityUnionName;
@Column
@Comment("报名人")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String applyUser;
@Column
@Comment("参加人")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userId;
@Column
@Comment("报名时间")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String applyDate;
@Column
@Comment("身份(1 运动员 2 教练 3 领队4 处级领导5 替补6 团长7工作人员)")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> identity;
@Column
@Comment("是否处级领导")
@ColDefine(type = ColType.BOOLEAN)
private Boolean divisionLevelLeadership;
@Column
@Comment("是否兼运动员")
@ColDefine(type = ColType.BOOLEAN)
private Boolean isAthlete;
@Column
@Comment("是否为工会总领队")
@ColDefine(type = ColType.BOOLEAN)
private Boolean unionLeader;
@Column
@Comment("是否为工会总教练")
@ColDefine(type = ColType.BOOLEAN)
private Boolean unionCoach;
@Column
@Comment("是否为工会团长")
@ColDefine(type = ColType.BOOLEAN)
private Boolean unionHead;
@Column
@Comment("是否为工会工作人员")
@ColDefine(type = ColType.BOOLEAN)
private Boolean unionStaff;
@Column
@Comment("状态(0 保存 1 待审核 2 报名成功 3 审核不通过)")
private Integer status;
@Column
@Comment("单位名称")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String unitname;
@Excel(name = "分工会", width = 30)
private String unionname;
@Column
@Comment("小队名称")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String team;
/* @Excel(name = "项目名称", width = 40)
private String allName;*/
@Excel(name = "项目名称", width = 70)
private String allNames;
private String identitys;
@Column
@Comment("工号")
@Excel(name = "工号", width = 20)
@ColDefine(type = ColType.VARCHAR, width = 50)
private String loginname;
@Column
@Comment("姓名")
@Excel(name = "姓名", width = 20)
@ColDefine(type = ColType.VARCHAR, width = 50)
private String username;
@Column
@Comment("电话")
@Excel(name = "手机号码", width = 20)
@ColDefine(type = ColType.VARCHAR, width = 50)
private String mobile;
@Excel(name = "身份证号", width = 20)
private String idCard;
@Column
@Comment("性别")
@Excel(name = "性别", width = 20)
@ColDefine(type = ColType.VARCHAR, width = 50)
private String sex;
@Column
@Comment("出生年月")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String birthday;
private int age;
private String userState;
@Excel(name = "身份", width = 40)
private String sf;
}
@@ -0,0 +1,148 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* @author: Aaron
* @create: 2021-04-06 10:05
* @description: 校级活动活动项目关联表
**/
@Data
@Table("Activity_school_event")
public class ActivitySchoolEvent {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("活动ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityId;
@Column
@Comment("项目ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String eventId;
@Column
@Comment("比赛模式(1:单项 2:团队)")
@ColDefine(type = ColType.MYSQL_JSON)
private Integer awardsMode;
@Column
@Comment("组合方式(1:单项报名人数 2:团体报名人数)")
@ColDefine(type = ColType.MYSQL_JSON)
private List<Integer> combinationMethod;
@Column
@Comment("组合方式1:最多人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer restrictTotalPeople;
@Column
@Comment("组合方式1:报名方式(1-单人、2-双人)")
@ColDefine(type = ColType.INT, width = 2)
private Integer registrationWays;
@Column
@Comment("组合方式2:最少人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer restrictMinNum;
@Column
@Comment("组合方式2:最多人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer restrictMaxNum;
@Column
@Comment("组合方式2:最大队数")
@ColDefine(type = ColType.INT, width = 8)
private Integer restrictTotalTeam;
@Column
@Comment("组合方式2:运动员最多人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer athletesMaxNum;
@Column
@Comment("组合方式2:运动员最少人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer athletesMinNum;
@Column
@Comment("组合方式2:领队人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer leanderNum;
@Column
@Comment("组合方式2:教练人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer coachNum;
@Column
@Comment("组合方式2:女队人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer restrictGirlNum;
@Column
@Comment("组合方式2:男队人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer restrictBoyNum;
@Column
@Comment("组合方式2:副处长(级)以上至少人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer deputyDirectorNum;
@Column
@Comment("组合方式2:替补人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer substituteNum;
@Column
@Comment("每人限报项目数")
@ColDefine(type = ColType.INT, width = 2)
private Integer restrictRegNumber;
@Column
@Comment("开始年龄")
@ColDefine(type = ColType.VARCHAR,width = 10)
private String startAgeDate;
@Column
@Comment("截至年龄")
@ColDefine(type = ColType.VARCHAR, width = 10)
private String endAgeDate;
@Column
@Comment("是否只报领队")
@ColDefine(type = ColType.BOOLEAN)
private boolean isLeader;
@Column
@Comment("每对运动员男女不做限制")
@ColDefine(type = ColType.BOOLEAN)
private boolean isManGirlNum;
@One(field = "activityId", key = "id")
private ActivitySchool activitySchool;
@Column
@Comment("分工会人数限制")
@ColDefine(type = ColType.MYSQL_JSON)
private List<NutMap> unionLimit;
@Column
@Comment("报名人数限制模式")
@ColDefine(type = ColType.INT)
private Integer applyUserModel;
}
@@ -0,0 +1,61 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;
import java.io.Serializable;
/**
* @author: Aaron
* @create: 2021-02-22 11:31
* @description: 校活动 队
*/
@Data
@Table("activity_school_team")
@TableIndexes({
@Index(name = "AST_ACTIVITY", fields = {"activityId"}, unique = false),
})
public class ActivitySchoolTeam implements Serializable {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("对应的活动")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityId;
@Column
@Comment("项目ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String eventId;
@Column
@Comment("队名")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String name;
@Column
@Comment("最少人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer minNum;
@Column
@Comment("最多人数")
@ColDefine(type = ColType.INT, width = 8)
private Integer maxNum;
@Column
@Comment("排序")
@Prev({
@SQL(db = DB.MYSQL, value = "SELECT IFNULL(MAX(location),0)+1 FROM Activity_School_Team"),
@SQL(db = DB.ORACLE, value = "SELECT COALESCE(MAX(location),0)+1 FROM Activity_School_Team")
})
private Integer location;
}
@@ -0,0 +1,89 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import java.util.List;
/**
* @author: Aaron
* @create: 2020-12-13 09:31
* @description: 活动场地信息
**/
@Data
@Table("activity_site_info")
public class ActivitySiteInfo {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("场地名称")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String name;
@Column
@Comment("场地地址")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String address;
@Column
@Comment("联系人")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String contact_person;
@Column
@Comment("联系电话")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String contact_phone;
@Column
@Comment("开启状态")
@ColDefine(type = ColType.BOOLEAN)
private Boolean state;
@Column
@Comment("开放时段")
@ColDefine(type = ColType.MYSQL_JSON)
private List open_hours;
@Column
@Comment("关闭时段")
@ColDefine(type = ColType.MYSQL_JSON)
private List close_dates;
@Column
@Comment("创建人")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String create_username;
@Column
@Comment("创建时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String create_time;
@Column
@Comment("活动类型")
@ColDefine(type = ColType.INT)
private Integer typeId;
@Column
@Comment("是否多次预约")
@ColDefine(type = ColType.BOOLEAN)
private Boolean multiple;
@Column
@Comment("限定工作日预约")
@ColDefine(type = ColType.BOOLEAN)
private Boolean workday;
@Column
@Comment("限制男女,0表示不限制,1表示限制男,2表示限制女")
@ColDefine(type = ColType.INT)
private Integer sexLimit;
}
@@ -0,0 +1,125 @@
package io.v.nutz.activity.models;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* @author: Aaron
* @create: 2020-12-13 14:19
* @description: 活动场地预约信息
**/
@Data
@Table("activity_site_reserve")
public class ActivitySiteReserve extends BaseModel {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("场地id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String site_id;
@Column
@Comment("预约人")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String reserve_person;
@Column
@Comment("预约人ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String reserve_person_id;
@Column
@Comment("预约人单位")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String reserve_person_unit;
@Column
@Comment("预约人联系方式")
@ColDefine(type = ColType.VARCHAR, width = 20)
private String reserve_person_phone;
@Column
@Comment("预约事由")
@ColDefine(type = ColType.VARCHAR, width = 1000)
private String reserve_cause;
@Column
@Comment("预约状态id")
@ColDefine(type = ColType.INT, width = 4)
private Integer reserve_state;
@Column
@Comment("预约日期(天)")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String reserve_day;
@Column
@Comment("预约开始时间")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String start_time;
@Column
@Comment("预约结束时间")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String end_time;
@Column
@Comment("场地管理员id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String site_manager_id;
@Column
@Comment("场地管理员审核时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String site_manager_time;
@Column
@Comment("场地管理员退回理由")
@ColDefine(type = ColType.VARCHAR, width = 500)
private String back_out_opinion;
@Column
@Comment("主席审核人id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String chairman_review_person;
@Column
@Comment("主席审核时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String chairman_review_time;
@Column
@Comment("主席审核意见")
@ColDefine(type = ColType.VARCHAR, width = 500)
private String chairman_review_opinion;
@Column
@Comment("审核记录")
@ColDefine(type = ColType.VARCHAR, width = 500)
private List<NutMap> auditList;
@Column
@Comment("反馈意见")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String back_option;
@Column
@Comment("申请id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String sqid;
@Column
@Comment("参与人员")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String joinUser;
}
@@ -0,0 +1,226 @@
package io.v.nutz.activity.models;
import io.v.nutz.common.models.Goods;
import io.v.nutz.sys.models.Sys_file;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* @author: Aaron
* @create: 2021-03-09 13:57
* @description: 社团或分工会活动校工会活动
**/
@Data
@Table("activity_tissue")
public class ActivityTissue {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("创建人")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userId;
@Column
@Comment("联系方式")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String mobile;
@Column
@Comment("举办单位")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String helpUnitIds;
@Column
@Comment("协办单位")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> unitId;
@Column
@Comment("活动名称")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String name;
@Column
@Comment("活动编号")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String activityCode;
@Column
@Comment("活动项目类型")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String projectTypeCode;
@Column
@Comment("活动计划开始时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String startPlannedDate;
@Column
@Comment("活动计划结束时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String endPlannedDate;
@Column
@Comment("报名开始时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String applyStartTime;
@Column
@Comment("报名结束时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String applyEndTime;
@Column
@Comment("活动开始时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String startTime;
@Column
@Comment("活动结束时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String endTime;
@Column
@Comment("创建时间")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String applyTime;
@Column
@Comment("活动人数")
@ColDefine(type = ColType.INT, width = 6)
private Integer peopleNum;
@Column
@Comment("活动地点")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String address;
@Column
@Comment("发票")
@ColDefine(type = ColType.MYSQL_JSON)
private List<Sys_file> billFiles;
@Column
@Comment("照片")
@ColDefine(type = ColType.MYSQL_JSON)
private List<Sys_file> photoFiles;
@Column
@Comment("其他")
@ColDefine(type = ColType.MYSQL_JSON)
private List<Sys_file> otherFiles;
@Column
@Comment("活动类型")
@ColDefine(type = ColType.INT, width = 10)
private Integer type;
@Column
@Comment("创建人所属工会")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unionId;
@Column
@Comment("创建人所属社团")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String clubId;
@Column
@Comment("活动内容")
@ColDefine(type = ColType.TEXT)
private String activityContent;
@Column
@Comment("活动考核内容")
@ColDefine(type = ColType.TEXT)
private String activityExamineContent;
@Column
@Comment("报名方式(1.个人 2.分工会 null.不需要报名)")
@ColDefine(type = ColType.INT)
private Integer signUpMethod;
@Column
@Comment("限制方式(1.总人数限制 2.分工会人数限制 null.不限制)")
@ColDefine(type = ColType.INT)
private Integer userNumberLimit;
@Column
@Comment("是否需要签到")
@ColDefine(type = ColType.BOOLEAN)
private boolean needSign;
@Column
@Comment("签到经纬度")
@ColDefine(type = ColType.MYSQL_JSON)
private List<String> location;
@Column
@Comment("签到范围")
@ColDefine(type = ColType.INT)
private Integer rangeMeter;
@Column
@Comment("总人数限制")
@ColDefine(type = ColType.INT)
private Integer totalUserNumberLimit;
@Column
@Comment("组队人数")
@ColDefine(type = ColType.INT)
private Integer teamNum;
@Column
@Comment("分工会人数限制")
@ColDefine(type = ColType.MYSQL_JSON)
private List<NutMap> unionUserNumberLimit;
@Column
@Comment("活动总结")
@ColDefine(type = ColType.TEXT)
private String activitySummary;
@Column
@Comment("活动分组id")
@ColDefine(type = ColType.INT)
private Integer groupId;
@Column
@Comment("封面图")
@ColDefine(type = ColType.VARCHAR)
private String cover;
@Column
@Comment("审核状态")
@ColDefine(type = ColType.INT)
private Integer state;
@Column
@Comment("审核id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String auditId;
@Column
@Comment("是否报名系统")
@ColDefine(type = ColType.BOOLEAN)
private boolean isEnrollSystem;
@Many(field = "tissueId")
private List<ActivityTissuePerson> tissuePersonList;
@Many(field = "reid")
private List<Goods> goods;
@Column
@Comment("是否发送系统消息")
@ColDefine(type = ColType.BOOLEAN)
private Boolean xlFlag;
}
@@ -0,0 +1,93 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
/**
* @author: Aaron
* @create: 2021-03-09 14:02
* @description: 活动人员列表
**/
@Data
@Table("activity_tissue_person")
public class ActivityTissuePerson {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("分工会或社团活动ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String tissueId;
@Column
@Comment("用户ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userId;
@Column
@Comment("报名人ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String applyUserId;
@Column
@Comment("报名人姓名")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String applyUserUserName;
@Column
@Comment("签字ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String signId;
@Column
@Comment("用户姓名")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String userName;
@Column
@Comment("用户工号")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String loginName;
@Column
@Comment("用户性别")
@ColDefine(type = ColType.VARCHAR, width = 2)
private String sex;
@Column
@Comment("用户手机号")
@ColDefine(type = ColType.VARCHAR, width = 20)
private String mobile;
@Column
@Comment("用户单位")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unitName;
@Column
@Comment("用户工会")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String unionName;
@Column
@Comment("是否签到")
@ColDefine(type = ColType.BOOLEAN)
private boolean isSign;
@Column
@Comment("签到时间")
@ColDefine(type = ColType.VARCHAR, width = 20)
private String signTime;
@Column
@Comment("报名时间")
@ColDefine(type = ColType.VARCHAR, width = 20)
private String applyDateTime;
}
@@ -0,0 +1,38 @@
package io.v.nutz.activity.models;
import io.v.nutz.modules.models.AuditState;
import lombok.Data;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import java.util.List;
@Table
@Data
@Accessors(chain = true)
public class ActivityType {
@Id
@Comment("ID")
@ColDefine(type = ColType.INT)
private Integer id;
@Column
@Comment("名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String meetingTypeName;
@Column
@Comment("模块名称")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String moduleName;
@Column
@Comment("排序")
@ColDefine(type = ColType.INT)
private int sortNum;
@Many(field = "meetingTypeId")
private List<AuditState> auditStateList;
}
@@ -0,0 +1,37 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
/**
* TODO
*
* @Author zhf
* @Date 2022/7/29 14:12
*/
@Data
@Table
public class ActivityUnion {
@Column
@Name
@Comment("工会id")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true, nullEffective = true)
private String id;
@Column
@Comment("工会名称")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String unionname;
@Column
@Comment("活动id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityId;
}
@@ -0,0 +1,76 @@
package io.v.nutz.activity.models;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.v.nutz.data.constant.ConditionalOperational;
import io.v.nutz.data.constant.MatchMethod;
import lombok.Data;
import org.nutz.dao.Cnd;
import org.nutz.dao.util.cri.SqlExpression;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.json.Json;
import org.nutz.lang.Lang;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Data
public class ActivityUserCnd {
private MatchMethod matchMethod;
private List<Rule> rules;
/**
* sql格式
*
* @param userTablePrefix 用户表前缀
* @param activityUserCndStr 活动用户cnd str
* @param reverseSelection 逆向选择
* @return {@link SqlExpressionGroup}
* @throws Exception 异常
*/
public static SqlExpressionGroup formatSql(String userTablePrefix, String activityUserCndStr, boolean reverseSelection) throws Exception {
SqlExpressionGroup seg = new SqlExpressionGroup();
if (StrUtil.isBlank(activityUserCndStr)) {
return seg;
}
String prefix = StrUtil.blankToDefault(userTablePrefix, "user");
ActivityUserCnd activityUserCnd = Json.fromJson(ActivityUserCnd.class, activityUserCndStr);
if (activityUserCnd.getMatchMethod() != null && Lang.isNotEmpty(activityUserCnd.getRules())) {
List<Rule> filterRules = activityUserCnd.getRules().stream().filter(v -> StrUtil.isAllNotBlank(v.getName(), v.getCnd())).collect(Collectors.toList());
ConditionalOperational[] conditionalOperationals = ConditionalOperational.values();
Map<String, ConditionalOperational> conditionalOperationalMap = Arrays.stream(conditionalOperationals).collect(Collectors.toMap(v -> v.getValue(), v -> v));
for (Rule rule : filterRules) {
ConditionalOperational conditionalOperational = conditionalOperationalMap.get(rule.getCnd());
conditionalOperational.exec(seg, prefix + "." + rule.getName(), rule.getValue(), activityUserCnd.getMatchMethod());
}
}
if (reverseSelection) {
List<SqlExpression> exps = seg.getExps();
for (SqlExpression exp : exps) {
exp.setNot(true);
}
}
return seg;
}
@Data
public static class Rule {
private String name;
private String cnd;
private String value;
}
}
@@ -0,0 +1,51 @@
package io.v.nutz.activity.models;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.nutz.dao.entity.annotation.*;
import java.io.Serial;
import java.io.Serializable;
/**
* @author zxy
* @Description 活动人员范围设置
* @createTime 2022年01月04日 11:36:00
*/
@Table
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ActivityUserScope extends BaseModel implements Serializable {
@Serial
private static final long serialVersionUID = -5794884307112120554L;
@Id
@Comment("id")
private Integer id;
@Column
@ColDefine
@Comment("groupId")
private Integer groupId;
@Column
@ColDefine(type = ColType.VARCHAR)
@Comment("name")
private String groupName;
@Column
@ColDefine(type = ColType.VARCHAR, width = 32)
@Comment("userid")
private String userId;
@Column
@ColDefine(type = ColType.VARCHAR, width = 32)
@Comment("创建人")
private String creator;
}
@@ -0,0 +1,54 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* @Author JyuHsin
* @Date 2022/6/29
* @Description
*/
@Data
@Table("activity_summary")
public class ActivityYearSummary {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("提交人")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userId;
@Column
@Comment("提交时间")
@ColDefine(type = ColType.VARCHAR, width = 50)
private String ctime;
@Column
@Comment("工会/协会id")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String tissueId;
@Column
@Comment("总结类型")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String summaryType;
@Column
@Comment("总结来源(1-校活动、2-分工会活动、3协会社团活动)")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String summaryFrom;
@Column
@Comment("文件")
@ColDefine(type = ColType.MYSQL_JSON)
private List<NutMap> files;
}
@@ -0,0 +1,66 @@
package io.v.nutz.activity.models;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
/**
* @author zhf
* @date 2021/4/10 15:26
* @description
*/
@Data
@Table("school_assign_grades")
public class SchoolAssignGrades {
@Column
@Name
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@Prev(els = {@EL("uuid()")})
private String id;
@Column
@Comment("对应的活动")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String activityId;
@Column
@Comment("单项活动才有userid")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String userId;
@Column
@Comment("对应的项目")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String eventId;
@Column
@Comment("所属单位")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String unitId;
@Column
@Comment("荣誉奖项")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String mc;
@Column
@Comment("奖品名称")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String jpmc;
@Column
@Comment("金额")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String money;
@Column
@Comment("奖品类型")
@ColDefine(type = ColType.VARCHAR, width = 30)
private String jplx;
}
@@ -0,0 +1,24 @@
package io.v.nutz.activity.services;
import io.v.nutz.activity.models.ActivityUserScope;
import io.v.nutz.service.ViService;
import org.nutz.dao.Cnd;
import org.nutz.dao.sql.Sql;
import java.util.List;
/**
* @author zxy
* @Description TODO
* @createTime 2022年01月06日 09:02:00
*/
public interface ActivityBasicScopeService extends ViService<ActivityUserScope> {
Sql createSql(Cnd cnd);
/**
* 大量数据插入
*/
void largeDataInsert(List<ActivityUserScope> list) ;
}
@@ -0,0 +1,65 @@
package io.v.nutz.activity.services;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* 会议通用方法
*/
@IocBean
public interface ActivityCommonService {
/**
* 根据typeId查询所属模块名称
*
* @param typeId
* @return
*/
String findModuleNameByTypeId(Integer typeId);
/**
* 根据MeetId查询所属模块名称
*
* @param meetingId
* @return
*/
String findModuleNameByActivityId(String meetingId);
/**
* 根据模块名称查找对应stateCode 最开始的那个
*
* @param moduleName
* @return
*/
Integer findStartStateCodeByModuleName(String moduleName);
Integer findAfterStateCode(Integer stateCode, boolean isPass);
Integer findAfterStateCodeByModuleName(Integer stateCode, String moduleName);
/**
* 根据会议id查询请假成功的code
*
* @param meetingId
* @return
*/
Integer findSuccessStateCode(String meetingId);
/**
* 获取当前用户关联哪些会议
*
* @return
*/
Object find();
/**
* 查询当前登录用户能审核的状态Id
*
* @return
*/
List<Integer> findStateIdForMeCanAudit();
List<NutMap> getNextAuditUser(Integer stateCode, String moduleName);
}
@@ -0,0 +1,35 @@
package io.v.nutz.activity.services;
import io.v.nutz.activity.models.ActivityPlan;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
/**
* @author: Aaron
* @create: 2021-03-09 10:27
* @description:
**/
public interface ActivityPlanService extends ViService<ActivityPlan> {
/**
* 首页数据
*
* @param page
* @param year
* @param name
* @param tissueId
* @param cnd
* @return
*/
Object pageData(PageForm page, String year, String name, String tissueId, CndPlus cnd);
/**
* 根据id查询单个
*
* @param id
* @return
*/
Object findOne(String id);
}
@@ -0,0 +1,18 @@
package io.v.nutz.activity.services;
import io.v.nutz.activity.models.ActivitySchoolApply;
import io.v.nutz.service.ViService;
import java.util.List;
/**
* @author Aaron
*/
public interface ActivitySchoolApplyService extends ViService<ActivitySchoolApply> {
void doApplies(List<ActivitySchoolApply> applies);
void doApplies(String activity, String union_id, String eventId,List<ActivitySchoolApply> applies);
void doApply(ActivitySchoolApply apply);
}
@@ -0,0 +1,18 @@
package io.v.nutz.activity.services;
import io.v.nutz.activity.models.ActivitySchool;
import io.v.nutz.activity.models.ActivitySchoolEvent;
import io.v.nutz.service.ViService;
/**
* @author Aaron
*/
public interface ActivitySchoolService extends ViService<ActivitySchool> {
String doAdd(ActivitySchool activitySchool, ActivitySchoolEvent[] events);
void doEdit(ActivitySchool activitySchool, ActivitySchoolEvent[] events, String applyEndTime);
void doDelete(String id);
}
@@ -0,0 +1,12 @@
package io.v.nutz.activity.services;
import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.activity.models.ActivitySchoolTeam;
/**
* @author Aaron
*/
public interface ActivitySchoolTeamService extends BaseService<ActivitySchoolTeam> {
}
@@ -0,0 +1,47 @@
package io.v.nutz.activity.services;
import io.v.nutz.activity.models.ActivityTissue;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
/**
* @author: Aaron
* @create: 2021-03-09 10:27
* @description:
**/
public interface ActivityTissueService extends ViService<ActivityTissue> {
/**
* 首页数据
*
* @param page
* @param year
* @param name
* @param unionId
* @return
*/
Object pageData(PageForm page, String year, String name, String unionId,Integer type);
/**
* 删除
*
* @param id
*/
void doDelete(String id);
/**
* 编辑
*
* @param tissue
*/
void doEdit(ActivityTissue tissue);
/**
* 根据id查询单个
*
* @param id
* @return
*/
Object findOne(String id);
}
@@ -0,0 +1,24 @@
package io.v.nutz.activity.services;
import io.v.nutz.activity.models.ActivityType;
import io.v.nutz.service.ViService;
/**
* 会议类型 流程 service
*/
public interface ActivityTypeService extends ViService<ActivityType> {
/**
* 找出最大的那行stateId
*
* @return
*/
int findMaxStateId();
void add(ActivityType activityType);
void edit(ActivityType activityType);
void delete(ActivityType activityType);
}
@@ -0,0 +1,12 @@
package io.v.nutz.activity.services;
import io.v.nutz.activity.models.ActivityYearSummary;
import io.v.nutz.service.ViService;
/**
* @Author JyuHsin
* @Date 2022/6/29
* @Description
*/
public interface ActivityYearSummaryService extends ViService<ActivityYearSummary> {
}
@@ -0,0 +1,25 @@
package io.v.nutz.activity.services;
import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.activity.models.ActivitySiteInfo;
public interface SiteInfoService extends BaseService<ActivitySiteInfo> {
/**
* 判断指定预约日期是否落在场地关闭时段内。
*
* @param siteInfo 场地信息
* @param reserveDay 预约日期,格式为 yyyy-MM-dd
* @return true 表示该日期不可预约
*/
boolean isInCloseDates(ActivitySiteInfo siteInfo, String reserveDay);
/**
* 获取场地关闭时段的预约提示文案。
*
* @param siteInfo 场地信息
* @return 关闭时段提示文案
*/
String getCloseDateMessage(ActivitySiteInfo siteInfo);
}
@@ -0,0 +1,8 @@
package io.v.nutz.activity.services;
import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.activity.models.ActivitySiteReserve;
public interface SiteReserveService extends BaseService<ActivitySiteReserve> {
}
@@ -0,0 +1,82 @@
package io.v.nutz.activity.services.impl;
import cn.hutool.core.collection.CollectionUtil;
import io.v.nutz.activity.models.ActivityUserScope;
import io.v.nutz.activity.services.ActivityBasicScopeService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.service.impl.ViServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.impl.NutTxDao;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.IocBean;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author zxy
* @Description TODO
* @createTime 2022年01月06日 09:03:00
*/
@IocBean(args = {"refer:dao"})
@Slf4j
public class ActivityBasicScopeServiceImpl extends ViServiceImpl<ActivityUserScope> implements ActivityBasicScopeService {
public ActivityBasicScopeServiceImpl(Dao dao) {
super(dao);
}
@Override
public Sql createSql(Cnd cnd) {
return null;
}
/**
* 大量数据插入
* 注:Future.get()可以同步等待线程执行完成,并且可以监听执行结果
* 你也可以用countDownLatch
*/
@Override
public void largeDataInsert(List<ActivityUserScope> list) {
log.info("开始时间" + DateUtil.getDateTime());
List<List<ActivityUserScope>> splitList = CollectionUtil.split(list, 500);
NutTxDao nutTxDao = new NutTxDao(dao()).setDebug(true);
nutTxDao.beginRC();
ExecutorService executorService = Executors.newWorkStealingPool();
List<Callable<Object>> taskList = new ArrayList<>();
for (List<ActivityUserScope> everyList : splitList) {
taskList.add(() -> nutTxDao.insert(everyList).size());
}
List<Future<Object>> futureList = null;
AtomicInteger atomicInteger = new AtomicInteger();
try {
futureList = executorService.invokeAll(taskList);
for (Future<Object> future : futureList) {
atomicInteger.getAndAdd((Integer) future.get());
}
if (atomicInteger.get() != list.size()) {
throw new RuntimeException("插入数据与期望数据条数不符");
}
nutTxDao.commit();
} catch (Exception e) {
nutTxDao.rollback();
throw new RuntimeException(e);
} finally {
executorService.shutdown();
}
log.info("结束时间" + DateUtil.getDateTime());
}
}
@@ -0,0 +1,130 @@
package io.v.nutz.activity.services.impl;
import io.v.nutz.activity.models.ActivitySiteInfo;
import io.v.nutz.activity.models.ActivityType;
import io.v.nutz.activity.services.ActivityCommonService;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.constant.AuditTypeEnum;
import io.v.nutz.modules.models.AuditState;
import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.util.ShiroUtil;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@IocBean(args = {"refer:dao"})
public class ActivityCommonServiceImpl extends ViServiceImpl implements ActivityCommonService {
@Inject
private Vi vi;
public ActivityCommonServiceImpl(Dao dao) {
super(dao);
}
@Override
public String findModuleNameByTypeId(Integer typeId) {
ActivityType activityType = dao().fetch(ActivityType.class, Cnd.where("id", "=", typeId));
if (Lang.isNotEmpty(activityType)) {
return activityType.getModuleName();
}
return null;
}
@Override
public String findModuleNameByActivityId(String activityId) {
ActivitySiteInfo activitySiteInfo = dao().fetch(ActivitySiteInfo.class, activityId);
if (Lang.isNotEmpty(activitySiteInfo) && null != activitySiteInfo.getTypeId()) {
return findModuleNameByTypeId(activitySiteInfo.getTypeId());
}
return null;
}
@Override
public Integer findStartStateCodeByModuleName(String moduleName) {
List<AuditState> auditStateList = dao().query(AuditState.class, Cnd.where("module", "=", moduleName).asc("stateId"));
Optional<Integer> minOptional = auditStateList.stream().map(v -> v.getStateId()).min(Comparator.comparingInt(a -> a)).stream().findFirst();
return minOptional.orElse(null);
}
@Override
public Integer findAfterStateCode(Integer stateCode, boolean isPass) {
AuditState auditState = dao().fetch(AuditState.class, stateCode);
return isPass ? auditState.getAfterPassStateId() : auditState.getAfterRejectStateId();
}
@Override
public Integer findSuccessStateCode(String meetingId) {
String moduleName = findModuleNameByActivityId(meetingId);
Cnd cnd = Cnd.where("module", "=", moduleName).and("stateAuditType", "=", AuditTypeEnum.PROCESS_PASS.getValue());
AuditState auditState = dao().fetch(AuditState.class, cnd);
return auditState.getStateId();
}
@Override
public Integer findAfterStateCodeByModuleName(Integer stateCode, String moduleName) {
AuditState auditState = dao().fetch(AuditState.class, Cnd.where("stateId", "=", stateCode));
if (Lang.isNotEmpty(auditState)) {
return auditState.getAfterStateId();
}
return null;
}
@Override
public Object find() {
List<ActivityType> typeList = dao().query(ActivityType.class, null);
List<String> typeModuleNameList = typeList.stream().map(ActivityType::getModuleName).collect(Collectors.toList());
List<AuditState> auditStateList = dao().query(AuditState.class, Cnd.where("module", "in", typeModuleNameList));
for (AuditState state : auditStateList) {
dao().fetchLinks(state, "auditStateUserList");
}
return null;
}
@Override
public List<Integer> findStateIdForMeCanAudit() {
Cnd cnd = Cnd.NEW();
cnd.and("stateId", "in", Sqls.create("select stateId from audit_state_user where userId = @userid").setParam("userid", ShiroUtil.getPrincipalProperty("id")));
List<AuditState> auditStateList = dao().query(AuditState.class, cnd);
return auditStateList.stream().map(v -> v.getStateId()).collect(Collectors.toList());
}
/*根据状态码获取下一节点审核人*/
@Override
public List<NutMap> getNextAuditUser(Integer stateCode, String moduleName) {
Sql sql = Sqls.create("""
select
au.userId as userId,
u.username as userName,
u.loginname as loginName,
u.unitname as unitName,
u.mobile as mobile
from
audit_state_user au
left join
`user` u on au.userid = u.id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("stateId", "=", stateCode);
sql.setCondition(cnd);
return listMap(sql);
}
}
@@ -0,0 +1,84 @@
package io.v.nutz.activity.services.impl;
import io.v.nutz.activity.models.ActivityPlan;
import io.v.nutz.activity.services.ActivityPlanService;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.util.ShiroUtil;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
/**
* @author: Aaron
* @create: 2021-03-09 10:29
* @description:
**/
@IocBean(args = {"refer:dao"})
public class ActivityPlanServiceImpl extends ViServiceImpl<ActivityPlan> implements ActivityPlanService {
public ActivityPlanServiceImpl(Dao dao) {
super(dao);
}
@Inject
private Vi vi;
@Override
public Object pageData(PageForm page, String year, String name, String tissueId, CndPlus cnd) {
Sql sql = Sqls.create("""
SELECT
ap.*,
ab.name as activityTypeName,
year(ap.time) as `year`,
(SELECT GROUP_CONCAT(ev.allName) from activity_event ev WHERE JSON_CONTAINS(ap.`event`, CONCAT('"',ev.id,'"'))) allName,
((SELECT COUNT(1) FROM activity_school acs WHERE acs.planId = ap.id) >0 ) carryOut
FROM
activity_plan ap
left join activity_basic_settings ab on ab.id = ap.activityType
$condition
""");
cnd.andExcludeEmpty("YEAR(ap.time)", "=", year);
cnd.andExcludeEmpty("ap.tissueId", "=", tissueId);
if (Strings.isNotBlank(name)) {
cnd.where().andLike("ap.name", name);
}
if (!ShiroUtil.hasAnyRoles("sysadmin,H10,A06")) {
if (ShiroUtil.hasRole("H04")) {
cnd.and("tissueId", "in", vi.getMangeUnionStr());
} else if (ShiroUtil.hasRole("H02")) {
cnd.and("tissueId", "in", vi.getMangeClubStr());
}
}
cnd.desc("ap.time");
sql.setCondition(cnd);
return this.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@Override
public Object findOne(String id) {
Sql sql = Sqls.create("""
SELECT
ap.*,
(SELECT GROUP_CONCAT(ev.allName) from activity_event ev WHERE JSON_CONTAINS(ap.`event`, CONCAT('"',ev.id,'"'))) allName
FROM
activity_plan ap
WHERE
ap.id = @id
""").setParam("id", id);
return this.listMap(sql).get(0);
}
}
@@ -0,0 +1,44 @@
package io.v.nutz.activity.services.impl;
import io.v.nutz.activity.models.ActivitySchoolApply;
import io.v.nutz.activity.services.ActivitySchoolApplyService;
import io.v.nutz.service.impl.ViServiceImpl;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.IocBean;
import java.util.List;
@IocBean(args = {"refer:dao"})
public class ActivitySchoolApplyServiceImpl extends ViServiceImpl<ActivitySchoolApply> implements ActivitySchoolApplyService {
public ActivitySchoolApplyServiceImpl(Dao dao) {
super(dao);
}
@Aop(TransAop.READ_COMMITTED)
public void doApplies(List<ActivitySchoolApply> applies) {
/*for (ActivitySchoolApply apply : applies) {
insert(apply);
}*/
dao().insert(applies);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doApplies(String activity, String union_id, String eventId, List<ActivitySchoolApply> applies) {
clear(Cnd.where("activityId", "=", activity).and("activityUnionId", "=", union_id).and("eventId", "=", eventId));
doApplies(applies);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doApply(ActivitySchoolApply apply) {
insert(apply);
}
}
@@ -0,0 +1,135 @@
package io.v.nutz.activity.services.impl;
import io.v.nutz.activity.models.*;
import io.v.nutz.activity.services.ActivitySchoolApplyService;
import io.v.nutz.activity.services.ActivitySchoolService;
import io.v.nutz.activity.services.ActivitySchoolTeamService;
import io.v.nutz.base.utils.DateUtil;
import io.v.nutz.service.ViService;
import io.v.nutz.service.impl.ViServiceImpl;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author: Aaron
* @create: 2021-02-22 15:50
* @description: 活动信息管理 service
**/
@IocBean(args = {"refer:dao"})
public class ActivitySchoolServiceImpl extends ViServiceImpl<ActivitySchool> implements ActivitySchoolService {
public ActivitySchoolServiceImpl(Dao dao) {
super(dao);
}
@Inject
private ActivitySchoolTeamService activitySchoolTeamService;
@Inject
private ActivitySchoolApplyService activitySchoolApplyService;
@Inject("ActivitySchoolEvent")
private ViService<ActivitySchoolEvent> activitySchoolEventService;
@Inject("ActivitySchoolEvent")
private ViService<ActivitySchoolEvent> activitySchoolEventViService;
@Override
@Aop(TransAop.READ_COMMITTED)
public String doAdd(ActivitySchool activitySchool, ActivitySchoolEvent[] events) {
activitySchool.setClose(false);
ActivitySchool school = insert(activitySchool);
addTeam(school.getId(), events);
return school.getId();
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doEdit(ActivitySchool activitySchool, ActivitySchoolEvent[] events, String applyEndTime) {
long time = DateUtil.formatDate(applyEndTime);
long l = System.currentTimeMillis();
if (l < time) {
/* activitySchoolApplyService.clear(Cnd.where("activityId", "=", activitySchool.getId()));
activitySchoolEventService.clear(Cnd.where("activityId", "=", activitySchool.getId()));
activitySchoolTeamService.clear(Cnd.where("activityId", "=", activitySchool.getId()));
addTeam(activitySchool.getId(), events);*/
}
update(activitySchool);
List<ActivitySchoolEvent> query = activitySchoolEventViService.query(Cnd.where("activityId", "=", activitySchool.getId()));
List<ActivitySchoolEvent> collect = query.stream().filter(v -> {
return !activitySchool.getEventsIds().contains(v.getEventId());
}).collect(Collectors.toList());
List<ActivitySchoolEvent> collect1 = Lang.array2list(events).stream().filter(v -> {
return !query.stream().map(x -> x.getEventId()).collect(Collectors.toList()).contains(v.getEventId()) && (v.getId() == null || !v.getId().equals("allItems"));
}).collect(Collectors.toList());
if (collect.size() > 0) {
collect.forEach(v -> {
activitySchoolApplyService.clear(Cnd.where("activityId", "=", activitySchool.getId()).and("eventId", "=", v.getEventId()));
activitySchoolEventService.clear(Cnd.where("activityId", "=", activitySchool.getId()).and("eventId", "=", v.getEventId()));
activitySchoolTeamService.clear(Cnd.where("activityId", "=", activitySchool.getId()).and("eventId", "=", v.getEventId()));
});
}
if (collect1.size() > 0) {
addTeam(activitySchool.getId(), collect1.toArray(new ActivitySchoolEvent[collect1.size()]));
}
for (ActivitySchoolEvent event : events) {
update(event);
}
/* activitySchoolTeamService.clear(Cnd.where("activityId", "=", activitySchool.getId()));
addTeam(activitySchool.getId(), events);*/
}
@Aop(TransAop.READ_COMMITTED)
private void addTeam(String schoolId, ActivitySchoolEvent[] events) {
if (events.length > 0) {
Arrays.stream(events).forEach(v -> {
v.setActivityId(schoolId);
activitySchoolEventService.insert(v);
Integer totalTeam = v.getRestrictTotalTeam();
if (totalTeam != null && totalTeam > 0) {
for (int i = 1; i <= totalTeam; i++) {
ActivitySchoolTeam team = new ActivitySchoolTeam();
team.setActivityId(schoolId);
team.setEventId(v.getEventId());
team.setName(String.format("第%d队", i));
team.setMinNum(v.getRestrictMinNum());
team.setMaxNum(v.getRestrictMaxNum());
activitySchoolTeamService.insert(team);
}
}
});
}
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doDelete(String id) {
activitySchoolApplyService.clear(Cnd.where("activityId", "=", id));
activitySchoolEventService.clear(Cnd.where("activityId", "=", id));
activitySchoolTeamService.clear(Cnd.where("activityId", "=", id));
activitySchoolEventService.dao().clear(ActivityTissue.class, Cnd.where("id", "=", id));
dao().clear(ActivityUnion.class, Cnd.where("activityId", "=", id));
this.delete(id);
}
}
@@ -0,0 +1,18 @@
package io.v.nutz.activity.services.impl;
import cn.wizzer.framework.base.service.BaseServiceImpl;
import io.v.nutz.activity.models.ActivitySchoolTeam;
import io.v.nutz.activity.services.ActivitySchoolTeamService;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
@IocBean(args = {"refer:dao"})
public class ActivitySchoolTeamServiceImpl extends BaseServiceImpl<ActivitySchoolTeam> implements ActivitySchoolTeamService {
public ActivitySchoolTeamServiceImpl(Dao dao) {
super(dao);
}
}
@@ -0,0 +1,177 @@
package io.v.nutz.activity.services.impl;
import cn.hutool.core.util.StrUtil;
import io.v.nutz.activity.models.ActivityTissue;
import io.v.nutz.activity.models.ActivityTissuePerson;
import io.v.nutz.activity.services.ActivityTissueService;
import io.v.nutz.base.utils.Vi;
import io.v.nutz.common.models.Goods;
import io.v.nutz.dao.CndPlus;
import io.v.nutz.jf.model.ActivityBx;
import io.v.nutz.modules.models.PageForm;
import io.v.nutz.service.ViService;
import io.v.nutz.service.impl.ViServiceImpl;
import io.v.nutz.util.ShiroUtil;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.lang.util.NutMap;
import java.util.List;
/**
* @author: Aaron
* @create: 2021-03-09 10:29
* @description:
**/
@IocBean(args = {"refer:dao"})
public class ActivityTissueServiceImpl extends ViServiceImpl<ActivityTissue> implements ActivityTissueService {
public ActivityTissueServiceImpl(Dao dao) {
super(dao);
}
@Inject
private Vi vi;
@Inject("ActivityTissuePerson")
private ViService<ActivityTissuePerson> tissuePersonService;
@Override
public Object pageData(PageForm page, String year, String name, String unionId, Integer type) {
CndPlus cnd = CndPlus.create();
Sql sql = Sqls.create("""
SELECT
tissue.*,
uni.unionname ,
club.`name` clubName,
abs.`name` projectTypeName
FROM
activity_tissue tissue
LEFT JOIN sys_union uni ON uni.id = tissue.unionId
LEFT JOIN sys_club club ON club.id = tissue.clubId
LEFT JOIN activity_basic_settings abs ON abs.`code`=tissue.projectTypeCode
$condition
""");
cnd.andExcludeEmpty("YEAR(tissue.startTime)", "=", year);
cnd.andExcludeEmpty("tissue.unionId", "=", unionId);
cnd.andExcludeEmpty("tissue.type", "=", type);
if (Strings.isNotBlank(name)) {
cnd.where().andLike("tissue.name", name);
}
if (!ShiroUtil.hasAnyRoles("sysadmin,H10,A06")) {
if (ShiroUtil.hasRole("H04")) {
cnd.and("tissue.unionId", "in", vi.getMangeUnionStr());
} else if (ShiroUtil.hasRole("H02")) {
cnd.and("tissue.clubId", "in", vi.getMangeClubStr());
}
}
if (StrUtil.isNotBlank(page.getPageOrderName()) && StrUtil.isNotBlank(page.getPageOrderBy())) {
cnd.orderBy(page.getPageOrderName(), page.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC");
} else {
cnd.desc("tissue.startTime");
}
sql.setCondition(cnd);
return this.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doDelete(String id) {
this.delete(id);
tissuePersonService.clear(Cnd.where("tissueId", "=", id));
tissuePersonService.dao().clear(Goods.class, Cnd.where("reid", "=", id));
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void doEdit(ActivityTissue tissue) {
tissuePersonService.clear(Cnd.where("tissueId", "=", tissue.getId()));
tissuePersonService.dao().clear(Goods.class, Cnd.where("reid", "=", tissue.getId()));
if (tissue.getSignUpMethod() == null) {
tissue.setUserNumberLimit(null);
tissue.setTotalUserNumberLimit(null);
tissue.setUnionUserNumberLimit(null);
}
if (tissue.getUserNumberLimit() == null) {
tissue.setTotalUserNumberLimit(null);
tissue.setUnionUserNumberLimit(null);
} else if (tissue.getUserNumberLimit() == 1) {
tissue.setUnionUserNumberLimit(null);
} else if (tissue.getUserNumberLimit() == 2) {
tissue.setTotalUserNumberLimit(null);
}
this.update(tissue);
List<ActivityTissuePerson> tissuePersonList = tissue.getTissuePersonList();
tissuePersonList.forEach(v -> {
v.setTissueId(tissue.getId());
});
tissuePersonService.insert(tissuePersonList);
tissue.getGoods().forEach(v -> {
v.setActivityCode(tissue.getActivityCode());
v.setReid(tissue.getId());
});
tissuePersonService.dao().insert(tissue.getGoods());
if (tissue.getBillFiles() != null) {
tissuePersonService.dao().update(ActivityBx.class, Chain.make("billFiles", tissue.getBillFiles()),
Cnd.where("activity_id", "=", tissue.getId()));
}
if (tissue.getOtherFiles() != null) {
tissuePersonService.dao().update(ActivityBx.class, Chain.make("otherFiles", tissue.getOtherFiles()),
Cnd.where("activity_id", "=", tissue.getId()));
}
if (tissue.getPhotoFiles() != null) {
tissuePersonService.dao().update(ActivityBx.class, Chain.make("photoFiles", tissue.getPhotoFiles()),
Cnd.where("activity_id", "=", tissue.getId()));
}
}
@Override
public Object findOne(String id) {
Sql sql = Sqls.create("""
SELECT
tissue.*,
uni.unionname,
club.`name` clubName,
u.username,
u.loginname,
abs.`name` projectTypeName
FROM
activity_tissue tissue
LEFT JOIN sys_union uni ON uni.id = tissue.unionId
LEFT JOIN sys_club club ON club.id = tissue.clubId
LEFT JOIN `user` u ON u.id=tissue.userId
LEFT JOIN activity_basic_settings abs ON abs.`code`=tissue.projectTypeCode
WHERE
tissue.id = @id
""").setParam("id", id);
NutMap nutMap = this.fetch(sql);
List<ActivityTissuePerson> personList = tissuePersonService.query(Cnd.where("tissueId", "=", nutMap.getString("id")));
List<Goods> goodsList = tissuePersonService.dao().query(Goods.class, Cnd.where("reid", "=", nutMap.getString("id")));
nutMap.setv("tissuePersonList", personList);
nutMap.setv("goods", goodsList);
return nutMap;
}
}
@@ -0,0 +1,103 @@
package io.v.nutz.activity.services.impl;
import io.v.nutz.activity.models.ActivityType;
import io.v.nutz.activity.services.ActivityCommonService;
import io.v.nutz.activity.services.ActivityTypeService;
import io.v.nutz.modules.models.AuditState;
import io.v.nutz.modules.models.AuditStateUser;
import io.v.nutz.service.impl.ViServiceImpl;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import java.util.List;
@IocBean(args = {"refer:dao"})
public class ActivityTypeServiceImpl extends ViServiceImpl<ActivityType> implements ActivityTypeService {
@Inject
private ActivityCommonService activityCommonService;
public ActivityTypeServiceImpl(Dao dao) {
super(dao);
}
@Override
public int findMaxStateId() {
return dao().func(AuditState.class, "max", "stateId");
}
/**
* 根据模块名称查找stateId
*
* @param moduleName
* @return
*/
private String[] findStateIdArray(String moduleName) {
//查询该类型原来关联的stateId
Sql stateSql = Sqls.create("select stateId from audit_state where module = @moduleName").setParam("moduleName", moduleName);
return (String[]) Daos.query(dao(), stateSql.toString(), Sqls.callback.strs());
}
/**
* 添加流程信息
*
* @param activityType
*/
private void insertAuditInfo(ActivityType activityType) {
List<AuditState> auditStateList = activityType.getAuditStateList();
if (Lang.isNotEmpty(auditStateList)) {
for (int i = 0; i < auditStateList.size(); i++) {
AuditState state = auditStateList.get(i);
state.setModule(activityType.getModuleName());
state.setMeetingTypeId(activityType.getId());
dao().insertWith(state, "^auditStateUserList$");
}
}
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void add(ActivityType activityType) {
dao().insert(activityType);
insertAuditInfo(activityType);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void edit(ActivityType activityType) {
dao().update(activityType);
//查询该类型原来关联的stateId
String[] stateIdStr = findStateIdArray(activityType.getModuleName());
//删除原来审核状态下的审核人员
dao().clear(AuditStateUser.class, Cnd.where("stateId", "in", stateIdStr));
//删除原来的审核状态
dao().clear(AuditState.class, Cnd.where("stateId", "in", stateIdStr));
//添加新的审核流程
insertAuditInfo(activityType);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public void delete(ActivityType activityType) {
//查询该类型原来关联的stateId
String[] stateIdStr = findStateIdArray(activityType.getModuleName());
//删除原来审核状态下的审核人员
dao().clear(AuditStateUser.class, Cnd.where("stateId", "in", stateIdStr));
//删除原来的审核状态
dao().clear(AuditState.class, Cnd.where("stateId", "in", stateIdStr));
dao().delete(activityType);
}
}
@@ -0,0 +1,19 @@
package io.v.nutz.activity.services.impl;
import io.v.nutz.activity.models.ActivityYearSummary;
import io.v.nutz.activity.services.ActivityYearSummaryService;
import io.v.nutz.service.impl.ViServiceImpl;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
/**
* @Author JyuHsin
* @Date 2022/6/29
* @Description
*/
@IocBean(args = {"refer:dao"})
public class ActivityYearSummaryServiceImpl extends ViServiceImpl<ActivityYearSummary> implements ActivityYearSummaryService {
public ActivityYearSummaryServiceImpl(Dao dao) {
super(dao);
}
}
@@ -0,0 +1,76 @@
package io.v.nutz.activity.services.impl;
import cn.wizzer.framework.base.service.BaseServiceImpl;
import io.v.nutz.activity.models.ActivitySiteInfo;
import io.v.nutz.activity.services.SiteInfoService;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* @author: Aaron
* @create: 2020-12-13 09:38
* @description:
**/
@IocBean(args = {"refer:dao"})
public class SiteInfoServiceImpl extends BaseServiceImpl<ActivitySiteInfo> implements SiteInfoService {
public SiteInfoServiceImpl(Dao dao) {
super(dao);
}
@Override
public boolean isInCloseDates(ActivitySiteInfo siteInfo, String reserveDay) {
List closeDates = getCloseDates(siteInfo);
if (closeDates.size() < 2 || Strings.isBlank(reserveDay)) {
return false;
}
String start = closeDates.get(0).toString();
String end = closeDates.get(1).toString();
if (start.compareTo(end) > 0) {
String temp = start;
start = end;
end = temp;
}
// 关闭时段按日期闭区间处理,开始日期和结束日期当天都不能预约。
return reserveDay.compareTo(start) >= 0 && reserveDay.compareTo(end) <= 0;
}
@Override
public String getCloseDateMessage(ActivitySiteInfo siteInfo) {
List closeDates = getCloseDates(siteInfo);
if (closeDates.size() < 2) {
return "抱歉,该场地当前时段不能预约。";
}
String start = closeDates.get(0).toString();
String end = closeDates.get(1).toString();
if (start.compareTo(end) > 0) {
String temp = start;
start = end;
end = temp;
}
return "抱歉,该场地" + formatDateText(start) + "" + formatDateText(end) + "不能预约。";
}
private List getCloseDates(ActivitySiteInfo siteInfo) {
if (siteInfo == null || siteInfo.getClose_dates() == null) {
return List.of();
}
return siteInfo.getClose_dates();
}
private String formatDateText(String dateText) {
try {
LocalDate date = LocalDate.parse(dateText, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
return date.getMonthValue() + "" + date.getDayOfMonth() + "";
} catch (Exception e) {
return dateText;
}
}
}
@@ -0,0 +1,20 @@
package io.v.nutz.activity.services.impl;
import cn.wizzer.framework.base.service.BaseServiceImpl;
import io.v.nutz.activity.models.ActivitySiteReserve;
import io.v.nutz.activity.services.SiteReserveService;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
/**
* @author: Aaron
* @create: 2020-12-13 14:32
* @description:
**/
@IocBean(args = {"refer:dao"})
public class SiteReserveServiceImpl extends BaseServiceImpl<ActivitySiteReserve> implements SiteReserveService {
public SiteReserveServiceImpl(Dao dao) {
super(dao);
}
}
@@ -0,0 +1,18 @@
package io.v.nutz.activity.template;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
@Data
public class UserTemp {
@Excel(name = "工号")
private String loginname;
@Excel(name = "姓名")
private String username;
@Excel(name = "备注")
private String remarks;
}
@@ -0,0 +1,21 @@
package io.v.nutz.base.constant;
/**
* @author wizzer@qq.com
*/
public class RedisConstant {
public final static String PLATFORM_REDIS_PREFIX = "budwk5mini:";
public final static String PLATFORM_REDIS_WKCACHE_PREFIX = PLATFORM_REDIS_PREFIX + "wkcache:";
public final static String REDIS_KEY_WSROOM = PLATFORM_REDIS_PREFIX + "wsroom:";
public final static String REDIS_KEY_LOGIN_ADMIN_CAPTCHA = PLATFORM_REDIS_PREFIX + "admin:login:captcha:";
public final static String REDIS_KEY_ADMIN_PUBSUB = PLATFORM_REDIS_PREFIX + "admin:pubsub:";
public final static String REDIS_KEY_WX_TOKEN = PLATFORM_REDIS_PREFIX + "wx:token:";
public final static String REDIS_CAPTCHA_KEY = PLATFORM_REDIS_PREFIX + "platfrom:captcha:";
public final static String REDIS_SMSCODE_KEY = PLATFORM_REDIS_PREFIX + "platfrom:smscode:";
public final static String REDIS_KEY_API_SIGN_DEPLOY_NONCE = PLATFORM_REDIS_PREFIX + "api:sign:deploy:nonce:";
public final static String REDIS_KEY_API_SIGN_OPEN_NONCE = PLATFORM_REDIS_PREFIX + "api:sign:open:nonce:";
//健步走小程序TOKEN
public final static String REDIS_KEY_WE_APP_ACCESS_TOKEN = "weapp:token:";
}
@@ -0,0 +1,35 @@
package io.v.nutz.base.field;
import com.google.common.base.Joiner;
import org.nutz.dao.FieldFilter;
/**
* Todo
*
* @author : 1V
* @date : 2021-03-25
* @since :
*/
public interface FieldFilterUtil {
/**
* 创建
*
* @param type type
* @param fields fields
* @return FieldFilter
*/
static FieldFilter create(Class<?> type, Iterable<String> fields) {
return create(type, String.format("^%s$", Joiner.on("|").join(fields)));
}
/**
* 创建
*
* @param type type
* @param regex regex
* @return FieldFilter
*/
static FieldFilter create(Class<?> type, String regex) {
return FieldFilter.create(type, regex);
}
}
@@ -0,0 +1,18 @@
package io.v.nutz.base.field;
import io.v.nutz.sys.models.User;
import org.nutz.dao.FieldFilter;
/**
* Todo
*
* @author : 1V
* @date : 2021-03-25
* @since :
*/
public interface UserField {
FieldFilter NAME = FieldFilter.create(User.class, "^username$");
FieldFilter SIMPLE = FieldFilter.create(User.class, "^loginname|username|sex|mobile|unitname|unionname$");
}
@@ -0,0 +1,97 @@
package io.v.nutz.base.model;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import org.nutz.dao.interceptor.annotation.PrevUpdate;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings;
import org.nutz.mvc.Mvcs;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
/**
* Created by wizzer on 2016/6/21.
*/
@Data
public abstract class BaseModel implements Serializable {
private static final long serialVersionUID = 1L;
@Column
@Comment("创建人")
@PrevInsert(els = @EL("$me.createdByUid()"))
@ColDefine(type = ColType.VARCHAR, width = 32)
private String createdBy;
/**
* Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
* 13位时间戳哦,不再是11位
*/
@Column
@Comment("创建时间")
@PrevInsert(now = true)
private Long createdAt;
@Column
@Comment("修改人")
@PrevInsert(els = @EL("$me.updatedByUid()"))
@PrevUpdate(els = @EL("$me.updatedByUid()"))
@ColDefine(type = ColType.VARCHAR, width = 32)
private String updatedBy;
/**
* Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
* 13位时间戳哦,不再是11位
*/
@Column
@Comment("修改时间")
@PrevInsert(now = true)
@PrevUpdate(now = true)
private Long updatedAt;
@Column
@Comment("删除标记")
@PrevInsert(els = @EL("$me.flag()"))
@ColDefine(type = ColType.BOOLEAN)
private Boolean delFlag;
public String toJsonString() {
return Json.toJson(this, JsonFormat.compact());
}
public Boolean flag() {
return false;
}
public String createdByUid() {
String uid = getCreatedBy();
if (Strings.isNotBlank(uid)) {
return uid;
}
try {
HttpServletRequest request = Mvcs.getReq();
if (request != null) {
return Strings.sNull(request.getSession(true).getAttribute("platform_uid"));
}
} catch (Exception e) {
}
return "";
}
public String updatedByUid() {
String uid = getUpdatedBy();
if (Strings.isNotBlank(uid)) {
return uid;
}
try {
HttpServletRequest request = Mvcs.getReq();
if (request != null) {
return Strings.sNull(request.getSession(true).getAttribute("platform_uid"));
}
} catch (Exception e) {
}
return "";
}
}
@@ -0,0 +1,46 @@
package io.v.nutz.base.page;
import org.nutz.dao.pager.Pager;
import java.io.Serializable;
/**
* 指定偏移量及大小的Pager, 这样就不会受限于原生Pager的offset=(pageNumber-1)*pageSize
*
* @author wendal
*/
public class OffsetPager extends Pager implements Serializable {
private static final long serialVersionUID = -1385308131663113162L;
protected int offset = -1;
protected OffsetPager() {
}
/**
* 构建一个指定偏移量及大小的Pager
*
* @param offset 偏移量
* @param size 数据大小
*/
public OffsetPager(int offset, int size) {
super();
this.offset = offset;
setPageSize(size);
}
/**
* 覆盖超类的计算得到的offset
*/
public int getOffset() {
if (offset > -1)
return offset;
return super.getOffset();
}
public void setOffset(int offset) {
this.offset = offset;
}
}
@@ -0,0 +1,57 @@
package io.v.nutz.base.page;
public interface Paginable {
/**
* 总记录数
*
* @return
*/
public int getTotalCount();
/**
* 总页数
*
* @return
*/
public int getTotalPage();
/**
* 每页记录数
*
* @return
*/
public int getPageSize();
/**
* 当前页号
*
* @return
*/
public int getPageNo();
/**
* 是否第一页
*
* @return
*/
public boolean isFirstPage();
/**
* 是否最后一页
*
* @return
*/
public boolean isLastPage();
/**
* 返回下页的页号
*/
public int getNextPage();
/**
* 返回上页的页号
*/
public int getPrePage();
}
@@ -0,0 +1,78 @@
package io.v.nutz.base.page;
import org.nutz.lang.Lang;
import java.util.List;
public class Pagination extends SimplePage implements java.io.Serializable {
private static final long serialVersionUID = 1L;
public Pagination() {
}
/**
* 构造器
*
* @param pageNo 页码
* @param pageSize 每页几条数据
* @param totalCount 总共几条数据
*/
public Pagination(int pageNo, int pageSize, int totalCount) {
super(pageNo, pageSize, totalCount);
}
/**
* 构造器
*
* @param pageNo 页码
* @param pageSize 每页几条数据
* @param totalCount 总共几条数据
* @param list 分页内容
*/
public Pagination(int pageNo, int pageSize, int totalCount, List list) {
super(pageNo, pageSize, totalCount);
this.list = list;
}
/**
* 第一条数据位置
*
* @return
*/
public int getFirstResult() {
return (pageNo - 1) * pageSize;
}
/**
* 当前页的数据
*/
private List list;
/**
* 获得分页内容
*
* @return
*/
public <T> List<T> getList() {
return list;
}
/**
* @param classOfT 列表容器內的元素类型
* @param <T> 列表容器內的元素类型
* @return
*/
public <T> List<T> getList(Class<T> classOfT) {
return Lang.collection2list(list, classOfT);
}
/**
* 设置分页内容
*
* @param list
*/
public void setList(List list) {
this.list = list;
}
}
@@ -0,0 +1,175 @@
package io.v.nutz.base.page;
import java.util.ArrayList;
import java.util.List;
public class SimplePage implements java.io.Serializable, Paginable {
private static final long serialVersionUID = 1L;
public static final int DEF_COUNT = 10;
private List<Integer> localArrayList = new ArrayList<Integer>();
public List<Integer> getSegment() {
return localArrayList;
}
/**
* 检查页码 checkPageNo
*
* @param pageNo
* @return if pageNo==null or pageNo 小于 1 then return 1 else return pageNo
*/
public static int cpn(Integer pageNo) {
return (pageNo == null || pageNo < 1) ? 1 : pageNo;
}
public SimplePage() {
}
/**
* 构造器
*
* @param pageNo 页码
* @param pageSize 每页几条数据
* @param totalCount 总共几条数据
*/
public SimplePage(int pageNo, int pageSize, int totalCount) {
setTotalCount(totalCount);
setPageSize(pageSize);
setPageNo(pageNo);
adjustPageNo();
int totalPages = getTotalPage();
minPage = minPage < 1 ? 1 : minPage;
maxPage = maxPage > totalPages ? totalPages : maxPage;
for (int i = minPage; i <= maxPage; i++) {
localArrayList.add(i);
}
}
/**
* 调整页码,使不超过最大页数
*/
public void adjustPageNo() {
if (pageNo == 1) {
return;
}
int tp = getTotalPage();
if (pageNo > tp) {
pageNo = tp;
}
}
/**
* 获得页码
*/
public int getPageNo() {
return pageNo;
}
/**
* 每页几条数据
*/
public int getPageSize() {
return pageSize;
}
/**
* 总共几条数据
*/
public int getTotalCount() {
return totalCount;
}
/**
* 总共几页
*/
public int getTotalPage() {
int totalPage = totalCount / pageSize;
if (totalPage == 0 || totalCount % pageSize != 0) {
totalPage++;
}
return totalPage;
}
/**
* 是否第一页
*/
public boolean isFirstPage() {
return pageNo <= 1;
}
/**
* 是否最后一页
*/
public boolean isLastPage() {
return pageNo >= getTotalPage();
}
/**
* 下一页页码
*/
public int getNextPage() {
if (isLastPage()) {
return pageNo;
} else {
return pageNo + 1;
}
}
/**
* 上一页页码
*/
public int getPrePage() {
if (isFirstPage()) {
return pageNo;
} else {
return pageNo - 1;
}
}
protected int totalCount = 0;
protected int pageSize = 20;
protected int pageNo = 1;
/**
* if totalCount 小于 0 then totalCount=0
*
* @param totalCount
*/
public void setTotalCount(int totalCount) {
if (totalCount < 0) {
this.totalCount = 0;
} else {
this.totalCount = totalCount;
}
}
/**
* if pageSize 小于 1 then pageSize=DEF_COUNT
*
* @param pageSize
*/
public void setPageSize(int pageSize) {
if (pageSize < 1) {
this.pageSize = DEF_COUNT;
} else {
this.pageSize = pageSize;
}
}
/**
* if pageNo 小于 1 then pageNo=1
*
* @param pageNo
*/
public void setPageNo(int pageNo) {
if (pageNo < 1) {
this.pageNo = 1;
} else {
this.pageNo = pageNo;
}
}
int minPage = pageNo - (int) Math.floor((pageSize - 1) / 2.0D);
int maxPage = pageNo + (int) Math.ceil((pageSize - 1) / 2.0D);
int totalPage = getTotalPage();
}
@@ -0,0 +1,47 @@
package io.v.nutz.base.page.datatable;
import java.io.Serializable;
/**
* Created by wizzer on 2016/6/27.
*/
public class DataTableColumn implements Serializable {
private static final long serialVersionUID = 1L;
protected String data;
protected String name;
protected boolean searchable;
protected boolean orderable;
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isSearchable() {
return searchable;
}
public void setSearchable(boolean searchable) {
this.searchable = searchable;
}
public boolean isOrderable() {
return orderable;
}
public void setOrderable(boolean orderable) {
this.orderable = orderable;
}
}
@@ -0,0 +1,29 @@
package io.v.nutz.base.page.datatable;
import java.io.Serializable;
/**
* Created by wizzer on 2016/6/27.
*/
public class DataTableOrder implements Serializable {
private static final long serialVersionUID = 1L;
protected int column;
protected String dir;
public int getColumn() {
return column;
}
public void setColumn(int column) {
this.column = column;
}
public String getDir() {
return dir;
}
public void setDir(String dir) {
this.dir = dir;
}
}
@@ -0,0 +1,109 @@
package io.v.nutz.base.result;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings;
import org.nutz.mvc.Mvcs;
import java.io.Serializable;
/**
* Created by wizzer on 2016/12/21.
*/
public class Result implements Serializable {
private static final long serialVersionUID = 1L;
private int code;
private String msg;
private Object data;
private long time;
public Result() {
this.time = System.currentTimeMillis();
}
public static Result NEW() {
return new Result();
}
public Result addCode(int code) {
this.code = code;
return this;
}
public Result addMsg(String msg) {
if (Strings.isBlank(msg) || Mvcs.getActionContext() == null || Mvcs.getActionContext().getRequest() == null || Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg) == null) {
this.msg = Strings.sNull(msg);
} else {
this.msg = Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg);
}
return this;
}
public Result addData(Object data) {
this.data = data;
return this;
}
public Result(int code, String msg, Object data) {
this.code = code;
if (Strings.isBlank(msg) || Mvcs.getActionContext() == null || Mvcs.getActionContext().getRequest() == null || Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg) == null) {
this.msg = Strings.sNull(msg);
} else {
this.msg = Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg);
}
this.data = data;
this.time = System.currentTimeMillis();
}
public static Result success(String content) {
return new Result(0, content, null);
}
public static Result success(String content, Object data) {
return new Result(0, content, data);
}
public static Result success(Object data) {
return new Result(0, "system.success", data);
}
public static Result error(int code, String content) {
return new Result(code, content, null);
}
public static Result error(String content) {
return new Result(1, content, null);
}
public static Result success() {
return new Result(0, "system.success", null);
}
public static Result error() {
return new Result(1, "system.error", null);
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
public Object getData() {
return data;
}
public static Result condition(boolean flag) {
return flag ? success("system.error") : error("system.error");
}
public String toJsonString() {
return Json.toJson(this, JsonFormat.compact());
}
}
@@ -0,0 +1,914 @@
package io.v.nutz.base.service;
import io.v.nutz.base.page.Pagination;
import io.v.nutz.base.page.datatable.DataTableColumn;
import io.v.nutz.base.page.datatable.DataTableOrder;
import org.nutz.dao.*;
import org.nutz.dao.entity.Entity;
import org.nutz.dao.entity.Record;
import org.nutz.dao.pager.Pager;
import org.nutz.dao.sql.Sql;
import org.nutz.lang.util.NutMap;
import java.util.List;
import java.util.Map;
/**
* Created by wizzer on 2016/12/22.
*/
public interface BaseService<T> {
Dao dao();
/**
* 获取实体的Entity
*
* @return 实体的Entity
*/
Entity<T> getEntity();
/**
* 获取实体类型
*
* @return 实体类型
*/
Class<T> getEntityClass();
/**
* 统计符合条件的对象表条数
*
* @param cnd
* @return
*/
int count(Condition cnd);
/**
* 统计对象表条数
*
* @return
*/
int count();
/**
* 统计符合条件的记录条数
*
* @param tableName
* @param cnd
* @return
*/
int count(String tableName, Condition cnd);
/**
* 统计表记录条数
*
* @param tableName
* @return
*/
int count(String tableName);
/**
* 自定义SQL统计
*
* @param sql
* @return
*/
int count(Sql sql);
/**
* 通过数字型主键查询对象
*
* @param id
* @return
*/
T fetch(long id);
/**
* 通过字符型主键查询对象
*
* @param id
* @return
*/
T fetch(String id);
/**
* 查询关联表
*
* @param obj 数据对象,可以是普通对象或集合,但不是类
* @param regex 为null查询全部,支持通配符 ^(a|b)$
* @return
*/
<T> T fetchLinks(T obj, String regex);
/**
* 查询关联表
*
* @param obj 数据对象,可以是普通对象或集合,但不是类
* @param regex 为null查询全部,支持通配符 ^(a|b)$
* @param cnd 关联字段的过滤(排序,条件语句,分页等)
* @return
*/
<T> T fetchLinks(T obj, String regex, Condition cnd);
/**
* 查出符合条件的第一条记录
*
* @param cnd 查询条件
* @return 实体, 如不存在则为null
*/
T fetch(Condition cnd);
/**
* 复合主键专用
*
* @param pks 键值
* @return 对象 T
*/
T fetchx(Object... pks);
/**
* 复合主键专用
*
* @param pks 键值
* @return 对象 T
*/
boolean exists(Object... pks);
/**
* 将一个对象插入到一个数据库
*
* @param obj 要被插入的对象
* 它可以是:
* 普通 POJO
* 集合
* 数组
* Map
* 注意:如果是集合,数组或者 Map,所有的对象必须类型相同,否则可能会出错
* @return 插入后的对象
*/
<T> T insert(T obj);
/**
* 将一个对象按FieldFilter过滤后,插入到一个数据源。
* <p>
* <code>dao.insert(pet, FieldFilter.create(Pet.class, FieldMatcher.create(false)));</code>
*
* @param obj 要被插入的对象
* @param filter 字段过滤器, 其中FieldMatcher.isIgnoreId生效
* @return 插入后的对象
* @see Dao#insert(Object)
*/
<T> T insert(T obj, FieldFilter filter);
/**
* 根据对象的主键(@Id/@Name/@Pk)先查询, 如果存在就更新, 不存在就插入
*
* @param obj 对象
* @return 原对象
*/
<T> T insertOrUpdate(T obj);
/**
* 根据对象的主键(@Id/@Name/@Pk)先查询, 如果存在就更新, 不存在就插入
*
* @param obj 对象
* @param insertFieldFilter 插入时的字段过滤, 可以是null
* @param updateFieldFilter 更新时的字段过滤,可以是null
* @return 原对象
*/
<T> T insertOrUpdate(T obj, FieldFilter insertFieldFilter, FieldFilter updateFieldFilter);
/**
* 自由的向一个数据表插入一条数据
*
* @param tableName 表名
* @param chain 数据名值链
*/
void insert(String tableName, Chain chain);
/**
* 快速插入一个对象,对象的 '@Prev' 以及 '@Next' 在这个函数里不起作用
*
* @param obj
* @return
*/
<T> T fastInsert(T obj);
/**
* 将对象插入数据库同时,也将符合一个正则表达式的所有关联字段关联的对象统统插入相应的数据库
* <p>
* 关于关联字段更多信息,请参看 '@One' | '@Many' | '@ManyMany' 更多的描述
*
* @param obj 数据对象
* @param regex 正则表达式,描述了什么样的关联字段将被关注。如果为 null,则表示全部的关联字段都会被插入
* @return 数据对象本身
* @see org.nutz.dao.entity.annotation.One
* @see org.nutz.dao.entity.annotation.Many
* @see org.nutz.dao.entity.annotation.ManyMany
*/
<T> T insertWith(T obj, String regex);
/**
* 根据一个正则表达式,仅将对象所有的关联字段插入到数据库中,并不包括对象本身
*
* @param obj 数据对象
* @param regex 正则表达式,描述了什么样的关联字段将被关注。如果为 null,则表示全部的关联字段都会被插入
* @return 数据对象本身
* @see org.nutz.dao.entity.annotation.One
* @see org.nutz.dao.entity.annotation.Many
* @see org.nutz.dao.entity.annotation.ManyMany
*/
<T> T insertLinks(T obj, String regex);
/**
* 将对象的一个或者多个,多对多的关联信息,插入数据表
*
* @param obj 对象
* @param regex 正则表达式,描述了那种多对多关联字段将被执行该操作
* @return 对象自身
* @see org.nutz.dao.entity.annotation.ManyMany
*/
<T> T insertRelation(T obj, String regex);
/**
* 更新数据
*
* @param obj
* @return
*/
int update(Object obj);
/**
* 更新数据忽略值为null的字段
*
* @param obj
* @return
*/
int updateIgnoreNull(Object obj);
/**
* 部分更新实体表
*
* @param chain
* @param cnd
* @return
*/
int update(Chain chain, Condition cnd);
/**
* 部分更新表
*
* @param tableName
* @param chain
* @param cnd
* @return
*/
int update(String tableName, Chain chain, Condition cnd);
/**
* 将对象更新的同时,也将符合一个正则表达式的所有关联字段关联的对象统统更新
* <p>
* 关于关联字段更多信息,请参看 '@One' | '@Many' | '@ManyMany' 更多的描述
*
* @param obj 数据对象
* @param regex 正则表达式,描述了什么样的关联字段将被关注。如果为 null,则表示全部的关联字段都会被更新
* @return 数据对象本身
* @see org.nutz.dao.entity.annotation.One
* @see org.nutz.dao.entity.annotation.Many
* @see org.nutz.dao.entity.annotation.ManyMany
*/
<T> T updateWith(T obj, String regex);
/**
* 根据一个正则表达式,仅更新对象所有的关联字段,并不包括对象本身
*
* @param obj 数据对象
* @param regex 正则表达式,描述了什么样的关联字段将被关注。如果为 null,则表示全部的关联字段都会被更新
* @return 数据对象本身
* @see org.nutz.dao.entity.annotation.One
* @see org.nutz.dao.entity.annotation.Many
* @see org.nutz.dao.entity.annotation.ManyMany
*/
<T> T updateLinks(T obj, String regex);
/**
* 多对多关联是通过一个中间表将两条数据表记录关联起来。
* <p>
* 而这个中间表可能还有其他的字段,比如描述关联的权重等
* <p>
* 这个操作可以让你一次更新某一个对象中多个多对多关联的数据
*
* @param classOfT 对象类型
* @param regex 正则表达式,描述了那种多对多关联字段将被执行该操作
* @param chain 针对中间关联表的名值链。
* @param cnd 针对中间关联表的 WHERE 条件
* @return 共有多少条数据被更新
* @see org.nutz.dao.entity.annotation.ManyMany
*/
int updateRelation(Class<?> classOfT, String regex, Chain chain, Condition cnd);
/**
* 基于版本的更新,版本不一样无法更新到数据
*
* @param obj 需要更新的对象, 必须有version属性
* @return 若更新成功, 大于0, 否则小于0
*/
int updateWithVersion(Object obj);
/**
* 基于版本的更新,版本不一样无法更新到数据
*
* @param obj 需要更新的对象, 必须有version属性
* @param filter 需要过滤的字段设置
* @return 若更新成功, 大于0, 否则小于0
*/
int updateWithVersion(Object obj, FieldFilter filter);
/**
* 乐观锁, 以特定字段的值作为限制条件,更新对象,并自增该字段.
* <p>
* 执行的sql如下:
* <p>
* <code>update t_user set age=30, city="广州", version=version+1 where name="wendal" and version=124;</code>
*
* @param obj 需要更新的对象, 必须带@Id/@Name/@Pk中的其中一种.
* @param fieldFilter 需要过滤的属性. 若设置了哪些字段不更新,那务必确保过滤掉fieldName的字段
* @param fieldName 参考字段的Java属性名.默认是"version",可以是任意数值字段
* @return 若更新成功, 返回值大于0, 否则小于等于0
*/
int updateAndIncrIfMatch(Object obj, FieldFilter fieldFilter, String fieldName);
/**
* 获取某个对象,最大的 ID 值,这个对象必须声明了 '@Id'
*
* @return
*/
int getMaxId();
/**
* 通过long主键删除数据
*
* @param id
* @return
*/
int delete(long id);
/**
* 通过int主键删除数据
*
* @param id
* @return
*/
int delete(int id);
/**
* 通过string主键删除数据
*
* @param id
* @return
*/
int delete(String id);
/**
* 批量删除
*
* @param ids
*/
void delete(Integer[] ids);
/**
* 批量删除
*
* @param ids
*/
void delete(Long[] ids);
/**
* 批量删除
*
* @param ids
*/
void delete(String[] ids);
/**
* 批量删除
*
* @param ids
*/
void delete(List<String> ids);
/**
* 清空表
*
* @return
*/
int clear();
/**
* 清空表
*
* @return
*/
int clear(String tableName);
/**
* 按条件清除一组数据
*
* @return
*/
int clear(Condition cnd);
/**
* 按条件清除一组数据
*
* @return
*/
int clear(String tableName, Condition cnd);
/**
* 伪删除
*
* @param id
* @return
*/
int vDelete(String id);
/**
* 批量伪删除
*
* @param ids
* @return
*/
int vDelete(String[] ids);
/**
* 批量伪删除
*
* @param ids
* @return
*/
int vDelete(List<String> ids);
/**
* 根据条件进行伪删除
*
* @param cnd
* @return
*/
int vDelete(Condition cnd);
/**
* 根据条件进行伪删除
*
* @param cnd
* @return
*/
int vDelete(String tableName, Condition cnd);
/**
* 通过LONG主键获取部分字段值
*
* @param fieldName
* @param id
* @return
*/
T getField(String fieldName, long id);
/**
* 通过INT主键获取部分字段值
*
* @param fieldName
* @param id
* @return
*/
T getField(String fieldName, int id);
/**
* 通过NAME主键获取部分字段值
*
* @param fieldName 支持通配符 ^(a|b)$
* @param name
* @return
*/
T getField(String fieldName, String name);
/**
* 通过条件获取部分字段值
*
* @param fieldName 支持通配符 ^(a|b)$
* @param cnd
* @return
*/
T getField(String fieldName, Condition cnd);
/**
* 查询获取部分字段
*
* @param fieldName 支持通配符 ^(a|b)$
* @param cnd
* @return
*/
List<T> query(String fieldName, Condition cnd);
/**
* 查询一组对象。你可以为这次查询设定条件
*
* @param cnd WHERE 条件。如果为 null,将获取全部数据,顺序为数据库原生顺序<br>
* 只有在调用这个函数的时候, cnd.limit 才会生效
* @return 对象列表
*/
List<T> query(Condition cnd);
/**
* 获取全部数据
*
* @return
*/
List<T> query();
/**
* @param cnd 查询条件
* @param linkName 关联字段,支持正则 ^(a|b)$
* @return
*/
List<T> query(Condition cnd, String linkName);
/**
* 获取表及关联表全部数据(支持子查询)
*
* @param cnd 查询条件
* @param linkName 关联字段,支持正则 ^(a|b)$
* @param linkCnd 关联条件
* @return
*/
List<T> query(Condition cnd, String linkName, Condition linkCnd);
/**
* 获取表及关联表全部数据
*
* @param linkName 关联字段,支持正则 ^(a|b)$
* @return
*/
List<T> query(String linkName);
/**
* 分页关联字段查询
*
* @param cnd 查询条件
* @param linkName 关联字段,支持正则 ^(a|b)$
* @param pager 分页对象
* @return
*/
List<T> query(Condition cnd, String linkName, Pager pager);
/**
* 分页关联字段查询(支持关联条件)
*
* @param cnd 查询条件
* @param linkName 关联字段,支持正则 ^(a|b)$
* @param linkCnd 关联条件
* @param pager 分页对象
* @return
*/
List<T> query(Condition cnd, String linkName, Condition linkCnd, Pager pager);
/**
* 分页查询
*
* @param cnd 查询条件
* @param pager 分页对象
* @return
*/
List<T> query(Condition cnd, Pager pager);
/**
* 查询获取NutMap对象
*
* @param keyColumnName 作为key的字段名
* @param valueColumnName 作为value的字段名
* @param cnd 查询条件
* @return
*/
NutMap query(String keyColumnName, String valueColumnName, Condition cnd);
/**
* 查询获取NutMap对象
*
* @param tableName 表名
* @param keyColumnName 作为key的字段名
* @param valueColumnName 作为value的字段名
* @param cnd 查询条件
* @return
*/
NutMap query(String tableName, String keyColumnName, String valueColumnName, Condition cnd);
/**
* 计算子节点TREEID
*
* @param tableName
* @param colName
* @param value
* @return
*/
String getSubPath(String tableName, String colName, String value);
/**
* 获取TREEID父级
*
* @param path
* @return
*/
String getParentPath(String path);
/**
* 执行一条自定义SQL
*
* @param sql
* @return
*/
Sql execute(Sql sql);
/**
* 自定义SQL返回Record记录集,Record是个MAP但不区分大小写
* 别返回Map对象,因为MySql和Oracle中字段名有大小写之分
*
* @param sql
* @return
*/
List<Record> list(Sql sql);
/**
* 自定义SQL返回NutMap记录集,区分大小写
*
* @param sql
* @return
*/
List<NutMap> listMap(Sql sql);
/**
* 自定义查询,并返回当前实体类对象
*
* @param sql
* @return
*/
List<T> listEntity(Sql sql);
/**
* 自定义sql获取map key-value
*
* @param sql
* @return
*/
Map getMap(Sql sql);
/**
* 自定义sql获取NutMap key-value
*
* @param sql
* @return
*/
NutMap getNutMap(Sql sql);
/**
* 分页查询
*
* @param pageNumber
* @param cnd
* @return
*/
Pagination listPage(Integer pageNumber, Condition cnd);
/**
* 分页查询
*
* @param pageNumber
* @param sql
* @return
*/
Pagination listPage(Integer pageNumber, Sql sql);
/**
* 分页查询(sql)
*
* @param pageNumber
* @param pageSize
* @param sql
* @return
*/
Pagination listPage(Integer pageNumber, int pageSize, Sql sql);
/**
* 分页查询
*
* @param pageNumber
* @param sql 查询语句
* @param countSql 统计语句
* @return
*/
Pagination listPage(Integer pageNumber, Sql sql, Sql countSql);
/**
* 分页查询
*
* @param pageNumber
* @param pageSize
* @param sql 查询语句
* @param countSql 统计语句
* @return
*/
Pagination listPage(Integer pageNumber, int pageSize, Sql sql, Sql countSql);
/**
* 分页查询
*
* @param pageNumber
* @param sql
* @return
*/
Pagination listPageMap(Integer pageNumber, Sql sql);
/**
* 分页查询(sql)
*
* @param pageNumber
* @param pageSize
* @param sql
* @return
*/
Pagination listPageMap(Integer pageNumber, int pageSize, Sql sql);
/**
* 分页查询
*
* @param pageNumber
* @param sql 查询语句
* @param countSql 统计语句
* @return
*/
Pagination listPageMap(Integer pageNumber, Sql sql, Sql countSql);
/**
* 分页查询
*
* @param pageNumber
* @param pageSize
* @param sql 查询语句
* @param countSql 统计语句
* @return
*/
Pagination listPageMap(Integer pageNumber, int pageSize, Sql sql, Sql countSql);
/**
* 分页查询
*
* @param pageNumber
* @param tableName
* @param cnd
* @return
*/
Pagination listPage(Integer pageNumber, String tableName, Condition cnd);
/**
* 分页查询(cnd)
*
* @param pageNumber
* @param pageSize
* @param cnd
* @return
*/
Pagination listPage(Integer pageNumber, int pageSize, Condition cnd);
/**
* 分页查询,获取部分字段(cnd)
*
* @param pageNumber
* @param pageSize
* @param cnd
* @param fieldName 支持通配符 ^(a|b)$
* @return
*/
Pagination listPage(Integer pageNumber, int pageSize, Condition cnd, String fieldName);
/**
* 关联查询
*
* @param pageNumber
* @param pageSize
* @param cnd
* @param linkName 支持通配符 ^(a|b)$
* @return
*/
Pagination listPageLinks(Integer pageNumber, int pageSize, Condition cnd, String linkName);
/**
* 关联查询,带子查询条件
*
* @param pageNumber
* @param pageSize
* @param cnd
* @param linkName 支持通配符 ^(a|b)$
* @param subCnd 子查询条件
* @return
*/
Pagination listPageLinks(Integer pageNumber, int pageSize, Condition cnd, String linkName, Condition subCnd);
/**
* 分页查询(tabelName)
*
* @param pageNumber
* @param pageSize
* @param tableName
* @param cnd
* @return
*/
Pagination listPage(Integer pageNumber, int pageSize, String tableName, Condition cnd);
/**
* 分页查询并返回包含实体类内容的NutMap对象
*
* @param pageNumber
* @param cnd
* @return
*/
Pagination listPageMap(Integer pageNumber, Condition cnd);
/**
* 分页查询并返回包含实体类内容的NutMap对象
*
* @param pageNumber
* @param pageSize
* @param cnd
* @return
*/
Pagination listPageMap(Integer pageNumber, int pageSize, Condition cnd);
/**
* DataTable Page
*
* @param length 页大小
* @param start start
* @param draw draw
* @param orders 排序
* @param columns 字段
* @param cnd 查询条件
* @param linkName 关联查询 支持通配符 ^(a|b)$
* @return
*/
NutMap data(int length, int start, int draw, List<DataTableOrder> orders, List<DataTableColumn> columns, Cnd cnd, String linkName);
/**
* DataTable Page
*
* @param length 页大小
* @param start start
* @param draw draw
* @param orders 排序
* @param columns 字段
* @param cnd 查询条件
* @param linkName 关联查询 支持通配符 ^(a|b)$
* @param subCnd 关联查询条件
* @return
*/
NutMap data(int length, int start, int draw, List<DataTableOrder> orders, List<DataTableColumn> columns, Cnd cnd, String linkName, Cnd subCnd);
/**
* DataTable Page 自定义SQL
*
* @param length 页大小
* @param start start
* @param draw draw
* @param countSql 统计查询语句
* @param orderSql 结果查询语句
* @return
*/
NutMap data(int length, int start, int draw, Sql countSql, Sql orderSql);
/**
* DataTable Page 自定义SQL
*
* @param length 页大小
* @param start start
* @param draw draw
* @param countSql 统计查询语句
* @param orderSql 结果查询语句
* @param countOnly 统计查询语句是否只有count()
* @return
*/
NutMap data(int length, int start, int draw, Sql countSql, Sql orderSql, boolean countOnly);
/**
* DataTable Page
*
* @param length 页大小
* @param start start
* @param draw draw
* @param cnd 查询条件
* @param linkName 关联查询 支持通配符 ^(a|b)$
* @return
*/
NutMap data(int length, int start, int draw, Cnd cnd, String linkName);
}
@@ -0,0 +1,13 @@
package io.v.nutz.base.service;
import io.v.nutz.service.ViService;
/**
* @author zxy
* @Description TODO
* @createTime 2022年01月04日 13:55:00
*/
public interface SimpleService extends ViService {
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,20 @@
package io.v.nutz.base.service.impl;
import io.v.nutz.base.service.SimpleService;
import io.v.nutz.service.impl.ViServiceImpl;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
/**
* @author zxy
* @Description TODO
* @createTime 2022年01月04日 13:55:00
*/
@IocBean(args = {"refer:dao"})
public class SimpleServiceImpl extends ViServiceImpl implements SimpleService {
public SimpleServiceImpl(Dao dao) {
super(dao);
}
}
@@ -0,0 +1,155 @@
package io.v.nutz.base.utils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.nutz.lang.Times;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
/**
* Created by wizzer on 2016/6/24.
*/
public class DateUtil {
private static final Locale DEFAULT_LOCALE = Locale.CHINA;
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static Integer getYear() {
return Calendar.getInstance().get(Calendar.YEAR);
}
/**
* 获取当前时间(HH:mm:ss)
*
* @return
*/
public static String getDate() {
return DateFormatUtils.format(new Date(), "yyyy-MM-dd", DEFAULT_LOCALE);
}
/**
* 获取当前时间(HH:mm:ss)
*
* @return
*/
public static String getTime() {
return DateFormatUtils.format(new Date(), "HH:mm:ss", DEFAULT_LOCALE);
}
/**
* 获取当前时间(yyyy-MM-dd HH:mm:ss)
*
* @return
*/
public static String getDateTime() {
return DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss", DEFAULT_LOCALE);
}
/**
* 转换日期格式(yyyy-MM-dd HH:mm:ss)
*
* @param date
* @return
*/
public static String formatDateTime(Date date) {
if (date == null) return "";
return DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss", DEFAULT_LOCALE);
}
/**
* 转换日期格式(yyyy-MM-dd HH:mm:ss)
*
* @param date
* @param f
* @return
*/
public static String format(Date date, String f) {
if (date == null) return "";
return DateFormatUtils.format(date, f, DEFAULT_LOCALE);
}
/**
* 时间戳日期
*
* @param time
* @return
*/
public static String getDate(long time) {
return DateFormatUtils.format(new Date(time * 1000), "yyyy-MM-dd HH:mm:ss", DEFAULT_LOCALE);
}
/**
* 时间戳日期
*
* @param time
* @param f
* @return
*/
public static String getDate(long time, String f) {
return DateFormatUtils.format(new Date(time * 1000), f, DEFAULT_LOCALE);
}
/**
* 通过字符串时间获取时间戳 nutzwk5.0改为long
*
* @param date
* @return
*/
public static long getTime(String date) {
try {
return Times.parse(sdf, date).getTime() / 1000;
} catch (ParseException e) {
return 0;
}
}
/**
* 通过字符串时间获取时间戳 nutzwk5.0改为long
*
* @param date
* @return
*/
public static long getTime(SimpleDateFormat sdf, String date) {
try {
return Times.parse(sdf, date).getTime() / 1000;
} catch (ParseException e) {
return 0;
}
}
/**
* 通过字符串时间转时间戳
*
* @param data
* @return
*/
public static long formatDate(String data) {
try {
return new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(data).getTime();
} catch (ParseException e) {
e.printStackTrace();
return 0;
}
}
/**
* 转换cron
*
* @param date
* @return
*/
public static String getCron(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("ss mm HH dd MM ? yyyy");
String formatTimeStr = null;
if (Objects.nonNull(date)) {
formatTimeStr = sdf.format(date);
}
return formatTimeStr;
}
}
@@ -0,0 +1,199 @@
package io.v.nutz.base.utils;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import java.io.*;
/**
* 文档转换util
*/
public class DocConverter {
private static final int environment = 1;// 环境1windows,2:linux(涉及pdf2swf路径问题)
private String fileString;
private String outputPath = "";// 输入路径,如果不设置就输出在默认位置
private String fileName;
private File pdfFile;
private File swfFile;
private File docFile;
public DocConverter(String fileString) {
ini(fileString);
}
/*
* 重新设置 file @param fileString
*/
public void setFile(String fileString) {
ini(fileString);
}
/*
* 初始化 @param fileString
*/
private void ini(String fileString) {
this.fileString = fileString;
fileName = fileString.substring(0, fileString.lastIndexOf("."));
docFile = new File(fileString);
pdfFile = new File(fileName + ".pdf");
swfFile = new File(fileName + ".swf");
}
/*
* 转为PDF @param file
*/
private void doc2pdf() throws Exception {
if (docFile.exists()) {
if (!pdfFile.exists()) {
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(docFile, pdfFile);
// close the connection
connection.disconnect();
System.out.println("****pdf转换成功,PDF输出:" + pdfFile.getPath() + "****");
} catch (java.net.ConnectException e) {
// ToDo Auto-generated catch block
e.printStackTrace();
System.out.println("****swf转换异常,openoffice服务未启动!****");
throw e;
} catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
e.printStackTrace();
System.out.println("****swf转换器异常,读取转换文件失败****");
throw e;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
} else {
System.out.println("****已经转换为pdf,不需要再进行转化****");
}
} else {
System.out.println("****swf转换器异常,需要转换的文档不存在,无法转换****");
}
}
/*
* 转换成swf
*/
private void pdf2swf() throws Exception {
Runtime r = Runtime.getRuntime();
if (!swfFile.exists()) {
if (pdfFile.exists()) {
if (environment == 1)// windows环境处理
{
try {
// 这里根据SWFTools安装路径需要进行相应更改
Process p = r.exec("D:\\ewm\\hj\\pdf2swf\\pdf2swf.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
System.out.print(loadStream(p.getInputStream()));
System.err.print(loadStream(p.getErrorStream()));
System.out.print(loadStream(p.getInputStream()));
System.err.println("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
// if (pdfFile.exists()) {
// pdfFile.delete();
// }
} catch (Exception e) {
e.printStackTrace();
throw e;
}
} else if (environment == 2)// linux环境处理
{
try {
Process p = r.exec("pdf2swf " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
System.out.print(loadStream(p.getInputStream()));
System.err.print(loadStream(p.getErrorStream()));
System.err.println("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
if (pdfFile.exists()) {
pdfFile.delete();
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
} else {
System.out.println("****pdf不存在,无法转换****");
}
} else {
System.out.println("****swf已存在不需要转换****");
}
}
static String loadStream(InputStream in) throws IOException {
int ptr = 0;
//把InputStream字节流 替换为BufferedReader字符流 2013-07-17修改
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder buffer = new StringBuilder();
while ((ptr = reader.read()) != -1) {
buffer.append((char) ptr);
}
return buffer.toString();
}
/*
* 转换主方法
*/
public boolean conver() {
if (swfFile.exists()) {
System.out.println("****swf转换器开始工作,该文件已经转换为swf****");
return true;
}
if (environment == 1) {
System.out.println("****swf转换器开始工作,当前设置运行环境windows****");
} else {
System.out.println("****swf转换器开始工作,当前设置运行环境linux****");
}
try {
doc2pdf();
pdf2swf();
} catch (Exception e) {
// TODO: Auto-generated catch block
e.printStackTrace();
return false;
}
if (swfFile.exists()) {
return true;
} else {
return false;
}
}
/*
* 返回文件路径 @param s
*/
public String getswfPath() {
if (swfFile.exists()) {
String tempString = swfFile.getPath();
tempString = tempString.replaceAll("\\\\", "/");
return tempString;
} else {
return "";
}
}
/*
* 设置输出路径
*/
public void setOutputPath(String outputPath) {
this.outputPath = outputPath;
if (!outputPath.equals("")) {
String realName = fileName.substring(fileName.lastIndexOf("/"), fileName.lastIndexOf("."));
if (outputPath.charAt(outputPath.length()) == '/') {
swfFile = new File(outputPath + realName + ".swf");
} else {
swfFile = new File(outputPath + realName + ".swf");
}
}
}
public static void main(String s[]) {
DocConverter d = new DocConverter("C:\\Users\\mayn\\Desktop\\安全管理系统.docx");
d.conver();
}
}
@@ -0,0 +1,261 @@
package io.v.nutz.base.utils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.InputStream;
public class ExcelUtil {
/**
* 导出Excel
* @param sheetName sheet名称
* @param title 标题
* @param values 内容
* @param wb HSSFWorkbook对象
* @return
*/
public static HSSFWorkbook getHSSFWorkbook(String sheetName, String []title, String [][]values, HSSFWorkbook wb){
// 第一步,创建一个HSSFWorkbook,对应一个Excel文件
if(wb == null){
wb = new HSSFWorkbook();
}
// 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet
HSSFSheet sheet = wb.createSheet(sheetName);
// sheet.setColumnWidth(0, 3766);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
HSSFRow row = sheet.createRow(0);
// 第四步,创建单元格,并设置值表头 设置表头居中
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
/*style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
style.setBorderTop(HSSFCellStyle.BORDER_THIN); //上边框
style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框*/
HSSFFont font = wb.createFont();
font.setFontName("黑体");
font.setFontHeightInPoints((short) 12);//设置字体大小
style.setFont(font);
//声明列对象
HSSFCell cell = null;
//创建标题
for(int i=0;i<title.length;i++){
cell = row.createCell(i);
cell.setCellValue(title[i]);
cell.setCellStyle(style);
sheet.autoSizeColumn(i);
sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 35 / 10);
}
HSSFCellStyle style1 = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
//style1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//创建内容
for(int i=0;i<values.length;i++){
row = sheet.createRow(i + 1);
for(int j=0;j<values[i].length;j++){
HSSFCell cellx = row.createCell(j);
//将内容按顺序赋给对应的列对象
cellx.setCellValue(values[i][j]);
//样式
cellx.setCellStyle(style1);
}
}
return wb;
}
/**
* 导出Excel
* @param sheetName sheet名称
* @param title 标题
* @param values 内容
* @param wb HSSFWorkbook对象
* @return
*/
public static HSSFWorkbook getHSSFWorkbook2(String sheetName,String bigTitle,int bigTitleHbColumn, String []title, String [][]values, HSSFWorkbook wb){
if(wb == null){
wb = new HSSFWorkbook();
}
HSSFSheet sheet = wb.createSheet(sheetName);
HSSFRow row0 = sheet.createRow(0);
HSSFCellStyle style0 = wb.createCellStyle();
style0.setAlignment(HorizontalAlignment.CENTER);
/*style0.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
style0.setBorderTop(HSSFCellStyle.BORDER_THIN); //上边框
style0.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
style0.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
style0.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框*/
HSSFFont font0 = wb.createFont();
font0.setFontName("黑体");
font0.setFontHeightInPoints((short) 20);//设置字体大小
style0.setFont(font0);
HSSFCell cell0 = row0.createCell(0);
cell0.setCellStyle(style0);
cell0.setCellValue(bigTitle);
HSSFRow row1 = sheet.createRow(1);
HSSFCellStyle style1 = wb.createCellStyle();
style1.setAlignment(HorizontalAlignment.CENTER);
/*style1.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
style1.setBorderTop(HSSFCellStyle.BORDER_THIN); //上边框
style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
style1.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框*/
HSSFFont font1 = wb.createFont();
font1.setFontName("黑体");
font1.setFontHeightInPoints((short) 12);//设置字体大小
style1.setFont(font1);
//声明列对象
HSSFCell cell = null;
//创建标题
for(int i=0;i<title.length;i++){
cell = row1.createCell(i);
cell.setCellValue(title[i]);
cell.setCellStyle(style1);
/* sheet.autoSizeColumn(i);*/
sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 35 / 10);
}
//setSizeColumn(sheet,title.length);
HSSFCellStyle style2 = wb.createCellStyle();
/* style2.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式*/
style2.setAlignment(HorizontalAlignment.CENTER);
HSSFFont font2 = wb.createFont();
font2.setFontName("宋体");
font2.setFontHeightInPoints((short) 12);//设置字体大小
style2.setFont(font2);
//创建内容
for(int i=0;i<values.length;i++){
row1 = sheet.createRow(i + 2);
for(int j=0;j<values[i].length;j++){
HSSFCell cellx = row1.createCell(j);
//将内容按顺序赋给对应的列对象
cellx.setCellValue(values[i][j]);
//样式
cellx.setCellStyle(style2);
}
}
CellRangeAddress region = new CellRangeAddress(0, 0, 0, bigTitleHbColumn);
sheet.addMergedRegion(region);
return wb;
}
// 自适应宽度(中文支持)
private static void setSizeColumn(HSSFSheet sheet, int size) {
for (int columnNum = 0; columnNum < size; columnNum++) {
int columnWidth = sheet.getColumnWidth(columnNum) / 256;
for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
HSSFRow currentRow;
//当前行未被使用过
if (sheet.getRow(rowNum) == null) {
currentRow = sheet.createRow(rowNum);
} else {
currentRow = sheet.getRow(rowNum);
}
if (currentRow.getCell(columnNum) != null) {
HSSFCell currentCell = currentRow.getCell(columnNum);
if (currentCell.getCellType() == CellType.STRING) {
int length = currentCell.getStringCellValue().getBytes().length;
if (columnWidth < length) {
columnWidth = length;
}
}
}
}
sheet.setColumnWidth(columnNum, columnWidth * 256);
}
}
public void readExcelFile(InputStream inputStream, String fileName) {
/**
* 这个inputStream文件可以来源于本地文件的流,
* 也可以来源与上传上来的文件的流,也就是MultipartFile的流,
* 使用getInputStream()方法进行获取。
*/
/**
* 然后再读取文件的时候,应该excel文件的后缀名在不同的版本中对应的解析类不一样
* 要对fileName进行后缀的解析
*/
Workbook workbook = null;
try {
//判断什么类型文件
if (fileName.endsWith(".xls")) {
workbook = new HSSFWorkbook(inputStream);
} else if (fileName.endsWith(".xlsx")) {
workbook = new XSSFWorkbook(inputStream);
}
} catch (Exception e) {
e.printStackTrace();
}
if (workbook == null) {
return;
} else {
//获取所有的工作表的的数量
int numOfSheet = workbook.getNumberOfSheets();
System.out.println(numOfSheet + "--->numOfSheet");
//遍历表
for (int i = 0; i < numOfSheet; i++) {
//获取一个sheet也就是一个工作本。
Sheet sheet = workbook.getSheetAt(i);
if (sheet == null) {
continue;
}
//获取一个sheet有多少Row
int lastRowNum = sheet.getLastRowNum();
if (lastRowNum == 0) {
continue;
}
Row row;
for (int j = 1; j <= lastRowNum; j++) {
row = sheet.getRow(j);
if (row == null) {
continue;
}
//获取一个Row有多少Cell
short lastCellNum = row.getLastCellNum();
for (int k = 0; k <= lastCellNum; k++) {
if (row.getCell(k) == null) {
continue;
}
row.getCell(k).setCellType(CellType.STRING);
String res = row.getCell(k).getStringCellValue().trim();
//打印出cell(单元格的内容)
System.out.println(res);
}
}
}
}
}
}
@@ -0,0 +1,55 @@
package io.v.nutz.base.utils;
import freemarker.template.Configuration;
import freemarker.template.Template;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/**
* 导出excel Utils
*
* @author Administrator
*/
public class ExcelUtils {
private static Configuration configuration = null;
private static Map<String, Template> allTemplates = null;
private static String realPath = "src/main/resources/ftl";
public ExcelUtils() {
throw new AssertionError();
}
/**
* 创建excel
*
* @param dataMap
* @param type
* @return
*/
public static File createExcel(Map<?, ?> dataMap, String type, String valueName) {
try {
configuration = new Configuration();
configuration.setDefaultEncoding("UTF-8");
configuration.setDirectoryForTemplateLoading(new File(realPath));
allTemplates = new HashMap<String, Template>();
allTemplates.put(type, configuration.getTemplate(valueName));
} catch (IOException ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
String name = "temp" + (int) (Math.random() * 100000) + ".xls";
File file = new File(name);
Template template = allTemplates.get(type);
try {
Writer w = new OutputStreamWriter(new FileOutputStream(file), "utf-8");
template.process(dataMap, w);
w.close();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return file;
}
}

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