|
@@ -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),'<',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>
|