select distinct mam.ID,matt.ID as tyoeId0,matt.`NAME` as typeName,mat.ID as tyoeId,mat.`NAME` as type,mav.ID as verderId,mav.`NAME` as venderName,
mam.OUT_FAC_TIME as outFactortTime,mam.DEVICE_CODE as deviceCode,mam.OUT_FAC_NUM as outFactortNum,ROUND(mat.BUY_PRICE) as buyPrice,mam.PIC_URL as picUrl,
mam.IS_FIXED_ASSETS as isFixedAssets,mat.LEASE_PRICE as leasePrice,ROUND(mat.PAY_PRICE) as payPrice, mam.ASSETS_NUM as assetNum,mam.CYCLE_NUM as outInNum,
mam.REMARK as remarks,mam.PROPERTY_DEPARTMENT as propertyDepartment,mam.USE_DEPARTMENT as useDepartment,mam.SERVICE_LIFE as serviceLife,
mam.BATCH_STATUS as batchStatus,mam.GPS_CODE as gpsCode,mam.MAKE_ORDER_DATE as makeOrderDate,mam.INVOICE_DATE as invoiceDate,mam.QRCODE as qrcode
,org.NAME companyName,mam.ORIGIN_NUM originNum,rel.ORG_ID orgId ,mam.GPS_CODE gisCode,mam.DEVICE_TYPE as deviceType
from mm_machines mam
LEFT JOIN ma_status mas on mam.BATCH_STATUS = mas.BATCH_STATUS
LEFT JOIN mm_type mat on mam.TYPE = mat.ID
LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID
LEFT JOIN mm_vender mav on mav.ID = mam.VENDER_ID
LEFT JOIN ma_org_relation rel on rel.TYPE_ID=mat.ID
LEFT JOIN pm_organization org on org.ID=rel.ORG_ID
where 1=1 and mam.DEVICE_CODE is not null and mam.DEVICE_TYPE=1
<iftest='param.orgId !=null and param.orgId!="" and param.orgId !="1" '>
and rel.ORG_ID=#{param.orgId}
</if>
<iftest="param.batchStatus != 0">
and mas.MA_STATUS = #{param.batchStatus}
</if>
<iftest="param.typeName != null and param.typeName != ''">
and matt.`NAME` = #{param.typeName}
</if>
<iftest="param.type != null and param.type != ''">
and mat.`NAME` = #{param.type}
</if>
<iftest="param.keyWord !=null and param.keyWord !=''">
and (
matt.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
mam.DEVICE_CODE LIKE CONCAT('%',#{param.keyWord},'%') OR
mat.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
mam.QRCODE LIKE CONCAT('%',#{param.keyWord},'%') OR
mam.BATCH_STATUS LIKE CONCAT('%',#{param.keyWord},'%') OR
select distinct mam.ID,matt.ID as tyoeId0,matt.`NAME` as typeName,mat.ID as tyoeId,mat.`NAME` as type,mav.ID as verderId,mav.`NAME` as venderName,
mam.OUT_FAC_TIME as outFactortTime,mam.DEVICE_CODE as deviceCode,mam.OUT_FAC_NUM as outFactortNum,ROUND(mat.BUY_PRICE) as buyPrice,mam.PIC_URL as picUrl,
mam.IS_FIXED_ASSETS as isFixedAssets,mat.LEASE_PRICE as leasePrice,ROUND(mat.PAY_PRICE) as payPrice, mam.ASSETS_NUM as assetNum,mam.CYCLE_NUM as outInNum,
mam.REMARK as remarks,mam.PROPERTY_DEPARTMENT as propertyDepartment,mam.USE_DEPARTMENT as useDepartment,mam.SERVICE_LIFE as serviceLife,
mam.BATCH_STATUS as batchStatus,mam.GPS_CODE as gpsCode,mam.MAKE_ORDER_DATE as makeOrderDate,mam.INVOICE_DATE as invoiceDate,mam.QRCODE as qrcode
,org.NAME companyName,mam.ORIGIN_NUM originNum,rel.ORG_ID orgId ,mam.GPS_CODE gisCode,mam.DEVICE_TYPE as deviceType,u.NAME as userName,gb.BINDING_TIME as bindingTime,
if(mam.GPS_CODE is null,"未绑定","已绑定") as bindStatus
from mm_machines mam
LEFT JOIN ma_status mas on mam.BATCH_STATUS = mas.BATCH_STATUS
LEFT JOIN mm_type mat on mam.TYPE = mat.ID
LEFT JOIN mm_type matt on matt.ID = mat.PARENT_ID
LEFT JOIN mm_vender mav on mav.ID = mam.VENDER_ID
LEFT JOIN ma_org_relation rel on rel.TYPE_ID=mat.ID
LEFT JOIN pm_organization org on org.ID=rel.ORG_ID
LEFT JOIN gps_binding gb ON gb.MA_ID=mam.id
LEFT JOIN pm_user u ON u.id=gb.USER_ID
where 1=1 and mam.DEVICE_CODE is not null and mam.DEVICE_TYPE=2
<iftest='param.orgId !=null and param.orgId!="" and param.orgId !="1" '>
and rel.ORG_ID=#{param.orgId}
</if>
<iftest="param.batchStatus != 0">
and mas.MA_STATUS = #{param.batchStatus}
</if>
<iftest="param.bindStatus == 1">
and mam.GPS_CODE is not null
</if>
<iftest="param.bindStatus == 2">
and mam.GPS_CODE is null
</if>
<iftest="param.keyWord !=null and param.keyWord !=''">
and (
matt.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
mam.DEVICE_CODE LIKE CONCAT('%',#{param.keyWord},'%') OR
mat.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') OR
mam.QRCODE LIKE CONCAT('%',#{param.keyWord},'%') OR
mam.BATCH_STATUS LIKE CONCAT('%',#{param.keyWord},'%') OR
mav.`NAME` LIKE CONCAT('%',#{param.keyWord},'%') or