first commit

This commit is contained in:
lijiazhuo
2025-08-25 14:17:26 +08:00
commit 935c725d7b
55 changed files with 5936 additions and 0 deletions

31
.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
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/

118
.mvn/wrapper/MavenWrapperDownloader.java vendored Normal file
View File

@ -0,0 +1,118 @@
/*
* Copyright 2012-2019 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.5";
/**
* 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();
}
}

BIN
.mvn/wrapper/maven-wrapper.jar vendored Normal file

Binary file not shown.

2
.mvn/wrapper/maven-wrapper.properties vendored Normal file
View File

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar

14
README.md Normal file
View File

@ -0,0 +1,14 @@
项目概述:
此项目为国旅的项目《好多功能以废弃,目前只剩下一个人员更新
对接人:
卢飞
项目主要为定时:
@Scheduled(cron = "0 0 18 * * ?")
public void main1() {
。。。。。
}

322
mvnw vendored Normal file
View File

@ -0,0 +1,322 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ]; then
if [ -f /etc/mavenrc ]; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ]; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false
darwin=false
mingw=false
case "$(uname)" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true ;;
Darwin*)
darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="$(/usr/libexec/java_home)"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ]; then
if [ -r /etc/gentoo-release ]; then
JAVA_HOME=$(java-config --jre-home)
fi
fi
if [ -z "$M2_HOME" ]; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ]; do
ls=$(ls -ld "$PRG")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' >/dev/null; then
PRG="$link"
else
PRG="$(dirname "$PRG")/$link"
fi
done
saveddir=$(pwd)
M2_HOME=$(dirname "$PRG")/..
# make it fully qualified
M2_HOME=$(cd "$M2_HOME" && pwd)
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=$(cygpath --unix "$M2_HOME")
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw; then
[ -n "$M2_HOME" ] &&
M2_HOME="$( (
cd "$M2_HOME"
pwd
))"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="$( (
cd "$JAVA_HOME"
pwd
))"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="$(which javac)"
if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=$(which readlink)
if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then
if $darwin; then
javaHome="$(dirname \"$javaExecutable\")"
javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac"
else
javaExecutable="$(readlink -f \"$javaExecutable\")"
fi
javaHome="$(dirname \"$javaExecutable\")"
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ]; then
if [ -n "$JAVA_HOME" ]; then
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="$(which java)"
fi
fi
if [ ! -x "$JAVACMD" ]; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ]; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]; then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ]; do
if [ -d "$wdir"/.mvn ]; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=$(
cd "$wdir/.."
pwd
)
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' <"$1")"
fi
}
BASE_DIR=$(find_maven_basedir "$(pwd)")
if [ -z "$BASE_DIR" ]; then
exit 1
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
fi
while IFS="=" read key value; do
case "$key" in wrapperUrl)
jarUrl="$value"
break
;;
esac
done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
fi
if command -v wget >/dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl >/dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=$(cygpath --path --windows "$javaClass")
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=$(cygpath --path --windows "$M2_HOME")
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

182
mvnw.cmd vendored Normal file
View File

@ -0,0 +1,182 @@
@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 Maven2 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 key stroke 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.5/maven-wrapper-0.5.5.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.5/maven-wrapper-0.5.5.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%

68
pom.xml Normal file
View File

@ -0,0 +1,68 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>sso</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sso</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.45</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,17 @@
package com.example.sso;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
@EnableAsync
public class SsoApplication {
public static void main(String[] args) {
SpringApplication.run(SsoApplication.class, args);
}
}

View File

@ -0,0 +1,53 @@
package com.example.sso.config;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
@EnableAsync
public class AsyncConfig implements AsyncConfigurer {
// ThredPoolTaskExcutor的处理流程
// 当池子大小小于corePoolSize就新建线程并处理请求
// 当池子大小等于corePoolSize把请求放入workQueue中池子里的空闲线程就去workQueue中取任务并处理
// 当workQueue放不下任务时就新建线程入池并处理请求如果池子大小撑到了maximumPoolSize就用RejectedExecutionHandler来做拒绝处理
// 当池子的线程数大于corePoolSize时多余的线程会等待keepAliveTime长时间如果无请求可处理就自行销毁
@Override
@Bean
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// 核心线程数:线程池创建的时候初始化的线程数
executor.setCorePoolSize(30);
// 最大线程数:线程池最大的线程数,只有缓冲队列满了之后才会申请超过核心线程数的线程
executor.setMaxPoolSize(100);
// 缓冲队列:用来缓冲执行任务的队列
executor.setQueueCapacity(50);
// 线程池关闭:等待所有任务都完成再关闭
executor.setWaitForTasksToCompleteOnShutdown(true);
// 等待时间等待5秒后强制停止
executor.setAwaitTerminationSeconds(5);
// 允许空闲时间超过核心线程之外的线程到达60秒后会被销毁
executor.setKeepAliveSeconds(60);
// 线程名称前缀
executor.setThreadNamePrefix("fadada");
// 缓冲队列满了之后的拒绝策略:由调用线程处理(一般是主线程)
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// 初始化线程
executor.initialize();
return executor;
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return null;
}
}

View File

@ -0,0 +1,23 @@
package com.example.sso.config;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
//import javax.validation.constraints.NotBlank;
@Configuration
@ConfigurationProperties(prefix = "sso")
@NoArgsConstructor
@AllArgsConstructor
@Validated
@Getter
@Setter
public class SSOConfig {
private String acs;
private String secret;
}

View File

@ -0,0 +1,117 @@
package com.example.sso.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.config.SSOConfig;
import com.example.sso.dao.J9051Dao;
import com.example.sso.dao.J9052Dao;
import com.example.sso.dao.J9053Dao;
import com.example.sso.dao.J905Dao;
import com.example.sso.service.JDYAuthService;
import com.example.sso.service.SSOService;
import com.example.sso.util.BeiSenTest;
import com.example.sso.util.J905Util;
import com.example.sso.util.JDYUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.HashMap;
@RestController
@NoArgsConstructor
@AllArgsConstructor
class BeiSenController {
@Getter @Setter @Autowired private SSOConfig ssoConfig;
private JSONObject limitIpInfo_dep1 = new JSONObject();
private JSONObject limitIpInfo_dep2 = new JSONObject();
private JSONObject limitIpInfo_dep3 = new JSONObject();
private JSONObject limitIpInfo_dep4 = new JSONObject();
private JSONObject limitIpInfo_dep5 = new JSONObject();
private JSONObject limitIpInfo_dep6 = new JSONObject();
@Getter @Setter @Autowired private SSOService ssoService;
@Getter @Setter @Autowired private JDYAuthService jdyAuthService;
Logger logger = LoggerFactory.getLogger(getClass());
/**
* 创建人员信息
a */
@GetMapping("/createPerson")
public void yxMes() throws KeyManagementException, NoSuchAlgorithmException {
try {
JSONArray drivers=JDYUtil.getAllDrivers();//查询
for (Object o:drivers){
JSONObject driver=(JSONObject)o;
JSONObject orgNos=JDYUtil.getOrgNos();
BeiSenTest.createUser(driver,orgNos,"");
}
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* 接收简道云新增的人员数据
*/
@PostMapping("/createPerson_jdy")
public void yxMes3(@RequestBody JSONObject driver){
try {
logger.info(driver.toJSONString());
if (driver.getJSONObject("data").getString("status").equals("已择车") ||
driver.getJSONObject("data").getString("status").equals("运营")){
//if (driver.getJSONObject("data").getString("status").equals("运营")){
//这个情况说明上车,创建账户
JSONObject orgNos=JDYUtil.getOrgNos();
JSONObject data=driver.getJSONObject("data");
BeiSenTest.createUser(data,orgNos,driver.getJSONObject("data").getString("_id"));
}else if (driver.getJSONObject("data").getString("status").equals("已下车")){
//}else if (driver.getJSONObject("data").getString("status").equals("已下车")||
//driver.getJSONObject("data").getString("status").equals("休医疗期")){
BeiSenTest.deleteUser(driver.getJSONObject("data").getInteger("beisen_id"));
}
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* 更新人员数据信息,修护职务、身份证号码信息
*/
@GetMapping("/updatePersonData")
public void yxMes2(){
//修改职工基础信息数据
try {
JSONArray beiSens = JDYUtil.getAllDriversBeiSen();//查询
JSONArray drivers = JDYUtil.getAllDrivers();//查询
JSONObject orgNos=JDYUtil.getOrgNos();
JSONObject jsonObject = new JSONObject();
for (Object o : drivers) {
HashMap<String, Object> driver = (HashMap<String, Object>) o;
jsonObject.put((String) driver.get("shjh") + "@yinjian.com", driver);
}
for (Object o : beiSens) {
JSONObject driver = (JSONObject) o;
if (jsonObject.getJSONObject(driver.getString("zhanghao"))!=null){
// BeiSenTest.updateUser(driver,driver.getString("oid"),orgNos);
// System.out.println(jsonObject.getJSONObject(driver.getString("zhanghao")));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,77 @@
package com.example.sso.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.dao.GongZiFaFang;
import com.example.sso.dao.UpDataYes;
import com.example.sso.util.GongZiUtil;
import com.example.sso.util.V5utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
public class GongZiController {
@PostMapping("/gongzi")
public String gongzi(@RequestBody JSONObject driver){
log.info(driver.toJSONString());
log.info("------------------------------------------------------------");
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
jsonObject.put("entry_id", "62f4913c82654a00085de9e4");
jsonObject.put("limit",10000);
JSONArray fields = new JSONArray();
fields.add("yuefen");
fields.add("status_jiaoyan");
fields.add("sijishenfenzhenghao");
fields.add("jine");
fields.add("yinhangkahao");
fields.add("status_yinhang");
JSONObject filter = new JSONObject();
filter.put("rel","and");
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("field","status_jiaoyan");
jsonObject1.put("method","empty");
jsonArray.add(jsonObject1);
filter.put("cond",jsonArray);
jsonObject.put("fields",fields);
jsonObject.put("filter",filter);
String jsonString = jsonObject.toJSONString();
String list = V5utils.list(jsonString);
JSONObject jsonObject2 = JSON.parseObject(list);
JSONArray jsonArray1 = jsonObject2.getJSONArray("data");
String yuefen = GongZiUtil.yuefen();
for (Object o : jsonArray1){
JSONObject test = (JSONObject) o;
String yuefen1 = test.getString("yuefen");
String sijishenfenzhenghao = test.getString("sijishenfenzhenghao");
Integer jine = test.getInteger("jine");
String yinhangkahao = test.getString("yinhangkahao");
String status_yinhang = test.getString("status_yinhang");
String id = test.getString("_id");
if (yuefen.equals(yuefen1)){
String fafang = GongZiFaFang.fafang(yuefen1, sijishenfenzhenghao, jine, yinhangkahao, status_yinhang);
log.info(fafang);
UpDataYes.updata(id);
}
}
return "Success";
}
}

View File

@ -0,0 +1,90 @@
package com.example.sso.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.dao.GuoLvSelect;
import com.example.sso.util.BeiSenTest;
import com.example.sso.util.JDYUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
@Slf4j
@RestController
public class GuoLvController {
@PostMapping("/createPersonGuoLv")
public String yxMes(@RequestBody JSONObject datas) {
String jsonString = datas.toJSONString();
log.info(jsonString);
JSONObject jsonObject = datas.getJSONObject("data");
String xm = jsonObject.getString("xm");
String shfzhh = jsonObject.getString("shfzhh");
String shjh = jsonObject.getString("shjh");
String beisenId = jsonObject.getString("beisen_id");
String yxbs = jsonObject.getString("yxbs");
String sfjsy = jsonObject.getString("sfjsy");
String dlrzt = jsonObject.getString("dlrzt");
String fs = jsonObject.getString("fs");
String widget1723106903113 = jsonObject.getString("_widget_1723106903113");
String dataid = jsonObject.getString("_id");
try {
JSONObject orgNos = JDYUtil.getOrgNos();
BeiSenTest.createUserss(xm,yxbs,shfzhh,shjh,fs,beisenId,orgNos,dataid);
} catch (Exception e) {
e.printStackTrace();
}
return "成功了";
}
@PostMapping("/deleteuser")
public String yxMes11(@RequestBody JSONObject datas) throws NoSuchAlgorithmException, KeyManagementException {
String jsonString = datas.toJSONString();
log.info(jsonString);
JSONObject jsonObject = datas.getJSONObject("data");
String xm = jsonObject.getString("xm");
String shfzhh = jsonObject.getString("shfzhh");
String shjh = jsonObject.getString("shjh");
String beisenId = jsonObject.getString("beisen_id");
String yxbs = jsonObject.getString("yxbs");
String sfjsy = jsonObject.getString("sfjsy");
String dlrzt = jsonObject.getString("dlrzt");
String fs = jsonObject.getString("fs");
String widget1723106903113 = jsonObject.getString("_widget_1723106903113");
String dataid = jsonObject.getString("_id");
if (!sfjsy.equals("") && dlrzt.equals("已停用") && !dlrzt.isEmpty() ) {
Integer i = Integer.parseInt(beisenId);
BeiSenTest.deleteUser(i);
}
if (dlrzt.equals("启用") && !dlrzt.isEmpty() ) {
try {
JSONObject orgNos = JDYUtil.getOrgNos();
BeiSenTest.createUserss(xm,yxbs,shfzhh,shjh,fs,beisenId,orgNos,dataid);
} catch (Exception e) {
e.printStackTrace();
}
}
return "完成了";
}
}

View File

@ -0,0 +1,365 @@
package com.example.sso.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.config.SSOConfig;
import com.example.sso.dao.J9051Dao;
import com.example.sso.dao.J9052Dao;
import com.example.sso.dao.J9053Dao;
import com.example.sso.dao.J905Dao;
import com.example.sso.service.*;
import com.example.sso.util.J905Util;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
@RestController
@NoArgsConstructor
@AllArgsConstructor
class SSOController {
@Getter @Setter @Autowired private SSOConfig ssoConfig;
private JSONObject limitIpInfo_dep1 = new JSONObject();
private JSONObject limitIpInfo_dep2 = new JSONObject();
private JSONObject limitIpInfo_dep3 = new JSONObject();
private JSONObject limitIpInfo_dep4 = new JSONObject();
private JSONObject limitIpInfo_dep5 = new JSONObject();
private JSONObject limitIpInfo_dep6 = new JSONObject();
@Getter @Setter @Autowired private SSOService ssoService;
@Getter @Setter @Autowired private JDYAuthService jdyAuthService;
Logger logger = LoggerFactory.getLogger(getClass());
/**
* 查询SIM卡号车牌号和终端号的对应关系
* @param jsonMes
* @param httpServletRequest
* @return
* @throws KeyManagementException
* @throws NoSuchAlgorithmException
*/
@PostMapping("/mdnVcn/getPageList")
public JSONObject yxMes(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException {
try {
String ip = httpServletRequest.getRemoteAddr();
if (limitIpInfo_dep1.getJSONObject(ip) == null) {
limitIpInfo_dep1.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J905Dao.getAllSims();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
JSONObject limitInfo = limitIpInfo_dep1.getJSONObject(ip);
Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒
//logger.info(ip+":还需等待"+time);
if (time>=60) {
limitIpInfo_dep1.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J905Dao.getAllSims();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return J905Util.returnLoser(402,"接口频率超出限制1分钟内允许调取一次请稍后再试");//秘钥错误
}catch (Exception e){
e.printStackTrace();
return J905Util.returnLoser(401,"系统查询异常,请联系开发人员");
}
}
/**
* 查询车队
* @param jsonMes
* @param httpServletRequest
* @return
* @throws KeyManagementException
* @throws NoSuchAlgorithmException
*/
@PostMapping("/vDwnoFzr/getPageList")
public JSONObject vDwnoFzr(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException {
try {
String ip = httpServletRequest.getRemoteAddr();
if (limitIpInfo_dep2.getJSONObject(ip) == null) {
limitIpInfo_dep2.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J905Dao.getAllSims();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
JSONObject limitInfo = limitIpInfo_dep2.getJSONObject(ip);
Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒
//logger.info(ip+":还需等待"+time);
if (time>=60) {
limitIpInfo_dep2.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J905Dao.getAllSims();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return J905Util.returnLoser(402,"接口频率超出限制1分钟内允许调取一次请稍后再试");//秘钥错误
}catch (Exception e){
e.printStackTrace();
return J905Util.returnLoser(401,"系统查询异常,请联系开发人员");
}
}
/**
* 查询车辆
* @param jsonMes
* @param httpServletRequest
* @return
* @throws KeyManagementException
* @throws NoSuchAlgorithmException
*/
@PostMapping("/VGpsCheliang/getPageList")
public JSONObject VGpsCheliang(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException {
try {
String ip = httpServletRequest.getRemoteAddr();
if (limitIpInfo_dep3.getJSONObject(ip) == null) {
limitIpInfo_dep3.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J905Dao.getVGpsCheliangs();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
JSONObject limitInfo = limitIpInfo_dep3.getJSONObject(ip);
Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒
//logger.info(ip+":还需等待"+time);
if (time>=60) {
limitIpInfo_dep3.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J905Dao.getVGpsCheliangs();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return J905Util.returnLoser(402,"接口频率超出限制1分钟内允许调取一次请稍后再试");//秘钥错误
}catch (Exception e){
e.printStackTrace();
return J905Util.returnLoser(401,"系统查询异常,请联系开发人员");
}
}
/**
* 查询驾驶员
* @param jsonMes
* @param httpServletRequest
* @return
* @throws KeyManagementException
* @throws NoSuchAlgorithmException
*/
@PostMapping("/vGpsJiashiyuan/getPageList")
public JSONObject vGpsJiashiyuan(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException {
try {
String ip = httpServletRequest.getRemoteAddr();
if (limitIpInfo_dep4.getJSONObject(ip) == null) {
limitIpInfo_dep4.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray= J9051Dao.getAllJiashiyuans();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
JSONObject limitInfo = limitIpInfo_dep4.getJSONObject(ip);
Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒
//logger.info(ip+":还需等待"+time);
if (time>=60) {
limitIpInfo_dep4.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J9051Dao.getAllJiashiyuans();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return J905Util.returnLoser(402,"接口频率超出限制1分钟内允许调取一次请稍后再试");//秘钥错误
}catch (Exception e){
e.printStackTrace();
return J905Util.returnLoser(401,"系统查询异常,请联系开发人员");
}
}
/**
* 查询驾驶员和车辆关系
* @param jsonMes
* @param httpServletRequest
* @return
* @throws KeyManagementException
* @throws NoSuchAlgorithmException
*/
@PostMapping("/vGpsHetong/getPageList")
public JSONObject vGpsHetong(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException {
try {
String ip = httpServletRequest.getRemoteAddr();
if (limitIpInfo_dep5.getJSONObject(ip) == null) {
limitIpInfo_dep5.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray= J9052Dao.getAllvGpsHetongs();
for (Object o:jsonArray){
JSONObject jsonObject=(JSONObject)o;
String hphm=jsonObject.getString("hphm");
if (hphm.contains("")){
System.out.println("");
}
}
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
JSONObject limitInfo = limitIpInfo_dep5.getJSONObject(ip);
Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒
//logger.info(ip+":还需等待"+time);
if (time>=60) {
limitIpInfo_dep5.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J9052Dao.getAllvGpsHetongs();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return J905Util.returnLoser(402,"接口频率超出限制1分钟内允许调取一次请稍后再试");//秘钥错误
}catch (Exception e){
e.printStackTrace();
return J905Util.returnLoser(401,"系统查询异常,请联系开发人员");
}
}
/**
* 查询历史人车对应关系
* @param jsonMes
* @param httpServletRequest
* @return
* @throws KeyManagementException
* @throws NoSuchAlgorithmException
*/
@PostMapping("/vGpsLiShiHeTong/getPageList")
public JSONObject vGpsLiShiHeTong(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException {
try {
String ip = httpServletRequest.getRemoteAddr();
if (limitIpInfo_dep6.getJSONObject(ip) == null) {
limitIpInfo_dep6.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray= J9053Dao.getAllvGpsLiShiHeTong();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
JSONObject limitInfo = limitIpInfo_dep6.getJSONObject(ip);
Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒
//logger.info(ip+":还需等待"+time);
if (time>=180) {
limitIpInfo_dep6.put(ip, initializationIP());
try {
String key=jsonMes.getString("key");
if (key.equals("5fff9123eadbae0007b9ce3e")){
JSONArray jsonArray=J9053Dao.getAllvGpsLiShiHeTong();
return J905Util.returnOK(jsonArray);
}else{
return J905Util.returnLoser(400,"秘钥错误");//秘钥错误
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return J905Util.returnLoser(402,"接口频率超出限制3分钟内允许调取一次请稍后再试");//秘钥错误
}catch (Exception e){
e.printStackTrace();
return J905Util.returnLoser(401,"系统查询异常,请联系开发人员");
}
}
private JSONObject initializationIP() {
JSONObject info = new JSONObject();
info.put("time", new Date().getTime());
info.put("num", 1);
return info;
}
}

View File

@ -0,0 +1,78 @@
package com.example.sso.dao;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.V5utils;
public class GongZiFaFang {
public static String fafang(String yuefen, String sijishenfenzhenghao, Integer jine, String yinhangkahao, String status_yinhang) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
jsonObject.put("entry_id", "62f4752f87648b0007aebd47");
jsonObject.put("limit", 10000);
JSONArray fields = new JSONArray();
fields.add("yuefen");
fields.add("sijishenfenzhenghao");
fields.add("jine");
fields.add("yinhangkahao");
JSONObject filter = new JSONObject();
filter.put("rel", "and");
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("field", "yuefen");
jsonObject2.put("method", "eq");
JSONArray jsonArray1 = new JSONArray();
jsonArray1.add(yuefen);
jsonObject2.put("value", jsonArray1);
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("field", "sijishenfenzhenghao");
jsonObject3.put("method", "eq");
JSONArray jsonArray2 = new JSONArray();
jsonArray2.add(sijishenfenzhenghao);
jsonObject3.put("value", jsonArray2);
JSONObject jsonObject4 = new JSONObject();
jsonObject4.put("field", "jine");
jsonObject4.put("method", "eq");
JSONArray jsonArray3 = new JSONArray();
jsonArray3.add(jine);
jsonObject4.put("value", jsonArray3);
JSONObject jsonObject5 = new JSONObject();
jsonObject5.put("field", "yinhangkahao");
jsonObject5.put("method", "eq");
JSONArray jsonArray4 = new JSONArray();
jsonArray4.add(yinhangkahao);
jsonObject5.put("value", jsonArray4);
jsonArray.add(jsonObject5);
jsonArray.add(jsonObject2);
jsonArray.add(jsonObject3);
jsonArray.add(jsonObject4);
filter.put("cond", jsonArray);
jsonObject.put("fields", fields);
jsonObject.put("filter", filter);
String jsonString = jsonObject.toJSONString();
String list = V5utils.list(jsonString);
JSONObject jsonObject7 = JSON.parseObject(list);
JSONArray jsonArray7 = jsonObject7.getJSONArray("data");
for (Object o : jsonArray7) {
JSONObject test = (JSONObject) o;
String id = test.getString("_id");
GongZiFaFangUpData.updata(id, status_yinhang);
}
return "成功";
}
}

View File

@ -0,0 +1,23 @@
package com.example.sso.dao;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.V5utils;
public class GongZiFaFangUpData {
public static String updata(String id, String status ) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
jsonObject.put("entry_id", "62f4752f87648b0007aebd47");
jsonObject.put("data_id", id);
JSONObject jsonObject1 = new JSONObject();
JSONObject status_yinhang = new JSONObject();
status_yinhang.put("value",status);
jsonObject1.put("status_yinhang",status_yinhang);
jsonObject.put("data",jsonObject1);
String jsonString = jsonObject.toJSONString();
String updata = V5utils.updata(jsonString);
return updata;
}
}

View File

@ -0,0 +1,51 @@
package com.example.sso.dao;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.V5utils;
public class GuoLvSelect {
/*public static JSONArray array() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
jsonObject.put("entry_id", "6687bcc9da02e67cdc48e0f8");
jsonObject.put("limit", 10000);
JSONArray fields = new JSONArray();
fields.add("dlrzt");
fields.add("sfjsy");
// jsonObject.put("fields", fields);
JSONObject filter = new JSONObject();
filter.put("rel", "and");
JSONArray cond = new JSONArray();
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("field", "dlrzt");
jsonObject2.put("method", "eq");
JSONArray jsonArray1 = new JSONArray();
jsonArray1.add("启用");
jsonObject2.put("value", jsonArray1);
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("field", "sfjsy");
jsonObject3.put("method", "ne");
JSONArray jsonArray2 = new JSONArray();
jsonArray2.add("是");
jsonObject3.put("value", jsonArray2);
cond.add(jsonObject3);
cond.add(jsonObject2);
filter.put("cond",cond);
jsonObject.put("filter",filter);
String jsonString = jsonObject.toJSONString();
String list = V5utils.list(jsonString);
JSONObject jsonObject1 = JSON.parseObject(list);
JSONArray jsonArray = jsonObject1.getJSONArray("data");
return jsonArray;
}*/
}

View File

@ -0,0 +1,100 @@
package com.example.sso.dao;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.APIUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class J9051Dao {
public static void main(String[] args) {
getAllJiashiyuans();
}
/**
*
* @param
* @return
*/
public static JSONArray getAllJiashiyuans() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "667ccd162e0bccca52d91e66","BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "vcn");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"jsy_id","xm","xb","shfzhh","whchd","xzhzh","lxdh","shjh","jshzhh","zhjchx","lingzhengriqi","status","jdkh","jjlxr"},
//姓名
//性别
//身份号码
//文化程度
//居民身份证住址
//联系电话
//手机号码
//驾驶证档案编号
//准驾车型
//初次领证日期
//驾驶员状态
//监督卡号
//紧急联系人手机号
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i = 1;
if (datas != null && datas.size() != 0) {
while (i != 0) {
if (datas.size() > (i * 10000 - 1)) {
String id = (String) (datas.get(i * 10000 - 1).get("_id"));
List<Map<String, Object>> data = findData(api, filter, id);
if (data == null) {
i = 0;
} else {
datas.addAll(data);
i = i + 1;
}
} else {
i = 0;
}
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("list", datas);
return jsonObject.getJSONArray("list");
}
private static List<Map<String, Object>> findData(APIUtils api, Map<String, Object> filter, String id) {
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"jsy_id","xm","xb","shfzhh","whchd","xzhzh","lxdh","shjh","jshzhh","zhjchx","lingzhengriqi","status","jdkh","jjlxr"},
filter, id);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
return datas;
}
}

View File

@ -0,0 +1,97 @@
package com.example.sso.dao;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.APIUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class J9052Dao {
public static void main(String[] args) {
JSONArray jsonArray= J9052Dao.getAllvGpsHetongs();
for (Object o:jsonArray){
JSONObject jsonObject=(JSONObject)o;
String hphm=jsonObject.getString("hphm");
if (hphm.contains("BD98508")){
System.out.println("");
}
}
}
/**
*
* @param
* @return
*/
public static JSONArray getAllvGpsHetongs() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "62b80148c6c1af0007f8a824","BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "shfzhh");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"shfzhh","hphm","xgrq","zhzhrq"},//身份证号,车牌号码,承包合同开始日期,承包合同终止日期
//身份号码
//车牌号码
//承包合同开始日期
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i = 1;
if (datas != null && datas.size() != 0) {
while (i != 0) {
if (datas.size() > (i * 10000 - 1)) {
String id = (String) (datas.get(i * 10000 - 1).get("_id"));
List<Map<String, Object>> data = findData(api, filter, id);
if (data == null) {
i = 0;
} else {
datas.addAll(data);
i = i + 1;
}
} else {
i = 0;
}
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("list", datas);
return jsonObject.getJSONArray("list");
}
private static List<Map<String, Object>> findData(APIUtils api, Map<String, Object> filter, String id) {
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"shfzhh","hphm","xgrq","zhzhrq"},
filter, id);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
return datas;
}
}

View File

@ -0,0 +1,206 @@
package com.example.sso.dao;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.APIUtils;
import com.example.sso.util.TimeUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class J9053Dao {
public static void main(String[] args) {
getAllvGpsLiShiHeTong();
}
/**
* @param
* @return
*/
public static JSONArray getAllvGpsLiShiHeTong() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "62b817f0a5b6a3000714e456", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "shfzhh");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"shfzhh", "hphm", "xgrq","kshrq"},//身份证号,车牌号码,退租日期,承包合同开始日期
//身份号码
//车牌号码
//承包合同开始日期
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i = 1;
if (datas != null && datas.size() != 0) {
while (i != 0) {
if (datas.size() > (i * 10000 - 1)) {
String id = (String) (datas.get(i * 10000 - 1).get("_id"));
List<Map<String, Object>> data = findData(api, filter, id);
if (data == null) {
i = 0;
} else {
datas.addAll(data);
i = i + 1;
}
} else {
i = 0;
}
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("list", datas);
return jsonObject.getJSONArray("list");
}
private static List<Map<String, Object>> findData(APIUtils api, Map<String, Object> filter, String id) {
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"shfzhh", "hphm", "xgrq","kshrq"},
filter, id);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
return datas;
}
/**
* 更新客户报备数据
*
* @throws Exception
*/
public static void createTuiJianBiao(JSONObject jsonObject) {
try {
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "63c0af1e6a928200087c72d5", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
Map<String, Object> map1;
map1 = new HashMap<String, Object>() {
{
//推荐人邮箱
put("tuijian_recommendemail", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_recommendEmail"));
}});
put("beituijian_mobile", new HashMap<String, Object>() {{
put("value", jsonObject.getString("beituijian_mobile"));
}});
put("tuijian_recommendmobile", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_recommendMobile"));
}});
put("tuijian_employeeid", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_employeeId"));
}});
put("beituijian_eamil", new HashMap<String, Object>() {{
put("value", jsonObject.getString("beituijian_mobile"));
}});
put("tuijian_recommendertype", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_recommenderType"));
}});
put("beituijian_name", new HashMap<String, Object>() {{
put("value", jsonObject.getString("beituijian_name"));
}});
put("tuijian_recommendname", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_recommendName"));
}});
put("recommendertype", new HashMap<String, Object>() {{
put("value", jsonObject.getString("recommenderType"));
}});
put("beituijian_certificatenumber", new HashMap<String, Object>() {{
put("value", jsonObject.getString("beituijian_certificateNumber"));
}});
put("delivertime", new HashMap<String, Object>() {{
put("value", jsonObject.getString("deliverTime"));
}});
put("department_name", new HashMap<String, Object>() {{
put("value", jsonObject.getString("department_name"));
}});
}
};
//把封装好的数据创建至简道云
api.createData(map1);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 更新客户报备数据
*
* @throws Exception
*/
public static void updateTuiJianBiao(String id, JSONObject jsonObject) {
try {
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "63c0af1e6a928200087c72d5", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
Map<String, Object> map1;
map1 = new HashMap<String, Object>() {
{
//推荐人邮箱
put("tuijian_recommendemail", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_recommendEmail"));
}});
put("beituijian_mobile", new HashMap<String, Object>() {{
put("value", jsonObject.getString("beituijian_mobile"));
}});
put("tuijian_recommendmobile", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_recommendMobile"));
}});
put("tuijian_employeeid", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_employeeId"));
}});
put("beituijian_eamil", new HashMap<String, Object>() {{
put("value", jsonObject.getString("beituijian_mobile"));
}});
put("tuijian_recommendertype", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_recommenderType"));
}});
put("beituijian_name", new HashMap<String, Object>() {{
put("value", jsonObject.getString("beituijian_name"));
}});
put("tuijian_recommendname", new HashMap<String, Object>() {{
put("value", jsonObject.getString("tuijian_recommendName"));
}});
put("recommendertype", new HashMap<String, Object>() {{
put("value", jsonObject.getString("recommenderType"));
}});
put("beituijian_certificatenumber", new HashMap<String, Object>() {{
put("value", jsonObject.getString("beituijian_certificateNumber"));
}});
put("delivertime", new HashMap<String, Object>() {{
put("value", jsonObject.getString("deliverTime"));
}});
put("department_name", new HashMap<String, Object>() {{
put("value", jsonObject.getString("department_name"));
}});
}
};
//把封装好的数据创建至简道云
api.updateData(id, map1);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,158 @@
package com.example.sso.dao;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.APIUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class J905Dao {
public static void main(String[] args) {
getVGpsCheliangs();
}
/**
* 查询SIM卡号车牌号和终端号的对应关系
* @param
* @return
*/
public static JSONArray getAllSims() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "5673d2535dee5e584224e3e9","BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "vcn");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"vcn","mdn","mdn905","jjqbh"},//车牌号产品序列号UIM卡号计价器号
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i = 1;
if (datas != null && datas.size() != 0) {
while (i != 0) {
if (datas.size() > (i * 10000 - 1)) {
String id = (String) (datas.get(i * 10000 - 1).get("_id"));
List<Map<String, Object>> data = findData(api, filter, id);
if (data == null) {
i = 0;
} else {
datas.addAll(data);
i = i + 1;
}
} else {
i = 0;
}
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("list", datas);
return jsonObject.getJSONArray("list");
}
private static List<Map<String, Object>> findData(APIUtils api, Map<String, Object> filter, String id) {
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"vcn","mdn","mdn905","jjqbh"},//车牌号产品序列号UIM卡号计价器号
filter, id);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
return datas;
}
/**
* 查询车辆
* @param
* @return
*/
public static JSONArray getVGpsCheliangs() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "5673d2535dee5e584224e3e9","BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "vcn");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"dw","ssh","vcn","chp",
"xh","ys","djrq","chlzht","jch","pshh","shyxzh","chjh","shynx","dqzht","zhtxf","yyfsh","lhyyf"},//所属部门(文本),分司,车牌号码,品牌,型号,颜色 ,注册登记日期,班制,简称,喷饰号,使用性质,车架号,使用年限,当前状态,状态细分,运营方式,联合运营方
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i = 1;
if (datas != null && datas.size() != 0) {
while (i != 0) {
if (datas.size() > (i * 10000 - 1)) {
String id = (String) (datas.get(i * 10000 - 1).get("_id"));
List<Map<String, Object>> data = getVGpsCheliangs_zi(api, filter, id);
if (data == null) {
i = 0;
} else {
datas.addAll(data);
i = i + 1;
}
} else {
i = 0;
}
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("list", datas);
return jsonObject.getJSONArray("list");
}
private static List<Map<String, Object>> getVGpsCheliangs_zi(APIUtils api, Map<String, Object> filter, String id) {
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"dw","ssh","vcn","chp",
"xh","ys","djrq","chlzht","jch","pshh","shyxzh","chjh","shynx","dqzht","zhtxf","yyfsh","lhyyf"},
filter, id);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
return datas;
}
}

View File

@ -0,0 +1,22 @@
package com.example.sso.dao;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.V5utils;
public class UpDataYes {
public static String updata(String id) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
jsonObject.put("entry_id", "62f4913c82654a00085de9e4");
jsonObject.put("data_id", id);
JSONObject data = new JSONObject();
JSONObject status_jiaoyan = new JSONObject();
status_jiaoyan.put("value","");
data.put("status_jiaoyan",status_jiaoyan);
jsonObject.put("data",data);
String jsonString = jsonObject.toJSONString();
V5utils.updata(jsonString);
return "成功";
}
}

View File

@ -0,0 +1,73 @@
package com.example.sso.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.V5utils;
public class GuoLv {
/*public static void main(String[] args) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
jsonObject.put("entry_id", "6687bcc9da02e67cdc48e0f8");
jsonObject.put("limit",10000);
JSONObject filter = new JSONObject();
filter.put("rel","and");
JSONArray cond = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("field","sfjsy");
jsonObject1.put("method","ne");
JSONArray value = new JSONArray();
value.add("是");
jsonObject1.put("value",value);
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("field","jshycy");
jsonObject3.put("method","empty");
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("field","dlrzt");
jsonObject2.put("method","eq");
JSONArray value1 = new JSONArray();
value1.add("启用");
jsonObject2.put("value",value1);
cond.add(jsonObject3);
cond.add(jsonObject2);
cond.add(jsonObject1);
filter.put("cond",cond);
jsonObject.put("filter",filter);
String jsonString = jsonObject.toJSONString();
String list = V5utils.list(jsonString);
JSONObject jsonObject4 = JSON.parseObject(list);
JSONArray jsonArray1 = jsonObject4.getJSONArray("data");
for (Object o : jsonArray1){
JSONObject test = (JSONObject) o;
String beisenId = test.getString("beisen_id");
String id = test.getString("_id");
JSONObject jsonObject12 = new JSONObject();
jsonObject12.put("app_id", "667cc6dbaa923599ad735201");
jsonObject12.put("entry_id", "6687bcc9da02e67cdc48e0f8");
jsonObject12.put("data_id", id);
JSONObject data = new JSONObject();
JSONObject jshycy = new JSONObject();
jshycy.put("value",beisenId);
data.put("jshycy",jshycy);
jsonObject12.put("data",data);
String jsonString1 = jsonObject12.toJSONString();
String updata = V5utils.updata(jsonString1);
System.out.println(updata);
}
}*/
}

View File

@ -0,0 +1,114 @@
package com.example.sso.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.V5utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class L {
@Scheduled(cron = "0 0 18 * * ?")
public void main1() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
jsonObject.put("entry_id", "667ccd162e0bccca52d91e66");
jsonObject.put("limit",10000);
JSONArray jsonArray = new JSONArray();
jsonArray.add("status");
jsonArray.add("lrrq");
jsonArray.add("beisen_id");
jsonArray.add("jshycy");
jsonArray.add("jsy_id");
jsonObject.put("fields",jsonArray);
JSONObject filter = new JSONObject();
filter.put("rel","and");
JSONArray cond = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("field","status");
jsonObject1.put("method","eq");
JSONArray value = new JSONArray();
value.add("运营");
jsonObject1.put("value",value);
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("field","beisen_id");
jsonObject3.put("method","not_empty");
/* JSONObject jsonObject5 = new JSONObject();
jsonObject5.put("field","jsy_id");
jsonObject5.put("method","eq");
JSONArray value6 = new JSONArray();
value6.add("JSY202268659");
jsonObject5.put("value",value6);*/
cond.add(jsonObject3);
cond.add(jsonObject1);
//cond.add(jsonObject5);
filter.put("cond",cond);
jsonObject.put("filter",filter);
String jsonString = jsonObject.toJSONString();
String list = V5utils.list(jsonString);
JSONObject jsonObject2 = JSON.parseObject(list);
JSONArray jsonArray1 = jsonObject2.getJSONArray("data");
for (Object o : jsonArray1){
JSONObject TE = (JSONObject) o;
String lrrq = TE.getString("lrrq");
String id = TE.getString("_id");
String beisen_id = TE.getString("beisen_id");
String substring = lrrq.substring(0, 10);
String datas = LLL.DATAS(substring);
String now = LL.now();
if (now.equals(datas)){
JSONObject jsonObject4 = new JSONObject();
jsonObject4.put("app_id", "667cc6dbaa923599ad735201");
jsonObject4.put("entry_id", "667ccd162e0bccca52d91e66");
jsonObject4.put("data_id", id);
JSONObject data = new JSONObject();
// int i = Integer.parseInt(beisen_id);
JSONObject jshycy = new JSONObject();
jshycy.put("value",beisen_id);
data.put("jshycy",jshycy);
jsonObject4.put("data",data);
String jsonStrings = jsonObject4.toJSONString();
log.info("aaaaaaa"+jsonStrings);
String updata = V5utils.updata(jsonStrings);
System.out.println(updata);
}
}
}
}

View File

@ -0,0 +1,20 @@
package com.example.sso.schedule;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class LL {
public static String now() {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 定义日期格式化器
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 格式化当前日期
String formattedDate = currentDate.format(formatter);
// 输出格式化后的日期
return formattedDate;
}
}

View File

@ -0,0 +1,26 @@
package com.example.sso.schedule;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class LLL {
public static String DATAS(String dateString ) {
// 定义指定的日期字符串
// 定义日期格式化器
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 将字符串解析为 LocalDate 对象
LocalDate date = LocalDate.parse(dateString, formatter);
// 计算后一天的日期
LocalDate nextDay = date.plusDays(1);
// 格式化后一天的日期为字符串
String formattedNextDay = nextDay.format(formatter);
// 输出格式化后的日期
return formattedNextDay;
}
}

View File

@ -0,0 +1,227 @@
package com.example.sso.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.dao.J9053Dao;
import com.example.sso.util.HttpUtil;
import com.example.sso.util.JDYUtil;
import com.example.sso.util.TimeUtil;
import com.example.sso.util.WXUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.sql.Time;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class ScheduleDep {
private static String app_key = "F493FDF0DA9B4DF3A826530B568E6BAF";
private static String app_secret = "B9BAA96975C74DB8AF07EB5D5243F56DE2FAE0ED37D64797AB2487EA3F8011CD";
@Scheduled(cron = "0 0 5 * * ?")//0 00 00 1 4,7,10,1 ?\
public static void SynDep() throws KeyManagementException, NoSuchAlgorithmException {
try {
getApplysByPhaseStatusCode();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
getApplysByPhaseStatusCode();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
}
public static String getToken() throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/token";
JSONObject body = new JSONObject();
body.put("grant_type", "client_credentials");
body.put("app_key", app_key);
body.put("app_secret", app_secret);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString()));
return jsonObject.getString("access_token");
}
/**
* 修改人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void updateUser(JSONObject driver, Integer id) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/UpdateEmployee";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("originalId", driver.get("shfzhh"));//外部编码ID
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
/**
* 获取人员数据
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void getApplysByPhaseStatusCode() throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/RecruitV6/api/v1/Apply/GetApplysByPhaseStatusCode";
JSONObject body = new JSONObject();
body.put("startTime", TimeUtil.getEarly6Month());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
body.put("endTime", df.format(new Date()));
body.put("phaseCode", "S001");
body.put("statusCode", "U001");
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("items");
// while (jsonObject.getJSONObject("data").getString("nextBatchId")!=null){
// body.put("batchId",jsonObject.getJSONObject("data").getString("nextBatchId"));
// JSONObject jsonObject1 =JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
// JSONArray jsonArray1 = jsonObject1.getJSONObject("data").getJSONArray("items");
// jsonArray.addAll(jsonArray1);
// }
JSONObject jsonObject1 = new JSONObject();
JSONObject beitui = JDYUtil.getAllTuiJian();
for (Object o : jsonArray) {
JSONObject data = (JSONObject) o;
JSONObject applicantLite = data.getJSONObject("applicantLite");
if (data.getJSONObject("jobLite").getString("jobTitle").equals("出租车驾驶员")) {
String applyId = data.getString("applyId");
// JSONObject applicantLite = data.getJSONObject("applicantLite");
jsonObject1.put("beituijian_certificateNumber", applicantLite.getString("certificateNumber"));//身份证号码
jsonObject1.put("beituijian_name", applicantLite.getString("name"));//姓名
jsonObject1.put("beituijian_eamil", applicantLite.getString("eamil"));//身份证号码
jsonObject1.put("beituijian_mobile", applicantLite.getString("mobile"));//身份证号码
try {
getReferrerListByApplyId(applyId, jsonObject1);
} catch (Exception e) {
e.printStackTrace();
}
if (beitui.getString(jsonObject1.getString("beituijian_certificateNumber")) == null) {
J9053Dao.createTuiJianBiao(jsonObject1);
} else {
J9053Dao.updateTuiJianBiao(beitui.getJSONObject(jsonObject1.getString("beituijian_certificateNumber")).getString("_id"), jsonObject1);
}
jsonObject1.clear();
}
}
// return jsonObject.getString("access_token");
}
/**
* 根据申请ID获取推荐人相关信息
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static JSONObject getReferrerListByApplyId(String guid, JSONObject jsonObject) throws NoSuchAlgorithmException, KeyManagementException, ParseException {
String url = "https://openapi.italent.cn/RecruitV6/api/v1/Recommend/GetReferrerListByApplyId?applyId=" + guid;
JSONObject jsonObject1 = JSON.parseObject(HttpUtil.sendGet(url, getToken()));
System.out.println(jsonObject1.toJSONString());
JSONArray jsonArray = jsonObject1.getJSONArray("data");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
Date date = null;
for (Object o : jsonArray) {
JSONObject jsonObject2 = (JSONObject) o;
String deliverTime = jsonObject2.getString("deliverTime");
if (deliverTime != null) {
deliverTime = deliverTime.split("\\.")[0];
deliverTime = dateFormat.format(df.parse(deliverTime));
}
if (date == null) {
date = df.parse(deliverTime);
}
Boolean isEffective = jsonObject2.getBoolean("isEffective");
String recommendName = jsonObject2.getString("recommendName");
String recommendEmail = jsonObject2.getString("recommendEmail");
String recommendMobile = jsonObject2.getString("recommendMobile");
if (recommendEmail != null && recommendMobile != null
&& !recommendEmail.equals("") && !recommendMobile.equals("")) {
if (date != null) {
if (date.before(df.parse(deliverTime)) || date.equals(df.parse(deliverTime))) {
jsonObject.put("tuijian_recommendMobile", jsonObject2.getString("recommendMobile"));
jsonObject.put("tuijian_recommendName", jsonObject2.getString("recommendName"));
jsonObject.put("tuijian_recommendEmail", jsonObject2.getString("recommendEmail"));
jsonObject.put("tuijian_employeeId", jsonObject2.getString("employeeId"));
jsonObject.put("tuijian_recommenderType", jsonObject2.getString("recommenderType"));//推荐人类型
jsonObject.put("department_name", jsonObject2.getString("departmentName"));//推荐人类型
jsonObject.put("deliverTime", TimeUtil.timeConversion(deliverTime));//申请时间
}
}
}
if (date != null) {
if (deliverTime != null) {
if (date.before(df.parse(deliverTime))) {
date = df.parse(deliverTime);
}
}
}
}
return jsonObject;
// return jsonObject.getString("access_token");
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void createUser(HashMap<String, Object> driver, JSONObject orgNos) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
// employeeInformation.put("email",driver.get("yxbs"));//邮箱
employeeInformation.put("email", driver.get("shjh") + "@yinjian.com");//邮箱
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期
employmentRecord.put("probation", 0);//试用期无试用期为0
String name = (String) driver.get("name");//
for (String str : orgNos.keySet()) {
if (str.contains((String) driver.get("ssbm") + (String) driver.get("fs"))) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
}
}
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
}

View File

@ -0,0 +1,219 @@
package com.example.sso.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.dao.J9053Dao;
import com.example.sso.util.BeiSenTest;
import com.example.sso.util.HttpUtil;
import com.example.sso.util.JDYUtil;
import com.example.sso.util.TimeUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class ScheduleDep1 {
private static String app_key = "F493FDF0DA9B4DF3A826530B568E6BAF";
private static String app_secret = "B9BAA96975C74DB8AF07EB5D5243F56DE2FAE0ED37D64797AB2487EA3F8011CD";
// @Scheduled(cron = "0 35 1 * * ?")//0 00 00 1 4,7,10,1 ?\
// public static void SynDep() throws KeyManagementException, NoSuchAlgorithmException {
// try {
// List<Map<String, Object>> drivers=JDYUtil.getAllDrivers1();//查询
// for (Map<String, Object> driver:drivers){
// Integer integer=Integer.valueOf((String) driver.get("oid"));
// BeiSenTest.deleteUser(integer);
// }
// }catch (Exception e) {
// e.printStackTrace();
// }
// }
// public static void main(String[] args) {
// try {
// getApplysByPhaseStatusCode();
// } catch (NoSuchAlgorithmException e) {
// e.printStackTrace();
// } catch (KeyManagementException e) {
// e.printStackTrace();
// }
// }
public static String getToken() throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/token";
JSONObject body = new JSONObject();
body.put("grant_type", "client_credentials");
body.put("app_key", app_key);
body.put("app_secret", app_secret);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString()));
return jsonObject.getString("access_token");
}
/**
* 修改人员信息
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void updateUser(JSONObject driver, Integer id) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/UpdateEmployee";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("originalId", driver.get("shfzhh"));//外部编码ID
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
/**
* 获取人员数据
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void getApplysByPhaseStatusCode() throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/RecruitV6/api/v1/Apply/GetApplysByPhaseStatusCode";
JSONObject body = new JSONObject();
body.put("startTime", "2020-12-08T12:23:00");
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
body.put("endTime", df.format(new Date()));
body.put("phaseCode", "S001");
body.put("statusCode", "U001");
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
JSONArray jsonArray=jsonObject.getJSONObject("data").getJSONArray("items");
JSONObject jsonObject1=new JSONObject();
JSONObject beitui=JDYUtil.getAllTuiJian();
for (Object o:jsonArray){
JSONObject data=(JSONObject)o;
if (data.getJSONObject("jobLite").getString("jobTitle").equals("出租车驾驶员")){
String applyId=data.getString("applyId");
JSONObject applicantLite=data.getJSONObject("applicantLite");
if (applicantLite.getString("name").equals("吕玲")){
System.out.println("");
}
jsonObject1.put("beituijian_certificateNumber",applicantLite.getString("certificateNumber"));//身份证号码
jsonObject1.put("beituijian_name",applicantLite.getString("name"));//姓名
jsonObject1.put("beituijian_eamil",applicantLite.getString("eamil"));//身份证号码
jsonObject1.put("beituijian_mobile",applicantLite.getString("mobile"));//身份证号码
try {
getReferrerListByApplyId(applyId,jsonObject1);
} catch (Exception e) {
e.printStackTrace();
}
if (beitui.getString(jsonObject1.getString("beituijian_certificateNumber"))==null){
J9053Dao.createTuiJianBiao(jsonObject1);
}else {
J9053Dao.updateTuiJianBiao(beitui.getJSONObject(jsonObject1.getString("beituijian_certificateNumber")).getString("_id"),jsonObject1);
}
}
}
// return jsonObject.getString("access_token");
}
/**
* 根据申请ID获取推荐人相关信息
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static JSONObject getReferrerListByApplyId(String guid,JSONObject jsonObject) throws NoSuchAlgorithmException, KeyManagementException, ParseException {
String url = "https://openapi.italent.cn/RecruitV6/api/v1/Recommend/GetReferrerListByApplyId?applyId="+guid;
JSONObject jsonObject1 = JSON.parseObject(HttpUtil.sendGet(url,getToken()));
System.out.println(jsonObject1.toJSONString());
JSONArray jsonArray=jsonObject1.getJSONArray("data");
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
Date date=null;
for (Object o:jsonArray){
JSONObject jsonObject2=(JSONObject)o;
String deliverTime =jsonObject2.getString("deliverTime");
if (deliverTime!=null){
deliverTime=deliverTime.split("\\.")[0];
deliverTime=dateFormat.format(df.parse(deliverTime));
}
if (date==null){
date=df.parse(deliverTime);
}
Boolean isEffective=jsonObject2.getBoolean("isEffective");
String recommendName=jsonObject2.getString("recommendName");
String recommendEmail=jsonObject2.getString("recommendEmail");
String recommendMobile=jsonObject2.getString("recommendMobile");
if (recommendName!=null&&recommendEmail!=null&&recommendMobile!=null
&!recommendName.equals("")&&!recommendEmail.equals("")&&!recommendMobile.equals("")){
if (date!=null){
if (date.before(df.parse(deliverTime))||date.equals(df.parse(deliverTime))){
jsonObject.put("tuijian_recommendMobile",jsonObject2.getString("recommendMobile"));
jsonObject.put("tuijian_recommendName",jsonObject2.getString("recommendName"));
jsonObject.put("tuijian_recommendEmail",jsonObject2.getString("recommendEmail"));
jsonObject.put("tuijian_employeeId",jsonObject2.getString("employeeId"));
jsonObject.put("tuijian_recommenderType",jsonObject2.getString("recommenderType"));//推荐人类型
jsonObject.put("department_name",jsonObject2.getString("departmentName"));//推荐人类型
jsonObject.put("deliverTime", TimeUtil.timeConversion(deliverTime));//申请时间
}
}
}
if (date!=null){
if (deliverTime!=null){
if (date.before(df.parse(deliverTime))){
date=df.parse(deliverTime);
}
}
}
}
return jsonObject;
// return jsonObject.getString("access_token");
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void createUser(HashMap<String, Object> driver, JSONObject orgNos) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
// employeeInformation.put("email",driver.get("yxbs"));//邮箱
employeeInformation.put("email", driver.get("shjh") + "@yinjian.com");//邮箱
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期
employmentRecord.put("probation", 0);//试用期无试用期为0
String name = (String) driver.get("name");//
for (String str : orgNos.keySet()) {
if (str.contains((String) driver.get("ssbm") + (String) driver.get("fs"))) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
}
}
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
}

View File

@ -0,0 +1,402 @@
package com.example.sso.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.dao.J9053Dao;
import com.example.sso.util.APIUtils;
import com.example.sso.util.HttpUtil;
import com.example.sso.util.JDYUtil;
import com.example.sso.util.TimeUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 处理当日下车又上车相关人员
* 这部分人,不能使用修改接口,应在第二天使用新增接口遍历
*/
@Component
public class ScheduleLiZhiPerson {
private static String app_key = "F493FDF0DA9B4DF3A826530B568E6BAF";
private static String app_secret = "B9BAA96975C74DB8AF07EB5D5243F56DE2FAE0ED37D64797AB2487EA3F8011CD";
@Scheduled(cron = "0 20 5 * * ?")//0 00 00 1 4,7,10,1 ?\
// public static void main(String[] args) {
// try {
// SynDep();
// } catch (KeyManagementException e) {
// e.printStackTrace();
// } catch (NoSuchAlgorithmException e) {
// e.printStackTrace();
// }
// }
public static void SynDep() throws KeyManagementException, NoSuchAlgorithmException {
try {
JSONArray drivers = getAllLiShangDriver();//查询下车又上车的所有相关人员
for (Object o : drivers) {
JSONObject driver = (JSONObject) o;
String _id = driver.getString("_id");
String shfzhh = (String) driver.get("shfzhh");//获取当前人员身份证号码
JSONObject person = findPersonById_Card(shfzhh);//查询驾驶员信息表里该驾驶员的数据
JSONObject orgNos = JDYUtil.getOrgNos();
String integer=createUser(person, orgNos, person.getString("_id"));//创建该人员
if (integer.contains("200")){
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "6434f517e34c130008183344", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
api.deleteData(_id);
}else {
updateBeiSenStatus(_id,integer);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 修改简道云订单数据状态字段
* @param id
* @param
* @return
*/
public static void updateBeiSenStatus(String id,String status){
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "6434f517e34c130008183344", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
Map<String, Object> data = new HashMap<String, Object>() {{
put("status", new HashMap<String, Object>() {{
put("value", status);
}});
}};
api.updateData(id, data);
}
// public static void main(String[] args) {
// try {
// JSONArray drivers = getAllLiShangDriver();//查询下车又上车的所有相关人员
// for (Object o : drivers) {
// JSONObject driver = (JSONObject) o;
// String shfzhh = (String) driver.get("shfzhh");//获取当前人员身份证号码
// JSONObject person = findPersonById_Card(shfzhh);//查询驾驶员信息表里该驾驶员的数据
// JSONObject orgNos = JDYUtil.getOrgNos();
// createUser(person, orgNos, person.getString("_id"));//创建该人员
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
/**
* 查询下车又上车的所有相关人员
*
* @param
* @return
*/
public static JSONArray getAllLiShangDriver() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "6434f517e34c130008183344", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "xm");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"shfzhh"},//身份证号码
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("list", datas);
return jsonObject.getJSONArray("list");
}
/**
* 根据身份证查询驾驶员信息表数据
*/
public static JSONObject findPersonById_Card(String id_card_num) {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "667ccd162e0bccca52d91e66", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add(id_card_num);
condList.add(new HashMap<String, Object>() {
{
put("field", "shfzhh");//查新字段的名称/别名
put("method", "eq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"xm", "ssbm",
"fs", "yxbs", "lrrq", "shjh", "shfzhh", "shjh", "beisen_id"},//身份证号码
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("list", datas);
JSONArray jsonArray1 = new JSONArray();
for (Map<String, Object> o : datas) {
String time = (String) o.get("lrrq");
if (time != null) {
o.put("lrrq", TimeUtil.timeConversion2(time));
}
jsonArray1.add(o);
}
return jsonArray1.getJSONObject(0);
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
// public static void createUser(JSONObject driver, JSONObject orgNos,JSONArray deps) throws NoSuchAlgorithmException, KeyManagementException {
// String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
// JSONObject body = new JSONObject();
// body.put("employeeInformation", "client_credentials");
// JSONObject employeeInformation = new JSONObject();
// employeeInformation.put("name", driver.get("xm"));//姓名:张三
// employeeInformation.put("email",driver.get("yxbs"));//邮箱
// employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
//// employeeInformation.put("email", driver.get("shjh") + "@yinjian.com");//邮箱
// employeeInformation.put("mobilePhone", driver.get("shjh"));//身份证号码
// JSONObject employmentRecord = new JSONObject();
// employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期\
// employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//身份证号码
// employmentRecord.put("probation", 0);//试用期无试用期为0
// String name = (String) driver.get("name");//
// String uu=(String) driver.get("ssbm") + (String) driver.get("fs");
// for (String str : orgNos.keySet()) {
// if (str.equals((String) driver.get("ssbm") + (String) driver.get("fs")+"司")) {
// employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
// break;
// }
// }
// Integer O=employmentRecord.getInteger("OIdDepartment");
// if (O==null){
// deps.add(uu);
// System.out.println("");
// }
// employmentRecord.put("originalId", driver.get("shfzhh"));//外部编码ID
// employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
// employmentRecord.put("oIdJobPost", "149359");//职务
// body.put("employeeInformation", employeeInformation);
// body.put("employmentRecord", employmentRecord);
// JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
// System.out.println(jsonObject.toJSONString());
//// JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
//// System.out.println(jsonObject.toJSONString());
//// return jsonObject.getString("access_token");
//}
public static String getToken() throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/token";
JSONObject body = new JSONObject();
body.put("grant_type", "client_credentials");
body.put("app_key", app_key);
body.put("app_secret", app_secret);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString()));
return jsonObject.getString("access_token");
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static String createUser(JSONObject driver, JSONObject orgNos, String id) throws NoSuchAlgorithmException, KeyManagementException {
String token = getToken();
// if (driver.getString("beisen_id") == null || driver.getString("beisen_id").equals("")) {
try {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
employeeInformation.put("email", driver.get("yxbs"));//邮箱
// employeeInformation.put("originalId", driver.get("shfzhh"));//外部ID
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
employeeInformation.put("mobilePhone", driver.get("shjh"));//电话号码
employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//电话
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期
employmentRecord.put("probation", 0);//试用期无试用期为0
String name = (String) driver.get("name");//
for (String str : orgNos.keySet()) {
if (str.equals(driver.get("fs"))) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), token));
JSONObject returnData = jsonObject.getJSONObject("data");
System.out.println(driver.get("shfzhh") + "的创建账户动作返回为:" + jsonObject.toJSONString());
if (jsonObject.getString("code").equals("200")) {
JDYUtil.updateBeiSenId(id, returnData.getString("userId"));
}
return jsonObject.toJSONString();
}catch (Exception e){
e.printStackTrace();
return "同步异常";
}
// } else {
//如果不是新增则修改数据
// updateUser(driver, driver.getInteger("beisen_id"), orgNos, token);
// }
// return jsonObject.getString("access_token");
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
// public static void createUser(JSONObject driver, JSONObject orgNos,String id) throws NoSuchAlgorithmException, KeyManagementException {
// String token=getToken();
// if (driver.getString("beisen_id")==null||driver.getString("beisen_id").equals("")){
// String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
// JSONObject body = new JSONObject();
// body.put("employeeInformation", "client_credentials");
// JSONObject employeeInformation = new JSONObject();
// employeeInformation.put("name", driver.get("xm"));//姓名:张三
// employeeInformation.put("email",driver.get("yxbs"));//邮箱
// employeeInformation.put("originalId",driver.get("shfzhh"));//外部ID
// employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
// employeeInformation.put("mobilePhone", driver.get("shjh"));//电话号码
// employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//电话
// JSONObject employmentRecord = new JSONObject();
// employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期
// employmentRecord.put("probation", 0);//试用期无试用期为0
// String name = (String) driver.get("name");//
// employmentRecord.put("OIdDepartment",600186);//试用期无试用期为0
// body.put("employeeInformation", employeeInformation);
// body.put("employmentRecord", employmentRecord);
// JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(),token));
// JSONObject returnData=jsonObject.getJSONObject("data");
// try {
// if (returnData!=null){
// System.out.println(driver.get("shfzhh")+"的创建账户动作返回为:"+jsonObject.toJSONString());
// if (jsonObject.getString("code").equals("200")){
// JDYUtil.updateBeiSenId(id,returnData.getString("userId"));
// }
// }
// }catch (Exception e){
// e.printStackTrace();
// }
// }else {
// //如果不是新增则修改数据
// updateUser(driver,driver.getInteger("beisen_id"),orgNos,token);
// }
//// return jsonObject.getString("access_token");
// }
/**
* 修改人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void updateUser(JSONObject driver, Integer id, JSONObject orgNos, String token) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/UpdateEmployee";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
employeeInformation.put("email", driver.get("yxbs"));//邮箱
employeeInformation.put("originalId", driver.get("shfzhh"));//外部ID
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
employeeInformation.put("mobilePhone", driver.get("shjh"));//电话号码
employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//电话
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
for (String str : orgNos.keySet()) {
if (str.equals((String) driver.get("ssbm") + (String) driver.get("fs") + "")) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), token));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
/**
* 离职人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void deleteUser(Integer id) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Dimission";
JSONObject body = new JSONObject();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
JSONObject employmentRecord = new JSONObject();
try {
employmentRecord.put("lastWorkDate", df.format(new Date()));//最后工作日期
} catch (Exception e) {
e.printStackTrace();
}
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
}

View File

@ -0,0 +1,27 @@
package com.example.sso.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.HttpUtil;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
@Service
@NoArgsConstructor
public class JDYAuthService {
public static final String GET_USERINFO_URL = "http://10.165.35.44/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE";
public String getUserID(String accessToken, String code) throws NoSuchAlgorithmException, KeyManagementException {
//1.获取请求的url
String get_userInfo_url = GET_USERINFO_URL.replace("ACCESS_TOKEN", accessToken)
.replace("CODE", code);
//2.调用接口,发送请求,获取成员信息
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendGet(get_userInfo_url,accessToken));
return jsonObject.getString("UserId");
}
}

View File

@ -0,0 +1,44 @@
package com.example.sso.service;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.example.sso.config.SSOConfig;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.Date;
@Service
@NoArgsConstructor
@AllArgsConstructor
public class SSOService {
@Getter @Setter @Autowired private SSOConfig ssoConfig;
public String getResponse(String request,String username) {
Algorithm algorithm = Algorithm.HMAC256("");
JWTVerifier verifier = JWT.require(algorithm)
.withIssuer("com.jiandaoyun")
.build();
// DecodedJWT decoded = verifier.verify(request);
// if (!"sso_req".equals(decoded.getClaim("type").asString())) {
// return "";
// }
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.HOUR_OF_DAY, 1);
return JWT.create()
.withIssuer("com.jiandaoyun")
.withClaim("type", "sso_res")
.withClaim("username", username)
.withAudience("com.jiandaoyun")
.withExpiresAt(calendar.getTime())
.sign(algorithm);
}
}

View File

@ -0,0 +1,47 @@
package com.example.sso.test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.GongZiUtil;
import com.example.sso.util.V5utils;
public class A {
public static void main(String[] args) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
jsonObject.put("entry_id", "62f4913c82654a00085de9e4");
jsonObject.put("limit", 10000);
JSONArray fields = new JSONArray();
fields.add("yuefen");
fields.add("status_jiaoyan");
fields.add("sijishenfenzhenghao");
fields.add("jine");
fields.add("yinhangkahao");
fields.add("status_yinhang");
JSONObject filter = new JSONObject();
filter.put("rel", "and");
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("field", "status_jiaoyan");
jsonObject1.put("method", "empty");
jsonArray.add(jsonObject1);
filter.put("cond", jsonArray);
jsonObject.put("fields", fields);
jsonObject.put("filter", filter);
String jsonString = jsonObject.toJSONString();
String list = V5utils.list(jsonString);
JSONObject jsonObject2 = JSON.parseObject(list);
JSONArray jsonArray1 = jsonObject2.getJSONArray("data");
String yuefen = GongZiUtil.yuefen();
for (Object o : jsonArray1) {
JSONObject test = (JSONObject) o;
String string = test.getString("yuefen");
if (yuefen.equals(string)) {
System.out.println(string);
}
}
}
}

View File

@ -0,0 +1,22 @@
package com.example.sso.test;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class B {
public static void main(String[] args) {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
// 格式化当前日期
String formattedDate = currentDate.format(formatter);
// 输出结果
System.out.println("当前日期YYYY-MM: " + formattedDate);
}
}

View File

@ -0,0 +1,25 @@
package com.example.sso.test;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
@RestController
public class C {
@PostMapping("/example")
public String example(@RequestHeader(value = "Custom-Header") String customHeader, @RequestBody JSONObject cv ) {
if (customHeader.equals("sss")) {
// 处理请求头
String string = cv.getString("data");
return "您成功快乐 " + string ;
}
return "您失败了";
}
}

View File

@ -0,0 +1,47 @@
package com.example.sso.test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.util.HttpUtil;
import com.example.sso.util.JDYUtil;
import com.example.sso.util.V5utils;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class D {
private static String app_key = "F493FDF0DA9B4DF3A826530B568E6BAF";
private static String app_secret = "B9BAA96975C74DB8AF07EB5D5243F56DE2FAE0ED37D64797AB2487EA3F8011CD";
public static void main(String[] args) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Dimission";
JSONObject body = new JSONObject();
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
JSONObject employmentRecord = new JSONObject();
try {
employmentRecord.put("lastWorkDate",df.format(new Date()));//最后工作日期
} catch (Exception e) {
e.printStackTrace();
}
body.put("employmentRecord", employmentRecord);
body.put("userId", 123123);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
}
public static String getToken() throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/token";
JSONObject body = new JSONObject();
body.put("grant_type", "client_credentials");
body.put("app_key", app_key);
body.put("app_secret", app_secret);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString()));
return jsonObject.getString("access_token");
}
}

View File

@ -0,0 +1,22 @@
package com.example.sso.test;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class E {
public static void main(String[] args) {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 格式化日期
String formattedDate = currentDate.format(formatter);
// 输出结果
System.out.println("当前日期YYYY-MM-DD格式: " + formattedDate);
}
}

View File

@ -0,0 +1,84 @@
package com.example.sso.test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.sso.dao.GongZiFaFang;
import com.example.sso.dao.UpDataYes;
import com.example.sso.util.GongZiUtil;
import com.example.sso.util.V5utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PreDestroy;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@RestController
@Slf4j
public class F {
private final ExecutorService executorService = Executors.newFixedThreadPool(3); // 创建一个固定大小为3的线程池
@PostMapping("/TEST")
public Integer gongzi(@RequestBody JSONObject driver) throws InterruptedException {
log.info(driver.toJSONString());
log.info("------------------------------------------------------------");
// 在新线程中执行耗时操作
executorService.submit(() -> {
try {
// 耗时操作
Thread.sleep(5000);
log.info("我是等待线程");
while (true){
Thread.sleep(3000);
System.out.println("1");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // 重新设置中断状态
log.error("Thread was interrupted", e);
}
});
// 再启动两个新线程
executorService.submit(() -> {
try {
// 耗时操作
Thread.sleep(780000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // 重新设置中断状态
log.error("Thread was interrupted", e);
}
});
executorService.submit(() -> {
try {
// 耗时操作
Thread.sleep(780000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // 重新设置中断状态
log.error("Thread was interrupted", e);
}
});
// 立即返回200
return 200;
}
// 确保在应用程序关闭时,执行器服务能够优雅地关闭
// 可以在Spring的@PreDestroy注解方法中添加关闭逻辑
@PreDestroy
public void destroy() {
executorService.shutdown();
}
}

View File

@ -0,0 +1,503 @@
package com.example.sso.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.Charsets;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.TrustStrategy;
import javax.net.ssl.SSLContext;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class APIUtils {
public static final String WEBSITE = "https://www.jiyuankeshang.com";
private static boolean retryIfRateLimited = true;
private String urlGetWidgets;
private String urlGetFormData;
private String urlRetrieveData;
private String urlUpdateData;
private String urlCreateData;
private String urlDeleteData;
private String urlCreateUSer;
private String urlCreatePerson;
private String urlCreatePersonAll;
private String urlCreateDep;
private String urlCreateDepAll;
private String urlGetDepartment;
private String urlGetPeople;
private String urlDeletePeople;
private static String apiKey;
/**
* @param appId - 应用id
* @param entryId - 表单id
* @param apiKey - apiKey
*/
public APIUtils(String appId, String entryId, String apiKey) {
this.apiKey = apiKey;
this.initUrl(appId, entryId);
}
public Map<String, Object> createPerson (Map<String, Object> person) {
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlCreatePerson, person);
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
public Map<String, Object> createDep (Map<String, Object> person) {
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlCreatePerson, person);
data = (Map<String, Object>) result.get("department");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
private void initUrl (String appId, String entryId) {
urlGetWidgets = WEBSITE + "/api/v1/app/" + appId + "/entry/" + entryId + "/widgets";
urlGetFormData = WEBSITE + "/api/v1/app/" + appId + "/entry/" + entryId + "/data";
urlRetrieveData = WEBSITE + "/api/v1/app/" + appId + "/entry/" + entryId + "/data_retrieve";
urlUpdateData = WEBSITE + "/api/v1/app/" + appId + "/entry/" + entryId + "/data_update";
urlCreateData = WEBSITE + "/api/v3/app/" + appId + "/entry/" + entryId + "/data_create";
urlDeleteData = WEBSITE + "/api/v1/app/" + appId + "/entry/" + entryId + "/data_delete";
urlCreatePerson=WEBSITE+"/api/v2/user/create";
urlCreateUSer = WEBSITE + "/api/v2/user/create";
urlCreateDep=WEBSITE+"/api/v2/department/create";
urlCreateDepAll=WEBSITE+"/api/v2/department/import";
urlCreatePersonAll=WEBSITE+"/api/v2/user/import";
urlGetDepartment=WEBSITE+"/api/v2/department/1/department_list";
urlGetPeople=WEBSITE + "/api/v2/department/1/member_list";
urlDeletePeople=WEBSITE+"/api/v2/user/batch_delete";
}
public static HttpClient getSSLHttpClient() throws Exception {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
//信任所有
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
}
/**
* 获取部门成员信息
* @param - 创建数据内容
* @return 更新后的数据
*/
public Map<String, Object> deletePeopleBatch(Map<String,Object> map) {
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlDeletePeople, map);
return result;
// data = (Map<String, Object>) result.get("department");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 获取请求头信息
* @return
*/
public static Header[] getHttpHeaders() {
List<Header> headerList = new ArrayList<Header>();
headerList.add(new BasicHeader("Authorization", "Bearer " + apiKey));
headerList.add(new BasicHeader("Content-Type", "application/json;charset=utf-8"));
return headerList.toArray(new Header[headerList.size()]);
}
/**
* 查询人员信息
* @param username - 创建数据内容
* @return 更新后的数据
*/
public Map<String, Object> findPerson (String username) {
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",WEBSITE + "/api/v2/user/"+username+"/user_retrieve", new HashMap<>());
data = (Map<String, Object>) result.get("data");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 发送HTTP请求
* @param method - HTTP动词 { GET|POST }
* @param url - 请求路径
* @param data - 请求的数据
* @throws Exception
*/
public static Object sendRequest (String method, String url, Map<String, Object> data) throws Exception {
HttpClient client = getSSLHttpClient();
Header[] headers = getHttpHeaders();
HttpRequestBase request;
method = method.toUpperCase();
if ("GET".equals(method)) {
// GET请求
URIBuilder uriBuilder = new URIBuilder(url);
if (data != null) {
// 添加请求参数
for(Map.Entry<String, Object> entry : data.entrySet()) {
uriBuilder.addParameter(entry.getKey(), (String) entry.getValue());
}
}
request = new HttpGet(uriBuilder.build());
} else if ("POST".equals(method)) {
// POST请求
request = new HttpPost(url);
ObjectMapper mapper = new ObjectMapper();
HttpEntity entity = new StringEntity(mapper.writeValueAsString(data), Charsets.UTF_8);
((HttpPost) request).setEntity(entity);
} else {
throw new RuntimeException("不支持的HTTP动词");
}
// 设置请求头
request.setHeaders(headers);
// 发送请求并获取返回结果
HttpResponse response = client.execute(request);
int statusCode = response.getStatusLine().getStatusCode();
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> result = (Map<String, Object>) mapper.readValue(response.getEntity().getContent(), Object.class);
if (statusCode >= 400) {
// 请求错误
if ((Integer) result.get("code") == 8303 && retryIfRateLimited) {
// 频率超限1s后重试
Thread.sleep(1000);
return sendRequest(method, url, data);
} else {
return result;
}
} else {
// 处理返回结果
return result;
}
}
/**
* 获取表单字段
* @return 表单字段
*/
public List<Map<String, Object>> getFormWidgets () {
List<Map<String, Object>> widgets = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST", urlGetWidgets, new HashMap<String, Object>());
widgets = (List<Map<String, Object>>) result.get("widgets");
} catch (Exception e) {
e.printStackTrace();
}
return widgets;
}
public List<Map<String, Object>> createUser(String username, String name, Integer[] departments){
Map<String, Object> data = null;
try {
Map<String, Object> requestData = new HashMap<String, Object>();
requestData.put("username",username);
requestData.put("name",name);
requestData.put("departments",departments);
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlCreateUSer, requestData);
data = (Map<String, Object>) result.get("data");
}catch (Exception e) {
e.printStackTrace();
}
return (List<Map<String, Object>>) data;
}
/**
* 按条件获取表单数据
* @param limit - 数据条数
* @param fields - 显示的字段
* @param filter - 过滤条件
* @param dataId - 上次取数的最后一个数据id
* @return - 返回的数据
*/
public List<Map<String, Object>> getFormData (final int limit, final String[] fields, final Map<String, Object> filter, String dataId) {
List<Map<String, Object>> data = null;
try {
// 构造请求数据
Map<String, Object> requestData = new HashMap<String, Object>() {
{
put("limit", limit);
put("fields", fields);
put("filter", filter);
}
};
if (dataId != null) {
requestData.put("data_id", dataId);
}
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST", urlGetFormData, requestData);
data = (List<Map<String, Object>>) result.get("data");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 按条件获取全部表单数据
* @return 表单数据
*/
public List<Map<String, Object>> getAllFormData (String[] fields, Map<String, Object> filter) {
List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
String offset = null;
do {
List<Map<String, Object>> data = this.getFormData(100, fields, filter, offset);
// 获取返回的数据
if (data == null || data.isEmpty()) {
// 已经获取全部的数据
offset = null;
} else {
// 获取最后一条数据的id
offset = (String) data.get(data.size() - 1).get("_id");
dataList.addAll(data);
}
} while (offset != null);
return dataList;
}
/**
* 搜索单条数据
* @param dataId - 要查询的数据id
* @return 表单数据
*/
public Map<String, Object> retrieveData (String dataId) {
Map<String, Object> data = null;
try {
Map<String, Object> requestData = new HashMap<String, Object>();
requestData.put("data_id", dataId);
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST", urlRetrieveData, requestData);
data = (Map<String, Object>) result.get("data");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 新增部门
* @param - 创建数据内容
* @return 更新后的数据
*/
public Map<String, Object> createDataDep (Map<String, Object> requestData) {
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlCreateDep, requestData);
// data = (Map<String, Object>) result.get("department");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 批量创建部门
* @param - 创建数据内容
* @return 更新后的数据
*/
public Map<String, Object> createDataDepAll (Map<String, Object> requestData) {
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlCreateDepAll, requestData);
// data = (Map<String, Object>) result.get("department");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 批量创建人员
* @param - 创建数据内容
* @return 更新后的数据
*/
public Map<String, Object> createDataPersonAll (Map<String, Object> requestData) {
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlCreatePersonAll, requestData);
System.out.println(result);
return result;
// data = (Map<String, Object>) result.get("department");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获取部门信息
* @param - 创建数据内容
* @return 更新后的数据
*/
public Map<String, Object> getDepartment() {
Map<String, Object> map=new HashMap<>();
map.put("has_child",1);
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlGetDepartment,map);
System.out.println(result);
return result;
// data = (Map<String, Object>) result.get("department");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 获取部门成员信息
* @param - 创建数据内容
* @return 更新后的数据
*/
public Map<String, Object> getDepartmentPerson(String dno) {
Map<String, Object> map=new HashMap<>();
// map.put("has_child",1);
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",WEBSITE+"/api/v2/department/"+dno+"/member_list",map);
return result;
// data = (Map<String, Object>) result.get("department");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
public Map<String, Object> deleteDepartment(Integer no) {
Map<String, Object> map=new HashMap<>();
map.put("has_child",1);
Map<String, Object> data = null;
try {
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",WEBSITE+"/api/v2/department/"+no+"/delete",new HashMap<>());
System.out.println(result);
return result;
// data = (Map<String, Object>) result.get("department");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
// /**
// * 新增部门
// * @param - 创建数据内容
// * @return 更新后的数据
// */
// public Map<String, Object> createDataDep (Map<String, Object> requestData) {
// Map<String, Object> data = null;
// try {
// Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlCreateDep, requestData);
// data = (Map<String, Object>) result.get("data");
// } catch (Exception e) {
// e.printStackTrace();
// }
// return data;
// }
/**
* 创建单条数据
* @param rawData - 创建数据内容
* @return 更新后的数据
*/
public Map<String, Object> createData (Map<String, Object> rawData) {
Map<String, Object> data = null;
try {
Map<String, Object> requestData = new HashMap<String, Object>();
requestData.put("data", rawData);
requestData.put("is_start_workflow",true);
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlCreateData, requestData);
data = (Map<String, Object>) result.get("data");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 获取所有的人在简道云
* @return 更新后的数据
*/
public List<Map<String,Object>> getAllPeople () {
List<Map<String,Object>> data = null;
try {
Map<String, Object> requestData = new HashMap<String, Object>();
requestData.put("has_child",true);
// System.out.println("准备发起HTTP请求"+urlGetPeople);
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST",urlGetPeople, requestData);
data = (List<Map<String,Object>>) result.get("users");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 更新单条数据
* @return 更新结果
*/
public Map<String, Object> updateData (String dataId, Map<String, Object> update) {
Map<String, Object> data = null;
try {
Map<String, Object> requestData = new HashMap<String, Object>();
requestData.put("data_id", dataId);
requestData.put("data", update);
Map<String, Object> result = (Map<String, Object>) this.sendRequest("POST", urlUpdateData, requestData);
data = (Map<String, Object>) result.get("data");
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* 删除单条数据
* @return 删除结果
*/
public Map<String, String> deleteData (String dataId) {
Map<String, String> result = null;
try {
Map<String, Object> requestData = new HashMap<String, Object>();
requestData.put("data_id", dataId);
result = (Map<String, String>) this.sendRequest("POST", urlDeleteData, requestData);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}

View File

@ -0,0 +1,377 @@
package com.example.sso.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@Slf4j
public class BeiSenTest {
private static String app_key = "F493FDF0DA9B4DF3A826530B568E6BAF";
private static String app_secret = "B9BAA96975C74DB8AF07EB5D5243F56DE2FAE0ED37D64797AB2487EA3F8011CD";
private static int i=0;
public static void main(String[] args) {
// 同步职工数据
// try {
//// deleteUser(608421892);
// } catch (NoSuchAlgorithmException e) {
// e.printStackTrace();
// } catch (KeyManagementException e) {
// e.printStackTrace();
// }
// //修改职工基础信息数据
try {
JSONArray beiSens = JDYUtil.getAllDriversBeiSen();//查询
JSONArray drivers = JDYUtil.getAllDrivers();//查询
JSONObject orgNos=JDYUtil.getOrgNos();
JSONObject jsonObject = new JSONObject();
for (Object o : drivers) {
HashMap<String, Object> driver = (HashMap<String, Object>) o;
jsonObject.put((String) driver.get("shjh") + "@yinjian.com", driver);
}
String token=getToken();
int i=0;
for (Object o : beiSens) {
i=i+1;
JSONObject driver = (JSONObject) o;
String xm=driver.getString("xm");
if (xm.equals("宋乃庆")){
if (jsonObject.getJSONObject(driver.getString("zhanghao"))!=null){
BeiSenTest.updateUser(jsonObject.getJSONObject(driver.getString("zhanghao")),driver.getInteger("oid"),orgNos,token);
System.out.println(jsonObject.getJSONObject(driver.getString("zhanghao")));
//更新简道云数据
JDYUtil.updateBeiSenId(jsonObject.getJSONObject(driver.getString("zhanghao")).
getString("_id"),driver.getString("oid"));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
// JSONArray drivers=JDYUtil.getAllDrivers();//查询
// JSONObject orgNos=JDYUtil.getOrgNos();
// JSONArray deps=new JSONArray();
// for (Object o:drivers){
// HashMap<String,Object> driver=(HashMap<String,Object>)o;
//// try {
////// BeiSenTest.updateUser(driver,(String) driver.get("shfzhh"),orgNos);
//// } catch (NoSuchAlgorithmException e) {
//// e.printStackTrace();
//// } catch (KeyManagementException e) {
//// e.printStackTrace();
//// }
// }
// Set set=new HashSet();//创建set集合
// for (int i=0;i<deps.size();i++){
// set.add(deps.get(i));//数组中的数据循环加入集合中
// }
// deps=JSONArray.parseArray(set.toString());//转化为数组
// System.out.println(deps.toJSONString());
}
/**
* 创建人员信息
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void createUser(JSONObject driver, JSONObject orgNos,JSONArray deps) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
employeeInformation.put("email",driver.get("yxbs"));//邮箱
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
// employeeInformation.put("email", driver.get("shjh") + "@yinjian.com");//邮箱
employeeInformation.put("mobilePhone", driver.get("shjh"));//身份证号码
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期\
employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//身份证号码
employmentRecord.put("probation", 0);//试用期无试用期为0
String name = (String) driver.get("name");//
String uu=(String) driver.get("ssbm") + (String) driver.get("fs");
for (String str : orgNos.keySet()) {
if (str.equals(driver.get("ssbm"))) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
Integer O=employmentRecord.getInteger("OIdDepartment");
if (O==null){
deps.add(uu);
System.out.println("");
}
employmentRecord.put("originalId", driver.get("shfzhh"));//外部编码ID
String ssbm = (String) driver.get("ssbm");//所属部门
String ssbm1 = "景城利华";
if(ssbm.equals(ssbm1)){
employmentRecord.put("employmentType", "5cc3e855-f9b8-4cec-8860-b89d945ba615");//人员类别
}else {
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
}
//employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
// JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
// System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
public static String getToken() throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/token";
JSONObject body = new JSONObject();
body.put("grant_type", "client_credentials");
body.put("app_key", app_key);
body.put("app_secret", app_secret);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString()));
return jsonObject.getString("access_token");
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void createUser(JSONObject driver, JSONObject orgNos,String id) throws NoSuchAlgorithmException, KeyManagementException {
String token=getToken();
if (true){
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
employeeInformation.put("email",driver.get("yxbs"));//邮箱
// employeeInformation.put("originalId",driver.get("shfzhh"));//外部ID
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
employeeInformation.put("mobilePhone", driver.get("shjh"));//电话号码
employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//电话
JSONObject employmentRecord = new JSONObject();
String dang = TimeUtil.dang();
employmentRecord.put("entryDate",dang /*TimeUtil.timeConversion1(driver.getString("lrrq"))*/ );//入职日期
employmentRecord.put("probation", 0);//试用期无试用期为0
String name = (String) driver.get("name");//
for (String str : orgNos.keySet()) {
if (str.equals(driver.getString("fs"))){
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
//区分是否TYTY的人员类别为"5cc3e855-f9b8-4cec-8860-b89d945ba615",其余为"020c47b0-74b7-4a75-b454-e9905f64e1fc"
/* String ssbm = (String) driver.get("ssbm");//所属部门
String ssbm1 = "景城利华";
if(ssbm.equals(ssbm1)){
employmentRecord.put("employmentType", "5cc3e855-f9b8-4cec-8860-b89d945ba615");//人员类别
}else {
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
}*/
employmentRecord.put("employmentType", "70b80df9-c88c-4e2c-ab3d-a3a0a59d7d4c");
//employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(),token));
JSONObject returnData=jsonObject.getJSONObject("data");
System.out.println(driver.get("shfzhh")+"的创建账户动作返回为:"+jsonObject.toJSONString());
if (jsonObject.getString("code").equals("200")){
JDYUtil.updateBeiSenId(id,returnData.getString("userId"));
}else {
updateUser(driver,driver.getInteger("beisen_id"),orgNos,token);
}
}else {
//如果不是新增则修改数据
updateUser(driver,driver.getInteger("beisen_id"),orgNos,token);
}
// return jsonObject.getString("access_token");
}
public static void createUserss(String xm, String yxbs, String shfzhh, String shjh, String fs, String beisen_id, JSONObject orgNos,String id) throws NoSuchAlgorithmException, KeyManagementException {
String token = getToken();
Integer beisenid = 0;
if (true) {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", xm);//姓名:张三
employeeInformation.put("email", yxbs);//邮箱
// employeeInformation.put("originalId",driver.get("shfzhh"));//外部ID
employeeInformation.put("iDNumber", shfzhh);//身份证号码
employeeInformation.put("mobilePhone", shjh);//电话号码
employeeInformation.put("emergencyContactPhone", shjh);//电话
JSONObject employmentRecord = new JSONObject();
String dang = TimeUtil.dang();
employmentRecord.put("entryDate", dang /*TimeUtil.timeConversion1(driver.getString("lrrq"))*/);//入职日期
employmentRecord.put("probation", 0);//试用期无试用期为0
for (String str : orgNos.keySet()) {
if (str.equals(fs)) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
//区分是否TYTY的人员类别为"5cc3e855-f9b8-4cec-8860-b89d945ba615",其余为"020c47b0-74b7-4a75-b454-e9905f64e1fc"
/* String ssbm = (String) driver.get("ssbm");//所属部门
String ssbm1 = "景城利华";
if(ssbm.equals(ssbm1)){
employmentRecord.put("employmentType", "5cc3e855-f9b8-4cec-8860-b89d945ba615");//人员类别
}else {
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
}*/
employmentRecord.put("employmentType", "70b80df9-c88c-4e2c-ab3d-a3a0a59d7d4c");
//employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), token));
JSONObject returnData = jsonObject.getJSONObject("data");
System.out.println(shfzhh + "的创建账户动作返回为:" + jsonObject.toJSONString());
if (jsonObject.getString("code").equals("200")) {
String userId = JDYUtil.updateBeiSenId(id, returnData.getString("userId"));
log.info(userId);
} else {
beisenid = Integer.parseInt(beisen_id);
updateUserss(xm, yxbs, shfzhh, shjh, fs, beisenid, orgNos, token);
}
} else {
//如果不是新增则修改数据
updateUserss(xm, yxbs, shfzhh, shjh, fs, beisenid, orgNos, token);
}
// return jsonObject.getString("access_token");
}
/**
* 修改人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void updateUser(JSONObject driver, Integer id,JSONObject orgNos,String token) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/UpdateEmployee";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
employeeInformation.put("email",driver.get("yxbs"));//邮箱
// employeeInformation.put("originalId",driver.get("shfzhh"));//外部ID
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
employeeInformation.put("mobilePhone", driver.get("shjh"));//电话号码
employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//电话
JSONObject employmentRecord = new JSONObject();
/* String ssbm = (String) driver.get("ssbm");//所属部门
String ssbm1 = "景城利华";
if(ssbm.equals(ssbm1)){
employmentRecord.put("employmentType", "5cc3e855-f9b8-4cec-8860-b89d945ba615");//人员类别
}else {
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
}*/
employmentRecord.put("employmentType", "70b80df9-c88c-4e2c-ab3d-a3a0a59d7d4c");
//employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
for (String str : orgNos.keySet()) {
if (str.equals(driver.get("fs"))) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(),token));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
public static void updateUserss(String xm, String yxbs, String shfzhh, String shjh, String fs, Integer id,JSONObject orgNos,String token) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/UpdateEmployee";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", xm);//姓名:张三
employeeInformation.put("email",yxbs);//邮箱
// employeeInformation.put("originalId",driver.get("shfzhh"));//外部ID
employeeInformation.put("iDNumber", shfzhh);//身份证号码
employeeInformation.put("mobilePhone", shjh);//电话号码
employeeInformation.put("emergencyContactPhone", fs);//电话
JSONObject employmentRecord = new JSONObject();
/* String ssbm = (String) driver.get("ssbm");//所属部门
String ssbm1 = "景城利华";
if(ssbm.equals(ssbm1)){
employmentRecord.put("employmentType", "5cc3e855-f9b8-4cec-8860-b89d945ba615");//人员类别
}else {
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
}*/
employmentRecord.put("employmentType", "70b80df9-c88c-4e2c-ab3d-a3a0a59d7d4c");
//employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
for (String str : orgNos.keySet()) {
if (str.equals(fs)) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(),token));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
/**
* 离职人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void deleteUser(Integer id) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Dimission";
JSONObject body = new JSONObject();
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
JSONObject employmentRecord = new JSONObject();
try {
employmentRecord.put("lastWorkDate",df.format(new Date()));//最后工作日期
} catch (Exception e) {
e.printStackTrace();
}
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
}

View File

@ -0,0 +1,293 @@
package com.example.sso.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.*;
public class BeiSenTest1 {
private static String app_key = "F493FDF0DA9B4DF3A826530B568E6BAF";
private static String app_secret = "B9BAA96975C74DB8AF07EB5D5243F56DE2FAE0ED37D64797AB2487EA3F8011CD";
private static int i = 0;
public static void main(String[] args) {
try {
JSONArray drivers = JDYUtil.getAllDrivers1();//查询
for (Object o : drivers) {
JSONObject driver=(JSONObject)o;
String shfzhh = (String) driver.get("shfzhh");//身份证号码
JSONObject person = findPersonById_Card(shfzhh);
JSONObject orgNos = JDYUtil.getOrgNos();
createUser(person, orgNos, person.getString("_id"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 根据身份证查询驾驶员信息表数据
*/
public static JSONObject findPersonById_Card(String id_card_num) {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "667ccd162e0bccca52d91e66", "AXtEol6d7l0w2l5dUuqvhbg2kjzfYv6r");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add(id_card_num);
condList.add(new HashMap<String, Object>() {
{
put("field", "shfzhh");//查新字段的名称/别名
put("method", "eq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"xm", "ssbm",
"fs","yxbs","lrrq","shjh","shfzhh","shjh","beisen_id"},//身份证号码
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
JSONObject jsonObject=new JSONObject();
jsonObject.put("list",datas);
JSONArray jsonArray1=new JSONArray();
for (Map<String, Object> o:datas){
String time=(String) o.get("lrrq");
if (time!=null){
o.put("lrrq",TimeUtil.timeConversion2(time));
}
jsonArray1.add(o);
}
return jsonArray1.getJSONObject(0);
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
// public static void createUser(JSONObject driver, JSONObject orgNos,JSONArray deps) throws NoSuchAlgorithmException, KeyManagementException {
// String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
// JSONObject body = new JSONObject();
// body.put("employeeInformation", "client_credentials");
// JSONObject employeeInformation = new JSONObject();
// employeeInformation.put("name", driver.get("xm"));//姓名:张三
// employeeInformation.put("email",driver.get("yxbs"));//邮箱
// employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
//// employeeInformation.put("email", driver.get("shjh") + "@yinjian.com");//邮箱
// employeeInformation.put("mobilePhone", driver.get("shjh"));//身份证号码
// JSONObject employmentRecord = new JSONObject();
// employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期\
// employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//身份证号码
// employmentRecord.put("probation", 0);//试用期无试用期为0
// String name = (String) driver.get("name");//
// String uu=(String) driver.get("ssbm") + (String) driver.get("fs");
// for (String str : orgNos.keySet()) {
// if (str.equals((String) driver.get("ssbm") + (String) driver.get("fs")+"司")) {
// employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
// break;
// }
// }
// Integer O=employmentRecord.getInteger("OIdDepartment");
// if (O==null){
// deps.add(uu);
// System.out.println("");
// }
// employmentRecord.put("originalId", driver.get("shfzhh"));//外部编码ID
// employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
// employmentRecord.put("oIdJobPost", "149359");//职务
// body.put("employeeInformation", employeeInformation);
// body.put("employmentRecord", employmentRecord);
// JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
// System.out.println(jsonObject.toJSONString());
//// JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
//// System.out.println(jsonObject.toJSONString());
//// return jsonObject.getString("access_token");
//}
public static String getToken() throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/token";
JSONObject body = new JSONObject();
body.put("grant_type", "client_credentials");
body.put("app_key", app_key);
body.put("app_secret", app_secret);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString()));
return jsonObject.getString("access_token");
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void createUser(JSONObject driver, JSONObject orgNos, String id) throws NoSuchAlgorithmException, KeyManagementException {
String token = getToken();
// if (driver.getString("beisen_id") == null || driver.getString("beisen_id").equals("")) {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
employeeInformation.put("email", driver.get("yxbs"));//邮箱
employeeInformation.put("originalId", driver.get("shfzhh"));//外部ID
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
employeeInformation.put("mobilePhone", driver.get("shjh"));//电话号码
employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//电话
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期
employmentRecord.put("probation", 0);//试用期无试用期为0
String name = (String) driver.get("name");//
for (String str : orgNos.keySet()) {
if (str.equals(driver.get("fs"))) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), token));
JSONObject returnData = jsonObject.getJSONObject("data");
System.out.println(driver.get("shfzhh") + "的创建账户动作返回为:" + jsonObject.toJSONString());
if (jsonObject.getString("code").equals("200")) {
JDYUtil.updateBeiSenId(id, returnData.getString("userId"));
}
// } else {
//如果不是新增则修改数据
// updateUser(driver, driver.getInteger("beisen_id"), orgNos, token);
// }
// return jsonObject.getString("access_token");
}
/**
* 创建人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
// public static void createUser(JSONObject driver, JSONObject orgNos,String id) throws NoSuchAlgorithmException, KeyManagementException {
// String token=getToken();
// if (driver.getString("beisen_id")==null||driver.getString("beisen_id").equals("")){
// String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Create";
// JSONObject body = new JSONObject();
// body.put("employeeInformation", "client_credentials");
// JSONObject employeeInformation = new JSONObject();
// employeeInformation.put("name", driver.get("xm"));//姓名:张三
// employeeInformation.put("email",driver.get("yxbs"));//邮箱
// employeeInformation.put("originalId",driver.get("shfzhh"));//外部ID
// employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
// employeeInformation.put("mobilePhone", driver.get("shjh"));//电话号码
// employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//电话
// JSONObject employmentRecord = new JSONObject();
// employmentRecord.put("entryDate", driver.get("lrrq"));//入职日期
// employmentRecord.put("probation", 0);//试用期无试用期为0
// String name = (String) driver.get("name");//
// employmentRecord.put("OIdDepartment",600186);//试用期无试用期为0
// body.put("employeeInformation", employeeInformation);
// body.put("employmentRecord", employmentRecord);
// JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(),token));
// JSONObject returnData=jsonObject.getJSONObject("data");
// try {
// if (returnData!=null){
// System.out.println(driver.get("shfzhh")+"的创建账户动作返回为:"+jsonObject.toJSONString());
// if (jsonObject.getString("code").equals("200")){
// JDYUtil.updateBeiSenId(id,returnData.getString("userId"));
// }
// }
// }catch (Exception e){
// e.printStackTrace();
// }
// }else {
// //如果不是新增则修改数据
// updateUser(driver,driver.getInteger("beisen_id"),orgNos,token);
// }
//// return jsonObject.getString("access_token");
// }
/**
* 修改人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void updateUser(JSONObject driver, Integer id, JSONObject orgNos, String token) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/UpdateEmployee";
JSONObject body = new JSONObject();
body.put("employeeInformation", "client_credentials");
JSONObject employeeInformation = new JSONObject();
employeeInformation.put("name", driver.get("xm"));//姓名:张三
employeeInformation.put("email", driver.get("yxbs"));//邮箱
employeeInformation.put("originalId", driver.get("shfzhh"));//外部ID
employeeInformation.put("iDNumber", driver.get("shfzhh"));//身份证号码
employeeInformation.put("mobilePhone", driver.get("shjh"));//电话号码
employeeInformation.put("emergencyContactPhone", driver.get("shjh"));//电话
JSONObject employmentRecord = new JSONObject();
employmentRecord.put("employmentType", "020c47b0-74b7-4a75-b454-e9905f64e1fc");//人员类别
for (String str : orgNos.keySet()) {
if (str.equals((String) driver.get("ssbm") + (String) driver.get("fs") + "")) {
employmentRecord.put("OIdDepartment", orgNos.getInteger(str));//试用期无试用期为0
break;
}
}
employmentRecord.put("oIdJobPost", "149359");//职务
body.put("employeeInformation", employeeInformation);
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), token));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
/**
* 离职人员信息
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static void deleteUser(Integer id) throws NoSuchAlgorithmException, KeyManagementException {
String url = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Employee/Dimission";
JSONObject body = new JSONObject();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
JSONObject employmentRecord = new JSONObject();
try {
employmentRecord.put("lastWorkDate", df.format(new Date()));//最后工作日期
} catch (Exception e) {
e.printStackTrace();
}
body.put("employmentRecord", employmentRecord);
body.put("userId", id);
JSONObject jsonObject = JSON.parseObject(HttpUtil.sendPost(url, body.toJSONString(), getToken()));
System.out.println(jsonObject.toJSONString());
// return jsonObject.getString("access_token");
}
}

View File

@ -0,0 +1,18 @@
package com.example.sso.util;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class GongZiUtil {
public static String yuefen(){
LocalDate currentDate = LocalDate.now();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
// 格式化当前日期
String formattedDate = currentDate.format(formatter);
return formattedDate;
}
}

View File

@ -0,0 +1,265 @@
package com.example.sso.util;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
/** * Http工具类发送Http请求 Get请求请将参数放在url中 Post请求请将参数放在Map中 * * @author 程高伟 * @date 2017年1月5日 下午6:03:50 */
public class HttpUtil {
// private static final Logger log = LoggerFactory.getLogger(HttpUtil.class);
private static final CloseableHttpClient httpclient = HttpClients.createDefault();
private static final String userAgent = "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36";
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sc = SSLContext.getInstance("SSLv3");
// 实现一个X509TrustManager接口用于绕过验证不用修改里面的方法
X509TrustManager trustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
String paramString) throws CertificateException {
}
@Override
public void checkServerTrusted(
java.security.cert.X509Certificate[] paramArrayOfX509Certificate,
String paramString) throws CertificateException {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
};
sc.init(null, new TrustManager[] { trustManager }, null);
return sc;
}
/** * 发送HttpGet请求 * * @param url * 请求地址 * @return 返回字符串 */
public static String sendGet(String url,String token) throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslcontext = createIgnoreVerifySSL();
// 设置协议http和https对应的处理socket链接工厂的对象
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.INSTANCE)
.register("https", new SSLConnectionSocketFactory(sslcontext))
.build();
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connManager).build();
String result = null;
CloseableHttpResponse response = null;
try {
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("User-Agent", userAgent);
httpGet.setHeader("Authorization", "Bearer "+token);
response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
if (entity != null) {
result = EntityUtils.toString(entity,"UTF-8");
}
} catch (Exception e) {
// log.error("处理失败 {}" + e);
e.printStackTrace();
} finally {
if (response != null) {
try {
response.close();
} catch (IOException e) {
// // log.error(e.getMessage());
}
}
}
return result;
}
/** * 发送HttpPost请求参数为json字符串 * * @param url * @param jsonStr * @return */
public static String sendPost(String url, String jsonStr,String token) throws KeyManagementException, NoSuchAlgorithmException {
//采用绕过验证的方式处理https请求
SSLContext sslcontext = createIgnoreVerifySSL();
// 设置协议http和https对应的处理socket链接工厂的对象
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.INSTANCE)
.register("https", new SSLConnectionSocketFactory(sslcontext))
.build();
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connManager).build();
String result = null;
// 字符串编码
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
// 设置content-type
entity.setContentType("application/json");
HttpPost httpPost = new HttpPost(url);
// 防止被当成攻击添加的
httpPost.setHeader("User-Agent", userAgent);
httpPost.setHeader("Authorization", "Bearer "+token);
// 接收参数设置
httpPost.setHeader("Accept", "application/json");
httpPost.setEntity(entity);
CloseableHttpResponse response = null;
try {
response = httpClient.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
result = EntityUtils.toString(httpEntity);
} catch (IOException e) {
// // log.error(e.getMessage());
} finally {
// 关闭CloseableHttpResponse
if (response != null) {
try {
response.close();
} catch (IOException e) {
// // log.error(e.getMessage());
}
}
}
return result;
}
/** * 发送HttpPost请求参数为map * * @param url * 请求地址 * @param map * 请求参数 * @return 返回字符串 */
public static String sendPost(String url, Map<String, String> map) {
// 设置参数
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
for (Map.Entry<String, String> entry : map.entrySet()) {
formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
// 编码
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
// 取得HttpPost对象
HttpPost httpPost = new HttpPost(url);
// 防止被当成攻击添加的
httpPost.setHeader("User-Agent", userAgent);
// 参数放入Entity
httpPost.setEntity(formEntity);
CloseableHttpResponse response = null;
String result = null;
try {
// 执行post请求
response = httpclient.execute(httpPost);
// 得到entity
HttpEntity entity = response.getEntity();
// 得到字符串
result = EntityUtils.toString(entity);
} catch (IOException e) {
// log.error(e.getMessage());
} finally {
if (response != null) {
try {
response.close();
} catch (IOException e) {
// log.error(e.getMessage());
}
}
}
return result;
}
/** * 发送HttpPost请求参数为json字符串 * * @param url * @param jsonStr * @return */
public static String sendPost(String url, String jsonStr) throws KeyManagementException, NoSuchAlgorithmException {
//采用绕过验证的方式处理https请求
SSLContext sslcontext = createIgnoreVerifySSL();
// 设置协议http和https对应的处理socket链接工厂的对象
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.INSTANCE)
.register("https", new SSLConnectionSocketFactory(sslcontext))
.build();
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connManager).build();
String result = null;
// 字符串编码
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8);
// 设置content-type
entity.setContentType("application/json");
HttpPost httpPost = new HttpPost(url);
// 防止被当成攻击添加的
httpPost.setHeader("User-Agent", userAgent);
httpPost.setHeader("Authorization", "Bearer ");
// 接收参数设置
httpPost.setHeader("Accept", "application/json");
httpPost.setEntity(entity);
CloseableHttpResponse response = null;
try {
response = httpClient.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
result = EntityUtils.toString(httpEntity);
} catch (IOException e) {
// log.error(e.getMessage());
} finally {
// 关闭CloseableHttpResponse
if (response != null) {
try {
response.close();
} catch (IOException e) {
// log.error(e.getMessage());
}
}
}
System.out.println(result);
return result;
}
/** * 发送不带参数的HttpPost请求 * * @param url * @return */
public static String sendPost(String url) {
String result = null;
// 得到一个HttpPost对象
HttpPost httpPost = new HttpPost(url);
// 防止被当成攻击添加的
httpPost.setHeader("User-Agent", userAgent);
CloseableHttpResponse response = null;
try {
// 执行HttpPost请求并得到一个CloseableHttpResponse
response = httpclient.execute(httpPost);
// 从CloseableHttpResponse中拿到HttpEntity
HttpEntity entity = response.getEntity();
// 将HttpEntity转换为字符串
result = EntityUtils.toString(entity);
} catch (IOException e) {
// log.error(e.getMessage());
} finally {
// 关闭CloseableHttpResponse
if (response != null) {
try {
response.close();
} catch (IOException e) {
// log.error(e.getMessage());
}
}
}
return result;
}
}

View File

@ -0,0 +1,33 @@
package com.example.sso.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
public class J905Util {
/**
* 请求成功
* @param data
* @return
*/
public static JSONObject returnOK(JSONArray data){
JSONObject jsonObject=new JSONObject();
jsonObject.put("code",2000);
jsonObject.put("message","操作成功");
jsonObject.put("result",data);
return jsonObject;
}
/**
* 请求失败
* @param
* @return
*/
public static JSONObject returnLoser(int num,String meg){
JSONObject jsonObject=new JSONObject();
jsonObject.put("code",num);
jsonObject.put("message",meg);
return jsonObject;
}
}

View File

@ -0,0 +1,484 @@
package com.example.sso.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
public class JDYUtil {
public static void main(String[] args) {
// JSONArray drivers=JDYUtil.getAllDrivers();//查询
// for (Object o:drivers){
// HashMap<String,Object> driver=(HashMap<String,Object>)o;
// updateToJDY((String) driver.get("_id"),(String) driver.get("shjh")+"@yinjian.com");
// }
getAllOtherPer();
}
public static List<Map<String, Object>> getAllOtherPerson() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("5e129b2a041dd80006ab6f68", "639e03a23bd359000afb50e4", "jPK0bjd46jhmjdrRgi8Txts9wuKeqFA1");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "name");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(15000, new String[]{"_id", "", "",""},
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i=0;
Double sum=0.0;
for (Map<String, Object> o:datas){
HashMap<String,Object> map=(HashMap<String,Object>)o.get("_widget_1671300003467");
String name=(String) map.get("name");
if (name.equals("Taryn-章婷婷")){
i=i+1;
try {
Double fen=(Double)o.get("_widget_1671300003485");
sum=sum+fen;
}catch (Exception e){
int fen=(int)o.get("_widget_1671300003485");
sum=sum+fen;
}
}
}
Double age=sum/i;
return datas;
}
public static JSONObject getAllTuiJian() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "63c0af1e6a928200087c72d5", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "beituijian_certificatenumber");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(15000, new String[]{"_id", "beituijian_certificatenumber", "beituijian_name"},
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
JSONObject jsonObject=new JSONObject();
for (Map<String, Object> map:datas){
String beituijian_certificatenumber=(String) map.get("beituijian_certificatenumber");
jsonObject.put(beituijian_certificatenumber,map);
}
return jsonObject;
}
public static List<Map<String, Object>> getAllOtherPer() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("5e129b2a041dd80006ab6f68", "6396f5fbdcc24b000ae1e9ac", "jPK0bjd46jhmjdrRgi8Txts9wuKeqFA1");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "name");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(15000, new String[]{"_id", "", "",""},
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i=0;
Double sum=0.0;
for (Map<String, Object> o:datas){
// HashMap<String,Object> map=();
// String name=(String) map.get("name");
if (o.get("_widget_1665547160471").equals("组长")){
i=i+1;
try {
// Double fen=(Double)o.get("_widget_1671300003485");
// sum=sum+fen;
}catch (Exception e){
// int fen=(int)o.get("_widget_1671300003485");
// sum=sum+fen;
}
}
}
Double age=sum/i;
return datas;
}
/**
* 查询每个人的承包金标准 分别为 承包金(月份)、个税、保养费、调度费、社保 组成
* @param
* @return
*/
public static JSONArray getAllDrivers() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "667ccd162e0bccca52d91e66", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("运营");
JSONArray jsonArray2 = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray2.add("");
// JSONArray jsonArray3 = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
// jsonArray3.add("23分");
condList.add(new HashMap<String, Object>() {
{
put("field", "status");//查新字段的名称/别名
put("method", "eq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
condList.add(new HashMap<String, Object>() {
{
put("field", "beisen_id");//查新字段的名称/别名
put("method", "empty");//判断的方法
// put("value", jsonArray2);//查询的条件
}
});
// condList.add(new HashMap<String, Object>() {
// {
// put("field", "fs");//查新字段的名称/别名
// put("method", "eq");//判断的方法
// put("value", jsonArray3);//查询的条件
// }
// });
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"xm", "ssbm",
"fs","yxbs","lrrq","shjh","shfzhh","shjh","beisen_id"},//姓名,所属部门,分司
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i=1;
if (datas!=null&&datas.size()!=0){
while (i!=0){
if (datas.size()>(i*10000-1)){
String id=(String) (datas.get(i*10000-1).get("_id"));
List<Map<String, Object>> data=findData(api,filter,id);
if (data==null){
i=0;
}else {
datas.addAll(data);
i=i+1;
}
}else {
i=0;
}
}
}
JSONObject jsonObject=new JSONObject();
jsonObject.put("list",datas);
JSONArray jsonArray1=new JSONArray();
for (Map<String, Object> o:datas){
String time=(String) o.get("lrrq");
if (time!=null){
o.put("lrrq",TimeUtil.timeConversion1(time));
}
jsonArray1.add(o);
}
return jsonArray1;
}
/**
* 查询每个人的承包金标准 分别为 承包金(月份)、个税、保养费、调度费、社保 组成
* @param
* @return
*/
public static JSONArray getAllDrivers1() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "6437906af93cf400083ddb7b", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "xm");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"shfzhh"},//身份证号码
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
JSONObject jsonObject=new JSONObject();
jsonObject.put("list",datas);
return jsonObject.getJSONArray("list");
}
/**
* 查询北森导入数据人员信息表
* @param
* @return
*/
public static JSONArray getAllDriversBeiSen() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "63be479b8d5076000a259361", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "zhanghao");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
condList.add(new HashMap<String, Object>() {
{
put("field", "beisen_id");//查新字段的名称/别名
put("method", "eq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"xm","zhanghao",
"oid","beisen_id"},//姓名,所属部门,分司,
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
int i=1;
if (datas!=null&&datas.size()!=0){
while (i!=0){
if (datas.size()>(i*10000-1)){
String id=(String) (datas.get(i*10000-1).get("_id"));
List<Map<String, Object>> data=findData1(api,filter,id);
if (data==null){
i=0;
}else {
datas.addAll(data);
i=i+1;
}
}else {
i=0;
}
}
}
JSONObject jsonObject=new JSONObject();
jsonObject.put("list",datas);
return jsonObject.getJSONArray("list");
}
/**
* 查询
* @param
* @return
*/
public static JSONObject getOrgNos() {
//需要修改 appid entryid apikey
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "63b67cbb8de4d3000a4c60e2", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
final List<Map<String, Object>> condList = new ArrayList<Map<String, Object>>();
//因为想查询大于50的数据所以创建一个数组
JSONArray jsonArray = new JSONArray();
//在这个数组里面放一个数值类型的数字,用来判断查询范围
jsonArray.add("");
condList.add(new HashMap<String, Object>() {
{
put("field", "status");//查新字段的名称/别名
put("method", "nq");//判断的方法
put("value", jsonArray);//查询的条件
}
});
Map<String, Object> filter = new HashMap<String, Object>() {
{
put("rel", "and");
put("cond", condList);
}
};
//字段别名
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"name", "zuzhidanyuan_id"},
//姓名,所属部门,分司
filter, null);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
JSONObject jsonObject=new JSONObject();
for (Map<String, Object> data:datas){
jsonObject.put((String) data.get("name"),data.get("zuzhidanyuan_id"));
}
return jsonObject;
}
private static List<Map<String, Object>> findData(APIUtils api,Map<String, Object> filter,String id){
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"xm", "ssbm",
"fs","yxbs","lrrq","shjh","shfzhh","shjh"},
filter, id);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
return datas;
}
private static List<Map<String, Object>> findData1(APIUtils api,Map<String, Object> filter,String id){
List<Map<String, Object>> datas = api.getFormData(10000, new String[]{"xm", "ssbm",
"fs","yxbs","lrrq","shjh","shfzhh"},
filter, id);
if (datas == null) {
return null;
}
if (datas.size() == 0) {
return null;
}
return datas;
}
/**
* 修改简道云订单数据状态字段
* @param id
* @param
* @return
*/
public static void updateToJDY(String id,String yxbs){
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "667ccd162e0bccca52d91e66", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
Map<String, Object> data = new HashMap<String, Object>() {{
put("yxbs", new HashMap<String, Object>() {{
put("value", yxbs);
}});
}};
api.updateData(id, data);
}
/**
* 修改简道云订单数据状态字段
* @param id
* @param
* @return
*/
public static String updateBeiSenId(String id,String beisen_id){
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "667ccd162e0bccca52d91e66", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
Map<String, Object> data = new HashMap<String, Object>() {{
put("beisen_id", new HashMap<String, Object>() {{
put("value", beisen_id);
}});
}};
Map<String, Object> map = api.updateData(id, data);
String string = map.toString();
return string;
}
/**
* 修改简道云订单数据状态字段
* @param id
* @param
* @return
*/
public static void createToJDY(String id,String yxbs){
APIUtils api = new APIUtils("667cc6dbaa923599ad735201", "667ccd162e0bccca52d91e66", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
Map<String, Object> data = new HashMap<String, Object>() {{
put("yxbs", new HashMap<String, Object>() {{
put("value", yxbs);
}});
}};
api.updateData(id, data);
}
}

View File

@ -0,0 +1,113 @@
package com.example.sso.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class TimeUtil {
/**
* 由于时区的原因,调整时区
* @return
*/
public static String timeConversion(String time){
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date time_Date=sf.parse(time);
Calendar calendar=Calendar.getInstance();
calendar.setTime(time_Date);
calendar.add(Calendar.HOUR_OF_DAY, -8);// before 8 hour
return df.format(calendar.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return "";
}
/**
* 由于时区的原因,调整时区
* @return
*/
public static String timeConversion1(String time){
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
try {
Date time_Date=sf.parse(time);
Calendar calendar=Calendar.getInstance();
calendar.setTime(time_Date);
// calendar.add(Calendar.DAY_OF_MONTH,+2);
calendar.add(Calendar.HOUR_OF_DAY, +8);// before 8 hour
return df.format(calendar.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return "";
}
/**
* 由于时区的原因,调整时区
* @return
*/
public static String timeConversion2(String time){
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
try {
Date time_Date=sf.parse(time);
Calendar calendar=Calendar.getInstance();
calendar.setTime(time_Date);
calendar.add(Calendar.DAY_OF_MONTH,+1);
calendar.add(Calendar.HOUR_OF_DAY, +8);// before 8 hour
return df.format(calendar.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return "";
}
public static void main(String[] args) {
getEarly6Month();
}
/**
* 由于时区的原因,调整时区
* @return
*/
public static String getEarly6Month(){
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
try {
Date time_Date=new Date();
Calendar calendar=Calendar.getInstance();
calendar.setTime(time_Date);
// calendar.add(Calendar.DAY_OF_MONTH,+2);
calendar.add(Calendar.DAY_OF_MONTH, -1);// before 8 hour
return df.format(calendar.getTime());
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static String dang(){
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 格式化日期
String formattedDate = currentDate.format(formatter);
// 输出结果
System.out.println("当前日期YYYY-MM-DD格式: " + formattedDate);
return formattedDate;
}
}

View File

@ -0,0 +1,190 @@
package com.example.sso.util;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class V5utils {
/*
查询多条数据
*/
public static String list(String jsonBody){
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建 POST 请求对象
HttpPost httpPost = new HttpPost("https://www.jiyuankeshang.com/api/v5/app/entry/data/list");
String responseBody = null;
try {
// 设置请求头
httpPost.setHeader("Content-Type", "application/json");
httpPost.setHeader("Authorization", "Bearer " + "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
StringEntity entity = new StringEntity(jsonBody, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
// 执行请求,获取响应对象
CloseableHttpResponse response = httpClient.execute(httpPost);
try {
// 从响应对象中获取响应实体
HttpEntity responseEntity = response.getEntity();
// 处理响应数据
responseBody = EntityUtils.toString(responseEntity);
System.out.println(responseBody);
} finally {
// 关闭响应对象
response.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// 关闭 HttpClient
httpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return responseBody;
}
public static String delete(String jsonBody){
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建 POST 请求对象
HttpPost httpPost = new HttpPost("https://www.jiyuankeshang.com/api/v5/app/entry/data/delete");
String responseBody = null;
try {
// 设置请求头
httpPost.setHeader("Content-Type", "application/json");
httpPost.setHeader("Authorization", "Bearer " + "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
StringEntity entity = new StringEntity(jsonBody, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
// 执行请求,获取响应对象
CloseableHttpResponse response = httpClient.execute(httpPost);
try {
// 从响应对象中获取响应实体
HttpEntity responseEntity = response.getEntity();
// 处理响应数据
responseBody = EntityUtils.toString(responseEntity);
System.out.println(responseBody);
} finally {
// 关闭响应对象
response.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// 关闭 HttpClient
httpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return responseBody;
}
//新增
public static String add(String jsonBody){
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建 POST 请求对象
HttpPost httpPost = new HttpPost("https://www.jiyuankeshang.com/api/v5/app/entry/data/create");
String responseBody = null;
try {
// 设置请求头
httpPost.setHeader("Content-Type", "application/json");
httpPost.setHeader("Authorization", "Bearer " + "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
StringEntity entity = new StringEntity(jsonBody, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
// 执行请求,获取响应对象
CloseableHttpResponse response = httpClient.execute(httpPost);
try {
// 从响应对象中获取响应实体
HttpEntity responseEntity = response.getEntity();
// 处理响应数据
responseBody = EntityUtils.toString(responseEntity);
System.out.println(responseBody);
} finally {
// 关闭响应对象
response.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// 关闭 HttpClient
httpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return responseBody;
}
public static String updata(String jsonBody){
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建 POST 请求对象
HttpPost httpPost = new HttpPost("https://www.jiyuankeshang.com/api/v5/app/entry/data/update");
String responseBody = null;
try {
// 设置请求头
httpPost.setHeader("Content-Type", "application/json");
httpPost.setHeader("Authorization", "Bearer " + "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex");
StringEntity entity = new StringEntity(jsonBody, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
// 执行请求,获取响应对象
CloseableHttpResponse response = httpClient.execute(httpPost);
try {
// 从响应对象中获取响应实体
HttpEntity responseEntity = response.getEntity();
// 处理响应数据
responseBody = EntityUtils.toString(responseEntity);
System.out.println(responseBody);
} finally {
// 关闭响应对象
response.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// 关闭 HttpClient
httpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return responseBody;
}
}

View File

@ -0,0 +1,12 @@
package com.example.sso.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
public class WXUtil {
}

View File

@ -0,0 +1,8 @@
sso:
acs: https://www.jiandaoyun.com/sso/custom/59bb7045f3b3ab31f241bbf1/acs
secret:
server:
port: 8018
#正式环境
# port: 8080
#测试环境

View File

@ -0,0 +1,27 @@
package com.example.sso;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
//import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@SpringBootTest
class SsoApplicationTests {
// @Test
void context() {
String json = "[{\"name\":\"1111\",\"code\":\"123\"},{\"name\":\"1111\",\"code\":\"123\"},{\"name\":\"1234\",\"code\":\"111\"}]";
List list = JSONObject.parseArray(json);
HashSet hs = new HashSet(list);
String jsonSet = JSON.toJSONString(hs);
JSONArray newjsonarray= new JSONArray(Collections.singletonList(jsonSet));
System.out.println(newjsonarray);
}
}