Commit b690f3e5 authored by hkl's avatar hkl

修改代码

parent 14c16f87
......@@ -188,7 +188,12 @@
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j-spring-boot-starter.version}</version>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-ui</artifactId>
<version>2.0.2</version>
</dependency>
<!-- 代码生成器 -->
......
......@@ -18,7 +18,6 @@ import java.net.UnknownHostException;
*/
@Slf4j
@SpringBootApplication
//@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
public class JeecgSystemApplication extends SpringBootServletInitializer {
@Override
......
......@@ -57,7 +57,7 @@ public class CodeGenerate {
// 设置过滤前缀
.strategyConfig(builder -> {
builder.addInclude(tables) // 设置需要生成的表名
.addTablePrefix("t_sn", "t_da", "t_ek", "t_xd", "t_dsg", "t_djt", "t_jh", "t_dsa","t_mw"); // 设置过滤表前缀
.addTablePrefix("t_sn", "t_da", "t_ek", "t_xd", "t_dsg", "t_djt", "t_jh", "t_dsa", "t_mw"); // 设置过滤表前缀
// entity实体策略
builder.entityBuilder()
......
......@@ -94,9 +94,12 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
private IMovementTqiReportService movementTqiReportService;
@Resource
private IMovementTqiStandardManagerService movementTqiStandardManagerService;
@Resource
private AnalysisAlgorithmMapper analysisAlgorithmMapper;
@Resource
private IRailInspectionEquipmentItemService railInspectionEquipmentItemService;
@Resource
private IRailInspectionEquipmentItemDetailService railInspectionEquipmentItemDetailService;
//**********************************人工静态检查******************************
......@@ -274,6 +277,7 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
}
movementRecordsMaster.setDelFlag("0");
if (ObjectUtil.isEmpty(movementRecordsMaster.getId())) {
movementRecordsMaster.setId(UUIDGenerator.generate());
this.service.save(movementRecordsMaster);
} else {
this.service.updateById(movementRecordsMaster);
......@@ -298,12 +302,14 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
movementCourseInfoService.lambdaUpdate().eq(MovementCourseInfo::getMovementMasterId, id).remove();
//删除里程相关
movementCourseService.lambdaUpdate().eq(MovementCourse::getMovementMasterId, id).remove();
} else if ("2".equals(type)) {
// 删除里程
railInspectionEquipmentItemService.lambdaUpdate().eq(RailInspectionEquipmentItem::getRailInspectionEquipmentId, id).remove();
// 删除里程明细
railInspectionEquipmentItemDetailService.lambdaUpdate().eq(RailInspectionEquipmentItemDetail::getRailInspectionEquipmentId, id).remove();
} else if ("4".equals(type)) {
//删除添乘仪详情
LambdaUpdateWrapper<MovementAdditiveInfo> updateQuery = Wrappers.lambdaUpdate();
updateQuery.set(MovementAdditiveInfo::getDelFlag, "1");
updateQuery.eq(MovementAdditiveInfo::getMovementMasterId, id);
movementAdditiveInfoService.update(updateQuery);
movementAdditiveInfoService.lambdaUpdate().eq(MovementAdditiveInfo::getMovementMasterId, id).remove();
} else if ("3".equals(type)) {
//删除轨检车-》轨道动态几何尺寸容许值差管理值
movementDiferenceManagerService.lambdaUpdate().eq(MovementDiferenceManager::getMovementMasterId, id).remove();
......@@ -370,11 +376,8 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
String remark = "";
//初始化起始里程表主键
String courseId = "";
//获取当前登录人信息
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String realname = user.getRealname();
// 如果做完了一个解析就跳过
MovementCourse movementCourse = new MovementCourse();
List<MovementCourse> movementCourses = new ArrayList<>();
List<MovementCourseInfo> resultList = new ArrayList<>();
//初始化里程排序
int sort = 0;
......@@ -399,15 +402,22 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
String[] start = mileage.split("-");
String s = start[0];
String k = s.substring(s.indexOf("K") + 1, s.length()).trim();
startingAndEndingMileageStr = k.replace("+", "").trim();
// 按照“+”分割
startingAndEndingMileageStr = k.replace("\\s", "")
.replaceAll(" +", "")
.replace("+", "")
.trim();
//结束里程
String s1 = start[1];
String[] ks1 = s1.split("K");
String k1 = ks1[1];
String[] n1 = k1.split("\\+");
String s2 = n1[1];
endingMileageStr = n1[0] + s2.substring(0, s2.indexOf(" ")).trim();
String[] ks1 = s1.replaceAll("\\s*", "")
.replaceAll(" ", "")
.split(",");
String k1 = ks1[0];
String n1 = k1.replace("+", "")
.replace("K", "");
endingMileageStr = n1;
//曲线半径
String[] n2 = s1.split("半径 ");
......@@ -440,6 +450,7 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
//解析备注
remark = rowRecords.get(14).get(i + 3).toString().trim();
MovementCourse movementCourse = new MovementCourse();
movementCourse.setMovementMasterId(id);
movementCourse.setCourseStartingMileage(new BigDecimal(startingAndEndingMileageStr));
movementCourse.setCourseEndMileage(new BigDecimal(endingMileageStr));
......@@ -462,13 +473,9 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
courseId = UUIDGenerator.generate();
movementCourse.setId(courseId);
movementCourse.setDelFlag("0");
movementCourse.setCreateTime(new Date());
movementCourse.setUpdateTime(new Date());
movementCourse.setCreateBy(realname);
movementCourse.setUpdateBy(realname);
movementCourse.setRemark(remark);
movementCourse.setSort(sort);
movementCourseService.save(movementCourse);
movementCourses.add(movementCourse);
}
}
......@@ -479,18 +486,15 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
if ((skipColumnNum - 2) % 28 == 0) {
continue;
}
if (ObjectUtil.isNotEmpty(courseId)) {
// 保存明细
infoSort++;
measurePoint++;
MovementCourseInfo movementCourseInfo = new MovementCourseInfo();
movementCourseInfo.setId(IdWorker.get32UUID());
movementCourseInfo.setId(UUIDGenerator.generate());
movementCourseInfo.setDelFlag("0");
movementCourseInfo.setMovementMasterId(id);
movementCourseInfo.setMovementCourseId(courseId);
movementCourseInfo.setCreateTime(new Date());
movementCourseInfo.setUpdateTime(new Date());
movementCourseInfo.setCreateBy(realname);
movementCourseInfo.setUpdateBy(realname);
movementCourseInfo.setInfoSort(infoSort);
movementCourseInfo.setMeasurePoint(measurePoint);
//获取轨号
......@@ -557,7 +561,6 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
if (measurePoint % 8 == 0) {
measurePoint = 0;
}
}
if ((skipColumnNum + 2) % 28 == 0) {
i = i + 4;
skipColumnNum = skipColumnNum + 4;
......@@ -571,15 +574,17 @@ public class MovementRecordsMasterController extends JeecgController<MovementRec
remark = "";
courseId = "";
infoSort = 0;
movementCourse = new MovementCourse();
}
}
if (resultList != null && resultList.size() > 0) {
if (ObjectUtil.isNotEmpty(resultList)) {
movementCourseInfoService.saveBatch(resultList);
}
if (ObjectUtil.isNotEmpty(movementCourses)) {
movementCourseService.saveBatch(movementCourses);
}
} catch (Exception e) {
e.getMessage();
throw new RuntimeException(e);
}
return Result.ok("操作成功");
}
......
......@@ -32,8 +32,8 @@ public class MovementCheckDataUnitDeviceMap implements Serializable {
@ApiModelProperty("主键")
@TableId("id")
private String id;
@ApiModelProperty("创建人")
@TableField("create_by")
private String createBy;
......
......@@ -1414,7 +1414,7 @@ public class AnalysisAlgorithm {
if (1 == analysisType) {
finalTrackGauge = avgTrackGauge;
} else {
finalTrackGauge = maxLevel;
finalTrackGauge = maxTrackGauge;
}
}
......@@ -1760,6 +1760,12 @@ public class AnalysisAlgorithm {
}
}
if (ObjectUtil.isNotEmpty(movementCheckDataUnitDeviceMaps)) {
movementCheckDataUnitDeviceMapService.lambdaUpdate().eq(MovementCheckDataUnitDeviceMap::getCheckId, checkDataMap.getEkId()).remove();
movementCheckDataUnitDeviceMapService.saveBatch(movementCheckDataUnitDeviceMaps);
}
}
/**
......@@ -1819,7 +1825,7 @@ public class AnalysisAlgorithm {
if (1 == analysisType) {
finalTrackGauge = avgTrackGauge;
} else {
finalTrackGauge = maxLevel;
finalTrackGauge = maxTrackGauge;
}
}
......
......@@ -103,11 +103,11 @@
t2.remark
FROM
t_dsa_analysis_batch_unit_device_transfinite t1
LEFT JOIN t_djt_movement_check_data_unit_device_map t2 ON t1.unit_id = t2.unit_id AND t1.unit_type = t2.unit_type AND t1.check_id = t2.check_id
LEFT JOIN t_djt_movement_check_data_unit_device_map t2 ON t1.unit_id = t2.unit_id AND t1.unit_type = t2.unit_type AND t1.ek_id = t2.check_id
LEFT JOIN t_djt_movement_records_master t3 ON t2.check_id = t3.id
WHERE
t1.analysis_batch_unit_device_id = #{id}
AND t1.check_type in (1,2)
AND t1.ek_type in (1,2)
ORDER BY
t3.ek_code ASC
</select>
......@@ -135,10 +135,10 @@
t2.spend,
t2.remark
FROM t_dsa_analysis_batch_unit_device_transfinite t1
LEFT JOIN t_djt_movement_over_report_unit_device_map t2 ON t1.unit_id = t2.unit_id AND t1.unit_type = t2.unit_type AND t1.check_id = t2.check_id
LEFT JOIN t_djt_movement_over_report_unit_device_map t2 ON t1.unit_id = t2.unit_id AND t1.unit_type = t2.unit_type AND t1.ek_id = t2.check_id
LEFT JOIN t_djt_movement_records_master t3 ON t2.check_id = t3.id
WHERE t1.analysis_batch_unit_device_id = #{id}
AND t1.check_type = 3
AND t1.ek_type = 3
GROUP BY t2.id
ORDER BY t3.ek_code ASC
</select>
......@@ -174,10 +174,10 @@
t2.standard,
t2.spend
FROM t_dsa_analysis_batch_unit_device_transfinite t1
LEFT JOIN t_djt_movement_tqi_report_unit_device_map t2 ON t1.unit_id = t2.unit_id AND t1.unit_type = t2.unit_type AND t1.check_id = t2.check_id
LEFT JOIN t_djt_movement_tqi_report_unit_device_map t2 ON t1.unit_id = t2.unit_id AND t1.unit_type = t2.unit_type AND t1.ek_id = t2.check_id
LEFT JOIN t_djt_movement_records_master t3 ON t2.check_id = t3.id
WHERE t1.analysis_batch_unit_device_id = #{id}
AND t1.check_type = 3
AND t1.ek_type = 3
GROUP BY t2.id
ORDER BY t3.ek_code ASC
</select>
......@@ -206,10 +206,10 @@
FROM t_dsa_analysis_batch_unit_device_transfinite t1
LEFT JOIN t_djt_movement_additive_info_unit_device_map t2 ON t1.unit_id = t2.unit_id
AND t1.unit_type = t2.unit_type
AND t1.check_id = t2.movement_master_id
AND t1.ek_id = t2.movement_master_id
LEFT JOIN t_djt_movement_records_master t3 ON t2.movement_master_id = t3.id
WHERE t1.analysis_batch_unit_device_id = #{id}
AND t1.check_type = 4
AND t1.ek_type = 4
ORDER BY t3.ek_code ASC
</select>
......
......@@ -80,6 +80,11 @@ public class AnalysisBatchServiceImpl extends ServiceImpl<AnalysisBatchMapper, A
analysisBatchCheckDataMapMapper.insert(analysisBatchCheckDataMap);
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// 执行分析
MultiProducer.produce(analysisBatch.getId());
}
......@@ -88,7 +93,8 @@ public class AnalysisBatchServiceImpl extends ServiceImpl<AnalysisBatchMapper, A
public void updateRecord(AnalysisBatchSaveOrUpdateDTO dto) {
// 主表
AnalysisBatch analysisBatch = BeanUtil.copyProperties(dto, AnalysisBatch.class);
analysisBatch.setAnalysisType(1); // 1-分析中
analysisBatch.setAnalysisType(dto.getAnalysisType());
analysisBatch.setAnalysisStatus(1); // 1-分析中
Integer[] speedLevels = StrUtil.getSpeedLevel(dto.getDictLabel());
analysisBatch.setSpeedMin(speedLevels[0]);
analysisBatch.setSpeedMax(speedLevels[1]);
......@@ -124,6 +130,12 @@ public class AnalysisBatchServiceImpl extends ServiceImpl<AnalysisBatchMapper, A
analysisBatchCheckDataMapMapper.insert(analysisBatchCheckDataMap);
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// 执行分析
MultiProducer.produce(analysisBatch.getId());
}
......@@ -142,7 +154,6 @@ public class AnalysisBatchServiceImpl extends ServiceImpl<AnalysisBatchMapper, A
analysisBatchCheckDataMapMapper.delete(wrapper);
// 2.删除主信息
this.removeById(id);
}
......
......@@ -115,7 +115,7 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch
public void transfiniteSaveRecord(WorkBatchTransfiniteSaveDTO dto) {
WorkBatch workBatch = BeanUtil.copyProperties(dto, WorkBatch.class);
workBatch.setId(UUIDGenerator.generate());
workBatch.setWorkStatus(9); // 9-已作业
workBatch.setWorkStatus(0);
workBatch.setSource(2); // 超限页面
this.save(workBatch);
......@@ -153,7 +153,7 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch
public void batchSaveRecord(AnalysisBatchSaveDTO dto) {
WorkBatch workBatch = BeanUtil.copyProperties(dto, WorkBatch.class);
workBatch.setId(UUIDGenerator.generate());
workBatch.setWorkStatus(9); // 9-已作业
workBatch.setWorkStatus(0); // 9-已作业
workBatch.setSource(2); // 超限页面
this.save(workBatch);
......@@ -186,7 +186,7 @@ public class WorkBatchServiceImpl extends ServiceImpl<WorkBatchMapper, WorkBatch
@Override
public Page<CaseReportWorkBatchVO> caseReportWorkBatch(Page<CaseReportWorkBatchVO> pageData, CaseReportWorkBatchDTO dto) {
return this.baseMapper.caseReportWorkBatch(pageData,dto);
return this.baseMapper.caseReportWorkBatch(pageData, dto);
}
......
......@@ -13,7 +13,6 @@ import java.util.Date;
public class StaticCheckVO {
@ApiModelProperty("主键")
@TableId("id")
private String id;
@ApiModelProperty("创建人")
......
......@@ -131,7 +131,7 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://47.94.207.62:3306/hzgw?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
url: jdbc:mysql://47.94.207.62:3306/hzgw2?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
username: root
password: superAdmin&321
driver-class-name: com.mysql.jdbc.Driver
......
......@@ -131,7 +131,7 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/hzgw?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
url: jdbc:mysql://127.0.0.1:3306/hzgw2?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
username: root
password: superAdmin&321
driver-class-name: com.mysql.jdbc.Driver
......
......@@ -2,4 +2,4 @@ spring:
application:
name: jeecg-system
profiles:
active: test
active: dev
......@@ -28,10 +28,6 @@
<xxl-job-core.version>2.2.0</xxl-job-core.version>
<fastjson.version>1.2.83</fastjson.version>
<pegdown.version>1.6.0</pegdown.version>
<knife4j-spring-boot-starter.version>2.0.2</knife4j-spring-boot-starter.version>
<knife4j-spring-ui.version>2.0.2</knife4j-spring-ui.version>
<!-- <knife4j-spring-ui.version>2.0.9</knife4j-spring-ui.version>
<knife4j-spring-boot-starter.version>3.0.3</knife4j-spring-boot-starter.version>-->
<!-- 数据库驱动 -->
<postgresql.version>42.2.25</postgresql.version>
<ojdbc6.version>11.2.0.3</ojdbc6.version>
......@@ -161,18 +157,6 @@
<artifactId>jeecg-boot-base-core</artifactId>
<version>${jeecgboot.version}</version>
</dependency>
<!-- system 单体 api -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-local-api</artifactId>
<version>${jeecgboot.version}</version>
</dependency>
<!-- system 微服务 api -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-cloud-api</artifactId>
<version>${jeecgboot.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
......
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### 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/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
<?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.7.14</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.suntray</groupId>
<artifactId>subwayOA-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>subwayOA-app</name>
<description>地铁公务系统</description>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun Repository</name>
<url>https://maven.aliyun.com/repository/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.18</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.2</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.3.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.10.5</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.3</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.3</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dingtalk</artifactId>
<version>2.0.30</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.suntray.oa.app;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
import java.net.UnknownHostException;
@SpringBootApplication
@Log4j2
public class SubwayOaApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext application = SpringApplication.run(SubwayOaApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
log.info("\n----------------------------------------------------------\n\t" +
"Application " + env.getProperty("spring.application.name") + " is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
}
package com.suntray.oa.app.common.constant;
/**
* @author 黄康林
* @function 通用错误码
*/
public enum CommonCode {
/**
* 成功操作
*/
C0000("0", "操作成功", null, null),
;
private String code;
private String message;
private String possibleReason;
private String suggestMeasure;
CommonCode(String code, String message) {
this.code = code;
this.message = message;
}
CommonCode(String code, String message, String possibleReason, String suggestMeasure) {
this.code = code;
this.message = message;
this.possibleReason = possibleReason;
this.suggestMeasure = suggestMeasure;
}
}
package com.suntray.oa.app.common.exception;
/**
* 系统业务异常类
*/
public class BusinessException extends RuntimeException {
}
package com.suntray.oa.app.common.exception;
import com.suntray.oa.app.common.response.BaseResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 全局异常处理器
*/
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(value = {Exception.class})
@ResponseBody
public <T> BaseResponse<T> deal(Exception e) {
BaseResponse<T> response = new BaseResponse<>();
if (e instanceof BusinessException) {
} else if (e instanceof ParamValidException) {
} else {
response.setCode(-1);
response.setSuccess(false);
response.setMessage("系统错误");
}
return response;
}
}
package com.suntray.oa.app.common.exception;
/**
* 系统参数异常类
*/
public class ParamValidException extends RuntimeException {
}
package com.suntray.oa.app.common.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "统一响应结构")
public class BaseResponse<T> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "成功标志")
private boolean success = true;
@ApiModelProperty(value = "返回处理消息")
private String message = "";
@ApiModelProperty(value = "返回代码")
private Integer code = 0;
@ApiModelProperty(value = "返回数据对象")
private T result;
@ApiModelProperty(value = "时间戳")
private long timestamp = System.currentTimeMillis();
public static BaseResponse<String> ok() {
return ok("操作成功");
}
public static BaseResponse<String> ok(String message) {
BaseResponse<String> response = new BaseResponse<>();
return response;
}
}
package com.suntray.oa.app.common.util;
import java.net.InetAddress;
public class UUIDGenerator {
/**
* 产生一个32位的UUID
*
* @return
*/
public static String generate() {
return new StringBuilder(32).append(format(getIp())).append(
format(getJvm())).append(format(getHiTime())).append(
format(getLoTime())).append(format(getCount())).toString();
}
private static final int IP;
static {
int ipadd;
try {
ipadd = toInt(InetAddress.getLocalHost().getAddress());
} catch (Exception e) {
ipadd = 0;
}
IP = ipadd;
}
private static short counter = (short) 0;
private static final int JVM = (int) (System.currentTimeMillis() >>> 8);
private final static String format(int intval) {
String formatted = Integer.toHexString(intval);
StringBuilder buf = new StringBuilder("00000000");
buf.replace(8 - formatted.length(), 8, formatted);
return buf.toString();
}
private final static String format(short shortval) {
String formatted = Integer.toHexString(shortval);
StringBuilder buf = new StringBuilder("0000");
buf.replace(4 - formatted.length(), 4, formatted);
return buf.toString();
}
private final static int getJvm() {
return JVM;
}
private final static short getCount() {
synchronized (UUIDGenerator.class) {
if (counter < 0) {
counter = 0;
}
return counter++;
}
}
/**
* Unique in a local network
*/
private final static int getIp() {
return IP;
}
/**
* Unique down to millisecond
*/
private final static short getHiTime() {
return (short) (System.currentTimeMillis() >>> 32);
}
private final static int getLoTime() {
return (int) System.currentTimeMillis();
}
private final static int toInt(byte[] bytes) {
int result = 0;
int length = 4;
for (int i = 0; i < length; i++) {
result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i];
}
return result;
}
}
package com.suntray.oa.app.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import org.springframework.beans.factory.annotation.Value;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import springfox.documentation.service.Contact;
import springfox.documentation.builders.RequestHandlerSelectors;
@Slf4j
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {
@Value("${spring.application.name:default}")
private String applicationName;
@Bean
public Docket docket() {
// 指定使用Swagger2规范
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
// 简介(支持Markdown语法)
.description("地铁公务APP端api")
// 服务地址
.termsOfServiceUrl("API服务条款")
// 作者及联系信息
.contact(new Contact("地铁公务", "地铁公务", "地铁公务"))
// api版本
.version("1.0.0")
.build())
//分组名称(微服务项目可以用微服务名分组)
.groupName(applicationName)
.select()
// 定位api
// .apis(
// RequestHandlerSelectors.basePackage(getProjectBasePackage())
// .and(RequestHandlerSelectors.withClassAnnotation(RestController.class)
// .or(RequestHandlerSelectors.withClassAnnotation(Controller.class))
// )
// )
// .paths(PathSelectors.any())
.build();
// docket.securitySchemes(securitySchemes()).securityContexts(securityContexts());
return docket;
}
}
package com.suntray.oa.app.modules.test;
import com.suntray.oa.app.common.response.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Api(tags = "测试模块")
public class TestController {
@GetMapping(value = "/test1")
@ApiOperation(value = "test1")
public BaseResponse<String> test1() {
return BaseResponse.ok("添加成功");
}
}
server:
port: 16999
servlet:
context-path: /hzsomms-app/api
spring:
datasource:
druid:
url: jdbc:mysql://47.94.207.62:3306/hzgw?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
username: root
password: superAdmin&321
driver-class-name: com.mysql.cj.jdbc.Driver
initial-size: 5
min-idle: 5
max-active: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validation-query: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
redis:
database: 0
host: 47.94.207.62
password: 'redis@123'
port: 6773
mybatis-plus:
mapper-locations: classpath*:com/suntray/subway/oa/app/modules/**/xml/*Mapper.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
call-setters-on-nulls: true
map-underscore-to-camel-case: true
server:
port: 16999
servlet:
context-path: /hzsomms-app/api
spring:
datasource:
druid:
url: jdbc:mysql://192.168.81.81:3306/hzgw?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&zeroDateTimeBehavior=convertToNull
username: root
password: huang123
driver-class-name: com.mysql.cj.jdbc.Driver
initial-size: 5
min-idle: 5
max-active: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validation-query: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
redis:
database: 0
host: 47.94.207.62
password: 'redis@123'
port: 6773
mybatis-plus:
mapper-locations: classpath*:com/suntray/subway/oa/app/modules/**/xml/*Mapper.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
call-setters-on-nulls: true
map-underscore-to-camel-case: true
#第三方APP对接
third-app:
# 钉钉小程序应用凭证
dingtalk:
AgentId: 2690626997
AppKey: dingmuvi6qfwaqcpanry
AppSecret: DPgW5bP0ljIeEFB9LKpbDlrZY78MfzE-HMVL3yV1wIhTaaQdJ3PCv1jFMmr-kvAi
spring:
application:
name: subwayOA-app
profiles:
active: test
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 -->
<property name="LOG_HOME" value="../logs" />
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />-->
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n</pattern>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/jeecgboot-%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>30</MaxHistory>
<maxFileSize>10MB</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
</encoder>
</appender>
<!-- 生成 error html格式日志开始 -->
<appender name="HTML" class="ch.qos.logback.core.FileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<!--设置日志级别,过滤掉info日志,只输入error日志-->
<level>ERROR</level>
</filter>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%p%d%msg%M%F{32}%L</pattern>
</layout>
</encoder>
<file>${LOG_HOME}/error-log.html</file>
</appender>
<!-- 生成 error html格式日志结束 -->
<!-- 每天生成一个html格式的日志开始 -->
<appender name="FILE_HTML" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/jeecgboot-%d{yyyy-MM-dd}.%i.html</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>30</MaxHistory>
<MaxFileSize>10MB</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%p%d%msg%M%F{32}%L</pattern>
</layout>
</encoder>
</appender>
<!-- 每天生成一个html格式的日志结束 -->
<!--myibatis log configure -->
<logger name="com.apache.ibatis" level="TRACE" />
<logger name="java.sql.Connection" level="DEBUG" />
<logger name="java.sql.Statement" level="DEBUG" />
<logger name="java.sql.PreparedStatement" level="DEBUG" />
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<appender-ref ref="HTML" />
<appender-ref ref="FILE_HTML" />
</root>
</configuration>
\ No newline at end of file
package com.suntray.oa.app;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SubwayOaAppApplicationTests {
@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