<?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.BasicUdiRelMapper" >
<select id= "filterList" parameterType= "com.glxp.api.req.basic.FilterUdiRelRequest"
resultType="com.glxp.api.res.basic.BasicUdiRelResponse">
select bur.*,
uc.companyName,
nameCode,
packRatio,
packLevel,
bhxjsl,
bhzxxsbzsl,
zxxsbzbhsydysl,
bhxjcpbm,
sjcpbm,
bzcj,
thirdProductNo,
thirdProductName,
addType,
deviceRecordKey,
isUseDy,
cpmctymc,
cplb,
flbm,
ggxh,
qxlb,
tyshxydm,
ylqxzcrbarmc,
zczbhhzbapzbh,
ylqxzcrbarywmc,
sydycpbs,
versionNumber,
diType,
scbssfbhph,
scbssfbhxlh,
scbssfbhscrq,
scbssfbhsxrq,
ybbm,
spmc,
cphhhbh,
cpms,
cpbsbmtxmc,
cplx,
hchzsb,
sfwblztlcp,
cgzmraqxgxx,
sfbjwycxsy,
zdcfsycs,
sfwwjbz,
syqsfxyjxmj,
qtxxdwzlj,
mjfs,
p.measname,
p.manufactory
FROM basic_udi_rel bur
left JOIN basic_udi_product p on bur.uuid = p.uuid
left join user_company uc on bur.companyIdFk = uc.id
<where >
<if test= "companyIdFk != '' and companyIdFk != null" >
AND companyIdFk=#{companyIdFk}
</if>
<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= "companyIdFk != '' and companyIdFk != null" >
AND bur.companyIdFk = #{companyIdFk}
</if>
<if test= "ggxh != '' and ggxh != null" >
AND ggxh = #{ggxh}
</if>
<if test= "uuid != '' and uuid != null" >
AND bur.uuid = #{uuid}
</if>
<if test= "id != '' and id != null" >
AND bur.id = #{id}
</if>
<if test= "diType != null" >
AND diType = #{diType}
</if>
<if test= "zczbhhzbapzbh != '' and zczbhhzbapzbh != null" >
AND zczbhhzbapzbh LIKE concat(#{zczbhhzbapzbh}, '%')
</if>
<if test= "lastUpdateTime != null and lastUpdateTime != ''" >
< ![CDATA[
and DATE_FORMAT(bur.updateTime, '%Y-%m-%d %H:%i:%S') >=
DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
<if test= "unionCode != '' and unionCode != null" >
AND nameCode LIKE concat(#{unionCode}, '%')
</if>
<if test= "unionFilterStr != '' and unionFilterStr != null" >
or p.cpmctymc LIKE concat('%', #{unionFilterStr}, '%')
or p.ylqxzcrbarmc LIKE concat('%', #{unionFilterStr}, '%')
or p.ggxh LIKE concat('%', #{unionFilterStr}, '%')
or p.zczbhhzbapzbh LIKE concat('%', #{unionFilterStr}, '%')
</if>
<if test= "unionCode != '' and unionCode != null" >
AND nameCode = #{unionCode}
</if>
</where>
ORDER BY bur.updateTime DESC
</select>
<select id= "filterBasicList" parameterType= "com.glxp.api.req.basic.FilterUdiRelRequest"
resultType="com.glxp.api.res.basic.BasicUdiRelResponse">
select bur.*,sm.*,sc.*,
uc.companyName,
nameCode,
packRatio,
packLevel,
bhxjsl,
bhzxxsbzsl,
zxxsbzbhsydysl,
bhxjcpbm,
sjcpbm,
bzcj,
thirdProductNo,
thirdProductName,
addType,
deviceRecordKey,
isUseDy,
cpmctymc,
cplb,
flbm,
ggxh,
qxlb,
tyshxydm,
ylqxzcrbarmc,
zczbhhzbapzbh,
ylqxzcrbarywmc,
sydycpbs,
versionNumber,
diType,
scbssfbhph,
scbssfbhxlh,
scbssfbhscrq,
scbssfbhsxrq,
ybbm,
spmc,
cphhhbh,
cpms,
cpbsbmtxmc,
cplx,
hchzsb,
sfwblztlcp,
cgzmraqxgxx,
sfbjwycxsy,
zdcfsycs,
sfwwjbz,
syqsfxyjxmj,
qtxxdwzlj,
mjfs,
p.measname,
p.manufactory
FROM basic_udi_rel bur
left JOIN basic_udi_product p on bur.uuid = p.uuid
left join user_company uc on bur.companyIdFk = uc.id
left join sup_manufacturer sm on uc.id=sm.manufacturerId
left join sup_company sc on sm.customerId=sc.customerId
<where >
<if test= "companyIdFk != '' and companyIdFk != null" >
AND bur.companyIdFk = #{companyIdFk}
</if>
<if test= "burId != '' and burId != null" >
AND bur.id = #{burId}
</if>
</where>
ORDER BY bur.updateTime DESC
</select>
<select id= "filterCompanyList" parameterType= "com.glxp.api.req.basic.FilterUdiRelRequest"
resultType="com.glxp.api.res.basic.BasicUdiRelResponse">
SELECT sup_manufacturer.* ,user_company.companyName as supName
<if test= "productStatus!=null" >
,(SELECT count(*) FROM sup_product WHERE sup_manufacturer.customerId=sup_product.customerId AND sup_product.auditStatus!=0 AND sup_product.auditStatus!=1 AND sup_product.auditStatus!=4 AND sup_manufacturer.manufacturerId=sup_product.manufacturerIdFk ) as failCout,
(SELECT count(*) FROM sup_product WHERE sup_manufacturer.customerId=sup_product.customerId AND (sup_product.auditStatus=1 OR sup_product.auditStatus=4) AND sup_manufacturer.manufacturerId=sup_product.manufacturerIdFk ) as passCout
</if>
FROM sup_manufacturer
inner join user_company on sup_manufacturer.customerId = user_company.customerId
<where >
<if test= "id != null and id != '' and type==null" >
and id = #{id}
</if>
<if test= "manufacturerId != null and manufacturerId != ''" >
and manufacturerId = #{manufacturerId}
</if>
<if test= "companyName != null and companyName != ''" >
and sup_manufacturer.companyName like concat('%',#{companyName},'%')
</if>
<if test= "creditCode != null and creditCode != ''" >
and creditCode like concat('%',#{creditCode},'%')
</if>
<if test= "placeArea != null and placeArea != ''" >
and placeArea like concat('%',#{placeArea},'%')
</if>
<if test= "customerId != null and customerId != ''" >
and sup_manufacturer.customerId = #{customerId}
</if>
<if test= "auditStatus != null and auditStatus !=20 and auditStatus !=21 and auditStatus !=22" >
and sup_manufacturer.auditStatus = #{auditStatus}
</if>
<if test= "auditStatus ==20" >
and (sup_manufacturer.auditStatus = 0 or sup_manufacturer.auditStatus=5 or
sup_manufacturer.auditStatus=2)
</if>
<if test= "auditStatus ==21" >
and <![CDATA[ sup_manufacturer.auditStatus <> 0 ]]>
</if>
<if test= "auditStatus ==22" >
and (sup_manufacturer.auditStatus = 1 or sup_manufacturer.auditStatus=4 )
</if>
<if test= "lastUpdateTime!=null and lastUpdateTime!=''" >
<![CDATA[ and DATE_FORMAT(sup_manufacturer.updateTime, '%Y-%m-%d %H:%i:%S')>= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S') ]]>
</if>
<if test= "type != null" >
and id != #{id}
</if>
</where>
</select>
<select id= "findByNameCode" parameterType= "java.lang.String"
resultType="com.glxp.api.res.sup.UserCompanyResponse">
select user_company.*, basic_udi_rel.companyType
from basic_udi_rel
INNER JOIN basic_udi_product on basic_udi_rel.uuid = basic_udi_product.uuid
INNER JOIN user_company on basic_udi_rel.companyIdFk = user_company.id
where basic_udi_product.nameCode = #{nameCode}
</select>
<select id= "findByProduct"
resultType="com.glxp.api.entity.sup.UserCompanyEntity">
select user_company.*
from basic_udi_rel
INNER JOIN basic_udi_product on basic_udi_rel.uuid = basic_udi_product.uuid
INNER JOIN user_company on basic_udi_rel.companyIdFk = user_company.id
where basic_udi_product.ylqxzcrbarmc = #{ylqxzcrbarmc}
and basic_udi_product.cpmctymc = #{cpmctymc}
and basic_udi_product.ggxh = #{ggxh}
limit 1
</select>
<select id= "findDiList" parameterType= "java.lang.String"
resultType="java.lang.String">
select nameCode
from basic_udi_product
where uuid = #{uuid}
</select>
<select id= "findDiListByProduct"
resultType="java.lang.String">
select nameCode
from basic_udi_product
where basic_udi_product.ylqxzcrbarmc = #{ylqxzcrbarmc}
and basic_udi_product.cpmctymc = #{cpmctymc}
and basic_udi_product.ggxh = #{ggxh}
</select>
</mapper>