Selaa lähdekoodia

搜索药品时判断(库存-预扣库存)大于0

guowei 2 vuotta sitten
vanhempi
commit
3d97a1bff1

+ 6 - 2
cbkj_web_api/src/main/resources/mappers/drug/TAppMaterialMappingMapper.xml

@@ -216,7 +216,8 @@
 
 
     <select id="transMat" parameterType="CenterHisMappingVO" resultType="CenterHisMappingVO">
-        SELECT
+        select * from
+        (SELECT
         chm.YAOPINDM_TY as yaopindmTy,
 
         cmx.YPML_ID AS centerYpmlId,
@@ -244,6 +245,7 @@
         hmx.YAOPINYF as 'usage',
         hmx.PARENT_YPDM as parentYpdm,
         hmx.GUIGEID AS hisGgid,
+        hmx.shuruma1 AS shuruma1,
 
         amm.MAT_ID as matId,
         amm.MAT_NAME as matName
@@ -269,7 +271,9 @@
         <if test="centerYplx != null and centerYplx!='' ">
             AND cmx.ZHONGYAOLX = #{centerYplx}
         </if>
-        order by CHAR_LENGTH(hmx.shuruma1), hmx.shuruma1, cmx.YAOPINGG, cy.LINGSHOUJIA,cy.CHANDIID
+        ) t
+        where t.centerKucunsl > 0
+        order by CHAR_LENGTH(t.shuruma1), t.shuruma1, t.centerYpgg, t.centerYpdj, t.cdidCenter
         <if test="@java.lang.Math@random() > 0.5 ">
             DESC
         </if>

+ 38 - 34
cbkj_web_api/src/main/resources/mappers/drug/TAppPreparationMaterialMappingMapper.xml

@@ -98,41 +98,43 @@
 
 
     <select id="transPreparationByKnow" parameterType="CenterHisMappingVO" resultType="CenterHisMappingVO">
-        SELECT chm.YAOPINDM_TY     AS yaopindmTy,
-
-        hmx.YAOPINMC        AS showName,
-        hmx.shuruma1        AS shuruma1,
-        hmx.YPML_ID         AS hisYpmlId,
-        hmx.YAOPINDM        AS hisYpdm,
-        hmx.YAOPINMC        AS hisYpmc,
-        hmx.YAOPINGG        AS hisYpgg,
-        hmx.GUIGEID         AS hisGgid,
-        hmx.IS_INSURANCE    AS isInsurance,
-
-        hmx.YICIJL          AS matDose,
-        hmx.YICIJLDW        AS matDoseunit,
-        hmx.YAOPINYF        AS 'usage',
-        hmx.FREQUENCY_ID    AS frequencyId,
-        hmx.FREQUENCY       AS frequency,
-        hmx.FREQUENCY_RATE  AS frequencyRate,
-        hmx.CONTENT         AS content,
-        hmx.EFFECT          AS effect,
-        hmx.USAGE_DESC      AS usageDesc,
+        select * from
+        (SELECT chm.YAOPINDM_TY AS yaopindmTy,
+
+        hmx.YAOPINMC AS showName,
+        hmx.shuruma1 AS shuruma1,
+        hmx.YPML_ID AS hisYpmlId,
+        hmx.YAOPINDM AS hisYpdm,
+        hmx.YAOPINMC AS hisYpmc,
+        hmx.YAOPINGG AS hisYpgg,
+        hmx.GUIGEID AS hisGgid,
+        hmx.IS_INSURANCE AS isInsurance,
+
+        hmx.YICIJL AS matDose,
+        hmx.YICIJLDW AS matDoseunit,
+        hmx.YAOPINYF AS 'usage',
+        hmx.FREQUENCY_ID AS frequencyId,
+        hmx.FREQUENCY AS frequency,
+        hmx.FREQUENCY_RATE AS frequencyRate,
+        hmx.CONTENT AS content,
+        hmx.EFFECT AS effect,
+        hmx.USAGE_DESC AS usageDesc,
         hmx.APPROVAL_NUMBER AS approvalNumber,
 
-        cmx.YPML_ID         AS centerYpmlId,
-        cmx.YAOPINDM        AS centerYpdm,
-        cmx.YAOPINMC        AS centerYpmc,
-        cmx.YAOPINGG        AS centerYpgg,
-        cmx.BAOZHUANGDW     AS centerYpdw,
-        cmx.ZHONGYAOLX      AS centerYplx,
-        cmx.ZHUANHUANXS     AS zhuanhuanxs,
-
-        ckc.CHANDIID        AS cdidCenter,
-        ckc.CHANDIMC        AS centerYpcd,
-        ckc.LINGSHOUJIA     AS centerYpdj,
-        ckc.STORE_ID        AS centerStoreId,
-        (ckc.KUCUNSL- IFNULL((SELECT SUM(YUKOUSL) FROM t_center_ypkc_yk yk WHERE yk.YPML_ID = cmx.YPML_ID AND yk.YAOPINDM = cmx.YAOPINDM AND yk.STORE_ID = ckc.STORE_ID),0)) AS centerKucunsl
+        cmx.YPML_ID AS centerYpmlId,
+        cmx.YAOPINDM AS centerYpdm,
+        cmx.YAOPINMC AS centerYpmc,
+        cmx.YAOPINGG AS centerYpgg,
+        cmx.BAOZHUANGDW AS centerYpdw,
+        cmx.ZHONGYAOLX AS centerYplx,
+        cmx.ZHUANHUANXS AS zhuanhuanxs,
+
+        ckc.CHANDIID AS cdidCenter,
+        ckc.CHANDIMC AS centerYpcd,
+        ckc.LINGSHOUJIA AS centerYpdj,
+        ckc.STORE_ID AS centerStoreId,
+        (ckc.KUCUNSL- IFNULL((SELECT SUM(YUKOUSL) FROM t_center_ypkc_yk yk WHERE yk.YPML_ID = cmx.YPML_ID AND yk.YAOPINDM = cmx.YAOPINDM AND
+        yk.STORE_ID = ckc.STORE_ID),0)) AS centerKucunsl
 
         FROM T_CENTER_HIS_YPMLMX hmx
         JOIN T_CENTER_HIS_MAPPING chm ON chm.YPDM_HIS = hmx.YAOPINDM AND chm.YPML_ID_HIS = hmx.YPML_ID
@@ -144,6 +146,8 @@
         <if test="matId != null and matId!='' ">
             AND amm.MAT_ID = #{matId}
         </if>
-        ORDER BY ckc.KUCUNSL DESC, CHAR_LENGTH(hmx.shuruma1), cmx.YAOPINGG, hmx.YAOPINMC, ckc.LINGSHOUJIA, ckc.CHANDIID
+        ) t
+        where t.centerKucunsl > 0
+        ORDER BY t.centerKucunsl DESC, CHAR_LENGTH(t.shuruma1), t.centerYpgg, t.showName, t.centerYpdj, t.cdidCenter
     </select>
 </mapper>

+ 55 - 40
cbkj_web_api/src/main/resources/mappers/drug/TCenterHisYpmlmxMapper.xml

@@ -452,6 +452,7 @@
         </if>
         ORDER BY matId DESC
         ) t
+        where t.centerKucunsl > 0
         GROUP BY t.showName, t.hisGgid
         ORDER BY CHAR_LENGTH(t.shuruma1), t.matId DESC, t.centerYpgg, t.showName, t.centerYpdj, t.cdidCenter
         <if test="@java.lang.Math@random() > 0.5 ">
@@ -460,6 +461,7 @@
     </select>
 
     <select id="getHisMatByGuiGe" parameterType="CenterHisMappingVO" resultType="CenterHisMappingVO">
+        select * from (
         SELECT
         chm.YAOPINDM_TY AS yaopindmTy,
 
@@ -476,6 +478,7 @@
         hmx.DAILY_MAX_DOSE_EXT as dailyMaxDoseExt,
         hmx.PARENT_YPDM as parentYpdm,
         hmx.GUIGEID AS hisGgid,
+        hmx.shuruma1 AS shuruma1,
 
         cmx.YPML_ID AS centerYpmlId,
         cmx.YAOPINDM AS centerYpdm,
@@ -489,7 +492,8 @@
         ckc.CHANDIMC AS centerYpcd,
         ckc.LINGSHOUJIA AS centerYpdj,
         ckc.STORE_ID AS centerStoreId,
-        (ckc.KUCUNSL- IFNULL((SELECT SUM(YUKOUSL) FROM t_center_ypkc_yk yk WHERE yk.YPML_ID = cmx.YPML_ID AND yk.YAOPINDM = cmx.YAOPINDM AND yk.STORE_ID = ckc.STORE_ID),0)) AS centerKucunsl,
+        (ckc.KUCUNSL- IFNULL((SELECT SUM(YUKOUSL) FROM t_center_ypkc_yk yk WHERE yk.YPML_ID = cmx.YPML_ID AND yk.YAOPINDM = cmx.YAOPINDM AND
+        yk.STORE_ID = ckc.STORE_ID),0)) AS centerKucunsl,
 
         (SELECT amm.MAT_ID FROM T_APP_MATERIAL_MAPPING amm WHERE amm.YAOPINDM_TY = chm.YAOPINDM_TY LIMIT 1) AS matId,
         (SELECT amm.MAT_NAME FROM T_APP_MATERIAL_MAPPING amm WHERE amm.YAOPINDM_TY = chm.YAOPINDM_TY LIMIT 1) AS matName
@@ -514,13 +518,16 @@
         <if test="hisYpdm != null and hisYpdm!='' ">
             AND hmx.GUIGEID = (SELECT GUIGEID FROM T_CENTER_HIS_YPMLMX WHERE YPML_ID = #{hisYpmlId} AND YAOPINDM = #{hisYpdm})
         </if>
-        ORDER BY CHAR_LENGTH(hmx.shuruma1), hmx.GUIGEID,hmx.shuruma1,ckc.LINGSHOUJIA,ckc.CHANDIID
+        ) t
+        where t.centerKucunsl > 0
+        ORDER BY CHAR_LENGTH(t.shuruma1), t.hisGgid, t.shuruma1, t.centerYpdj, t.cdidCenter
         <if test="@java.lang.Math@random() > 0.5 ">
             DESC
         </if>
     </select>
 
     <select id="transHisMat" parameterType="CenterHisMappingVO" resultType="CenterHisMappingVO">
+        select * from (
         SELECT
         chm.YAOPINDM_TY as yaopindmTy,
 
@@ -536,6 +543,7 @@
         hmx.DAILY_MAX_DOSE_EXT as dailyMaxDoseExt,
         hmx.PARENT_YPDM as parentYpdm,
         hmx.GUIGEID AS hisGgid,
+        hmx.shuruma1 AS shuruma1,
 
         cmx.YPML_ID as centerYpmlId,
         cmx.YAOPINDM as centerYpdm,
@@ -549,7 +557,8 @@
         ckc.CHANDIMC as centerYpcd,
         ckc.LINGSHOUJIA as centerYpdj,
         ckc.STORE_ID as centerStoreId,
-        (ckc.KUCUNSL- IFNULL((SELECT SUM(YUKOUSL) FROM t_center_ypkc_yk yk WHERE yk.YPML_ID = cmx.YPML_ID AND yk.YAOPINDM = cmx.YAOPINDM AND yk.STORE_ID = ckc.STORE_ID),0)) as centerKucunsl,
+        (ckc.KUCUNSL- IFNULL((SELECT SUM(YUKOUSL) FROM t_center_ypkc_yk yk WHERE yk.YPML_ID = cmx.YPML_ID AND yk.YAOPINDM = cmx.YAOPINDM AND
+        yk.STORE_ID = ckc.STORE_ID),0)) as centerKucunsl,
 
         (SELECT amm.MAT_ID FROM T_APP_MATERIAL_MAPPING amm WHERE amm.YAOPINDM_TY = chm.YAOPINDM_TY LIMIT 1) AS matId,
         (SELECT amm.MAT_NAME FROM T_APP_MATERIAL_MAPPING amm WHERE amm.YAOPINDM_TY = chm.YAOPINDM_TY LIMIT 1) AS matName
@@ -577,7 +586,9 @@
         <if test="hisYpdm != null and hisYpdm!='' ">
             and hmx.YAOPINDM = #{hisYpdm}
         </if>
-        ORDER BY CHAR_LENGTH(hmx.shuruma1), matId desc, hmx.shuruma1,ckc.LINGSHOUJIA
+        ) t
+        where t.centerKucunsl > 0
+        ORDER BY CHAR_LENGTH(t.shuruma1), matId desc, t.shuruma1, t.centerYpdj
     </select>
 
     <update id="delNotInCenterInv" parameterType="List">
@@ -669,41 +680,43 @@
 
 
     <select id="getPreparationMat" parameterType="CenterHisMappingVO" resultType="CenterHisMappingVO">
-        SELECT chm.YAOPINDM_TY     AS yaopindmTy,
-
-               hmx.YAOPINMC        AS showName,
-               hmx.shuruma1        AS shuruma1,
-               hmx.YPML_ID         AS hisYpmlId,
-               hmx.YAOPINDM        AS hisYpdm,
-               hmx.YAOPINMC        AS hisYpmc,
-               hmx.YAOPINGG        AS hisYpgg,
-               hmx.GUIGEID         AS hisGgid,
-               hmx.IS_INSURANCE    AS isInsurance,
-               hmx.NOT_PAY_ALONE   AS notPayAlone,
-               hmx.YICIJL          AS matDose,
-               hmx.YICIJLDW        AS matDoseunit,
-               hmx.YAOPINYF        AS 'usage',
-               hmx.FREQUENCY_ID    AS frequencyId,
-               hmx.FREQUENCY       AS frequency,
-               hmx.FREQUENCY_RATE  AS frequencyRate,
-               hmx.CONTENT         AS content,
-               hmx.EFFECT          AS effect,
-               hmx.USAGE_DESC      AS usageDesc,
-               hmx.APPROVAL_NUMBER AS approvalNumber,
-
-               cmx.YPML_ID         AS centerYpmlId,
-               cmx.YAOPINDM        AS centerYpdm,
-               cmx.YAOPINMC        AS centerYpmc,
-               cmx.YAOPINGG        AS centerYpgg,
-               cmx.BAOZHUANGDW     AS centerYpdw,
-               cmx.ZHONGYAOLX      AS centerYplx,
-               cmx.ZHUANHUANXS     AS zhuanhuanxs,
-
-               ckc.CHANDIID        AS cdidCenter,
-               ckc.CHANDIMC        AS centerYpcd,
-               ckc.LINGSHOUJIA     AS centerYpdj,
-               ckc.STORE_ID        AS centerStoreId,
-               (ckc.KUCUNSL- IFNULL((SELECT SUM(YUKOUSL) FROM t_center_ypkc_yk yk WHERE yk.YPML_ID = cmx.YPML_ID AND yk.YAOPINDM = cmx.YAOPINDM AND yk.STORE_ID = ckc.STORE_ID),0)) AS centerKucunsl
+        select * from (
+        SELECT chm.YAOPINDM_TY AS yaopindmTy,
+
+        hmx.YAOPINMC AS showName,
+        hmx.shuruma1 AS shuruma1,
+        hmx.YPML_ID AS hisYpmlId,
+        hmx.YAOPINDM AS hisYpdm,
+        hmx.YAOPINMC AS hisYpmc,
+        hmx.YAOPINGG AS hisYpgg,
+        hmx.GUIGEID AS hisGgid,
+        hmx.IS_INSURANCE AS isInsurance,
+        hmx.NOT_PAY_ALONE AS notPayAlone,
+        hmx.YICIJL AS matDose,
+        hmx.YICIJLDW AS matDoseunit,
+        hmx.YAOPINYF AS 'usage',
+        hmx.FREQUENCY_ID AS frequencyId,
+        hmx.FREQUENCY AS frequency,
+        hmx.FREQUENCY_RATE AS frequencyRate,
+        hmx.CONTENT AS content,
+        hmx.EFFECT AS effect,
+        hmx.USAGE_DESC AS usageDesc,
+        hmx.APPROVAL_NUMBER AS approvalNumber,
+
+        cmx.YPML_ID AS centerYpmlId,
+        cmx.YAOPINDM AS centerYpdm,
+        cmx.YAOPINMC AS centerYpmc,
+        cmx.YAOPINGG AS centerYpgg,
+        cmx.BAOZHUANGDW AS centerYpdw,
+        cmx.ZHONGYAOLX AS centerYplx,
+        cmx.ZHUANHUANXS AS zhuanhuanxs,
+
+        ckc.CHANDIID AS cdidCenter,
+        ckc.CHANDIMC AS centerYpcd,
+        ckc.LINGSHOUJIA AS centerYpdj,
+        ckc.STORE_ID AS centerStoreId,
+        (ckc.KUCUNSL- IFNULL((SELECT SUM(YUKOUSL) FROM t_center_ypkc_yk yk WHERE yk.YPML_ID = cmx.YPML_ID AND yk.YAOPINDM = cmx.YAOPINDM AND
+        yk.STORE_ID = ckc.STORE_ID),0)) AS centerKucunsl
 
         FROM T_CENTER_HIS_YPMLMX hmx
         JOIN T_CENTER_HIS_MAPPING chm ON chm.YPDM_HIS = hmx.YAOPINDM AND chm.YPML_ID_HIS = hmx.YPML_ID
@@ -723,7 +736,9 @@
         <if test="shuruma2 != null and shuruma2!='' ">
             and hmx.shuruma2 LIKE CONCAT('%', trim(#{shuruma2}), '%')
         </if>
-        ORDER BY CHAR_LENGTH(hmx.shuruma1), cmx.YAOPINGG, hmx.YAOPINMC, ckc.LINGSHOUJIA, ckc.CHANDIID
+        ) t
+        where t.centerKucunsl > 0
+        ORDER BY CHAR_LENGTH(t.shuruma1), t.centerYpgg, t.showName, t.centerYpdj, t.cdidCenter
     </select>