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
b8ad4197
Commit
b8ad4197
authored
Jul 18, 2023
by
hkl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:1.单元编号划分
parent
98b0f4b0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
220 additions
and
5 deletions
+220
-5
RailManagementController.java
...ules/deviceAsset/controller/RailManagementController.java
+2
-2
RailManagementMapper.java
...eecg/modules/deviceAsset/mapper/RailManagementMapper.java
+5
-0
RailManagementMapper.xml
...g/modules/deviceAsset/mapper/xml/RailManagementMapper.xml
+45
-0
IRailManagementService.java
...g/modules/deviceAsset/service/IRailManagementService.java
+11
-1
RailManagementServiceImpl.java
...s/deviceAsset/service/impl/RailManagementServiceImpl.java
+139
-2
UnitCodeUtil.java
...m/src/main/java/org/jeecg/modules/utils/UnitCodeUtil.java
+18
-0
No files found.
jeecg-module-system/src/main/java/org/jeecg/modules/deviceAsset/controller/RailManagementController.java
View file @
b8ad4197
...
...
@@ -74,8 +74,8 @@ public class RailManagementController extends JeecgController<RailManagement, IR
@AutoLog
(
value
=
"资产管理-钢轨管理-智能生成"
)
@ApiOperation
(
value
=
"资产管理-钢轨管理-智能生成"
,
notes
=
"资产管理-钢轨管理-智能生成"
)
@GetMapping
(
value
=
"/intelligentGeneration"
)
public
Result
<
String
>
intelligentGeneration
(
@RequestParam
(
name
=
"ids"
,
required
=
true
)
String
ids
)
{
this
.
service
.
intelligentGeneration
();
public
Result
<
String
>
intelligentGeneration
()
{
this
.
service
.
intelligentGeneration
(
"1671390979417616386"
);
return
Result
.
OK
(
"生成成功"
);
}
...
...
jeecg-module-system/src/main/java/org/jeecg/modules/deviceAsset/mapper/RailManagementMapper.java
View file @
b8ad4197
...
...
@@ -6,6 +6,9 @@ import org.jeecg.modules.deviceAsset.entity.RailManagement;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.jeecg.modules.deviceAsset.vo.RailManagementVO
;
import
java.util.List
;
import
java.util.Map
;
/**
* <p>
* 资产管理-钢轨管理 Mapper 接口
...
...
@@ -17,4 +20,6 @@ import org.jeecg.modules.deviceAsset.vo.RailManagementVO;
public
interface
RailManagementMapper
extends
BaseMapper
<
RailManagement
>
{
Page
<
RailManagementVO
>
queryPageList
(
Page
<
RailManagementVO
>
pageData
,
RailManagementDTO
dto
);
List
<
Map
<
String
,
Object
>>
getLineSpecialRail
(
String
lineAliasId
);
}
jeecg-module-system/src/main/java/org/jeecg/modules/deviceAsset/mapper/xml/RailManagementMapper.xml
View file @
b8ad4197
...
...
@@ -27,4 +27,49 @@
</if>
</where>
</select>
<select
id=
"getLineSpecialRail"
resultType=
"java.util.Map"
>
SELECT
unitCode,
startMileage,
endMileage,
type
FROM
(
SELECT
t1.unit_code unitCode,
t1.curve_mileage_zh startMileage,
t1.curve_mileage_hz endMileage,
'曲线' type
FROM
t_da_curve_management t1
WHERE
t1.line_alias_id = #{lineAliasId}
UNION ALL
SELECT
unit_code unitCode,
starting_mileage startMileage,
end_mileage endMileage,
'竖曲线' type
FROM
t_da_vertical_curve_management
WHERE
line_alias_id = #{lineAliasId}
UNION ALL
SELECT
unit_code unitCode,
byroad_pre_mileage startMileage,
byroad_end_mileage endMileage,
'道岔' type
FROM
t_da_switch_management
WHERE
line_alias_id = #{lineAliasId}
) t
ORDER BY
t.startMileage
</select>
</mapper>
jeecg-module-system/src/main/java/org/jeecg/modules/deviceAsset/service/IRailManagementService.java
View file @
b8ad4197
...
...
@@ -6,6 +6,9 @@ import org.jeecg.modules.deviceAsset.entity.RailManagement;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
org.jeecg.modules.deviceAsset.vo.RailManagementVO
;
import
java.util.List
;
import
java.util.Map
;
/**
* <p>
* 资产管理-钢轨管理 服务类
...
...
@@ -20,5 +23,12 @@ public interface IRailManagementService extends IService<RailManagement> {
void
edit
(
RailManagement
railManagement
);
void
intelligentGeneration
();
void
intelligentGeneration
(
String
lightRailId
);
/**
* 获取线路的特殊钢轨
*
* @param lineAliasId 线别ID
*/
List
<
Map
<
String
,
Object
>>
getLineSpecialRail
(
String
lineAliasId
);
}
jeecg-module-system/src/main/java/org/jeecg/modules/deviceAsset/service/impl/RailManagementServiceImpl.java
View file @
b8ad4197
package
org
.
jeecg
.
modules
.
deviceAsset
.
service
.
impl
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.jeecg.common.util.UUIDGenerator
;
import
org.jeecg.modules.deviceAsset.dto.RailManagementDTO
;
import
org.jeecg.modules.deviceAsset.entity.RailManagement
;
import
org.jeecg.modules.deviceAsset.mapper.RailManagementMapper
;
import
org.jeecg.modules.deviceAsset.service.IRailManagementService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.jeecg.modules.deviceAsset.vo.RailManagementVO
;
import
org.jeecg.modules.subwayNetwork.entity.LightRail
;
import
org.jeecg.modules.subwayNetwork.mapper.LightRailMapper
;
import
org.jeecg.modules.utils.UnitCodeUtil
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* <p>
* 资产管理-钢轨管理 服务实现类
...
...
@@ -22,6 +35,14 @@ import org.springframework.stereotype.Service;
@Service
public
class
RailManagementServiceImpl
extends
ServiceImpl
<
RailManagementMapper
,
RailManagement
>
implements
IRailManagementService
{
/**
* 钢轨单元长度
*/
public
static
BigDecimal
UNIT_LENGTH
=
new
BigDecimal
(
"25"
);
@Resource
private
LightRailMapper
lightRailMapper
;
@Override
public
Page
<
RailManagementVO
>
queryPageList
(
Page
<
RailManagementVO
>
pageData
,
RailManagementDTO
dto
)
{
return
this
.
baseMapper
.
queryPageList
(
pageData
,
dto
);
...
...
@@ -39,8 +60,124 @@ public class RailManagementServiceImpl extends ServiceImpl<RailManagementMapper,
}
}
// 1.判断完整的线路有没有空白部分(指剩余区间既不是道岔、曲线、竖曲线、钢轨的部分),只需要填空白部分,空白部分一定是钢轨,按照25一根的逻辑余数自成一根;
// 2.如果不存在空白部分,则定义道岔曲线竖曲线为绝对正确里程值,并且定义为特殊钢轨,相邻两个特殊钢轨之间的里程区间按照25一根的逻辑余数自成一根。
@Override
public
void
intelligentGeneration
(
String
lightRailId
)
{
// 1.删除整条线的
this
.
lambdaUpdate
().
remove
();
// 2.查询当前车站的上下行里程
LightRail
lightRail
=
lightRailMapper
.
selectById
(
lightRailId
);
// 3.处理上行
// 3.1 查询上行所有里程数
List
<
RailManagement
>
allRailList
=
new
ArrayList
<>();
String
sdkId
=
"1"
;
// 上行线id
List
<
Map
<
String
,
Object
>>
lineSpecialRailList
=
this
.
getLineSpecialRail
(
sdkId
);
BigDecimal
lineStartMileage
=
BigDecimal
.
ZERO
;
BigDecimal
endMileage
=
lightRail
.
getUpLineMileage
();
// 3.2 循环处理
int
size
=
lineSpecialRailList
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Map
<
String
,
Object
>
currentMap
=
lineSpecialRailList
.
get
(
i
);
BigDecimal
currentStartMileage
=
Convert
.
toBigDecimal
(
currentMap
.
get
(
"startMileage"
));
// 3.2.1 第一次进入循环
if
(
i
==
0
)
{
if
(
currentStartMileage
.
subtract
(
lineStartMileage
).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
lineStartMileage
,
currentStartMileage
,
sdkId
);
allRailList
.
addAll
(
innerRailList
);
}
continue
;
}
// 3.2.2 后一个的开始 - 前一个的结束时间 > 0 相当于有空白
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
,
sdkId
);
allRailList
.
addAll
(
innerRailList
);
}
// 3.2.3 最后一次循环
if
(
i
==
size
-
1
)
{
if
(
endMileage
.
subtract
(
currentStartMileage
).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
List
<
RailManagement
>
innerRailList
=
this
.
generate
(
currentStartMileage
,
endMileage
,
sdkId
);
allRailList
.
addAll
(
innerRailList
);
}
}
}
for
(
int
i
=
0
;
i
<
allRailList
.
size
();
i
++)
{
RailManagement
railManagement
=
allRailList
.
get
(
i
);
String
railCode
=
"钢轨[上行]"
+
(
i
+
1
);
railManagement
.
setRailCode
(
railCode
);
String
unitCode
=
"SXXGG"
+
UnitCodeUtil
.
supplementZero
(
4
,
i
);
railManagement
.
setUnitCode
(
unitCode
);
railManagement
.
setRailOrderNum
(
i
+
1
);
railManagement
.
setCreateTime
(
new
Date
());
railManagement
.
setUpdateTime
(
new
Date
());
}
this
.
saveBatch
(
allRailList
);
}
/**
* @param startMileage
* @param endMileage
* @param lineAliasId
* @return
*/
private
List
<
RailManagement
>
generate
(
BigDecimal
startMileage
,
BigDecimal
endMileage
,
String
lineAliasId
)
{
List
<
RailManagement
>
result
=
new
ArrayList
<>();
// 1.处理25米一段的钢轨
while
(
startMileage
.
add
(
UNIT_LENGTH
).
compareTo
(
endMileage
)
<
0
)
{
// 开始里程向后移动25米
BigDecimal
currentEndMileage
=
startMileage
.
add
(
UNIT_LENGTH
);
// 中心里程 = (开始里程+结束里程) / 2
BigDecimal
centerMileage
=
startMileage
.
add
(
currentEndMileage
).
divide
(
new
BigDecimal
(
"2"
),
3
,
RoundingMode
.
HALF_UP
);
RailManagement
railManagement
=
new
RailManagement
();
railManagement
.
setId
(
UUIDGenerator
.
generate
());
railManagement
.
setLineAliasId
(
lineAliasId
);
railManagement
.
setStartingMileage
(
startMileage
);
railManagement
.
setCenterMileage
(
centerMileage
);
railManagement
.
setEndMileage
(
currentEndMileage
);
result
.
add
(
railManagement
);
startMileage
=
currentEndMileage
;
}
// 2.处理不到25米一段的钢轨
RailManagement
railManagement
=
new
RailManagement
();
railManagement
.
setId
(
UUIDGenerator
.
generate
());
railManagement
.
setLineAliasId
(
lineAliasId
);
railManagement
.
setStartingMileage
(
startMileage
);
railManagement
.
setCenterMileage
(
startMileage
.
add
(
endMileage
).
divide
(
new
BigDecimal
(
"2"
),
3
,
RoundingMode
.
HALF_UP
));
// 中心里程 = (开始里程+结束里程) / 2
railManagement
.
setEndMileage
(
endMileage
);
result
.
add
(
railManagement
);
return
result
;
}
// public static void main(String[] args) {
// List<RailManagement> generate = generate(BigDecimal.ZERO, new BigDecimal("64.709"), "1");
// System.out.printf(JSONObject.toJSONString(generate));
// }
@Override
public
void
intelligentGeneration
(
)
{
throw
new
NullPointerException
(
);
public
List
<
Map
<
String
,
Object
>>
getLineSpecialRail
(
String
lineAliasId
)
{
return
this
.
baseMapper
.
getLineSpecialRail
(
lineAliasId
);
}
}
jeecg-module-system/src/main/java/org/jeecg/modules/utils/UnitCodeUtil.java
View file @
b8ad4197
...
...
@@ -12,6 +12,9 @@ import org.jeecg.modules.deviceAsset.service.IVerticalCurveManagementService;
import
org.jeecg.modules.subwayNetwork.entity.LineAlias
;
import
org.jeecg.modules.subwayNetwork.service.ILineAliasService
;
import
java.util.List
;
import
java.util.Map
;
/**
* @describe:单元编码生成工具
*/
...
...
@@ -180,4 +183,19 @@ public class UnitCodeUtil {
public
static
String
supplementZero
(
int
numLength
,
int
num
)
{
return
String
.
format
(
"%0"
+
numLength
+
"d"
,
num
);
}
/**
* 钢轨智能单元生成
*
* @param lineAliasId 线别ID
*/
public
static
void
railIntelligentGeneration
(
String
lineAliasId
)
{
List
<
Map
<
String
,
Object
>>
lineSpecialRail
=
railManagementService
.
getLineSpecialRail
(
lineAliasId
);
// 1.判断完整的线路有没有空白部分(指剩余区间既不是道岔、曲线、竖曲线、钢轨的部分),只需要填空白部分,空白部分一定是钢轨,按照25一根的逻辑余数自成一根;
// 2.如果不存在空白部分,则定义道岔曲线竖曲线为绝对正确里程值,并且定义为特殊钢轨,相邻两个特殊钢轨之间的里程区间按照25一根的逻辑余数自成一根。
}
}
\ No newline at end of file
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