<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.ruoyi.system.mapper.AssetInventoryTaskMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.system.model.AssetInventoryTask">
|
<id column="id" property="id" />
|
<result column="user_id" property="userId" />
|
<result column="dept_id" property="deptId" />
|
<result column="task_name" property="taskName" />
|
<result column="execute_date" property="executeDate" />
|
<result column="status" property="status" />
|
<result column="remarks" property="remarks" />
|
<result column="create_time" property="createTime" />
|
<result column="create_by" property="createBy" />
|
<result column="update_time" property="updateTime" />
|
<result column="update_by" property="updateBy" />
|
<result column="disabled" property="disabled" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, user_id, dept_id, task_name, execute_date, status, remarks, create_time, create_by, update_time, update_by, disabled
|
</sql>
|
|
<!-- 获取盘点任务详情中的资产列表 -->
|
<select id="getAssetMainInventoryList" resultType="com.ruoyi.system.vo.asset.AssetMainInventoryVO">
|
SELECT
|
am.id,
|
am.asset_code,
|
am.asset_name,
|
at2.type_name AS asset_type_name,
|
at1.type_name AS parent_asset_type,
|
am.specification_model,
|
am.category,
|
am.measurement_unit,
|
am.quantity,
|
am.unit_price,
|
am.total_value,
|
am.accounting_voucher_no,
|
am.accounting_subject,
|
am.accounting_status,
|
am.accounting_amount,
|
am.accounting_date,
|
am.asset_status,
|
td.dept_name AS ownership_dept_name,
|
am.ownership_dept_id,
|
am.asset_type_id,
|
am.address_type,
|
am.address,
|
am.use_dept_id,
|
am.warehouse_id,
|
am.user_name,
|
aw.warehouse_name,
|
td2.dept_name AS use_dept_name,
|
su.nick_name AS check_user_name,
|
aiti.result_status AS inventory_status,
|
aiti.real_dept_name,
|
aiti.real_user_name,
|
aiti.id AS asset_inventory_task_item_id,
|
aiti.exception_explain
|
FROM
|
asset_inventory_task_item aiti
|
INNER JOIN
|
asset_main am ON aiti.asset_main_id = am.id
|
LEFT JOIN
|
asset_type at2 ON am.asset_type_id = at2.id
|
LEFT JOIN
|
asset_type at1 ON at1.id = (CASE WHEN at2.level = 2 THEN at2.parent_id ELSE at2.id END)
|
LEFT JOIN
|
t_dept td ON am.ownership_dept_id = td.id
|
LEFT JOIN
|
sys_user su ON aiti.user_id = su.user_id
|
LEFT JOIN
|
t_dept td2 ON am.address_type = 0 AND am.use_dept_id = td2.id
|
LEFT JOIN
|
asset_warehouse aw ON am.address_type = 1 AND am.warehouse_id = aw.id
|
WHERE
|
aiti.inventory_task_id = #{taskId}
|
ORDER BY
|
am.asset_code
|
</select>
|
|
<!-- 获取盘点任务中的所有盘点人姓名(去重) -->
|
<select id="getInventoryUserNames" resultType="java.lang.String">
|
SELECT DISTINCT su.nick_name
|
FROM
|
asset_inventory_task_item aiti
|
INNER JOIN
|
sys_user su ON aiti.user_id = su.user_id
|
WHERE
|
aiti.inventory_task_id = #{taskId}
|
AND su.nick_name IS NOT NULL
|
AND su.nick_name != ''
|
ORDER BY
|
su.nick_name
|
</select>
|
<select id="getAssetMainInventoryPageList" resultType="com.ruoyi.system.vo.asset.AssetMainInventoryVO">
|
|
SELECT
|
am.id,
|
am.asset_code,
|
am.asset_name,
|
at.type_name AS asset_type_name,
|
am.specification_model,
|
am.category,
|
am.measurement_unit,
|
am.quantity,
|
am.unit_price,
|
am.total_value,
|
am.accounting_voucher_no,
|
am.accounting_subject,
|
am.accounting_status,
|
am.accounting_amount,
|
am.accounting_date,
|
am.asset_status,
|
td.dept_name AS ownership_dept_name,
|
am.ownership_dept_id,
|
am.asset_type_id,
|
am.address_type,
|
am.address,
|
am.use_dept_id,
|
am.warehouse_id,
|
am.user_name,
|
aw.warehouse_name,
|
td2.dept_name AS use_dept_name,
|
su.nick_name AS check_user_name,
|
aiti.result_status AS inventory_status,
|
aiti.real_dept_name,
|
aiti.real_user_name,
|
aiti.id AS asset_inventory_task_item_id,
|
aiti.exception_explain
|
FROM
|
asset_inventory_task_item aiti
|
INNER JOIN
|
asset_main am ON aiti.asset_main_id = am.id
|
LEFT JOIN
|
asset_type at ON am.asset_type_id = at.id
|
LEFT JOIN
|
t_dept td ON am.ownership_dept_id = td.id
|
LEFT JOIN
|
sys_user su ON aiti.user_id = su.user_id
|
LEFT JOIN
|
t_dept td2 ON am.address_type = 0 AND am.use_dept_id = td2.id
|
LEFT JOIN
|
asset_warehouse aw ON am.address_type = 1 AND am.warehouse_id = aw.id
|
<where>
|
aiti.inventory_task_id = #{query.id}
|
<if test="query.keyword != null and query.keyword != ''">
|
AND (am.asset_name LIKE CONCAT('%',#{query.keyword},'%') OR
|
am.asset_code LIKE CONCAT('%',#{query.keyword},'%'))
|
</if>
|
<if test="query.resultStatus != null">
|
AND aiti.result_status = #{query.reslutStatus}
|
</if>
|
</where>
|
ORDER BY
|
am.asset_code
|
</select>
|
|
<!-- 获取盘点任务统计数据 -->
|
<select id="getInventoryTaskStatistics" resultType="com.ruoyi.system.vo.asset.InventoryTaskStatisticsVO">
|
SELECT
|
COALESCE(SUM(CASE WHEN result_status = 0 THEN 1 ELSE 0 END), 0) as pendingCount,
|
COALESCE(SUM(CASE WHEN result_status = 1 THEN 1 ELSE 0 END), 0) as normalCount,
|
COALESCE(SUM(CASE WHEN result_status = 2 THEN 1 ELSE 0 END), 0) as abnormalCount,
|
COALESCE(COUNT(*), 0) as totalCount
|
FROM
|
asset_inventory_task_item
|
WHERE
|
inventory_task_id = #{taskId}
|
</select>
|
|
</mapper>
|