Browse Source

1.完成知识库映射

zjh 2 years ago
parent
commit
227369d1be

BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/beans/drug/BMaterial.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/beans/drug/BStandardMat.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/beans/drug/TDrugList.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/beans/drug/TKnowMaterialMappingVo.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/beans/drug/TMaterialKnowMapping.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/beans/drug/TMaterialKnowVO.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/controller/drug/BMaterialController.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/controller/drug/TDrugListController.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/mapper/drug/TAppMaterialMappingMapper.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/service/drug/BMaterialService.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/service/drug/TAppMaterialMappingService.java


BIN
cbkj_web_parameter/src/main/java/com/jiuzhekan/cbkj/service/drug/TStandardMaterialMappingService.java


+ 57 - 0
cbkj_web_parameter/src/main/resources/mappers/drug/TAppMaterialMappingMapper.xml

@@ -41,6 +41,23 @@
         </foreach>
     </insert>
 
+    <insert id="insertautoMapping" parameterType="StandTMAutoMappingVO">
+        INSERT INTO t_app_material_mapping
+        SELECT rand_string(32),
+               m.k_mat_id,
+               m.k_mat_name,
+               tm2.drug_id,
+               tmp.mat_price_id,
+               NOW(),
+               #{createUser},
+               #{createUserName}
+        FROM t_material_price tmp
+                 JOIN t_material AS tm2 ON ( tm2.status = '1' AND tm2.is_del='0' AND tm2.mat_id = tmp.mat_id )
+                 LEFT JOIN b_material m ON m.k_mat_name = substring_index(substring_index(substring_index(substring_index(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(REPLACE(tm2.mat_name,'【配送】',''),'5',''),'1',''),'*',''),'d',''),'K',''),'G',''),'P',''),'Z',''),'配方颗粒',''),'颗粒',''),'(',1),'(',1),'[',1),'&lt;',1)
+                 LEFT JOIN t_app_material_mapping p ON p.mat_price_id = tmp.mat_price_id
+        WHERE tm2.is_del = '0' and tm2.drug_id = #{drugId} AND p.mat_price_id IS NULL AND m.k_mat_id IS NOT NULL
+    </insert>
+
     <update id="updateByPrimaryKey" parameterType="TAppMaterialMapping">
         update t_app_material_mapping
         <set>
@@ -83,5 +100,45 @@
             </if>
         </where>
     </select>
+    <resultMap id="BaseResultMap2" type="TMaterialKnowVO">
+        <id column="matId" jdbcType="VARCHAR"  property="matId" />
+
+    </resultMap>
+    <select id="getDataPage" parameterType="com.jiuzhekan.cbkj.beans.drug.TMaterialKnowVO" resultMap="BaseResultMap2">
+        SELECT
+            tm2.mat_id matId,
+            tm2.mat_name matName,
+            tm2.mat_standard matStandard,
+            tamm.id as mapId,
+            tmp.mat_price_id as matPriceId,
+        tdl.drug_id as drugId,
+        bm.k_mat_id as kMatId,
+        bm.k_mat_name as kMatName
+        FROM
+            t_material_price AS tmp
+                JOIN t_material AS tm2 ON ( tm2.status = '1' AND tm2.is_del='0' AND tm2.mat_id = tmp.mat_id )
+                JOIN t_drug_list AS tdl ON (tm2.drug_id = tdl.drug_id )
+                LEFT JOIN t_app_material_mapping AS tamm ON(tamm.drug_id = tm2.drug_id AND tamm.mat_price_id = tmp.mat_price_id )
+                LEFT JOIN b_material AS bm ON(bm.k_mat_id=tamm.k_mat_id )
+                LEFT JOIN t_pharmacy AS tp ON(tdl.drug_id = tp.drug_id)
+        where tmp.status='1'
+        <if test=" isMapping == 1">
+            and bm.k_mat_id is not null
+        </if>
+        <if test=" isMapping == 2">
+            and bm.k_mat_id is null
+        </if>
+        <if test=" phaType != null and phaType !=''">
+            and tp.pha_type =#{phaType}
+        </if>
+        <if test=" keyWord != null and keyWord !=''">
+            and (tm2.mat_name like CONCAT('%',trim(#{keyWord}),'%') or tm2.mat_standard like CONCAT('%',trim(#{keyWord}),'%') )
+        </if>
+        GROUP BY tmp.mat_id
+    </select>
+    <select id="selectCountData" resultType="java.lang.Long" parameterType="TMaterialKnowVO">
+        select count(*) from t_app_material_mapping
+where mat_price_id = #{matPriceId}
+    </select>
 
 </mapper>

+ 5 - 4
cbkj_web_parameter/src/main/resources/mappers/drug/TStandardMaterialMappingMapper.xml

@@ -100,13 +100,13 @@
         tsmm.id as mapId,
         tsmm.drug_id as drugId
         FROM
-        t_pharmacy AS tp
-        JOIN t_drug_list AS tdl ON(tdl.drug_id = tp.drug_id)
-        JOIN t_material AS tm2 ON (tm2.drug_id = tdl.drug_id AND tm2.status = '1' )
+        t_drug_list AS tdl
+        LEFT JOIN t_pharmacy AS tp ON(tdl.drug_id = tp.drug_id and tp.status = '1')
+        JOIN t_material AS tm2 ON (tm2.drug_id = tdl.drug_id AND tm2.status = '1' and tm2.is_del='0')
         LEFT JOIN t_standard_material_mapping AS tsmm ON(tsmm.drug_id = tm2.drug_id AND tsmm.mat_id = tm2.mat_id AND tsmm.s_mat_type='2')
         LEFT JOIN b_standard_mat AS bsm ON(bsm.s_id=tsmm.s_id AND bsm.s_mat_type='2')
         <where>
-            tp.status = '1'
+            tdl.status='1'
             <if test=" isMapping == 1">
                  and bsm.s_id is not null
             </if>
@@ -119,6 +119,7 @@
             <if test=" keyWord != null and keyWord !=''">
                 and (tm2.mat_name like CONCAT('%',trim(#{keyWord}),'%') or tm2.mat_standard like CONCAT('%',trim(#{keyWord}),'%') )
             </if>
+group by tm2.mat_id
         </where>
     </select>