提交 41b39e0d authored 作者: gongwenjie's avatar gongwenjie

通知

上级 f603f0e9
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
/*
* Copyright 2007-present the original author or authors.
*
* 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
*
* https://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.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
差异被折叠。
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>tynotes</artifactId>
<groupId>com.zjty.tynotes</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>notes-address</artifactId>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-redis</artifactId>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-misc</artifactId>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-search</artifactId>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-sms</artifactId>
<exclusions>
<exclusion>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-address</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-pas</artifactId>
<exclusions>
<exclusion>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-address</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.zjty.tynotes.address;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
@SpringBootApplication(scanBasePackages = {
"com.zjty.tynotes.redis",
"com.zjty.tynotes.misc",
"com.zjty.tynotes.search",
"com.zjty.tynotes.sms",
"com.zjty.tynotes.address",
"com.zjty.tynotes.pas"
}
)
@EnableCaching
public class NotesAddressApplication {
public static void main(String[] args) {
SpringApplication.run(NotesAddressApplication.class, args);
}
}
package com.zjty.tynotes.address.server.controller;
import com.zjty.tynotes.address.server.entity.Notice;
import com.zjty.tynotes.address.server.service.NoticeService;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static org.springframework.http.ResponseEntity.ok;
/**
* @Author gwj
* @create 2020/5/13 14:30
*/
@Api(tags = "通知模块", protocols = "http")
@RestController
@RequestMapping("/notice/manage")
@AutoDocument
public class NoticeController {
private static final Logger logger = LoggerFactory.getLogger(NoticeController.class);
@Autowired
private NoticeService noticeService;
@ApiOperation(value = "根据人的id查找所有相同部门")
@GetMapping("/findUserByLevel/{id}")
public ResponseEntity findUserByLevel(@PathVariable String id) {
List<Department> departments = noticeService.findDepart(id);
if(departments!=null){
return ok(departments);
}
return ok("根据部门等级查找所有部门");
}
@ApiOperation(value = "回应通知")
@PostMapping("/replyNotice")
public ResponseEntity replyNotice(@RequestBody Notice notice) {
Notice notice1 = noticeService.replyNotice(notice);
if(notice1!=null){
return ok(notice1);
}
return ok("回应通知失败");
}
@ApiOperation(value = "获取某部门下的所有人员")
@GetMapping("/findUnderUser/{departId}")
public ResponseEntity findUnderUser(@PathVariable String departId) {
List<User> userList = noticeService.findUnderUser(departId);
if(userList!=null){
return ok(userList);
}
return ok("回应通知失败");
}
@ApiOperation(value = "查询所有我未处理的通知")
@GetMapping("/findNotReadNotice/{id}")
public ResponseEntity findNotReadNotice(@PathVariable String id) {
try {
List<Notice> notReadNotice = noticeService.findNotReadNotice(id);
return ok(notReadNotice);
} catch (Exception e) {
e.printStackTrace();
}
return ok("查询所有我未处理的通知失败");
}
@ApiOperation(value = "查询所有我请求的通知")
@GetMapping("/findReadNotice/{id}")
public ResponseEntity findReadNotice(@PathVariable String id) {
try {
List<Notice> notices = noticeService.findReadNotice(id);
return ok(notices);
} catch (Exception e) {
e.printStackTrace();
}
return ok("查询所有我请求的通知失败");
}
}
package com.zjty.tynotes.address.server.dao;
import com.zjty.tynotes.address.server.entity.Notice;
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List;
/**
* @Author gwj
* @create 2020/5/13 15:36
*/
public interface NoticeDao extends MongoRepository<Notice,String> {
List<Notice> findAllByResponseIdAndIsRead(String responseId,String isRead);
List<Notice> findAllByApplyIdAndIsRead(String applyId,String isRead);
List<Notice> findAllByApplyId(String applyId);
}
package com.zjty.tynotes.address.server.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
import java.util.List;
/**
* @Author gwj
* @create 2020/5/13 15:18
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "通知信息", description = "通知信息")
@Document(collection = "work_notice")
public class Notice {
@Id
@ApiModelProperty(value = "通知信息id",example = "123qdsdd212")
private String id;
@ApiModelProperty(value = "通知绑定的任务id",example = "123qdsdd212")
private String workId;
@ApiModelProperty(value = "通知绑定的任务名称",example = "123qdsdd212")
private String workName;
@ApiModelProperty(value = "请求人的id",example = "123qdsdd212")
private String applyId;
@ApiModelProperty(value = "请求人的名字",example = "123qdsdd212")
private String applyName;
@ApiModelProperty(value = "反馈人的id",example = "123qdsdd212")
private String responseId;
@ApiModelProperty(value = "反馈人的名字",example = "123qdsdd212")
private String responseName;
@ApiModelProperty(value = "通知是否同意0同意1拒绝",example = "0")
private String isAgree;
@ApiModelProperty(value = "若拒绝,填写拒绝原因",example = "正有其他任务")
private String reason;
@ApiModelProperty(value = "部门id",example = "123qdsdd212")
private String departId;
@ApiModelProperty(value = "通知是否已读,0未读1已读",example = "0")
private String isRead;
@ApiModelProperty(value = "描述",example = "0")
private String des;
@ApiModelProperty(value = "所借人的id",example = "0")
private String borrowUserId;
@ApiModelProperty(value = "描述",example = "0")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
package com.zjty.tynotes.address.server.service;
import com.zjty.tynotes.address.server.entity.Notice;
import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.User;
import java.util.List;
import java.util.Map;
/**
* @Author gwj
* @create 2020/5/13 14:40
*/
public interface NoticeService {
/**
* 查询同级别人员
* @param level
* @return
*/
List<User> findUser(String level);
/**
* 提交通知
* @return
*/
List<Notice> submitNotice(String publishId,Map<String,List<String>> map,String workId,String workName);
/**
* 回应通知
* @param notice
* @return
*/
Notice replyNotice(Notice notice);
/**
* 获取某部门下的所有用户(包括同级)
* @return
*/
List<User> findUnderUser(String departId);
/**
* 查询所有未读通知
*/
List<Notice> findNotReadNotice(String id);
/**
* 查询所有通知
* @param id
* @return
*/
List<Notice> findReadNotice(String id);
/**
* 查看发布者下的所有人员id集合
*/
List<String> findUserIdList(String userId);
/**
* 查找发布者的部门等级
* @param publisher
* @return
*/
String findDepartLevel(String publisher);
/**
* 查询同级别部门
* @param level
* @return
*/
List<Department> findDepart(String level);
/**
* 查找所借人的id集合
* @param users
* @param otherIds
* @return
*/
Map<String,List<String>> findLeadUser(List<User> users, List<String> otherIds,String level);
}
package com.zjty.tynotes.address;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class NotesAddressApplicationTests {
void contextLoads() {
}
}
...@@ -67,12 +67,12 @@ public class DingTestController { ...@@ -67,12 +67,12 @@ public class DingTestController {
myInit.getToken(); myInit.getToken();
myInit.getDepartmentList(); myInit.getDepartmentList();
myInit.getUserList(); myInit.getUserList();
List<String> userIds = myInit.userIds; List<String> userIds = new ArrayList<>();
userIds.add("096031193739801599");
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/listRecord"); DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/listRecord");
OapiAttendanceListRecordRequest request = new OapiAttendanceListRecordRequest(); OapiAttendanceListRecordRequest request = new OapiAttendanceListRecordRequest();
request.setCheckDateFrom("2020-04-04 00:00:00"); request.setCheckDateFrom("2020-05-11 00:00:00");
request.setCheckDateTo("2020-04-10 00:00:00"); request.setCheckDateTo("2020-05-14 00:00:00");
request.setUserIds(userIds); request.setUserIds(userIds);
try { try {
OapiAttendanceListRecordResponse execute = client.execute(request,myInit.token); OapiAttendanceListRecordResponse execute = client.execute(request,myInit.token);
...@@ -84,6 +84,31 @@ public class DingTestController { ...@@ -84,6 +84,31 @@ public class DingTestController {
return null; return null;
} }
@GetMapping("/card2")
public Object card2(){
myInit.getToken();
myInit.getDepartmentList();
myInit.getUserList();
List<String> userIds = new ArrayList<>();
userIds.add("096031193739801599");
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list");
OapiAttendanceListRequest request = new OapiAttendanceListRequest();
request.setWorkDateFrom("2020-05-11 00:00:00");
request.setWorkDateTo("2020-05-14 00:00:00");
request.setUserIdList(userIds);
request.setOffset(0L);
request.setLimit(50L);
try {
OapiAttendanceListResponse response = client.execute(request,myInit.token);
List<OapiAttendanceListResponse.Recordresult> recordresult = response.getRecordresult();
System.out.println(recordresult);
return recordresult;
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
@GetMapping("/score") @GetMapping("/score")
public Object score(){ public Object score(){
String month = "2020-04"; String month = "2020-04";
......
package com.zjty.tynotes.attendance.dao;
import com.zjty.tynotes.attendance.entity.CardAlarm;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
* @Author gwj
* @create 2020/5/13 13:39
*/
public interface CardAlarmDao extends MongoRepository<CardAlarm,String> {
}
package com.zjty.tynotes.attendance.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* @Author gwj
* @create 2020/5/13 11:20
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "打卡报警", description = "打卡报警信息")
@Document(collection = "card_alarm")
public class CardAlarm {
@Id
@ApiModelProperty(value = "打卡报警信息的id",example = "123qdsdd212")
private String id;
@ApiModelProperty(value = "用户id",example = "")
private String userId;
@ApiModelProperty(value = "报警描述",example = "使用虚拟定位打卡")
private String des;
}
...@@ -531,7 +531,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic ...@@ -531,7 +531,7 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
*/ */
@Override @Override
public List<Department> findSelectDepartment() { public List<Department> findSelectDepartment() {
List<Department> departments = departmentDao.findByLevel("2"); List<Department> departments = departmentDao.findAllByLevel("2");
return departments; return departments;
} }
......
...@@ -129,7 +129,6 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService { ...@@ -129,7 +129,6 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
userAttenVo.computerRealAttendanceDay(); userAttenVo.computerRealAttendanceDay();
} }
System.out.println(attendanceDetailsList.size());
return userAttenVo; return userAttenVo;
} catch (ParseException e) { } catch (ParseException e) {
logger.error("时间转换格式错误"); logger.error("时间转换格式错误");
...@@ -138,20 +137,66 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService { ...@@ -138,20 +137,66 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
return userAttenVo; return userAttenVo;
} }
/**
* 查询部门下人员的考勤情况
* @param request
* @return
*/
@Override @Override
public List<UserAttenVo> findDepartment(AttenRequest request) { public List<UserAttenVo> findDepartment(AttenRequest request) {
List<UserAttenVo> userAttenVos = new ArrayList<>(); List<UserAttenVo> userAttenVos = new ArrayList<>();
String id = request.getId();//部门id String id = request.getId();//人的id
List<User> users = pasUserDao.findAll(); List<User> users = pasUserDao.findAll();
List<User> userList = new ArrayList<>(); List<User> userList = new ArrayList<>();
List<String> departIds = new ArrayList<>();
List<String> departmentIds = new ArrayList<>();
Optional<User> byId = pasUserDao.findById(id);
if(byId.isPresent()){
User user = byId.get();
List<UserRole> userRoles = userRoleDao.findAllByUserId(user.getId());
if(userRoles!=null){
List<String> roleIds = new ArrayList<>();
userRoles.forEach(userRole -> {
roleIds.add(userRole.getRoleId());
});
List<Role> roles = roleDao.findAllByIdIn(roleIds);
if(roles!=null){
roles.forEach(role -> {
if(role.getIsLeader().equals("0")){
departmentIds.add(role.getDepartmentId());
}
});
}
}
}
if(departmentIds!=null){
List<String> deIds = new ArrayList<>();
for (String s : departmentIds) {
deIds = getDepartIds(deIds,s);
if(deIds!=null){
for (String s1 : deIds) {
if(!departIds.contains(s1)){
departIds.add(s1);
}
}
}
}
}
if(users!=null){ if(users!=null){
users.forEach(user -> { for (User user : users) {
List<String> departmentIds = user.getDepartmentIds(); if(departIds!=null){
if(departmentIds!=null){ List<String> departmentIds1 = user.getDepartmentIds();
departmentIds.contains(id); if(departmentIds1!=null){
userList.add(user); for (String s : departmentIds1) {
if(departIds.contains(s)){
userList.add(user);
break;
}
}
}
} }
}); }
} }
List<AttenRequest> attenRequests = new ArrayList<>(); List<AttenRequest> attenRequests = new ArrayList<>();
userList.forEach(user -> { userList.forEach(user -> {
...@@ -281,4 +326,21 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService { ...@@ -281,4 +326,21 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
} }
} }
/**
* 递归获得某个部门下的所有部门id集合
* @param ids
* @param departId
* @return
*/
public List<String> getDepartIds(List<String> ids,String departId){
ids.add(departId);
List<Department> departments = departmentDao.findAllByParentId(departId);
if(departments!=null){
departments.forEach(department -> {
getDepartIds(ids,department.getId());
});
}
return ids;
}
} }
...@@ -2,7 +2,9 @@ package com.zjty.tynotes.attendance.task; ...@@ -2,7 +2,9 @@ package com.zjty.tynotes.attendance.task;
import com.dingtalk.api.DefaultDingTalkClient; import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient; import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiAttendanceListRecordRequest;
import com.dingtalk.api.request.OapiAttendanceListRequest; import com.dingtalk.api.request.OapiAttendanceListRequest;
import com.dingtalk.api.response.OapiAttendanceListRecordResponse;
import com.dingtalk.api.response.OapiAttendanceListResponse; import com.dingtalk.api.response.OapiAttendanceListResponse;
import com.taobao.api.ApiException; import com.taobao.api.ApiException;
import com.zjty.tynotes.attendance.dao.*; import com.zjty.tynotes.attendance.dao.*;
...@@ -61,6 +63,8 @@ public class CardTask { ...@@ -61,6 +63,8 @@ public class CardTask {
private UserLateNumDao userLateNumDao; private UserLateNumDao userLateNumDao;
@Autowired @Autowired
private WorkoverApproDao workoverApproDao; private WorkoverApproDao workoverApproDao;
@Autowired
private CardAlarmDao cardAlarmDao;
/** /**
* 定时任务,定时获取打卡信息.计算前天的个人考勤信息情况 * 定时任务,定时获取打卡信息.计算前天的个人考勤信息情况
...@@ -88,19 +92,9 @@ public class CardTask { ...@@ -88,19 +92,9 @@ public class CardTask {
String startTime = sdf.format(time); String startTime = sdf.format(time);
String endTime = sdf3.format(time); String endTime = sdf3.format(time);
// String time1 = null; //获取上下班打卡记录
// String time2 = null;
// try {
// long l1 = sdf2.parse(startTime).getTime() - 8*60*60*1000;
// time1 = sdf2.format(new Date(l1));
// long l2 = sdf2.parse(endTime).getTime() - 8*60*60*1000;
// time2 = sdf2.format(new Date(l2));
// } catch (ParseException e) {
// e.printStackTrace();
// }
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list"); DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list");
OapiAttendanceListRequest request = new OapiAttendanceListRequest(); OapiAttendanceListRequest request = new OapiAttendanceListRequest();
List<DingUser> dingUsers = dingUserDao.findAll(); List<DingUser> dingUsers = dingUserDao.findAll();
List<String> dingUserIds = new ArrayList<>(); List<String> dingUserIds = new ArrayList<>();
if(dingUsers!=null){ if(dingUsers!=null){
...@@ -108,26 +102,48 @@ public class CardTask { ...@@ -108,26 +102,48 @@ public class CardTask {
dingUserIds.add(dingUser.getDingUserId()); dingUserIds.add(dingUser.getDingUserId());
}); });
} }
request.setWorkDateFrom(startTime); request.setWorkDateFrom(startTime);
request.setWorkDateTo(endTime); request.setWorkDateTo(endTime);
request.setUserIdList(dingUserIds); request.setUserIdList(dingUserIds);
request.setOffset(0L); request.setOffset(0L);
request.setLimit(50L); request.setLimit(50L);
//获取打卡详情
DingTalkClient client1 = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/listRecord");
OapiAttendanceListRecordRequest request1 = new OapiAttendanceListRecordRequest();
request1.setCheckDateFrom(startTime);
request1.setCheckDateTo(endTime);
request1.setUserIds(dingUserIds);
try { try {
init.getToken(); init.getToken();
OapiAttendanceListResponse response = client.execute(request,init.token); OapiAttendanceListResponse response = client.execute(request,init.token);
OapiAttendanceListRecordResponse execute = client1.execute(request1,init.token);
if(response!=null){ if(response!=null){
List<OapiAttendanceListRecordResponse.Recordresult> recordresults = new ArrayList<>();
if(execute!=null){
recordresults = execute.getRecordresult();//打卡详情
}
List<OapiAttendanceListResponse.Recordresult> recordresult = response.getRecordresult(); List<OapiAttendanceListResponse.Recordresult> recordresult = response.getRecordresult();
if(recordresult!=null){ if(recordresult!=null){
recordresult.forEach(recordresult1 -> { for (OapiAttendanceListResponse.Recordresult recordresult1 : recordresult) {
String userId = recordresult1.getUserId(); String userId = recordresult1.getUserId();
DingUser dingUser = dingUserDao.findByDingUserId(userId); DingUser dingUser = dingUserDao.findByDingUserId(userId);
CardResult cardResult = new CardResult(recordresult1); if(recordresults!=null){
cardResult.setUserId(dingUser.getUserId()); for (OapiAttendanceListRecordResponse.Recordresult recordresult2 : recordresults) {
cardResults.add(cardResult); if(recordresult2.getUserId()!=null&&recordresult2.getUserId().equals(userId)){
}); if(recordresult2.getInvalidRecordMsg()!=null&&(!recordresult2.getInvalidRecordMsg().equals(""))){
CardAlarm cardAlarm = new CardAlarm(null,dingUser.getUserId(),"使用虚拟定位打卡");
cardAlarmDao.save(cardAlarm);
break;
}
}
}
CardResult cardResult = new CardResult(recordresult1);
cardResult.setUserId(dingUser.getUserId());
cardResults.add(cardResult);
}
}
} }
List<CardResult> cardResults1 = cardResultDao.saveAll(cardResults); List<CardResult> cardResults1 = cardResultDao.saveAll(cardResults);
computerPersonAttenDanceDay(startTime,endTime,userList,cardResults1); computerPersonAttenDanceDay(startTime,endTime,userList,cardResults1);
...@@ -561,7 +577,7 @@ public class CardTask { ...@@ -561,7 +577,7 @@ public class CardTask {
/** /**
* 定时任务,定时进行运算 * 定时任务,定时进行运算
*/ */
@Scheduled(cron = "0/30 * * * * ? ") // @Scheduled(cron = "0/30 * * * * ? ")
public void calculate() throws Exception{ public void calculate() throws Exception{
int attendanceDay = 0;//应出勤天数 int attendanceDay = 0;//应出勤天数
int averageWorkHours = 0;//平均工时 int averageWorkHours = 0;//平均工时
...@@ -591,41 +607,6 @@ public class CardTask { ...@@ -591,41 +607,6 @@ public class CardTask {
}); });
} }
} }
public static void main(String[] args) throws Exception{
// Calendar calendar = Calendar.getInstance();
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//// Date date = new Date();
// String date = "2020-03-29 11:11:11";
// String format = sdf.format(new Date());
// //计算这个月的应出勤天数
// Date parse = sdf.parse(date);
// calendar.setTime(parse);
// calendar.set(Calendar.DAY_OF_MONTH,1);
// Date time = calendar.getTime();
// System.out.println(time);
// calendar.add(Calendar.MONTH,1);
// calendar.set(Calendar.DAY_OF_MONTH,0);
// Date time1 = calendar.getTime();
// System.out.println("time1:"+time1);
// Float aFloat = CardTask.fullScore();
// System.out.println(aFloat);
String month = "2020-04";
Calendar calendar = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
String format = "2020-04-05 00:00:00";
try {
Date parse = sdf2.parse(format);
calendar.setTime(parse);
calendar.add(Calendar.DATE,-1);
Date date = sdf.parse(month);
System.out.println(calendar.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
}
/** /**
* 计算个人当月总考勤分 * 计算个人当月总考勤分
* @return * @return
......
...@@ -161,11 +161,13 @@ public class MyInit implements CommandLineRunner { ...@@ -161,11 +161,13 @@ public class MyInit implements CommandLineRunner {
} }
} }
OapiUserGetResponse user = client.execute(request, token); OapiUserGetResponse user = client.execute(request, token);
if(user.getName().equals("黄夏豪")){
System.out.println("黄夏豪:"+user.getUserid());
}
if(user!=null){ if(user!=null){
if(!dingsuerIds.contains(user.getUserid())){ if(!dingsuerIds.contains(user.getUserid())){
for (User user1 : users) { for (User user1 : users) {
if(user.getName().equals(user1.getUsername())){ if(user.getName().equals(user1.getUsername())){
logger.error(user.getUserid());
dingUserList.add(new DingUser(null,user1.getId(),user.getUserid())); dingUserList.add(new DingUser(null,user1.getId(),user.getUserid()));
} }
} }
......
...@@ -78,6 +78,17 @@ ...@@ -78,6 +78,17 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-address</artifactId>
<exclusions>
<exclusion>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-job</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -18,7 +18,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -18,7 +18,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
"com.zjty.tynotes.search", "com.zjty.tynotes.search",
"com.zjty.tynotes.redis", "com.zjty.tynotes.redis",
"com.zjty.tynotes.sms" "com.zjty.tynotes.sms"
,"com.zjty.tynotes.log" ,"com.zjty.tynotes.log",
"com.zjty.tynotes.address"
}) })
@EnableCaching @EnableCaching
@EnableScheduling @EnableScheduling
......
package com.zjty.tynotes.job.basic.service.impl; package com.zjty.tynotes.job.basic.service.impl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.zjty.tynotes.address.server.service.NoticeService;
import com.zjty.tynotes.job.basic.entity.database.ScoreCoefficient; import com.zjty.tynotes.job.basic.entity.database.ScoreCoefficient;
import com.zjty.tynotes.job.basic.entity.database.Work; import com.zjty.tynotes.job.basic.entity.database.Work;
import com.zjty.tynotes.job.basic.entity.database.WorkTime; import com.zjty.tynotes.job.basic.entity.database.WorkTime;
...@@ -25,12 +26,11 @@ import lombok.extern.slf4j.Slf4j; ...@@ -25,12 +26,11 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.validation.constraints.NotNull;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.*;
import java.util.Date; import java.util.concurrent.CompletableFuture;
import java.util.List;
import java.util.Optional;
import static java.util.Objects.isNull; import static java.util.Objects.isNull;
import static java.util.Objects.nonNull; import static java.util.Objects.nonNull;
...@@ -62,6 +62,9 @@ public class WorkServiceImpl implements WorkService { ...@@ -62,6 +62,9 @@ public class WorkServiceImpl implements WorkService {
@Autowired @Autowired
WorkTimeService workTimeService; WorkTimeService workTimeService;
@Autowired
private NoticeService noticeService;
@Autowired @Autowired
public WorkServiceImpl(WorkRepository workRepository) { public WorkServiceImpl(WorkRepository workRepository) {
this.workRepository = workRepository; this.workRepository = workRepository;
...@@ -82,6 +85,39 @@ public class WorkServiceImpl implements WorkService { ...@@ -82,6 +85,39 @@ public class WorkServiceImpl implements WorkService {
work.setGeneralManagers(jobLeads.getGeneralManagers()); work.setGeneralManagers(jobLeads.getGeneralManagers());
String saveId = workRepository.save(work).getId(); String saveId = workRepository.save(work).getId();
log.info(String.format("[job] 新增了id为 %s 的数据.", saveId)); log.info(String.format("[job] 新增了id为 %s 的数据.", saveId));
CompletableFuture.runAsync(()->{
if(work.getSuperiorId()==null){
List<String> otherIds = new ArrayList<>();
List<String> crewList = work.getCrewList();//获取组员id集合
@NotNull String publisher = work.getPublisher();
List<String> userIdList = noticeService.findUserIdList(publisher);//查找发布者下的人员id集合
if(crewList!=null){
crewList.forEach(s -> {
if(!userIdList.contains(s)){
otherIds.add(s);
System.out.println("需要请求人的id"+s);
}
});
}
//查找发布者的部门等级
String level = noticeService.findDepartLevel(publisher);
List<User> users = noticeService.findUser(level);//查找与发布者相同等级的人
if(users!=null){
Map<String,List<String>> map = noticeService.findLeadUser(users,otherIds,level);//查找所借人的id集合
if(map!=null){
Optional<Work> optional = workRepository.findById(saveId);
if(optional.isPresent()){
Work work1 = optional.get();
noticeService.submitNotice(work1.getPublisher(),map,work1.getId(),work1.getTitle());
}
}
}
}
});
return saveId; return saveId;
} else { } else {
String msg = "[job] %s: 新增数据不可附带id."; String msg = "[job] %s: 新增数据不可附带id.";
......
...@@ -6,12 +6,12 @@ import org.springframework.context.annotation.ComponentScan; ...@@ -6,12 +6,12 @@ import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication @SpringBootApplication
@ComponentScan(basePackages = { @ComponentScan(basePackages = {
"com.zjty.tynotes.misc", // "com.zjty.tynotes.misc",
"com.zjty.tynotes.pas", "com.zjty.tynotes.pas",
"com.zjty.tynotes.log", "com.zjty.tynotes.log"
"com.zjty.tynotes.search", // "com.zjty.tynotes.search",
"com.zjty.tynotes.redis", // "com.zjty.tynotes.redis",
"com.zjty.tynotes.sms" // "com.zjty.tynotes.sms"
// "com.zjty.tynotes.weekly" // "com.zjty.tynotes.weekly"
// ,"com.zjty.tynotes.attendance" // ,"com.zjty.tynotes.attendance"
}) })
......
...@@ -7,14 +7,19 @@ import cn.afterturn.easypoi.excel.entity.ImportParams; ...@@ -7,14 +7,19 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.zjty.tynotes.misc.config.AutoDocument; import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.misc.utils.ExcelUtil; import com.zjty.tynotes.misc.utils.ExcelUtil;
import com.zjty.tynotes.pas.dao.PasUserDao;
import com.zjty.tynotes.pas.entity.Address;
import com.zjty.tynotes.pas.entity.Department; import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.User; import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.ImportUserExcel;
import com.zjty.tynotes.pas.service.IUserService; import com.zjty.tynotes.pas.service.IUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -23,12 +28,15 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -23,12 +28,15 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.springframework.http.ResponseEntity.ok;
/** /**
* @Author gwj * @Author gwj
* @create 2020/4/24 9:36 * @create 2020/4/24 9:36
...@@ -41,17 +49,45 @@ import java.util.stream.Collectors; ...@@ -41,17 +49,45 @@ import java.util.stream.Collectors;
public class ExcelController { public class ExcelController {
@Autowired @Autowired
private IUserService iUserService; private IUserService iUserService;
@Autowired
private PasUserDao pasUserDao;
@Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;
private String addressUrl = "C:\\Users\\gwj\\Desktop\\工作簿\\address.xls";
@ApiOperation(value = "上传excel通讯录") @ApiOperation(value = "上传excel通讯录")
@PostMapping("/import") @PostMapping("/import")
public List<ImportUserExcel> upload(@RequestParam("file") MultipartFile multipartFile) throws Exception { public List<Address> upload(@RequestParam("file") MultipartFile multipartFile,HttpServletRequest request,HttpServletResponse response) throws Exception {
ImportParams params = new ImportParams(); ImportParams params = new ImportParams();
params.setHeadRows(2); params.setHeadRows(1);
params.setNeedVerfiy(true); // params.setNeedVerfiy(true);
// params.setTitleRows(0); params.setTitleRows(1);
List<ImportUserExcel> result = ExcelImportUtil.importExcel(multipartFile.getInputStream(), List<Address> result = ExcelImportUtil.importExcel(multipartFile.getInputStream(),
ImportUserExcel.class, params); Address.class, params);
System.out.println(result); List<User> users = new ArrayList<>();
if(result!=null){
result.forEach(address -> {
User user = pasUserDao.findByUsername(address.getName());
if(user==null){
User user1 = new User(address);
user1.setPassword(bCryptPasswordEncoder.encode("qwer1234"));
boolean flag = true;
if(users!=null){
for (User user2 : users) {
if(user2.getUsername().equals(address.getName())){
flag = false;
}
}
}
if(flag){
users.add(user1);
}
}
});
}
pasUserDao.saveAll(users);
return result; return result;
} }
...@@ -63,19 +99,18 @@ public class ExcelController { ...@@ -63,19 +99,18 @@ public class ExcelController {
//构建创建导出excel表格所需要的Workbook对象的map //构建创建导出excel表格所需要的Workbook对象的map
//源数据 //源数据
List<User> users = iUserService.findAll(); List<User> users = iUserService.findAll();
List<ImportUserExcel> importUserExcels = new ArrayList<>(); List<Address> addresses = new ArrayList<>();
if(users!=null){ if(users!=null){
users.forEach(user -> { users.forEach(user -> {
importUserExcels.add(new ImportUserExcel(user)); addresses.add(new Address(user));
}); });
} }
Map<String, Object> map = new HashMap<>(8); Map<String, Object> map = new HashMap<>(8);
String FpName="用户通讯录"; String FpName="用户通讯录";
map.put("subFpName", FpName); map.put("subFpName", FpName);
map.put("title", new ExportParams(FpName,FpName)); map.put("title", new ExportParams(FpName,FpName));
map.put("entity", ImportUserExcel.class); map.put("entity", Address.class);
map.put("data",importUserExcels); map.put("data",addresses);
excelList.add(map); excelList.add(map);
Workbook workbook = ExcelExportUtil.exportExcel(excelList, ExcelType.HSSF); Workbook workbook = ExcelExportUtil.exportExcel(excelList, ExcelType.HSSF);
...@@ -83,4 +118,45 @@ public class ExcelController { ...@@ -83,4 +118,45 @@ public class ExcelController {
ExcelUtil.downloadExcel(request, response, workbook, FpName); ExcelUtil.downloadExcel(request, response, workbook, FpName);
} }
@ApiOperation(value = "下载通讯录模板")
@PostMapping("/download")
public ResponseEntity download(HttpServletRequest request, HttpServletResponse response) throws Exception {
String filename="address.xls";
File file = new File(addressUrl);
System.out.println(addressUrl);
System.out.println("存在??");
if(file.exists()){ //判断文件父目录是否存在
System.out.println("存在???");
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(filename,"UTF-8"));
byte[] buffer = new byte[1024];
FileInputStream fis = null; //文件输入流
BufferedInputStream bis = null;
OutputStream os = null; //输出流
try {
os = response.getOutputStream();
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
int i = bis.read(buffer);
while(i != -1){
os.write(buffer);
i = bis.read(buffer);
}
return ok("下载成功");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("----------file download---" + filename);
try {
bis.close();
fis.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return ok("下载失败");
}
} }
package com.zjty.tynotes.pas.controller; package com.zjty.tynotes.pas.controller;
import com.zjty.tynotes.misc.config.AutoDocument; import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.dao.AuthorityDao; import com.zjty.tynotes.pas.dao.*;
import com.zjty.tynotes.pas.dao.DayDao; import com.zjty.tynotes.pas.entity.*;
import com.zjty.tynotes.pas.dao.RoleAuthorityDao;
import com.zjty.tynotes.pas.dao.RoleDao;
import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.entity.Day;
import com.zjty.tynotes.pas.entity.Role;
import com.zjty.tynotes.pas.entity.RoleAuthority;
import com.zjty.tynotes.pas.entity.vo.JobLeads; import com.zjty.tynotes.pas.entity.vo.JobLeads;
import com.zjty.tynotes.pas.service.IUserService; import com.zjty.tynotes.pas.service.IUserService;
import com.zjty.tynotes.pas.service.impl.UserServiceImpl; import com.zjty.tynotes.pas.service.impl.UserServiceImpl;
...@@ -38,6 +32,8 @@ public class TestController { ...@@ -38,6 +32,8 @@ public class TestController {
private RoleAuthorityDao roleAuthorityDao; private RoleAuthorityDao roleAuthorityDao;
@Autowired @Autowired
private UserServiceImpl userService; private UserServiceImpl userService;
@Autowired
private PasUserDao pasUserDao;
// @GetMapping("/test") // @GetMapping("/test")
// public void calculate() throws Exception{ // public void calculate() throws Exception{
...@@ -88,5 +84,33 @@ public class TestController { ...@@ -88,5 +84,33 @@ public class TestController {
return jobLeads; return jobLeads;
} }
@GetMapping("/test2/delete")
public void delete() throws Exception{
List<User> all = pasUserDao.findAll();
if(all!=null){
all.forEach(user -> {
if(user.getUsername()==null){
pasUserDao.deleteById(user.getId());
}
});
}
}
@GetMapping("/test2/showName")
public void showName() throws Exception{
List<User> all = pasUserDao.findAll();
List<String> names = new ArrayList<>();
if(all!=null){
all.forEach(user -> {
if(names.contains(user.getUsername())){
System.out.println(user.getUsername());
}else {
names.add(user.getUsername());
}
});
}
}
} }
...@@ -10,7 +10,8 @@ import java.util.List; ...@@ -10,7 +10,8 @@ import java.util.List;
* @create 2020/2/29 9:42 * @create 2020/2/29 9:42
*/ */
public interface DepartmentDao extends MongoRepository<Department,String> { public interface DepartmentDao extends MongoRepository<Department,String> {
List<Department> findByLevel(String level);
List<Department> findAllByLevel(String level);
List<Department> findAllByParentId(String parentId); List<Department> findAllByParentId(String parentId);
......
...@@ -81,4 +81,6 @@ public interface PasUserDao extends MongoRepository<User, String> { ...@@ -81,4 +81,6 @@ public interface PasUserDao extends MongoRepository<User, String> {
*/ */
List<User> findAllByStatus(String status); List<User> findAllByStatus(String status);
List<User> findAllByDepartmentIdsContains(String departId);
} }
...@@ -33,4 +33,6 @@ public interface RoleDao extends MongoRepository<Role, String> { ...@@ -33,4 +33,6 @@ public interface RoleDao extends MongoRepository<Role, String> {
*/ */
List<Role> findAllByIdInAndIsLeader(List<String> ids,String isLeader); List<Role> findAllByIdInAndIsLeader(List<String> ids,String isLeader);
List<Role> findAllByDepartmentIdInAndIsLeader(List<String> ids,String isLeader);
} }
package com.zjty.tynotes.pas.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* @Author gwj
* @create 2020/5/13 8:46
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "通讯录", description = "通讯录说明")
public class Address {
@Excel(name = "姓名")
@ApiModelProperty(value = "姓名",example = "gwj")
private String name;
@Excel(name = "职务")
@ApiModelProperty(value = "职务",example = "后端程序员")
private String duty;
@Excel(name = "手机")
@ApiModelProperty(value = "手机号",example = "13211111111")
private String telphone;
@Excel(name = "邮箱")
@ApiModelProperty(value = "邮箱",example = "1@1.com")
private String email;
@Excel(name = "手机虚拟号")
@ApiModelProperty(value = "短号",example = "666666")
private String shortphone;
@Excel(name = "工号")
@ApiModelProperty(value = "工号",example = "1111111111111")
private String workerNum;
public Address(User user) {
this.workerNum = user.getWorkerNum();
this.name = user.getUsername();
this.duty = user.getJobs();
this.telphone = user.getPhone1();
// this.shortphone = user.getPhone2();
this.email = user.getEmail();
}
}
...@@ -39,7 +39,7 @@ public class Role { ...@@ -39,7 +39,7 @@ public class Role {
@ApiModelProperty(value = "部门id",example = "1") @ApiModelProperty(value = "部门id",example = "1")
private String departmentId; private String departmentId;
@ApiModelProperty(value = "是否领导",example = "1") @ApiModelProperty(value = "是否领导,0代表是该部门领导,1代表为该部门普通员工",example = "1")
private String isLeader;//0代表是该部门领导,1代表为该部门普通员工 private String isLeader;//0代表是该部门领导,1代表为该部门普通员工
@ApiModelProperty(value = "正副经理0为正,1为副",example = "1") @ApiModelProperty(value = "正副经理0为正,1为副",example = "1")
......
...@@ -39,9 +39,13 @@ public class User implements UserDetails, Serializable { ...@@ -39,9 +39,13 @@ public class User implements UserDetails, Serializable {
private String id; private String id;
@NotEmpty(message = "身份证号码不可为空") @NotEmpty(message = "身份证号码不可为空")
@ApiModelProperty(value = "身份证",example = "48489498131566546") @ApiModelProperty(value ="身份证",example = "48489498131566546")
private String idCard; private String idCard;
@NotEmpty(message = "工号不可为空")
@ApiModelProperty(value = "工号",example = "11111111111111111")
private String workerNum;
@NotEmpty(message = "地址不可为空") @NotEmpty(message = "地址不可为空")
@ApiModelProperty(value = "地址",example = "xx路xx楼xx号") @ApiModelProperty(value = "地址",example = "xx路xx楼xx号")
private String address; private String address;
...@@ -160,4 +164,14 @@ public class User implements UserDetails, Serializable { ...@@ -160,4 +164,14 @@ public class User implements UserDetails, Serializable {
return this; return this;
} }
public User(Address address) {
this.workerNum = address.getWorkerNum();
this.username = address.getName();
this.phone1 = address.getTelphone();
this.jobs = address.getDuty();
this.phone2 = address.getTelphone();
// this.phone2 = address.getShortphone();
this.email = address.getEmail();
}
} }
package com.zjty.tynotes.pas.entity.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.zjty.tynotes.pas.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author gwj
* @create 2020/4/24 9:33
* @des 导入excel模板的实体类
*/
@Data
@AllArgsConstructor
public class ImportUserExcel {
@Excel(name = "姓名*")
private String name;
@Excel(name = "性别*",replace = {"男_0","女_1"})
private Integer gender;
@Excel(name = "手机号*")
private String phone;
public ImportUserExcel(User user) {
this.name = user.getUsername();
this.phone = user.getPhone1();
}
}
...@@ -67,7 +67,7 @@ public class DepartmentServiceImpl implements IDepartmentService { ...@@ -67,7 +67,7 @@ public class DepartmentServiceImpl implements IDepartmentService {
@Override @Override
@Transactional @Transactional
public List<Department> findList() { public List<Department> findList() {
List<Department> departments = departmentDao.findByLevel("1"); List<Department> departments = departmentDao.findAllByLevel("1");
Department department = null; Department department = null;
if(departments==null||departments.size()==0){ if(departments==null||departments.size()==0){
Department department1 = new Department(null,"泰源","1","泰源",null,null,null); Department department1 = new Department(null,"泰源","1","泰源",null,null,null);
......
...@@ -69,6 +69,12 @@ public class Init implements CommandLineRunner { ...@@ -69,6 +69,12 @@ public class Init implements CommandLineRunner {
if (!authorityName.contains("查看人员")) { if (!authorityName.contains("查看人员")) {
authorities1.add(new Authority(null, "查看人员", "能够查看人员")); authorities1.add(new Authority(null, "查看人员", "能够查看人员"));
} }
if (!authorityName.contains("审批管理")) {
authorities1.add(new Authority(null, "审批管理", "能够查看请假审批、加班审批"));
}
if (!authorityName.contains("部门统计")) {
authorities1.add(new Authority(null, "部门统计", "能够查看部门任务"));
}
if (authorities1 != null) { if (authorities1 != null) {
authorityDao.saveAll(authorities1); authorityDao.saveAll(authorities1);
} }
......
...@@ -10,4 +10,9 @@ public interface MessageTemplateService { ...@@ -10,4 +10,9 @@ public interface MessageTemplateService {
* 对相关人员推送通知 * 对相关人员推送通知
*/ */
void beingPushed(String receive,String destination,String payload); void beingPushed(String receive,String destination,String payload);
/**
* 借用人员通知信息
*/
void noticePushed(String receive ,String payload);
} }
...@@ -27,6 +27,11 @@ public class MessageTemplateServiceImpl implements MessageTemplateService { ...@@ -27,6 +27,11 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
this.sendToUser(receive, destination, payload); this.sendToUser(receive, destination, payload);
} }
@Override
public void noticePushed(String receive, String payload) {
this.sendToUser(receive, "/topic/notice", payload);
}
/** /**
* 给指定用户发送消息,并处理接收者不在线的情况 * 给指定用户发送消息,并处理接收者不在线的情况
* *
......
...@@ -106,6 +106,11 @@ ...@@ -106,6 +106,11 @@
<artifactId>notes-log</artifactId> <artifactId>notes-log</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-address</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
......
...@@ -27,7 +27,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -27,7 +27,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
"com.zjty.tynotes.weekly", "com.zjty.tynotes.weekly",
"com.zjty.tynotes.misc", "com.zjty.tynotes.misc",
"com.zjty.tynotes.union", "com.zjty.tynotes.union",
"com.zjty.tynotes.log" "com.zjty.tynotes.log",
"com.zjty.tynotes.address"
// , "com.zjty.tynotes.attendance" // , "com.zjty.tynotes.attendance"
}) })
@EnableCaching @EnableCaching
......
...@@ -3,24 +3,25 @@ spring.application.name=workbook ...@@ -3,24 +3,25 @@ spring.application.name=workbook
## https端口号. ## https端口号.
server.port=8289 server.port=8289
# 证书的路径. # 证书的路径.
#server.ssl.key-store=classpath:2586377_workbook.zjtys.com.cn.pfx server.ssl.key-store=classpath:2586377_workbook.zjtys.com.cn.pfx
## 证书密码,请修改为您自己证书的密码. # 证书密码,请修改为您自己证书的密码.
#server.ssl.key-store-password=bMEPW9BG server.ssl.key-store-password=bMEPW9BG
## 秘钥库类型 # 秘钥库类型
#server.ssl.keyStoreType=PKCS12 server.ssl.keyStoreType=PKCS12
## 证书别名 # 证书别名
#server.ssl.keyAlias= alias server.ssl.keyAlias= alias
#mongodb configuration #mongodb configuration
spring.data.mongodb.uri=mongodb://192.168.1.246:27017/notes5 spring.data.mongodb.uri=mongodb://localhost:27017/notes5
# servlet configuration # servlet configuration
spring.servlet.multipart.max-file-size=100MB spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=1000MB spring.servlet.multipart.max-request-size=1000MB
spring.redis.host=192.168.1.246 spring.redis.host=localhost
spring.redis.port=6379 spring.redis.port=6379
spring.redis.timeout=5000ms spring.redis.timeout=5000ms
# es configuraiton # es configuraiton
es.ip=192.168.1.246 es.ip=localhost
logging.file=./log/note.log logging.file=./log/note.log
...@@ -16,4 +16,5 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -16,4 +16,5 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
}) })
@EnableSwagger2 @EnableSwagger2
public class WeeklyApplication { public class WeeklyApplication {
} }
...@@ -4,9 +4,11 @@ import com.zjty.tynotes.log.entity.Log; ...@@ -4,9 +4,11 @@ import com.zjty.tynotes.log.entity.Log;
import com.zjty.tynotes.log.server.LogService; import com.zjty.tynotes.log.server.LogService;
import com.zjty.tynotes.misc.config.AutoDocument; import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.base.advise.Content; import com.zjty.tynotes.pas.base.advise.Content;
import com.zjty.tynotes.pas.entity.Address;
import com.zjty.tynotes.pas.entity.User; import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest; import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse; import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.entity.vo.AddressRequest;
import com.zjty.tynotes.weekly.subject.entity.vo.Problem; import com.zjty.tynotes.weekly.subject.entity.vo.Problem;
import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo; import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo;
import com.zjty.tynotes.weekly.subject.entity.vo.UserVo; import com.zjty.tynotes.weekly.subject.entity.vo.UserVo;
...@@ -23,7 +25,10 @@ import org.springframework.security.core.Authentication; ...@@ -23,7 +25,10 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -141,16 +146,16 @@ public class UserManageController { ...@@ -141,16 +146,16 @@ public class UserManageController {
} }
@ApiOperation(value = "查询通讯录基本信息") @ApiOperation(value = "查询通讯录基本信息")
@GetMapping("/findAddressBook") @PostMapping("/findAddressBook")
public ResponseEntity findAddressBook(){ public ResponseEntity findAddressBook(@RequestBody AddressRequest addressRequest){
try { try {
List<SimpleUserVo> simpleUserVos = userManageService.findAddressBook(); PageResponse pageResponse = userManageService.findAddressBook(addressRequest);
return ok(simpleUserVos); return ok(pageResponse);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
logger.error("查询通讯录信息失败"); logger.error("查询通讯录信息失败");
} }
return ok("查询通讯录信息失败"); return ok("查询通讯录信息失败");
} }
} }
package com.zjty.tynotes.weekly.subject.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author gwj
* @create 2020/5/13 10:18
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AddressRequest {
/**
* 每页显示个数
*/
private int pageSize;
/**
* 当前页数
*/
private int currentPage;
}
package com.zjty.tynotes.weekly.subject.service; package com.zjty.tynotes.weekly.subject.service;
import com.zjty.tynotes.pas.entity.Address;
import com.zjty.tynotes.pas.entity.Department; import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.User; import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest; import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse; import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.entity.vo.AddressRequest;
import com.zjty.tynotes.weekly.subject.entity.vo.Problem; import com.zjty.tynotes.weekly.subject.entity.vo.Problem;
import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo; import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo;
import com.zjty.tynotes.weekly.subject.entity.vo.UserVo; import com.zjty.tynotes.weekly.subject.entity.vo.UserVo;
import org.springframework.web.multipart.MultipartFile;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
...@@ -83,7 +86,8 @@ public interface UserManageService { ...@@ -83,7 +86,8 @@ public interface UserManageService {
* 查询通讯录信息 * 查询通讯录信息
* @return * @return
*/ */
List<SimpleUserVo> findAddressBook(); PageResponse findAddressBook(AddressRequest addressRequest);
// /** // /**
// * 根据任务状态查询人员任务列表 // * 根据任务状态查询人员任务列表
......
...@@ -10,6 +10,7 @@ import com.zjty.tynotes.pas.entity.*; ...@@ -10,6 +10,7 @@ import com.zjty.tynotes.pas.entity.*;
import com.zjty.tynotes.pas.entity.vo.PageRequest; import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse; import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.dao.ProblemDao; import com.zjty.tynotes.weekly.subject.dao.ProblemDao;
import com.zjty.tynotes.weekly.subject.entity.vo.AddressRequest;
import com.zjty.tynotes.weekly.subject.entity.vo.Problem; import com.zjty.tynotes.weekly.subject.entity.vo.Problem;
import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo; import com.zjty.tynotes.weekly.subject.entity.vo.SimpleUserVo;
import com.zjty.tynotes.weekly.subject.entity.vo.UserVo; import com.zjty.tynotes.weekly.subject.entity.vo.UserVo;
...@@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -351,19 +353,49 @@ public class UserManageServiceImpl implements UserManageService { ...@@ -351,19 +353,49 @@ public class UserManageServiceImpl implements UserManageService {
* @return * @return
*/ */
@Override @Override
public List<SimpleUserVo> findAddressBook() { public PageResponse findAddressBook(AddressRequest addressRequest) {
PageResponse pageResponse = new PageResponse();
List<User> users = pasUserDao.findAll(); List<User> users = pasUserDao.findAll();
List<SimpleUserVo> userList = new ArrayList<>(); List<Address> userList = new ArrayList<>();
List<Address> addressList = new ArrayList<>();
if(users!=null){ if(users!=null){
users.forEach(user -> { users.forEach(user -> {
if(user.getUsername()!="root" && user.getUsername()!="HR"){ if((!user.getUsername().equals("root")) && (!user.getUsername().equals("HR"))){
userList.add(new SimpleUserVo(user)); userList.add(new Address(user));
} }
}); });
} }
return userList; if(addressRequest.getCurrentPage()<1){
addressRequest.setCurrentPage(1);
}
int totalPage = 1;
int totalCount = 0;
if(userList.size()==0){
totalPage = 1;
}else if(userList.size()%addressRequest.getPageSize()==0){
totalPage = userList.size()/(addressRequest.getPageSize());
}else{
totalPage = userList.size()/(addressRequest.getPageSize())+1;
}
int currentPage = addressRequest.getCurrentPage();
int pageSize = addressRequest.getPageSize();
if(userList.size()>(currentPage*pageSize)){
addressList = userList.subList((currentPage-1)*pageSize,currentPage*pageSize);
}else if(userList.size()<(currentPage-1)*pageSize){
addressList = new ArrayList<>();
}else {
addressList = userList.subList((currentPage-1)*pageSize,userList.size());
}
totalCount = userList.size();
pageResponse.setCurrentPage(addressRequest.getCurrentPage());
pageResponse.setPageSize(addressRequest.getPageSize());
pageResponse.setTotalCount(totalCount);
pageResponse.setTotalPage(totalPage);
pageResponse.setRows(addressList);
return pageResponse;
} }
/** /**
* 暂时没有用到 * 暂时没有用到
* @param des * @param des
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
<module>notes-weekly</module> <module>notes-weekly</module>
<module>notes-attendance</module> <module>notes-attendance</module>
<module>notes-log</module> <module>notes-log</module>
<module>notes-address</module>
</modules> </modules>
<dependencyManagement> <dependencyManagement>
...@@ -104,6 +105,12 @@ ...@@ -104,6 +105,12 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.zjty.tynotes</groupId>
<artifactId>notes-address</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论