Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
c7ff5f91
Commit
c7ff5f91
authored
Aug 05, 2022
by
xinglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*)增加单个条件查询统计
parent
dda713d6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
28 deletions
+136
-28
IdxFeignService.java
...n/amos/boot/module/tzs/flc/api/feign/IdxFeignService.java
+13
-0
InspectionService.java
...os/boot/module/tzs/flc/api/service/InspectionService.java
+15
-0
InspectionController.java
.../boot/module/tzs/biz/controller/InspectionController.java
+20
-0
InspectionServiceImpl.java
...ot/module/tzs/biz/service/impl/InspectionServiceImpl.java
+64
-28
StringUtils.java
...m/yeejoin/amos/boot/module/tzs/biz/utils/StringUtils.java
+24
-0
No files found.
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/api/feign/IdxFeignService.java
View file @
c7ff5f91
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
flc
.
api
.
feign
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.util.List
;
import
java.util.Map
;
@FeignClient
(
value
=
"AMOS-IDX"
,
path
=
"idx"
)
public
interface
IdxFeignService
{
@RequestMapping
(
"/dimensionTable/getTreeChildIds"
)
ResponseModel
<
List
<
String
>>
getTreeChildIds
(
@RequestParam
String
dimensionTableId
,
@RequestParam
String
selectValue
);
/**
* 查询表详情和表字段
*
* @param tableId
* @return
*/
@RequestMapping
(
value
=
"/table/{tableId}"
,
method
=
RequestMethod
.
GET
)
ResponseModel
<
JSONObject
>
queryByTableId
(
@PathVariable
String
tableId
);
}
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/api/service/InspectionService.java
View file @
c7ff5f91
...
...
@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.service;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.dto.BizRecordCount
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.dto.IdxUjerDto
;
...
...
@@ -13,9 +14,23 @@ public interface InspectionService {
IPage
<
IdxUjerDto
>
bizDetailList
(
String
dimensionTableId
,
String
selectValue
,
String
bizType
,
int
current
,
int
size
);
/**
* 返回多个监察统计(list)
* @param bizRecordCountList
* @return
*/
List
<
Map
<
String
,
Object
>>
bizRecordCountByField
(
List
<
BizRecordCount
>
bizRecordCountList
);
/**
* 返回单个监察统计(map)
* @param bizRecordCount
* @return
*/
Map
<
String
,
Object
>
bizRecordCountByField
(
BizRecordCount
bizRecordCount
);
JSONObject
getSafetySupervisionCode
(
String
bizTable
);
JSONObject
getSafetySupervisionInfo
();
Page
<
JSONObject
>
getMapByRegion
(
Long
regionSeq
,
String
tableId
,
String
type
);
}
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/InspectionController.java
View file @
c7ff5f91
...
...
@@ -70,6 +70,19 @@ public class InspectionController {
}
/**
* 生产、使用环节
*
* @param bizRecordCount
* @return
*/
@PostMapping
(
"/safetySupervisionForMap"
)
@ApiOperation
(
value
=
"安全监察统计"
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
public
ResponseModel
<
Map
<
String
,
Object
>>
safetySupervisionForMap
(
@RequestBody
BizRecordCount
bizRecordCount
)
{
return
ResponseHelper
.
buildResponse
(
inspectionService
.
bizRecordCountByField
(
bizRecordCount
));
}
/**
* 生成安全监察指令书编号
*
* @param bizTable
...
...
@@ -112,4 +125,11 @@ public class InspectionController {
Page
result
=
Privilege
.
agencyUserClient
.
queryForPage
(
null
,
realName
,
mobile
,
null
,
current
,
size
,
ids
).
getResult
();
return
ResponseHelper
.
buildResponse
(
result
);
}
@GetMapping
(
"/getMapByRegion/{regionSeq}"
)
@ApiOperation
(
value
=
"获取下级行政区划下的所有数据"
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
public
ResponseModel
<
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
>
getMapByRegion
(
@PathVariable
(
value
=
"regionSeq"
)
Long
regionSeq
,
@RequestParam
(
value
=
"tableId"
)
String
tableId
,
@RequestParam
(
value
=
"type"
)
String
type
)
{
return
ResponseHelper
.
buildResponse
(
inspectionService
.
getMapByRegion
(
regionSeq
,
tableId
,
type
));
}
}
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/InspectionServiceImpl.java
View file @
c7ff5f91
...
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.JsonValueUtils
;
import
com.yeejoin.amos.boot.module.tzs.api.mapper.IdxUjerMapper
;
import
com.yeejoin.amos.boot.module.tzs.biz.utils.StringUtils
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.dto.BizRecordCount
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.dto.IdxUjerDto
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.feign.IdxFeignService
;
...
...
@@ -24,6 +25,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.util.*
;
...
...
@@ -51,7 +53,7 @@ public class InspectionServiceImpl implements InspectionService {
List
<
String
>
companyIds
=
idxFeignService
.
getTreeChildIds
(
dimensionTableId
,
selectValue
).
getResult
();
Collection
<
CompanyModel
>
companyModels
=
Privilege
.
companyClient
.
companyTreeWithoutAuth
().
getResult
();
Map
<
String
,
String
>
companyMap
=
new
HashMap
<>();
convertCompanyTreeToMap
(
companyModels
,
null
,
companyMap
);
convertCompanyTreeToMap
(
companyModels
,
null
,
companyMap
);
IPage
<
IdxUjerDto
>
idxUjerPage
=
new
Page
<>(
current
,
size
);
IPage
<
IdxUjerDto
>
page
=
idxUjerMapper
.
getPage
(
idxUjerPage
,
companyIds
,
bizType
);
List
<
IdxUjerDto
>
records
=
page
.
getRecords
();
...
...
@@ -87,39 +89,42 @@ public class InspectionServiceImpl implements InspectionService {
public
List
<
Map
<
String
,
Object
>>
bizRecordCountByField
(
List
<
BizRecordCount
>
bizRecordCountList
)
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
BizRecordCount
requestData
:
bizRecordCountList
)
{
Map
map
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
requestData
),
Map
.
class
);
StrSubstitutor
ss
=
new
StrSubstitutor
(
map
);
String
selectSql
=
"SELECT "
;
if
(!
ValidationUtil
.
isEmpty
(
requestData
.
getBizRecordItems
()))
{
requestData
.
setExpression
(
buildBizRecordItems
(
requestData
.
getBizRecordItems
()));
}
if
(!
ValidationUtil
.
isEmpty
(
requestData
.
getExpression
()))
{
selectSql
+=
requestData
.
getExpression
()
+
" as count"
;
}
else
{
selectSql
+=
"COUNT(*) count"
;
}
if
(!
ValidationUtil
.
isEmpty
(
requestData
.
getTableName
()))
{
selectSql
=
selectSql
+
" FROM ${tableName}"
;
}
if
(!
ValidationUtil
.
isEmpty
(
requestData
.
getFieldKey
()))
{
selectSql
=
selectSql
+
(
selectSql
.
contains
(
"WHERE"
)
?
" AND"
:
" WHERE"
)
+
" ${fieldKey}='${fieldValue}'"
;
}
selectSql
=
ss
.
replace
(
selectSql
);
Map
<
String
,
Object
>
queryResult
=
bizJdbcTemplate
.
queryForMap
(
selectSql
);
HashMap
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"key"
,
requestData
.
getTitle
());
item
.
put
(
"value"
,
queryResult
.
get
(
"count"
));
Map
<
String
,
Object
>
item
=
bizRecordCountByField
(
requestData
);
result
.
add
(
item
);
}
return
result
;
}
@Override
public
Map
<
String
,
Object
>
bizRecordCountByField
(
BizRecordCount
bizRecordCount
)
{
Map
map
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
bizRecordCount
),
Map
.
class
);
StrSubstitutor
ss
=
new
StrSubstitutor
(
map
);
String
selectSql
=
"SELECT "
;
if
(!
ValidationUtil
.
isEmpty
(
bizRecordCount
.
getBizRecordItems
()))
{
bizRecordCount
.
setExpression
(
buildBizRecordItems
(
bizRecordCount
.
getBizRecordItems
()));
}
if
(!
ValidationUtil
.
isEmpty
(
bizRecordCount
.
getExpression
()))
{
selectSql
+=
bizRecordCount
.
getExpression
()
+
" as count"
;
}
else
{
selectSql
+=
"COUNT(*) count"
;
}
if
(!
ValidationUtil
.
isEmpty
(
bizRecordCount
.
getTableName
()))
{
selectSql
=
selectSql
+
" FROM ${tableName}"
;
}
if
(!
ValidationUtil
.
isEmpty
(
bizRecordCount
.
getFieldKey
()))
{
selectSql
=
selectSql
+
(
selectSql
.
contains
(
"WHERE"
)
?
" AND"
:
" WHERE"
)
+
" ${fieldKey}='${fieldValue}'"
;
}
selectSql
=
ss
.
replace
(
selectSql
);
Map
<
String
,
Object
>
queryResult
=
bizJdbcTemplate
.
queryForMap
(
selectSql
);
HashMap
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"key"
,
bizRecordCount
.
getTitle
());
item
.
put
(
"value"
,
queryResult
.
get
(
"count"
));
return
item
;
}
@Override
public
JSONObject
getSafetySupervisionCode
(
String
bizTable
)
{
String
safetySupervisionCode
=
"(%s)市监特令中[%s]第 %s 号"
;
AgencyUserModel
agencyUserModel
=
Privilege
.
agencyUserClient
.
getme
().
getResult
();
...
...
@@ -166,6 +171,37 @@ public class InspectionServiceImpl implements InspectionService {
return
jsonObject
;
}
@Override
public
Page
<
JSONObject
>
getMapByRegion
(
Long
regionSeq
,
String
tableId
,
String
type
)
{
Page
<
JSONObject
>
page
=
new
Page
<>(
1
,
10
);
Collection
<
RegionModel
>
result
=
Systemctl
.
regionClient
.
queryByParentId
(
regionSeq
).
getResult
();
JSONObject
tableMap
=
idxFeignService
.
queryByTableId
(
tableId
).
getResult
();
String
tableName
=
tableMap
.
getString
(
"tableName"
);
JSONArray
tableCols
=
tableMap
.
getJSONArray
(
"tableCols"
);
Map
<
String
,
String
>
columMap
=
new
HashMap
<>();
tableCols
.
forEach
(
x
->
{
Map
<
String
,
String
>
obj
=
(
Map
)
x
;
if
(!
"type"
.
equals
(
obj
.
get
(
"columnName"
)))
{
columMap
.
put
(
obj
.
get
(
"name"
),
obj
.
get
(
"columnName"
));
}
});
JSONObject
jsonObject
=
new
JSONObject
();
String
selectSql
=
"SELECT * FROM "
+
tableName
+
" WHERE type="
+
StringUtils
.
str2sqlValue
(
type
);
Map
<
String
,
Object
>
objectMap
=
bizJdbcTemplate
.
queryForMap
(
selectSql
);
result
.
forEach
(
x
->
{
String
regionName
=
columMap
.
get
(
x
.
getRegionName
());
jsonObject
.
put
(
regionName
,
objectMap
.
get
(
regionName
));
});
if
(!
ValidationUtil
.
isEmpty
(
jsonObject
)){
page
.
setTotal
(
1
);
List
<
JSONObject
>
list
=
new
ArrayList
();
list
.
add
(
jsonObject
);
page
.
setRecords
(
list
);
}
return
page
;
}
private
String
buildBizRecordItems
(
List
<
BizRecordCount
.
BizRecordItem
>
bizRecordItems
)
{
String
sql
=
""
;
for
(
BizRecordCount
.
BizRecordItem
item
:
bizRecordItems
)
{
...
...
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/utils/StringUtils.java
0 → 100644
View file @
c7ff5f91
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
utils
;
import
java.util.Map
;
import
java.util.StringJoiner
;
/**
* @Author: xl
* @Description:
* @Date: 2022/8/4 9:08
*/
public
class
StringUtils
{
public
static
StringJoiner
getWhereSql
(
String
operator
,
Map
<
String
,
String
>
map
){
StringJoiner
stringJoiner
=
new
StringJoiner
(
" "
+
operator
+
" "
);
for
(
Map
.
Entry
entry
:
map
.
entrySet
())
{
stringJoiner
.
add
(
entry
.
getKey
()
+
"="
+
str2sqlValue
(
entry
.
getValue
().
toString
()));
}
return
stringJoiner
;
}
public
static
String
str2sqlValue
(
String
str
){
return
"'"
+
str
+
"'"
;
}
}
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