Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
pipeline-network
Commits
c6039ccb
Commit
c6039ccb
authored
Jul 23, 2026
by
wujipeng
Browse files
优化
parent
5c48a862
Changes
6
Show whitespace changes
Inline
Side-by-side
src/main/java/com/example/pipelinenetwork/controller/BasicController.java
0 → 100644
View file @
c6039ccb
package
com.example.pipelinenetwork.controller
;
import
com.example.pipelinenetwork.pojo.dto.RoadDTO
;
import
com.example.pipelinenetwork.result.Result
;
import
com.example.pipelinenetwork.service.BasicService
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.Map
;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/7/23 9:59
* @Version: 1.0
*/
@RestController
@RequestMapping
(
"/basic"
)
public
class
BasicController
{
@Resource
private
BasicService
basicService
;
/**
* 详情查询
*/
@PostMapping
(
"/detail"
)
public
Result
<
Map
<
String
,
Integer
>>
roadDetail
(
@RequestBody
RoadDTO
roadDTO
)
{
return
Result
.
success
(
basicService
.
roadDetail
(
roadDTO
));
}
/**
* 各路段检测修复汇总
*/
@GetMapping
(
"/summary"
)
public
Result
<
Map
<
String
,
Integer
>>
roadSummary
(
@RequestParam
(
name
=
"type"
)
String
type
)
{
return
Result
.
success
(
basicService
.
roadSummary
(
type
));
}
}
src/main/java/com/example/pipelinenetwork/controller/RoadController.java
View file @
c6039ccb
...
...
@@ -9,7 +9,6 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/road"
)
...
...
@@ -18,6 +17,9 @@ public class RoadController {
@Resource
private
RoadService
roadService
;
/**
* 道路匹配
*/
@GetMapping
(
"/match"
)
public
Result
<
RoadVO
>
match
(
@RequestParam
Double
lng
,
...
...
@@ -25,35 +27,21 @@ public class RoadController {
return
Result
.
success
(
roadService
.
match
(
lng
,
lat
));
}
/**
* 上传Excel文件并生成sql语句
*/
@PostMapping
(
"/import"
)
public
List
<
String
>
importRoadData
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
return
roadService
.
importRoadData
(
file
);
}
/**
* 详情查询
*/
@PostMapping
(
"/detail"
)
public
Result
<
Map
<
String
,
Integer
>>
roadDetail
(
@RequestBody
RoadDTO
roadDTO
)
{
return
Result
.
success
(
roadService
.
roadDetail
(
roadDTO
));
}
/**
* 道路详情
*/
@PostMapping
(
"/detail
/name
"
)
@PostMapping
(
"/detail"
)
public
Result
<
RoadVO
>
queryByRoadName
(
@RequestBody
RoadDTO
roadDTO
)
{
return
Result
.
success
(
roadService
.
queryByRoadName
(
roadDTO
)
)
;
return
roadService
.
queryByRoadName
(
roadDTO
);
}
/**
*
各路段检测修复汇总
*
上传Excel文件并生成sql语句
*/
@
Ge
tMapping
(
"/
summary
"
)
public
Result
<
Map
<
String
,
Integer
>>
roadSummary
(
@RequestParam
(
name
=
"type"
)
String
type
)
{
return
Result
.
success
(
roadService
.
roadSummary
(
type
)
);
@
Pos
tMapping
(
"/
import
"
)
public
List
<
String
>
importRoadData
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
return
roadService
.
importRoadData
(
file
);
}
}
\ No newline at end of file
src/main/java/com/example/pipelinenetwork/service/BasicService.java
View file @
c6039ccb
package
com.example.pipelinenetwork.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.example.pipelinenetwork.pojo.dto.RoadDTO
;
import
com.example.pipelinenetwork.pojo.entity.BasicEntity
;
import
java.util.
List
;
import
java.util.
Map
;
/**
* @Author: wujipeng
...
...
@@ -12,8 +13,7 @@ import java.util.List;
* @Version: 1.0
*/
public
interface
BasicService
extends
IService
<
BasicEntity
>
{
List
<
String
>
getRelIdsByRegion
(
String
region
);
List
<
String
>
getRelIdsByRoadName
(
String
roadName
);
Map
<
String
,
Integer
>
roadDetail
(
RoadDTO
roadDTO
);
Map
<
String
,
Integer
>
roadSummary
(
String
type
);
}
src/main/java/com/example/pipelinenetwork/service/RoadService.java
View file @
c6039ccb
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.example.pipelinenetwork.pojo.dto.RoadDTO
;
import
com.example.pipelinenetwork.pojo.vo.RoadVO
;
import
com.example.pipelinenetwork.pojo.entity.RoadEntity
;
import
com.example.pipelinenetwork.result.Result
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
...
...
@@ -21,10 +22,8 @@ public interface RoadService extends IService<RoadEntity> {
List
<
String
>
importRoadData
(
MultipartFile
file
)
throws
Exception
;
Map
<
String
,
Integer
>
roadDetail
(
RoadDTO
roadDTO
);
Result
<
RoadVO
>
queryByRoadName
(
RoadDTO
roadDTO
);
RoadVO
queryByRoadName
(
RoadDTO
roadDTO
);
Map
<
String
,
Integer
>
roadSummary
(
String
type
);
}
src/main/java/com/example/pipelinenetwork/service/impl/BasicServiceImpl.java
View file @
c6039ccb
package
com.example.pipelinenetwork.service.impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.example.pipelinenetwork.mapper.BasicMapper
;
import
com.example.pipelinenetwork.pojo.dto.RoadDTO
;
import
com.example.pipelinenetwork.pojo.entity.BasicEntity
;
import
com.example.pipelinenetwork.pojo.entity.DefectEntity
;
import
com.example.pipelinenetwork.service.BasicService
;
import
com.example.pipelinenetwork.service.DefectService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Author: wujipeng
...
...
@@ -16,13 +23,63 @@ import java.util.List;
*/
@Service
public
class
BasicServiceImpl
extends
ServiceImpl
<
BasicMapper
,
BasicEntity
>
implements
BasicService
{
@Resource
private
DefectService
defectService
;
@Override
public
List
<
String
>
getRelIdsByRegion
(
String
region
)
{
return
baseMapper
.
getRelIdsByRegion
(
region
);
public
Map
<
String
,
Integer
>
roadDetail
(
RoadDTO
roadDTO
)
{
Map
<
String
,
Integer
>
result
=
new
HashMap
<>();
//获取relId
List
<
String
>
relIds
=
baseMapper
.
getRelIdsByRegion
(
roadDTO
.
getRegion
());
if
(
"检测"
.
equals
(
roadDTO
.
getType
()))
{
List
<
DefectEntity
>
defectList
=
defectService
.
list
(
new
LambdaQueryWrapper
<
DefectEntity
>()
.
in
(
DefectEntity:
:
getRelId
,
relIds
).
eq
(
DefectEntity:
:
getType
,
roadDTO
.
getDefectType
())
.
eq
(
DefectEntity:
:
getLevel
,
roadDTO
.
getLev
())
);
for
(
DefectEntity
defectEntity
:
defectList
)
{
if
(
result
.
containsKey
(
defectEntity
.
getName
()))
{
result
.
put
(
defectEntity
.
getName
(),
result
.
get
(
defectEntity
.
getName
())
+
defectEntity
.
getNum
());
}
else
{
result
.
put
(
defectEntity
.
getName
(),
defectEntity
.
getNum
());
}
}
}
else
if
(
"修复"
.
equals
(
roadDTO
.
getType
()))
{
}
return
result
;
}
@Override
public
List
<
String
>
getRelIdsByRoadName
(
String
roadName
)
{
return
baseMapper
.
getRelIdsByRoadName
(
roadName
);
public
Map
<
String
,
Integer
>
roadSummary
(
String
type
)
{
Map
<
String
,
Integer
>
result
=
new
HashMap
<>();
//获取基础信息
List
<
BasicEntity
>
basicList
=
list
();
Map
<
String
,
String
>
basicMap
=
new
HashMap
<>();
for
(
BasicEntity
basicEntity
:
basicList
)
{
basicMap
.
put
(
basicEntity
.
getRelId
(),
basicEntity
.
getRoadName
());
}
if
(
"检测"
.
equals
(
type
))
{
List
<
DefectEntity
>
defectList
=
defectService
.
list
();
Map
<
String
,
Integer
>
defectMap
=
new
HashMap
<>();
for
(
DefectEntity
defectEntity
:
defectList
)
{
if
(
defectMap
.
containsKey
(
defectEntity
.
getRelId
()))
{
defectMap
.
put
(
defectEntity
.
getRelId
(),
defectMap
.
get
(
defectEntity
.
getRelId
())
+
defectEntity
.
getNum
());
}
else
{
defectMap
.
put
(
defectEntity
.
getRelId
(),
defectEntity
.
getNum
());
}
}
basicMap
.
forEach
((
key
,
value
)
->
{
if
(
defectMap
.
containsKey
(
key
))
{
Integer
i
=
defectMap
.
get
(
key
);
result
.
put
(
value
,
i
);
}
else
{
result
.
put
(
value
,
0
);
}
});
}
else
if
(
"修复"
.
equals
(
type
))
{
}
return
result
;
}
}
src/main/java/com/example/pipelinenetwork/service/impl/RoadServiceImpl.java
View file @
c6039ccb
...
...
@@ -8,6 +8,7 @@ import com.example.pipelinenetwork.pojo.entity.BasicEntity;
import
com.example.pipelinenetwork.pojo.entity.DefectEntity
;
import
com.example.pipelinenetwork.pojo.entity.RoadEntity
;
import
com.example.pipelinenetwork.pojo.vo.RoadVO
;
import
com.example.pipelinenetwork.result.Result
;
import
com.example.pipelinenetwork.service.BasicService
;
import
com.example.pipelinenetwork.service.DefectService
;
import
com.example.pipelinenetwork.service.RoadService
;
...
...
@@ -22,7 +23,6 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.annotation.Resource
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -60,30 +60,7 @@ public class RoadServiceImpl extends ServiceImpl<RoadMapper, RoadEntity> impleme
}
@Override
public
Map
<
String
,
Integer
>
roadDetail
(
RoadDTO
roadDTO
)
{
Map
<
String
,
Integer
>
result
=
new
HashMap
<>();
//获取relId
List
<
String
>
relIds
=
basicService
.
getRelIdsByRegion
(
roadDTO
.
getRegion
());
if
(
"检测"
.
equals
(
roadDTO
.
getType
()))
{
List
<
DefectEntity
>
defectList
=
defectService
.
list
(
new
LambdaQueryWrapper
<
DefectEntity
>()
.
in
(
DefectEntity:
:
getRelId
,
relIds
).
eq
(
DefectEntity:
:
getType
,
roadDTO
.
getDefectType
())
.
eq
(
DefectEntity:
:
getLevel
,
roadDTO
.
getLev
())
);
for
(
DefectEntity
defectEntity
:
defectList
)
{
if
(
result
.
containsKey
(
defectEntity
.
getName
()))
{
result
.
put
(
defectEntity
.
getName
(),
result
.
get
(
defectEntity
.
getName
())
+
defectEntity
.
getNum
());
}
else
{
result
.
put
(
defectEntity
.
getName
(),
defectEntity
.
getNum
());
}
}
}
else
if
(
"修复"
.
equals
(
roadDTO
.
getType
()))
{
}
return
result
;
}
@Override
public
RoadVO
queryByRoadName
(
RoadDTO
roadDTO
)
{
public
Result
<
RoadVO
>
queryByRoadName
(
RoadDTO
roadDTO
)
{
RoadVO
result
=
new
RoadVO
();
//管道数量
int
pipeNum
=
0
;
...
...
@@ -103,6 +80,9 @@ public class RoadServiceImpl extends ServiceImpl<RoadMapper, RoadEntity> impleme
pipeNum
+=
basicEntity
.
getPipeNum
();
length
+=
basicEntity
.
getDetectionLength
();
}
if
(
relIds
.
isEmpty
())
{
return
Result
.
error
(
"未找到该名称的路段"
);
}
if
(
"检测"
.
equals
(
roadDTO
.
getType
()))
{
List
<
DefectEntity
>
defectList
=
defectService
.
list
(
new
LambdaQueryWrapper
<
DefectEntity
>()
.
in
(
DefectEntity:
:
getRelId
,
relIds
).
eq
(
DefectEntity:
:
getType
,
roadDTO
.
getDefectType
())
...
...
@@ -124,40 +104,7 @@ public class RoadServiceImpl extends ServiceImpl<RoadMapper, RoadEntity> impleme
result
.
setStructuralDefect
(
structuralDefect
);
result
.
setFunctionalDefect
(
functionalDefect
);
result
.
setData
(
data
);
return
result
;
}
@Override
public
Map
<
String
,
Integer
>
roadSummary
(
String
type
)
{
Map
<
String
,
Integer
>
result
=
new
HashMap
<>();
//获取基础信息
List
<
BasicEntity
>
basicList
=
basicService
.
list
();
Map
<
String
,
String
>
basicMap
=
new
HashMap
<>();
for
(
BasicEntity
basicEntity
:
basicList
)
{
basicMap
.
put
(
basicEntity
.
getRelId
(),
basicEntity
.
getRoadName
());
}
if
(
"检测"
.
equals
(
type
))
{
List
<
DefectEntity
>
defectList
=
defectService
.
list
();
Map
<
String
,
Integer
>
defectMap
=
new
HashMap
<>();
for
(
DefectEntity
defectEntity
:
defectList
)
{
if
(
defectMap
.
containsKey
(
defectEntity
.
getRelId
()))
{
defectMap
.
put
(
defectEntity
.
getRelId
(),
defectMap
.
get
(
defectEntity
.
getRelId
())
+
defectEntity
.
getNum
());
}
else
{
defectMap
.
put
(
defectEntity
.
getRelId
(),
defectEntity
.
getNum
());
}
}
basicMap
.
forEach
((
key
,
value
)
->
{
if
(
defectMap
.
containsKey
(
key
)){
Integer
i
=
defectMap
.
get
(
key
);
result
.
put
(
value
,
i
);
}
else
{
result
.
put
(
value
,
0
);
}
});
}
else
if
(
"修复"
.
equals
(
type
))
{
}
return
result
;
return
Result
.
success
(
result
);
}
/**
...
...
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