This commit is contained in:
parent
40c7c19aa8
commit
4598a2d5ea
|
|
@ -249,4 +249,6 @@ public class Type extends BaseEntity {
|
|||
@ApiModelProperty("机具类型(1机具,2安全工器具)")
|
||||
private int jiJuType;
|
||||
|
||||
@ApiModelProperty(value = "待出库数量")
|
||||
private BigDecimal pendingOutNum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1164,39 +1164,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
|
||||
(
|
||||
SELECT
|
||||
type_id as typeId,
|
||||
SUM(pre_num) as preNum,
|
||||
SUM(al_num) as alNum
|
||||
FROM
|
||||
lease_apply_details
|
||||
WHERE
|
||||
type_id =#{typeId}
|
||||
and new_type is null
|
||||
GROUP BY type_id
|
||||
#{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
|
||||
lad.type_id as typeId,
|
||||
SUM(pre_num) - SUM(al_num) as pendingOutNum
|
||||
FROM
|
||||
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
|
||||
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
|
||||
FROM
|
||||
lease_apply_details
|
||||
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
|
||||
SELECT
|
||||
lpd.new_type as typeId,
|
||||
SUM(lpd.num) - IFNULL(lod.alNum, 0) as pendingOutNum
|
||||
FROM
|
||||
lease_publish_details lpd
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
lod.type_id as typeId,
|
||||
SUM(lod.out_num) as alNum
|
||||
FROM
|
||||
lease_out_details lod
|
||||
WHERE
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue