machine库存查询修改

This commit is contained in:
liang.chao 2024-08-20 14:09:48 +08:00
parent a0affba5ae
commit 2edf5af00b
4 changed files with 48 additions and 5 deletions

View File

@ -109,4 +109,6 @@ public interface LeaseOutDetailsMapper {
int updateLeaseApplyDetails(@Param("record") LeaseOutDetails record);
List<LeaseOutDetails> getOutboundOrder(String parentId);
int getCountOfCodeMachine(@Param("record") LeaseOutDetails record);
}

View File

@ -258,10 +258,17 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
//判断(ma_type 设备规格表)中的库存够不够出库的
MaType maType = leaseOutDetailsMapper.selectByTypeId(record);
if (maType != null) {
if ("0".equals(maType.getManageType())) {
int count = leaseOutDetailsMapper.getCountOfCodeMachine(record);
if (BigDecimal.valueOf(count).compareTo(BigDecimal.valueOf(record.getOutNum())) < 0) {
return 0;
}
} else if ("1".equals(maType.getManageType())) {
if (maType.getNum() == null || maType.getNum().compareTo(BigDecimal.valueOf(record.getOutNum())) < 0) {
return 0;
}
}
}
return 1;
}
@ -272,7 +279,11 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
//判断(ma_type 设备规格表)中的库存够不够出库的
MaType maType = leaseOutDetailsMapper.selectByTypeId(record);
if (maType != null) {
if ("1".equals(maType.getManageType())) {
return maType.getNum().intValue();
} else {
return leaseOutDetailsMapper.getCountOfCodeMachine(record);
}
}
return 0;
}

View File

@ -476,5 +476,16 @@
WHERE
lod.parent_id = #{parentId}
</select>
<select id="getCountOfCodeMachine" resultType="java.lang.Integer">
select count(mm.ma_id)
FROM ma_type mt
left join ma_machine mm on mm.type_id=mt.type_id
WHERE
mm.type_id = #{record.typeId}
and mm.ma_code is not null
and mm.ma_status in (15)
and mt.`level` = 4
and mt.del_flag = '0'
</select>
</mapper>

View File

@ -8,12 +8,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT mt2.type_name as typeName,
mt.type_name as typeModelName,
mt.unit_name as unit,
IFNULL(mt.num, 0) as num,
CASE mt.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(mt.num, 0)
END as num,
IFNULL(subquery1.usNum, 0) as usNum,
IFNULL(subquery2.repairNum, 0) as repairNum,
IFNULL(subquery3.repairInputNum, 0) as repairInputNum,
IFNULL(subquery4.inputNum, 0) as inputNum,
IFNULL(mt.num, 0) + IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0) as allNum,
CASE mt.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0)
ELSE
IFNULL(mt.num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0)
END as allNum,
CASE mt.manage_type
WHEN 0 THEN
'否'
@ -22,6 +32,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
END manageType
FROM ma_type mt
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 (15)
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
LEFT JOIN (SELECT subquery1.type_id,
subquery1.typeName,
subquery1.typeModelName,