Commit 7f895f3a by 春觉晓

初始化策略中心rop

0 parents
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rop</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj.strategy</groupId>
<artifactId>rop-dj-strategy</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj.strategy</groupId>
<artifactId>rpc-dj-strategy-api</artifactId>
<version>5.5.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rop-common</artifactId>
<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-smartcarlife-api</artifactId>
<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-smartcarlife-api</artifactId>
<version>5.3.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.com.glsx.dj.strategy;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
@SpringBootApplication
@ServletComponentScan
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
\ No newline at end of file
package cn.com.glsx.dj.strategy.constant;
/**
* 公共常量
* @author yangwei
* @version 1.0
* @since 2025/10/27 14:18
*/
public interface CommonConstants {
/** 必填项 */
String REQUIRED_TRUE = "存在必填字段为空";
}
package cn.com.glsx.dj.strategy.constant;
/**
* 配置中心相关常量
* @author yangwei
* @version 1.0
* @since 2025/10/23 16:00
*/
public interface ConfigCenterConstants {
/** 配置中心-excel模板路径 */
String GOP_EXCEL_TEMP_PATH = "gop.excel.tem.path";
/** excel 临时文件静态资源路径 */
String GOP_EXCEL_TEM_URL = "gop.excel.tem.url";
}
package cn.com.glsx.dj.strategy.constant;
/**
* 分页相关静态常量
* @author yangwei
* @version 1.0
* @since 2025/10/15 10:02
*/
public interface PageConstants {
/** 页码1 */
Integer PAGE_NUM = 1;
/** 页数据量 9999 */
Integer PAGE_SIZE = 9999;
}
package cn.com.glsx.dj.strategy.constant;
/**
* 手机号校验正则
* @author yangwei
* @version 1.0
* @since 2025/10/22 16:49
*/
public interface RegExpConstants {
/** 手机号校验正则 */
String PHONE_REGEX = "^1(3\\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$";
}
package cn.com.glsx.dj.strategy.constant;
public interface RopConstants {
/** 登录信息session**/
final String LOGIN_SESSION = "ROP_USER";
/** 登录令牌存贮有效期(单位:秒)**/
final int LOGIN_TOKEN_EXPIRE_TIME = 5 * 60;
/** 登录跳转地址**/
final String LOGIN_REDIRECT_URL = "/loginByToken?token=";
/** WEB SOCKET SESSION缓存前缀**/
final String LOGIN_WS_SESSION_PREFIX = "SMARTCARLIFE_LOGIN_WS_SESSION_";
/**选择登录令牌 **/
public static final String LOGIN_SELECT_TOKEN = "SMARTCARLIFE_LOGIN_SELECT_";
}
package cn.com.glsx.dj.strategy.controller;
import cn.com.glsx.dj.strategy.uitl.CommonUtil;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.AbstractRopRequest;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("策略中心-策略信息")
public class StrategyInfoController {
@ApiOperation("创建策略")
@ServiceMethod(method = "dj.api.strategy.info.create")
public RopResponse<Boolean> create(AbstractRopRequest request) {
String accountName = CommonUtil.getAccountName();
try {
log.info("=====创建策略 accountName:{}", accountName);
return RopResponse.success(true);
} catch (RpcServiceException e) {
log.error("=====AI助理-账号管理-新建账号 rpcServiceException:{}", e.getMessage());
return RopResponse.error(e);
} catch (Exception e) {
log.error("=====AI助理-账号管理-新建账号 exception:{}", e.getMessage(), e);
return RopResponse.error("查询AI助理-账号管理-新建账号 失败");
}
}
}
package cn.com.glsx.dj.strategy.interceptor;
import com.rop.RopServlet;
import com.rop.config.InterceptorHolder;
import org.oreframework.boot.autoconfigure.rop.metadata.RopProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnClass({RopServlet.class})
@EnableConfigurationProperties({RopProperty.class})
public class SmartcarlifeRopAutoConfigure {
@Bean
public InterceptorHolder threadLocalCacheInterceptor() {
return new InterceptorHolder(new ThreadLocalCacheInterceptor());
}
}
package cn.com.glsx.dj.strategy.interceptor;
import com.rop.RopRequestContext;
public class ThreadLocalCache {
private static ThreadLocal<RopRequestContext> ropRequestContextCache = new ThreadLocal<RopRequestContext>();
public static void setRopRequestContext(RopRequestContext ropRequestContext){
ropRequestContextCache.set(ropRequestContext);
}
public static RopRequestContext getRopRequestContext(){
return ropRequestContextCache.get();
}
public static void removeRopRequestContext(){
ropRequestContextCache.remove();
}
}
package cn.com.glsx.dj.strategy.interceptor;
import com.rop.AbstractInterceptor;
import com.rop.RopRequestContext;
public class ThreadLocalCacheInterceptor extends AbstractInterceptor{
@Override
public void beforeService(RopRequestContext ropRequestContext) {
super.beforeService(ropRequestContext);
ThreadLocalCache.setRopRequestContext(ropRequestContext);
}
@Override
public void beforeResponse(RopRequestContext ropRequestContext) {
super.beforeResponse(ropRequestContext);
ThreadLocalCache.removeRopRequestContext();
}
@Override
public int getOrder() {
return Integer.MIN_VALUE;
}
}
package cn.com.glsx.dj.strategy.uitl;
public interface ConvertHandler<T,V> {
V convert(T source);
}
server.port=8594
server.servlet.context-path=/rop-dj-strategy
server.display-name=rop-dj-strategy
logging.config=classpath:logback.xml
logging.path=/data/java_log/jetty/rop-dj-strategy/rop-dj-strategy.log
logging.level.root=INFO
ore.starter.class-name=Main
# diamond config
ore.diamond.group=dijia
ore.diamond.dataId=rop-dj-strategy
ore.diamond.env=release
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<property resource="config/application.properties" />
<property name="APP_NAME" value="${server.display-name}" />
<property name="LOG_PATH" value="${logging.path}" />
<property name="LOG_LEVEL" value="${logging.level}" />
<contextName>${APP_NAME}</contextName>
<turboFilter class="org.oreframework.boot.logging.logback.OreBootTurboFilter">
<Marker>oreframework</Marker>
</turboFilter>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</pattern>
</layout>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <Encoding> Label Old version of this label can not be used -->
<!-- <Encoding>UTF-8</Encoding> -->
<File>${LOG_PATH}</File>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_PATH}.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</layout>
<!-- 根据文件大小滚动,不支持 SizeBasedTriggeringPolicy 这种配置-->
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>200MB</MaxFileSize>
</triggeringPolicy> -->
</appender>
<root level="${LOG_LEVEL}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/name="LOG_PATH"/!d;s/.*value="\(.*\)".*/\1/g' classes/logback.xml`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
DUMP_DIR=$LOGS_DIR/dump
if [ ! -d $DUMP_DIR ]; then
mkdir $DUMP_DIR
fi
DUMP_DATE=`date +%Y%m%d%H%M%S`
DATE_DIR=$DUMP_DIR/$DUMP_DATE
if [ ! -d $DATE_DIR ]; then
mkdir $DATE_DIR
fi
echo -e "Dumping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
echo -e ".\c"
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
echo -e ".\c"
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
echo -e ".\c"
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
echo -e ".\c"
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
echo -e ".\c"
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
echo -e ".\c"
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
echo -e ".\c"
if [ -r /usr/sbin/lsof ]; then
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
echo -e ".\c"
fi
done
if [ -r /bin/netstat ]; then
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/iostat ]; then
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/mpstat ]; then
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/vmstat ]; then
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/free ]; then
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/sar ]; then
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/uptime ]; then
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
echo -e ".\c"
fi
echo "OK!"
echo "DUMP: $DATE_DIR"
#!/bin/bash
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
./stop.sh
./start.sh $ENV
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
if [ "$1" = "start" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV
else
if [ "$1" = "stop" ]; then
./stop.sh
else
if [ "$1" = "debug" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV debug
else
if [ "$1" = "restart" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./restart.sh $ENV
else
if [ "$1" = "dump" ]; then
./dump.sh
else
echo "ERROR: Please input argument: start or stop or debug or restart or dump"
exit 1
fi
fi
fi
fi
fi
#!/bin/bash
JAVA_HOME="/app/soft/jdk1.8.0_20"
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/server.display-name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
SERVER_PORT=`sed '/server.port/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
LOGS_FILE=`sed '/logging.path/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
echo "server name is $SERVER_NAME"
echo "server port is $SERVER_PORT"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
if [ -n "$SERVER_PORT" ]; then
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$2" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$2" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the $SERVER_NAME ...\c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS org.oreframework.boot.bootstrap.OreBootApplication env=$ENV > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
if [ -n "$SERVER_PORT" ]; then
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
else
COUNT=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
fi
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
#if [ "$1" != "skip" ]; then
#$BIN_DIR/dump.sh
#fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!