Commit 90e73bdd authored by tank.li@mushiny.com's avatar tank.li@mushiny.com

init

parent d0a374b5
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/
#!/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 "$@"
@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%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.mushiny.heli.xnr</groupId>
<artifactId>xnr-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>xnr-interface</name>
<description>xnr-interface</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.33</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.0.9.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.mushiny.heli.xnr;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class XnrInterfaceApplication {
public static void main(String[] args) {
SpringApplication.run(XnrInterfaceApplication.class, args);
}
}
package com.mushiny.heli.xnr.beans;
/**
* Created by Tank.li on 2017/10/17.
*/
public class BaseBpo extends BaseObject {
//操作类型 TODO
public static final int INSERT = 1;
public static final int UPDATE = 2;
public static final int DELETE = 3;
private int operType = INSERT;
public int getOperType() {
return operType;
}
public void setOperType(int operType) {
this.operType = operType;
}
private Object Id;
private String table;
private String idName;
@Override
public Object getId() {
return Id;
}
public void setId(Object id) {
Id = id;
}
@Override
public String getTable() {
return table;
}
public void setTable(String table) {
this.table = table;
}
@Override
public String getIdName() {
return idName;
}
public void setIdName(String idName) {
this.idName = idName;
}
}
package com.mushiny.heli.xnr.beans;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Tank.li on 2017/7/25.
*/
public abstract class BaseObject implements java.io.Serializable{
private String activeThread;//activeThread
public String getActiveThread() {
return activeThread;
}
public void setActiveThread(String activeThread) {
this.activeThread = activeThread;
}
private Map<String,Object> kv = new HashMap<>();
private Map<String,Object> con;
private Map<String,Object> delCon;//删除条件
public Map<String, Object> getDelCon() {
return delCon;
}
public void setDelCon(Map<String, Object> delCon) {
this.delCon = delCon;
}
public Map<String, Object> getCon() {
return con;
}
public void setCon(Map<String, Object> con) {
this.con = con;
}
public Map getNewValue(){
return kv;
}
public Map<String, Object> getKv() {
return kv;
}
public void setKv(Map<String, Object> kv) {
this.kv = kv;
}
/**
* 做多次操作
* @param key
* @param value
* @return
*/
public BaseObject addKV(String key, Object value){
kv.put(key,value);
return this;
}
public void clearKV(){
kv.clear();
}
public abstract Object getId();
public abstract String getTable();
public abstract String getIdName();
}
package com.mushiny.heli.xnr.comm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* Created by Tank.li on 2017/6/25.
*/
public class CommonUtils {
private final static Logger logger = LoggerFactory.getLogger(CommonUtils.class);
public static String face2WorkStation(int podFace, int wsFace){
//现在工作站的朝向相当于POD的面
int[] fourFace = {podFace,(podFace+270)%360,(podFace+180)%360,(podFace+90)%360};
int index = 0;
for (int i = 0; i < fourFace.length; i++) {
int face = fourFace[i];
if(wsFace == face){
index = i;
break;
}
}
index = (index+2)%4;
return "ABCD".charAt(index)+"";
}
/**
* 按格式转换时间
* @param format
* @return
*/
public static String now2String(String format){
LocalDateTime localDateTime = LocalDateTime.now();
//yyyyMMddHHmmss
DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
//System.out.println(df.format(localDateTime));
return df.format(localDateTime);
}
/**
* 把日期类型格式化成字符串
* @param date
* @param format
* @return
*/
public static String convert2String(Date date, String format) {
SimpleDateFormat formater = new SimpleDateFormat(format);
try {
return formater.format(date);
} catch (Exception e) {
return null;
}
}
public static String genUUID(){
return UUID.randomUUID().toString();
}
public static void main(String[] args) {
/* System.out.println(now2String("yyyyMMddHHmmss"));
System.out.println(genUUID());*/
/*System.out.println(aFaceToward(0,0,"A"));
System.out.println(aFaceToward(0,0,"B"));
System.out.println(aFaceToward(0,0,"C"));
System.out.println(aFaceToward(0,0,"D"));*/
Random random = new Random();
int i = 0;
/*while (i<1000) {
System.out.println(random.nextInt(100));
i++;
}*/
Long ss = Long.parseLong("0");
System.out.println(ss==0);
Integer podDirect = 0;
Integer rotate = 270;
//找到当前面对货架的
String currentFace = CommonUtils.face2WorkStation(podDirect,0);
System.out.println("面对工作站的角度是:"+currentFace);
int times = rotate/90 + "ABCD".indexOf(currentFace);
String newFace = String.valueOf("ABCD".charAt(times%4));
System.out.println("新的旋转需要的面是:"+newFace);
Map data = new HashMap();
for (int j = 0; j < 1100; j++) {
data.put(CommonUtils.int2Long(j),"123");
}
System.out.println(data.size());
/* Map addr = new HashMap();
addr.put("ADDRESSID","111");*/
//Address address = (Address) map2Bean(Address.class,addr);
//System.out.println(aFaceToward(90,0,"D"));
/* System.out.println(convert2String(new Date(System.currentTimeMillis()),"YYYY-MM-dd HH:mm:ss"));
String ss = loadFromFile("lisi.txt");//"Kleannara/可绿纳乐-\"天然纯棉系列\"天然卫生巾(日用加长)260mm *16片";
System.out.println(ss);
ss = ss.replaceAll("\"","\\\\\\\"");
System.out.println(ss);*/
}
private static String loadFromFile(String s) {
InputStream inputStream = CommonUtils.class.getResourceAsStream("/lisi.txt");
Reader reader = new InputStreamReader(inputStream);
int tempchar;
StringBuffer sb = new StringBuffer();
try {
while ((tempchar = reader.read()) != -1) {
// 对于windows下,\r\n这两个字符在一起时,表示一个换行。
// 但如果这两个字符分开显示时,会换两次行。
// 因此,屏蔽掉\r,或者屏蔽\n。否则,将会多出很多空行。
if (((char) tempchar) != '\r') {
sb.append((char) tempchar);
}
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
//System.out.println(sb.toString());
return sb.toString();
}
/**
* 行数据转换成对象 TODO 用javaassist
* @param tClass
* @param data
* @return
*/
public static Object map2Bean(Class tClass, Map data){
Object instance = null;
try {
instance = tClass.newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
Field[] fields = tClass.getDeclaredFields();
Map<String,Method> methodNames = new HashMap();
Method[] methods = tClass.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
methodNames.put(method.getName().toUpperCase(),method);
}
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
String fieldName = field.getName();
//包含get/set方法
if(methodNames.get("GET"+fieldName.toUpperCase())!=null
&& methodNames.get("SET"+fieldName.toUpperCase())!=null
&& data.get(fieldName.toUpperCase())!=null){
Method methodSet = methodNames.get("SET"+fieldName.toUpperCase());//获取set方法
try {
methodSet.invoke(instance, data.get(fieldName.toUpperCase()));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}
return instance;
}
/**
* 对象转数组
* @param obj
* @return
*/
public static byte[] toByteArray (Object obj) {
byte[] bytes = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
bytes = bos.toByteArray ();
oos.close();
bos.close();
} catch (IOException ex) {
ex.printStackTrace();
}
return bytes;
}
/**
* 数组转对象
* @param bytes
* @return
*/
public static Object toObject (byte[] bytes) {
Object obj = null;
try {
ByteArrayInputStream bis = new ByteArrayInputStream (bytes);
ObjectInputStream ois = new ObjectInputStream (bis);
obj = ois.readObject();
ois.close();
bis.close();
} catch (IOException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
return obj;
}
public static void genUselessInfo(Map record) {
//record.put("ID",genUUID());
record.putIfAbsent("CREATED_DATE",new Timestamp(System.currentTimeMillis()));
record.putIfAbsent("CREATED_BY","SYSTEM");
/*record.put("CLIENT_ID","SYSTEM");*/
//record.putIfAbsent("WAREHOUSE_ID", "DEFAULT");
record.put("ENTITY_LOCK",0);
record.put("VERSION",0);
}
public static void modifyUselessInfo(Map record) {
record.put("MODIFIED_BY","SYSTEM");
record.put("MODIFIED_DATE",new Timestamp(System.currentTimeMillis()));
}
public static Long parseLong(String key, Map data) {
Object value = data.get(key);
if(value == null){
return 0l;
}
return Long.parseLong(""+data.get(key));
}
public static Integer parseInteger(String key, Map data) {
Object value = data.get(key);
if(value == null){
return 0;
}
return (new Double(value+"")).intValue();
}
public static String parseString(String key, Map data) {
Object value = data.get(key);
if(value == null){
return null;
}
return value.toString();
}
public static double parseDouble(String key, Map data) {
Object value = data.get(key);
if(value == null){
return 0.0;
}
return Double.parseDouble(value.toString()+"");
}
public static boolean parseBoolean(String key, Map map) {
Object value = map.get(key);
if(value == null){
return false;
}
if(value.toString().equals("1")){
return true;
}
return Boolean.parseBoolean(value.toString()+"");
}
public static boolean isEmpty(String str) {
return str == null || "".equals(str);
}
public static short parseShort(String key, Map data) {
Object value = data.get(key);
if(value == null){
return 0;
}
return (new Double(value+"")).shortValue();
}
public static Integer long2Int(Long srcAddr) {
return (new Double(srcAddr+"")).intValue();
}
public static void sleep(long time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static String formatDate(Date date) {
return CommonUtils.convert2String(date,"YYYY-MM-dd HH:mm:ss");
}
public static Long asLong(String str) {
if(str == null){
return 0L;
}
return Long.parseLong("" + str);
}
public static Long int2Long(int i) {
return Long.parseLong(i+"");
}
}
package com.mushiny.heli.xnr.comm;
/**
* Created by Tank.li on 2017/7/27.
*/
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.JavaType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class JsonUtils {
private static ObjectMapper objectMapper = new ObjectMapper();
public static <T> String bean2Json(T bean) {
try {
return objectMapper.writeValueAsString(bean);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static String map2Json(Map map) {
try {
return objectMapper.writeValueAsString(map);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static String list2Json(List list) {
try {
return objectMapper.writeValueAsString(list);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static <T> T json2Bean(String json, Class<T> beanClass) {
try {
return objectMapper.readValue(json, beanClass);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static <T> List<T> json2List(String json, Class<T> beanClass) {
if(CommonUtils.isEmpty(json)){
return new ArrayList<>();
}
try {
return (List<T>) objectMapper.readValue(json, getCollectionType(List.class, beanClass));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static Map json2Map(String json) {
if(CommonUtils.isEmpty(json)){
return new HashMap();
}
try {
return (Map) objectMapper.readValue(json, Map.class);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static JavaType getCollectionType(Class<?> collectionClass, Class<?>... elementClasses) {
return objectMapper.getTypeFactory().constructParametricType(collectionClass, elementClasses);
}
}
package com.mushiny.heli.xnr.comm;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if(SpringUtil.applicationContext == null) {
SpringUtil.applicationContext = applicationContext;
}
System.out.println("ApplicationContext配置成功,在普通类可以通过调用SpringUtils.getAppContext()获取applicationContext对象,applicationContext="+SpringUtil.applicationContext+"========");
}
//获取applicationContext
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
//通过name获取 Bean.
public static Object getBean(String name){
return getApplicationContext().getBean(name);
}
//通过class获取Bean.
public static <T> T getBean(Class<T> clazz){
return getApplicationContext().getBean(clazz);
}
//通过name,以及Clazz返回指定的Bean
public static <T> T getBean(String name,Class<T> clazz){
return getApplicationContext().getBean(name, clazz);
}
}
package com.mushiny.heli.xnr.controller;
import com.mushiny.heli.xnr.comm.CommonUtils;
import com.mushiny.heli.xnr.comm.JsonUtils;
import com.mushiny.heli.xnr.dto.MessageDTO;
import com.mushiny.heli.xnr.service.InboundService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* Created by Lisi on 2019-11-27.
*/
@RestController
@RequestMapping("/inbound")
public class InboundController {
private final static Logger logger = LoggerFactory.getLogger(InboundController.class);
@Autowired
private InboundService inboundService;
@PostMapping(value = "/store", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> store(
@RequestBody String json){
Map data = JsonUtils.json2Map(json);
int stored = CommonUtils.parseInteger("stored",data);
String skuId = CommonUtils.parseString("skuId",data);
String factory = CommonUtils.parseString("factory",data);
String section = CommonUtils.parseString("section",data);
String entryId = CommonUtils.parseString("entryId",data);
//货架的货位
String containerId = CommonUtils.parseString("containerId",data);
MessageDTO dto = this.inboundService.store(skuId,stored,containerId,factory,section,entryId);
return ResponseEntity.ok(dto);
}
/**
* @param json
* @return
*/
@PostMapping(value = "/searchInbound", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> searchInbound(
@RequestBody String json){
Map reqData = JsonUtils.json2Map(json);
String entryId = CommonUtils.parseString("entryId",reqData);
String warehouseId = CommonUtils.parseString("factory",reqData);
String sectionId = CommonUtils.parseString("section",reqData);
List<Map> data = this.inboundService.searchInbound(entryId,warehouseId,sectionId);
return ResponseEntity.ok(JsonUtils.list2Json(data));
}
/**
* @param json
* @return
*/
@PostMapping(value = "/searchInboundInfo", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> searchInboundInfo(
@RequestBody String json){
Map reqData = JsonUtils.json2Map(json);
String entryId = CommonUtils.parseString("entryId",reqData);
Map data = this.inboundService.searchInboundInfo(entryId);
return ResponseEntity.ok(JsonUtils.map2Json(data));
}
/**
* @param json
* @return
*/
@PostMapping(value = "/orderFinish", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> orderFinish(
@RequestBody String json){
Map reqData = JsonUtils.json2Map(json);
String entryId = CommonUtils.parseString("entryId",reqData);
MessageDTO dto = this.inboundService.orderFinish(entryId);
return ResponseEntity.ok(dto);
}
/**
* @param json
* @return
*/
@PostMapping(value = "/skuNotFound", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> skuNotFound(
@RequestBody String json){
Map reqData = JsonUtils.json2Map(json);
String entryId = CommonUtils.parseString("entryId",reqData);
String skuId = CommonUtils.parseString("entryId",reqData);
MessageDTO dto = this.inboundService.skuNotFound(entryId,skuId);
return ResponseEntity.ok(dto);
}
/**
* 启动上架入库单
* @param json
* @return
*/
@PostMapping(value = "/startInbound", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> startInbound(
@RequestBody String json){
Map station = JsonUtils.json2Map(json);
List entryIds = (List) station.get("entryIds");
String stationName = (String) station.get("stationName");
MessageDTO dto = this.inboundService.startInbound(entryIds, stationName);
return ResponseEntity.ok(dto);
}
/**
* 退出上架 如果stowpod任务还在 就提示并强制退出
* @param json
* @return
*/
@PostMapping(value = "/endInbound", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> endInbound(
@RequestBody String json){
Map station = JsonUtils.json2Map(json);
MessageDTO dto = this.inboundService.endInbound(CommonUtils.parseString("stationName",station));
return ResponseEntity.ok(dto);
}
/**
* 当前任务
* @param json
* @return
*/
@PostMapping(value = "/currentPodTask", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> currentPodTask(
@RequestBody String json){
Map station = JsonUtils.json2Map(json);
//工作站号码
Map dto = this.inboundService.currentPodTask(CommonUtils.parseString("stationName",station));
return ResponseEntity.ok(JsonUtils.map2Json(dto));
}
//前次操作
}
package com.mushiny.heli.xnr.controller;
import com.mushiny.heli.xnr.comm.JsonUtils;
import com.mushiny.heli.xnr.dto.InboundOrderDTO;
import com.mushiny.heli.xnr.dto.ItemDTO;
import com.mushiny.heli.xnr.dto.MessageDTO;
import com.mushiny.heli.xnr.dto.OutboundOrderDTO;
import com.mushiny.heli.xnr.service.WMSService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 电梯配置
*/
@RestController
@RequestMapping("/mushiny")
public class WMSController {
private final static Logger logger = LoggerFactory.getLogger(WMSController.class);
@Autowired
private WMSService wmsService;
@PostMapping(value = "/createICQAOrder", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> createICQAOrder(
@RequestBody String json){
Map data = JsonUtils.json2Map(json);
logger.debug("收到创建盘点任务指令:" + json);
MessageDTO dto = MessageDTO.success();
try {
this.wmsService.createICQAOrder(data);
} catch (Exception e) {
dto.setMESSAGE(e.getMessage());
dto.setCODE(1);
}
return ResponseEntity.ok(dto);
}
@PostMapping(value = "/syncItem", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> syncItem(
@RequestBody String json){
ItemDTO itemDTO = JsonUtils.json2Bean(json,ItemDTO.class);
logger.debug("收到物料同步指令:" + json);
MessageDTO dto = MessageDTO.success();
try {
this.wmsService.syncItem(itemDTO);
} catch (Exception e) {
dto.setMESSAGE(e.getMessage());
dto.setCODE(1);
}
return ResponseEntity.ok(dto);
}
@PostMapping(value = "/inbound", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> inboundOrder(
@RequestBody String json){
InboundOrderDTO inboundOrderDTO = JsonUtils.json2Bean(json,InboundOrderDTO.class);
logger.debug("收到入库单下发指令:" + json);
MessageDTO dto = MessageDTO.success();
try {
this.wmsService.saveInboundOrder(inboundOrderDTO);
} catch (Exception e) {
dto.setMESSAGE(e.getMessage());
dto.setCODE(1);
}
return ResponseEntity.ok(dto);
}
@PostMapping(value = "/outbound", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> outboundOrder(
@RequestBody String json){
OutboundOrderDTO outboundOrderDTO = JsonUtils.json2Bean(json, OutboundOrderDTO.class);
logger.debug("收到出库单下发指令:" + json);
MessageDTO dto = MessageDTO.success();
try {
this.wmsService.saveOutboundOrder(outboundOrderDTO);
} catch (Exception e) {
dto.setMESSAGE(e.getMessage());
dto.setCODE(1);
}
return ResponseEntity.ok(dto);
}
}
package com.mushiny.heli.xnr.dto;
import com.mushiny.heli.xnr.comm.JsonUtils;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 电梯配置
*/
public class InboundOrderDTO implements Serializable{
@JsonProperty("ENTRYID")
private String ENTRYID;
@JsonProperty("TIMES")
private Integer TIMES;
@JsonProperty("FACTORY")
private String FACTORY;
@JsonProperty("SECTION")
private String SECTION;
@JsonProperty("DATA")
List<InboundOrderPosition> DATA;
@JsonIgnore
public String getENTRYID() {
return ENTRYID;
}
@JsonIgnore
public void setENTRYID(String ENTRYID) {
this.ENTRYID = ENTRYID;
}
@JsonIgnore
public Integer getTIMES() {
return TIMES;
}
@JsonIgnore
public void setTIMES(Integer TIMES) {
this.TIMES = TIMES;
}
@JsonIgnore
public String getFACTORY() {
return FACTORY;
}
@JsonIgnore
public void setFACTORY(String FACTORY) {
this.FACTORY = FACTORY;
}
@JsonIgnore
public String getSECTION() {
return SECTION;
}
@JsonIgnore
public void setSECTION(String SECTION) {
this.SECTION = SECTION;
}
@JsonIgnore
public List<InboundOrderPosition> getDATA() {
return DATA;
}
@JsonIgnore
public void setDATA(List<InboundOrderPosition> DATA) {
this.DATA = DATA;
}
public static void main(String[] args) {
InboundOrderDTO inboundOrderDTO = new InboundOrderDTO();
List<InboundOrderPosition> pos = new ArrayList<>();
InboundOrderPosition inboundOrderPosition = new InboundOrderPosition();
inboundOrderPosition.setAMOUNT(5);
inboundOrderPosition.setSKUID("XTTEST0001");
InboundOrderPosition inboundOrderPosition2 = new InboundOrderPosition();
inboundOrderPosition2.setAMOUNT(4);
inboundOrderPosition2.setSKUID("XTTEST0002");
pos.add(inboundOrderPosition);
pos.add(inboundOrderPosition2);
inboundOrderDTO.setDATA(pos);
inboundOrderDTO.setENTRYID("INBOUND0001");
inboundOrderDTO.setTIMES(10);
inboundOrderDTO.setFACTORY("HELI0001");
inboundOrderDTO.setSECTION("HELIHF0001");
System.out.println(JsonUtils.bean2Json(inboundOrderDTO));
}
}
package com.mushiny.heli.xnr.dto;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
/**
* 电梯配置
*/
public class InboundOrderPosition implements Serializable {
@JsonProperty("SKUID")
private String SKUID;
@JsonProperty("AMOUNT")
private Integer AMOUNT;
@JsonProperty("STORED")
private Integer STORED;
@JsonProperty("STATE")
private String STATE;
@JsonProperty("MSG")
private String MSG;
@JsonIgnore
public Integer getSTORED() {
return STORED;
}
@JsonIgnore
public void setSTORED(Integer STORED) {
this.STORED = STORED;
}
@JsonIgnore
public String getSTATE() {
return STATE;
}
@JsonIgnore
public void setSTATE(String STATE) {
this.STATE = STATE;
}
@JsonIgnore
public String getMSG() {
return MSG;
}
@JsonIgnore
public void setMSG(String MSG) {
this.MSG = MSG;
}
@JsonIgnore
public String getSKUID() {
return SKUID;
}
@JsonIgnore
public void setSKUID(String SKUID) {
this.SKUID = SKUID;
}
@JsonIgnore
public Integer getAMOUNT() {
return AMOUNT;
}
@JsonIgnore
public void setAMOUNT(Integer AMOUNT) {
this.AMOUNT = AMOUNT;
}
}
package com.mushiny.heli.xnr.dto;
import com.mushiny.heli.xnr.comm.JsonUtils;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by Lisi on 2019-11-19.
*/
public class ItemDTO implements Serializable {
/*SKUID SNAME LENGTH WIDTH HEIGHT STATUS FACTORY SECTION*/
@JsonProperty("SKUID")
private String SKUID;
@JsonProperty("SNAME")
private String SNAME;
@JsonProperty("LENGTH")
private Integer LENGTH;
@JsonProperty("WIDTH")
private Integer WIDTH;
@JsonProperty("HEIGHT")
private Integer HEIGHT;
@JsonProperty("STATUS")
private Integer STATUS;
@JsonProperty("FACTORY")
private String FACTORY;
@JsonProperty("SECTION")
private String SECTION;
@JsonIgnore
public String getSKUID() {
return SKUID;
}
@JsonIgnore
public void setSKUID(String SKUID) {
this.SKUID = SKUID;
}
@JsonIgnore
public String getSNAME() {
return SNAME;
}
@JsonIgnore
public void setSNAME(String SNAME) {
this.SNAME = SNAME;
}
@JsonIgnore
public Integer getLENGTH() {
return LENGTH;
}
@JsonIgnore
public void setLENGTH(Integer LENGTH) {
this.LENGTH = LENGTH;
}
@JsonIgnore
public Integer getWIDTH() {
return WIDTH;
}
@JsonIgnore
public void setWIDTH(Integer WIDTH) {
this.WIDTH = WIDTH;
}
@JsonIgnore
public Integer getHEIGHT() {
return HEIGHT;
}
@JsonIgnore
public void setHEIGHT(Integer HEIGHT) {
this.HEIGHT = HEIGHT;
}
@JsonIgnore
public Integer getSTATUS() {
return STATUS;
}
@JsonIgnore
public void setSTATUS(Integer STATUS) {
this.STATUS = STATUS;
}
@JsonIgnore
public String getFACTORY() {
return FACTORY;
}
@JsonIgnore
public void setFACTORY(String FACTORY) {
this.FACTORY = FACTORY;
}
@JsonIgnore
public String getSECTION() {
return SECTION;
}
@JsonIgnore
public void setSECTION(String SECTION) {
this.SECTION = SECTION;
}
@JsonIgnore
public static void main(String[] args) {
List list = new ArrayList();
list.add("1");
list.add("2");
list.add("3");
Map data = new HashMap();
data.put("list",list);
data.put("stationName","lisist");
System.out.println("P0000024CC02".substring(9));
System.out.println("P0000024CC02".substring(8,9));
System.out.println(Integer.parseInt("P0000024CC02".substring(1,8)));
System.out.println(JsonUtils.json2Map(JsonUtils.map2Json(data)));
}
}
package com.mushiny.heli.xnr.dto;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* 通用消息体
*/
public class MessageDTO implements java.io.Serializable{
@JsonProperty("CODE")
private Integer CODE;
@JsonProperty("MESSAGE")
private String MESSAGE;
@JsonProperty("DESCRIPTION")
private String DESCRIPTION;
public Integer getCODE() {
return CODE;
}
public void setCODE(Integer CODE) {
this.CODE = CODE;
}
public String getMESSAGE() {
return MESSAGE;
}
public void setMESSAGE(String MESSAGE) {
this.MESSAGE = MESSAGE;
}
public String getDESCRIPTION() {
return DESCRIPTION;
}
public void setDESCRIPTION(String DESCRIPTION) {
this.DESCRIPTION = DESCRIPTION;
}
public static MessageDTO success() {
MessageDTO messageDTO = new MessageDTO();
messageDTO.setCODE(0);
messageDTO.setMESSAGE("OK");
messageDTO.setDESCRIPTION("");
return messageDTO;
}
public static MessageDTO fail(Integer code) {
MessageDTO messageDTO = new MessageDTO();
messageDTO.setCODE(code);
messageDTO.setMESSAGE("FAIL");
messageDTO.setDESCRIPTION("FAIL");
return messageDTO;
}
public static MessageDTO fail_msg(Integer code,String msg) {
MessageDTO messageDTO = new MessageDTO();
messageDTO.setCODE(code);
messageDTO.setMESSAGE(msg);
messageDTO.setDESCRIPTION("FAIL");
return messageDTO;
}
}
package com.mushiny.heli.xnr.dto;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
import java.util.List;
/**
* Created by Lisi on 2019-11-18.
*/
public class OutboundOrderDTO implements Serializable {
@JsonProperty("ORDERID")
private String ORDERID;
@JsonProperty("TIMES")
private Integer TIMES;
@JsonProperty("FACTORY")
private String FACTORY;
@JsonProperty("SECTION")
private String SECTION;
@JsonProperty("DATA")
List<OutboundOrderPosition> DATA;
@JsonIgnore
public String getORDERID() {
return ORDERID;
}
@JsonIgnore
public void setORDERID(String ORDERID) {
this.ORDERID = ORDERID;
}
@JsonIgnore
public Integer getTIMES() {
return TIMES;
}
@JsonIgnore
public void setTIMES(Integer TIMES) {
this.TIMES = TIMES;
}
@JsonIgnore
public String getFACTORY() {
return FACTORY;
}
@JsonIgnore
public void setFACTORY(String FACTORY) {
this.FACTORY = FACTORY;
}
@JsonIgnore
public String getSECTION() {
return SECTION;
}
@JsonIgnore
public void setSECTION(String SECTION) {
this.SECTION = SECTION;
}
@JsonIgnore
public List<OutboundOrderPosition> getDATA() {
return DATA;
}
@JsonIgnore
public void setDATA(List<OutboundOrderPosition> DATA) {
this.DATA = DATA;
}
}
package com.mushiny.heli.xnr.dto;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
/**
* Created by Lisi on 2019-11-19.
*/
public class OutboundOrderPosition implements Serializable {
@JsonProperty("SHIPMENTID")
private String SHIPMENTID;
@JsonProperty("SKUID")
private String SKUID;
@JsonProperty("AMOUNT")
private Integer AMOUNT;
@JsonProperty("PICKED")
private Integer PICKED;
@JsonProperty("STATE")
private String STATE;
@JsonProperty("MSG")
private String MSG;
@JsonIgnore
public String getSHIPMENTID() {
return SHIPMENTID;
}
@JsonIgnore
public void setSHIPMENTID(String SHIPMENTID) {
this.SHIPMENTID = SHIPMENTID;
}
@JsonIgnore
public String getSKUID() {
return SKUID;
}
@JsonIgnore
public void setSKUID(String SKUID) {
this.SKUID = SKUID;
}
@JsonIgnore
public Integer getAMOUNT() {
return AMOUNT;
}
@JsonIgnore
public void setAMOUNT(Integer AMOUNT) {
this.AMOUNT = AMOUNT;
}
@JsonIgnore
public Integer getPICKED() {
return PICKED;
}
@JsonIgnore
public void setPICKED(Integer PICKED) {
this.PICKED = PICKED;
}
@JsonIgnore
public String getSTATE() {
return STATE;
}
@JsonIgnore
public void setSTATE(String STATE) {
this.STATE = STATE;
}
@JsonIgnore
public String getMSG() {
return MSG;
}
@JsonIgnore
public void setMSG(String MSG) {
this.MSG = MSG;
}
}
package com.mushiny.heli.xnr.dto;
/**
* Created by Lisi on 2019-11-27.
*/
public class StorageLocation implements java.io.Serializable{
private String podId;
private Integer podIndex;
private String podFace;
private String locate;
private String pName;
public String getpName() {
return pName;
}
public void setpName(String pName) {
this.pName = pName;
}
public String getPodId() {
return podId;
}
public void setPodId(String podId) {
this.podId = podId;
}
public Integer getPodIndex() {
return podIndex;
}
public void setPodIndex(Integer podIndex) {
this.podIndex = podIndex;
}
public String getPodFace() {
return podFace;
}
public void setPodFace(String podFace) {
this.podFace = podFace;
}
public String getLocate() {
return locate;
}
public void setLocate(String locate) {
this.locate = locate;
}
}
package com.mushiny.heli.xnr.jdbc.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.env.Environment;
import javax.sql.DataSource;
/**
* Created by Tank.li on 2017/6/13.
*/
@Configuration
@ImportResource(locations={"classpath:sql.xml"})
public class JdbcConfig {
@Autowired
private Environment env;
@Bean
public DataSource dataSource() {
System.out.println("in init datasource");
DruidDataSource dataSource = new DruidDataSource();
dataSource.setUrl(env.getProperty("spring.datasource.url"));
dataSource.setUsername(env.getProperty("spring.datasource.username"));//用户名
dataSource.setPassword(env.getProperty("spring.datasource.password"));//密码
dataSource.setInitialSize(2);
dataSource.setMaxActive(20);
dataSource.setMinIdle(0);
dataSource.setMaxWait(60000);
//dataSource.setValidationQuery("SELECT 1");
dataSource.setTestOnBorrow(false);
dataSource.setTestWhileIdle(true);
dataSource.setPoolPreparedStatements(false);
return dataSource;
}
}
package com.mushiny.heli.xnr.jdbc.config;
import java.util.Properties;
/**
* Created by Tank.li on 2017/6/13.
*/
public class SqlMapper {
private Properties sqls;
public Properties getSqls() {
return sqls;
}
public void setSqls(Properties sqls) {
this.sqls = sqls;
}
}
package com.mushiny.heli.xnr.jdbc.domain;
/**
* Created by Tank.li on 2017/6/13.
*/
public abstract class BaseParam implements IParam {
//定义的java.sql.Types.***类型,为空的话,默认返回字符串
private int type;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
//无参数构造函数 默认为字符串
public BaseParam() {
this.type = java.sql.Types.CHAR;
}
/**
* 构造不同的返回类型,java.sql.Types定义了格式
*
* @param type java.sql.Types 里头定义的类型格式
*/
public BaseParam(int type) {
this.type = type;
}
private int index;
private Object value;
@Override
public int getIndex() {
return index;
}
@Override
public void setIndex(int index) {
this.index = index;
}
@Override
public Object getValue() {
return value;
}
@Override
public void setValue(Object value) {
this.value = value;
}
@Override
public String toString() {
return "index:"+index+" value:"+value;
}
}
package com.mushiny.heli.xnr.jdbc.domain;
import java.sql.CallableStatement;
/**
* Created by Tank.li on 2017/6/13.
*/
public interface IParam {
/**
* 索引值
* @param index
*/
void setIndex(int index);
/**
* 参数
* @param value
*/
void setValue(Object value);
/**
* 返回值
* @return
*/
Object getValue();
/**
* 返回索引
* @return
*/
int getIndex();
//注册参数//入参与返回参数注册方式不一样
/**
* 设置参数
* @param callableStatement
*/
void registerParam(CallableStatement callableStatement);
}
package com.mushiny.heli.xnr.jdbc.domain;
import java.sql.CallableStatement;
import java.sql.SQLException;
/**
* Created by Tank.li on 2017/6/13.
*/
public class InOutParam extends BaseParam {
@Override
public void registerParam(CallableStatement callableStatement) {
try {
callableStatement.setObject(this.getIndex(),this.getValue(),this.getType());
callableStatement.registerOutParameter(this.getIndex(),this.getType());
} catch (SQLException e) {
e.printStackTrace();
}
}
}
package com.mushiny.heli.xnr.jdbc.domain;
import java.sql.CallableStatement;
import java.sql.SQLException;
/**
* Created by Tank.li on 2017/6/13.
*/
public class InParam extends BaseParam {
@Override
public void registerParam(CallableStatement callableStatement) {
try {
callableStatement.setObject(this.getIndex(),this.getValue(),this.getType());
} catch (SQLException e) {
e.printStackTrace();
}
}
}
package com.mushiny.heli.xnr.jdbc.domain;
import java.sql.CallableStatement;
import java.sql.SQLException;
/**
* Created by Tank.li on 2017/6/13.
*/
public class OutParam extends BaseParam {
@Override
public void registerParam(CallableStatement callableStatement) {
try {
callableStatement.registerOutParameter(this.getIndex(),this.getType());
} catch (SQLException e) {
e.printStackTrace();
}
}
}
package com.mushiny.heli.xnr.jdbc.repositories;
import com.mushiny.heli.xnr.beans.BaseBpo;
import com.mushiny.heli.xnr.beans.BaseObject;
import com.mushiny.heli.xnr.comm.CommonUtils;
import com.mushiny.heli.xnr.jdbc.config.SqlMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
/**
* Created by Tank.li on 2017/6/13.
*/
@Repository
@Transactional
@org.springframework.core.annotation.Order(value = 8)
public class JdbcRepository implements CommandLineRunner {
private final static Logger logger = LoggerFactory.getLogger(JdbcRepository.class);
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private SqlMapper sqlMapper;
/**
* 通过
* @param sql
* @param con
* @return
*/
public List<Map> queryByMap(String sql,List<QueryCondition> con){
return null;
}
/**
* 对象状态变化后更新数据库表
* @param baseObject
*/
public int updateBusinessObject(BaseObject baseObject){
Map newValue = baseObject.getNewValue();
if(newValue == null || newValue.isEmpty()){
//logger.debug("未做更新操作,表"+baseObject.getTable()+"的状态是空:"+newValue);
return 0;
}
CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap();
con.put(baseObject.getIdName(),baseObject.getId());
int result = this.updateRecords(baseObject.getTable(),newValue,con);
baseObject.clearKV();
logger.debug("BO:"+baseObject.getTable()+"状态已刷新到数据库!"
+ baseObject.getIdName() + ":" +baseObject.getId());
return result;
}
private BaseBpo genNewBo(BaseObject baseObject) {
BaseBpo baseBpo = new BaseBpo();
baseBpo.setIdName(baseObject.getIdName());
baseBpo.setId(baseObject.getId());
baseBpo.setTable(baseObject.getTable());
//赋值操作条件
if (baseObject.getDelCon() != null) {
baseBpo.setDelCon(new HashMap<>(baseObject.getDelCon()));
}
if (baseObject.getCon() != null) {
baseBpo.setCon(new HashMap<>(baseObject.getCon()));
}
if (baseObject.getKv() != null) {
baseBpo.setKv(new HashMap<>(baseObject.getKv()));
}
logger.debug("生成数据库操作对象:["+baseBpo.getTable()+"]"+baseBpo.getIdName()+":"+baseBpo.getId());
if(baseBpo.getDelCon()!=null && !baseBpo.getDelCon().isEmpty()){
logger.debug("数据库操作对象的删除条件:["+baseBpo.getDelCon()+"]");
}else if(baseBpo.getKv()!=null && !baseBpo.getKv().isEmpty()){
logger.debug("数据库操作对象的更新值:["+baseBpo.getKv()+"] "+baseBpo.getIdName()+" == "+baseBpo.getId());
}
return baseBpo;
}
/**
* 对象状态变化后更新数据库表
* @param baseObject
*/
public void insertBusinessObject(BaseObject baseObject){
Map newValue = baseObject.getNewValue();
if(newValue == null || newValue.isEmpty()){
logger.debug("未做新增操作,表"+baseObject.getTable()+"的状态是空:"+newValue);
return;
}
CommonUtils.genUselessInfo(newValue);
/*Map con = new HashMap();
con.put(baseObject.getIdName(),baseObject.getId());*/
this.insertRecord(baseObject.getTable(),newValue);
logger.debug("BO:"+baseObject.getTable()+"状态已刷新,新增到数据库!"
+ (baseObject.getActiveThread() == null ?
"":baseObject.getActiveThread())+" "+baseObject.getKv());
baseObject.clearKV();
}
/**
* 通过key更新 params是?的参数
*
* @param key
* @param params
* @return
*/
public int updateByKey(String key, List params) {
logger.debug("sql key:" + key);
String sql = sqlMapper.getSqls().getProperty(key);
return updateBySql(sql, params);
}
/**
* 通过key更新 params是?的参数
*
* @param key
* @param params
* @return
*/
public int updateByKey(String key, Object... params) {
logger.debug("sql key:" + key);
String sql = sqlMapper.getSqls().getProperty(key);
return updateBySql(sql, params);
}
/**
* 通过key更新
*
* @param key
* @return
*/
public int updateByKey(String key) {
logger.debug("sql key:" + key);
String sql = sqlMapper.getSqls().getProperty(key);
return updateBySql(sql);
}
/**
* 通过SQL更新
*
* @param sql
* @return
*/
public int updateBySql(String sql) {
return updateBySql(sql, new ArrayList());
}
/**
* * 通过key更新 params是?的参数
*
* @param sql
* @param params
* @return
*/
public int updateBySql(String sql, List params) {
logger.debug("SQL:" + sql + " params:" + params);
long start = System.currentTimeMillis();
int count = this.jdbcTemplate.update(sql, params.toArray());
logger.debug(count + "条记录更新!SQL更新耗时:"+(System.currentTimeMillis()-start)+"毫秒!");
return count;
}
public int updateBySql(String sql, Object... params) {
logger.debug("SQL:" + sql.toUpperCase() + " params:" + paramsStr(params));
long start = System.currentTimeMillis();
int count = this.jdbcTemplate.update(sql.toUpperCase(), params);
logger.debug(count + "条记录更新!SQL更新耗时:"+(System.currentTimeMillis()-start)+"毫秒!");
return count;
}
/**
* 通过SQLkey去查询 配置在sql.xml
*
* @param key
* @param params
* @return
*/
public List<Map> queryByKey(String key, List params) {
logger.debug("sql key:" + key);
if (key == null || "".equals(key)) {
logger.error("key is null :" + key);
throw new RuntimeException("key is null:" + key);
}
String sql = sqlMapper.getSqls().getProperty(key);
if (sql == null || "".equals(sql)) {
logger.error("sql is null :" + key);
throw new RuntimeException("sql is null:" + key);
}
return queryBySql(sql, params);
}
/**
* 通过SQL key 查找 没有参数
*
* @param key
* @return
*/
public List<Map> queryByKey(String key) {
List params = new ArrayList();
return queryByKey(key, params);
}
public List<Map> queryByKey(String key,Object... pars) {
List params = new ArrayList();
for (int i = 0; i < pars.length; i++) {
Object object = pars[i];
params.add(object);
}
return queryByKey(key, params);
}
public List<Map> queryBySql(String sql,Object... pars) {
List params = new ArrayList();
for (int i = 0; i < pars.length; i++) {
Object object = pars[i];
params.add(object);
}
return queryBySql(sql, params);
}
/**
* SQL执行 带? 参数
*
* @param sql
* @param params
* @return
*/
@Transactional
public List<Map> queryBySql(String sql, List params) {
if (params == null) {
params = new ArrayList();
}
Object[] _params = params.toArray();
String _paramsStr = paramsStr(_params);
logger.debug("查询语句是:" + sql.toUpperCase() + " 参数是:" + _paramsStr);
long start = System.currentTimeMillis();
List<Map> rows = this.jdbcTemplate.query(sql.toUpperCase(), _params, new RowMap());
logger.debug("查询结果总数:"+rows.size()+" SQL查询耗时:"+(System.currentTimeMillis() -start)+"毫秒!");
return rows;
}
private String paramsStr(Object[] params) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("[");
for (int i = 0; i < params.length; i++) {
Object param = params[i];
if(i<params.length-1){
stringBuilder.append(param==null? "" : param.toString()).append(",");
}else{
stringBuilder.append(param.toString());
}
}
stringBuilder.append("]");
return stringBuilder.toString();
}
@Transactional
public List<Map> queryBySql(String sql) {
Object[] _params = new Object[]{};
return this.jdbcTemplate.query(sql, _params, new RowMap());
}
/**
* 根据whereValue与tableName将表字段更新成newValue
*
* @param tableName 表名
* @param newValue 字段及更新后的值
* @param whereValue 更新条件:字段及对应值
* @return
* @Method update
* @Function 功能描述:可能存在多行被更新
* @Date 2010-11-24
*/
@Transactional
public int updateRecords(String tableName, Map newValue, Map whereValue) {
//1、生成update **** set **=? and **=? where **id1= ? and id2=?
//2、为?号赋值
if (newValue == null
|| tableName == null
|| whereValue == null
|| "".equals(tableName)
|| whereValue.size() == 0
|| newValue.size() == 0) {
logger.error("表名或值或条件为空,不满足更新条件!!");
return 0;//
}
List values = new ArrayList();
StringBuffer sb = new StringBuffer();
sb.append(" update ");
sb.append(tableName);
sb.append(" set ");
sb.append(buildUpdateParams(newValue, values, ","));
sb.append(" where ");
sb.append(buildUpdateParams(whereValue, values, "and"));//通过原先的值判断该条记录
String sql = sb.toString().toUpperCase();
logger.debug("更新记录时生成的SQL语句是:" + sql + " 参数:" + this.paramsStr(values.toArray()));
long start = System.currentTimeMillis();
//下面生成为参数赋值 执行update的sql语句
int count = this.jdbcTemplate.update(sql, values.toArray());
logger.debug("Table:["+tableName+"]的 "+count + " 条记录更新!耗时:"
+(System.currentTimeMillis()-start)+"毫秒");
return count;
}
/**
* @param tableName
* @param whereValue
* @return
*/
@Transactional
public int deleteRecords(String tableName, Map whereValue) {
if (tableName == null
|| whereValue == null
|| "".equals(tableName)
|| whereValue.size() == 0) {
logger.error("表名或条件为空,不满足删除条件!!");
return 0;
}
List values = new ArrayList();
StringBuffer buffer = new StringBuffer();
buffer.append("delete from ");
buffer.append(tableName);
buffer.append(" where ");
buffer.append(buildUpdateParams(whereValue, values, "and"));
String sql = buffer.toString().toUpperCase();
logger.debug("删除记录语句是:" + sql +" 参数是:" + whereValue);
int count = this.jdbcTemplate.update(sql, values.toArray());
logger.debug("表"+tableName+"记录删除 数量:"+count);
return count;
}
//link 是连接符 如,或 and
private static String buildUpdateParams(Map newValue, List values, String link) {
if (newValue.size() == 0) {
return "";
}
List list = new ArrayList(newValue.keySet());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
String key = (String) list.get(i);
values.add(newValue.get(key));
if (i < list.size() - 1) {
sb.append(key).append("=? ").append(link).append(" ");
} else {
sb.append(key).append("=? ");
}
}
return sb.toString(); //去掉第一个","号
}
/**
* @param tableName 表名
* @param record 记录的Map形式 key为字段名 value为字段值
* @return
* @Method insertRecord
* @Function 功能描述:插入一条记录
* @Date 2010-11-24
*/
//@Transactional
public int insertRecord(String tableName, Map record) {
//1、生成insert into tableName (column1,column2.....) values (?,?......)
//2、为?号赋值
if (record == null
|| tableName == null
|| "".equals(tableName)
|| record.size() == 0) {
logger.error("表名或记录为空,不执行插入语句!!");
return 0;//
}
int result = 0;
List values = new ArrayList();
String sql = buildInsertSql(tableName, record, values).toUpperCase();//mysql要转成大写
logger.debug("增加记录时生成的SQL语句是:" + sql + " 参数值是:"+record);
result = this.jdbcTemplate.update(sql, values.toArray());
logger.debug(result + "条记录增加!");
return result;
}
private static String buildInsertSql(String tableName, Map record, List values) {
StringBuffer sb = new StringBuffer();
sb.append(" insert into ");
sb.append(tableName);
sb.append(" (");
sb.append(buildInsertParams(record, values));
sb.append(") ");
sb.append(" values (");
sb.append(buildInsertValues(record.size()));
sb.append(") ");
return sb.toString();
}
private static String buildInsertParams(Map record, List values) {
StringBuffer buffer = new StringBuffer();
Set keySet = record.keySet();
for (Iterator iterator = keySet.iterator(); iterator.hasNext(); ) {
String key = (String) iterator.next();
buffer.append(",").append(key);
values.add(record.get(key));
}
return buffer.substring(1);//去掉第一个逗号
}
private static String buildInsertValues(int count) { //count 是?的数量
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < count; i++) {
buffer.append(",").append("?");
}
return buffer.substring(1);
}
@Override
public void run(String... strings) throws Exception {
}
}
package com.mushiny.heli.xnr.jdbc.repositories;
/**
* Created by Lisi on 2019-11-27.
*/
public class QueryCondition {
private String key;
private String oper;//" like = <> in "
private Object value;
}
package com.mushiny.heli.xnr.jdbc.repositories;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Tank.li on 2017/6/13.
*/
public class RowMap implements RowMapper<Map> {
private final static Logger logger = LoggerFactory.getLogger(RowMap.class);
@Override
public Map mapRow(ResultSet resultSet, int i) throws SQLException {
Map data = new HashMap();
int colCount = resultSet.getMetaData().getColumnCount();
for (int j = 0; j < colCount; j++) {
String key = resultSet.getMetaData().getColumnName(j+1);
String label = resultSet.getMetaData().getColumnLabel(j+1);
data.put(key.toUpperCase(),resultSet.getObject(key));
data.put(label.toUpperCase(),resultSet.getObject(label));
}
//logger.debug("index:"+i,"row="+data);
return data;
}
}
package com.mushiny.heli.xnr.service;
import com.mushiny.heli.xnr.beans.BaseBpo;
import com.mushiny.heli.xnr.comm.CommonUtils;
import com.mushiny.heli.xnr.dto.MessageDTO;
import com.mushiny.heli.xnr.dto.StorageLocation;
import com.mushiny.heli.xnr.jdbc.repositories.JdbcRepository;
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.Service;
import javax.transaction.Transactional;
import java.util.*;
/**
* Created by Lisi on 2019-11-27.
*/
@Service
@Transactional
public class InboundService {
public static final String SQL_SEARCHINBOUND_FACTORY = " AND WAREHOUSE_ID=? ";
public static final String SQL_SEARCHINBOUND_SECTION = " AND SECTION_ID=? ";
public static final String SQL_SEARCHINBOUNDINFO =
"SELECT * FROM WMS_INBOUND_ORDER WHERE ENTRYID = ?";
private final static Logger logger = LoggerFactory.getLogger(InboundService.class);
@Autowired
private JdbcRepository jdbcRepository;
@Autowired
private SystemPropertiesManager systemPropertiesManager;
public static final String SQL_SEARCHINBOUND = "SELECT * FROM WMS_INBOUND_ORDER WHERE ENTRYID like ? ";
public List<Map> searchInbound(String entryId, String warehouseId, String sectionId) {
List params = new ArrayList();
StringBuilder sql = new StringBuilder();
sql.append(SQL_SEARCHINBOUND);
params.add(entryId);
if(!CommonUtils.isEmpty(warehouseId)){
sql.append(SQL_SEARCHINBOUND_FACTORY);
params.add(warehouseId);
}
if(!CommonUtils.isEmpty(sectionId)){
sql.append(SQL_SEARCHINBOUND_SECTION);
params.add(warehouseId);
}
return this.jdbcRepository.queryBySql(sql.toString(),params);
}
public Map searchInboundInfo(String entryId) {
List params = new ArrayList();
StringBuilder sql = new StringBuilder();
sql.append(SQL_SEARCHINBOUNDINFO);
params.add(entryId);
List<Map> data = this.jdbcRepository.queryBySql(sql.toString(),params);
if(!data.isEmpty()){
return data.get(0);
}
throw new RuntimeException("没有这条记录:"+entryId);
}
public MessageDTO orderFinish(String entryId) {
MessageDTO messageDTO = MessageDTO.success();
BaseBpo baseBpo = new BaseBpo();
baseBpo.setIdName("ENTRYID");
baseBpo.setTable(Sql_Table.WMS_INBOUND_ORDER);
baseBpo.setId(entryId);
baseBpo.addKV("STATE", Sql_Table.FINISH);
int result = this.jdbcRepository.updateBusinessObject(baseBpo);
if(result == 0){
messageDTO.setMESSAGE("更新失败,没有更新记录!");
messageDTO.setCODE(1);
//return messageDTO;
}
return messageDTO;
}
public static final String SQL_INV_UNITLOADID =
"SELECT INV_UNITLOAD.ID FROM INV_UNITLOAD,MD_STORAGELOCATION WHERE MD_STORAGELOCATION.NAME=? " +
"AND MD_STORAGELOCATION.ID=INV_UNITLOAD.STORAGELOCATION_ID";
public static final String SQL_MD_ITEMDATA =
"SELECT ID FROM MD_ITEMDATA WHERE SKUID=?";
/**
* 上架到货位
* @param skuId
* @param stored
* @param containerId
* @param factory
* @param section
* @param entryId
* @return
*/
public MessageDTO store(String skuId, int stored, String containerId,
String factory, String section, String entryId) {
MessageDTO messageDTO = MessageDTO.success();
List<Map> invs = this.jdbcRepository.queryBySql(SQL_INV_UNITLOADID,containerId);
if(invs.isEmpty()){
messageDTO.setCODE(1);
messageDTO.setMESSAGE("没有找到该容器:"+containerId);
return messageDTO;
}
List<Map> items = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERYITEM_BYSKUNO, skuId);
if(items.isEmpty()){
messageDTO.setCODE(1);
messageDTO.setMESSAGE("没有找到该商品信息:"+skuId);
return messageDTO;
}
Map item = items.get(0);
String mID = CommonUtils.parseString("ID",item);
Map data = invs.get(0);
String uid = CommonUtils.parseString("ID",data);
List<Map> lists = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_INV_SKU,mID,uid);
//是否存在记录
if(lists.isEmpty()){
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.TABLE_INV_STOCKUNIT);
baseBpo.addKV("ID",CommonUtils.genUUID());
baseBpo.addKV("ITEMDATA_ID",mID);
baseBpo.addKV("STATE","Inventory");
baseBpo.addKV("AMOUNT",stored);//上架的数量
baseBpo.addKV("UNITLOAD_ID",uid);
baseBpo.addKV("RESERVED_AMOUNT",0);
baseBpo.addKV("CLIENT_ID",factory);
baseBpo.addKV("WAREHOUSE_ID",section);
this.jdbcRepository.insertBusinessObject(baseBpo);
//end of 新增记录
}else{
//获取数据
Map inv = lists.get(0);
Integer amount = CommonUtils.parseInteger("AMOUNT",inv);
Map newValue = new HashMap();
newValue.put("AMOUNT",amount+stored);//增加的库存数
Map con = new HashMap();
con.put("ITEMDATA_ID",mID);
con.put("UNITLOAD_ID",uid);
this.jdbcRepository.updateRecords(Sql_Table.TABLE_INV_STOCKUNIT,newValue,con);
}
//更新入库单状态
this.updateInboundOrderStatus(entryId,skuId, Sql_Table.FINISH,stored,"OK");
return messageDTO;
}
/**
* 更新入库单状态
* @param entryId
* @param skuId
* @param state
* @param stored
* @return
*/
public MessageDTO updateInboundOrderStatus(String entryId,String skuId,
String state,Integer stored,String msg){
MessageDTO messageDTO = MessageDTO.success();
Map newValue = new HashMap();
newValue.put("STATE",state);
newValue.put("MSG",msg);
newValue.put("STORED",stored);
Map con = new HashMap();
con.put("SKUID",skuId);
con.put("ENTRYID",entryId);
//
int count = this.jdbcRepository.updateRecords(Sql_Table.WMS_INBOUND_ORDERPOSITION, newValue, con);
if(count == 0){
messageDTO.setMESSAGE("更新失败,entryId:"+entryId+" skuId:"+skuId);
messageDTO.setCODE(1);
}
return messageDTO;
}
/**
* 物料缺失
* @param entryId
* @param skuId
* @return
*/
public MessageDTO skuNotFound(String entryId, String skuId) {
return this.updateInboundOrderStatus(entryId, skuId, Sql_Table.ERROR,0, "物料缺失");
}
public static final String STATION_ID = "6db9c7c0-4f93-4fa1-82c0-fb6435af7aae";//NTYH01S1-S001-1
public static final String STOW_OPERATOR_ID = "stowPod_user";//NTYH01S1-S001-1
public static final String ICQA_OPERATOR_ID = "icqaPod_user";//NTYH01S1-S001-1
public static final String STATION_NAME_STOWPOD = "STOWPOD_STATION";//NTYH01S1-S001-1
public static final String STATION_NAME_ICQAPOD = "ICQAPOD_STATION";//NTYH01S1-S001-1
/**
* 批量生成上架任务
* @param entryIds
* @param stationName
* @return
*/
public MessageDTO startInbound(List entryIds, String stationName) {
//成功
MessageDTO dto = MessageDTO.success();
//查询是否为空
if(!isLocked(stationName)){
dto.setCODE(1);
dto.setMESSAGE("工作站被锁定或不存在,无法启动上架任务!");
return dto;
}
if(!this.lockStowStation(stationName)){
dto.setCODE(1);
dto.setMESSAGE("工作站锁定失败,无法启动上架任务!");
return dto;
}
for (int i = 0; i < entryIds.size(); i++) {
String entryId = (String) entryIds.get(i);
List<Map> entryPositions = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_INBOUND_POSITION,entryId);
for (int j = 0; j < entryPositions.size(); j++) {
Map map = entryPositions.get(j);
String skuId = CommonUtils.parseString("SKUID",map);
StorageLocation storageLocation = this.findStorageLocation(skuId);
if(storageLocation == null){
logger.error("SKU没有找到对应存储位,将随机分配空的存储位 SKU:"+skuId);
storageLocation = newStorageLocation();
if(storageLocation == null){
dto.setCODE(1);
dto.setMESSAGE("无法为SKU分配库位! SKU:"+skuId);
return dto;
}
}
/* `ID` VARCHAR(255) NOT NULL, WMS_INBOUND_PODORDER
`ENTRYID` VARCHAR(255) NOT NULL,
`ENTRYPOSITIONID` VARCHAR(255) NOT NULL,
`SKUID` VARCHAR(255) NOT NULL,
`POD_ID` VARCHAR(255) NOT NULL,
`POD_FACE` VARCHAR(255) NOT NULL,
`POD_LOCATE` VARCHAR(255) NOT NULL,
`PODINDEX` INT(11) DEFAULT NULL COMMENT '货架编号',
`STATE` VARCHAR(255) COMMENT '状态',
`AMOUNT` INT(11) DEFAULT NULL COMMENT '数量',
`WAREHOUSE_ID` VARCHAR(255) NOT NULL COMMENT 'FACTORY',
`SECTION_ID` VARCHAR(255) DEFAULT NULL COMMENT '物理区域SECTION',*/
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.WMS_INBOUND_PODORDER);
baseBpo.addKV("ID",CommonUtils.genUUID());
baseBpo.addKV("ENTRYID",entryId);
baseBpo.addKV("ENTRYPOSITIONID",CommonUtils.parseString("ID",map));
baseBpo.addKV("POD_ID",storageLocation.getPodId());
baseBpo.addKV("POD_FACE",storageLocation.getPodFace());
baseBpo.addKV("POD_LOCATE",storageLocation.getLocate());
baseBpo.addKV("WORKSTATION_ID",stationName);
baseBpo.addKV("PODINDEX",storageLocation.getPodIndex());
baseBpo.addKV("AMOUNT",CommonUtils.parseString("AMOUNT",map));
baseBpo.addKV("STATE", Sql_Table.AVAILABLE);
baseBpo.addKV("WAREHOUSE_ID",CommonUtils.parseString("WAREHOUSE_ID",map));
baseBpo.addKV("SECTION_ID",CommonUtils.parseString("SECTION_ID",map));
//插入货架搬运任务 指令
this.jdbcRepository.insertBusinessObject(baseBpo);
}
}
return dto;
}
public static final String WAREHOUSE = "456e94fe-127d-4861-9948-cc38760801b4";
/**
* 定时启动任务
*/
@Scheduled(fixedDelay = 10*1000L)
public void startInboundTrip(){
//6db9c7c0-4f93-4fa1-82c0-fb6435af7aae
if(isLocked("6db9c7c0-4f93-4fa1-82c0-fb6435af7aae")){
logger.error("工作站被锁定,无法启动上架任务!");
return ;
}
//TODO 根据工作站查找
String pods = this.systemPropertiesManager.getProperty("StowPodStationMaxPod", WAREHOUSE);
List<Map> runningPods = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_RUNNINGPODS, "StowPod", Sql_Table.AVAILABLE);
Integer limit = Integer.parseInt(pods) - runningPods.size(); //TODO 按工作站区分
//先找这么多货架 然后加载所有任务
List<Map> podIds = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_PODS, "StowPod", Sql_Table.AVAILABLE);
for (int i = 0; i < podIds.size() && i < limit; i++) {
Map map = podIds.get(i);
String podId = CommonUtils.parseString("POD_ID",map);
String workStation = CommonUtils.parseString("WORKSTATION_ID",map);
List<Map> orderPosition = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_PODORDERS
,podId, Sql_Table.AVAILABLE);
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable("RCS_TRIP");
String tripId = CommonUtils.genUUID();
baseBpo.addKV("ID",tripId);
baseBpo.addKV("POD_ID",podId);
baseBpo.addKV("TRIP_TYPE","StowPod");
baseBpo.addKV("WORKSTATION_ID",workStation);
baseBpo.addKV("TRIP_STATE","New");
baseBpo.addKV("WAREHOUSE_ID",CommonUtils.parseString("WAREHOUSE_ID",map));
baseBpo.addKV("SECTION_ID",CommonUtils.parseString("SECTION_ID",map));
this.jdbcRepository.insertBusinessObject(baseBpo);
for (int j = 0; j < orderPosition.size(); j++) {
Map podOrders = orderPosition.get(j);
BaseBpo baseBpo2 = new BaseBpo();
baseBpo2.setTable("RCS_TRIPPOSITION");
String tripPositionID = CommonUtils.genUUID();
baseBpo2.addKV("ID",tripPositionID);
baseBpo2.addKV("TRIP_ID",tripId);
baseBpo2.addKV("POD_USING_FACE",CommonUtils.parseString("POD_FACE",map));
baseBpo2.addKV("POSITION_NO",j+1);
baseBpo2.addKV("WAREHOUSE_ID",CommonUtils.parseString("WAREHOUSE_ID",map));
baseBpo2.addKV("SECTION_ID",CommonUtils.parseString("SECTION_ID",map));
this.jdbcRepository.insertBusinessObject(baseBpo2);
Map newValue = new HashMap();
newValue.put("STATE", Sql_Table.FINISH);//生成就结束了 是不是执行完看TRIPPOSITION_ID
newValue.put("TRIPPOSITION_ID", tripPositionID);
Map con = new HashMap();
con.put("ID",CommonUtils.parseString("ID",podOrders));
this.jdbcRepository.updateRecords(Sql_Table.WMS_INBOUND_PODORDER, newValue,con);
}
}
}
public static final String SQL_NEWSTORAGELOCATION = "SELECT MD_STORAGELOCATION.* FROM MD_STORAGELOCATION,INV_UNITLOAD \n" +
"WHERE MD_STORAGELOCATION.ID=INV_UNITLOAD.STORAGELOCATION_ID \n" +
"AND MD_STORAGELOCATION.POD_ID IS NOT NULL AND INV_UNITLOAD.ID NOT IN \n" +
"(SELECT UNITLOAD_ID from \n" +
"(SELECT sum(AMOUNT) as SUMALL,UNITLOAD_ID \n" +
"FROM INV_STOCKUNIT group by UNITLOAD_ID )UNITLOAD WHERE UNITLOAD.SUMALL>0) limit 1";
private StorageLocation newStorageLocation() {
List<Map> list = this.jdbcRepository.queryBySql(SQL_NEWSTORAGELOCATION);
if(list.isEmpty()){
return null;
}
Map row = list.get(0);
StorageLocation storageLocation = new StorageLocation();
genStorageLocation(storageLocation,row);
return storageLocation;
}
private StorageLocation findStorageLocation(String skuId) {
StorageLocation storageLocation = new StorageLocation();
List<Map> data = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERYSTORAGELOCATION_BYSKU,skuId);
if(data.isEmpty()){
return null;
}
Map row = data.get(0);
genStorageLocation(storageLocation, row);
return storageLocation;
}
private void genStorageLocation(StorageLocation storageLocation, Map row) {
//P0000024CC02
String pName = CommonUtils.parseString("NAME",row);
String podId = CommonUtils.parseString("POD_ID",row);
logger.debug("pName:"+pName);
String locate = pName.substring(9);
storageLocation.setLocate(locate);
storageLocation.setPodFace(pName.substring(8,9));
storageLocation.setPodId(podId);
storageLocation.setPodIndex(Integer.parseInt(pName.substring(1,8)));
storageLocation.setpName(pName);
}
private synchronized boolean lockStowStation(String stationId) {
List<Map> stations = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_WORKSTATION,stationId);
if(stations.isEmpty()){
return false;
}
Map data = stations.get(0);
Integer version = CommonUtils.parseInteger("VERSION",data);
Map newValue = new HashMap();
newValue.put("VERSION",version+1);
newValue.put("ISCALLPOD",Boolean.TRUE);
newValue.put("OPEATOR_ID","LISI");
newValue.put("STAION_NAME","stowPod");
Map con = new HashMap();
con.put("WORKSTATION_ID",stationId);
con.put("VERSION",version);
int count = this.jdbcRepository.updateRecords(Sql_Table.TABLE_MD_WORKSTATION, newValue ,con);
return count != 0;
}
//用户名写死为 LISI
private boolean isLocked(String stationId) {
List<Map> rows = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_WORKSTATION, stationId);
if(rows.isEmpty()){
return false;
}
Map data = rows.get(0);
String operator_id = CommonUtils.parseString("OPERATOR_ID",data);
if(!CommonUtils.isEmpty(operator_id)
&& !Objects.equals(operator_id,"LISI")){
return true;
}
return false;
}
public MessageDTO endInbound(String stationName) {
return null;
}
public Map currentPodTask(String stationName) {
Map dto = new HashMap();
//如果没有锁定 就没有任务
if(isLocked(stationName) ){
dto.put("CODE",1);
dto.put("MSG","工作站"+stationName+"被占用,没有当前任务!");
return dto;
}
List<Map> datas = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_CURRENTPODTASK,
Sql_Table.AVAILABLE, Sql_Table.PROCESS, Sql_Table.PROCESS,stationName);
if(datas.isEmpty()){
dto.put("CODE",1);
dto.put("MSG","没有找到当前在工作站的货架");
return dto;
}
Map data = datas.get(0);
/*`ID` varchar(255) NOT NULL,
`ENTRYID` varchar(255) NOT NULL,
`ENTRYPOSITIONID` varchar(255) NOT NULL,
`SKUID` varchar(255) NOT NULL,
`POD_ID` varchar(255) NOT NULL,
`POD_FACE` varchar(255) NOT NULL,
`POD_LOCATE` varchar(255) NOT NULL,
`PODINDEX` int(11) DEFAULT NULL COMMENT '货架编号',
`STATE` varchar(255) COMMENT '状态',*/
String skuId = CommonUtils.parseString("SKUID",data);
List<Map> skus = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERYITEM_BYSKUNO, skuId);
if (skus.isEmpty()){
dto.put("CODE",1);
dto.put("MSG","没有找到当前上架商品信息, SKU:"+skuId);
return dto;
}
Map sku = skus.get(0);
data.put("SKUNAME",CommonUtils.parseString("NAME",sku));
return data;
}
}
package com.mushiny.heli.xnr.service;
/**
* Created by Lisi on 2019-11-27.
*/
public interface Sql_Table {
String SQL_QUERY_INV_SKU = "SELECT * FROM INV_STOCKUNIT WHERE UNITLOAD_ID=? AND ITEMDATA_ID=?";
String SQL_QUERY_CURRENTPODTASK = "SELECT WMS_INBOUND_PODORDER.* \n" +
"FROM MD_POD,MD_WORKSTATION,RCS_TRIP, RCS_TRIPPOSITION, \n" +
"WMS_INBOUND_PODORDER, WMS_INBOUND_ORDERPOSITION \n" +
"WHERE MD_WORKSTATION.ID=RCS_TRIP.WORKSTATION_ID \n" +
"AND WMS_INBOUND_PODORDER.TRIPPOSITION_ID \n" +
"AND MD_POD.PLACEMARK=MD_WORKSTATION.STOPPOINT\n" +
"AND WMS_INBOUND_ORDERPOSITION.ID=WMS_INBOUND_PODORDER.ENTRYPOSITIONID \n" +
"AND WMS_INBOUND_ORDERPOSITION.STATE= ? \n" +
"AND RCS_TRIP.POD_ID=MD_POD.ID \n" +
"AND RCS_TRIPPOSITION.TRIPPOSITION_STATE = ? \n" +
"AND TRIP_STATE= ? \n" +
"AND RCS_TRIP.ID=RCS_TRIPPOSITION.TRIP_ID \n" +
"AND MD_WORKSTATION.ID = ? \n" +
"LIMIT 1";
String SQL_QUERY_INBOUNDORDER_BYPOSITIONSTATE = "SELECT WMS_INBOUND_ORDER.* " +
"FROM WMS_INBOUND_ORDER\n" +
"WHERE NOT EXISTS (SELECT * FROM WMS_INBOUND_ORDERPOSITION \n" +
"WHERE WMS_INBOUND_ORDERPOSITION.STATE<>? \n" +
"AND WMS_INBOUND_ORDERPOSITION.ENTRYID = WMS_INBOUND_ORDER.ENTRYID)";
String SQL_QUERYITEM_BYID = "SELECT * FROM MD_ITEMDATA WHERE ID=?";
String TABLE_MD_ITEMDATA = "MD_ITEMDATA";
String SQL_FINDALLITEM = "SELECT * FROM MD_ITEMDATA WHERE CLIENT_ID=? AND WAREHOUSE_ID=?";
String WMS_ICQA_ORDERPOSITION = "WMS_ICQA_ORDERPOSITION";
String WMS_ICQA_ORDER = "WMS_ICQA_ORDER";
String SQL_QUERY_ICQA_BY_TYPE = "SELECT * FROM WMS_ICQA_ORDER WHERE TYPE='ALL' AND STATE<>?";
String SQL_ALL_TASKING_SKU = "SELECT SKUID FROM WMS_ICQA_ORDERPOSITION " +
"WHERE STATE<>?" ;
String FINISH = "Finish";
String PROCESS = "Process";
String ERROR = "Error";
String AVAILABLE = "Available";
String TABLE_INV_STOCKUNIT = "TABLE_INV_STOCKUNIT";
String SQL_QUERYITEM_BYSKUNO = "SELECT * FROM MD_ITEMATA, MD_ITEMDATA_SKUNO " +
"WHERE MD_ITEMATA.ITEM_NO = MD_ITEMDATA_SKUNO.ITEM_NO AND SKU_NO = ?";
String TABLE_MD_ITEMDATA_SKUNO = "TABLE_MD_ITEMDATA_SKUNO";
String SQL_QUERY_WORKSTATION = "SELECT * FROM MD_WORKSTATION WHERE ID=?";
String SQL_QUERY_INBOUND_POSITION = "SELECT * FROM WMS_INBOUND_POSITION WHERE ENTRYID=?";
String SQL_QUERYSTORAGELOCATION_BYSKU = "SELECT MD_STORAGELOCATION.* \n" +
"FROM MD_STORAGELOCATION,INV_UNITLOAD, INV_STOCKUNIT, MD_ITEMDATA, MD_ITEMDATA_SKUNO \n" +
"WHERE INV_STOCKUNIT.ITEMDATA_ID=MD_ITEMDATA.ID \n" +
"AND INV_UNITLOAD.ID=INV_STOCKUNIT.UNITLOAD_ID \n" +
"AND MD_STORAGELOCATION.ID = INV_UNITLOAD.STORAGELOCATION_ID\n" +
"AND MD_ITEMDATA.ITEM_NO=MD_ITEMDATA_SKUNO.ITEM_NO \n" +
"AND MD_ITEMDATA_SKUNO.SKU_NO=? AND POD_ID IS NOT NULL LIMIT 1";
String WMS_INBOUND_PODORDER = "WMS_INBOUND_PODORDER";
String SQL_QUERY_PODS = "SELECT DISTINCT POD_ID FROM WMS_INBOUND_PODORDER" +
" WHERE PODID NOT IN (SELECT POD_ID FROM RCS_TRIP WHERE TRIP_TYPE=? AND TRIP_STATE=?) " +
" LIMIT 10";
String SQL_QUERY_RUNNINGPODS = "SELECT DISTINCT POD_ID " +
"FROM RCS_TRIP WHERE TRIP_TYPE=? AND TRIP_STATE=? " +
" LIMIT 10";
String SQL_QUERY_PODORDERS = "SELECT * FROM WMS_INBOUND_PODORDER WHERE POD_ID=? AND STATE=? ";
String TABLE_MD_WORKSTATION = "MD_WORKSTATION";
String WMS_INBOUND_ORDER = "WMS_INBOUND_ORDER";
String WMS_INBOUND_ORDERPOSITION = "WMS_INBOUND_ORDERPOSITION";
String WMS_OUTBOUND_ORDER = "WMS_OUTBOUND_ORDER";
String WMS_OUTBOUND_ORDERPOSITION = "WMS_OUTBOUND_ORDERPOSITION";
}
package com.mushiny.heli.xnr.service;
import com.mushiny.heli.xnr.comm.CommonUtils;
import com.mushiny.heli.xnr.jdbc.repositories.JdbcRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Created by Tank.li on 2017/7/25.
*/
@Component
@org.springframework.core.annotation.Order(value = 0)
public class SystemPropertiesManager implements CommandLineRunner {
private final static Logger logger = LoggerFactory.getLogger(SystemPropertiesManager.class);
@Autowired
private JdbcRepository jdbcRepository;
private Map<SysKey,String> properties = new ConcurrentHashMap<>();
public String getProperty(String key,String wareHouseId){
return properties.get(new SysKey(wareHouseId,key));
}
@Override
public void run(String... strings) throws Exception {
loadSystemProperties();
}
@Scheduled(fixedDelay = 100000l)
public void loadSystemProperties() {
/*SYSTEM_KEY` varchar(255) NOT NULL,
`SYSTEM_VALUE` varchar(255) NOT NULL,
`WAREHOUSE_ID` varchar(255) NOT NULL,*/
logger.debug("加载系统参数信息.....");
List<Map> rows = this.jdbcRepository.queryByKey("SystemPropertiesManager.loadSystemProperty");
for (int i = 0; i < rows.size(); i++) {
Map row = rows.get(i);
String WAREHOUSE_ID = CommonUtils.parseString("WAREHOUSE_ID",row);
String SYSTEM_KEY = CommonUtils.parseString("SYSTEM_KEY",row);
String SYSTEM_VALUE = CommonUtils.parseString("SYSTEM_VALUE",row);
properties.put(new SysKey(WAREHOUSE_ID,SYSTEM_KEY), SYSTEM_VALUE);
}
logger.debug("加载系统参数信息结束:"+properties);
}
private class SysKey{
private String wareHouseId;
private String key;
public SysKey(String wareHouseId, String key) {
this.wareHouseId = wareHouseId;
this.key = key;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SysKey sysKey = (SysKey) o;
if (wareHouseId != null ? !wareHouseId.equals(sysKey.wareHouseId) : sysKey.wareHouseId != null)
return false;
return key != null ? key.equals(sysKey.key) : sysKey.key == null;
}
@Override
public int hashCode() {
int result = wareHouseId != null ? wareHouseId.hashCode() : 0;
result = 31 * result + (key != null ? key.hashCode() : 0);
return result;
}
}
}
package com.mushiny.heli.xnr.service;
import com.mushiny.heli.xnr.comm.CommonUtils;
import com.mushiny.heli.xnr.comm.JsonUtils;
import com.mushiny.heli.xnr.dto.InboundOrderDTO;
import com.mushiny.heli.xnr.dto.InboundOrderPosition;
import com.mushiny.heli.xnr.dto.OutboundOrderDTO;
import com.mushiny.heli.xnr.dto.OutboundOrderPosition;
import com.mushiny.heli.xnr.jdbc.repositories.JdbcRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by Lisi on 2019-11-18.
*/
@Service
public class WMSRespService {
private final static Logger logger = LoggerFactory.getLogger(WMSRespService.class);
public static final String SQL_QUERYALL_INBOUNDORDER =
"SELECT * FROM WMS_INBOUND_ORDER ,WMS_INBOUND_ORDERPOSITION " +
"WHERE WMS_INBOUND_ORDER.ENTRYID=WMS_INBOUND_ORDERPOSITION.ENTRYID " +
"AND WMS_INBOUND_ORDER.STATE=? AND NEED_RESP=1";
private static final String SQL_QUERYALL_OUTBOUNDORDER =
"SELECT * FROM WMS_OUTBOUND_ORDER ,WMS_OUTBOUND_ORDERPOSITION " +
"WHERE WMS_OUTBOUND_ORDER.ORDERID=WMS_OUTBOUND_ORDERPOSITION.ORDERID " +
"AND WMS_OUTBOUND_ORDER.STATE=? AND NEED_RESP=1";
public static final String TABLE_OBORDER = "WMS_OUTBOUND_ORDER";
public static final String TABLE_IBORDER = "WMS_INBOUND_ORDER";
public static final String SQL_QUERYALL_ICQAORDER =
"SELECT * FROM WMS_ICQA_ORDER,WMS_ICQA_ORDERPOSITION " +
"WHERE WMS_ICQA_ORDER.TASKID = WMS_ICQA_ORDERPOSITION.TASKID " +
"AND WMS_ICQA_ORDER.STATE=? AND NEED_RESP=1";
@Value("${mushiny.heli.wms.inboundResp.url}")
private String inboundResp_url;
@Value("${mushiny.heli.wms.outboundResp.url}")
private String outboundResp_url;
//mushiny.heli.wms.icqaResp.url=http://localhost/heli/icqaResp
@Value("${mushiny.heli.wms.icqaResp.url}")
private String icqaResp_url;
public static final String FINISH = "Finish";
public static final String AVAILABLE = "Available";
public static final String PROCESS = "Process";
private final RestTemplateBuilder builder;
@Autowired
private JdbcRepository jdbcRepository;
@Autowired
public WMSRespService(RestTemplateBuilder builder) {
this.builder = builder;
}
@Scheduled(fixedDelay = 50*1000L)
@Transactional
public void icqaResp(){
logger.debug("回复盘点任务状态....");
RestTemplate restTemplate = builder.build();
HttpHeaders headers = this.getHttpHeaders();
List<Map> data = this.jdbcRepository.queryBySql(SQL_QUERYALL_ICQAORDER,FINISH);
List<InboundOrderDTO> data2 = this.transfer2InDTO(data);//合并主表记录
for (int i = 0; i < data2.size(); i++) {
InboundOrderDTO inboundOrderDTO = data2.get(i);
String json = JsonUtils.bean2Json(inboundOrderDTO);
logger.debug("post data: " + json);
HttpEntity<String> httpEntity = new HttpEntity<String>(json, headers);
ResponseEntity<String> res = restTemplate.postForEntity(this.inboundResp_url, httpEntity, String.class);
Map result = JsonUtils.json2Map(res.getBody());
logger.debug("result: " + result);
if(CommonUtils.parseInteger("CODE",result) == 0){
logger.debug("成功回调"+inboundOrderDTO.getENTRYID());
Map newValue = new HashMap();
newValue.put("NEED_RESP",2);
Map con = new HashMap();
con.put("ENTRYID",inboundOrderDTO.getENTRYID());
this.jdbcRepository.updateRecords(TABLE_IBORDER,newValue,con);
}
}
//检查是否有明细已完成 需要将主表记录更新为完成Finish
}
@Scheduled(fixedDelay = 50*1000L)
@Transactional
public void inboundResp(){
logger.debug("回复入库单状态....");
RestTemplate restTemplate = builder.build();
HttpHeaders headers = this.getHttpHeaders();
List<Map> data = this.jdbcRepository.queryBySql(SQL_QUERYALL_INBOUNDORDER,FINISH);
List<InboundOrderDTO> data2 = this.transfer2InDTO(data);//合并主表记录
for (int i = 0; i < data2.size(); i++) {
InboundOrderDTO inboundOrderDTO = data2.get(i);
String json = JsonUtils.bean2Json(inboundOrderDTO);
logger.debug("post data: " + json);
HttpEntity<String> httpEntity = new HttpEntity<String>(json, headers);
ResponseEntity<String> res = restTemplate.postForEntity(this.inboundResp_url, httpEntity, String.class);
Map result = JsonUtils.json2Map(res.getBody());
logger.debug("result: " + result);
if(CommonUtils.parseInteger("CODE",result) == 0){
logger.debug("成功回调"+inboundOrderDTO.getENTRYID());
Map newValue = new HashMap();
newValue.put("NEED_RESP",2);
Map con = new HashMap();
con.put("ENTRYID",inboundOrderDTO.getENTRYID());
this.jdbcRepository.updateRecords(TABLE_IBORDER,newValue,con);
}
}
}
private HttpHeaders getHttpHeaders() {
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
return headers;
}
@Scheduled(fixedDelay = 50*1000L)
@Transactional
public void outboundResp(){
logger.debug("回复入库单状态....");
RestTemplate restTemplate = builder.build();
HttpHeaders headers = this.getHttpHeaders();
List<Map> data = this.jdbcRepository.queryBySql(SQL_QUERYALL_OUTBOUNDORDER,FINISH);
List<OutboundOrderDTO> data2 = this.transfer2OutDTO(data);//合并主表记录
for (int i = 0; i < data2.size(); i++) {
OutboundOrderDTO outboundOrderDTO = data2.get(i);
String json = JsonUtils.bean2Json(outboundOrderDTO);
logger.debug("post data: " + json);
HttpEntity<String> httpEntity = new HttpEntity<String>(json, headers);
ResponseEntity<String> res = restTemplate.postForEntity(this.outboundResp_url, httpEntity, String.class);
Map result = JsonUtils.json2Map(res.getBody());
logger.debug("result: " + result);
if(CommonUtils.parseInteger("CODE",result) == 0){
logger.debug("成功回调"+outboundOrderDTO.getORDERID());
Map newValue = new HashMap();
newValue.put("NEED_RESP",2);
Map con = new HashMap();
con.put("ORDERID",outboundOrderDTO.getORDERID());
this.jdbcRepository.updateRecords(TABLE_OBORDER,newValue,con);
}
}
//如果明细都已结束 将主表更新为已完成,减少操作时的判断
List<Map> list = this.jdbcRepository
.queryBySql(Sql_Table.SQL_QUERY_INBOUNDORDER_BYPOSITIONSTATE, Sql_Table.FINISH);
for (int i = 0; i < list.size(); i++) {
Map rows = list.get(i);
Map newValue = new HashMap();
newValue.put("STATE", Sql_Table.FINISH);
Map con = new HashMap();
con.put("ENTRYID",CommonUtils.parseString("ENTRYID",rows));
this.jdbcRepository.updateRecords(Sql_Table.WMS_INBOUND_PODORDER,newValue,con);
}
}
private List<OutboundOrderDTO> transfer2OutDTO(List<Map> data) {
Map<String,OutboundOrderDTO> temp = new HashMap();
for (int i = 0; i < data.size(); i++) {
Map map = data.get(i);
String entryId = (String) map.get("ENTRYID");
if(temp.get(entryId) == null){
OutboundOrderDTO outboundOrderDTO = new OutboundOrderDTO();
outboundOrderDTO.setORDERID(entryId);
outboundOrderDTO.setSECTION((String) map.get("SECTION"));
outboundOrderDTO.setFACTORY((String) map.get("FACTORY"));
outboundOrderDTO.setTIMES(CommonUtils.parseInteger("TIMES",map));
outboundOrderDTO.setDATA(new ArrayList<>());
temp.put(entryId,outboundOrderDTO);
}
OutboundOrderDTO outboundOrderDTO = temp.get(entryId);
//每行一条明细记录
OutboundOrderPosition outboundOrderPosition = new OutboundOrderPosition();
outboundOrderPosition.setSHIPMENTID(CommonUtils.parseString("SHIPMENTID",map));
outboundOrderPosition.setSKUID(CommonUtils.parseString("SKUID",map));
outboundOrderPosition.setAMOUNT(CommonUtils.parseInteger("AMOUNT",map));
outboundOrderPosition.setMSG(CommonUtils.parseString("MSG",map));
outboundOrderPosition.setSTATE(CommonUtils.parseString("STATE",map));
outboundOrderPosition.setPICKED(CommonUtils.parseInteger("PICKED",map));
outboundOrderDTO.getDATA().add(outboundOrderPosition);
}
//返回所有
return new ArrayList<>(temp.values());
}
private List<InboundOrderDTO> transfer2InDTO(List<Map> data) {
Map<String,InboundOrderDTO> temp = new HashMap();
for (int i = 0; i < data.size(); i++) {
Map map = data.get(i);
String entryId = (String) map.get("ENTRYID");
if(temp.get(entryId) == null){
InboundOrderDTO inboundOrderDTO = new InboundOrderDTO();
inboundOrderDTO.setENTRYID(entryId);
inboundOrderDTO.setSECTION((String) map.get("SECTION"));
inboundOrderDTO.setFACTORY((String) map.get("FACTORY"));
inboundOrderDTO.setTIMES(CommonUtils.parseInteger("TIMES",map));
inboundOrderDTO.setDATA(new ArrayList<>());
temp.put(entryId,inboundOrderDTO);
}
InboundOrderDTO inboundOrderDTO = temp.get(entryId);
//每行一条明细记录
InboundOrderPosition inboundOrderPosition = new InboundOrderPosition();
inboundOrderPosition.setSKUID((String) map.get("SKUID"));
inboundOrderPosition.setAMOUNT(CommonUtils.parseInteger("AMOUNT",map));
inboundOrderPosition.setMSG(CommonUtils.parseString("MSG",map));
inboundOrderPosition.setSTATE(CommonUtils.parseString("STATE",map));
inboundOrderPosition.setSTORED(CommonUtils.parseInteger("STORED",map));
inboundOrderDTO.getDATA().add(inboundOrderPosition);
}
//返回所有
return new ArrayList<>(temp.values());
}
}
package com.mushiny.heli.xnr.service;
import com.mushiny.heli.xnr.beans.BaseBpo;
import com.mushiny.heli.xnr.comm.CommonUtils;
import com.mushiny.heli.xnr.comm.JsonUtils;
import com.mushiny.heli.xnr.dto.*;
import com.mushiny.heli.xnr.jdbc.repositories.JdbcRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Date;
import java.util.*;
/**
* Lisi @ 2019-11-18
*/
@Service
public class WMSService {
@Autowired
private JdbcRepository jdbcRepository;
private final static Logger logger = LoggerFactory.getLogger(WMSService.class);
@Transactional
public void saveInboundOrder(InboundOrderDTO inboundOrderDTO){
List<InboundOrderPosition> data = inboundOrderDTO.getDATA();
for (int i = 0; i < data.size(); i++) {
InboundOrderPosition inboundOrderPosition = data.get(i);
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.WMS_INBOUND_ORDERPOSITION);
baseBpo.setIdName("ID");
baseBpo.addKV("ENTRYID",inboundOrderDTO.getENTRYID());
baseBpo.addKV("AMOUNT",inboundOrderPosition.getAMOUNT());
baseBpo.addKV("SKUID",inboundOrderPosition.getSKUID());
baseBpo.addKV("ID",CommonUtils.genUUID());
baseBpo.addKV("WAREHOUSE_ID",inboundOrderDTO.getFACTORY());
baseBpo.addKV("SECTION_ID",inboundOrderDTO.getSECTION());
baseBpo.addKV("STATE", Sql_Table.AVAILABLE);
this.jdbcRepository.insertBusinessObject(baseBpo);
}
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.WMS_INBOUND_ORDER);
baseBpo.setIdName("ENTRYID");
baseBpo.addKV("TIMES",inboundOrderDTO.getTIMES());
baseBpo.addKV("WAREHOUSE_ID",inboundOrderDTO.getFACTORY());
baseBpo.addKV("SECTION_ID",inboundOrderDTO.getSECTION());
baseBpo.addKV("ENTRYID",inboundOrderDTO.getENTRYID());
this.jdbcRepository.insertBusinessObject(baseBpo);
}
@Transactional
public void saveOutboundOrder(OutboundOrderDTO outboundOrderDTO) {
List<OutboundOrderPosition> data = outboundOrderDTO.getDATA();
for (int i = 0; i < data.size(); i++) {
OutboundOrderPosition outboundOrderPosition = data.get(i);
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.WMS_OUTBOUND_ORDERPOSITION);
baseBpo.setIdName("ID");
baseBpo.addKV("ID",CommonUtils.genUUID());
baseBpo.addKV("ORDERID",outboundOrderDTO.getORDERID());
baseBpo.addKV("AMOUNT",outboundOrderPosition.getAMOUNT());
baseBpo.addKV("SKUID",outboundOrderPosition.getSKUID());
baseBpo.addKV("SHIPMENTID",outboundOrderPosition.getSHIPMENTID());
baseBpo.addKV("WAREHOUSE_ID",outboundOrderDTO.getFACTORY());
baseBpo.addKV("SECTION_ID",outboundOrderDTO.getSECTION());
this.jdbcRepository.insertBusinessObject(baseBpo);
}
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.WMS_OUTBOUND_ORDER);
baseBpo.setIdName("ORDERID");
baseBpo.addKV("TIMES",outboundOrderDTO.getTIMES());
baseBpo.addKV("WAREHOUSE_ID",outboundOrderDTO.getFACTORY());
baseBpo.addKV("SECTION_ID",outboundOrderDTO.getSECTION());
baseBpo.addKV("ORDERID",outboundOrderDTO.getORDERID());
this.jdbcRepository.insertBusinessObject(baseBpo);
}
/* `ID` varchar(255) NOT NULL,
`ITEM_NO` varchar(255) NOT NULL DEFAULT '' COMMENT '唯一编码',
`SKU_NO` varchar(255) DEFAULT '' COMMENT 'SKU',
`NAME` varchar(255) NOT NULL DEFAULT '' COMMENT '名称',
`SAFETY_STOCK` int(11) NOT NULL COMMENT '安全库存',
`LOT_MANDATORY` bit(1) NOT NULL COMMENT '是否有效期商品',
`SERIAL_RECORD_TYPE` varchar(255) NOT NULL DEFAULT '' COMMENT '商品的序列号码有规则的设置', NO_RECORD
`HEIGHT` decimal(15,2) DEFAULT NULL COMMENT '高',
`WIDTH` decimal(15,2) DEFAULT NULL COMMENT '长',
`DEPTH` decimal(15,2) DEFAULT NULL COMMENT '宽',
`MULTIPLE_PART` bit(1) NOT NULL COMMENT '是否一套',
`MULTIPLE_PART_AMOUNT` int(11) NOT NULL COMMENT '几套几件',
`MEASURED` bit(1) NOT NULL COMMENT '是否测量',
`PREFER_OWNBOX` bit(1) NOT NULL COMMENT '是否自带包装',
`PREFER_BAG` bit(1) NOT NULL COMMENT '是否用袋子',
`USE_BUBBLEFILM` bit(1) NOT NULL COMMENT '是否使用气垫膜',
`ITEMGROUP_ID` varchar(255) NOT NULL DEFAULT '' COMMENT '商品类型',
`HANDLINGUNIT_ID` varchar(255) NOT NULL DEFAULT '' COMMENT '商品单位',
`VERSION` int(11) NOT NULL,*/
/*保存到商品信息表*/
public static final String ITEM_GROUP = "fd335ce3-1b83-4819-81d9-34f8aa5a2139";
public static final String HANDLING_UNIT_ID = "d7599399-3da6-478c-b14d-60e6be6ef11e";
public void syncItem(ItemDTO itemDTO) {
List<Map> skus = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERYITEM_BYSKUNO, itemDTO.getSKUID());
List<Map> rows = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERYITEM_BYID, itemDTO.getSKUID());
if (skus.isEmpty() || rows.isEmpty()){
//新建一条
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.TABLE_MD_ITEMDATA);
baseBpo.addKV("ID",itemDTO.getSKUID()).addKV("ITEM_NO",itemDTO.getSKUID())/*.addKV("SKU_NO",itemDTO.getSKUID())*/;
baseBpo.addKV("NAME",itemDTO.getSNAME()).addKV("LOT_MANDATORY",0).addKV("SERIAL_RECORD_TYPE","NO_RECORD");
baseBpo.addKV("HEIGHT",itemDTO.getHEIGHT()).addKV("WIDTH",itemDTO.getWIDTH()).addKV("DEPTH",itemDTO.getLENGTH());
baseBpo.addKV("MULTIPLE_PART",Boolean.FALSE).addKV("MULTIPLE_PART_AMOUNT",0).addKV("MEASURED",Boolean.TRUE);
baseBpo.addKV("PREFER_OWNBOX",Boolean.FALSE).addKV("PREFER_BAG",Boolean.FALSE).addKV("USE_BUBBLEFILM",Boolean.FALSE);
baseBpo.addKV("ITEMGROUP_ID",ITEM_GROUP).addKV("HANDLINGUNIT_ID",HANDLING_UNIT_ID).addKV("VERSION",itemDTO.getSTATUS());
baseBpo.addKV("CLIENT_ID",itemDTO.getFACTORY()).addKV("WAREHOUSE_ID",itemDTO.getSECTION());
baseBpo.addKV("SAFETY_STOCK",0);
//增加工厂和仓库 一个工厂多个仓库 一个工厂我们认为是CLIENT_ID户主 一个WAREHOUSE_ID是一个仓库
BaseBpo baseBpo2 = new BaseBpo();
baseBpo2.setTable(Sql_Table.TABLE_MD_ITEMDATA_SKUNO);
baseBpo2.addKV("CLIENT_ID",itemDTO.getFACTORY()).addKV("ITEM_NO",itemDTO.getSKUID()).addKV("SKU_NO",itemDTO.getSKUID());
baseBpo2.addKV("ID",CommonUtils.genUUID());
this.jdbcRepository.insertBusinessObject(baseBpo);
}else{
//根据ID更新 ID暂定跟SKU_NO ITEM_NO 一样
BaseBpo baseBpo = new BaseBpo();
//baseBpo.addKV("ID",itemDTO.getSKUID()).addKV("ITEM_NO",itemDTO.getSKUID()).addKV("SKU_NO",itemDTO.getSKUID());
baseBpo.addKV("NAME",itemDTO.getSNAME()).addKV("LOT_MANDATORY",0).addKV("SERIAL_RECORD_TYPE","NO_RECORD");
baseBpo.addKV("HEIGHT",itemDTO.getHEIGHT()).addKV("WIDTH",itemDTO.getWIDTH()).addKV("DEPTH",itemDTO.getLENGTH());
baseBpo.addKV("MULTIPLE_PART",Boolean.FALSE).addKV("MULTIPLE_PART_AMOUNT",0).addKV("MEASURED",Boolean.TRUE);
baseBpo.addKV("PREFER_OWNBOX",Boolean.FALSE).addKV("PREFER_BAG",Boolean.FALSE).addKV("USE_BUBBLEFILM",Boolean.FALSE);
baseBpo.addKV("ITEMGROUP_ID",ITEM_GROUP).addKV("HANDLINGUNIT_ID",HANDLING_UNIT_ID).addKV("VERSION",itemDTO.getSTATUS());
baseBpo.addKV("CLIENT_ID",itemDTO.getFACTORY()).addKV("WAREHOUSE_ID",itemDTO.getSECTION());
baseBpo.setIdName("ID");
baseBpo.setTable(Sql_Table.TABLE_MD_ITEMDATA);
baseBpo.setId(itemDTO.getSKUID());
this.jdbcRepository.updateBusinessObject(baseBpo);
}
}
public MessageDTO createICQAOrder(Map data) {
MessageDTO messageDTO = MessageDTO.success();
BaseBpo order = new BaseBpo();
order.setTable(Sql_Table.WMS_ICQA_ORDER);
String orderId = CommonUtils.genUUID();
order.addKV("ICQAID", orderId);
order.addKV("CREATED_DATE",new Date(System.currentTimeMillis()));
order.addKV("FACTORY",CommonUtils.parseString("FACTORY",data));
order.addKV("SECTION",CommonUtils.parseString("SECTION",data));
order.addKV("SECTION",CommonUtils.parseString("SECTION",data));
if(CommonUtils.parseInteger("ALL",data)==1){
//检查是否有全盘在执行 如果没完成不能再生成
List<Map> rows = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_ICQA_BY_TYPE,"Finish");
if(rows!=null && rows.size()>0){
messageDTO.setCODE(1);
messageDTO.setMESSAGE("已有全库盘点任务,不能再次生成!");
return messageDTO;
}
//全盘 所有SKU生成盘点任务
List<Map> items= this.jdbcRepository.queryBySql(Sql_Table.SQL_FINDALLITEM
,CommonUtils.parseString("FACTORY",data)
,CommonUtils.parseString("SECTION",data));
for (int i = 0; i < items.size(); i++) {
Map map = items.get(i);
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.WMS_ICQA_ORDERPOSITION);
baseBpo.addKV("ICQAID",orderId).addKV("ID",CommonUtils.genUUID())
.addKV("SKUID",CommonUtils.parseString("ID",map));
this.jdbcRepository.insertBusinessObject(baseBpo);
}
}else{
//从 DATA选sku
List<Map> skus = (List<Map>) data.get("DATA");
//查找所有存在盘点任务的SKU过滤
List<Map> allTaskingSKU = this.jdbcRepository.queryBySql(Sql_Table.SQL_ALL_TASKING_SKU,"Finish");
Set<String> allSku = this.list2Set(allTaskingSKU);
List exist = new ArrayList();
for (int i = 0; i < skus.size(); i++) {
Map row = skus.get(i);
String skuId = CommonUtils.parseString("SKUID",row);
if(allSku.contains(skuId)){
logger.debug("SKU已存在盘点任务:" + skuId);
exist.add(skuId);
}
}
if(!exist.isEmpty()){
messageDTO.setCODE(1);
messageDTO.setMESSAGE("以下"+JsonUtils.list2Json(exist)+"盘点任务未完成!");
return messageDTO;
}
//没有存在的盘点任务就生成
for (int i = 0; i < skus.size(); i++) {
Map row = skus.get(i);
String skuId = CommonUtils.parseString("SKUID",row);
if(allSku.contains(skuId)){
logger.debug("SKU已存在盘点任务:" + skuId);
continue;
}
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.WMS_ICQA_ORDERPOSITION);
baseBpo.addKV("ICQAID",orderId).addKV("ID",CommonUtils.genUUID())
.addKV("SKUID",CommonUtils.parseString("ID",row));
this.jdbcRepository.insertBusinessObject(baseBpo);
}
}
this.jdbcRepository.insertBusinessObject(order);
return messageDTO;
}
private Set<String> list2Set(List<Map> allTaskingSKU) {
Set set = new HashSet();
for (int i = 0; i < allTaskingSKU.size(); i++) {
Map map = allTaskingSKU.get(i);
set.add(map.get("SKUID"));
}
return set;
}
}
server.port=8000
spring.datasource.url=jdbc:mysql://192.168.1.240:3307/wms_heli
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
mushiny.heli.wms.inboundResp.url=http://localhost/heli/inboundResp
mushiny.heli.wms.outboundResp.url=http://localhost/heli/outboundResp
mushiny.heli.wms.icqaResp.url=http://localhost/heli/icqaResp
#log
logging.level.root=ERROR
logging.level.org.springframework=ERROR
logging.level.com.mushiny=DEBUG
logging.config=classpath:logback-spring.xml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<!--<property name="LOG_HOME" value="/home" />-->
<!-- 开发环境变量develop-->
<springProfile name="dev">
<property name="LOG_HOME" value="E:/SpDevLogs"/>
</springProfile>
<!-- 生成环境变量product-->
<springProfile name="pro">
<property name="LOG_HOME" value="/home/mushiny/wms_v8"/>
</springProfile>
<!--RobotManager_FILE-->
<appender name="WCS_SERVER_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--<file>E:/logs/mylog.txt</file>-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>./WCS_%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxHistory>5</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>500MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{36} %M [%file : %line] %msg%n</pattern>
</encoder>
</appender>
<!--MQ收发日志文件输出-->
<appender name="MQ_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--<file>E:/logs/mylog.txt</file>-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>./MQ_%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxHistory>5</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>500MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{36} [%file : %line] %msg%n</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} %M - %msg%n</pattern>
</encoder>
</appender>
<!-- 日志文件:按照每天生成 -->
<root level="ERROR">
<!-- 日志输出地点,输出一个就行 -->
<appender-ref ref="STDOUT"/>
</root>
<logger name="com.mushiny" level="DEBUG" additivity="false">
<!--<appender-ref ref="WCS_SERVER_FILE"/>-->
<appender-ref ref="STDOUT"/>
</logger>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="sqlMapper" class="com.mushiny.heli.xnr.jdbc.config.SqlMapper">
<property name="sqls">
<props>
<prop key="HOT.SERVICE.QUERYALLSHIPMENTLINE">
<![CDATA[SELECT COUNT(*) AS COUNTSHIPMENTS FROM OB_CUSTOMERSHIPMENTPOSITION WHERE STATE<600 AND CREATED_DATE<=?]]>
</prop>
<prop key="SystemPropertiesManager.loadSystemProperty">
<![CDATA[SELECT SYSTEM_KEY,SYSTEM_VALUE,WAREHOUSE_ID FROM SYS_SYSTEMPROPERTY]]><!--TODO-->
</prop>
</props>
</property>
</bean>
</beans>
\ No newline at end of file
package com.mushiny.heli.xnr;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class XnrInterfaceApplicationTests {
@Test
void contextLoads() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment