This commit is contained in:
hayu 2025-09-01 13:22:58 +08:00
parent 40c7c19aa8
commit 4598a2d5ea
3 changed files with 63 additions and 31 deletions

View File

@ -249,4 +249,6 @@ public class Type extends BaseEntity {
@ApiModelProperty("机具类型1机具2安全工器具") @ApiModelProperty("机具类型1机具2安全工器具")
private int jiJuType; 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.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils; 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.MaTypeHistory;
import com.bonus.material.ma.domain.TypeKeeper; import com.bonus.material.ma.domain.TypeKeeper;
import com.bonus.material.ma.domain.TypeRepair; import com.bonus.material.ma.domain.TypeRepair;
@ -49,6 +51,9 @@ public class TypeServiceImpl implements ITypeService {
@Resource @Resource
private TypeMapper typeMapper; private TypeMapper typeMapper;
@Resource
private LeaseTaskMapper leaseTaskMapper;
@Resource @Resource
private ITypeKeeperService typeKeeperService; private ITypeKeeperService typeKeeperService;

View File

@ -1164,39 +1164,64 @@
</select> </select>
<select id="selectPendingOutNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails"> <select id="selectPendingOutNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT SELECT
a.typeId, #{typeId} as typeId,
SUM(a.preNum) as preNum, COALESCE(SUM(combined.pendingOutNum), 0) as pendingOutNum,
SUM(a.alNum) as alNum, COALESCE(mt.storage_num, 0) as storageNum,
SUM(a.preNum)-SUM(a.alNum) as pendingOutNum, CASE mt.manage_type
ifnull(mt.storage_num,0) as storageNum WHEN 0 THEN
FROM IFNULL(subquery0.num, 0)
( ELSE
IFNULL(mt.storage_num, 0)
END as storage_num
FROM (
SELECT SELECT
type_id as typeId, lad.type_id as typeId,
SUM(pre_num) as preNum, SUM(pre_num) - SUM(al_num) as pendingOutNum
SUM(al_num) as alNum
FROM 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 WHERE
type_id =#{typeId} tt.task_status = '3'
and new_type is null AND tt.task_type = '2'
GROUP BY type_id AND lad.type_id = #{typeId}
GROUP BY lad.type_id
UNION UNION ALL
SELECT SELECT
new_type as typeId, lpd.new_type as typeId,
SUM(pre_num) as preNum, SUM(lpd.num) - IFNULL(lod.alNum, 0) as pendingOutNum
SUM(al_num) as alNum
FROM 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 WHERE
new_type = #{typeId} publish_task is not null
and new_type is not null AND lod.type_id = #{typeId}
GROUP BY new_type GROUP BY lod.type_id
) a ) lod ON lpd.new_type = lod.typeId
LEFT JOIN ma_type mt on mt.type_id=a.typeId WHERE
GROUP BY typeId 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>
<select id="selectLeaseApplyDetailsCountByParentId" resultType="java.lang.Integer"> <select id="selectLeaseApplyDetailsCountByParentId" resultType="java.lang.Integer">
SELECT SELECT