Merge remote-tracking branch 'origin/master'

This commit is contained in:
mashuai 2025-09-01 13:32:04 +08:00
commit 7a2a10372f
3 changed files with 63 additions and 31 deletions

View File

@ -249,4 +249,6 @@ public class Type extends BaseEntity {
@ApiModelProperty("机具类型1机具2安全工器具")
private int jiJuType;
@ApiModelProperty(value = "待出库数量")
private BigDecimal pendingOutNum;
}

View File

@ -13,6 +13,8 @@ import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.mapper.LeaseTaskMapper;
import com.bonus.material.ma.domain.MaTypeHistory;
import com.bonus.material.ma.domain.TypeKeeper;
import com.bonus.material.ma.domain.TypeRepair;
@ -49,6 +51,9 @@ public class TypeServiceImpl implements ITypeService {
@Resource
private TypeMapper typeMapper;
@Resource
private LeaseTaskMapper leaseTaskMapper;
@Resource
private ITypeKeeperService typeKeeperService;

View File

@ -1165,39 +1165,64 @@
</select>
<select id="selectPendingOutNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
a.typeId,
SUM(a.preNum) as preNum,
SUM(a.alNum) as alNum,
SUM(a.preNum)-SUM(a.alNum) as pendingOutNum,
ifnull(mt.storage_num,0) as storageNum
FROM
(
#{typeId} as typeId,
COALESCE(SUM(combined.pendingOutNum), 0) as pendingOutNum,
COALESCE(mt.storage_num, 0) as storageNum,
CASE mt.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(mt.storage_num, 0)
END as storage_num
FROM (
SELECT
type_id as typeId,
SUM(pre_num) as preNum,
SUM(al_num) as alNum
lad.type_id as typeId,
SUM(pre_num) - SUM(al_num) as pendingOutNum
FROM
lease_apply_details
lease_apply_info lai
LEFT JOIN lease_apply_details lad ON lad.parent_id = lai.id
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
WHERE
type_id =#{typeId}
and new_type is null
GROUP BY type_id
tt.task_status = '3'
AND tt.task_type = '2'
AND lad.type_id = #{typeId}
GROUP BY lad.type_id
UNION
UNION ALL
SELECT
new_type as typeId,
SUM(pre_num) as preNum,
SUM(al_num) as alNum
lpd.new_type as typeId,
SUM(lpd.num) - IFNULL(lod.alNum, 0) as pendingOutNum
FROM
lease_apply_details
lease_publish_details lpd
LEFT JOIN (
SELECT
lod.type_id as typeId,
SUM(lod.out_num) as alNum
FROM
lease_out_details lod
WHERE
new_type = #{typeId}
and new_type is not null
GROUP BY new_type
) a
LEFT JOIN ma_type mt on mt.type_id=a.typeId
GROUP BY typeId
publish_task is not null
AND lod.type_id = #{typeId}
GROUP BY lod.type_id
) lod ON lpd.new_type = lod.typeId
WHERE
lpd.new_type = #{typeId}
GROUP BY lpd.new_type
) combined
RIGHT JOIN (SELECT #{typeId} as type_id) param ON combined.typeId = param.type_id
LEFT JOIN ma_type mt ON mt.type_id = param.type_id
left join (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (1)
and mm.type_id=#{typeId}
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = param.type_id
GROUP BY param.type_id
</select>
<select id="selectLeaseApplyDetailsCountByParentId" resultType="java.lang.Integer">
SELECT