fix(report): 修复库存报表查询SQL格式化问题并优化处方组套处理逻辑
- 修复InventoryProductReportMapper.xml中SQL查询的缩进格式问题 - 在prescriptionlist.vue中添加组套数据验证防止空值异常 - 优化组套处理逻辑确保医嘱详情数据正确获取 - 修复最小单位数量计算避免partPercent为空时的错误
This commit is contained in:
@@ -4,130 +4,130 @@
|
|||||||
|
|
||||||
<select id="selectProductReportPage"
|
<select id="selectProductReportPage"
|
||||||
resultType="com.openhis.web.reportmanage.dto.InventoryProductReportPageDto">
|
resultType="com.openhis.web.reportmanage.dto.InventoryProductReportPageDto">
|
||||||
-- SELECT T8.id, --ID
|
SELECT T8.id, --ID
|
||||||
-- T8.bus_no, --药品编码
|
T8.bus_no, --药品编码
|
||||||
-- T8.name, --药品名称
|
T8.name, --药品名称
|
||||||
-- T8.lot_number, --批次号
|
T8.lot_number, --批次号
|
||||||
-- T8.manufacturer_text, --厂家
|
T8.manufacturer_text, --厂家
|
||||||
-- T8.item_table, --药品类型
|
T8.item_table, --药品类型
|
||||||
-- T8.item_quantity, --库存数量
|
T8.item_quantity, --库存数量
|
||||||
-- T8.unit_code, --计量单位
|
T8.unit_code, --计量单位
|
||||||
-- T8.min_package_quantity, --小包装库存数
|
T8.min_package_quantity, --小包装库存数
|
||||||
-- T8.min_package_unit, --小包装单位
|
T8.min_package_unit, --小包装单位
|
||||||
-- T8.price, --进价
|
T8.price, --进价
|
||||||
-- T8.sale_price, --售价
|
T8.sale_price, --售价
|
||||||
-- T8.price * T8.part_percent AS part_price, --拆零进价
|
T8.price * T8.part_percent AS part_price, --拆零进价
|
||||||
-- T8.sale_price * T8.part_percent AS part_sale_price, --拆零售价
|
T8.sale_price * T8.part_percent AS part_sale_price, --拆零售价
|
||||||
-- T8.price * T8.item_quantity AS total_price, --进价金额(总价)
|
T8.price * T8.item_quantity AS total_price, --进价金额(总价)
|
||||||
-- T8.sale_price * T8.item_quantity AS total_sale_price, --售价金额(总价)
|
T8.sale_price * T8.item_quantity AS total_sale_price, --售价金额(总价)
|
||||||
-- T8.purpose_type_enum, --仓库类型
|
T8.purpose_type_enum, --仓库类型
|
||||||
-- T8.location_name, --仓库名称
|
T8.location_name, --仓库名称
|
||||||
-- T8.location_store_name, --货位名称
|
T8.location_store_name, --货位名称
|
||||||
-- T8.expiration_date, --有效期
|
T8.expiration_date, --有效期
|
||||||
-- T8.yb_no, --医保编码
|
T8.yb_no, --医保编码
|
||||||
-- T8.tenant_id -- 租户ID
|
T8.tenant_id -- 租户ID
|
||||||
-- FROM (SELECT T1.id, --ID
|
FROM (SELECT T1.id, --ID
|
||||||
-- T2.bus_no, --药品编码
|
T2.bus_no, --药品编码
|
||||||
-- T2.name, --药品名称
|
T2.name, --药品名称
|
||||||
-- T1.lot_number, --批次号
|
T1.lot_number, --批次号
|
||||||
-- T2.manufacturer_text, --厂家
|
T2.manufacturer_text, --厂家
|
||||||
-- T2.category_code AS item_table, --药品类型
|
T2.category_code AS item_table, --药品类型
|
||||||
-- T1.quantity AS item_quantity, --库存数量
|
T1.quantity AS item_quantity, --库存数量
|
||||||
-- T2.unit_code, --计量单位
|
T2.unit_code, --计量单位
|
||||||
-- T1.quantity AS min_package_quantity, --小包装库存数
|
T1.quantity AS min_package_quantity, --小包装库存数
|
||||||
-- T2.min_unit_code AS min_package_unit, --小包装单位
|
T2.min_unit_code AS min_package_unit, --小包装单位
|
||||||
-- CASE
|
CASE
|
||||||
-- WHEN T4.condition_code = #{lotNumber}
|
WHEN T4.condition_code = #{lotNumber}
|
||||||
-- AND T4.condition_value = T1.lot_number
|
AND T4.condition_value = T1.lot_number
|
||||||
-- THEN T4.amount
|
THEN T4.amount
|
||||||
-- ELSE T3.price END AS sale_price, --售价
|
ELSE T3.price END AS sale_price, --售价
|
||||||
-- T2.part_percent, --拆零比
|
T2.part_percent, --拆零比
|
||||||
-- T6.form_enum AS purpose_type_enum, --仓库类型
|
T6.form_enum AS purpose_type_enum, --仓库类型
|
||||||
-- T6.name AS location_name, --仓库名称
|
T6.name AS location_name, --仓库名称
|
||||||
-- T7.name AS location_store_name, --货位名称
|
T7.name AS location_store_name, --货位名称
|
||||||
-- T1.expiration_date, --有效期
|
T1.expiration_date, --有效期
|
||||||
-- T2.yb_no, --医保编码
|
T2.yb_no, --医保编码
|
||||||
-- T1.tenant_id -- 租户ID
|
T1.tenant_id -- 租户ID
|
||||||
-- FROM wor_inventory_item AS T1
|
FROM wor_inventory_item AS T1
|
||||||
-- INNER JOIN med_medication_definition AS T2
|
INNER JOIN med_medication_definition AS T2
|
||||||
-- ON T2.id = T1.item_id
|
ON T2.id = T1.item_id
|
||||||
-- AND T2.delete_flag = '0'
|
AND T2.delete_flag = '0'
|
||||||
-- INNER JOIN adm_charge_item_definition AS T3
|
INNER JOIN adm_charge_item_definition AS T3
|
||||||
-- ON T3.instance_id = T2.id
|
ON T3.instance_id = T2.id
|
||||||
-- AND T3.delete_flag = '0'
|
AND T3.delete_flag = '0'
|
||||||
-- LEFT JOIN adm_charge_item_def_detail AS T4
|
LEFT JOIN adm_charge_item_def_detail AS T4
|
||||||
-- ON T4.definition_id = T3.id
|
ON T4.definition_id = T3.id
|
||||||
-- AND T4.delete_flag = '0'
|
AND T4.delete_flag = '0'
|
||||||
-- LEFT JOIN adm_location T6
|
LEFT JOIN adm_location T6
|
||||||
-- ON T1.location_id = T6.id
|
ON T1.location_id = T6.id
|
||||||
-- AND T6.delete_flag = '0'
|
AND T6.delete_flag = '0'
|
||||||
-- LEFT JOIN adm_location T7
|
LEFT JOIN adm_location T7
|
||||||
-- ON T1.location_store_id = T7.id
|
ON T1.location_store_id = T7.id
|
||||||
-- AND T7.delete_flag = '0'
|
AND T7.delete_flag = '0'
|
||||||
-- WHERE T1.delete_flag = '0') AS T8
|
WHERE T1.delete_flag = '0') AS T8
|
||||||
-- UNION
|
UNION
|
||||||
-- SELECT T10.id, --ID
|
SELECT T10.id, --ID
|
||||||
-- T10.bus_no, --器材编码
|
T10.bus_no, --器材编码
|
||||||
-- T10.name, --器材名称
|
T10.name, --器材名称
|
||||||
-- T10.lot_number, --批次号
|
T10.lot_number, --批次号
|
||||||
-- T10.manufacturer_text, --厂家
|
T10.manufacturer_text, --厂家
|
||||||
-- T10.item_table, --器材类型
|
T10.item_table, --器材类型
|
||||||
-- T10.item_quantity, --库存数量
|
T10.item_quantity, --库存数量
|
||||||
-- T10.unit_code, --计量单位
|
T10.unit_code, --计量单位
|
||||||
-- T10.min_package_quantity, --小包装库存数
|
T10.min_package_quantity, --小包装库存数
|
||||||
-- T10.min_package_unit, --小包装单位
|
T10.min_package_unit, --小包装单位
|
||||||
-- T10.price, --进价
|
T10.price, --进价
|
||||||
-- T10.sale_price, --售价
|
T10.sale_price, --售价
|
||||||
-- T10.price * T10.part_percent AS part_price, --拆零进价
|
T10.price * T10.part_percent AS part_price, --拆零进价
|
||||||
-- T10.sale_price * T10.part_percent AS part_sale_price, --拆零售价
|
T10.sale_price * T10.part_percent AS part_sale_price, --拆零售价
|
||||||
-- T10.price * T10.item_quantity AS total_price, --进价金额(总价)
|
T10.price * T10.item_quantity AS total_price, --进价金额(总价)
|
||||||
-- T10.sale_price * T10.item_quantity AS total_sale_price, --售价金额(总价)
|
T10.sale_price * T10.item_quantity AS total_sale_price, --售价金额(总价)
|
||||||
-- T10.purpose_type_enum, --仓库类型
|
T10.purpose_type_enum, --仓库类型
|
||||||
-- T10.location_name, --仓库名称
|
T10.location_name, --仓库名称
|
||||||
-- T10.location_store_name, --货位名称
|
T10.location_store_name, --货位名称
|
||||||
-- T10.expiration_date, --有效期
|
T10.expiration_date, --有效期
|
||||||
-- T10.yb_no, --医保编码
|
T10.yb_no, --医保编码
|
||||||
-- T10.tenant_id -- 租户ID
|
T10.tenant_id -- 租户ID
|
||||||
-- FROM (SELECT T1.id, --ID
|
FROM (SELECT T1.id, --ID
|
||||||
-- T9.bus_no, --药品编码
|
T9.bus_no, --药品编码
|
||||||
-- T9.name, --药品名称
|
T9.name, --药品名称
|
||||||
-- T1.lot_number, --批次号
|
T1.lot_number, --批次号
|
||||||
-- T9.manufacturer_text, --厂家
|
T9.manufacturer_text, --厂家
|
||||||
-- T9.category_code AS item_table, --药品类型
|
T9.category_code AS item_table, --药品类型
|
||||||
-- T1.quantity AS item_quantity, --库存数量
|
T1.quantity AS item_quantity, --库存数量
|
||||||
-- T9.unit_code, --计量单位
|
T9.unit_code, --计量单位
|
||||||
-- T1.quantity AS min_package_quantity, --小包装库存数
|
T1.quantity AS min_package_quantity, --小包装库存数
|
||||||
-- T9.min_unit_code AS min_package_unit, --小包装单位
|
T9.min_unit_code AS min_package_unit, --小包装单位
|
||||||
-- T1.price, --进价
|
T1.price, --进价
|
||||||
-- CASE
|
CASE
|
||||||
-- WHEN T4.condition_code = #{lotNumber}
|
WHEN T4.condition_code = #{lotNumber}
|
||||||
-- AND T4.condition_value = T1.lot_number
|
AND T4.condition_value = T1.lot_number
|
||||||
-- THEN T4.amount
|
THEN T4.amount
|
||||||
-- ELSE T3.price END AS sale_price, --售价
|
ELSE T3.price END AS sale_price, --售价
|
||||||
-- T9.part_percent, --拆零比
|
T9.part_percent, --拆零比
|
||||||
-- T6.form_enum AS purpose_type_enum, --仓库类型
|
T6.form_enum AS purpose_type_enum, --仓库类型
|
||||||
-- T6.name AS location_name, --仓库名称
|
T6.name AS location_name, --仓库名称
|
||||||
-- T7.name AS location_store_name, --货位名称
|
T7.name AS location_store_name, --货位名称
|
||||||
-- T1.expiration_date, --有效期
|
T1.expiration_date, --有效期
|
||||||
-- T9.yb_no, --医保编码
|
T9.yb_no, --医保编码
|
||||||
-- T1.tenant_id -- 租户ID
|
T1.tenant_id -- 租户ID
|
||||||
-- FROM wor_inventory_item AS T1
|
FROM wor_inventory_item AS T1
|
||||||
-- INNER JOIN adm_device_definition AS T9
|
INNER JOIN adm_device_definition AS T9
|
||||||
-- ON T9.id = T1.item_id
|
ON T9.id = T1.item_id
|
||||||
-- AND T9.delete_flag = '0'
|
AND T9.delete_flag = '0'
|
||||||
-- INNER JOIN adm_charge_item_definition AS T3
|
INNER JOIN adm_charge_item_definition AS T3
|
||||||
-- ON T3.instance_id = T9.id
|
ON T3.instance_id = T9.id
|
||||||
-- AND T3.delete_flag = '0'
|
AND T3.delete_flag = '0'
|
||||||
-- LEFT JOIN adm_charge_item_def_detail AS T4
|
LEFT JOIN adm_charge_item_def_detail AS T4
|
||||||
-- ON T4.definition_id = T3.id
|
ON T4.definition_id = T3.id
|
||||||
-- AND T4.delete_flag = '0'
|
AND T4.delete_flag = '0'
|
||||||
-- LEFT JOIN adm_location T6
|
LEFT JOIN adm_location T6
|
||||||
-- ON T1.location_id = T6.id
|
ON T1.location_id = T6.id
|
||||||
-- AND T6.delete_flag = '0'
|
AND T6.delete_flag = '0'
|
||||||
-- LEFT JOIN adm_location T7
|
LEFT JOIN adm_location T7
|
||||||
-- ON T1.location_store_id = T7.id
|
ON T1.location_store_id = T7.id
|
||||||
-- AND T7.delete_flag = '0'
|
AND T7.delete_flag = '0'
|
||||||
-- WHERE T1.delete_flag = '0') AS T10
|
WHERE T1.delete_flag = '0') AS T10
|
||||||
-- ${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -2453,9 +2453,31 @@ function setValue(row) {
|
|||||||
|
|
||||||
// 选择组套
|
// 选择组套
|
||||||
function handleSaveGroup(orderGroupList) {
|
function handleSaveGroup(orderGroupList) {
|
||||||
|
if (!orderGroupList || !Array.isArray(orderGroupList) || orderGroupList.length === 0) {
|
||||||
|
proxy.$modal.msgWarning('组套数据为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
orderGroupList.forEach((item) => {
|
orderGroupList.forEach((item) => {
|
||||||
rowIndex.value = prescriptionList.value.length;
|
rowIndex.value = prescriptionList.value.length;
|
||||||
setValue(item.orderDetailInfos);
|
|
||||||
|
// 确保 item 有值
|
||||||
|
if (!item) {
|
||||||
|
console.warn('组套中的项目为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取实际的医嘱项目数据
|
||||||
|
// 如果 item 包含 orderDetailInfos,则使用它;否则直接使用 item
|
||||||
|
const orderDetail = item.orderDetailInfos || item;
|
||||||
|
|
||||||
|
if (!orderDetail) {
|
||||||
|
console.warn('组套中的项目详情为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用医嘱项目详情设置值
|
||||||
|
setValue(orderDetail);
|
||||||
|
|
||||||
// 创建新的处方项目
|
// 创建新的处方项目
|
||||||
const newRow = {
|
const newRow = {
|
||||||
@@ -2490,7 +2512,7 @@ function handleSaveGroup(orderGroupList) {
|
|||||||
} else {
|
} else {
|
||||||
newRow.price = newRow.unitPrice;
|
newRow.price = newRow.unitPrice;
|
||||||
newRow.totalPrice = (item.quantity * newRow.unitPrice).toFixed(6);
|
newRow.totalPrice = (item.quantity * newRow.unitPrice).toFixed(6);
|
||||||
newRow.minUnitQuantity = item.quantity * item.orderDetailInfos.partPercent;
|
newRow.minUnitQuantity = item.quantity * (orderDetail.partPercent || 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
newRow.contentJson = JSON.stringify(newRow);
|
newRow.contentJson = JSON.stringify(newRow);
|
||||||
|
|||||||
Reference in New Issue
Block a user