|
@@ -82,14 +82,76 @@
|
|
|
from t_standard_material_mapping where id = #{id}
|
|
|
</select>
|
|
|
|
|
|
- <select id="getPageListByObj" parameterType="TStandardMaterialMapping" resultMap="BaseResultMap">
|
|
|
- SELECT id,s_id,s_mat_name,s_mat_code,s_mat_type,drug_id,mat_id,create_date,create_user,create_user_name
|
|
|
+ <select id="getPageListByObj" parameterType="TMaterialStandVO" resultType="TMaterialStandVO">
|
|
|
+ SELECT
|
|
|
+ tm2.mat_id matId,
|
|
|
+ tm2.mat_name matName,
|
|
|
+ tm2.mat_standard matStandard,
|
|
|
+ bsm.s_mat_code sMatCode,
|
|
|
+ bsm.s_mat_name sMatName,
|
|
|
+ bsm.s_id sId,
|
|
|
+ bsm.s_mat_type as sMatType,
|
|
|
+ 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' )
|
|
|
+ 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'
|
|
|
+ <if test=" isMapping == 1">
|
|
|
+ and bsm.s_id is not null
|
|
|
+ </if>
|
|
|
+ <if test=" isMapping == 2">
|
|
|
+ and bsm.s_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>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getCountByObj" resultType="java.lang.Long">
|
|
|
+ select count(*)
|
|
|
from t_standard_material_mapping
|
|
|
<where>
|
|
|
- <if test=" name != null and name!='' ">
|
|
|
- and name like CONCAT('%',trim(#{name}),'%')
|
|
|
+ <if test=" sId != null and sId !=''">
|
|
|
+ s_id = #{sId}
|
|
|
+ </if>
|
|
|
+ <if test=" sMatCode != null and sMatCode !=''">
|
|
|
+ s_mat_code = #{sMatCode}
|
|
|
+ </if>
|
|
|
+ <if test=" drugId != null and drugId !=''">
|
|
|
+ drug_id = #{drugId}
|
|
|
+ </if>
|
|
|
+ <if test=" matId != null and matId !=''">
|
|
|
+ mat_id = #{matId}
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
+ <insert id="insertautoMapping" parameterType="StandTMAutoMappingVO">
|
|
|
+
|
|
|
+ INSERT INTO t_standard_material_mapping
|
|
|
+ SELECT rand_string(32),
|
|
|
+ m.s_id,
|
|
|
+ m.s_mat_name,
|
|
|
+ m.s_mat_code,
|
|
|
+ m.s_mat_type,
|
|
|
+ mx.drug_id,
|
|
|
+ mx.mat_id,
|
|
|
+ NOW(),
|
|
|
+ #{createUser},
|
|
|
+ #{createUserName}
|
|
|
+ FROM t_material mx
|
|
|
+ LEFT JOIN b_standard_mat m ON m.s_mat_name = substring_index(substring_index(substring_index(substring_index(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(REPLACE(mx.mat_name,'【配送】',''),'5',''),'1',''),'*',''),'d',''),'K',''),'G',''),'P',''),'Z',''),'配方颗粒',''),'颗粒',''),'(',1),'(',1),'[',1),'<',1)
|
|
|
+ LEFT JOIN t_standard_material_mapping p ON p.mat_id = mx.mat_id
|
|
|
+ WHERE mx.is_del = '0' and mx.drug_id = #{drugId} AND p.mat_id IS NULL AND m.s_id IS NOT NULL
|
|
|
+
|
|
|
+ </insert>
|
|
|
|
|
|
</mapper>
|