jsk 数据概览 修改

This commit is contained in:
jiask 2026-02-05 17:01:09 +08:00
parent 3f42f95b41
commit 3c046f5ee6
2 changed files with 1203 additions and 1068 deletions

File diff suppressed because it is too large Load Diff

View File

@ -196,23 +196,32 @@
UNION UNION
SELECT SELECT
0 AS storageNum, 0 AS storageNum,
0 AS checkNum, 0 AS checkNum,
COUNT(DISTINCT maId) as useNum, COUNT(*) AS useNum,
0 as changeNum 0 AS changeNum
FROM FROM (
( SELECT 1
SELECT FROM
DISTINCT ps.machine as maId, ma_type_project_storage ps
to_days(now()) -to_days(ps.start_date) as days INNER JOIN mm_machines mm ON ps.machine = mm.ID
FROM INNER JOIN mm_type mt ON mm.TYPE = mt.ID
ma_type_project_storage ps LEFT JOIN mm_type mt2 ON mt.PARENT_ID = mt2.ID
LEFT JOIN mm_machines mm on ps.machine = mm.ID LEFT JOIN wf_lease_agreement wla ON ps.agreement_id = wla.ID
WHERE ps.`status` =1 and ps.is_count = 0 LEFT JOIN bm_project bp ON wla.PROJECT = bp.ID
and mm.BATCH_STATUS = 6 LEFT JOIN bm_company bc ON bp.COMPANY_ID = bc.ID
GROUP BY ps.machine WHERE
) rs ps.status = 1
WHERE rs.days> 180 AND ps.end_date IS NULL
AND mm.BATCH_STATUS = 6
AND DATEDIFF(NOW(), ps.start_date) > 180
GROUP BY
mt.ID,
mt2.ID,
wla.ID,
bp.ID,
bc.ID
) AS t
UNION UNION
SELECT SELECT
@ -315,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>