Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
H
hzsomms
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZTGK
hzsomms
Commits
6b7261e7
Commit
6b7261e7
authored
Oct 23, 2023
by
hkl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:1.bug修复
parent
6aba953e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
199 additions
and
11 deletions
+199
-11
pom.xml
jeecg-module-system/pom.xml
+5
-4
RailManagementController.java
...ules/deviceAsset/controller/RailManagementController.java
+0
-1
RailManagementMapper.xml
...g/modules/deviceAsset/mapper/xml/RailManagementMapper.xml
+1
-0
RailManagementServiceImpl.java
...s/deviceAsset/service/impl/RailManagementServiceImpl.java
+193
-6
No files found.
jeecg-module-system/pom.xml
View file @
6b7261e7
...
...
@@ -65,6 +65,7 @@
<properties>
<package.environment>
dev
</package.environment>
</properties>
</profile>
<!-- 黄康林本地配置-->
...
...
@@ -73,6 +74,10 @@
<properties>
<package.environment>
hkl
</package.environment>
</properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
</profile>
<!-- 测试环境 -->
...
...
@@ -81,10 +86,6 @@
<properties>
<package.environment>
test
</package.environment>
</properties>
<!-- 是否默认 true表示默认-->
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
</profile>
<!-- 压测环境-->
...
...
jeecg-module-system/src/main/java/org/jeecg/modules/deviceAsset/controller/RailManagementController.java
View file @
6b7261e7
...
...
@@ -93,7 +93,6 @@ public class RailManagementController extends JeecgController<RailManagement, IR
@ApiImplicitParam
(
name
=
"lineAliasId"
,
value
=
"线别id"
)
})
public
Result
<
String
>
intelligentGeneration
(
String
lightRailId
,
String
lineAliasId
)
{
// this.service.intelligentGeneration(lightRailId);
this
.
service
.
intelligentGeneration
(
lightRailId
,
lineAliasId
);
return
Result
.
OK
(
"生成成功"
);
}
...
...
jeecg-module-system/src/main/java/org/jeecg/modules/deviceAsset/mapper/xml/RailManagementMapper.xml
View file @
6b7261e7
...
...
@@ -25,6 +25,7 @@
<if
test=
"dto.lineAliasId != null and dto.lineAliasId != ''"
>
AND t1.line_alias_id = #{dto.lineAliasId}
</if>
ORDER BY t1.light_rail_id ,t1.line_alias_id,t1.starting_mileage
</select>
<select
id=
"getLineSpecialRail"
resultType=
"java.util.Map"
>
SELECT id,
...
...
jeecg-module-system/src/main/java/org/jeecg/modules/deviceAsset/service/impl/RailManagementServiceImpl.java
View file @
6b7261e7
...
...
@@ -2,6 +2,7 @@ package org.jeecg.modules.deviceAsset.service.impl;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.extra.pinyin.PinyinUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -26,6 +27,7 @@ import javax.annotation.Resource;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* <p>
...
...
@@ -135,19 +137,18 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
}
@Override
public
void
intelligentGeneration
(
String
lightRailId
,
String
lineAliasId
)
{
System
.
out
.
printf
(
"lineAliasId="
+
lineAliasId
);
// 2.查询当前车站的上下行里程
// @Override
public
void
intelligentGeneration1
(
String
lightRailId
,
String
lineAliasId
)
{
// 1.查询当前车站的上下行里程
LightRail
lightRail
=
lightRailMapper
.
selectById
(
lightRailId
);
//
3
.1 查询上行所有里程数
//
2
.1 查询上行所有里程数
List
<
RailManagement
>
allRailList
=
new
ArrayList
<>();
generationCore
(
lightRail
,
allRailList
,
lineAliasId
);
for
(
int
i
=
0
;
i
<
allRailList
.
size
();
i
++)
{
RailManagement
railManagement
=
allRailList
.
get
(
i
);
String
railCode
=
"钢轨[上行]"
+
UnitCodeUtil
.
supplementZero
(
4
,
i
+
1
);
String
railCode
=
"钢轨[上行]"
+
UnitCodeUtil
.
supplementZero
(
4
,
i
+
1
)
+
"[自动]"
;
railManagement
.
setRailCode
(
railCode
);
String
unitCode
=
"SXXGG"
+
UnitCodeUtil
.
supplementZero
(
4
,
i
+
1
);
railManagement
.
setUnitCode
(
unitCode
);
...
...
@@ -166,6 +167,189 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
}
@Override
public
void
intelligentGeneration
(
String
lightRailId
,
String
lineAliasId
)
{
// 1.查询当前车站的上下行里程
LightRail
lightRail
=
lightRailMapper
.
selectById
(
lightRailId
);
// 2.1 查询上行所有里程数
List
<
RailManagement
>
allRailList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
lineSpecialRailList
=
this
.
getLineSpecialRail
(
lightRail
.
getId
(),
lineAliasId
);
BigDecimal
lineStartMileage
=
BigDecimal
.
ZERO
;
LineAlias
lineAlias
=
lineAliasMapper
.
selectById
(
lineAliasId
);
BigDecimal
endMileage
=
lightRail
.
getUpLineMileage
();
if
(
lineAlias
.
getLineAliasName
().
contains
(
"下行"
))
{
endMileage
=
lightRail
.
getDownLineMileage
();
}
int
size
=
lineSpecialRailList
.
size
();
// 1.如果查询不到曲线,竖曲线,道岔,则全是钢轨
if
(
size
==
0
&&
endMileage
.
compareTo
(
lineStartMileage
)
>
0
)
{
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
lineStartMileage
,
endMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
else
{
// true 可以进入生成规则2(说明没有空白部分) 否则用生成规则1
boolean
isGenerateRule2
=
true
;
// 生成规则1:
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Map
<
String
,
Object
>
currentMap
=
lineSpecialRailList
.
get
(
i
);
BigDecimal
currentStartMileage
=
Convert
.
toBigDecimal
(
currentMap
.
get
(
"startMileage"
));
BigDecimal
currentEndMileage
=
Convert
.
toBigDecimal
(
currentMap
.
get
(
"endMileage"
));
// 3.2.1 第一次进入循环
if
(
i
==
0
)
{
// ① 线路起点 < 第一个单元开始里程[线路起点,第一个单元开始里程]
if
(
currentStartMileage
.
compareTo
(
lineStartMileage
)
>
0
)
{
isGenerateRule2
=
false
;
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
lineStartMileage
,
currentStartMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
// 只有一个的情况下做一个判断第一个单元可能只有半截
if
(
size
==
1
)
{
// ② 第一个开始里程 < 线路起点里程 < 第一个单元结束里程[第一个单元结束里程,结束里程] ,
if
(
lineStartMileage
.
compareTo
(
currentStartMileage
)
>
0
&&
lineStartMileage
.
compareTo
(
currentEndMileage
)
<
0
)
{
isGenerateRule2
=
false
;
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
currentEndMileage
,
endMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
}
continue
;
}
// 3.2.2 后一个的开始里程 - 前一个的结束里程 > 0 相当于有空白[注:1个单元情况下不做]
Map
<
String
,
Object
>
frontMap
=
lineSpecialRailList
.
get
(
i
-
1
);
BigDecimal
frontEndMileage
=
Convert
.
toBigDecimal
(
frontMap
.
get
(
"endMileage"
));
if
(
currentStartMileage
.
subtract
(
frontEndMileage
).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
isGenerateRule2
=
false
;
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
frontEndMileage
,
currentStartMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
// 3.2.3 最后一次循环:线路终点里程 > 最后一个单元结束里程,要补充[最后一个单元结束里程,线路终点里程]
if
(
i
==
size
-
1
)
{
if
(
endMileage
.
subtract
(
currentEndMileage
).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
isGenerateRule2
=
false
;
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
currentEndMileage
,
endMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
}
}
// 生成规则2:
if
(
isGenerateRule2
)
{
// 1.将钢轨删除,保留道岔,曲线,竖曲线
lineSpecialRailList
=
lineSpecialRailList
.
stream
()
.
filter
(
currentMap
->
Convert
.
toInt
(
currentMap
.
get
(
"type"
))
!=
1
)
.
collect
(
Collectors
.
toList
());
// 移除钢轨
this
.
lambdaUpdate
()
.
eq
(
RailManagement:
:
getLightRailId
,
lightRailId
)
.
eq
(
RailManagement:
:
getLineAliasId
,
lineAliasId
)
.
remove
();
size
=
lineSpecialRailList
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Map
<
String
,
Object
>
currentMap
=
lineSpecialRailList
.
get
(
i
);
BigDecimal
currentStartMileage
=
Convert
.
toBigDecimal
(
currentMap
.
get
(
"startMileage"
));
BigDecimal
currentEndMileage
=
Convert
.
toBigDecimal
(
currentMap
.
get
(
"endMileage"
));
// 3.2.1 第一次进入循环
if
(
i
==
0
)
{
// ① 线路起点 < 第一个单元开始里程[线路起点,第一个单元开始里程]
if
(
currentStartMileage
.
compareTo
(
lineStartMileage
)
>
0
)
{
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
lineStartMileage
,
currentStartMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
// 只有一个的情况下做一个判断第一个单元可能只有半截
if
(
size
==
1
)
{
// ② 第一个开始里程 < 线路起点里程 < 第一个单元结束里程[第一个单元结束里程,结束里程] ,
if
(
lineStartMileage
.
compareTo
(
currentStartMileage
)
>
0
&&
lineStartMileage
.
compareTo
(
currentEndMileage
)
<
0
)
{
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
currentEndMileage
,
endMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
}
continue
;
}
// 3.2.2 后一个的开始里程 - 前一个的结束里程 > 0 相当于有空白[注:1个单元情况下不做]
Map
<
String
,
Object
>
frontMap
=
lineSpecialRailList
.
get
(
i
-
1
);
BigDecimal
frontEndMileage
=
Convert
.
toBigDecimal
(
frontMap
.
get
(
"endMileage"
));
if
(
currentStartMileage
.
subtract
(
frontEndMileage
).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
frontEndMileage
,
currentStartMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
// 3.2.3 最后一次循环:线路终点里程 > 最后一个单元结束里程,要补充[最后一个单元结束里程,线路终点里程]
if
(
i
==
size
-
1
)
{
if
(
endMileage
.
subtract
(
currentEndMileage
).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
currentEndMileage
,
endMileage
,
lineAliasId
);
allRailList
.
addAll
(
innerRailList
);
}
}
}
}
}
// 查询最大的编号
String
lineAliasPinyin
=
PinyinUtil
.
getFirstLetter
(
lineAlias
.
getLineAliasName
(),
""
).
toUpperCase
();
String
unitCodePrefix
=
lineAliasPinyin
+
"GG"
;
RailManagement
record
=
this
.
lambdaQuery
()
.
likeRight
(
RailManagement:
:
getUnitCode
,
unitCodePrefix
)
.
orderByDesc
(
RailManagement:
:
getUnitCode
)
.
last
(
"limit 1"
)
.
one
();
// 流水号初始化为1
Integer
serialNum
=
1
;
if
(
null
!=
record
&&
record
.
getUnitCode
()
!=
null
)
{
// 流水号+1
serialNum
=
Integer
.
parseInt
(
record
.
getUnitCode
().
substring
(
record
.
getUnitCode
().
length
()
-
4
))
+
1
;
}
for
(
int
i
=
0
;
i
<
allRailList
.
size
();
i
++)
{
RailManagement
railManagement
=
allRailList
.
get
(
i
);
String
railCode
=
"钢轨["
+
lineAlias
.
getLineAliasName
()
+
"]"
+
UnitCodeUtil
.
supplementZero
(
4
,
serialNum
+
i
)
+
"[自动]"
;
railManagement
.
setRailCode
(
railCode
);
String
unitCode
=
unitCodePrefix
+
UnitCodeUtil
.
supplementZero
(
4
,
serialNum
+
i
);
railManagement
.
setUnitCode
(
unitCode
);
railManagement
.
setLightRailId
(
lightRailId
);
railManagement
.
setRailOrderNum
(
serialNum
+
i
);
railManagement
.
setCreateBy
(
"系统生成"
);
railManagement
.
setUpdateBy
(
"系统生成"
);
}
// 3.2 计算区间
this
.
calcSection
(
lightRailId
,
lineAliasId
,
allRailList
);
// 异步执行保存
asyncTask
.
getAsyncExecutor
().
execute
(()
->
{
this
.
saveBatch
(
allRailList
);
});
}
/**
* 计算区间
*
...
...
@@ -245,6 +429,7 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
allRailList
.
addAll
(
innerRailList
);
}
else
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Map
<
String
,
Object
>
currentMap
=
lineSpecialRailList
.
get
(
i
);
BigDecimal
currentStartMileage
=
Convert
.
toBigDecimal
(
currentMap
.
get
(
"startMileage"
));
...
...
@@ -291,6 +476,8 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment