Merge remote-tracking branch 'origin/main'

# Conflicts:
#	resources/mybatis/index/IndexHomeDetailsMapper.xml
This commit is contained in:
liang.chao 2026-02-06 09:40:26 +08:00
commit 052bb6d687
3 changed files with 782 additions and 702 deletions

View File

@ -10,273 +10,280 @@
<select id="getMaTypeDetails" parameterType="com.bonus.index.beans.IndexHomeDetailsBean" resultMap="index">
SELECT
rs.typeId,
mat2.`NAME` maType,
mat1.`NAME` maName,
mat1.UNIT as maUnit,
SUM(rs.storageNum)+SUM(rs.inuseNum) +SUM(rs.repairNum) as maTotal,
SUM(rs.storageNum) storageNum,
SUM(rs.inuseNum) inuseNum,
SUM(rs.repairNum) repairNum,
SUM(rs.scrapNum) scrapNum,
SUM(rs.projectNum) projectNum,
SUM(rs.inuseCount) inuseCount,
SUM(rs.backCount) backCount,
SUM(rs.pyNum) as pyNum,
SUM(rs.pkNum) as pkNum,
rs.isCount
FROM
(
SELECT
mat1.ID AS typeId,
mat1.NUM storageNum,
0 inuseNum,
0 repairNum,
0 scrapNum,
0 projectNum,
0 inuseCount,
0 backCount,
0 as pyNum,
0 as pkNum,
mat1.IS_COUNT AS isCount
FROM
mm_type mat1
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
mat1.`LEVEL` = 4
AND mat1.IS_ACTIVE = '1'
GROUP BY
mat1.ID
UNION
SELECT
typeId,
0 storageNum,
sum( leaseNum ) - SUM( backNum ) inuseNum,
0 repairNum,
0 scrapNum,
0 projectNum,
sum( leaseNum ) inuseCount,
SUM( backNum ) backCount,
0 as pyNum,
0 as pkNum,
isCount AS isCount
FROM
(
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
SUM( wir.NUM ) AS leaseNum,
0 AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_task_record wtr ON wir.SUP_ID = wtr.ID
LEFT JOIN wf_task_record wtr2 ON wtr.SUP_ID = wtr2.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
LEFT JOIN wf_collar_details wcd ON wcd.TASK_ID = wtr.SUP_ID
AND wcd.MODEL_ID = wir.MODEL_ID
WHERE
wir.TYPE = 2
AND wtr2.IS_ACTIVE = 1
AND wcd.IS_APPROVAL = 1
GROUP BY
mt.ID UNION
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
0 AS leaseNum,
SUM( wir.NUM ) AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_return_material_details wrd ON wir.SUP_ID = wrd.ID
LEFT JOIN wf_task_record wtr ON wrd.TASK_ID = wtr.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
WHERE
wir.TYPE = 4
AND wtr.IS_ACTIVE = 1
GROUP BY
mt.ID
) a
GROUP BY
typeId
UNION
SELECT
typeId,
0 storageNum,
0 inuseNum,
SUM(repairNum) + SUM(checkNum) + SUM(waitInputNum) as repairNum,
0 scrapNum,
0 projectNum,
0 inuseCount,
0 backCount,
0 as pyNum,
0 as pkNum,
isCount
FROM
(
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
SUM( wrd.REPAIR_NUM ) - SUM( wrd.ALREPAIR_NUM ) - SUM( SCRAP_NUM ) AS repairNum,
0 checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_repair_details wrd
LEFT JOIN mm_type mat1 ON wrd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrd.MODEL_ID
UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
SUM( wrc.CHECK_NUM ) - SUM( wrc.ALCHECK_NUM ) AS checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_repair_check wrc
LEFT JOIN mm_type mat1 ON wrc.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrc.MODEL_ID
UNION
SELECT DISTINCT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
0 checkNum,
0 AS scrapNum,
0 loseNum,
SUM(
IFNULL( PRE_PUT_NUM, 0 )) - sum(
IFNULL( AL_PUT_NUM, 0 )) AS waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_put_storage_details wpd
LEFT JOIN mm_type mat1 ON wpd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wpd.IS_SURE = 0
GROUP BY
wpd.MODEL_ID
) res
GROUP BY typeId
UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 inuseNum,
0 as repairNum,
SUM( wsd.ALSCRAP_NUM ) AS scrapNum ,
0 projectNum,
0 inuseCount,
0 backCount,
0 as pyNum,
0 as pkNum,
mat1.IS_COUNT AS isCount
select * from (
SELECT
rs.typeId,
mat2.`NAME` maType,
mat1.`NAME` maName,
mat1.UNIT as maUnit,
SUM(rs.storageNum)+SUM(rs.inuseNum) +SUM(rs.repairNum) as maTotal,
SUM(rs.storageNum) storageNum,
SUM(rs.inuseNum) inuseNum,
SUM(rs.repairNum) repairNum,
SUM(rs.scrapNum) scrapNum,
SUM(rs.projectNum) projectNum,
SUM(rs.inuseCount) inuseCount,
SUM(rs.backCount) backCount,
SUM(rs.pyNum) as pyNum,
SUM(rs.pkNum) as pkNum,
rs.isCount
FROM
wf_scrap_details wsd
LEFT JOIN mm_type mat1 ON wsd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
(
SELECT
mat1.ID AS typeId,
mat1.NUM storageNum,
0 inuseNum,
0 repairNum,
0 scrapNum,
0 projectNum,
0 inuseCount,
0 backCount,
0 as pyNum,
0 as pkNum,
mat1.IS_COUNT AS isCount
FROM
mm_type mat1
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wsd.IS_SURE = 1
mat1.`LEVEL` = 4
AND mat1.IS_ACTIVE = '1'
GROUP BY
wsd.MODEL_ID
UNION
mat1.ID
UNION
SELECT
mps.type AS typeId,
0 storageNum,
0 inuseNum,
0 as repairNum,
0 AS scrapNum ,
COUNT(DISTINCT wla.PROJECT) as projectNum ,
0 inuseCount,
0 backCount,
0 as pyNum,
0 as pkNum,
mat1.IS_COUNT AS isCount
FROM
ma_type_project_storage mps
LEFT JOIN wf_lease_agreement wla on mps.agreement_id = wla.ID
LEFT JOIN mm_type mat1 ON mps.type = mat1.ID
WHERE mps.`status` = 1
GROUP BY mps.type
UNION
SELECT
typeId,
0 storageNum,
0 inuseNum,
0 as repairNum,
0 AS scrapNum ,
0 as projectNum ,
0 inuseCount,
0 backCount,
SUM(pyNum) as pyNum,
SUM(pkNum) as pkNum,
isCount
FROM
(
SELECT
mli.TYPE_ID as typeId,
mli.IS_PROFIT as type,
IF(mli.IS_PROFIT =1,SUM(mli.IN_NUMS),0) as pyNum,
IF(mli.IS_PROFIT =0,SUM(mli.IN_NUMS),0) as pkNum,
mat1.IS_COUNT AS isCount
FROM
ma_lib_inventroy mli
LEFT JOIN mm_type mat1 ON mli.TYPE_ID = mat1.ID
GROUP BY mli.TYPE_ID,mli.IS_PROFIT
) res
GROUP BY typeId
) rs
LEFT JOIN mm_type mat1 ON rs.typeId = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
<where>
<if test="maName != null and maName != ''">
and mat1.`NAME` like concat ('%',#{maName},'%')
</if>
<if test="maType != null and maType != ''">
and mat2.`NAME` like concat ('%',#{maType},'%')
</if>
<if test="isCount != null and isCount != ''">
and rs.isCount = #{isCount}
</if>
</where>
GROUP BY rs.typeId
SELECT
typeId,
0 storageNum,
sum( leaseNum ) - SUM( backNum ) inuseNum,
0 repairNum,
0 scrapNum,
0 projectNum,
sum( leaseNum ) inuseCount,
SUM( backNum ) backCount,
0 as pyNum,
0 as pkNum,
isCount AS isCount
FROM
(
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
SUM( wir.NUM ) AS leaseNum,
0 AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_task_record wtr ON wir.SUP_ID = wtr.ID
LEFT JOIN wf_task_record wtr2 ON wtr.SUP_ID = wtr2.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
LEFT JOIN wf_collar_details wcd ON wcd.TASK_ID = wtr.SUP_ID
AND wcd.MODEL_ID = wir.MODEL_ID
WHERE
wir.TYPE = 2
AND wtr2.IS_ACTIVE = 1
AND wcd.IS_APPROVAL = 1
GROUP BY
mt.ID UNION
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
0 AS leaseNum,
SUM( wir.NUM ) AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_return_material_details wrd ON wir.SUP_ID = wrd.ID
LEFT JOIN wf_task_record wtr ON wrd.TASK_ID = wtr.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
WHERE
wir.TYPE = 4
AND wtr.IS_ACTIVE = 1
GROUP BY
mt.ID
) a
GROUP BY
typeId
UNION
SELECT
typeId,
0 storageNum,
0 inuseNum,
SUM(repairNum) + SUM(checkNum) + SUM(waitInputNum) as repairNum,
0 scrapNum,
0 projectNum,
0 inuseCount,
0 backCount,
0 as pyNum,
0 as pkNum,
isCount
FROM
(
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
SUM( wrd.REPAIR_NUM ) - SUM( wrd.ALREPAIR_NUM ) - SUM( SCRAP_NUM ) AS repairNum,
0 checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_repair_details wrd
LEFT JOIN mm_type mat1 ON wrd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrd.MODEL_ID
UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
SUM( wrc.CHECK_NUM ) - SUM( wrc.ALCHECK_NUM ) AS checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_repair_check wrc
LEFT JOIN mm_type mat1 ON wrc.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrc.MODEL_ID
UNION
SELECT DISTINCT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
0 checkNum,
0 AS scrapNum,
0 loseNum,
SUM(
IFNULL( PRE_PUT_NUM, 0 )) - sum(
IFNULL( AL_PUT_NUM, 0 )) AS waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_put_storage_details wpd
LEFT JOIN mm_type mat1 ON wpd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wpd.IS_SURE = 0
GROUP BY
wpd.MODEL_ID
) res
GROUP BY typeId
UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 inuseNum,
0 as repairNum,
SUM( wsd.ALSCRAP_NUM ) AS scrapNum ,
0 projectNum,
0 inuseCount,
0 backCount,
0 as pyNum,
0 as pkNum,
mat1.IS_COUNT AS isCount
FROM
wf_scrap_details wsd
LEFT JOIN mm_type mat1 ON wsd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wsd.IS_SURE = 1
GROUP BY
wsd.MODEL_ID
UNION
SELECT
mps.type AS typeId,
0 storageNum,
0 inuseNum,
0 as repairNum,
0 AS scrapNum ,
COUNT(DISTINCT wla.PROJECT) as projectNum ,
0 inuseCount,
0 backCount,
0 as pyNum,
0 as pkNum,
mat1.IS_COUNT AS isCount
FROM
ma_type_project_storage mps
LEFT JOIN wf_lease_agreement wla on mps.agreement_id = wla.ID
LEFT JOIN mm_type mat1 ON mps.type = mat1.ID
WHERE mps.`status` = 1
GROUP BY mps.type
UNION
SELECT
typeId,
0 storageNum,
0 inuseNum,
0 as repairNum,
0 AS scrapNum ,
0 as projectNum ,
0 inuseCount,
0 backCount,
SUM(pyNum) as pyNum,
SUM(pkNum) as pkNum,
isCount
FROM
(
SELECT
mli.TYPE_ID as typeId,
mli.IS_PROFIT as type,
IF(mli.IS_PROFIT =1,SUM(mli.IN_NUMS),0) as pyNum,
IF(mli.IS_PROFIT =0,SUM(mli.IN_NUMS),0) as pkNum,
mat1.IS_COUNT AS isCount
FROM
ma_lib_inventroy mli
LEFT JOIN mm_type mat1 ON mli.TYPE_ID = mat1.ID
GROUP BY mli.TYPE_ID,mli.IS_PROFIT
) res
GROUP BY typeId
) rs
LEFT JOIN mm_type mat1 ON rs.typeId = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
<where>
<if test="maName != null and maName != ''">
and mat1.`NAME` like concat ('%',#{maName},'%')
</if>
<if test="maType != null and maType != ''">
and mat2.`NAME` like concat ('%',#{maType},'%')
</if>
</where>
GROUP BY rs.typeId
) a WHERE
typeId IN (
SELECT DISTINCT
mt.ID
FROM
mm_type mt
WHERE
mt.`LEVEL` = 4
AND mt.IS_ACTIVE = 1
)
</select>
@ -905,104 +912,212 @@
</select>
<select id="getProjectDiff" parameterType="com.bonus.index.beans.IndexProjectBean" resultType="com.bonus.index.beans.IndexProjectBean">
SELECT
id as projectId,
projectName,
companyId,
companyName,
SUM( leaseNum ) AS useCount,
SUM( backNum ) AS returnCount,
SUM( leaseNum ) - SUM( backNum ) diffCount ,
firstTime,
lastTime,
max(backTime) as backTime,subName
SELECT
id as projectId,
projectName,
companyId,
companyName,
SUM( leaseNum ) AS useCount,
SUM( backNum ) AS returnCount,
SUM( leaseNum ) - SUM( backNum ) diffCount ,
firstTime,
lastTime,
max(backTime) as backTime,subName
FROM
(
SELECT
wla.PROJECT as id,
bp.`NAME` AS projectName,
bc.ID as companyId,
bc.`NAME` as companyName,
wla.`CODE` AS agreementCode,
SUM( wir.NUM ) AS leaseNum,
"0" AS backNum,
wla.ID AS agreementId ,
min(wir.time) as firstTime,
max(wir.time) as lastTime,
wir.time as backTime,real_sub.subName
FROM
wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
left join(
SELECT wla.PROJECT proId ,GROUP_CONCAT( distinct bu.`NAME`) subName
FROM wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
left join bm_unit bu on bu.id =wla.LEASE_COMPANY
where bu.`NAME` is not null AND wtr.IS_ACTIVE = 1
GROUP BY wla.PROJECT
) real_sub on real_sub.proId=wla.PROJECT
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
LEFT JOIN bm_company bc on bp.COMPANY_ID = bc.ID
LEFT JOIN wf_task_record wte ON wtr.ID = wte.SUP_ID
LEFT JOIN wf_info_record wir ON wte.ID = wir.SUP_ID
WHERE
wir.TYPE = 2
AND wtr.IS_ACTIVE = 1
<if test="projectId != null and projectId != ''">
and wla.PROJECT = #{projectId}
</if>
GROUP BY
wla.ID UNION
SELECT
wla.PROJECT as id,
bp.`NAME` AS projectName,
bc.ID as companyId,
bc.`NAME` as companyName,
wla.`CODE` AS agreementCode,
"0" AS leaseNum,
SUM( wir.NUM ) AS backNum,
wla.ID AS agreementId ,
"" as firstTime,
"" as lastTime,
max(wir.time) as backTime,real_sub.subName
FROM
wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
left join(
SELECT wla.PROJECT proId ,GROUP_CONCAT( distinct bu.`NAME`) subName
FROM wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
left join bm_unit bu on bu.id =wla.LEASE_COMPANY
where bu.`NAME` is not null AND wtr.IS_ACTIVE = 1
GROUP BY wla.PROJECT
) real_sub on real_sub.proId= wla.PROJECT
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
LEFT JOIN bm_company bc on bp.COMPANY_ID = bc.ID
LEFT JOIN wf_return_material_details wrd ON wtr.ID = wrd.TASK_ID
LEFT JOIN wf_info_record wir ON wrd.ID = wir.SUP_ID
WHERE wtr.IS_ACTIVE = 1 AND wir.TYPE = 4
<if test="projectId != null and projectId != ''">
and wla.PROJECT = #{projectId}
</if>
(
SELECT
wla.PROJECT as id,
bp.`NAME` AS projectName,
bc.ID as companyId,
bc.`NAME` as companyName,
wla.`CODE` AS agreementCode,
SUM( wir.NUM ) AS leaseNum,
"0" AS backNum,
wla.ID AS agreementId ,
min(wir.time) as firstTime,
max(wir.time) as lastTime,
wir.time as backTime,real_sub.subName
FROM
wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
left join(
SELECT wla.PROJECT proId ,GROUP_CONCAT( distinct bu.`NAME`) subName
FROM wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
left join bm_unit bu on bu.id =wla.LEASE_COMPANY
where bu.`NAME` is not null AND wtr.IS_ACTIVE = 1
GROUP BY wla.PROJECT
) real_sub on real_sub.proId=wla.PROJECT
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
LEFT JOIN bm_company bc on bp.COMPANY_ID = bc.ID
LEFT JOIN wf_task_record wte ON wtr.ID = wte.SUP_ID
LEFT JOIN wf_info_record wir ON wte.ID = wir.SUP_ID
WHERE
wir.TYPE = 2
AND wtr.IS_ACTIVE = 1
<if test="projectId != null and projectId != ''">
and wla.PROJECT = #{projectId}
</if>
GROUP BY
wla.ID UNION
SELECT
wla.PROJECT as id,
bp.`NAME` AS projectName,
bc.ID as companyId,
bc.`NAME` as companyName,
wla.`CODE` AS agreementCode,
"0" AS leaseNum,
SUM( wir.NUM ) AS backNum,
wla.ID AS agreementId ,
"" as firstTime,
"" as lastTime,
max(wir.time) as backTime,real_sub.subName
FROM
wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
left join(
SELECT wla.PROJECT proId ,GROUP_CONCAT( distinct bu.`NAME`) subName
FROM wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
left join bm_unit bu on bu.id =wla.LEASE_COMPANY
where bu.`NAME` is not null AND wtr.IS_ACTIVE = 1
GROUP BY wla.PROJECT
) real_sub on real_sub.proId= wla.PROJECT
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
LEFT JOIN bm_company bc on bp.COMPANY_ID = bc.ID
LEFT JOIN wf_return_material_details wrd ON wtr.ID = wrd.TASK_ID
LEFT JOIN wf_info_record wir ON wrd.ID = wir.SUP_ID
WHERE wtr.IS_ACTIVE = 1 AND wir.TYPE = 4
<if test="projectId != null and projectId != ''">
and wla.PROJECT = #{projectId}
</if>
GROUP BY
wla.ID
) a
GROUP BY
wla.ID
union
SELECT
bp.id AS id,
bp.`NAME` AS projectName,
bc.ID AS companyId,
bc.`NAME` AS companyName,
"" AS agreementCode,
"0" AS leaseNum,
"0" AS backNum,
"0" AS agreementId,
"" AS firstTime,
"" AS lastTime,
"" AS backTime,
"" AS subName
FROM
bm_project bp
LEFT JOIN bm_company bc ON bp.COMPANY_ID = bc.ID
WHERE
bp.IS_ACTIVE = 1
AND bp.id NOT IN (
SELECT
id
FROM
(
SELECT
wla.PROJECT AS id,
bp.`NAME` AS projectName,
bc.ID AS companyId,
bc.`NAME` AS companyName,
wla.`CODE` AS agreementCode,
SUM( wir.NUM ) AS leaseNum,
"0" AS backNum,
wla.ID AS agreementId,
min( wir.time ) AS firstTime,
max( wir.time ) AS lastTime,
wir.time AS backTime,
real_sub.subName
FROM
wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
LEFT JOIN (
SELECT
wla.PROJECT proId,
GROUP_CONCAT( DISTINCT bu.`NAME` ) subName
FROM
wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
LEFT JOIN bm_unit bu ON bu.id = wla.LEASE_COMPANY
WHERE
bu.`NAME` IS NOT NULL
AND wtr.IS_ACTIVE = 1
GROUP BY
wla.PROJECT
) real_sub ON real_sub.proId = wla.PROJECT
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
LEFT JOIN bm_company bc ON bp.COMPANY_ID = bc.ID
LEFT JOIN wf_task_record wte ON wtr.ID = wte.SUP_ID
LEFT JOIN wf_info_record wir ON wte.ID = wir.SUP_ID
WHERE
wir.TYPE = 2
AND wtr.IS_ACTIVE = 1
GROUP BY
wla.ID UNION
SELECT
wla.PROJECT AS id,
bp.`NAME` AS projectName,
bc.ID AS companyId,
bc.`NAME` AS companyName,
wla.`CODE` AS agreementCode,
"0" AS leaseNum,
SUM( wir.NUM ) AS backNum,
wla.ID AS agreementId,
"" AS firstTime,
"" AS lastTime,
max( wir.time ) AS backTime,
real_sub.subName
FROM
wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
LEFT JOIN (
SELECT
wla.PROJECT proId,
GROUP_CONCAT( DISTINCT bu.`NAME` ) subName
FROM
wf_task_record wtr
LEFT JOIN wf_agreement_task wat ON wtr.ID = wat.TASK_ID
LEFT JOIN wf_lease_agreement wla ON wat.AGREEMENT_ID = wla.ID
LEFT JOIN bm_unit bu ON bu.id = wla.LEASE_COMPANY
WHERE
bu.`NAME` IS NOT NULL
AND wtr.IS_ACTIVE = 1
GROUP BY
wla.PROJECT
) real_sub ON real_sub.proId = wla.PROJECT
LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
LEFT JOIN bm_company bc ON bp.COMPANY_ID = bc.ID
LEFT JOIN wf_return_material_details wrd ON wtr.ID = wrd.TASK_ID
LEFT JOIN wf_info_record wir ON wrd.ID = wir.SUP_ID
WHERE
wtr.IS_ACTIVE = 1
AND wir.TYPE = 4
GROUP BY
wla.ID
) a
)
) a
<where>
<if test="subName != null and subName != ''">
AND FIND_IN_SET(subName, #{subName}) > 0
AND FIND_IN_SET(subName, #{subName}) > 0
</if>
<if test="projectName != null and projectName != ''">
and projectName like concat('%',#{projectName},'%')
</if>
</where>
GROUP BY
a.projectName
order by diffCount desc
a.projectName
order by diffCount,subName desc
</select>
<select id="getProjectMaDiff" parameterType="com.bonus.index.beans.IndexProjectBean" resultType="com.bonus.index.beans.IndexProjectBean">
@ -1460,7 +1575,7 @@
and tpd.`NAME` like concat('%', #{maName}, '%')
</if>
</select>
<select id="getNewlyStored" resultType="com.bonus.index.beans.IndexStorageWarnBean">
<select id="getNewlyStored">
select mt2.NAME as maType,
mt.NAME as maName,
wir.CODE as maCode,
@ -1471,7 +1586,7 @@
left join mm_type mt2 on mt.PARENT_ID = mt2.ID
where wir.TYPE = #{type}
</select>
<select id="getInventoryStored" resultType="com.bonus.index.beans.IndexStorageWarnBean">
<select id="getInventoryStored">
select mt2.NAME as maType,
mt.NAME as maName,
mt.UNIT as maUnit,

View File

@ -324,351 +324,307 @@
<select id="getOverview" parameterType="com.bonus.index.beans.IndexHomeBean" resultType="com.bonus.index.beans.PartOneBean">
SELECT
SUM(projectCount) projectCount,
SUM(equipmentTypes) equipmentTypes,
SUM(totalCount) totalCount,
SUM(stockCount) stockCount,
SUM(inUseCount) inUseCount,
SUM(repairCount) repairCount,
SUM(scrappedCount) scrappedCount
FROM
(
SELECT
COUNT( DISTINCT bp.ID ) AS projectCount,
0 AS equipmentTypes,
0 AS totalCount,
0 AS stockCount,
0 AS inUseCount,
0 AS repairCount,
0 AS scrappedCount
FROM
bm_project bp
WHERE
bp.IS_ACTIVE = 1 UNION
SELECT
0 AS projectCount,
COUNT( DISTINCT mt.ID ) AS equipmentTypes,
0 AS totalCount,
0 AS stockCount,
0 AS inUseCount,
0 AS repairCount,
0 AS scrappedCount
FROM
mm_type mt
WHERE
mt.`LEVEL` = 4
AND mt.IS_ACTIVE = 1 UNION
SELECT
0 AS projectCount,
0 AS equipmentTypes,
ROUND(
IF
(
SUM( storageNum ) IS NULL,
0,
SUM( storageNum )))+ ROUND(
sum( leaseNum ))+ ROUND(
SUM( repairNum )) + ROUND(
SUM( checkNum )) + ROUND( SUM( waitInputNum ) ) AS totalCount,
0 AS stockCount,
0 AS inUseCount,
0 AS repairCount,
0 AS scrappedCount
FROM
(
SELECT
mat1.ID AS typeId,
mat1.NUM storageNum,
0 leaseNum,
0 repairNum,
0 checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
1 AS isCount
FROM
mm_type mat1
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
mat1.`LEVEL` = 4
AND mat1.IS_ACTIVE = '1'
GROUP BY
mat1.ID UNION
SELECT
typeId,
0 storageNum,
sum( leaseNum ) - SUM( backNum ) leaseNum,
0 repairNum,
0 checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
1 AS isCount
FROM
(
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
SUM( wir.NUM ) AS leaseNum,
0 AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_task_record wtr ON wir.SUP_ID = wtr.ID
LEFT JOIN wf_task_record wtr2 ON wtr.SUP_ID = wtr2.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
LEFT JOIN wf_collar_details wcd ON wcd.TASK_ID = wtr.SUP_ID
AND wcd.MODEL_ID = wir.MODEL_ID
WHERE
wir.TYPE = 2
AND wtr2.IS_ACTIVE = 1
AND wcd.IS_APPROVAL = 1
GROUP BY
mt.ID UNION
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
0 AS leaseNum,
SUM( wir.NUM ) AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_return_material_details wrd ON wir.SUP_ID = wrd.ID
LEFT JOIN wf_task_record wtr ON wrd.TASK_ID = wtr.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
WHERE
wir.TYPE = 4
AND wtr.IS_ACTIVE = 1
GROUP BY
mt.ID
) a
GROUP BY
typeId UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
SUM( wrd.REPAIR_NUM ) - SUM( wrd.ALREPAIR_NUM ) - SUM( SCRAP_NUM ) AS repairNum,
0 checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
1 AS isCount
FROM
wf_repair_details wrd
LEFT JOIN mm_type mat1 ON wrd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrd.MODEL_ID UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
SUM( wrc.CHECK_NUM ) - SUM( wrc.ALCHECK_NUM ) AS checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
1 AS isCount
FROM
wf_repair_check wrc
LEFT JOIN mm_type mat1 ON wrc.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrc.MODEL_ID UNION
SELECT DISTINCT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
0 checkNum,
0 AS scrapNum,
0 loseNum,
SUM(
IFNULL( PRE_PUT_NUM, 0 )) - sum(
IFNULL( AL_PUT_NUM, 0 )) AS waitInputNum,
1 AS isCount
FROM
wf_put_storage_details wpd
LEFT JOIN mm_type mat1 ON wpd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wpd.IS_SURE = 0
GROUP BY
wpd.MODEL_ID
) res UNION
SELECT
0 AS projectCount,
0 AS equipmentTypes,
0 AS totalCount,
SUM( mat1.NUM ) AS stockCount,
0 AS inUseCount,
0 AS repairCount,
0 AS scrappedCount
FROM
mm_type mat1
WHERE
mat1.`LEVEL` = 4
AND mat1.IS_ACTIVE = '1' UNION
SELECT
0 AS projectCount,
0 AS equipmentTypes,
0 AS totalCount,
0 AS stockCount,
sum( leaseNum ) - SUM( backNum ) inUseCount,
0 AS repairCount,
0 AS scrappedCount
FROM
(
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
SUM( wir.NUM ) AS leaseNum,
0 AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_task_record wtr ON wir.SUP_ID = wtr.ID
LEFT JOIN wf_task_record wtr2 ON wtr.SUP_ID = wtr2.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
LEFT JOIN wf_collar_details wcd ON wcd.TASK_ID = wtr.SUP_ID
AND wcd.MODEL_ID = wir.MODEL_ID
WHERE
wir.TYPE = 2
AND wtr2.IS_ACTIVE = 1
AND wcd.IS_APPROVAL = 1
GROUP BY
mt.ID UNION
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
0 AS leaseNum,
SUM( wir.NUM ) AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_return_material_details wrd ON wir.SUP_ID = wrd.ID
LEFT JOIN wf_task_record wtr ON wrd.TASK_ID = wtr.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
WHERE
wir.TYPE = 4
AND wtr.IS_ACTIVE = 1
GROUP BY
mt.ID
) a UNION
SELECT
0 AS projectCount,
0 AS equipmentTypes,
0 AS totalCount,
0 AS stockCount,
0 inUseCount,
SUM( repairNum )+ SUM( checkNum )+ SUM( waitInputNum ) AS repairCount,
0 AS scrappedCount
FROM
(
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
SUM( wrd.REPAIR_NUM ) - SUM( wrd.ALREPAIR_NUM ) - SUM( SCRAP_NUM ) AS repairNum,
0 checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
1 AS isCount
FROM
wf_repair_details wrd
LEFT JOIN mm_type mat1 ON wrd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrd.MODEL_ID UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
SUM( wrc.CHECK_NUM ) - SUM( wrc.ALCHECK_NUM ) AS checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
1 AS isCount
FROM
wf_repair_check wrc
LEFT JOIN mm_type mat1 ON wrc.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrc.MODEL_ID UNION
SELECT DISTINCT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
0 checkNum,
0 AS scrapNum,
0 loseNum,
SUM(
IFNULL( PRE_PUT_NUM, 0 )) - sum(
IFNULL( AL_PUT_NUM, 0 )) AS waitInputNum,
1 AS isCount
FROM
wf_put_storage_details wpd
LEFT JOIN mm_type mat1 ON wpd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wpd.IS_SURE = 0
GROUP BY
wpd.MODEL_ID
) res UNION
SELECT
0 AS projectCount,
0 AS equipmentTypes,
0 AS totalCount,
0 AS stockCount,
0 inUseCount,
0 AS repairCount,
SUM( wsd.ALSCRAP_NUM ) AS scrappedCount
FROM
wf_scrap_details wsd
LEFT JOIN mm_type mat1 ON wsd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wsd.IS_SURE = 1
) rs
SELECT
SUM( projectCount ) projectCount,
SUM( equipmentTypes ) equipmentTypes,
SUM( totalCount ) totalCount,
SUM( stockCount ) stockCount,
SUM( inUseCount ) inUseCount,
SUM( repairCount ) repairCount,
SUM( scrappedCount ) scrappedCount
FROM
(
SELECT
COUNT( DISTINCT bp.ID ) AS projectCount,
0 AS equipmentTypes,
0 AS totalCount,
0 AS stockCount,
0 AS inUseCount,
0 AS repairCount,
0 AS scrappedCount
FROM
bm_project bp
WHERE
bp.IS_ACTIVE = 1 UNION
SELECT
0 AS projectCount,
COUNT( DISTINCT mt.ID ) AS equipmentTypes,
0 AS totalCount,
0 AS stockCount,
0 AS inUseCount,
0 AS repairCount,
0 AS scrappedCount
FROM
mm_type mt
WHERE
mt.`LEVEL` = 4
AND mt.IS_ACTIVE = 1 UNION
SELECT
0 AS projectCount,
0 AS equipmentTypes,
sum( maTotal ) AS totalCount,
sum( storageNum ) AS stockCount,
SUM( inuseNum ) AS inUseCount,
SUM( repairNum ) AS repairCount,
SUM( scrapNum ) AS scrappedCount
FROM
(
SELECT
rs.typeId,
mat2.`NAME` maType,
mat1.`NAME` maName,
mat1.UNIT AS maUnit,
SUM( rs.storageNum )+ SUM( rs.inuseNum ) + SUM( rs.repairNum ) AS maTotal,
SUM( rs.storageNum ) storageNum,
SUM( rs.inuseNum ) inuseNum,
SUM( rs.repairNum ) repairNum,
SUM( rs.scrapNum ) scrapNum,
SUM( rs.projectNum ) projectNum,
SUM( rs.inuseCount ) inuseCount,
SUM( rs.backCount ) backCount,
SUM( rs.pyNum ) AS pyNum,
SUM( rs.pkNum ) AS pkNum,
rs.isCount
FROM
(
SELECT
mat1.ID AS typeId,
mat1.NUM storageNum,
0 inuseNum,
0 repairNum,
0 scrapNum,
0 projectNum,
0 inuseCount,
0 backCount,
0 AS pyNum,
0 AS pkNum,
mat1.IS_COUNT AS isCount
FROM
mm_type mat1
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
mat1.`LEVEL` = 4
AND mat1.IS_ACTIVE = '1'
GROUP BY
mat1.ID UNION
SELECT
typeId,
0 storageNum,
sum( leaseNum ) - SUM( backNum ) inuseNum,
0 repairNum,
0 scrapNum,
0 projectNum,
sum( leaseNum ) inuseCount,
SUM( backNum ) backCount,
0 AS pyNum,
0 AS pkNum,
isCount AS isCount
FROM
(
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
SUM( wir.NUM ) AS leaseNum,
0 AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_task_record wtr ON wir.SUP_ID = wtr.ID
LEFT JOIN wf_task_record wtr2 ON wtr.SUP_ID = wtr2.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
LEFT JOIN wf_collar_details wcd ON wcd.TASK_ID = wtr.SUP_ID
AND wcd.MODEL_ID = wir.MODEL_ID
WHERE
wir.TYPE = 2
AND wtr2.IS_ACTIVE = 1
AND wcd.IS_APPROVAL = 1
GROUP BY
mt.ID UNION
SELECT
mmt1.`NAME` AS pMachineName,
mmt.`NAME` AS machineName,
mt.`NAME` AS machineModel,
mt.ID AS typeId,
mt.BUY_PRICE AS buyPrice,
mt.UNIT,
0 AS leaseNum,
SUM( wir.NUM ) AS backNum,
mt.IS_COUNT AS isCount
FROM
wf_info_record wir
LEFT JOIN wf_return_material_details wrd ON wir.SUP_ID = wrd.ID
LEFT JOIN wf_task_record wtr ON wrd.TASK_ID = wtr.ID
LEFT JOIN mm_type mt ON wir.MODEL_ID = mt.ID
LEFT JOIN mm_type mmt ON mt.PARENT_ID = mmt.ID
LEFT JOIN mm_type mmt1 ON mmt.PARENT_ID = mmt1.ID
WHERE
wir.TYPE = 4
AND wtr.IS_ACTIVE = 1
GROUP BY
mt.ID
) a
GROUP BY
typeId UNION
SELECT
typeId,
0 storageNum,
0 inuseNum,
SUM( repairNum ) + SUM( checkNum ) + SUM( waitInputNum ) AS repairNum,
0 scrapNum,
0 projectNum,
0 inuseCount,
0 backCount,
0 AS pyNum,
0 AS pkNum,
isCount
FROM
(
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
SUM( wrd.REPAIR_NUM ) - SUM( wrd.ALREPAIR_NUM ) - SUM( SCRAP_NUM ) AS repairNum,
0 checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_repair_details wrd
LEFT JOIN mm_type mat1 ON wrd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrd.MODEL_ID UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
SUM( wrc.CHECK_NUM ) - SUM( wrc.ALCHECK_NUM ) AS checkNum,
0 scrapNum,
0 loseNum,
0 waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_repair_check wrc
LEFT JOIN mm_type mat1 ON wrc.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
GROUP BY
wrc.MODEL_ID UNION
SELECT DISTINCT
mat1.ID AS typeId,
0 storageNum,
0 leaseNum,
0 repairNum,
0 checkNum,
0 AS scrapNum,
0 loseNum,
SUM(
IFNULL( PRE_PUT_NUM, 0 )) - sum(
IFNULL( AL_PUT_NUM, 0 )) AS waitInputNum,
mat1.IS_COUNT AS isCount
FROM
wf_put_storage_details wpd
LEFT JOIN mm_type mat1 ON wpd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wpd.IS_SURE = 0
GROUP BY
wpd.MODEL_ID
) res
GROUP BY
typeId UNION
SELECT
mat1.ID AS typeId,
0 storageNum,
0 inuseNum,
0 AS repairNum,
SUM( wsd.ALSCRAP_NUM ) AS scrapNum,
0 projectNum,
0 inuseCount,
0 backCount,
0 AS pyNum,
0 AS pkNum,
mat1.IS_COUNT AS isCount
FROM
wf_scrap_details wsd
LEFT JOIN mm_type mat1 ON wsd.MODEL_ID = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
WHERE
wsd.IS_SURE = 1
GROUP BY
wsd.MODEL_ID UNION
SELECT
mps.type AS typeId,
0 storageNum,
0 inuseNum,
0 AS repairNum,
0 AS scrapNum,
COUNT( DISTINCT wla.PROJECT ) AS projectNum,
0 inuseCount,
0 backCount,
0 AS pyNum,
0 AS pkNum,
mat1.IS_COUNT AS isCount
FROM
ma_type_project_storage mps
LEFT JOIN wf_lease_agreement wla ON mps.agreement_id = wla.ID
LEFT JOIN mm_type mat1 ON mps.type = mat1.ID
WHERE
mps.`status` = 1
GROUP BY
mps.type UNION
SELECT
typeId,
0 storageNum,
0 inuseNum,
0 AS repairNum,
0 AS scrapNum,
0 AS projectNum,
0 inuseCount,
0 backCount,
SUM( pyNum ) AS pyNum,
SUM( pkNum ) AS pkNum,
isCount
FROM
(
SELECT
mli.TYPE_ID AS typeId,
mli.IS_PROFIT AS type,
IF
( mli.IS_PROFIT = 1, SUM( mli.IN_NUMS ), 0 ) AS pyNum,
IF
( mli.IS_PROFIT = 0, SUM( mli.IN_NUMS ), 0 ) AS pkNum,
mat1.IS_COUNT AS isCount
FROM
ma_lib_inventroy mli
LEFT JOIN mm_type mat1 ON mli.TYPE_ID = mat1.ID
GROUP BY
mli.TYPE_ID,
mli.IS_PROFIT
) res
GROUP BY
typeId
) rs
LEFT JOIN mm_type mat1 ON rs.typeId = mat1.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat1.PARENT_ID
GROUP BY
rs.typeId
) a
WHERE
typeId IN ( SELECT DISTINCT mt.ID FROM mm_type mt WHERE mt.`LEVEL` = 4 AND mt.IS_ACTIVE = 1 )
) rs
</select>

View File

@ -9,10 +9,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.bonus.core.DateTimeHelper;
import com.bonus.index.service.IndexHomeService;
@ -42,6 +39,18 @@ public class IndexHomeController extends BaseController<IndexHomeBean> {
return "/equipment/equipmentTypesDetail";
}
@RequestMapping("dataOverview/equipmentProportion/index")
public String dataOverviewProportionDetails(@RequestParam("type") String type, Model model) {
model.addAttribute("type",type);
return "/equipment/equipmentProportionDetail";
}
@RequestMapping("dataOverview/equipmentType/index")
public String dataOverviewTypeDetails(@RequestParam("type") String type, Model model) {
model.addAttribute("type",type);
return "/equipment/equipmentTypeDetail";
}
@RequestMapping("dataOverview/equipment/detail")
public String showEquipmentTypeInfo(Model model) {
return "/equipment/equipmentTypesInfo";