Commit 3445cc84 by zhu.zewen

修复剩余药品数量/可销毁数量

parent 0a44c500
...@@ -20,6 +20,9 @@ public interface PhysicStorageAmpouleMapper extends BaseMapper<PhysicStorageAmpo ...@@ -20,6 +20,9 @@ public interface PhysicStorageAmpouleMapper extends BaseMapper<PhysicStorageAmpo
Integer selectCurrentSumByName(@Param("name") String name,@Param("spec") String spec,@Param("factoryName") String factoryName); Integer selectCurrentSumByName(@Param("name") String name,@Param("spec") String spec,@Param("factoryName") String factoryName);
/**
* 获取剩余药品数量(可销毁数量=库存数量 - 已销毁数量)
*/
List<PhysicDestroyNumVO> selectDestroy(@Param("deptId") Long deptId); List<PhysicDestroyNumVO> selectDestroy(@Param("deptId") Long deptId);
} }
...@@ -17,6 +17,6 @@ public class PhysicDestroyNumVO { ...@@ -17,6 +17,6 @@ public class PhysicDestroyNumVO {
private String factoryName; private String factoryName;
private String unit; private String unit;
private String remark; private String remark;
@ApiModelProperty(value = "销毁数量") @ApiModelProperty(value = "剩余数量/可销毁数量")
private Integer destroyNum; private Integer destroyNum;
} }
...@@ -44,28 +44,44 @@ ...@@ -44,28 +44,44 @@
<select id="selectDestroy" resultType="com.jmai.physic.vo.PhysicDestroyNumVO"> <select id="selectDestroy" resultType="com.jmai.physic.vo.PhysicDestroyNumVO">
SELECT SELECT
a.id, s.physic_name,
a.order_no AS ampouleOrderNo, s.physic_spec,
d.order_no AS destroyCheckOrderNo, s.batch_no,
a.physic_name, s.factory_name,
a.physic_spec, s.unit,
a.batch_no, (IFNULL(s.total_physic_num, 0) - IFNULL(d.total_destroy_num, 0)) AS destroyNum
a.factory_name, FROM (
a.unit, -- 按药品名称、规格、批号、厂家分组统计physic_storage_ampoule表中的physic_num数量
(IFNULL(sum(a.physic_num),0) - IFNULL(sum(a.expend_num),0)) AS destroyNum, SELECT
a.type, physic_name,
a.destroy_status, physic_spec,
d.status AS destroyCheckStatus batch_no,
FROM physic_storage_ampoule a factory_name,
LEFT JOIN physic_destroy_check d ON a.order_no = d.order_no unit,
WHERE a.del_flag = 0 SUM(physic_num) AS total_physic_num
AND a.accept_dept_id = #{deptId} FROM physic_storage_ampoule
-- 2-移至销毁 WHERE del_flag = 0
AND a.type = 2 AND accept_dept_id = #{deptId}
-- 销毁状态:0-待销毁 1-已销毁 AND type = 2
AND a.destroy_status = 0 AND destroy_status = 0
-- 销毁状态:0-5审批中, 100-已销毁 GROUP BY physic_name, physic_spec, batch_no, factory_name, unit
AND (d.id IS NULL OR d.status BETWEEN 0 AND 99) ) s
GROUP BY a.physic_name,a.physic_spec,a.batch_no,a.factory_name,a.accept_dept_id LEFT JOIN (
-- 按药品名称、规格、批号、厂家分组统计physic_destroy_check_detail表中的destroy_num数量
SELECT
d.physic_name,
d.physic_spec,
d.batch_no,
d.factory_name,
SUM(d.destroy_num) AS total_destroy_num
FROM physic_destroy_check_detail d
INNER JOIN physic_destroy_check c ON d.check_id = c.id AND c.del_flag = 0 AND c._dept_id = #{deptId}
WHERE d.del_flag = 0
GROUP BY d.physic_name, d.physic_spec, d.batch_no, d.factory_name
) d ON s.physic_name = d.physic_name
AND s.physic_spec = d.physic_spec
AND s.batch_no = d.batch_no
AND s.factory_name = d.factory_name
ORDER BY s.physic_name ASC, s.physic_spec ASC, s.factory_name ASC, s.batch_no ASC
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment