commit 07fa6dac757a31ec3f772c9e46c78b6e1cd00531 Author: lijiazhuo <13787924+lijiazhuosky@user.noreply.gitee.com> Date: Mon Aug 25 10:41:40 2025 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..74f4de4 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -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(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..0d5e649 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..7d59a01 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..65185f9 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ + +项目概述: + +此项目基本作废好久不执行了,主要为执行上海费税 + + + +对接人: +王波涵,卢飞 + + \ No newline at end of file diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..822f699 --- /dev/null +++ b/mvnw @@ -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 "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..84d60ab --- /dev/null +++ b/mvnw.cmd @@ -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% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..325a986 --- /dev/null +++ b/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.1.RELEASE + + + com.example + sso + 0.0.1-SNAPSHOT + jar + sso + Demo project for Spring Boot + + + 1.8 + + + + + com.auth0 + java-jwt + 3.8.1 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.httpcomponents + httpclient + 4.5.2 + + + com.alibaba + fastjson + 1.2.45 + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/main/java/com/example/sso/SsoApplication.java b/src/main/java/com/example/sso/SsoApplication.java new file mode 100644 index 0000000..14dff0b --- /dev/null +++ b/src/main/java/com/example/sso/SsoApplication.java @@ -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); + } + +} diff --git a/src/main/java/com/example/sso/config/JDYConfig.java b/src/main/java/com/example/sso/config/JDYConfig.java new file mode 100644 index 0000000..8812939 --- /dev/null +++ b/src/main/java/com/example/sso/config/JDYConfig.java @@ -0,0 +1,25 @@ +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 = "jdy") +@NoArgsConstructor +@AllArgsConstructor +@Validated +@Getter +@Setter +public class JDYConfig { + @NotBlank private String appkey; + @NotBlank private String appid; + @NotBlank private String formid; + @NotBlank private String formid_account; +} diff --git a/src/main/java/com/example/sso/config/SSOConfig.java b/src/main/java/com/example/sso/config/SSOConfig.java new file mode 100644 index 0000000..c8deaa5 --- /dev/null +++ b/src/main/java/com/example/sso/config/SSOConfig.java @@ -0,0 +1,24 @@ +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 { + + @NotBlank private String acs; + +} diff --git a/src/main/java/com/example/sso/controller/SSOController.java b/src/main/java/com/example/sso/controller/SSOController.java new file mode 100644 index 0000000..92de364 --- /dev/null +++ b/src/main/java/com/example/sso/controller/SSOController.java @@ -0,0 +1,317 @@ +package com.example.sso.controller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.config.SSOConfig; +import com.example.sso.dao.*; +import com.example.sso.service.*; +import com.example.sso.util.APIUtils; +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.scheduling.annotation.Async; +import org.springframework.web.bind.annotation.*; + +import java.math.BigInteger; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@RestController +@NoArgsConstructor +@AllArgsConstructor +class SSOController { + @Getter + @Setter + @Autowired + private SSOConfig ssoConfig; + @Getter + @Setter + @Autowired + private SSOService ssoService; + @Getter + @Setter + @Autowired + private JDYConfig jdyConfig; + Logger logger = LoggerFactory.getLogger(getClass()); + + @PostMapping("/test")//流程插件 + @Async + public String jdyAuth( + @RequestBody JSONObject jsonMes + ) { + logger.info(jsonMes.toJSONString()); + JSONObject data = jsonMes.getJSONObject("data"); + String url_old = data.getString("url"); + logger.info(url_old); + String url = url_old; + String appId = url.split("\\?")[1].split("&")[4].split("=")[1];//appid + String dataId = url.split("\\?")[1].split("&")[5].split("=")[1];//dataid + String flow_id = url.split("\\?")[1].split("&")[6].split("=")[1];//flowid + String formId = url.split("\\?")[1].split("&")[7].split("=")[1];//formid +// APIUtils apiUtils=new APIUtils("","",jdyConfig.getAppkey()); +// Map map=apiUtils.urlGetWorkflow(getId(url_old)); + YueFenJiSuanInfoDao.updateFlowId(dataId, appId, formId, flow_id, jdyConfig); + return ""; + } + + private static String getId(String url) { +// String urlOld="https://www.jiandaoyun.com/message/redirect?msg=task_inst%3A%3A%3A%3A%3A&instanceId=63f71ea23ecbeb000891a402&taskId=63f71faee2532a0008ba8a3e&memberType=0&guestCorpId="; + String id = url.split("\\?")[1].split("&")[1].split("=")[1]; + return id; + } + + @PostMapping("/ruku")//发票库存入库拆分 由箱拆成卷 + @Async + public String jdyAuth1( + @RequestBody JSONObject jsonMes + ) throws InterruptedException { + logger.info(jsonMes.toJSONString()); + JSONObject data = jsonMes.getJSONObject("data"); + Long luruxiangshushouhao = data.getLong("luruxiangshushouhao"); + JSONArray rukuxiangshuchaifen = data.getJSONArray("rukuxiangshuchaifen"); + String _id = data.getString("_id"); + if (rukuxiangshuchaifen == null || rukuxiangshuchaifen.size() == 0) { + JSONArray invos = new JSONArray(); + for (int i = 1; i <= 100; i++) { + JSONObject invo = new JSONObject(); + //本卷发票首号 + JSONObject xuhao = new JSONObject(); + xuhao.put("value", i); + invo.put("xuhao", xuhao); + JSONObject benxiangshouhao = new JSONObject(); + benxiangshouhao.put("value", luruxiangshushouhao + (100 * (i - 1)));//本卷发票尾号 + invo.put("benxiangshouhao", benxiangshouhao); + JSONObject benxiangweihao = new JSONObject(); + benxiangweihao.put("value", luruxiangshushouhao + (100 * i) - 1); + invo.put("benxiangweihao", benxiangweihao); + JSONObject rukujuanshu = new JSONObject(); + rukujuanshu.put("value", 1); + invo.put("rukujuanshu", rukujuanshu); + invos.add(invo); + } + Map map1; + map1 = new HashMap() { + { + put("rukuxiangshuchaifen", new HashMap() {{ + put("value", invos); + }});//报销部门 + } + }; + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3", "62f0b7264af59a000749cbcd", jdyConfig.getAppkey()); + Thread.sleep(1000); + api.updateData(_id, map1); + } + return ""; + } + + + @PostMapping("/lingyong")//发票领用 + @Async + public String jdyAuth2( + @RequestBody JSONObject jsonMes + ) { + logger.info(jsonMes.toJSONString()); + JSONObject data = jsonMes.getJSONObject("data"); + JSONArray lingyongmingxi = data.getJSONArray("lingyongmingxi"); + String yewuyuan = data.getJSONObject("yewuyuan").getString("username"); + String lingyongshijian = data.getString("lingyongshijian"); + for (Object o : lingyongmingxi) { + JSONObject jsonObject = (JSONObject) o; + String yewuliushui = jsonObject.getString("yewuliushui");//执行查询动作 + FaPiaoDao faPiaoDao = new FaPiaoDao(); + JSONArray jsonArray = faPiaoDao.selectFapiaoAnJuanByNo(yewuliushui, jdyConfig); + for (Object o1 : jsonArray) { + JSONObject jsonObject1 = (JSONObject) o1; + String _id = jsonObject1.getString("_id"); + GongZiDao.updateLingYongStatus(_id, "65122df9d8ce14000e42b2b3", "62f0f550f0e8f3000862fe6e", yewuyuan, lingyongshijian, jdyConfig); + } + } + return ""; + } + + @PostMapping("/dayinshoukuan")//打印收款 + public String jdyAuth3( + @RequestBody JSONObject jsonMes + ) { + logger.info(jsonMes.toJSONString()); + DaYinDao.createDaYinData(jsonMes, jdyConfig); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("status", "生成成功"); + return jsonObject.toJSONString(); + } + + + @PostMapping("/dayinfukuan")//打印付款 + public String jdyAuth4( + @RequestBody JSONObject jsonMes + ) { + logger.info(jsonMes.toJSONString()); + DaYinDao.createDaYinDataFuKuan(jsonMes, jdyConfig); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("status", "生成成功"); + return jsonObject.toJSONString(); + } + + @PostMapping("/dayinshoukuan_huizong")//打印收款汇总 + public String jdyAuth5( + @RequestBody JSONObject jsonMes + ) { + logger.info(jsonMes.toJSONString()); + String[] ranyoubutie_heji = jsonMes.getString("ranyoubutie_heji").split(","); + String[] yanchebaoxiao_heji = jsonMes.getString("yanchebaoxiao_heji").split(","); + String[] danhanghejijine_heji = jsonMes.getString("danhanghejijine_heji").split(","); + String[] qita_heji = jsonMes.getString("qita_heji").split(","); + String[] zhengfubutie_heji = jsonMes.getString("zhengfubutie_heji").split(","); + String[] xingming_heji = jsonMes.getString("xingming_heji").split(","); + String[] shiyou_heji = jsonMes.getString("shiyou_heji").split(","); + String[] gangweibutie_heji = jsonMes.getString("gangweibutie_heji").split(","); + String[] jiangli_heji = jsonMes.getString("jiangli_heji").split(","); + String[] chexing_heji = jsonMes.getString("chexing_heji").split(","); + String[] chepaihaoma_heji = jsonMes.getString("chepaihaoma_heji").split(","); + String[] jigou_heji = jsonMes.getString("jigou_heji").split(","); + String[] fensi_heji = jsonMes.getString("fensi_heji").split(","); + String[] yuefen_heji = jsonMes.getString("yuefen_heji").split(","); + String[] shenfenhaoma_heji = jsonMes.getString("shenfenhaoma_heji").split(","); + JSONArray list = new JSONArray(); + for (int i = 0; i < ranyoubutie_heji.length; i++) { + JSONObject yihang = new JSONObject(); + + JSONObject ranyoubutie_heji_json = new JSONObject(); + ranyoubutie_heji_json.put("value", ranyoubutie_heji[i]); + yihang.put("ranyoubutie_heji", ranyoubutie_heji_json);//燃油补贴 + + JSONObject yuefen_heji_json = new JSONObject(); + yuefen_heji_json.put("value", yuefen_heji[i]); + yihang.put("yuefen_heji", yuefen_heji_json);//月份合计 + + JSONObject shenfenhaoma_heji_json = new JSONObject(); + shenfenhaoma_heji_json.put("value", shenfenhaoma_heji[i]); + yihang.put("shenfenhaoma_heji", shenfenhaoma_heji_json);//身份号码合计 + + JSONObject yanchebaoxiao_heji_json = new JSONObject(); + yanchebaoxiao_heji_json.put("value", yanchebaoxiao_heji[i]); + yihang.put("yanchebaoxiao_heji", yanchebaoxiao_heji_json);//验车报销 + + JSONObject danhanghejijine_heji_json = new JSONObject(); + danhanghejijine_heji_json.put("value", danhanghejijine_heji[i]); + yihang.put("danhanghejijine_heji", danhanghejijine_heji_json);//单行金额合计 + + JSONObject qita_heji_json = new JSONObject(); + qita_heji_json.put("value", qita_heji[i]); + yihang.put("qita_heji", qita_heji_json);//其他合计 + + JSONObject zhengfubutie_heji_json = new JSONObject(); + zhengfubutie_heji_json.put("value", zhengfubutie_heji[i]); + yihang.put("zhengfubutie_heji", zhengfubutie_heji_json);//政府补贴 + + JSONObject xingming_heji_json = new JSONObject(); + xingming_heji_json.put("value", xingming_heji[i]); + yihang.put("xingming_heji", xingming_heji_json);//姓名 + + JSONObject shiyou_heji_json = new JSONObject(); + shiyou_heji_json.put("value", shiyou_heji[i]); + yihang.put("shiyou_heji", shiyou_heji_json);//合计 + + JSONObject gangweibutie_heji_json = new JSONObject(); + gangweibutie_heji_json.put("value", gangweibutie_heji[i]); + yihang.put("gangweibutie_heji", gangweibutie_heji_json);//岗位补贴 + + JSONObject jiangli_heji_json = new JSONObject(); + jiangli_heji_json.put("value", jiangli_heji[i]); + yihang.put("jiangli_heji", jiangli_heji_json);//奖励 + + JSONObject chexing_heji_json = new JSONObject(); + chexing_heji_json.put("value", chexing_heji[i]); + yihang.put("chexing_heji", chexing_heji_json);//车型 + + JSONObject chepaihaoma_heji_json = new JSONObject(); + chepaihaoma_heji_json.put("value", chepaihaoma_heji[i]); + yihang.put("chepaihaoma_heji", chepaihaoma_heji_json);//车牌号码 + + JSONObject jigou_heji_json = new JSONObject(); + jigou_heji_json.put("value", jigou_heji[i]); + yihang.put("jigou_heji", jigou_heji_json);//机构 + + JSONObject fensi_heji_json = new JSONObject(); + fensi_heji_json.put("value", fensi_heji[i]); + yihang.put("fensi_heji", fensi_heji_json);//分司 + list.add(yihang); + } + jsonMes.put("list", list);//处理子表 + DaYinDao.createDaYinDataFuKuan(jsonMes, jdyConfig); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("status", "生成成功"); + return jsonObject.toJSONString(); + } + + + @PostMapping("/yinhangdaoru")//银行信息导入后,更新每月承包金状态 + @Async + public String jdyAuth6( + @RequestBody JSONObject jsonMes + ) { + logger.info(jsonMes.toJSONString()); + YinHangHuaKouDao yinHangHuaKouDao = new YinHangHuaKouDao(); + String month = jsonMes.getJSONObject("data").getString("month"); + JSONArray yinHangs = yinHangHuaKouDao.selectYinHang(month, jdyConfig);//查询出所有未更新状态的银行导入数据 + JSONObject monthData = yinHangHuaKouDao.selectMonthData(month, jdyConfig);//银行信息 + if (yinHangs != null) { + for (Object o : yinHangs) { + try { + JSONObject yinHang = (JSONObject) o; + String sijixingming = yinHang.getString("sijixingming"); + String yinhangkahao = yinHang.getString("yinhangkahao"); +// String sijishenfenzhenghao=yinHang.getString("sijishenfenzhenghao"); + JSONObject dataJSONObject = monthData.getJSONObject(sijixingming + yinhangkahao); + if (dataJSONObject != null) { + String id = dataJSONObject.getString("_id");//更新数据 + String status_yinhang = yinHang.getString("status_yinhang"); + yinHangHuaKouDao.updateData(id, status_yinhang, jdyConfig); + } else { +// String id=dataJSONObject.getString("_id");//更新数据 +// yinHangHuaKouDao.updateData(id,jdyConfig); + } + String id = yinHang.getString("_id"); + yinHangHuaKouDao.updateYinHangData(id, jdyConfig); + } catch (Exception e) { + e.printStackTrace(); + } + } + } else { + logger.info("未查询到本月导入的银行划扣数据"); + } + return ""; + } + + @PostMapping("/yinhangdaoru_gongzi")//银行信息导入后,更新每月承包金状态 + @Async + public String jdyAuth7( + @RequestBody JSONObject jsonMes + ) { + logger.info(jsonMes.toJSONString()); + YinHangHuaKouDao yinHangHuaKouDao = new YinHangHuaKouDao(); + String month = jsonMes.getJSONObject("data").getString("month"); + JSONArray yinHangs = yinHangHuaKouDao.selectYinHang_gongzi(month, jdyConfig);//查询出所有未更新状态的银行导入数据 + JSONObject monthData = yinHangHuaKouDao.selectMonthData_Gongzi(month, jdyConfig);//银行信息 + for (Object o : yinHangs) { + JSONObject yinHang = (JSONObject) o; + String sijishenfenzhenghao = yinHang.getString("sijishenfenzhenghao"); + String jine = yinHang.getString("jine"); + JSONObject dataJSONObject = monthData.getJSONObject(sijishenfenzhenghao + jine); + if (dataJSONObject != null) { + String id = dataJSONObject.getString("_id");//更新数据 + String status_yinhang = yinHang.getString("status_yinhang"); + yinHangHuaKouDao.updateData_gongzi(id, status_yinhang, jdyConfig); + } + String id = yinHang.getString("_id"); + yinHangHuaKouDao.updateYinHangDataGongZi(id, jdyConfig); + } + return ""; + } +} diff --git a/src/main/java/com/example/sso/dao/A.java b/src/main/java/com/example/sso/dao/A.java new file mode 100644 index 0000000..de27326 --- /dev/null +++ b/src/main/java/com/example/sso/dao/A.java @@ -0,0 +1,16 @@ +package com.example.sso.dao; + +import com.example.sso.util.TimeUtil; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +public class A { + public static void main(String[] args) { + String timew = TimeUtil.timew(); + + // 输出格式化后的文本 + System.out.println( timew); + } + +} diff --git a/src/main/java/com/example/sso/dao/ChengBaoJinHeZengHeJianDao.java b/src/main/java/com/example/sso/dao/ChengBaoJinHeZengHeJianDao.java new file mode 100644 index 0000000..97b901a --- /dev/null +++ b/src/main/java/com/example/sso/dao/ChengBaoJinHeZengHeJianDao.java @@ -0,0 +1,72 @@ +package com.example.sso.dao; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.util.APIUtils; +import com.example.sso.util.TimeUtil; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +public class ChengBaoJinHeZengHeJianDao { + /** + * 承包金核增核减数据新增 + * @throws Exception + */ + public static void createHeZengData(String appId, String entryId, JSONObject data, Double jine,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils(appId, entryId, ssoConfig.getAppkey()); + Map map1; + map1 = new HashMap() { + { + put("suoshubumen", new HashMap() {{ + put("value", data.getString("suoshubumen")); + }}); + put("fensi", new HashMap() {{ + put("value", data.getString("fensi")); + }}); + put("xingming", new HashMap() {{ + put("value", data.getString("xingming")); + }}); + put("id_card", new HashMap() {{ + put("value", data.getString("id_card")); + }}); + put("chepaihaoma", new HashMap() {{ + put("value", data.getString("chepaihaoma")); + }}); + put("month", new HashMap() {{ + if (data.getString("month")!=null){ + String month=data.getString("month"); + SimpleDateFormat df=new SimpleDateFormat("yyyy-MM"); + put("value", TimeUtil.getMonthDate(df.parse(month))); + } + }}); + put("shenqingbumen", new HashMap() {{ + put("value", "自动生成"); + }}); + put("jine", new HashMap() {{ + put("value",jine); + }}); + put("shiyou", new HashMap() {{ + put("value", "上月未进入计划增减额"); + }}); + put("shenqingshijian", new HashMap() {{ + put("value", data.getString("shenqingshijian")); + }}); + put("leixing", new HashMap() {{ + put("value", data.getString("leixing")); + }}); + put("cheliangxinghao", new HashMap() {{ + put("value", data.getString("cheliangxinghao")); + }}); + put("banzhi", new HashMap() {{ + put("value", data.getString("banzhi")); + }}); + } + }; + //把封装好的数据创建至简道云 + api.createData(map1); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/example/sso/dao/DaYinDao.java b/src/main/java/com/example/sso/dao/DaYinDao.java new file mode 100644 index 0000000..5a7c16d --- /dev/null +++ b/src/main/java/com/example/sso/dao/DaYinDao.java @@ -0,0 +1,293 @@ +package com.example.sso.dao; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.util.APIUtils; +import com.example.sso.util.DataBatchUtil; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +public class DaYinDao { + /** + * 更新客户报备数据 + * @throws Exception + */ + public static void createDaYinData(JSONObject jsonMes,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f09f05c37b800008c54f20", ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("xingming",new HashMap() {{ put("value",jsonMes.getString("xingming"));}}); + put("shouyinyuan",new HashMap() {{ put("value",jsonMes.getString("shouyinyuan"));}}); + put("shenfenzhenghaoma",new HashMap() {{ put("value",jsonMes.getString("shenfenzhenghaoma"));}}); + put("shouyinshijian",new HashMap() {{ put("value",jsonMes.getString("shouyinshijian"));}}); + put("shoufukuanshiyou",new HashMap() {{ put("value",jsonMes.getString("shoufukuanshiyou"));}}); + put("shijijiaonajine",new HashMap() {{ put("value",jsonMes.getString("shijijiaonajine"));}}); + put("chepaihaoma",new HashMap() {{ put("value",jsonMes.getString("chepaihaoma"));}}); + put("jigou",new HashMap() {{ put("value",jsonMes.getString("jigou"));}}); + put("fensi",new HashMap() {{ put("value",jsonMes.getString("fensi"));}}); + put("dayinshijian",new HashMap() {{ put("value",jsonMes.getString("dayinshijian"));}}); + put("jiaonajinedaxie",new HashMap() {{ put("value",jsonMes.getString("jiaonajinedaxie"));}}); + put("jiaonajineshuzi",new HashMap() {{ put("value",jsonMes.getString("jiaonajineshuzi"));}}); + put("zijinwanglaiyewuliushuihao",new HashMap() {{ put("value",jsonMes.getString("zijinwanglaiyewuliushuihao"));}}); + put("uuid",new HashMap() {{ put("value",jsonMes.getString("uuid"));}}); + put("yewuyuan",new HashMap() {{ put("value",jsonMes.getString("yewuyuan"));}}); + put("yewubiaodanmingcheng",new HashMap() {{ put("value",jsonMes.getString("yewubiaodanmingcheng"));}}); + put("yuefen",new HashMap() {{ put("value",jsonMes.getString("yuefen"));}}); + } + }; + //把封装好的数据创建至简道云 + api.createData(map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + + /** + * 更新客户报备数据 + * @throws Exception + */ + public static void createDaYinDataFuKuan(JSONObject jsonMes,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f09f05c37b800008c54f20", ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("shouyinyuan",new HashMap() {{ put("value",jsonMes.getString("shouyinyuan"));}}); + put("jigou",new HashMap() {{ put("value",jsonMes.getString("jigou"));}}); + put("fensi",new HashMap() {{ put("value",jsonMes.getString("fensi"));}}); + put("chepaihaoma",new HashMap() {{ put("value",jsonMes.getString("chepaihaoma"));}}); + put("shenfenzhenghaoma",new HashMap() {{ put("value",jsonMes.getString("shenfenzhenghaoma"));}}); + put("uuid",new HashMap() {{ put("value",jsonMes.getString("uuid"));}}); + put("xingming",new HashMap() {{ put("value",jsonMes.getString("xingming"));}}); + put("shouyinshijian",new HashMap() {{ put("value",jsonMes.getString("shouyinshijian"));}}); + put("zhichujineshuzi",new HashMap() {{ put("value",jsonMes.getString("zhichujineshuzi"));}}); + put("zhichujinedaxie",new HashMap() {{ put("value",jsonMes.getString("zhichujinedaxie"));}}); + put("zhichushijian",new HashMap() {{ put("value",jsonMes.getString("zhichushijian"));}}); + put("shoufukuanshiyou",new HashMap() {{ put("value",jsonMes.getString("shoufukuanshiyou"));}}); + put("jiaonajinedaxie",new HashMap() {{ put("value",jsonMes.getString("jiaonajinedaxie"));}}); + put("jiaonajineshuzi",new HashMap() {{ put("value",jsonMes.getString("jiaonajineshuzi"));}}); + put("dayinshijian",new HashMap() {{ put("value",jsonMes.getString("dayinshijian"));}}); + put("zijinwanglaiyewuliushuihao",new HashMap() {{ put("value",jsonMes.getString("zijinwanglaiyewuliushuihao"));}}); + put("list",new HashMap() {{ put("value",jsonMes.getJSONArray("list"));}}); + put("yewuyuan",new HashMap() {{ put("value",jsonMes.getString("yewuyuan"));}}); + put("yewubiaodanmingcheng",new HashMap() {{ put("value",jsonMes.getString("yewubiaodanmingcheng"));}}); + put("yuefen",new HashMap() {{ put("value",jsonMes.getString("yuefen"));}}); + } + }; + //把封装好的数据创建至简道云 + api.createData(map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + /** + * 选择发票按卷 按照业务流水编码 + * @param jdyConfig + * @return + */ + public JSONArray selectFapiaoAnJuanByNo(String no,JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f0f550f0e8f3000862fe6e", jdyConfig.getAppkey()); + final List> condList = new ArrayList>();//因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(no); + condList.add(new HashMap() { + { + put("field", "yewuliushui");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"yewuliushui", + "luruxiangshushouhao","luruxiangshuweihao"},//业务流水,录入首号,录入尾号 + 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> 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> findData(APIUtils api,Map filter,String id){ + List> datas = api.getFormData(10000, new String[]{"yewuliushui", + "luruxiangshushouhao","luruxiangshuweihao"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + + + /** + * 查询每月核减情况 + * @param jdyConfig + * @return + */ + public JSONObject selectHeJian(String month,JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62ef6cd6741a1e000744cc2c", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(month); + condList.add(new HashMap() { + { + put("field", "month");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"id_card", "jine"},//身份证,本月扣减金额 + 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> data=findData1(api,filter,id); + if (data==null){ + i=0; + }else { + datas.addAll(data); + i=i+1; + } + }else { + i=0; + } + } + } + JSONObject jsonObject_test=new JSONObject(); + jsonObject_test.put("list",datas); + JSONArray data=jsonObject_test.getJSONArray("list"); + JSONObject jsonObject=new JSONObject(); + for (Object o:data){ + JSONObject map=(JSONObject)o; + if (jsonObject.get(map.getString("id_card"))==null){ + jsonObject.put(map.getString("id_card"),map.get("jine")); + }else { + Double a=jsonObject.getDouble((String) map.get("id_card")); + jsonObject.put((String) map.get("id_card"),a+map.getDouble("jine")); + } + } + return jsonObject; + } + + private static List> findData1(APIUtils api,Map filter,String id){ + List> datas = api.getFormData(10000, new String[]{"id_card", "jine"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + + /** + * 创建流水账数据 月份 + * @throws Exception + */ + public void createLiuShuiYueFen(List> jsonArray,JDYConfig ssoConfig) { + JSONArray fields = new JSONArray(); + fields.add("type"); + fields.add("fukuanshiyou"); + fields.add("yewubiaodanmingcheng"); + fields.add("yewubiaodanbianma"); + fields.add("sijixingming"); + fields.add("sijishenfenzhenghao"); + fields.add("sijisuozaigongsi"); + fields.add("jine"); + fields.add("fesi"); + JSONArray fields_data = new JSONArray(); + fields_data.add("type"); + fields_data.add("fukuanshiyou"); + fields_data.add("yewubiaodanmingcheng"); + fields_data.add("yewubiaodanbianma"); + fields_data.add("sijixingming"); + fields_data.add("sijishenfenzhenghao"); + fields_data.add("sijisuozaigongsi"); + fields_data.add("jine"); + fields_data.add("fensi"); + int i = 1; + JSONArray create_data = new JSONArray(); + for (Object o : jsonArray) { + JSONObject jsonObject = (JSONObject) o; + if (i >= 1) { + create_data.add(jsonObject); + i = i + 1; + if (create_data.size() == 100) { + DataBatchUtil.dataBatchCreate("628eeaace7f28c00089a60cc", "62ecd78e76f428000749e457", ssoConfig.getAppkey(), create_data, fields, fields_data); + create_data.clear();//清空 + } + } + } + if (create_data.size() != 0) { + DataBatchUtil.dataBatchCreate("613825eb8a6d0300070e67fb", "613871c8fab0ca0007beea94", "jPK0bjd46jhmjdrRgi8Txts9wuKeqFA1", create_data, fields, fields_data); + create_data.clear();//清空 + } + i=i-1; + System.out.println("共计新增:" + i + "条工资数据!"); + } +} diff --git a/src/main/java/com/example/sso/dao/FaPiaoDao.java b/src/main/java/com/example/sso/dao/FaPiaoDao.java new file mode 100644 index 0000000..da3015c --- /dev/null +++ b/src/main/java/com/example/sso/dao/FaPiaoDao.java @@ -0,0 +1,254 @@ +package com.example.sso.dao; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.util.APIUtils; +import com.example.sso.util.DataBatchUtil; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +public class FaPiaoDao { + /** + * 更新客户报备数据 + * @throws Exception + */ + public static void updateFlowId(String id,String appId,String entryId,String flow_id,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils(appId,entryId, ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("flow_id",new HashMap() {{ put("value",flow_id);}}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id,map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + /** + * 选择发票按卷 按照业务流水编码 + * @param jdyConfig + * @return + */ + public JSONArray selectFapiaoAnJuanByNo(String no,JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3","62f0f550f0e8f3000862fe6e", jdyConfig.getAppkey()); + final List> condList = new ArrayList>();//因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(no); + condList.add(new HashMap() { + { + put("field", "yewuliushui");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"yewuliushui", + "luruxiangshushouhao","luruxiangshuweihao"},//业务流水,录入首号,录入尾号 + 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> 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> findData(APIUtils api,Map filter,String id){ + List> datas = api.getFormData(10000, new String[]{"yewuliushui", + "luruxiangshushouhao","luruxiangshuweihao"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + + + + /* + 发票入库管理部门负责人 + */ + + + + + + + + + + + + + + /** + * 查询每月核减情况 + * @param jdyConfig + * @return + */ + public JSONObject selectHeJian(String month,JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62ef6cd6741a1e000744cc2c", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(month); + condList.add(new HashMap() { + { + put("field", "month");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"id_card", "jine"},//身份证,本月扣减金额 + 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> data=findData1(api,filter,id); + if (data==null){ + i=0; + }else { + datas.addAll(data); + i=i+1; + } + }else { + i=0; + } + } + } + JSONObject jsonObject_test=new JSONObject(); + jsonObject_test.put("list",datas); + JSONArray data=jsonObject_test.getJSONArray("list"); + JSONObject jsonObject=new JSONObject(); + for (Object o:data){ + JSONObject map=(JSONObject)o; + if (jsonObject.get(map.getString("id_card"))==null){ + jsonObject.put(map.getString("id_card"),map.get("jine")); + }else { + Double a=jsonObject.getDouble((String) map.get("id_card")); + jsonObject.put((String) map.get("id_card"),a+map.getDouble("jine")); + } + } + return jsonObject; + } + + private static List> findData1(APIUtils api,Map filter,String id){ + List> datas = api.getFormData(10000, new String[]{"id_card", "jine"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + + /** + * 创建流水账数据 月份 + * @throws Exception + */ + public void createLiuShuiYueFen(List> jsonArray,JDYConfig ssoConfig) { + JSONArray fields = new JSONArray(); + fields.add("type"); + fields.add("fukuanshiyou"); + fields.add("yewubiaodanmingcheng"); + fields.add("yewubiaodanbianma"); + fields.add("sijixingming"); + fields.add("sijishenfenzhenghao"); + fields.add("sijisuozaigongsi"); + fields.add("jine"); + fields.add("fesi"); + JSONArray fields_data = new JSONArray(); + fields_data.add("type"); + fields_data.add("fukuanshiyou"); + fields_data.add("yewubiaodanmingcheng"); + fields_data.add("yewubiaodanbianma"); + fields_data.add("sijixingming"); + fields_data.add("sijishenfenzhenghao"); + fields_data.add("sijisuozaigongsi"); + fields_data.add("jine"); + fields_data.add("fensi"); + int i = 1; + JSONArray create_data = new JSONArray(); + for (Object o : jsonArray) { + JSONObject jsonObject = (JSONObject) o; + if (i >= 1) { + create_data.add(jsonObject); + i = i + 1; + if (create_data.size() == 100) { + DataBatchUtil.dataBatchCreate("628eeaace7f28c00089a60cc", "62ecd78e76f428000749e457", ssoConfig.getAppkey(), create_data, fields, fields_data); + create_data.clear();//清空 + } + } + } + if (create_data.size() != 0) { + DataBatchUtil.dataBatchCreate("613825eb8a6d0300070e67fb", "613871c8fab0ca0007beea94", "jPK0bjd46jhmjdrRgi8Txts9wuKeqFA1", create_data, fields, fields_data); + create_data.clear();//清空 + } + i=i-1; + System.out.println("共计新增:" + i + "条工资数据!"); + } +} diff --git a/src/main/java/com/example/sso/dao/GongZiDao.java b/src/main/java/com/example/sso/dao/GongZiDao.java new file mode 100644 index 0000000..8905219 --- /dev/null +++ b/src/main/java/com/example/sso/dao/GongZiDao.java @@ -0,0 +1,365 @@ +package com.example.sso.dao; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.util.APIUtils; +import com.example.sso.util.DataBatchUtil; +import com.example.sso.util.TimeUtil; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +@Component +public class GongZiDao { + /** + * 更新领用状态 + * + * @throws Exception + */ + public static void updateLingYongStatus(String id, String appId, String entryId, String lingyongyewuyuan, String lingyongshijian, JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils(appId, entryId, ssoConfig.getAppkey()); + Map map1; + map1 = new HashMap() { + { + put("lingyongyewuyuan", new HashMap() {{ + put("value", lingyongyewuyuan); + }}); + put("lingyongshijian", new HashMap() {{ + put("value", lingyongshijian); + }}); + put("fapiaozhuangtai", new HashMap() {{ + put("value", "已出库"); + }}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id, map1); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 查询每个人的承包金标准 分别为 承包金(月份)、个税、保养费、调度费、社保 组成 + * + * @param jdyConfig + * @return + */ + public JSONArray selectGongBiaoZhun(JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc", "62ef5405e022900008e9c7b5", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(""); + condList.add(new HashMap() { + { + put("field", "id_card");//查新字段的名称/别名 + put("method", "nq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"id_card", "gongsi", "name", "gangweibutie", "ranliaobutie", + "linshibutie", "zhengfubutie", "fensi", "haopaihaoma", "yinhangkahao", "qita", "yingyunriqi","fensifuzeren"},//身份证,公司,姓名,岗位补贴,燃油补贴,临时补贴,其他补贴 + 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> data = findData(api, filter, id); + if (data == null) { + i = 0; + } else { + datas.addAll(data); + i = i + 1; + } + } else { + i = 0; + } + } + } +// JSONArray datas_new=new JSONArray(); +// for (Object o:datas){ +// JSONObject map = (JSONObject) o;//上月拖欠数据 获取上月日期 +// Date month=map.getDate("yingyunriqi"); +// if (month!=null){ +// SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM"); +// Date month_ontime=new Date(); +// try { +// month_ontime=simpleDateFormat.parse(simpleDateFormat.format(month_ontime)); +// if (month.before(month_ontime)){ +// //小于算进去 +// datas_new.add(map); +// } +// } catch (ParseException e) { +// e.printStackTrace(); +// } +// } +// } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("list", datas); + return jsonObject.getJSONArray("list"); + } + + + /** + * 查询首月司机 + * + * @param jdyConfig + * @return + */ + public JSONObject selectShouYueSiJi(JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc", "62f4752f87648b0007aebd47", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add("是"); + condList.add(new HashMap() { + { + put("field", "is_shouyue");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao", "jine"},//身份证,公司,姓名,岗位补贴,燃油补贴,临时补贴,其他补贴 + filter, null); + JSONObject jsonObject = new JSONObject(); + if (datas == null) { + return jsonObject; + } + if (datas.size() == 0) { + return jsonObject; + } + JSONObject jsonObject_test = new JSONObject(); + jsonObject_test.put("list", datas); + JSONArray data = jsonObject_test.getJSONArray("list"); + for (Object o : data) { + JSONObject map = (JSONObject) o; + if (!map.equals("")) { + jsonObject.put(map.getString("sijishenfenzhenghao"), map); + } + //处理历史首月数据的状态 + String _id = map.getString("_id"); + Map map1; + map1 = new HashMap() { + { + put("is_shouyue", new HashMap() {{ + put("value", ""); + }}); + } + }; + api.updateData(_id, map1); + //处理完毕 + } + return jsonObject; + } + + + private static List> findData(APIUtils api, Map filter, String id) { + List> datas = api.getFormData(10000, new String[]{"id_car", "gongsi", "name", "gangweibutie", "ranliaobutie", + "linshibutie", "zhengfubutie", "qitabutie", "fensi", "yinhangkahao", "haopaihaoma", "yingyunriqi","fensifuzeren"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + /** + * 查询未缴纳钱财的司机 欠承包金的司机 + * + * @param jdyConfig + * @return + */ + public JSONObject selectSiJiQian(JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc", "62ecd78e76f428000749e457", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add("费税收取"); + condList.add(new HashMap() { + { + put("field", "fukuanshiyou");//查新字段的名称/别名 + put("method", "like");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao","fukuanshiyou", "sijixingming", "jine","yuefen"},//身份证,本月扣减金额 + 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> data = findData1(api, filter, id); + if (data == null) { + i = 0; + } else { + datas.addAll(data); + i = i + 1; + } + } else { + i = 0; + } + } + } + JSONObject jsonObject_test = new JSONObject(); + jsonObject_test.put("list", datas); + JSONArray data = jsonObject_test.getJSONArray("list"); + JSONObject jsonObject = new JSONObject(); + for (Object o : data) { + JSONObject map = (JSONObject) o;//上月拖欠数据 获取上月日期 + String fukuanshiyou=map.getString("fukuanshiyou"); + String uu=map.getString("sijishenfenzhenghao"); + if(fukuanshiyou.contains("费税收取")){ + String month=map.getString("yuefen"); + if (month!=null){ + SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM"); + Date month_ontime=new Date(); + try { + Date monthDate=simpleDateFormat.parse(month); + month_ontime=simpleDateFormat.parse(simpleDateFormat.format(month_ontime)); + if (monthDate.before(month_ontime)){ + //小于算进去 + jsonObject.put(map.getString("sijishenfenzhenghao"), map); + } + } catch (ParseException e) { + e.printStackTrace(); + } + } + } + } + return jsonObject; + } + + private static List> findData1(APIUtils api, Map filter, String id) { + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao","fukuanshiyou","sijixingming", "jine","yuefen"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + /** + * 创建流水账数据 月份 + * + * @throws Exception + */ + public void createLiuShuiYueFen(List> jsonArray, JDYConfig ssoConfig) { + JSONArray fields = new JSONArray(); + fields.add("type"); + fields.add("fukuanshiyou"); + fields.add("yewubiaodanmingcheng"); + fields.add("yewubiaodanbianma"); + fields.add("sijixingming"); + fields.add("sijishenfenzhenghao"); + fields.add("gongsi"); + fields.add("jine"); + fields.add("fensi"); + fields.add("yuefen"); + fields.add("is_tuoqianchengbaojin"); + fields.add("status_yinhang"); + fields.add("haopaihaoma"); + fields.add("gangweibutie"); + fields.add("ranliaobutie"); + fields.add("linshibutie"); + fields.add("zhengfubutie"); + fields.add("qita"); + fields.add("yinhangkahao"); + fields.add("yingyunriqi"); + fields.add("fensifuzeren"); + JSONArray fields_data = new JSONArray(); + fields_data.add("type"); + fields_data.add("fukuanshiyou"); + fields_data.add("yewubiaodanmingcheng"); + fields_data.add("yewubiaodanbianma"); + fields_data.add("sijixingming"); + fields_data.add("sijishenfenzhenghao"); + fields_data.add("gongsi"); + fields_data.add("jine"); + fields_data.add("fensi"); + fields_data.add("yuefen"); + fields_data.add("is_tuoqianchengbaojin"); + fields_data.add("status_yinhang"); + fields_data.add("haopaihaoma"); + fields_data.add("gangweibutie"); + fields_data.add("ranliaobutie"); + fields_data.add("linshibutie"); + fields_data.add("zhengfubutie"); + fields_data.add("qita"); + fields_data.add("yinhangkahao"); + fields_data.add("yingyunriqi"); + fields_data.add("fensifuzeren"); + int i = 1; + JSONArray create_data = new JSONArray(); + for (Object o : jsonArray) { + JSONObject jsonObject = (JSONObject) o; + if (i >= 1) { + create_data.add(jsonObject); + i = i + 1; + if (create_data.size() == 100) { + DataBatchUtil.dataBatchCreate("628eeaace7f28c00089a60cc", "62f4752f87648b0007aebd47", ssoConfig.getAppkey(), create_data, fields, fields_data); + create_data.clear();//清空 + } + } + } + if (create_data.size() != 0) { + DataBatchUtil.dataBatchCreate("628eeaace7f28c00089a60cc", "62f4752f87648b0007aebd47", ssoConfig.getAppkey(), create_data, fields, fields_data); + create_data.clear();//清空 + } + i = i - 1; + System.out.println("共计新增:" + i + "条工资数据!"); + } +} diff --git a/src/main/java/com/example/sso/dao/YinHangHuaKouDao.java b/src/main/java/com/example/sso/dao/YinHangHuaKouDao.java new file mode 100644 index 0000000..99cab98 --- /dev/null +++ b/src/main/java/com/example/sso/dao/YinHangHuaKouDao.java @@ -0,0 +1,448 @@ +package com.example.sso.dao; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.util.APIUtils; +import com.example.sso.util.DataBatchUtil; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +public class YinHangHuaKouDao { + /** + * 更新客户报备数据 + * @throws Exception + */ + public static void createDaYinData(JSONObject jsonMes,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f09f05c37b800008c54f20", ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("xingming",new HashMap() {{ put("value",jsonMes.getString("xingming"));}}); + put("shouyinyuan",new HashMap() {{ put("value",jsonMes.getString("shouyinyuan"));}}); + put("shenfenzhenghaoma",new HashMap() {{ put("value",jsonMes.getString("shenfenzhenghaoma"));}}); + put("shouyinshijian",new HashMap() {{ put("value",jsonMes.getString("shouyinshijian"));}}); + put("shoufukuanshiyou",new HashMap() {{ put("value",jsonMes.getString("shoufukuanshiyou"));}}); + put("shijijiaonajine",new HashMap() {{ put("value",jsonMes.getString("shijijiaonajine"));}}); + put("chepaihaoma",new HashMap() {{ put("value",jsonMes.getString("chepaihaoma"));}}); + put("jigou",new HashMap() {{ put("value",jsonMes.getString("jigou"));}}); + put("fensi",new HashMap() {{ put("value",jsonMes.getString("fensi"));}}); + put("dayinshijian",new HashMap() {{ put("value",jsonMes.getString("dayinshijian"));}}); + put("jiaonajinedaxie",new HashMap() {{ put("value",jsonMes.getString("jiaonajinedaxie"));}}); + put("jiaonajineshuzi",new HashMap() {{ put("value",jsonMes.getString("jiaonajineshuzi"));}}); + put("zijinwanglaiyewuliushuihao",new HashMap() {{ put("value",jsonMes.getString("zijinwanglaiyewuliushuihao"));}}); + put("uuid",new HashMap() {{ put("value",jsonMes.getString("uuid"));}}); + } + }; + //把封装好的数据创建至简道云 + api.createData(map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + + /** + * 更新客户报备数据 + * @throws Exception + */ + public void updateData(String id, String status_yinhang,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3","62f3b97652bc8c0008ae8a23", ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("status_yinhang",new HashMap() {{ put("value",status_yinhang);}}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id,map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + /** + * 更新客户报备数据 + * @throws Exception + */ + public void updateData(String id,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f3b97652bc8c0008ae8a23", ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("status_yinhang",new HashMap() {{ put("value","代扣失败");}}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id,map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + + + /** + * 更新客户报备数据 + * @throws Exception + */ + public void updateYinHangData(String id,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3","62f3bd85f38042000848842e", ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("status_jiaoyan",new HashMap() {{ put("value","是");}}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id,map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + + /** + * 更新客户报备数据 + * @throws Exception + */ + public void updateYinHangDataGongZi(String id,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f4913c82654a00085de9e4", ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("status_jiaoyan",new HashMap() {{ put("value","是");}}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id,map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + + /** + * 工资表 更新状态 + * @throws Exception + */ + public void updateData_gongzi(String id, String status_yinhang,JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f4752f87648b0007aebd47", ssoConfig.getAppkey()); + Map map1; + map1=new HashMap(){ + { + put("status_yinhang",new HashMap() {{ put("value",status_yinhang);}}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id,map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + /** + * 选择发票按卷 按照业务流水编码 + * @param jdyConfig + * @return + */ + public JSONArray selectYinHang(String month,JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3","62f3bd85f38042000848842e", jdyConfig.getAppkey()); + final List> condList = new ArrayList>();//因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(""); + JSONArray jsonArray1 = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray1.add(month); + condList.add(new HashMap() { + { + put("field", "status_jiaoyan");//查新字段的名称/别名 + put("method", "empty");//判断的方法 +// put("value", jsonArray);//查询的条件 + } + }); + condList.add(new HashMap() { + { + put("field", "yuefen");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray1);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao", + "status_yinhang","sijixingming","yinhangkahao"},//业务流水,录入首号,录入尾号 + 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> 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"); + } + + + /** + * 查询所有未更新银行状态的工资数据 + * @param jdyConfig + * @return + */ + public JSONArray selectYinHang_gongzi(String month,JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f4913c82654a00085de9e4", jdyConfig.getAppkey()); + final List> condList = new ArrayList>();//因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(""); + JSONArray jsonArray1 = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray1.add(month); + condList.add(new HashMap() { + { + put("field", "status_jiaoyan");//查新字段的名称/别名 +// put("method", "nq");//判断的方法 + put("method", "empty");//判断的方法 +// put("value", jsonArray);//查询的条件 + } + }); + condList.add(new HashMap() { + { + put("field", "yuefen");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray1);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao","jine", + "status_yinhang","sijixingming","yinhangkahao"},//业务流水,录入首号,录入尾号 + 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> 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> findData(APIUtils api,Map filter,String id){ + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao","jine", + "status_yinhang","sijixingming","yinhangkahao","sijixingming","yinhangkahao"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + + + /** + * 查询每月生成数据信息 + * @param jdyConfig + * @return + */ + public JSONObject selectMonthData(String month,JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3","62f3b97652bc8c0008ae8a23", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(month); + condList.add(new HashMap() { + { + put("field", "yuefen");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao", "status_yinhang","sijixingming","yinhangkahao"},//身份证,本月扣减金额 + 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> data=findData1(api,filter,id); + if (data==null){ + i=0; + }else { + datas.addAll(data); + i=i+1; + } + }else { + i=0; + } + } + } + JSONObject jsonObject_test=new JSONObject(); + jsonObject_test.put("list",datas); + JSONArray data=jsonObject_test.getJSONArray("list"); + JSONObject jsonObject=new JSONObject(); + for (Object o:data){ + JSONObject map=(JSONObject)o; + jsonObject.put(map.getString("sijixingming")+map.getString("yinhangkahao"),map); + } + return jsonObject; + } + + private static List> findData1(APIUtils api,Map filter,String id){ + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao","jine","status_yinhang","sijixingming","yinhangkahao"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + /** + * 查询每月生成数据信息 + * @param jdyConfig + * @return + */ + public JSONObject selectMonthData_Gongzi(String month,JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f4752f87648b0007aebd47", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(month); + condList.add(new HashMap() { + { + put("field", "yuefen");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"sijishenfenzhenghao","jine","status_yinhang","sijixingming","yinhangkahao"},//身份证,本月扣减金额 + 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> data=findData1(api,filter,id); + if (data==null){ + i=0; + }else { + datas.addAll(data); + i=i+1; + } + }else { + i=0; + } + } + } + JSONObject jsonObject_test=new JSONObject(); + jsonObject_test.put("list",datas); + JSONArray data=jsonObject_test.getJSONArray("list"); + JSONObject jsonObject=new JSONObject(); + for (Object o:data){ + JSONObject map=(JSONObject)o; + jsonObject.put(map.getString("sijishenfenzhenghao")+map.getString("jine"),map); + } + return jsonObject; + } + + + +} diff --git a/src/main/java/com/example/sso/dao/YueFenJiSuanInfoDao.java b/src/main/java/com/example/sso/dao/YueFenJiSuanInfoDao.java new file mode 100644 index 0000000..abe9de9 --- /dev/null +++ b/src/main/java/com/example/sso/dao/YueFenJiSuanInfoDao.java @@ -0,0 +1,880 @@ +package com.example.sso.dao; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.config.SSOConfig; +import com.example.sso.util.APIUtils; +import com.example.sso.util.DataBatchUtil; +import com.example.sso.util.TimeUtil; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.*; + +@Component +public class YueFenJiSuanInfoDao { + /** + * 更新客户报备数据 + * + * @throws Exception + */ + public static void updateFlowId(String id, String appId, String entryId, String flow_id, JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils(appId, entryId, ssoConfig.getAppkey()); + Map map1; + map1 = new HashMap() { + { + put("flow_id", new HashMap() {{ + put("value", flow_id); + }}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id, map1); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 查询每个人的承包金标准 分别为 承包金(月份)、个税、保养费、调度费、社保 组成 + * + * @param jdyConfig + * @return + */ + public JSONArray selectChengBaiJinBiaoZhun(JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3", "62ef512dd727d700099f4910", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(""); + condList.add(new HashMap() { + { + put("field", "id_card");//查新字段的名称/别名 + put("method", "nq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + condList.add(new HashMap() { + { + put("field", "piliangtuizubiaoshi");//查新字段的名称/别名 + put("method", "empty");//判断的方法 +// put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"id_card", "chengbaojin", + "geshui", "weixiujijin", "diandiaofei", "shebao", "gongsi", "name", "fensi", "haopaihaoma", + "fensifuzeren", "jiancheng", "yinhangkahao", "daikouyinhang", "zhunyingzhenghaoma", "guanlibumen", "guanlibumenfuzeren", + "yuanchengshuakafei", "anquanjijin", "dianchiweibaofei", "huandianfei","yanglaobaoxian","yiliaobaoxian","shiyebaoxian","gongjijin"},//身份证,承包金,个税,保养费,调度费,社保 准营证号码zhunyingzhenghaoma管理部门guanlibumen管理部门负责人guanlibumenfuzeren远程刷卡费yuanchengshuakafei安全基金anquanjijin电池维保费dianchiweibaofei代收代付换电费huandianfei + + 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> 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> findData(APIUtils api, Map filter, String id) { + List> datas = api.getFormData(10000, new String[]{"id_card", "chengbaojin", + "geshui", "weixiujijin", "diandiaofei", "shebao", "gongsi", "name", "fensi", "haopaihaoma", + "fensifuzeren", "jiancheng", "yinhangkahao", "daikouyinhang", "zhunyingzhenghaoma", "guanlibumen", "guanlibumenfuzeren", + "yuanchengshuakafei", "anquanjijin", "dianchiweibaofei", "huandianfei","yanglaobaoxian","yiliaobaoxian","shiyebaoxian","gongjijin"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + /** + * 查询每月核减情况 + * + * @param jdyConfig + * @return + */ + public JSONObject selectHeJian(String month, JDYConfig jdyConfig, JSONArray persons) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3", "62ef6cd6741a1e000744cc2c", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(month); + condList.add(new HashMap() { + { + put("field", "month");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"id_card", "jine", "suoshubumen", "fensi", "xingming", "chepaihaoma", + "month", "shenqingbumen", "shiyou", "shenqingshijian", "leixing", "cheliangxinghao", "banzhi"},//身份证,本月扣减金额 + 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> data = findData1(api, filter, id); + if (data == null) { + i = 0; + } else { + datas.addAll(data); + i = i + 1; + } + } else { + i = 0; + } + } + } + JSONObject person_feishuidangan = new JSONObject(); + for (Object o : persons) { + JSONObject person = (JSONObject) o; + String id_card = person.getString("id_card"); + person_feishuidangan.put(id_card, person); + } + JSONObject jsonObject_test = new JSONObject(); + jsonObject_test.put("list", datas); + JSONArray data = jsonObject_test.getJSONArray("list"); + JSONObject jsonObject = new JSONObject(); + for (Object o : data) { + JSONObject map = (JSONObject) o; + if (jsonObject.get(map.getString("id_card")) == null) { + if (map.getDouble("jine") != null) { + jsonObject.put(map.getString("id_card"), map.get("jine")); + } + } else { + Double a = jsonObject.getDouble((String) map.get("id_card")); + if (map.getDouble("jine") != null) { + jsonObject.put((String) map.get("id_card"), a + map.getDouble("jine")); + } + } + if (person_feishuidangan.getString(map.getString("id_card")) != null) { + updateHeZengStatus("65122df9d8ce14000e42b2b3", "62ef6cd6741a1e000744cc2c", map.getString("_id"), jdyConfig); + } + } + return jsonObject; + } + + + /** + * 更新承包金核增核减汇总-在车 数据状态为 加入计划 + * + * @throws Exception + */ + public static void updateHeZengStatus(String appId, String entryId, String id, JDYConfig ssoConfig) { + try { + APIUtils api = new APIUtils(appId, entryId, ssoConfig.getAppkey()); + Map map1; + map1 = new HashMap() { + { + put("status", new HashMap() {{ + put("value", "加入计划"); + }}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id, map1); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * 查询每月核减情况 + * + * @param jdyConfig + * @return + */ + public JSONObject selectHeJianAllInfo(String month, JDYConfig jdyConfig) { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3", "62ef6cd6741a1e000744cc2c", jdyConfig.getAppkey()); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(month); + condList.add(new HashMap() { + { + put("field", "month");//查新字段的名称/别名 + put("method", "eq");//判断的方法 + put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"id_card", "jine", "suoshubumen", "fensi", "xingming", "chepaihaoma", + "month", "shenqingbumen", "shiyou", "shenqingshijian", "leixing", "cheliangxinghao", "banzhi"},//身份证,本月扣减金额 + 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> data = findData1(api, filter, id); + if (data == null) { + i = 0; + } else { + datas.addAll(data); + i = i + 1; + } + } else { + i = 0; + } + } + } + JSONObject jsonObject_test = new JSONObject(); + jsonObject_test.put("list", datas); + JSONArray data = jsonObject_test.getJSONArray("list"); + JSONObject jsonObject = new JSONObject(); + for (Object o : data) { + JSONObject map = (JSONObject) o; + jsonObject.put(map.getString("id_card"), map); + } + return jsonObject; + } + + private static List> findData1(APIUtils api, Map filter, String id) { + List> datas = api.getFormData(10000, new String[]{"id_card", "jine", "suoshubumen", "fensi", "xingming", "chepaihaoma", + "month", "shenqingbumen", "shiyou", "shenqingshijian", "leixing", "cheliangxinghao", "banzhi"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + /** + * 创建流水账数据 月份 + * + * @throws Exception + */ + public void createLiuShuiYueFen(List> jsonArray, JDYConfig ssoConfig) { + JSONArray fields = new JSONArray(); + fields.add("type"); + fields.add("fukuanshiyou"); + fields.add("yewubiaodanmingcheng"); + fields.add("yewubiaodanbianma"); + fields.add("sijixingming"); + fields.add("sijishenfenzhenghao"); + fields.add("sijisuozaigongsi"); + fields.add("jine"); + JSONArray fields_data = new JSONArray(); + fields_data.add("type"); + fields_data.add("fukuanshiyou"); + fields_data.add("yewubiaodanmingcheng"); + fields_data.add("yewubiaodanbianma"); + fields_data.add("sijixingming"); + fields_data.add("sijishenfenzhenghao"); + fields_data.add("sijisuozaigongsi"); + fields_data.add("jine"); + int i = 1; + JSONArray create_data = new JSONArray(); + for (Object o : jsonArray) { + JSONObject jsonObject = (JSONObject) o; + if (i >= 1) { + create_data.add(jsonObject); + i = i + 1; + if (create_data.size() == 100) { + DataBatchUtil.dataBatchCreate("65122df9d8ce14000e42b2b3", "62ecd78e76f428000749e457", ssoConfig.getAppkey(), create_data, fields, fields_data); + create_data.clear();//清空 + } + } + } + if (create_data.size() != 0) { + DataBatchUtil.dataBatchCreate("65122df9d8ce14000e42b2b3", "62ecd78e76f428000749e457", ssoConfig.getAppkey(), create_data, fields, fields_data); + create_data.clear();//清空 + } +// System.out.println("共计同步:" + i + "条出差数据数据"); + } + + + /** + * 创建流水账数据 月份 + * + * @throws Exception + */ + public void createYinHangDaoChu(List> jsonArray, JDYConfig ssoConfig) { + JSONArray fields = new JSONArray(); + fields.add("type"); + fields.add("fukuanshiyou"); + fields.add("yewubiaodanmingcheng"); + fields.add("yewubiaodanbianma"); + fields.add("sijixingming"); + fields.add("sijishenfenzhenghao"); + fields.add("sijisuozaigongsi"); + fields.add("jine"); + fields.add("fensi"); + fields.add("yuefen"); + fields.add("haopaihaoma"); + //fields.add("hejianjine"); + fields.add("chengbaojin"); + fields.add("geshui"); + fields.add("weixiujijin"); + fields.add("diandiaofei"); + fields.add("shebao"); + fields.add("feishuihejijine"); + fields.add("zonge"); + fields.add("weijinrujihuazengjiane"); + fields.add("jiancheng"); + fields.add("fensifuzeren"); + fields.add("yinhangkahao"); + fields.add("daikouyinhang"); + + +//新增字段 + fields.add("zhunyingzhenghaoma"); + fields.add("guanlibumen"); + fields.add("guanlibumenfuzeren"); + fields.add("yuanchengshuakafei"); + fields.add("anquanjijin"); + fields.add("dianchiweibaofei"); + fields.add("huandianfei"); + fields.add("leijiqianjiaojine"); + fields.add("bencidikoujine"); + fields.add("yanglaobaoxian"); + fields.add("yiliaobaoxian"); + fields.add("shiyebaoxian"); + fields.add("gongjijin"); + fields.add("dangyueyuefen"); + + JSONArray fields_data = new JSONArray(); + fields_data.add("type"); + fields_data.add("fukuanshiyou"); + fields_data.add("yewubiaodanmingcheng"); + fields_data.add("yewubiaodanbianma"); + fields_data.add("sijixingming"); + fields_data.add("sijishenfenzhenghao"); + fields_data.add("sijisuozaigongsi"); + fields_data.add("jine"); + fields_data.add("fensi"); + fields_data.add("yuefen"); + fields_data.add("haopaihaoma"); + // fields_data.add("hejianjine"); + fields_data.add("chengbaojin"); + fields_data.add("geshui"); + fields_data.add("weixiujijin"); + fields_data.add("diandiaofei"); + fields_data.add("shebao"); + fields_data.add("feishuihejijine"); + fields_data.add("zonge"); + fields_data.add("weijinrujihuazengjiane"); + fields_data.add("jiancheng"); + fields_data.add("fensifuzeren"); + fields_data.add("yinhangkahao"); + fields_data.add("daikouyinhang"); + + + + fields_data.add("zhunyingzhenghaoma"); + fields_data.add("guanlibumen"); + fields_data.add("guanlibumenfuzeren"); + fields_data.add("yuanchengshuakafei"); + fields_data.add("anquanjijin"); + fields_data.add("dianchiweibaofei"); + fields_data.add("huandianfei"); + fields_data.add("leijiqianjiaojine"); + fields_data.add("bencidikoujine"); + fields_data.add("yanglaobaoxian"); + fields_data.add("yiliaobaoxian"); + fields_data.add("shiyebaoxian"); + fields_data.add("gongjijin"); + fields_data.add("dangyueyuefen"); + int i = 1; + JSONArray create_data = new JSONArray(); + for (Object o : jsonArray) { + JSONObject jsonObject = (JSONObject) o; + if (i >= 1) { + create_data.add(jsonObject); + i = i + 1; + if (create_data.size() == 100) { + DataBatchUtil.dataBatchCreate("65122df9d8ce14000e42b2b3", "62f3b97652bc8c0008ae8a23", ssoConfig.getAppkey(), create_data, fields, fields_data); + create_data.clear();//清空 + } + } + } + if (create_data.size() != 0) { + DataBatchUtil.dataBatchCreate("65122df9d8ce14000e42b2b3", "62f3b97652bc8c0008ae8a23", ssoConfig.getAppkey(), create_data, fields, fields_data); + create_data.clear();//清空 + } + System.out.println("共计同步:" + (i - 1) + "条出差数据数据"); + } + /** + * + *驾驶员个人账户-WF 余额 + * + */ + public static void main(String[] args) { + System.out.println(selectJiaShiYuanZahngHuYuE()); + } + + public static JSONObject selectJiaShiYuanZahngHuYuE(){ + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3", "645b5af630488a0007259b55", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex"); + final List> condList = new ArrayList>(); + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(0.00); + + condList.add(new HashMap() { + { + put("field", "balance");//查新字段的名称/别名 + put("method", "not_empty");//判断的方法 + // put("value", jsonArray);//查询的条件 + } + }); + + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + + List> datas = api.getFormData(10000, new String[]{"id_card", "name", "hphm", "jg", "fs", "fsfz", + "pay", "deduction", "balance", "date" },//身份证,本月扣减金额 + 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> data = findData3(api, filter, id); + if (data == null) { + i = 0; + } else { + datas.addAll(data); + i = i + 1; + } + } else { + i = 0; + } + } + } + JSONObject jsonObject_test = new JSONObject(); + jsonObject_test.put("list", datas); + JSONArray data = jsonObject_test.getJSONArray("list"); + JSONObject jsonObject = new JSONObject(); + for (Object o : data) { + JSONObject map = (JSONObject) o; + /*if (jsonObject.get(map.getString("id_card")) == null) { + if (map.getDouble("balance") != null) { + jsonObject.put(map.getString("id_card"), map.get("balance")); + } + }*/ /*else {*/ + Double a = jsonObject.getDouble((String) map.get("id_card")); + if (map.getDouble("balance") != null) { + jsonObject.put((String) map.get("id_card"), map.getDouble("balance")); + } + } + + /*}*/ + return jsonObject; + } + + private static List> findData3(APIUtils api, Map filter, String id) { + List> datas = api.getFormData(10000, new String[]{"id_card", "name", "hphm", "jg", "fs", "fsfz", + "pay", "deduction", "balance", "date" }, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + + public JSONObject shoukuan(JDYConfig jdyConfig){ + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3", "62ecd78e76f428000749e457", jdyConfig.getAppkey()); + final List> condList = new ArrayList>();//因为想查询大于50的数据,所以创建一个数组 + + JSONArray jsonArray1 = new JSONArray(); + jsonArray1.add("预收承包金"); + JSONArray jsonArray2 = new JSONArray(); + jsonArray1.add("收款"); + + + condList.add(new HashMap() { + { + put("field", "fukuanshiyou");//查新字段的名称/别名 + put("method", "ne");//判断的方法 + put("value", jsonArray1);//查询的条件 + } + }); + /*condList.add(new HashMap() { + { + put("field", "type");//查新字段的名称/别名 + put("method", "like");//判断的方法 + put("value", jsonArray2);//查询的条件 + } + });*/ + + + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + List> datas = api.getFormData(10000, new String[]{"sijixingming","type", "sijishenfenzhenghao", "company_jc", "xd", "license_plate", "jc", + "sijisuozaigongsi", "fs", "fs_p", "jine", "pay", "unpay", "status", "hz_month", "ys", "bj", "sy",},//身份证,本月扣减金额 + 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> data = findData2(api, filter, id); + if (data == null) { + i = 0; + } else { + datas.addAll(data); + i = i + 1; + } + } else { + i = 0; + } + } + } + + JSONObject jsonObject_test = new JSONObject(); + jsonObject_test.put("list", datas); + JSONArray data = jsonObject_test.getJSONArray("list"); + JSONObject jsonObject = new JSONObject(); + for (Object o : data) { + JSONObject map = (JSONObject) o; + if (jsonObject.get(map.getString("sijishenfenzhenghao")) == null) { + if (map.getDouble("unpay") != null) { + jsonObject.put(map.getString("sijishenfenzhenghao"), map.get("unpay")); + + + } + } else { + /* Double a = jsonObject.getDouble((String) map.get("sijishenfenzhenghao"));*/ + if (map.getDouble("unpay") != null ) { + jsonObject.put((String) map.get("sijishenfenzhenghao"), map.getDouble("unpay")); + + + + } + } + + } + return jsonObject; + } + + /* public static void main(String[] args) { + System.out.println(fukuan()); + } +*/ +/* +未收付查询未缴费用 + */ + + public static JSONObject fukuan(){ + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3", "62ecd78e76f428000749e457", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex"); + final List> condList = new ArrayList>();//因为想查询大于50的数据,所以创建一个数组 + + JSONArray jsonArray1 = new JSONArray(); + jsonArray1.add("预收承包金"); + /*JSONArray jsonArray2 = new JSONArray(); + jsonArray1.add("付款");*/ + + + condList.add(new HashMap() { + { + put("field", "fukuanshiyou");//查新字段的名称/别名 + put("method", "ne");//判断的方法 + put("value", jsonArray1);//查询的条件 + } + }); + /* condList.add(new HashMap() { + { + put("field", "type");//查新字段的名称/别名 + put("method", "like");//判断的方法 + put("value", jsonArray2);//查询的条件 + } + });*/ + + + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + List> datas = api.getFormData(10000, new String[]{"sijixingming","type", "sijishenfenzhenghao", "company_jc", "xd", "license_plate", "jc", + "sijisuozaigongsi", "fs", "fs_p", "jine", "pay", "unpay", "status", "hz_month", "ys", "bj", "sy","fukuanshiyou"},//身份证,本月扣减金额 + 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> data = findData2(api, filter, id); + if (data == null) { + i = 0; + } else { + datas.addAll(data); + i = i + 1; + } + } else { + i = 0; + } + } + } + + JSONObject jsonObject_test = new JSONObject(); + jsonObject_test.put("list", datas); + JSONArray data = jsonObject_test.getJSONArray("list"); + JSONObject jsonObject = new JSONObject(); + Map addmap = new HashMap<>(); + for (Object o : data) { + JSONObject map = (JSONObject) o; + /* if (jsonObject.get(map.getString("sijishenfenzhenghao")) == null) { + if (map.getDouble("unpay") != null ) { + jsonObject.put(map.getString("sijishenfenzhenghao"), (map.get("unpay"))); + + + } + }*/ /*else {*/ + //Double a = jsonObject.getDouble((String) map.get("sijishenfenzhenghao")); + String idCard=map.getString("sijishenfenzhenghao"); + Double B = addmap.get(idCard)==null?0.0:(Double)addmap.get(idCard) ; + if (map.getDouble("unpay") != null && map.getString("type").equals("收款") && !map.getString("fukuanshiyou").contains("预收承包金") && !map.getString("fukuanshiyou").contains("违约金") && !map.getString("fukuanshiyou").contains("维修费") && !map.getString("fukuanshiyou").contains("交通违法赔偿金") && !map.getString("fukuanshiyou").contains("营运违法赔偿金") && !map.getString("fukuanshiyou").contains("退还奖励")) { + B=B+map.getDouble("unpay").doubleValue(); + jsonObject.put(idCard, B ); + addmap.put(idCard,B); + + + } + if (map.getDouble("unpay") != null && map.getString("type").equals("付款") && !map.getString("fukuanshiyou").contains("预收承包金") && !map.getString("fukuanshiyou").contains("违约金") && !map.getString("fukuanshiyou").contains("维修费") && !map.getString("fukuanshiyou").contains("交通违法赔偿金") && !map.getString("fukuanshiyou").contains("营运违法赔偿金") && !map.getString("fukuanshiyou").contains("退还奖励")) { + B=B-map.getDouble("unpay").doubleValue(); + jsonObject.put(idCard, B ); + addmap.put(idCard,B); + + } + + /* if (map.getDouble("unpay") != null && map.getString("type").equals("付款")) { + jsonObject.put((String) map.get("sijishenfenzhenghao"), -map.getDouble("unpay").doubleValue()); + + + }*/ + /*}*/ + + } + return jsonObject; + } + + + + + + /*Map addmap = new HashMap<>(); + for (Object o : data) { + JSONObject map = (JSONObject) o; + *//* if (jsonObject.get(map.getString("sijishenfenzhenghao")) == null) { + if (map.getDouble("unpay") != null ) { + jsonObject.put(map.getString("sijishenfenzhenghao"), (map.get("unpay"))); + + + } + }*//* *//*else {*//* + //Double a = jsonObject.getDouble((String) map.get("sijishenfenzhenghao")); + String idCard=map.getString("sijishenfenzhenghao"); + Double B = addmap.get(idCard)==null?0.0:(Double)addmap.get(idCard) ; + if (map.getDouble("unpay") != null && map.getString("type").equals("收款")) { + B=B+map.getDouble("unpay").doubleValue(); + jsonObject.put(idCard, B ); + addmap.put(idCard,B); + + + } + + if (map.getDouble("unpay") != null && map.getString("type").equals("付款")) { + B=B-map.getDouble("unpay").doubleValue(); + jsonObject.put(idCard, B ); + addmap.put(idCard,B); + + } + + } + + +*/ + + + + private static List> findData2(APIUtils api, Map filter, String id) { + List> datas = api.getFormData(10000, new String[]{"sijixingming","type", "sijishenfenzhenghao", "company_jc", "xd", "license_plate", "jc", + "sijisuozaigongsi", "fs", "fs_p", "jine", "pay", "unpay", "status", "hz_month", "ys", "bj", "sy","fukuanshiyou"}, + filter, id); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + return datas; + } + + + /* public static void main(String[] args) { + System.out.println(types()); + }*/ + + public static JSONObject types() { + APIUtils api = new APIUtils("65122df9d8ce14000e42b2b3", "62ecd78e76f428000749e457", "BkIyzlh1onqnqu9cQ3ralDQBjECn97ex"); + final List> condList = new ArrayList>();//因为想查询大于50的数据,所以创建一个数组 + + JSONArray jsonArray1 = new JSONArray(); + jsonArray1.add("预收承包金"); + + + condList.add(new HashMap() { + { + put("field", "type");//查新字段的名称/别名 + put("method", "not_empty");//判断的方法 + // put("value", jsonArray1);//查询的条件 + } + }); + + + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + List> datas = api.getFormData(10000, new String[]{"sijixingming","type", "sijishenfenzhenghao", "company_jc", "xd", "license_plate", "jc", + "sijisuozaigongsi", "fs", "fs_p", "jine", "pay", "unpay", "status", "hz_month", "ys", "bj", "sy",},//身份证,本月扣减金额 + 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> data = findData2(api, filter, id); + if (data == null) { + i = 0; + } else { + datas.addAll(data); + i = i + 1; + } + } else { + i = 0; + } + } + } + + JSONObject jsonObject_test = new JSONObject(); + jsonObject_test.put("list", datas); + JSONArray data = jsonObject_test.getJSONArray("list"); + + JSONObject jsonObject = new JSONObject(); + for (Object o : data) { + + JSONObject map = (JSONObject) o; + jsonObject.put(map.getString("sijishenfenzhenghao"), map.get("type")); + + } + return jsonObject; + } + + + + +} diff --git a/src/main/java/com/example/sso/schedule/ScheduleCreateDriverYueFen.java b/src/main/java/com/example/sso/schedule/ScheduleCreateDriverYueFen.java new file mode 100644 index 0000000..5dbdb0b --- /dev/null +++ b/src/main/java/com/example/sso/schedule/ScheduleCreateDriverYueFen.java @@ -0,0 +1,408 @@ +package com.example.sso.schedule; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.dao.ChengBaoJinHeZengHeJianDao; +import com.example.sso.dao.YueFenJiSuanInfoDao; +import com.example.sso.util.TimeUtil; +import lombok.Getter; +import lombok.Setter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.*; + +@Component +public class ScheduleCreateDriverYueFen { + Logger logger = LoggerFactory.getLogger(getClass()); + @Getter @Setter @Autowired private JDYConfig jdyConfig; + //每月生成司机应缴纳金额,每月25日收取下月 缴纳金额根据 驾驶员承包金缴纳标准档案 表单进行收取 + //并根据核减项目,核减项目为上月提交,下月生效,生效日期为一个月。 + //银行划扣是 25号以前 还是25号以后 + @Scheduled(cron = " 0 37 9 21 * ?")//每月25日触发 + public void ScheduleCreateDriverYueFen(){ + YueFenJiSuanInfoDao yueFenJiSuanInfoDao=new YueFenJiSuanInfoDao(); + JSONArray persons=yueFenJiSuanInfoDao.selectChengBaiJinBiaoZhun(jdyConfig); + //JSONObject hejian=yueFenJiSuanInfoDao.selectHeJian(TimeUtil.getMonthDate(new Date()),jdyConfig,persons); + // JSONObject hejian_AllInfo=yueFenJiSuanInfoDao.selectHeJianAllInfo(TimeUtil.getMonthDate(new Date()),jdyConfig); + JSONObject selectJiaShiYuanZahngHuYuE = yueFenJiSuanInfoDao.selectJiaShiYuanZahngHuYuE(); + // JSONObject shoukuan = yueFenJiSuanInfoDao.shoukuan(jdyConfig); + + // JSONObject types = yueFenJiSuanInfoDao.types(); + + JSONObject fukuan = yueFenJiSuanInfoDao.fukuan(); + List> jsonArray=new LinkedList<>(); + for (Object map:persons){ + Map data=new JSONObject(); + JSONObject jsonObject=(JSONObject)map; + Double zonge=0.0; + String id_card=jsonObject.getString("id_card"); + String jiancheng=jsonObject.getString("jiancheng"); + String yinhangkahao=jsonObject.getString("yinhangkahao"); + Double chengbaojin=jsonObject.getDouble("chengbaojin"); + Double geshui=jsonObject.getDouble("geshui"); + Double weixiujijin=jsonObject.getDouble("weixiujijin"); + Double diandiaofei=jsonObject.getDouble("diandiaofei"); + Double shebao=jsonObject.getDouble("shebao"); + JSONObject fensifuzeren=jsonObject.getJSONObject("fensifuzeren"); + String zhunyingzhenghaoma = jsonObject.getString("zhunyingzhenghaoma"); + String guanlibumen = jsonObject.getString("guanlibumen"); + JSONObject guanlibumenfuzeren = jsonObject.getJSONObject("guanlibumenfuzeren"); + /* Double weixiujijin = jsonObject.getDouble("weixiujijin"); + Double diandiaofei = jsonObject.getDouble("diandiaofei");*/ + + Double yuanchengshuakafei = jsonObject.getDouble("yuanchengshuakafei"); + Double anquanjijin = jsonObject.getDouble("anquanjijin"); + Double dianchiweibaofei = jsonObject.getDouble("dianchiweibaofei"); + Double huandianfei = jsonObject.getDouble("huandianfei"); + Double yanglaobaoxian = jsonObject.getDouble("yanglaobaoxian"); + Double yiliaobaoxian = jsonObject.getDouble("yiliaobaoxian"); + Double shiyebaoxian = jsonObject.getDouble("shiyebaoxian"); + Double gongjijin = jsonObject.getDouble("gongjijin"); + + + Integer guanlibumenfuzeren_no =null; + if (guanlibumenfuzeren!=null){ + guanlibumenfuzeren_no=guanlibumenfuzeren.getInteger("dept_no"); + } + + + Integer fensifuzeren_no=null; + if (fensifuzeren!=null){ + fensifuzeren_no=fensifuzeren.getInteger("dept_no"); + } + if (chengbaojin!=null){ + zonge=zonge+chengbaojin; + data.put("chengbaojin",chengbaojin); + }else { + data.put("chengbaojin",0); + } + if (geshui!=null){ + zonge=zonge+geshui; + data.put("geshui",geshui); + }else { + data.put("geshui",0); + } + if (weixiujijin!=null){ + zonge=zonge+weixiujijin; + data.put("weixiujijin",weixiujijin); + }else { + data.put("weixiujijin",0); + } + if (diandiaofei!=null){ + zonge=zonge+diandiaofei; + data.put("diandiaofei",diandiaofei); + }else { + data.put("diandiaofei",0); + } + if (shebao!=null){ + zonge=zonge+shebao; + data.put("shebao",shebao); + }else { + data.put("shebao",0); + } + //上海业务新增字段 + if (yuanchengshuakafei != null) { + zonge = zonge + yuanchengshuakafei; + data.put("yuanchengshuakafei", yuanchengshuakafei); + } else { + data.put("yuanchengshuakafei", 0); + } + + if (gongjijin != null) { + zonge = zonge + gongjijin; + data.put("gongjijin", gongjijin); + } else { + data.put("gongjijin", 0); + } + + + + if (anquanjijin != null) { + zonge = zonge + anquanjijin; + data.put("anquanjijin", anquanjijin); + } else { + data.put("anquanjijin", 0); + } + if (dianchiweibaofei != null) { + zonge = zonge + dianchiweibaofei; + data.put("dianchiweibaofei", dianchiweibaofei); + } else { + data.put("dianchiweibaofei", 0); + } + if (huandianfei != null) { + zonge = zonge + huandianfei; + data.put("huandianfei", huandianfei); + } else { + data.put("huandianfei", 0); + } + + if (yanglaobaoxian != null) { + + data.put("yanglaobaoxian", yanglaobaoxian); + } else { + data.put("yanglaobaoxian", 0); + } + if (yiliaobaoxian != null) { + + data.put("yiliaobaoxian", yiliaobaoxian); + } else { + data.put("yiliaobaoxian", 0); + } + if (shiyebaoxian != null) { + + data.put("shiyebaoxian", shiyebaoxian); + } else { + data.put("shiyebaoxian", 0); + } + + + + + + + if (zonge!=null){ + data.put("zonge",zonge); + } + + + + + // Double hejian_jie = hejian.getDouble(id_card); + Double selectJiaShiYuanZahngHuYuEDouble = selectJiaShiYuanZahngHuYuE.getDouble(id_card); + // Double shoukuanDouble = shoukuan.getDouble(id_card); + + Double fukuanDouble = fukuan.getDouble(id_card); + + //String typesString = types.getString(id_card); + // String shoukuanString = shoukuan.getString(id_card); + + System.out.println(fukuanDouble); + + + + + + Double dangyuechengbaojin=0.0; + Double dikou = 0.0; + + if (/*hejian_jie!=null &&*/ selectJiaShiYuanZahngHuYuEDouble != null && selectJiaShiYuanZahngHuYuEDouble > 0.0){ + + data.put("leijiqianjiaojine",-selectJiaShiYuanZahngHuYuEDouble); + dangyuechengbaojin=zonge-/*hejian_jie-*/selectJiaShiYuanZahngHuYuEDouble; + + //data.put("hejianjine",hejian_jie); + if (dangyuechengbaojin > 0) { + data.put("jine", dangyuechengbaojin); + }else { + data.put("jine", 0); + } + + + + } else if (selectJiaShiYuanZahngHuYuEDouble != null && selectJiaShiYuanZahngHuYuEDouble==0.0 && fukuanDouble ==null) { + data.put("leijiqianjiaojine", 0); + dangyuechengbaojin = zonge ; + + //data.put("hejianjine",hejian_jie); + if (dangyuechengbaojin > 0) { + data.put("jine", dangyuechengbaojin); + } else { + data.put("jine", 0); + } + + } + /*else if (*//*hejian_jie!=null &&*//* selectJiaShiYuanZahngHuYuEDouble != null && selectJiaShiYuanZahngHuYuEDouble == 0.0 && fukuanDouble !=null ) { + + data.put("leijiqianjiaojine", fukuanDouble); + dangyuechengbaojin = zonge +*//*hejian_jie+*//*fukuanDouble; + + //data.put("hejianjine",hejian_jie); + if (dangyuechengbaojin > 0) { + data.put("jine", dangyuechengbaojin); + } else { + data.put("jine", 0); + } + } */else if (selectJiaShiYuanZahngHuYuEDouble != null && selectJiaShiYuanZahngHuYuEDouble==0.0 && fukuanDouble !=null) { + data.put("leijiqianjiaojine", fukuanDouble); + dangyuechengbaojin = zonge +/*hejian_jie+*/fukuanDouble; + + //data.put("hejianjine",hejian_jie); + if (dangyuechengbaojin > 0) { + data.put("jine", dangyuechengbaojin); + } else { + data.put("jine", 0); + } + + } else if (fukuanDouble !=null) { + data.put("leijiqianjiaojine", fukuanDouble); + dangyuechengbaojin = zonge +/*hejian_jie+*/fukuanDouble; + + //data.put("hejianjine",hejian_jie); + if (dangyuechengbaojin > 0) { + data.put("jine", dangyuechengbaojin); + } else { + data.put("jine", 0); + } + + } else if (selectJiaShiYuanZahngHuYuEDouble == null && fukuanDouble ==null) { + data.put("leijiqianjiaojine", 0); + dangyuechengbaojin = zonge ; + + //data.put("hejianjine",hejian_jie); + if (dangyuechengbaojin > 0) { + data.put("jine", dangyuechengbaojin); + } else { + data.put("jine", 0); + } + + } + + + + + + /*else if (selectJiaShiYuanZahngHuYuEDouble != null *//*&& hejian_jie ==null*//* ){ + data.put("leijiqianjiaojine",-selectJiaShiYuanZahngHuYuEDouble); + dangyuechengbaojin=zonge-selectJiaShiYuanZahngHuYuEDouble; + //data.put("hejianjine",0); + if (dangyuechengbaojin > 0){ + data.put("jine",dangyuechengbaojin); + }else { + data.put("jine", 0); + } + }*/ + + + /* if (*//*hejian_jie!=null &&*//* selectJiaShiYuanZahngHuYuEDouble != null && selectJiaShiYuanZahngHuYuEDouble == 0.0 && fukuanDouble !=null ){ + + data.put("leijiqianjiaojine",fukuanDouble); + dangyuechengbaojin=zonge+*//*hejian_jie+*//*fukuanDouble; + + //data.put("hejianjine",hejian_jie); + if (dangyuechengbaojin > 0) { + data.put("jine", dangyuechengbaojin); + }else { + data.put("jine", 0); + } + + + + } */ /*else if (*//*hejian_jie ==null &&*//* selectJiaShiYuanZahngHuYuEDouble == null && fukuanDouble !=null ){ + + data.put("leijiqianjiaojine",fukuanDouble); + dangyuechengbaojin=zonge+fukuanDouble; + + // data.put("hejianjine",0); + if (dangyuechengbaojin > 0) { + data.put("jine", dangyuechengbaojin); + }else { + data.put("jine", 0); + } + + + + }*/ + /* else if (selectJiaShiYuanZahngHuYuEDouble == null && hejian_jie ==null && shoukuanDouble !=null ){ + data.put("leijiqianjiaojine",shoukuanDouble); + dangyuechengbaojin=zonge+shoukuanDouble; + data.put("hejianjine",0); + data.put("jine",dangyuechengbaojin); + } + + + else if (selectJiaShiYuanZahngHuYuEDouble == null && hejian_jie ==null && shoukuanDouble !=null ){ + data.put("leijiqianjiaojine",-shoukuanDouble); + dangyuechengbaojin=zonge-shoukuanDouble; + data.put("hejianjine",0); + data.put("jine",dangyuechengbaojin); + }*/ + + + + + + /* if (hejian_jie!=null && selectJiaShiYuanZahngHuYuEDouble == null && fukuanDouble !=null && typesString!= null && typesString.equals("付款") && typesString!= null){ + + data.put("leijiqianjiaojine",-fukuanDouble); + dangyuechengbaojin=zonge+hejian_jie-fukuanDouble; + + data.put("hejianjine",hejian_jie); + data.put("jine",dangyuechengbaojin); + + + + } else if (selectJiaShiYuanZahngHuYuEDouble == null && hejian_jie ==null && fukuanDouble !=null && typesString.equals("付款") && typesString!= null ){ + data.put("leijiqianjiaojine",-fukuanDouble); + dangyuechengbaojin=zonge-fukuanDouble; + data.put("hejianjine",0); + data.put("jine",dangyuechengbaojin); + }*/ + + + /* + 抵扣逻辑 + */ + + if (/*hejian_jie!=null &&*/ selectJiaShiYuanZahngHuYuEDouble != null){ + dikou = /*hejian_jie + */zonge; + + if (selectJiaShiYuanZahngHuYuEDouble >= dikou){ + data.put("bencidikoujine",dikou); + } + if (selectJiaShiYuanZahngHuYuEDouble < dikou){ + data.put("bencidikoujine",selectJiaShiYuanZahngHuYuEDouble); + } + + + } /*else if (*//*hejian_jie == null &&*//* selectJiaShiYuanZahngHuYuEDouble != null) { + dikou = zonge; + if (selectJiaShiYuanZahngHuYuEDouble >= dikou){ + data.put("bencidikoujine",dikou); + } + if (selectJiaShiYuanZahngHuYuEDouble < dikou){ + data.put("bencidikoujine",selectJiaShiYuanZahngHuYuEDouble); + } + + }*/ + + + if (fensifuzeren_no!=null){ + data.put("fensifuzeren",fensifuzeren_no); + } + if (guanlibumenfuzeren_no!=null){ + data.put("guanlibumenfuzeren",guanlibumenfuzeren_no); + } + data.put("type","收款"); + if (jiancheng!=null){ + data.put("jiancheng",jiancheng); + } + data.put("fukuanshiyou","费税收取"); + data.put("yinhangkahao",yinhangkahao); + data.put("yewubiaodanbianma","自动生成"); + data.put("yewubiaodanmingcheng","费税计划"); + data.put("sijixingming",jsonObject.getString("name")); + data.put("sijishenfenzhenghao",jsonObject.getString("id_card")); + data.put("sijisuozaigongsi",jsonObject.getString("gongsi")); + data.put("fensi",jsonObject.getString("fensi")); + data.put("haopaihaoma",jsonObject.getString("haopaihaoma")); + data.put("daikouyinhang",jsonObject.getString("daikouyinhang")); + data.put("yuefen",TimeUtil.getMonthDate(new Date())); + + + data.put("zhunyingzhenghaoma",zhunyingzhenghaoma); + data.put("guanlibumen",guanlibumen); + String timew = TimeUtil.timew(); + data.put("dangyueyuefen",timew); + + + jsonArray.add(data); + } +// yueFenJiSuanInfoDao.createLiuShuiYueFen(jsonArray,jdyConfig); + yueFenJiSuanInfoDao.createYinHangDaoChu(jsonArray,jdyConfig); + } +} diff --git a/src/main/java/com/example/sso/schedule/ScheduleCreateGongZi.java b/src/main/java/com/example/sso/schedule/ScheduleCreateGongZi.java new file mode 100644 index 0000000..2686ace --- /dev/null +++ b/src/main/java/com/example/sso/schedule/ScheduleCreateGongZi.java @@ -0,0 +1,253 @@ +/* +package com.example.sso.schedule; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.dao.GongZiDao; +import com.example.sso.dao.YueFenJiSuanInfoDao; +import com.example.sso.util.MathUtil; +import com.example.sso.util.TimeUtil; +import lombok.Getter; +import lombok.Setter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +@Component +public class ScheduleCreateGongZi { + Logger logger = LoggerFactory.getLogger(getClass()); + @Getter + @Setter + @Autowired + private JDYConfig jdyConfig; + @Scheduled(cron = "0 0 1 1 * ?")//每月25日触发 + //每月生成司机工资信息 + //银行划扣是次月1号 + public void createDriverGongZi() throws ParseException { + GongZiDao gongZiDao = new GongZiDao(); +// JSONObject shouYueSiJi = gongZiDao.selectShouYueSiJi(jdyConfig);//查询出首月缴纳的司机 + JSONObject siJiQian = gongZiDao.selectSiJiQian(jdyConfig);//查询出拖欠承包金的司机 忽略掉上月未缴纳的司机 + JSONArray persons = gongZiDao.selectGongBiaoZhun(jdyConfig); + List> jsonArray = new LinkedList<>(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM"); + for (Object map : persons) { + Map data = new JSONObject(); + JSONObject jsonObject = (JSONObject) map; + Date yingyundate = jsonObject.getDate("yingyunriqi");//获取营运日期 + if (!yingyundate.after(TimeUtil.getLastDay())){//营运日期大月上个月末最后一天的 不生成工资发放(确保只有上个月运营的驾驶员才发工资) + //if (jsonObject.getString("id_card").equals("130102197006011835")){ + JSONObject fensifuzeren=jsonObject.getJSONObject("fensifuzeren"); + if (fensifuzeren!=null){ + data.put("fensifuzeren", fensifuzeren.getInteger("dept_no")); + } + if (yingyundate != null) { + String yingyun_string = df.format(yingyundate); + String month_last = TimeUtil.getMonthDateLast(new Date()); + if (yingyun_string.equals(month_last)) {//是上月上车的司机 + Double zonge = 0.0; + String id_card = jsonObject.getString("id_card"); +// if (shouYueSiJi.getJSONObject(id_card) == null) { + int amount = TimeUtil.getAllMonthDays1(); + int dayOfMonth = TimeUtil.getRi(yingyundate)+1; + //过滤掉首月司机 + Double gangweibutie=0.0;Double ranliaobutie=0.0;Double linshibutie=0.0;Double zhengfubutie=0.0;Double qitabutie=0.0; + if (jsonObject.getDouble("gangweibutie")!=null){ + gangweibutie= MathUtil.formatDouble5(jsonObject.getDouble("gangweibutie") / amount * dayOfMonth); + } + if (jsonObject.getDouble("ranliaobutie")!=null){ + ranliaobutie = MathUtil.formatDouble5(jsonObject.getDouble("ranliaobutie") / amount * dayOfMonth); + } + if (jsonObject.getDouble("linshibutie")!=null){ + linshibutie = MathUtil.formatDouble5(jsonObject.getDouble("linshibutie") / amount * dayOfMonth); + } + if (jsonObject.getDouble("zhengfubutie")!=null){ + zhengfubutie= MathUtil.formatDouble5(jsonObject.getDouble("zhengfubutie") / amount * dayOfMonth); + } + if (jsonObject.getDouble("qitabutie")!=null){ + qitabutie = MathUtil.formatDouble5(jsonObject.getDouble("qitabutie") / amount * dayOfMonth); + } + zonge = zonge + gangweibutie; + zonge = zonge + ranliaobutie; + zonge = zonge + linshibutie; + zonge = zonge + zhengfubutie; + zonge = zonge + qitabutie; + data.put("type", "付款"); + data.put("jine", MathUtil.formatDouble5(zonge)); + data.put("haopaihaoma", jsonObject.getString("haopaihaoma")); + data.put("fukuanshiyou","工资补贴"); + data.put("yewubiaodanmingcheng", "驾驶员工资发放"); + data.put("yewubiaodanbianma", "自动生成"); + data.put("sijixingming", jsonObject.getString("name")); + data.put("sijishenfenzhenghao", jsonObject.getString("id_card")); + data.put("gongsi", jsonObject.getString("gongsi")); + data.put("fensi", jsonObject.getString("fensi")); + data.put("yuefen", TimeUtil.getMonthDateLast(new Date())); + data.put("gangweibutie", gangweibutie); + data.put("ranliaobutie", ranliaobutie); + data.put("linshibutie", linshibutie); + data.put("zhengfubutie", zhengfubutie); + data.put("qita", qitabutie); + data.put("yingyunriqi", yingyundate); + data.put("yinhangkahao", jsonObject.getString("yinhangkahao")); + //判断该司机是否拖欠承包金 + if (siJiQian != null) { + if (siJiQian.getJSONObject(id_card) != null) { + //拖欠承包金 + data.put("is_tuoqianchengbaojin", "是"); + data.put("status_yinhang", ""); + } else { + //不拖欠承包金 + data.put("is_tuoqianchengbaojin", "否"); + data.put("status_yinhang", ""); + } + jsonArray.add(data); + } else { + //拖欠承包金 + data.put("is_tuoqianchengbaojin", "是"); + data.put("status_yinhang", ""); + jsonArray.add(data); + } +// } +// System.out.println(""); + } else { + Double zonge = 0.0; + String id_card = jsonObject.getString("id_card"); +// if (shouYueSiJi.getJSONObject(id_card) == null) {//过滤掉首月司机 + Double gangweibutie = jsonObject.getDouble("gangweibutie"); + Double ranliaobutie = jsonObject.getDouble("ranliaobutie"); + Double linshibutie = jsonObject.getDouble("linshibutie"); + Double zhengfubutie = jsonObject.getDouble("zhengfubutie"); + Double qitabutie = jsonObject.getDouble("qitabutie"); + if (gangweibutie != null) { + zonge = zonge + gangweibutie; + } + if (ranliaobutie != null) { + zonge = zonge + ranliaobutie; + } + if (linshibutie != null) { + zonge = zonge + linshibutie; + } + if (zhengfubutie != null) { + zonge = zonge + zhengfubutie; + } + if (qitabutie != null) { + zonge = zonge + qitabutie; + } + data.put("type", "付款"); + data.put("jine", zonge); + data.put("haopaihaoma", jsonObject.getString("haopaihaoma")); + data.put("fukuanshiyou","工资补贴"); + data.put("yewubiaodanmingcheng", "驾驶员工资发放"); + data.put("yewubiaodanbianma", "自动生成"); + data.put("sijixingming", jsonObject.getString("name")); + data.put("sijishenfenzhenghao", jsonObject.getString("id_card")); + data.put("gongsi", jsonObject.getString("gongsi")); + data.put("fensi", jsonObject.getString("fensi")); + data.put("yuefen", TimeUtil.getMonthDateLast(new Date())); + data.put("gangweibutie", gangweibutie); + data.put("ranliaobutie", ranliaobutie); + data.put("linshibutie", linshibutie); + data.put("zhengfubutie", zhengfubutie); + data.put("qita", qitabutie); + data.put("yingyunriqi", yingyundate); + data.put("yinhangkahao", jsonObject.getString("yinhangkahao")); + //判断该司机是否拖欠承包金 + if (siJiQian != null) { + if (siJiQian.getJSONObject(id_card) != null) { + //拖欠承包金 + data.put("is_tuoqianchengbaojin", "是"); + data.put("status_yinhang", ""); + } else { + //不拖欠承包金 + data.put("is_tuoqianchengbaojin", "否"); + data.put("status_yinhang", ""); + } + jsonArray.add(data); + } else { + //拖欠承包金 + data.put("is_tuoqianchengbaojin", "是"); +// data.put("status_yinhang", ""); + jsonArray.add(data); + } +// } + } + } else { +// Double zonge = 0.0; +// String id_card = jsonObject.getString("id_card"); +//// if (shouYueSiJi.getJSONObject(id_card) == null) {//过滤掉首月司机 +// Double gangweibutie = jsonObject.getDouble("gangweibutie"); +// Double ranliaobutie = jsonObject.getDouble("ranliaobutie"); +// Double linshibutie = jsonObject.getDouble("linshibutie"); +// Double zhengfubutie = jsonObject.getDouble("zhengfubutie"); +// Double qitabutie = jsonObject.getDouble("qitabutie"); +// if (gangweibutie != null) { +// zonge = zonge + gangweibutie; +// } +// if (ranliaobutie != null) { +// zonge = zonge + ranliaobutie; +// } +// if (linshibutie != null) { +// zonge = zonge + linshibutie; +// } +// if (zhengfubutie != null) { +// zonge = zonge + zhengfubutie; +// } +// if (qitabutie != null) { +// zonge = zonge + qitabutie; +// } +// data.put("type", "付款"); +// data.put("jine", zonge); +// data.put("haopaihaoma", jsonObject.getString("haopaihaoma")); +// data.put("fukuanshiyou","工资补贴"); +// data.put("yewubiaodanmingcheng", "驾驶员工资发放"); +// data.put("yewubiaodanbianma", "自动生成"); +// data.put("sijixingming", jsonObject.getString("name")); +// data.put("sijishenfenzhenghao", jsonObject.getString("id_card")); +// data.put("gongsi", jsonObject.getString("gongsi")); +// data.put("fensi", jsonObject.getString("fensi")); +// data.put("yuefen", TimeUtil.getMonthDateLast(new Date())); +// data.put("gangweibutie", gangweibutie); +// data.put("ranliaobutie", ranliaobutie); +// data.put("linshibutie", linshibutie); +// data.put("zhengfubutie", zhengfubutie); +// data.put("qita", qitabutie); +// data.put("yingyunriqi", yingyundate); +// data.put("yinhangkahao", jsonObject.getString("yinhangkahao")); +// //判断该司机是否拖欠承包金 +// if (siJiQian != null) { +// if (siJiQian.getJSONObject(id_card) != null) { +// //拖欠承包金 +// data.put("is_tuoqianchengbaojin", "是"); +// data.put("status_yinhang", ""); +// } else { +// //不拖欠承包金 +// data.put("is_tuoqianchengbaojin", "否"); +// data.put("status_yinhang", ""); +// } +// jsonArray.add(data); +// } else { +// //拖欠承包金 +// data.put("is_tuoqianchengbaojin", "是"); +// data.put("status_yinhang", ""); +// jsonArray.add(data); +// } +// } + } +// } + } + } + //处理首月的数据 + gongZiDao.createLiuShuiYueFen(jsonArray, jdyConfig); + } +} +*/ diff --git a/src/main/java/com/example/sso/service/SSOService.java b/src/main/java/com/example/sso/service/SSOService.java new file mode 100644 index 0000000..70b2470 --- /dev/null +++ b/src/main/java/com/example/sso/service/SSOService.java @@ -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 javax.servlet.http.HttpSession; +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, HttpSession httpSession) { + Algorithm algorithm = Algorithm.HMAC256((String) httpSession.getAttribute("sso_secret")); + 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); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/sso/service/YueFenJiSuanService.java b/src/main/java/com/example/sso/service/YueFenJiSuanService.java new file mode 100644 index 0000000..286b9ab --- /dev/null +++ b/src/main/java/com/example/sso/service/YueFenJiSuanService.java @@ -0,0 +1,5 @@ +package com.example.sso.service; + +public class YueFenJiSuanService { + +} diff --git a/src/main/java/com/example/sso/util/APIUtils.java b/src/main/java/com/example/sso/util/APIUtils.java new file mode 100644 index 0000000..c49130f --- /dev/null +++ b/src/main/java/com/example/sso/util/APIUtils.java @@ -0,0 +1,559 @@ +package com.example.sso.util; + +import com.alibaba.fastjson.JSONArray; +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.*; + +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 String urlDataBatchCreate; + private String urlGetWorkflow; + + private static String apiKey; + private static int i=1; + /** + * @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 createPerson (Map person) { + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",urlCreatePerson, person); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + public Map createDep (Map person) { + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",urlCreatePerson, person); + data = (Map) 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/v2/app/" + appId + "/entry/" + entryId + "/data_retrieve"; + urlUpdateData = WEBSITE + "/api/v4/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"; + urlDataBatchCreate=WEBSITE+ "/api/v1/app/" + appId + "/entry/" + entryId + "/data_batch_create"; + urlGetWorkflow=WEBSITE+"/api/v3/workflow/instance/get"; + } + + 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 deletePeopleBatch(Map map) { + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",urlDeletePeople, map); + return result; +// data = (Map) result.get("department"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + public Map urlGetWorkflow(String id) { + Map map=new HashMap<>(); + map.put("instance_id",id); + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",urlGetWorkflow,map); + System.out.println(result); + return result; +// data = (Map) result.get("department"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + /** + * 获取请求头信息 + * @return + */ + public static Header[] getHttpHeaders() { + List
headerList = new ArrayList
(); + 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 findPerson (String username) { + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",WEBSITE + "/api/v2/user/"+username+"/user_retrieve", new HashMap<>()); + data = (Map) 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 data) throws Exception { + try { + 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 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 result = (Map) 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; + } + }catch (Exception e){ + e.printStackTrace(); + // 请求异常,等等重试 + Thread.sleep(1000); + if (i>=5){ + i=0; + return 555; + }else { + i=i+1; + return sendRequest(method, url, data); + } + } + } + + + + + /** + * 获取表单字段 + * @return 表单字段 + */ + public List> getFormWidgets () { + List> widgets = null; + try { + Map result = (Map) this.sendRequest("POST", urlGetWidgets, new HashMap()); + widgets = (List>) result.get("widgets"); + } catch (Exception e) { + e.printStackTrace(); + } + return widgets; + } + + + + public List> createUser(String username, String name, Integer[] departments){ + Map data = null; + try { + Map requestData = new HashMap(); + requestData.put("username",username); + requestData.put("name",name); + requestData.put("departments",departments); + Map result = (Map) this.sendRequest("POST",urlCreateUSer, requestData); + data = (Map) result.get("data"); + }catch (Exception e) { + e.printStackTrace(); + } + return (List>) data; + } + /** + * 按条件获取表单数据 + * @param limit - 数据条数 + * @param fields - 显示的字段 + * @param filter - 过滤条件 + * @param dataId - 上次取数的最后一个数据id + * @return - 返回的数据 + */ + public List> getFormData (final int limit, final String[] fields, final Map filter, String dataId) { + List> data = null; + try { + // 构造请求数据 + Map requestData = new HashMap() { + { + put("limit", limit); + put("fields", fields); + put("filter", filter); + } + }; + if (dataId != null) { + requestData.put("data_id", dataId); + } + Thread.sleep(1000); + Map result = (Map) this.sendRequest("POST", urlGetFormData, requestData); + data = (List>) result.get("data"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + /** + * 按条件获取全部表单数据 + * @return 表单数据 + */ + public List> getAllFormData (String[] fields, Map filter) { + List> dataList = new ArrayList>(); + String offset = null; + do { + List> 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 retrieveData (String dataId) { + Map data = null; + try { + Map requestData = new HashMap(); + requestData.put("data_id", dataId); + Map result = (Map) this.sendRequest("POST", urlRetrieveData, requestData); + data = (Map) result.get("data"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + /** + * 新增部门 + * @param - 创建数据内容 + * @return 更新后的数据 + */ + public Map createDataDep (Map requestData) { + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",urlCreateDep, requestData); +// data = (Map) result.get("department"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + + + /** + * 批量创建部门 + * @param - 创建数据内容 + * @return 更新后的数据 + */ + public Map createDataDepAll (Map requestData) { + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",urlCreateDepAll, requestData); +// data = (Map) result.get("department"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + + /** + * 批量创建人员 + * @param - 创建数据内容 + * @return 更新后的数据 + */ + public Map createDataPersonAll (Map requestData) { + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",urlCreatePersonAll, requestData); + System.out.println(result); + return result; +// data = (Map) result.get("department"); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 获取部门信息 + * @param - 创建数据内容 + * @return 更新后的数据 + */ + public Map getDepartment() { + Map map=new HashMap<>(); + map.put("has_child",1); + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",urlGetDepartment,map); + System.out.println(result); + return result; +// data = (Map) result.get("department"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + + /** + * 获取部门成员信息 + * @param - 创建数据内容 + * @return 更新后的数据 + */ + public Map getDepartmentPerson(String dno) { + Map map=new HashMap<>(); +// map.put("has_child",1); + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",WEBSITE+"/api/v2/department/"+dno+"/member_list",map); + return result; +// data = (Map) result.get("department"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + public Map deleteDepartment(Integer no) { + Map map=new HashMap<>(); + map.put("has_child",1); + Map data = null; + try { + Map result = (Map) this.sendRequest("POST",WEBSITE+"/api/v2/department/"+no+"/delete",new HashMap<>()); + System.out.println(result); + return result; +// data = (Map) result.get("department"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + + +// /** +// * 新增部门 +// * @param - 创建数据内容 +// * @return 更新后的数据 +// */ +// public Map createDataDep (Map requestData) { +// Map data = null; +// try { +// Map result = (Map) this.sendRequest("POST",urlCreateDep, requestData); +// data = (Map) result.get("data"); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return data; +// } + + + /** + * 创建单条数据 + * @param rawData - 创建数据内容 + * @return 更新后的数据 + */ + public Map createData (Map rawData) { + Map data = null; + try { + Map requestData = new HashMap(); + requestData.put("data", rawData); + requestData.put("is_start_trigger",true); + requestData.put("is_start_workflow",true); + Map result = (Map) this.sendRequest("POST",urlCreateData, requestData); + data = (Map) result.get("data"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + + + /** + * 获取所有的人在简道云 + * @return 更新后的数据 + */ + public List> getAllPeople () { + List> data = null; + try { + Map requestData = new HashMap(); + requestData.put("has_child",true); +// System.out.println("准备发起HTTP请求!"+urlGetPeople); + Map result = (Map) this.sendRequest("POST",urlGetPeople, requestData); + data = (List>) result.get("users"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + /** + * 更新单条数据 + * @return 更新结果 + */ + public Map updateData (String dataId, Map update) { + Map data = null; + try { + Map requestData = new HashMap(); + requestData.put("data_id", dataId); + requestData.put("data", update); + requestData.put("is_start_trigger",true); + Map result = (Map) this.sendRequest("POST", urlUpdateData, requestData); + data = (Map) result.get("data"); + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + /** + * 删除单条数据 + * @return 删除结果 + */ + public Map deleteData (String dataId) { + Map result = null; + try { + Map requestData = new HashMap(); + requestData.put("data_id", dataId); + result = (Map) this.sendRequest("POST", urlDeleteData, requestData); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + /** + * 批量新增数据 + * @return 新增结果 + */ + public Map dataBatchCreate (JSONArray data_list,Boolean is_start_workflow) { + Map result = null; + try { + UUID uuid = UUID.randomUUID(); + Map requestData = new HashMap(); + requestData.put("transaction_id", uuid.toString()); + requestData.put("data_list", data_list); + requestData.put("is_start_workflow", is_start_workflow); + result = (Map) this.sendRequest("POST", urlDataBatchCreate, requestData); + System.out.println(result); + result.put("transaction_id",uuid.toString()); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + +} \ No newline at end of file diff --git a/src/main/java/com/example/sso/util/DataBatchUtil.java b/src/main/java/com/example/sso/util/DataBatchUtil.java new file mode 100644 index 0000000..53e3af0 --- /dev/null +++ b/src/main/java/com/example/sso/util/DataBatchUtil.java @@ -0,0 +1,42 @@ +package com.example.sso.util; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DataBatchUtil { + /** + * 批量新增数据 + * @param appId 应用ID + * @param entryId 表单ID + * @param apiKey 秘钥 + * @param datas 原始数据源 + * @param fields 简道云字段别名 + * @param fields_data data里面的字段值key,需要与fields一一对应起来。 + */ + public static Map dataBatchCreate(String appId, String entryId, String apiKey, JSONArray datas, JSONArray fields, JSONArray fields_data){ + try { + APIUtils apiUtils=new APIUtils(appId,entryId,apiKey); + JSONArray data_list=new JSONArray();//封装修饰好的数据 + for (Object o1:datas){ + JSONObject o=(JSONObject)o1; + Map map1=new HashMap(){ + { + for (int i=0;i() {{ put("value",o.get(fields_data.getString(finalI)));}}); + } + } + }; + data_list.add(map1); + } + return apiUtils.dataBatchCreate(data_list,false); + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/main/java/com/example/sso/util/HttpUtil.java b/src/main/java/com/example/sso/util/HttpUtil.java new file mode 100644 index 0000000..c1178e3 --- /dev/null +++ b/src/main/java/com/example/sso/util/HttpUtil.java @@ -0,0 +1,216 @@ +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) throws KeyManagementException, NoSuchAlgorithmException { + SSLContext sslcontext = createIgnoreVerifySSL(); + + // 设置协议http和https对应的处理socket链接工厂的对象 + Registry socketFactoryRegistry = RegistryBuilder.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); + 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请求,参数为map * * @param url * 请求地址 * @param map * 请求参数 * @return 返回字符串 */ + public static String sendPost(String url, Map map) { + // 设置参数 + List formparams = new ArrayList(); + for (Map.Entry 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,String appkey) throws KeyManagementException, NoSuchAlgorithmException { + //采用绕过验证的方式处理https请求 + SSLContext sslcontext = createIgnoreVerifySSL(); + + // 设置协议http和https对应的处理socket链接工厂的对象 + Registry socketFactoryRegistry = RegistryBuilder.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 "+appkey); + // 接收参数设置 + 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) { + response.getEntity() ; + log.error(e.getMessage()); + } + } + } + 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; + } +} diff --git a/src/main/java/com/example/sso/util/MathUtil.java b/src/main/java/com/example/sso/util/MathUtil.java new file mode 100644 index 0000000..7c7ff77 --- /dev/null +++ b/src/main/java/com/example/sso/util/MathUtil.java @@ -0,0 +1,31 @@ +package com.example.sso.util; + +import java.text.DecimalFormat; + +public class MathUtil { + + public static void main(String[] args) { + System.out.println(Double.valueOf(formatDouble5(111.159099))); + } + + /** + * 保留两位小数,四舍五入的一个老土的方法 + * @param d + * @return + */ + public static double formatDouble1(double d) { + return (double)Math.round(d*100)/100; + } + + + /** + * 如果只是用于程序中的格式化数值然后输出,那么这个方法还是挺方便的。 + * 应该是这样使用:System.out.println(String.format("%.2f", d)); + * @param d + * @return + */ + public static Double formatDouble5(double d) { + return Double.valueOf(String.format("%.2f", d)); + } + +} diff --git a/src/main/java/com/example/sso/util/StringUtil.java b/src/main/java/com/example/sso/util/StringUtil.java new file mode 100644 index 0000000..7a83e68 --- /dev/null +++ b/src/main/java/com/example/sso/util/StringUtil.java @@ -0,0 +1,19 @@ +package com.example.sso.util; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class StringUtil { + /** + * 判断是否包含特殊字段 + * + * @param username + * @return + */ + public static Boolean isContainSpecialChar(String username) { + String regEx = "^[0-9a-zA-Z_]{1,}$"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(username); + return m.find(); + } +} diff --git a/src/main/java/com/example/sso/util/Test.java b/src/main/java/com/example/sso/util/Test.java new file mode 100644 index 0000000..26a9053 --- /dev/null +++ b/src/main/java/com/example/sso/util/Test.java @@ -0,0 +1,118 @@ +package com.example.sso.util; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.example.sso.config.JDYConfig; +import com.example.sso.dao.GongZiDao; +import com.example.sso.dao.YinHangHuaKouDao; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Test { + public static void main(String[] args) { + selectGongBiaoZhun(); + } + + + + public static JSONArray selectGongBiaoZhun() { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f0f3754af59a0007691522","AXtEol6d7l0w2l5dUuqvhbg2kjzfYv6r"); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(""); + condList.add(new HashMap() { + { + put("field", "chufa");//查新字段的名称/别名 + put("method", "empty");//判断的方法 +// put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"chufa"},//身份证,公司,姓名,岗位补贴,燃油补贴,临时补贴,其他补贴 + filter, null); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + for (Map map:datas){ + String id=(String)map.get("_id"); + updateFlowId(id); + } + return null; + } + + /** + * 更新客户报备数据 + * @throws Exception + */ + public static void updateFlowId(String id) { + try { + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62f0f3754af59a0007691522","AXtEol6d7l0w2l5dUuqvhbg2kjzfYv6r"); + Map map1; + map1=new HashMap(){ + { + put("chufa",new HashMap() {{ put("value","1");}}); + } + }; + //把封装好的数据创建至简道云 + api.updateData(id,map1); + }catch (Exception e){ + e.printStackTrace(); + } + } + + + public static JSONObject selectGongBiao() { + //需要修改 appid entryid apikey + APIUtils api = new APIUtils("628eeaace7f28c00089a60cc","62ef5405e022900008e9c7b5","AXtEol6d7l0w2l5dUuqvhbg2kjzfYv6r"); + final List> condList = new ArrayList>(); + //因为想查询大于50的数据,所以创建一个数组 + JSONArray jsonArray = new JSONArray(); + //在这个数组里面放一个数值类型的数字,用来判断查询范围 + jsonArray.add(""); + condList.add(new HashMap() { + { + put("field", "fensi");//查新字段的名称/别名 + put("method", "not_empty");//判断的方法 +// put("value", jsonArray);//查询的条件 + } + }); + Map filter = new HashMap() { + { + put("rel", "and"); + put("cond", condList); + } + }; + //字段别名 + List> datas = api.getFormData(10000, new String[]{"id_card","gongsi","name","gangweibutie","ranliaobutie", + "linshibutie","zhengfubutie","fensi","haopaihaoma","qita"},//身份证,公司,姓名,岗位补贴,燃油补贴,临时补贴,其他补贴 + filter, null); + if (datas == null) { + return null; + } + if (datas.size() == 0) { + return null; + } + JSONObject jsonObject=new JSONObject(); + for (Map map:datas){ + String id=(String)map.get("id_card"); + String fensi=(String)map.get("fensi"); + jsonObject.put(id,fensi); + } + return jsonObject; + } +} diff --git a/src/main/java/com/example/sso/util/TimeUtil.java b/src/main/java/com/example/sso/util/TimeUtil.java new file mode 100644 index 0000000..c63f9dd --- /dev/null +++ b/src/main/java/com/example/sso/util/TimeUtil.java @@ -0,0 +1,183 @@ +package com.example.sso.util; + +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +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 ""; + } + + + + /** + * 获取startDate日期后month月的日期 + * @param startDate 开始日期 + * @return + */ + public static String getMonthDate(Date startDate){ + LocalDateTime localDateTime = startDate.toInstant() + .atZone(ZoneId.systemDefault() ) + .toLocalDateTime().plusMonths(1); + Date date = Date.from(localDateTime.atZone( ZoneId.systemDefault()).toInstant()); + SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM"); + return dateFormat.format(date); + } + + + public static int getAllMonthDays() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + int amount=calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + return amount; + } + public static int getAllMonthDays1() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(getLastMonth1()); + int amount=calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + return amount; + } + + public static int getRi(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + int yunyun=calendar.get(Calendar.DAY_OF_MONTH);//营运日期日子 + int zonge=getAllMonthDays1(); + return zonge-yunyun; + } + public static int getDaysOfMonth() { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + Integer dayOfMonth = Calendar.getInstance().get(Calendar.DAY_OF_MONTH); + int amount=calendar.getActualMaximum(Calendar.DAY_OF_MONTH); +// System.out.println("今天是"+dayOfMonth+"号"); + return amount-dayOfMonth; + } + + /** + * 获取startDate日期后month月的日期 + * @param startDate 开始日期 + * @return + */ + public static String getMonthDateLast(Date startDate){ + LocalDateTime localDateTime = startDate.toInstant() + .atZone(ZoneId.systemDefault() ) + .toLocalDateTime().plusMonths(-1); + Date date = Date.from(localDateTime.atZone( ZoneId.systemDefault()).toInstant()); + SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM"); + return dateFormat.format(date); + } + /** + * 由于时区的原因,调整时区 + * @return + */ + public static String timeConversion_90(){ + 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 { + Calendar calendar=Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.DAY_OF_MONTH, 90);// before 8 hour + return df.format(calendar.getTime()); + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } + + + + + public static void main(String[] args) { +// System.out.println(getDaysOfMonth(new Date())); + } + /** + * 获取上月日期数据 + * @return + */ + public static String getLastMonth(){ + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + // 设置为当前时间 + calendar.setTime(date); + calendar.add(Calendar.MONTH,-1); + // 设置为上一个月 + //calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); + date = calendar.getTime(); + return format.format(date); + } + /** + * 获取上月日期数据 + * @return + */ + public static Date getLastDay() throws ParseException { + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + // 设置为当前时间 + calendar.setTime(date); + calendar.add(Calendar.DAY_OF_MONTH,-1); + // 设置为上一个月 + //calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); + date = calendar.getTime(); + SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd"); + return dateFormat.parse(dateFormat.format(date)); + } + /** + * 获取上月日期数据 + * @return + */ + public static Date getLastMonth1(){ + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + // 设置为当前时间 + calendar.setTime(date); + calendar.add(Calendar.MONTH,-1); + // 设置为上一个月 + //calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); + date = calendar.getTime(); + return date; + } + + /* + 获取当前时间文本 + */ + public static String timew(){ + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + + // 定义日期格式化模式 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + + // 将日期格式化为指定格式的文本 + String formattedDate = currentDate.format(formatter); + + return formattedDate; + } + +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..f2f037f --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,11 @@ +sso: + acs: https://www.jiandaoyun.com/sso/custom/59bb7045f3b3ab31f241bbf1/acs + +server: + port: 8083 +jdy: + appkey: BkIyzlh1onqnqu9cQ3ralDQBjECn97ex + appid: 61bae73aebe2f500080d567b + formid: 61bae7bc5aa1e60008dbd378 # + formid_account: 11 # +#测试环境 diff --git a/src/test/java/com/example/sso/SsoApplicationTests.java b/src/test/java/com/example/sso/SsoApplicationTests.java new file mode 100644 index 0000000..1a3000a --- /dev/null +++ b/src/test/java/com/example/sso/SsoApplicationTests.java @@ -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); + } + +}