You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-java/src/main/resources/mybatis/mapper/basic/UdiRlSupDao.xml

374 lines
14 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.basic.UdiRlSupDao">
<select id="filterCompanyProductRelevance"
parameterType="com.glxp.api.req.basic.FilterCompanyProductRelevanceRequest"
resultType="com.glxp.api.entity.basic.UdiRlSupEntity">
select *
from company_product_relevance
<where>
<if test="customerId != '' and customerId != null">
and customerId = #{customerId}
</if>
<if test="udiRlIdFk != '' and udiRlIdFk != null">
and udiRlIdFk = #{udiRlIdFk}
</if>
<if test="unitFk != null and unitFk != ''">
and unitFk = #{unitFk}
</if>
<if test="lastUpdateTime != null and lastUpdateTime != ''">
<![CDATA[
and DATE_FORMAT(updateTime, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
</where>
ORDER BY id DESC
</select>
<select id="filterUdiGp" parameterType="com.glxp.api.req.basic.CompanyProductRelevanceRequest"
resultType="com.glxp.api.res.basic.UdiRlSupResponse">
select company_product_relevance.id,
company_product_relevance.customerId,
company_product_relevance.auditStatus,
company_product_relevance.price,
basic_udirel.uuid,
basic_udirel.thirdId,
basic_udirel.id rlId,
basic_udirel.isUseDy,
basic_udirel.useMuti,
basic_udirel.isLock,
basic_udirel.thirdId1,
basic_udirel.thirdId2,
basic_udirel.thirdId3,
basic_udirel.thirdId4,
basic_udirel.lockStatus,
basic_udirel.mainId,
basic_udirel.isAdavence,
basic_udirel.lowStockNum,
basic_udirel.overStockNum,
basic_udirel.recentDateTime,
basic_udirel.isDateBy,
bht.name classifyName,
basic_products.id as PRId,
basic_products.originUuid,
basic_products.nameCode,
basic_products.deviceRecordKey,
basic_products.packRatio,
basic_products.packUnit,
basic_products.packLevel,
basic_products.bhxjsl,
basic_products.bhzxxsbzsl,
basic_products.zxxsbzbhsydysl,
basic_products.bhxjcpbm,
basic_products.bzcj,
basic_products.cpmctymc,
basic_products.cplb,
basic_products.flbm,
basic_products.ggxh,
basic_products.qxlb,
basic_products.tyshxydm,
basic_products.ylqxzcrbarmc,
basic_products.zczbhhzbapzbh,
basic_products.ylqxzcrbarywmc,
basic_products.sydycpbs,
basic_products.sjcpbm,
basic_products.versionNumber,
basic_products.diType,
basic_products.ybbm,
basic_products.sptm,
basic_products.manufactory,
basic_products.measname,
basic_products.productType,
basic_products.scbssfbhph,
basic_products.scbssfbhxlh,
basic_products.scbssfbhscrq,
basic_products.scbssfbhsxrq,
basic_products.cpms,
basic_products.allowNoBatch,
basic_products.allowNoExpire,
basic_products.allowNoProduct,
basic_products.allowNoSerial,
basic_products.spmc,
basic_products.cplx,
basic_products.hchzsb,
basic_products.cpdls,
basic_products.basicPrductRemak1,
basic_products.basicPrductRemak2,
basic_products.basicPrductRemak3,
basic_products.basicPrductRemak4,
basic_products.basicPrductRemak5,
basic_products.basicPrductRemak6,
basic_products.basicPrductRemak7,
basic_products.basicPrductRemak8,
basic_corp.name companyName
FROM company_product_relevance
inner JOIN basic_udirel
ON company_product_relevance.udiRlIdFk = basic_udirel.id
inner JOIN basic_products
ON basic_udirel.uuid = basic_products.uuid
left JOIN basic_corp on basic_corp.erpId = company_product_relevance.customerId
left join basic_hosp_type bht on basic_udirel.relCode = bht.code
left join thr_products tp on tp.code = basic_udirel.mainId
<where>
<if test="ylqxzcrbarmc != '' and ylqxzcrbarmc != null">
AND ylqxzcrbarmc LIKE concat(#{ylqxzcrbarmc}, '%')
</if>
<if test="cpmctymc != '' and cpmctymc != null">
AND cpmctymc LIKE concat(#{cpmctymc}, '%')
</if>
<if test="nameCode != '' and nameCode != null">
AND nameCode LIKE concat(#{nameCode}, '%')
</if>
<if test="ggxh != '' and ggxh != null">
AND ggxh LIKE concat('%', #{ggxh}, '%')
</if>
<if test="unionCode != '' and unionCode != null">
and (
nameCode LIKE concat('%', #{unionCode}, '%')
or basic_products.ybbm LIKE concat('%', #{unionCode}, '%')
or basic_products.sptm LIKE concat('%', #{unionCode}, '%')
)
</if>
<if test="thrPiId != '' and thrPiId != null">
and (
basic_udirel.thirdId LIKE concat('%', #{thrPiId}, '%')
or basic_udirel.thirdId1 LIKE concat('%', #{thrPiId}, '%')
or basic_udirel.thirdId2 LIKE concat('%', #{thrPiId}, '%')
or basic_udirel.thirdId3 LIKE concat('%', #{thrPiId}, '%')
or basic_udirel.thirdId4 LIKE concat('%', #{thrPiId}, '%')
)
</if>
<if test="uuid != '' and uuid != null">
AND basic_udirel.uuid = #{uuid}
</if>
<if test="thirdId != '' and thirdId != null">
AND basic_udirel.thirdId = #{thirdId}
</if>
<if test="zczbhhzbapzbh != '' and zczbhhzbapzbh != null">
AND zczbhhzbapzbh LIKE concat(#{zczbhhzbapzbh}, '%')
</if>
<if test="diType != '' and diType != null">
AND diType = #{diType}
</if>
<if test="filterType != null and filterType == 1">
AND (basic_udirel.thirdId <![CDATA[<>]]> '' or basic_udirel.thirdId1 <![CDATA[<>]]> '' or
basic_udirel.thirdId2 <![CDATA[<>]]> '' or
basic_udirel.thirdId3 <![CDATA[<>]]> '' or basic_udirel.thirdId4 <![CDATA[<>]]> '')
and basic_products.originUuid <![CDATA[<>]]> ''
</if>
<if test="filterType != null and filterType == 2">
AND basic_products.originUuid is NULL
</if>
<if test="filterType != null and filterType == 3">
AND (basic_udirel.thirdId IS NULL or basic_udirel.thirdId='')
and basic_products.originUuid <![CDATA[<>]]> ''
</if>
<if test="filterType != null and filterType == 4">
AND basic_udirel.thirdId1 is NULL
and basic_products.originUuid <![CDATA[<>]]> ''
</if>
<if test="filterType != null and filterType == 5">
AND basic_udirel.thirdId2 is NULL
and basic_products.originUuid <![CDATA[<>]]> ''
</if>
<if test="filterType != null and filterType == 6">
AND basic_udirel.thirdId3 is NULL
and basic_products.originUuid <![CDATA[<>]]> ''
</if>
<if test="filterType != null and filterType == 7">
AND basic_udirel.thirdId4 is NULL
and basic_products.originUuid <![CDATA[<>]]> ''
</if>
<if test="filterType != null and filterType == 10">
AND basic_udirel.updateTime is NULL
</if>
<if test="pinyinInitial != null and pinyinInitial != ''">
AND basic_products.pinyinInitial like concat('%', #{pinyinInitial}, '%')
</if>
<if test="code != '' and code != null">
AND basic_udirel.mainId = #{code}
</if>
<if test="customerId != '' and customerId != null">
AND company_product_relevance.customerId = #{customerId}
</if>
<if test="auditStatus != '' and auditStatus != null">
AND company_product_relevance.auditStatus = #{auditStatus}
</if>
<if test="id != '' and id != null">
AND basic_udirel.id = #{id}
</if>
<if test="companyName != '' and companyName != null">
AND basic_corp.name like concat('%', #{companyName}, '%')
</if>
<if test="lockStatus != '' and lockStatus != null">
AND basic_udirel.lockStatus = #{lockStatus}
</if>
<if test="isAdavence != '' and isAdavence != null">
AND basic_udirel.isAdavence = #{isAdavence}
</if>
<if test="unitFk != null and unitFk != ''">
and unitFk = #{unitFk}
</if>
<if test="isDisable == false">
AND (basic_udirel.isDisable is null or basic_udirel.isDisable = false)
</if>
</where>
ORDER BY company_product_relevance.updateTime DESC
</select>
<select id="findCompanyProductRelevance" parameterType="java.lang.Long"
resultType="com.glxp.api.entity.basic.UdiRlSupEntity">
SELECT *
FROM company_product_relevance
where customerId = #{customerId}
</select>
<select id="findCompanyProductRelevanceByProductId" parameterType="java.lang.String"
resultType="com.glxp.api.entity.basic.UdiRlSupEntity">
SELECT *
FROM company_product_relevance
where productId = #{productId}
</select>
<select id="findCompanyProductRelevanceByUdiRlIdFk" parameterType="java.lang.String"
resultType="com.glxp.api.entity.basic.UdiRlSupEntity">
SELECT *
FROM company_product_relevance
where udiRlIdFk = #{udiRlIdFk}
and customerId = #{customerId}
</select>
<select id="findCompanyProductRelevanceByProductUuid"
parameterType="com.glxp.api.entity.basic.UdiRlSupEntity"
resultType="com.glxp.api.entity.basic.UdiRlSupEntity">
SELECT *
FROM company_product_relevance
<where>
<if test="customerId != null and customerId != ''">
and customerId = #{customerId}
</if>
<if test="productId != null and productId != ''">
and productId = #{productId}
</if>
<if test="productUuid != null and productUuid != ''">
and productUuid = #{productUuid}
</if>
<if test="unitFk != null and unitFk != ''">
and unitFk = #{unitFk}
</if>
</where>
</select>
<select id="getCompanyProductRelevance"
parameterType="com.glxp.api.req.basic.FilterCompanyProductRelevanceRequest"
resultType="com.glxp.api.entity.basic.UdiRlSupEntity">
SELECT *
FROM company_product_relevance
<where>
<if test="customerId != null and customerId != ''">
and customerId = #{customerId}
</if>
<if test="productId != null and productId != ''">
and productId = #{productId}
</if>
<if test="productUuid != null and productUuid != ''">
and productUuid = #{productUuid}
</if>
<if test="unitFk != null and unitFk != ''">
and unitFk = #{unitFk}
</if>
</where>
</select>
<insert id="insertCompanyProductRelevance"
parameterType="com.glxp.api.entity.basic.UdiRlSupEntity">
replace
INTO company_product_relevance(id,customerId, productId, enterpriseId, registrationId,
createTime, updateTime, auditStatus, productUuid, udiRlIdFk, unitFk,
price, createUser, updateUser)
values (#{id},#{customerId},
#{productId},
#{enterpriseId},
#{registrationId},
#{createTime},
#{updateTime},
#{auditStatus},
#{productUuid},
#{udiRlIdFk},
#{unitFk},
#{price},
#{createUser},
#{updateUser})
</insert>
<insert id="importCompanyProductRelevance"
parameterType="com.glxp.api.entity.basic.UdiRlSupEntity">
replace
INTO company_product_relevance(id, customerId, productId, enterpriseId, registrationId,
createTime, updateTime, auditStatus, productUuid, udiRlIdFk, unitFk,
price, createUser, updateUser)
values (#{id},
#{customerId},
#{productId},
#{enterpriseId},
#{registrationId},
#{createTime},
#{updateTime},
#{auditStatus},
#{productUuid},
#{udiRlIdFk},
#{unitFk},
#{price},
#{createUser},
#{updateUser})
</insert>
<delete id="deleteById" parameterType="Map">
DELETE
FROM company_product_relevance
WHERE id = #{id}
</delete>
<delete id="deleteByRlId" parameterType="Map">
DELETE
FROM company_product_relevance
WHERE udiRlIdFk = #{id}
</delete>
<select id="selectUnitFkByUdiRlIdFk" resultType="java.lang.String">
select unitFk
from company_product_relevance
where udiRlIdFk = #{udiRlIdFk}
</select>
<select id="selectUnitFkByRelId" resultType="java.lang.String">
select unitFk
from company_product_relevance
where udiRlIdFk = #{relId}
</select>
<select id="selectSupRlCount" resultType="java.lang.Long">
select count(*)
FROM company_product_relevance
inner JOIN basic_udirel
ON company_product_relevance.udiRlIdFk = basic_udirel.id
inner JOIN basic_products ON basic_udirel.uuid = basic_products.uuid
<where>
<if test="nameCode != '' and nameCode != null">
AND nameCode LIKE concat(#{nameCode}, '%')
</if>
<if test="unitFk != null and unitFk != ''">
and unitFk = #{unitFk}
</if>
</where>
</select>
</mapper>