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
20a8832b
Commit
20a8832b
authored
May 10, 2023
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一码通总览sql优化
parent
b1eae7c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
33 deletions
+55
-33
EquipmentCategoryMapper.java
...s/boot/module/tzs/api/mapper/EquipmentCategoryMapper.java
+1
-1
EquipmentCategoryMapper.xml
...api/src/main/resources/mapper/EquipmentCategoryMapper.xml
+32
-21
EquipmentCategoryServiceImpl.java
...le/tzs/biz/service/impl/EquipmentCategoryServiceImpl.java
+22
-11
No files found.
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/mapper/EquipmentCategoryMapper.java
View file @
20a8832b
...
...
@@ -20,7 +20,7 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
@Select
(
"select * from tz_equipment_category where code in('1000','2000','3000','4000','5000','6000','8000','9000')"
)
List
<
EquipmentCategoryDto
>
selectClassify
();
Map
<
String
,
Object
>
getCategoryCount
(
@Param
(
"code"
)
String
code
,
@Param
(
"level"
)
String
level
,
List
<
Map
<
String
,
Object
>>
getCategoryCount
(
@Param
(
"level"
)
String
level
,
@Param
(
"orgCode"
)
String
orgCode
,
@Param
(
"companyCode"
)
String
companyCode
);
Map
<
String
,
Object
>
getAdministrativeDivision
(
@Param
(
"division"
)
String
division
,
@Param
(
"county"
)
String
county
);
...
...
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/resources/mapper/EquipmentCategoryMapper.xml
View file @
20a8832b
...
...
@@ -3,37 +3,44 @@
<mapper
namespace=
"com.yeejoin.amos.boot.module.tzs.api.mapper.EquipmentCategoryMapper"
>
<select
id=
"getCategoryCount"
resultType=
"java.util.Map"
>
SELECT (SELECT
count(*)
SELECT A."EQU_LIST" category,
IFNULL ( A.count, 0 ) waitClaim,
IFNULL ( b.count, 0 ) alreadyClaim,
IFNULL ( C.count, 0 ) refuseClaim
FROM
(
SELECT
"EQU_LIST",
COUNT ( * )
FROM
idx_biz_jg_use_info ibjui
LEFT JOIN idx_biz_jg_supervision_info ibjsi ON ibjui.RECORD = ibjsi.RECORD
LEFT JOIN idx_biz_jg_register_info ibjri ON ibjui.RECORD = ibjri.RECORD
LEFT JOIN idx_biz_jg_other_info ibjoi ON ibjui.RECORD = ibjoi.RECORD
LEFT JOIN tz_equipment_category tec ON ibjri.EQU_CATEGORY = tec.code
LEFT JOIN tz_equipment_category tec1 ON ibjri.EQU_LIST = tec1.code
WHERE
ibjoi.claim_status = '待认领'
AND ibjri."EQU_LIST" = #{code}
ibjoi.claim_status = '待认领'
<if
test=
"level == 'company'"
>
AND ibjui."USE_UNIT_CREDIT_CODE"
LIKE CONCAT('%',#{companyCode},'%')
LIKE CONCAT('%',#{companyCode},'%')
</if>
<if
test=
"level != 'company'"
>
AND ibjsi."ORG_BRANCH_CODE"
LIKE CONCAT('%',#{orgCode},'%')
AND ibjsi."ORG_BRANCH_CODE"
LIKE CONCAT('%',#{orgCode},'%')
</if>
) waitClaim ,
(SELECT
COUNT( * )
GROUP BY
"EQU_LIST"
)
A LEFT JOIN (
SELECT
"EQU_LIST",
COUNT ( * )
FROM
idx_biz_jg_use_info ibjui
LEFT JOIN idx_biz_jg_supervision_info ibjsi ON ibjui.RECORD = ibjsi.RECORD
LEFT JOIN idx_biz_jg_register_info ibjri ON ibjui.RECORD = ibjri.RECORD
LEFT JOIN idx_biz_jg_other_info ibjoi ON ibjui.RECORD = ibjoi.RECORD
LEFT JOIN tz_equipment_category tec ON ibjri.EQU_CATEGORY = tec.code
LEFT JOIN tz_equipment_category tec1 ON ibjri.EQU_LIST = tec1.code
WHERE
ibjoi.claim_status = '已认领'
AND ibjri."EQU_LIST" = #{code}
ibjoi.claim_status = '已认领'
<if
test=
"level == 'company'"
>
AND ibjui."USE_UNIT_CREDIT_CODE"
LIKE CONCAT('%',#{companyCode},'%')
...
...
@@ -42,18 +49,20 @@
AND ibjsi."ORG_BRANCH_CODE"
LIKE CONCAT('%',#{orgCode},'%')
</if>
) alreadyClaim,
(SELECT
COUNT( * )
GROUP BY
"EQU_LIST"
) b ON A."EQU_LIST" = b."EQU_LIST"
LEFT JOIN (
SELECT
"EQU_LIST",
COUNT ( * )
FROM
idx_biz_jg_use_info ibjui
LEFT JOIN idx_biz_jg_supervision_info ibjsi ON ibjui.RECORD = ibjsi.RECORD
LEFT JOIN idx_biz_jg_register_info ibjri ON ibjui.RECORD = ibjri.RECORD
LEFT JOIN idx_biz_jg_other_info ibjoi ON ibjui.RECORD = ibjoi.RECORD
LEFT JOIN tz_equipment_category tec ON ibjri.EQU_CATEGORY = tec.code
LEFT JOIN tz_equipment_category tec1 ON ibjri.EQU_LIST = tec1.code
WHERE
ibjoi.claim_status = '已拒领'
AND ibjri."EQU_LIST" = #{code}
ibjoi.claim_status = '已拒领'
<if
test=
"level == 'company'"
>
AND ibjui."USE_UNIT_CREDIT_CODE"
LIKE CONCAT('%',#{companyCode},'%')
...
...
@@ -62,7 +71,9 @@
AND ibjsi."ORG_BRANCH_CODE"
LIKE CONCAT('%',#{orgCode},'%')
</if>
) refuseClaim
GROUP BY
"EQU_LIST"
) C ON A."EQU_LIST" = C."EQU_LIST"
</select>
<select
id=
"getAdministrativeDivision"
resultType=
"java.util.Map"
>
...
...
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/EquipmentCategoryServiceImpl.java
View file @
20a8832b
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.EquInfoDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.EquipmentCategoryDto
;
...
...
@@ -29,6 +32,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.core.io.Resource
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
...
...
@@ -123,17 +127,24 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
resourceJson
=
JsonUtils
.
getResourceJson
(
equipCategory
);
List
<
Map
<
String
,
Object
>>
mapList
=
resourceJson
.
get
(
EquipmentClassifityEnum
.
BDLS
.
getCode
());
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
JSONObject
object
=
getCompanyType
();
String
level
=
object
.
getString
(
"level"
);
String
orgCode
=
object
.
getString
(
"orgCode"
);
String
companyCode
=
object
.
getString
(
"companyCode"
);
for
(
Map
map
:
mapList
)
{
Map
<
String
,
Object
>
categoryCountMap
=
equipmentCategoryMapper
.
getCategoryCount
(
map
.
get
(
"code"
).
toString
(),
level
,
orgCode
,
companyCode
);
categoryCountMap
.
put
(
"name"
,
map
.
get
(
"name"
));
categoryCountMap
.
put
(
"image"
,
map
.
get
(
"image"
));
Long
sum
=
Long
.
valueOf
(
categoryCountMap
.
get
(
"waitClaim"
).
toString
())
+
Long
.
valueOf
(
categoryCountMap
.
get
(
"alreadyClaim"
).
toString
())
+
Long
.
valueOf
(
categoryCountMap
.
get
(
"refuseClaim"
).
toString
());
categoryCountMap
.
put
(
"sum"
,
sum
);
list
.
add
(
categoryCountMap
);
ReginParams
reginParams
=
JSON
.
parseObject
(
redisUtils
.
get
(
RedisKey
.
buildReginKey
(
RequestContext
.
getExeUserId
(),
RequestContext
.
getToken
())).
toString
(),
ReginParams
.
class
);
if
(
ObjectUtils
.
isEmpty
(
reginParams
)){
return
null
;
}
String
level
=
reginParams
.
getUserModel
().
getCompanys
().
get
(
0
).
getLevel
();
String
orgCode
=
reginParams
.
getUserModel
().
getCompanys
().
get
(
0
).
getOrgCode
();
String
companyCode
=
reginParams
.
getUserModel
().
getCompanys
().
get
(
0
).
getCompanyCode
();
List
<
Map
<
String
,
Object
>>
listMap
=
equipmentCategoryMapper
.
getCategoryCount
(
level
,
orgCode
,
companyCode
);
for
(
Map
<
String
,
Object
>
map
:
mapList
)
{
for
(
Map
<
String
,
Object
>
map1
:
listMap
)
{
if
(
map
.
get
(
"code"
).
equals
(
map1
.
get
(
"category"
)))
{
map1
.
put
(
"name"
,
map
.
get
(
"name"
));
map1
.
put
(
"image"
,
map
.
get
(
"image"
));
Long
sum
=
Long
.
valueOf
(
map1
.
get
(
"waitClaim"
).
toString
())
+
Long
.
valueOf
(
map1
.
get
(
"alreadyClaim"
).
toString
())
+
Long
.
valueOf
(
map1
.
get
(
"refuseClaim"
).
toString
());
map1
.
put
(
"sum"
,
sum
);
list
.
add
(
map1
);
}
}
}
page
.
setCurrent
(
1
);
page
.
setTotal
(
list
.
size
());
...
...
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