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/
This diff is collapsed.
@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();
}
This diff is collapsed.
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;
/**
* 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;
}
}
This diff is collapsed.
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;
}
}
}
This diff is collapsed.
This diff is collapsed.
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