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

View File

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