采购历史增强代码
This commit is contained in:
@@ -112,11 +112,10 @@
|
||||
COUNT(id) AS count,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN day_length > 0 THEN 1
|
||||
WHEN hour > 0 THEN 1
|
||||
WHEN day_length != 0 OR hour != 0 THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS work_times,
|
||||
) AS work_times,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN day_length > 0 THEN day_length * 8
|
||||
@@ -137,8 +136,8 @@
|
||||
|
||||
FROM sys_oa_attendance soa
|
||||
WHERE user_id = #{userId}
|
||||
AND #{lastDay} > create_time
|
||||
AND create_time > #{firstDay}
|
||||
AND #{lastDay} >= create_time
|
||||
AND create_time >= #{firstDay}
|
||||
AND del_flag = '0'
|
||||
GROUP BY soa.project_id;
|
||||
|
||||
|
||||
@@ -107,5 +107,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectRecentOutbound" resultType="com.ruoyi.oa.domain.vo.SysOaWarehouseVo">
|
||||
SELECT w.id AS id,
|
||||
w.name AS name,
|
||||
w.model AS model,
|
||||
w.price AS price,
|
||||
w.inventory AS inventory,
|
||||
w.unit AS unit,
|
||||
w.brand AS brand,
|
||||
w.specifications AS specifications,
|
||||
w.remark AS remark,
|
||||
w.threshold AS threshold,
|
||||
d.amount AS taskInventory,
|
||||
|
||||
-- 最近一次出库数量(type=0)
|
||||
(SELECT d2.amount
|
||||
FROM sys_oa_warehouse_detail d2
|
||||
INNER JOIN sys_oa_warehouse_master m2
|
||||
ON d2.master_id = m2.master_id
|
||||
WHERE m2.type = 0
|
||||
AND d2.warehouse_id = w.id
|
||||
ORDER BY d2.create_time DESC
|
||||
LIMIT 1) AS lastOutbound,
|
||||
|
||||
-- 最近一次入库数量(type=1)
|
||||
(SELECT d3.amount
|
||||
FROM sys_oa_warehouse_detail d3
|
||||
INNER JOIN sys_oa_warehouse_master m3
|
||||
ON d3.master_id = m3.master_id
|
||||
WHERE m3.type = 1
|
||||
AND d3.warehouse_id = w.id
|
||||
ORDER BY d3.create_time DESC
|
||||
LIMIT 1) AS lastInbound,
|
||||
|
||||
'' AS temp
|
||||
FROM sys_oa_warehouse_detail d
|
||||
INNER JOIN sys_oa_warehouse_master m
|
||||
ON d.master_id = m.master_id
|
||||
INNER JOIN sys_oa_warehouse w
|
||||
ON d.warehouse_id = w.id
|
||||
WHERE m.type = 0
|
||||
ORDER BY d.create_time DESC
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -69,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join sys_oa_warehouse_master sowm on sowm.master_id = sowt.master_id
|
||||
where sowt.warehouse_id = sow.id
|
||||
and sowm.type = 2
|
||||
and (sowt.task_status = 0 or sowt.task_status = 1)
|
||||
and sowt.del_flag = '0'
|
||||
and sowm.del_flag = '0'
|
||||
and sowm.status = 0
|
||||
@@ -79,4 +80,208 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 1. 快照时点的库存总量 -->
|
||||
<select id="selectInventoryAt" resultType="long">
|
||||
SELECT IFNULL(SUM(w.inventory),0)
|
||||
FROM sys_oa_warehouse w
|
||||
<where>
|
||||
w.del_flag = 0
|
||||
<!-- 快照时点 -->
|
||||
<if test="f.endTime != null">
|
||||
AND w.update_time <= #{f.endTime}
|
||||
</if>
|
||||
<!-- 可选物料名 -->
|
||||
<if test="f.name != null and f.name != ''">
|
||||
AND w.name LIKE CONCAT('%',#{f.name},'%')
|
||||
</if>
|
||||
<!-- 可选品牌 -->
|
||||
<if test="f.brand != null and f.brand != ''">
|
||||
AND w.brand LIKE CONCAT('%',#{f.brand},'%')
|
||||
</if>
|
||||
<!-- 可选供应商:假设用 master.sign_user 表示 -->
|
||||
<if test="f.supplier != null and f.supplier != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_oa_warehouse_task t
|
||||
JOIN sys_oa_warehouse_master m
|
||||
ON t.master_id = m.master_id
|
||||
WHERE t.warehouse_id = w.id
|
||||
AND m.sign_user = #{f.supplier}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 2. 区间内在途物料数量 -->
|
||||
<select id="selectInTransitBetween" resultType="long">
|
||||
SELECT IFNULL(SUM(t.task_inventory),0)
|
||||
FROM sys_oa_warehouse_task t
|
||||
JOIN sys_oa_warehouse_master m
|
||||
ON t.master_id = m.master_id
|
||||
<where>
|
||||
m.del_flag = 0
|
||||
and t.del_flag = 0
|
||||
and m.type = 2
|
||||
and m.status = 0
|
||||
<!-- 时间范围 -->
|
||||
<if test="f.beginTime != null">
|
||||
AND m.sign_time >= #{f.beginTime}
|
||||
</if>
|
||||
<if test="f.endTime != null">
|
||||
AND m.sign_time <= #{f.endTime}
|
||||
</if>
|
||||
<!-- 物料名/品牌/供应商 同理 -->
|
||||
<if test="f.name != null and f.name != ''">
|
||||
AND t.name LIKE CONCAT('%',#{f.name},'%')
|
||||
</if>
|
||||
<if test="f.brand != null and f.brand != ''">
|
||||
AND t.brand LIKE CONCAT('%',#{f.brand},'%')
|
||||
</if>
|
||||
<if test="f.supplier != null and f.supplier != ''">
|
||||
AND m.sign_user = #{f.supplier}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 3. 指定日期的入库量 -->
|
||||
<select id="selectInboundOn" resultType="long">
|
||||
SELECT IFNULL(SUM(d.amount),0)
|
||||
FROM sys_oa_warehouse_detail d
|
||||
JOIN sys_oa_warehouse_master m
|
||||
ON d.master_id = m.master_id
|
||||
JOIN sys_oa_warehouse w
|
||||
ON d.warehouse_id = w.id
|
||||
<where>
|
||||
m.del_flag = 0
|
||||
and d.del_flag = 0
|
||||
and m.type = 1
|
||||
<!-- 当日 -->
|
||||
<if test="f.endTime != null">
|
||||
AND DATE(m.sign_time) = DATE(#{f.endTime})
|
||||
</if>
|
||||
<!-- 物料名/品牌/供应商 -->
|
||||
<if test="f.name != null and f.name != ''">
|
||||
AND w.name LIKE CONCAT('%',#{f.name},'%')
|
||||
</if>
|
||||
<if test="f.brand != null and f.brand != ''">
|
||||
AND w.brand LIKE CONCAT('%',#{f.brand},'%')
|
||||
</if>
|
||||
<if test="f.supplier != null and f.supplier != ''">
|
||||
AND m.sign_user = #{f.supplier}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 4. 指定日期的出库量 -->
|
||||
<select id="selectOutboundOn"
|
||||
parameterType="com.ruoyi.oa.domain.dto.SummaryFilterDTO"
|
||||
resultType="long">
|
||||
SELECT IFNULL(SUM(d.amount),0)
|
||||
FROM sys_oa_warehouse_detail d
|
||||
JOIN sys_oa_warehouse_master m
|
||||
ON d.master_id = m.master_id
|
||||
JOIN sys_oa_warehouse w
|
||||
ON d.warehouse_id = w.id
|
||||
<where>
|
||||
m.del_flag = 0
|
||||
AND d.del_flag = 0
|
||||
AND m.type = 0
|
||||
<!-- “当日”条件,用 endTime 对比 -->
|
||||
<if test="f.endTime != null">
|
||||
AND DATE(m.sign_time) = DATE(#{f.endTime})
|
||||
</if>
|
||||
|
||||
<!-- 可选的物料名过滤 -->
|
||||
<if test="f.name != null and f.name != ''">
|
||||
AND w.name LIKE CONCAT('%',#{f.name},'%')
|
||||
</if>
|
||||
<!-- 可选品牌过滤 -->
|
||||
<if test="f.brand != null and f.brand != ''">
|
||||
AND w.brand LIKE CONCAT('%',#{f.brand},'%')
|
||||
</if>
|
||||
<!-- 可选供应商过滤 -->
|
||||
<if test="f.supplier != null and f.supplier != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_oa_warehouse_task t
|
||||
JOIN sys_oa_warehouse_master m2
|
||||
ON t.master_id = m2.master_id
|
||||
WHERE t.warehouse_id = w.id
|
||||
AND m2.sign_user = #{f.supplier}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 5. 指定日期的预警数 -->
|
||||
<select id="selectWarningOn" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM sys_oa_warehouse w
|
||||
<where>
|
||||
w.del_flag = 0
|
||||
AND w.threshold >= w.inventory
|
||||
<!-- 当日快照 -->
|
||||
<if test="f.endTime != null">
|
||||
AND DATE(w.update_time) = DATE(#{f.endTime})
|
||||
</if>
|
||||
<if test="f.name != null and f.name != ''">
|
||||
AND w.name LIKE CONCAT('%',#{f.name},'%')
|
||||
</if>
|
||||
<if test="f.brand != null and f.brand != ''">
|
||||
AND w.brand LIKE CONCAT('%',#{f.brand},'%')
|
||||
</if>
|
||||
<if test="f.supplier != null and f.supplier != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_oa_warehouse_task t
|
||||
JOIN sys_oa_warehouse_master m
|
||||
ON t.master_id = m.master_id
|
||||
WHERE t.warehouse_id = w.id
|
||||
AND m.sign_user = #{f.supplier}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 1. 年度入库量按月分组 -->
|
||||
<select id="selectInboundByMonth" parameterType="int" resultType="map">
|
||||
SELECT MONTH(m.sign_time) AS month,
|
||||
IFNULL(SUM(d.amount),0) AS total
|
||||
FROM sys_oa_warehouse_detail d
|
||||
JOIN sys_oa_warehouse_master m
|
||||
ON d.master_id = m.master_id
|
||||
WHERE m.del_flag = 0
|
||||
AND d.del_flag = 0
|
||||
AND m.type = 1
|
||||
AND YEAR(m.sign_time) = #{year}
|
||||
GROUP BY MONTH(m.sign_time)
|
||||
ORDER BY MONTH(m.sign_time)
|
||||
</select>
|
||||
|
||||
<!-- 2. 年度出库量按月分组 -->
|
||||
<select id="selectOutboundByMonth" parameterType="int" resultType="map">
|
||||
SELECT MONTH(m.sign_time) AS month,
|
||||
IFNULL(SUM(d.amount),0) AS total
|
||||
FROM sys_oa_warehouse_detail d
|
||||
JOIN sys_oa_warehouse_master m
|
||||
ON d.master_id = m.master_id
|
||||
WHERE m.del_flag = 0
|
||||
AND d.del_flag = 0
|
||||
AND m.type = 0
|
||||
AND YEAR(m.sign_time) = #{year}
|
||||
GROUP BY MONTH(m.sign_time)
|
||||
ORDER BY MONTH(m.sign_time)
|
||||
</select>
|
||||
|
||||
<!-- 任意日期的库存快照 -->
|
||||
<select id="selectInventorySnapshot"
|
||||
parameterType="java.time.LocalDate"
|
||||
resultType="long">
|
||||
SELECT IFNULL(SUM(inventory),0)
|
||||
FROM sys_oa_warehouse
|
||||
WHERE del_flag = 0
|
||||
AND #{date} >= DATE(update_time)
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="projectName" column="project_name"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="nearestEndTime" column="nearest_end_time"/>
|
||||
|
||||
<collection property="warehouseList"
|
||||
column="master_id"
|
||||
@@ -48,6 +49,7 @@
|
||||
sowm.sign_user,
|
||||
sowm.remark,
|
||||
sowm.status,
|
||||
${ew.sqlSelect},
|
||||
sop.project_name
|
||||
FROM sys_oa_warehouse_master sowm
|
||||
LEFT JOIN sys_oa_project sop
|
||||
|
||||
Reference in New Issue
Block a user