|
@@ -2,11 +2,15 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.miyzh.dao.MedicineStorageDao">
|
|
|
|
|
|
- <resultMap id="BaseResultMap" type="com.miyzh.entity.MedicineStorage" extends="com.miyzh.dao.MedicineDao.BaseResultMap">
|
|
|
+ <resultMap id="BaseResultMap" type="com.miyzh.entity.MedicineStorageTemp" extends="com.miyzh.dao.MedicineDao.BaseResultMap">
|
|
|
<!--实际入库数量-->
|
|
|
<result column="storage_quantity" jdbcType="VARCHAR" property="storageQuantity" />
|
|
|
<!--机构入库编码-->
|
|
|
<result column="store_storage_code" jdbcType="VARCHAR" property="storeStorageCode" />
|
|
|
+ <!--入库人-->
|
|
|
+ <result column="storage_man" jdbcType="VARCHAR" property="storageMan" />
|
|
|
+ <!--入库时间-->
|
|
|
+ <result column="storage_time" jdbcType="VARCHAR" property="storageTime" />
|
|
|
</resultMap>
|
|
|
|
|
|
<select id="listMedicinePurchase" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
@@ -15,23 +19,224 @@
|
|
|
IF
|
|
|
( length( cm.med_ins_backup_id )> 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
cm.medicine_c_name as store_medicine_name,
|
|
|
- cm.medicine_specifications AS YPGG,
|
|
|
- cm.medicine_unit AS YPDW,
|
|
|
- '采购入库' BRXM,
|
|
|
+ cm.medicine_name_goods as store_medicine_trade_name,
|
|
|
+ ifnull(idm.formulation, " ") as dosage_id,
|
|
|
+ cm.medicine_dosage_forms as dosage_name,
|
|
|
+ cm.medicine_specifications AS specification,
|
|
|
+ cm.medicine_manufacturer_name as manufacturer,
|
|
|
+ cm.medicine_place as place,
|
|
|
+ cm.medicine_unit AS pack,
|
|
|
+ " " as model,
|
|
|
+ csd.stock_batch_number as batch_no,
|
|
|
+ csd.create_time as medicine_deadline,
|
|
|
+ csd.medicine_deadline as manufacture_time,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
+ "" as regist_no,
|
|
|
+ csd.stock_channel as delivery_company,
|
|
|
+ "999999999" as distributor,
|
|
|
cp.purchase_no as store_storage_code,
|
|
|
- sum( csd.stock_change_number ) AS YPSL,
|
|
|
- csd.stock_bid AS JHJG,
|
|
|
- cs.medicine_retail_price AS YPDJ,
|
|
|
- sum( csd.stock_change_number * cs.medicine_retail_price ) AS YPJE,
|
|
|
- cp.create_time AS CZRQ,
|
|
|
- cp.create_username AS CZGH,
|
|
|
- cp.id AS HIS_ID
|
|
|
+ sum( csd.stock_change_number ) AS storage_quantity,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ cs.medicine_retail_price AS retail_price,
|
|
|
+ "" as plat_item_code,
|
|
|
+ "" as plat_item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
+ cp.create_username AS storage_man,
|
|
|
+ cp.create_time as storage_time
|
|
|
FROM
|
|
|
clc_stock_detail csd,
|
|
|
clc_medicine cm,
|
|
|
clc_stock cs,
|
|
|
clc_stock_inbound csi,
|
|
|
- clc_purchase cp
|
|
|
+ clc_purchase cp,
|
|
|
+ ins_d_medicine idm
|
|
|
+ WHERE
|
|
|
+ csd.medicine_id = cm.medicine_id
|
|
|
+ AND csd.clinic_id = cm.clinic_id
|
|
|
+ AND csd.clinic_id = cs.clinic_id
|
|
|
+ AND csd.medicine_id = cs.medicine_id
|
|
|
+ AND cs.warehouse_code = '1'
|
|
|
+ AND csd.clinic_id = csi.clinic_id
|
|
|
+ AND csd.id = csi.id
|
|
|
+ AND csd.clinic_id = cp.clinic_id
|
|
|
+ AND cp.id = csi.purchase_id
|
|
|
+ AND csd.clinic_id = #{clinicId}
|
|
|
+ AND timestamp_number != 'default'
|
|
|
+ AND cm.is_base = 1
|
|
|
+ and cp.purchase_no is not null
|
|
|
+ AND idm.medicine_id = cm.medicine_id
|
|
|
+ AND idm.clinic_id = cm.clinic_id
|
|
|
+ GROUP BY
|
|
|
+ cp.id,
|
|
|
+ csd.medicine_id
|
|
|
+ ORDER BY
|
|
|
+ cp.create_time,
|
|
|
+ csd.medicine_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="listChinaMedicinePurchase" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT DISTINCT
|
|
|
+ cm.medicine_category as item_type,
|
|
|
+ IF
|
|
|
+ ( length( cm.med_ins_backup_id )> 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
+ cm.medicine_c_name as store_medicine_name,
|
|
|
+ cm.medicine_name_goods as store_medicine_trade_name,
|
|
|
+ ifnull(idm.formulation, " ") as dosage_id,
|
|
|
+ cm.medicine_dosage_forms as dosage_name,
|
|
|
+ cm.medicine_specifications AS specification,
|
|
|
+ cm.medicine_manufacturer_name as manufacturer,
|
|
|
+ cm.medicine_place as place,
|
|
|
+ cm.medicine_unit AS pack,
|
|
|
+ " " as model,
|
|
|
+ csd.stock_batch_number as batch_no,
|
|
|
+ csd.create_time as medicine_deadline,
|
|
|
+ csd.medicine_deadline as manufacture_time,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
+ "" as regist_no,
|
|
|
+ csd.stock_channel as delivery_company,
|
|
|
+ "999999999" as distributor,
|
|
|
+ cp.purchase_no as store_storage_code,
|
|
|
+ sum( csd.stock_change_number ) AS storage_quantity,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ cs.medicine_retail_price AS retail_price,
|
|
|
+ "" as plat_item_code,
|
|
|
+ "" as plat_item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
+ cp.create_username AS storage_man,
|
|
|
+ cp.create_time as storage_time
|
|
|
+ FROM
|
|
|
+ clc_stock_detail csd,
|
|
|
+ clc_medicine cm,
|
|
|
+ clc_stock cs,
|
|
|
+ clc_stock_inbound csi,
|
|
|
+ clc_purchase cp,
|
|
|
+ ins_d_medicine idm
|
|
|
+ WHERE
|
|
|
+ csd.medicine_id = cm.medicine_id
|
|
|
+ AND csd.clinic_id = cm.clinic_id
|
|
|
+ AND csd.clinic_id = cs.clinic_id
|
|
|
+ AND csd.medicine_id = cs.medicine_id
|
|
|
+ AND cs.warehouse_code = '1'
|
|
|
+ AND csd.clinic_id = csi.clinic_id
|
|
|
+ AND csd.id = csi.id
|
|
|
+ AND csd.clinic_id = cp.clinic_id
|
|
|
+ AND cp.id = csi.purchase_id
|
|
|
+ AND csd.clinic_id = #{clinicId}
|
|
|
+ AND timestamp_number != 'default'
|
|
|
+ AND cm.is_base = 1
|
|
|
+ and cp.purchase_no is not null
|
|
|
+ AND idm.medicine_id = cm.medicine_id
|
|
|
+ AND idm.clinic_id = cm.clinic_id
|
|
|
+ GROUP BY
|
|
|
+ cp.id,
|
|
|
+ csd.medicine_id
|
|
|
+ ORDER BY
|
|
|
+ cp.create_time,
|
|
|
+ csd.medicine_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="listMedicineOutbound" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT DISTINCT
|
|
|
+ cm.medicine_category as item_type,
|
|
|
+ IF
|
|
|
+ ( length( cm.med_ins_backup_id )> 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
+ cm.medicine_c_name as store_medicine_name,
|
|
|
+ cm.medicine_name_goods as store_medicine_trade_name,
|
|
|
+ ifnull(idm.formulation, " ") as dosage_id,
|
|
|
+ cm.medicine_dosage_forms as dosage_name,
|
|
|
+ cm.medicine_specifications AS specification,
|
|
|
+ cm.medicine_manufacturer_name as manufacturer,
|
|
|
+ cm.medicine_place as place,
|
|
|
+ cm.medicine_unit AS pack,
|
|
|
+ " " as model,
|
|
|
+ csd.stock_batch_number as batch_no,
|
|
|
+ csd.create_time as medicine_deadline,
|
|
|
+ csd.medicine_deadline as manufacture_time,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
+ "" as regist_no,
|
|
|
+ csd.stock_channel as delivery_company,
|
|
|
+ "999999999" as distributor,
|
|
|
+ cp.purchase_no as store_storage_code,
|
|
|
+ sum( csd.stock_change_number ) AS storage_quantity,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ cs.medicine_retail_price AS retail_price,
|
|
|
+ "" as plat_item_code,
|
|
|
+ "" as plat_item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
+ cp.create_username AS storage_man,
|
|
|
+ cp.create_time as storage_time
|
|
|
+ FROM
|
|
|
+ clc_stock_detail csd,
|
|
|
+ clc_medicine cm,
|
|
|
+ clc_stock cs,
|
|
|
+ clc_stock_inbound csi,
|
|
|
+ clc_purchase cp,
|
|
|
+ ins_d_medicine idm
|
|
|
+ WHERE
|
|
|
+ csd.medicine_id = cm.medicine_id
|
|
|
+ AND csd.clinic_id = cm.clinic_id
|
|
|
+ AND csd.clinic_id = cs.clinic_id
|
|
|
+ AND csd.medicine_id = cs.medicine_id
|
|
|
+ AND cs.warehouse_code = '1'
|
|
|
+ AND csd.clinic_id = csi.clinic_id
|
|
|
+ AND csd.id = csi.id
|
|
|
+ AND csd.clinic_id = cp.clinic_id
|
|
|
+ AND cp.id = csi.purchase_id
|
|
|
+ AND csd.clinic_id = #{clinicId}
|
|
|
+ AND timestamp_number != 'default'
|
|
|
+ AND cm.is_base = 1
|
|
|
+ and cp.purchase_no is not null
|
|
|
+ AND idm.medicine_id = cm.medicine_id
|
|
|
+ AND idm.clinic_id = cm.clinic_id
|
|
|
+ GROUP BY
|
|
|
+ cp.id,
|
|
|
+ csd.medicine_id
|
|
|
+ ORDER BY
|
|
|
+ cp.create_time,
|
|
|
+ csd.medicine_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="listChinaMedicineOutbound" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT DISTINCT
|
|
|
+ cm.medicine_category as item_type,
|
|
|
+ IF
|
|
|
+ ( length( cm.med_ins_backup_id )> 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
+ cm.medicine_c_name as store_medicine_name,
|
|
|
+ cm.medicine_name_goods as store_medicine_trade_name,
|
|
|
+ ifnull(idm.formulation, " ") as dosage_id,
|
|
|
+ cm.medicine_dosage_forms as dosage_name,
|
|
|
+ cm.medicine_specifications AS specification,
|
|
|
+ cm.medicine_manufacturer_name as manufacturer,
|
|
|
+ cm.medicine_place as place,
|
|
|
+ cm.medicine_unit AS pack,
|
|
|
+ " " as model,
|
|
|
+ csd.stock_batch_number as batch_no,
|
|
|
+ csd.create_time as medicine_deadline,
|
|
|
+ csd.medicine_deadline as manufacture_time,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
+ "" as regist_no,
|
|
|
+ csd.stock_channel as delivery_company,
|
|
|
+ "999999999" as distributor,
|
|
|
+ cp.purchase_no as store_storage_code,
|
|
|
+ sum( csd.stock_change_number ) AS storage_quantity,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ cs.medicine_retail_price AS retail_price,
|
|
|
+ "" as plat_item_code,
|
|
|
+ "" as plat_item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
+ cp.create_username AS storage_man,
|
|
|
+ cp.create_time as storage_time
|
|
|
+ FROM
|
|
|
+ clc_stock_detail csd,
|
|
|
+ clc_medicine cm,
|
|
|
+ clc_stock cs,
|
|
|
+ clc_stock_inbound csi,
|
|
|
+ clc_purchase cp,
|
|
|
+ ins_d_medicine idm
|
|
|
WHERE
|
|
|
csd.medicine_id = cm.medicine_id
|
|
|
AND csd.clinic_id = cm.clinic_id
|
|
@@ -45,6 +250,9 @@
|
|
|
AND csd.clinic_id = #{clinicId}
|
|
|
AND timestamp_number != 'default'
|
|
|
AND cm.is_base = 1
|
|
|
+ and cp.purchase_no is not null
|
|
|
+ AND idm.medicine_id = cm.medicine_id
|
|
|
+ AND idm.clinic_id = cm.clinic_id
|
|
|
GROUP BY
|
|
|
cp.id,
|
|
|
csd.medicine_id
|
|
@@ -53,48 +261,128 @@
|
|
|
csd.medicine_id
|
|
|
</select>
|
|
|
|
|
|
- <select id="listChinaMedicineStore" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
- select
|
|
|
- ccm.medicine_category as item_type,
|
|
|
- ccm.med_ins_backup_id as store_medicine_code,
|
|
|
- ccm.medicine_name as store_medicine_name,
|
|
|
- ccm.medicine_name as store_medicine_trade_name,
|
|
|
- ifnull(idm.formulation, " ") as dosage_id,
|
|
|
- ccm.medicine_rate_last as dosage_name,
|
|
|
- ccm.medicine_specifications as specification,
|
|
|
- ccm.medicine_manufacturer_name as manufacturer,
|
|
|
- ccm.medicine_address as place,
|
|
|
- idm.medicine_package as pack,
|
|
|
- " " as model,
|
|
|
- ccsp.stock_batch_number as batch_no,
|
|
|
- ccm.create_time as medicine_deadline,
|
|
|
- ccsp.medicine_deadline as manufacture_time,
|
|
|
- "0000000000000" as bar_code,
|
|
|
- "" as regist_no,
|
|
|
- ccsp.stock_channel as delivery_company,
|
|
|
- "999999999" as distributor,
|
|
|
- ccsp.stock_bid as price,
|
|
|
- idm.sale_price as retail_price,
|
|
|
- "" as plat_item_code,
|
|
|
- "" as plat_item_name,
|
|
|
- idm.standard_menu_code as item_code,
|
|
|
- idm.insurance_medicine_name as item_name,
|
|
|
- "999999999" as approval_number,
|
|
|
- ccsp.remain_number as current_num
|
|
|
- from
|
|
|
- clc_china_stock_profit ccsp
|
|
|
- left join
|
|
|
- clc_china_medicine ccm
|
|
|
- on
|
|
|
- ccm.clinic_id = ccsp.clinic_id and ccsp.medicine_id=ccm.medicine_id
|
|
|
- left join
|
|
|
+ <select id="listMedicineInventory" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT DISTINCT
|
|
|
+ cm.medicine_category as item_type,
|
|
|
+ IF
|
|
|
+ ( length( cm.med_ins_backup_id )> 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
+ cm.medicine_c_name as store_medicine_name,
|
|
|
+ cm.medicine_name_goods as store_medicine_trade_name,
|
|
|
+ ifnull(idm.formulation, " ") as dosage_id,
|
|
|
+ cm.medicine_dosage_forms as dosage_name,
|
|
|
+ cm.medicine_specifications AS specification,
|
|
|
+ cm.medicine_manufacturer_name as manufacturer,
|
|
|
+ cm.medicine_place as place,
|
|
|
+ cm.medicine_unit AS pack,
|
|
|
+ " " as model,
|
|
|
+ csd.stock_batch_number as batch_no,
|
|
|
+ csd.create_time as medicine_deadline,
|
|
|
+ csd.medicine_deadline as manufacture_time,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
+ "" as regist_no,
|
|
|
+ csd.stock_channel as delivery_company,
|
|
|
+ "999999999" as distributor,
|
|
|
+ cp.purchase_no as store_storage_code,
|
|
|
+ sum( csd.stock_change_number ) AS storage_quantity,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ cs.medicine_retail_price AS retail_price,
|
|
|
+ "" as plat_item_code,
|
|
|
+ "" as plat_item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
+ cp.create_username AS storage_man,
|
|
|
+ cp.create_time as storage_time
|
|
|
+ FROM
|
|
|
+ clc_stock_detail csd,
|
|
|
+ clc_medicine cm,
|
|
|
+ clc_stock cs,
|
|
|
+ clc_stock_inbound csi,
|
|
|
+ clc_purchase cp,
|
|
|
ins_d_medicine idm
|
|
|
- on
|
|
|
- ccsp.clinic_id = idm.clinic_id and ccsp.medicine_id=idm.medicine_id
|
|
|
- where
|
|
|
- ccsp.clinic_id = #{clinicId}
|
|
|
+ WHERE
|
|
|
+ csd.medicine_id = cm.medicine_id
|
|
|
+ AND csd.clinic_id = cm.clinic_id
|
|
|
+ AND csd.clinic_id = cs.clinic_id
|
|
|
+ AND csd.medicine_id = cs.medicine_id
|
|
|
+ AND cs.warehouse_code = '1'
|
|
|
+ AND csd.clinic_id = csi.clinic_id
|
|
|
+ AND csd.id = csi.id
|
|
|
+ AND csd.clinic_id = cp.clinic_id
|
|
|
+ AND cp.id = csi.purchase_id
|
|
|
+ AND csd.clinic_id = #{clinicId}
|
|
|
+ AND timestamp_number != 'default'
|
|
|
+ AND cm.is_base = 1
|
|
|
+ and cp.purchase_no is not null
|
|
|
+ AND idm.medicine_id = cm.medicine_id
|
|
|
+ AND idm.clinic_id = cm.clinic_id
|
|
|
+ GROUP BY
|
|
|
+ cp.id,
|
|
|
+ csd.medicine_id
|
|
|
+ ORDER BY
|
|
|
+ cp.create_time,
|
|
|
+ csd.medicine_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="listChinaMedicineInventory" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
|
+ SELECT DISTINCT
|
|
|
+ cm.medicine_category as item_type,
|
|
|
+ IF
|
|
|
+ ( length( cm.med_ins_backup_id )> 0, cm.med_ins_backup_id, cm.medicine_id ) AS store_medicine_code,
|
|
|
+ cm.medicine_c_name as store_medicine_name,
|
|
|
+ cm.medicine_name_goods as store_medicine_trade_name,
|
|
|
+ ifnull(idm.formulation, " ") as dosage_id,
|
|
|
+ cm.medicine_dosage_forms as dosage_name,
|
|
|
+ cm.medicine_specifications AS specification,
|
|
|
+ cm.medicine_manufacturer_name as manufacturer,
|
|
|
+ cm.medicine_place as place,
|
|
|
+ cm.medicine_unit AS pack,
|
|
|
+ " " as model,
|
|
|
+ csd.stock_batch_number as batch_no,
|
|
|
+ csd.create_time as medicine_deadline,
|
|
|
+ csd.medicine_deadline as manufacture_time,
|
|
|
+ cm.medicine_barcode as bar_code,
|
|
|
+ "" as regist_no,
|
|
|
+ csd.stock_channel as delivery_company,
|
|
|
+ "999999999" as distributor,
|
|
|
+ cp.purchase_no as store_storage_code,
|
|
|
+ sum( csd.stock_change_number ) AS storage_quantity,
|
|
|
+ csd.stock_bid AS price,
|
|
|
+ cs.medicine_retail_price AS retail_price,
|
|
|
+ "" as plat_item_code,
|
|
|
+ "" as plat_item_name,
|
|
|
+ idm.standard_menu_code as item_code,
|
|
|
+ idm.insurance_medicine_name as item_name,
|
|
|
+ cp.create_username AS storage_man,
|
|
|
+ cp.create_time as storage_time
|
|
|
+ FROM
|
|
|
+ clc_stock_detail csd,
|
|
|
+ clc_medicine cm,
|
|
|
+ clc_stock cs,
|
|
|
+ clc_stock_inbound csi,
|
|
|
+ clc_purchase cp,
|
|
|
+ ins_d_medicine idm
|
|
|
+ WHERE
|
|
|
+ csd.medicine_id = cm.medicine_id
|
|
|
+ AND csd.clinic_id = cm.clinic_id
|
|
|
+ AND csd.clinic_id = cs.clinic_id
|
|
|
+ AND csd.medicine_id = cs.medicine_id
|
|
|
+ AND cs.warehouse_code = '1'
|
|
|
+ AND csd.clinic_id = csi.clinic_id
|
|
|
+ AND csd.id = csi.id
|
|
|
+ AND csd.clinic_id = cp.clinic_id
|
|
|
+ AND cp.id = csi.purchase_id
|
|
|
+ AND csd.clinic_id = #{clinicId}
|
|
|
+ AND timestamp_number != 'default'
|
|
|
+ AND cm.is_base = 1
|
|
|
+ and cp.purchase_no is not null
|
|
|
+ AND idm.medicine_id = cm.medicine_id
|
|
|
+ AND idm.clinic_id = cm.clinic_id
|
|
|
GROUP BY
|
|
|
- ccsp.medicine_id
|
|
|
+ cp.id,
|
|
|
+ csd.medicine_id
|
|
|
+ ORDER BY
|
|
|
+ cp.create_time,
|
|
|
+ csd.medicine_id
|
|
|
</select>
|
|
|
|
|
|
|