Commit d54b26de by 叶立庆

初始化项目

0 parents
Showing 35 changed files with 1241 additions and 0 deletions
# Default ignored files
/shelf/
/workspace.xml
<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-rpc-api</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-supervisor-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>rpc-dj-supervisor-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.dj.supervisor.remote</deploy.scanPackage>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>rpc-api-deploy-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-supervisor-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.dto;
import java.io.Serializable;
/**
* @Title: DemoDTO.java
* @Description:
* @author ${userName}
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@SuppressWarnings("serial")
public class DemoDTO implements Serializable{
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package cn.com.glsx.dj.supervisor.model;
import java.io.Serializable;
/**
* @Title: DemoModel.java
* @Description:
* @author ${userName}
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@SuppressWarnings("serial")
public class DemoModel implements Serializable{
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package cn.com.glsx.dj.supervisor.remote;
import cn.com.glsx.dj.supervisor.model.DemoModel;
import cn.com.glsx.dj.supervisor.dto.DemoDTO;
/**
* @Title: DemoService.java
* @Description:
* @author ${userName}
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
public interface DemoRemote {
DemoModel get(String name);
DemoDTO convert(DemoModel model);
}
# framework-archetype-rpc-api
RPC-API项目骨架
```properties
└─src
├─main
├─java
├─cn.com.glsx.dj.supervisor.dto 数据传输模型层
├─cn.com.glsx.dj.supervisor.enums 枚举定义
├─cn.com.glsx.dj.supervisor.model 数据模型层
└─cn.com.glsx.dj.supervisor.remote RPC暴露服务层
└─resources 资源文件目录
└─rpc
└─dubbo.xml dubbo接口配置
└─pom.xml pom文件
```
```properties
1、API改动后,请及时deploy到Maven仓库
```
```properties
1、rpc-api-deploy-maven-plugin api上报插件需配置当前api的jar包的引用。
```
\ No newline at end of file \ No newline at end of file
<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-rpc</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-supervisor</artifactId>
<version>1.0-SNAPSHOT</version>
<name>rpc-dj-supervisor</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-supervisor-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.14.8</version>
</dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-elasticjob</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
* @Title: Main.java
*/
@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);
}
}
package cn.com.glsx.dj.supervisor.config;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Title: DubboConfig.java
* @Description: Dubbo服务注册配置
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class DubboConfig {
//
// @Autowired
// private ReferenceBuilderFactory factory;
@Autowired
protected ReferenceBuilderFactory factory;
/**
* 注册远程服务(示例)
* RpcRemote为需要调用的远程服务
* @return
*/
/*@Bean
public RpcRemote rpcApiMethodRemote(){
return factory.builder(RpcRemote.class).check(false).timeout(30000).build();
}*/
protected final boolean check = false;
protected final int timeout = 30000;
}
package cn.com.glsx.dj.supervisor.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* @Description todo
* @Author yelq
* @Date 2024/12/25-14:30
* @Version 1.0
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
package cn.com.glsx.dj.supervisor.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: SystemProperty.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Configuration
@ConfigurationProperties("system")
public class SystemProperty {
// 对应配置项:system.name
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package cn.com.glsx.dj.supervisor.converter;
import cn.com.glsx.framework.core.beans.converter.RpcBaseConverter;
import org.mapstruct.Mapper;
import cn.com.glsx.dj.supervisor.model.DemoModel;
import cn.com.glsx.dj.supervisor.dto.DemoDTO;
/**
* @Title: DemoConverter.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Mapper(componentModel = "spring")
public abstract class DemoConverter extends RpcBaseConverter<DemoModel,DemoDTO>{
}
package cn.com.glsx.dj.supervisor.manager;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.supervisor.model.DemoModel;
/**
* @Title: DemoManager.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Service
public class DemoManager{
public DemoModel load(){
return null;
}
}
package cn.com.glsx.dj.supervisor.mapper;
import cn.com.glsx.dj.supervisor.model.DemoModel;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
/**
* @Title: DemoMapper.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Mapper
public interface DemoMapper extends OreMapper<DemoModel> {
DemoModel load();
}
package cn.com.glsx.dj.supervisor.remote;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.supervisor.model.DemoModel;
import cn.com.glsx.dj.supervisor.dto.DemoDTO;
import cn.com.glsx.dj.supervisor.service.DemoService;
import cn.com.glsx.dj.supervisor.converter.DemoConverter;
import org.apache.dubbo.config.annotation.DubboService;
/**
* @Title: DemoRemoteImpl.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@DubboService(retries = 0, timeout = 30000)
public class DemoRemoteImpl implements DemoRemote{
@Autowired
private DemoConverter demoConverter;
@Autowired
private DemoService demoService;
public DemoModel get(String name){
return demoService.load();
}
public DemoDTO convert(DemoModel model){
return demoConverter.convertToTarget(model);
}
}
package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.mapper.DemoMapper;
import cn.com.glsx.dj.supervisor.model.DemoModel;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/**
* @author deployer name
* @version V1.0
* @Title: DemoService.java
* @Description:
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Slf4j
@Service
public class DemoService {
@Autowired
private DemoMapper demoMapper;
@Autowired
private RestTemplate restTemplate;
@Autowired
private Environment env;
public void test() {
String configValue = OrePropertyConfigurer.getString("ore.redis.hostName");
System.out.println(configValue);
}
public DemoModel load() {
return null;
}
}
package cn.com.glsx.dj.supervisor.util;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @author fangfang
* @create 2024-12-19 17:59
*/
public class DateUtil {
//获取每日日期 startdate-->enddate
public static List<String> getDateRangeList(String startdate, String enddate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate start = LocalDate.parse(startdate, formatter);
LocalDate end = LocalDate.parse(enddate, formatter);
List<String> dateList = new ArrayList<>();
while (!start.isAfter(end)) {
dateList.add(start.format(formatter));
start = start.plusDays(1);
}
return dateList;
}
//获取每日日期 enddate-->startdate
public static List<String> getDateRangeListInReverse(String startdate, String enddate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate start = LocalDate.parse(startdate, formatter);
LocalDate end = LocalDate.parse(enddate, formatter);
List<String> dateList = new ArrayList<>();
while (!end.isBefore(start)) {
dateList.add(end.format(formatter));
end = end.minusDays(1);
}
return dateList;
}
//获取每月1号 startdate -->enddate
public static List<String> getFirstDayOfEachMonthFirst(String startdate, String enddate) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date start = sdf.parse(startdate);
Date end = sdf.parse(enddate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
List<String> resultList = new ArrayList<>();
// 将时间设置为所在月的第一天
calendar.set(Calendar.DAY_OF_MONTH, 1);
while (calendar.getTime().getTime() <= end.getTime()) {
resultList.add(sdf.format(calendar.getTime()));
// 移到下一个月的第一天
calendar.add(Calendar.MONTH, 1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
}
return resultList;
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<>();
}
}
//获取每月1号 enddate-->startdate
public static List<String> getFirstDayOfEachMonthFirstInReverse(String startdate, String enddate) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date start = sdf.parse(startdate);
Date end = sdf.parse(enddate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(end);
List<String> resultList = new ArrayList<>();
// 将时间设置为所在月的第一天
calendar.set(Calendar.DAY_OF_MONTH, 1);
while (calendar.getTime().getTime() >= start.getTime()) {
resultList.add(sdf.format(calendar.getTime()));
// 移到上一个月的第一天
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
}
return resultList;
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<>();
}
}
//获取每月1号 startdate -->enddate
public static List<String> getFirstDayOfEachMonth(String startdate, String enddate) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
try {
Date start = sdf.parse(startdate);
Date end = sdf.parse(enddate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
List<String> resultList = new ArrayList<>();
// 将时间设置为所在月的第一天
calendar.set(Calendar.DAY_OF_MONTH, 1);
while (calendar.getTime().getTime() <= end.getTime()) {
resultList.add(sdf.format(calendar.getTime()));
// 移到下一个月的第一天
calendar.add(Calendar.MONTH, 1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
}
return resultList;
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<>();
}
}
//获取每月1号 enddate-->startdate
public static List<String> getFirstDayOfEachMonthInReverse(String startdate, String enddate) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
try {
Date start = sdf.parse(startdate);
Date end = sdf.parse(enddate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(end);
List<String> resultList = new ArrayList<>();
// 将时间设置为所在月的第一天
calendar.set(Calendar.DAY_OF_MONTH, 1);
while (calendar.getTime().getTime() >= start.getTime()) {
resultList.add(sdf.format(calendar.getTime()));
// 移到上一个月的第一天
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
}
return resultList;
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<>();
}
}
//yyyy-MM-dd
public static List<String> getFirstDayOfMonthsToEndOfYear(String startdate, String enddate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate start = LocalDate.parse(startdate, formatter);
int currentYear = start.getYear();
LocalDate end = LocalDate.of(currentYear, 12, 1);
List<String> resultList = new ArrayList<>();
LocalDate current = start.withDayOfMonth(1);
while (!current.isAfter(end)) {
resultList.add(current.format(formatter));
current = current.plusMonths(1).withDayOfMonth(1);
}
return resultList;
}
public static List<String> getFirstDayOfMonthsToStartOfYearInReverse(String startdate, String enddate) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date start = sdf.parse(startdate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
int currentYear = calendar.get(Calendar.YEAR);
Calendar endCalendar = Calendar.getInstance();
endCalendar.set(currentYear, Calendar.JANUARY, 1);
List<String> resultList = new ArrayList<>();
Calendar currentCalendar = Calendar.getInstance();
currentCalendar.set(currentYear, Calendar.DECEMBER, 1);
while (currentCalendar.getTime().getTime() >= endCalendar.getTime().getTime()) {
resultList.add(sdf.format(currentCalendar.getTime()));
currentCalendar.add(Calendar.MONTH, -1);
currentCalendar.set(Calendar.DAY_OF_MONTH, 1);
}
return resultList;
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<>();
}
}
//yyyy-MM
public static List<String> getYearofEveryMonth(String startdate, String enddate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate start = LocalDate.parse(startdate, formatter);
int currentYear = start.getYear();
LocalDate end = LocalDate.of(currentYear, 12, 1);
List<String> resultList = new ArrayList<>();
LocalDate current = start.withDayOfMonth(1);
while (!current.isAfter(end)) {
resultList.add(current.format(formatter));
current = current.plusMonths(1).withDayOfMonth(1);
}
return resultList;
}
public static List<String> getYearofEveryMonthReverse(String startdate, String enddate) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
try {
Date start = sdf.parse(startdate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
int currentYear = calendar.get(Calendar.YEAR);
Calendar endCalendar = Calendar.getInstance();
endCalendar.set(currentYear, Calendar.JANUARY, 1);
List<String> resultList = new ArrayList<>();
Calendar currentCalendar = Calendar.getInstance();
currentCalendar.set(currentYear, Calendar.DECEMBER, 1);
while (currentCalendar.getTime().getTime() >= endCalendar.getTime().getTime()) {
resultList.add(sdf.format(currentCalendar.getTime()));
currentCalendar.add(Calendar.MONTH, -1);
currentCalendar.set(Calendar.DAY_OF_MONTH, 1);
}
return resultList;
} catch (Exception e) {
e.printStackTrace();
return new ArrayList<>();
}
}
public static void main(String[] args) {
// String start = "2024-01-01";
// String end = "2024-12-10";
// List<String> result = getDateRangeList(start, end);
// System.out.println(result);
// String start = "2024-01-01";
// String end = "2024-12-31";
// List<String> list = getFirstDayOfEachMonth(start, end);
// System.out.println(list);
// String start = "2024-01-01";
// String end = "2024-01-10";
// List<String> result = getDateRangeListInReverse(start, end);
// System.out.println(result);
String start = "2024-01-01";
String end = "2024-10-31";
List<String> list = getYearofEveryMonthReverse(start, end);
System.out.println(list);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.util;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.impl.client.CloseableHttpClient;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
/**
* @author chizw
* @version ver.1.0.0
* @Description http工具
* @create 2024/4/12 16:06
*/
@Slf4j
public class HttpUtil {
private static String tokenString = "";
private static String AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED";
private static CloseableHttpClient httpClient = null;
private final static String appKey = "48e5e13229b82c1b4e6e8c96151f0637";
private final static String secret = "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b";
private final static String ROBOT_URL_PRE = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=";
private final static RestTemplate restTemplate = new RestTemplate();
private static void addBaseParam(MultiValueMap<String, String> paramsMap, String method) {
paramsMap.add("v", "1.0.0");
paramsMap.add("method", method);
paramsMap.add("name", "zhouhb");
}
public static MultiValueMap<String, String> getSysParams() {
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(16);
params.add("appKey", appKey);
params.add("format", "json");
return params;
}
public static <T> T post(String url, JSONObject json, Class<T> responseType) throws Exception {
RestTemplate restTemplate = new RestTemplate();
//创建请求头
HttpHeaders httpHeaders = new HttpHeaders();
//添加到添加进去
httpHeaders.add("Content-Type", "application/json");
HttpEntity<Object> htttpentity = new HttpEntity<>(json, httpHeaders);
//远程调用,
return restTemplate.postForObject(url, htttpentity, responseType);
}
}
package cn.com.glsx.dj.supervisor.util;
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.dj.supervisor.mapper.DemoMapper">
<select id="load" resultType="cn.com.glsx.dj.supervisor.model.DemoModel">
select "hello"name from dual
</select>
</mapper>
server.port=8080
server.display-name=rpc-dj-supervisor
server.servlet.context-path=/rpc-dj-supervisor
server.servlet.application-display-name=rpc-dj-supervisor
logging.config=classpath:logback.xml
logging.path=/data/java_log/jetty/rpc-dj-supervisor/rpc-dj-supervisor.log
logging.level.root=INFO
ore.starter.class-name=Main
# diamond config
ore.diamond.group=dijia
ore.diamond.dataId=rpc-dj-supervisor
ore.diamond.env=release
\ No newline at end of file \ 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>
<!-- druid连接池慢查询日志记录 -->
<appender name="DruidFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${LOG_PATH}.druid_slow_sql</file>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 归档的日志文件的路径,例如今天是2020-01-01日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
而2020-01-01的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
<fileNamePattern>${LOG_PATH}.druid_slow_sql-%d{yyyy-MM-dd}.%i</fileNamePattern>
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,命名日志文件,例如log-error-2020-01-01.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>200MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 追加方式记录日志 -->
<append>true</append>
<!-- 日志文件的格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 此日志文件只记录级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<root level="${LOG_LEVEL}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<appender-ref ref="DruidFILE" />
</root>
</configuration>
\ No newline at end of file \ 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 \ 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 '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.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"
package cn.com.glsx.dj.supervisor.remote;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import cn.com.glsx.dj.supervisor.Main;
/**
* @Title: BaseRemoteTest.java
* @Description:
* @author deployer name
* @date 2018年1月6日 下午3:58:33
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class BaseRemoteTest {
@Test
public void testSayHello(){
System.out.println("Jerry");
}
}
package cn.com.glsx.dj.supervisor.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import cn.com.glsx.dj.supervisor.Main;
/**
* @Title: BaseServiceTest.java
* @Description:
* @author deployer name
* @date 2018年1月6日 下午1:23:03
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class BaseServiceTest {
@Test
public void testSayHello(){
System.out.println("Jerry");
}
}
package cn.com.glsx.dj.supervisor.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.junit.Test;
/**
* @Title: DemoServiceTest.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
public class DemoServiceTest extends BaseServiceTest{
@Autowired
private DemoService demoService;
@Test
public void testSayHello(){
System.out.println("Jerry");
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<!-- 确保已安装mybatis generator eclipse插件 -->
<generatorConfiguration>
<context id="DB2Tables" targetRuntime="MyBatis3">
<property name="javaFileEncoding" value="UTF-8"/>
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="org.oreframework.datasource.mybatis.mapper.OreMapper"/>
<property name="caseSensitive" value="true"/>
<property name="useActualColumnNames" value="true" />
<!--<property name="beginningDelimiter" value="`"/>-->
<!--<property name="endingDelimiter" value="`"/>-->
</plugin>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.227:3306/dj_smartcarlife?characterEncoding=utf8" userId="dev_admin" password="1f7e1ed2" />
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<javaModelGenerator targetPackage="cn.com.glsx.dj.riskmanage.model.sem" targetProject="../rpc-dj-riskmanage-api/src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="META-INF/orm" targetProject="src/main/resources">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<javaClientGenerator targetPackage="cn.com.glsx.dj.riskmanage.mapper.sem" targetProject="MAVEN" type="XMLMAPPER">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- 可配置多个 -->
<table tableName="sem_kpi_metrics" domainObjectName="SemKpiMetrics" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="sem_user_kpi_metric" domainObjectName="SemUserKpiMetric" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
</context>
</generatorConfiguration>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!