2024-11-22 10:16:54 +08:00
<?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.bonus.material.device.mapper.DevInfoMapper" >
<resultMap type= "com.bonus.material.device.domain.vo.DevInfoVo" id= "DevInfoResult" >
<result property= "maId" column= "ma_id" />
<result property= "code" column= "code" />
<result property= "typeId" column= "type_id" />
<result property= "maStatus" column= "ma_status" />
<result property= "leaseScope" column= "lease_scope" />
<result property= "location" column= "location" />
<result property= "provinceId" column= "province_id" />
<result property= "cityId" column= "city_id" />
<result property= "areaId" column= "area_id" />
<result property= "brand" column= "brand" />
<result property= "modelName" column= "model_name" />
<result property= "productionDate" column= "production_date" />
<result property= "workingHours" column= "working_hours" />
<result property= "serialNumber" column= "serial_number" />
<result property= "monthLeasePrice" column= "month_lease_price" />
<result property= "dayLeasePrice" column= "day_lease_price" />
<result property= "picUrl" column= "pic_url" />
<result property= "jsMonthPrice" column= "js_month_price" />
<result property= "jsDayPrice" column= "js_day_price" />
<result property= "description" column= "description" />
<result property= "gpsCode" column= "gps_code" />
<result property= "ownCo" column= "own_co" />
<result property= "createTime" column= "create_time" />
<result property= "creator" column= "creator" />
<result property= "updateTime" column= "update_time" />
<result property= "updateBy" column= "update_by" />
<result property= "specification" column= "specification" />
<result property= "deposit" column= "deposit" />
<result property= "isOperator" column= "is_operator" />
<result property= "isActive" column= "is_active" />
<result property= "deviceName" column= "device_name" />
2024-11-23 11:40:06 +08:00
<result property= "deviceWeight" column= "device_weight" />
2024-11-22 10:16:54 +08:00
<result property= "groupName" column= "group_name" />
<result property= "companyName" column= "company_name" />
</resultMap>
<sql id= "selectDevInfoVo" >
select ma_id, code, type_id, ma_status, lease_scope, location, province_id, city_id, area_id, brand, model_name, production_date, working_hours, serial_number,
month_lease_price, day_lease_price, pic_url, js_month_price, js_day_price, description, gps_code, own_co, create_time,
creator, update_time, update_by, specification, deposit, is_operator, is_active, update_time, update_by from ma_dev_info
</sql>
<select id= "selectDevInfoList" parameterType= "com.bonus.material.device.domain.vo.DevInfoVo" resultType= "com.bonus.material.device.domain.vo.DevInfoVo" >
select d.*,mt1.type_name as device_name, mt2.type_name as group_name, mt3.type_name as type_name,c.company_name
from ma_dev_info d
2024-11-23 11:40:06 +08:00
left join ma_type mt1 on d.type_id = mt1.type_id
left join ma_type mt2 on mt1.parent_id = mt2.type_id
left join ma_type mt3 on mt2.parent_id = mt3.type_id
2024-11-22 10:16:54 +08:00
left join bm_company_info c on d.own_co = c.company_id
<where >
<if test= "maId != null " > and d.ma_id = #{maId}</if>
<if test= "code != null and code != ''" > and d.code = #{code}</if>
<if test= "typeId != null" >
<if test= "level != null and level == 2" >
and t.parent_id = #{typeId}
</if>
<if test= "level != null and level == 3" >
and d.type_id = #{typeId}
</if>
</if>
<if test= "maStatus != null and maStatus != ''" > and d.ma_status = #{maStatus}</if>
<if test= "leaseScope != null " > and d.lease_scope = #{leaseScope}</if>
<if test= "location != null and location != ''" > and d.location = #{location}</if>
<if test= "provinceId != null and provinceId != ''" > and d.province_id = #{provinceId}</if>
<if test= "cityId != null and cityId != ''" > and d.city_id = #{cityId}</if>
<if test= "areaId != null and areaId != ''" > and d.area_id = #{areaId}</if>
<if test= "brand != null and brand != ''" > and d.brand = #{brand}</if>
<if test= "modelName != null and modelName != ''" > and d.model_name like concat('%', #{modelName}, '%')</if>
<if test= "ageMin != null and ageMin != '' and ageMax != null and ageMax != ''" >
and DATEDIFF(DATE_FORMAT(now(), '%Y-%m-%d'), d.production_date) > = #{ageMin} * 365
and DATEDIFF(DATE_FORMAT(now(), '%Y-%m-%d'), d.production_date) < = #{ageMax} * 365
</if>
<if test= "workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != ''" >
and d.working_hours > = #{workingHoursMin} and d.working_hours < = #{workingHoursMax}
</if>
<if test= "serialNumber != null and serialNumber != ''" > and d.serial_number = #{serialNumber}</if>
<if test= "monthLeasePriceMin != null and monthLeasePriceMax != null" >
and d.month_lease_price > = #{monthLeasePriceMin} and d.month_lease_price < = #{monthLeasePriceMax}
</if>
<if test= "dayLeasePrice != null and dayLeasePrice != ''" > and d.day_lease_price = #{dayLeasePrice}</if>
<if test= "picUrl != null and picUrl != ''" > and d.pic_url = #{picUrl}</if>
<if test= "jsMonthPrice != null and jsMonthPrice != ''" > and d.js_month_price = #{jsMonthPrice}</if>
<if test= "jsDayPrice != null and jsDayPrice != ''" > and d.js_day_price = #{jsDayPrice}</if>
<if test= "description != null and description != ''" > and d.description = #{description}</if>
<if test= "gpsCode != null and gpsCode != ''" > and d.gps_code = #{gpsCode}</if>
<if test= "ownCo != null " > and d.own_co = #{ownCo}</if>
<if test= "creator != null " > and d.creator = #{creator}</if>
<if test= "updateBy != null " > and d.update_by = #{updateBy}</if>
<if test= "specification != null " > and d.specification = #{specification}</if>
<if test= "deposit != null " > and d.deposit = #{deposit}</if>
<if test= "isActive != null and isActive != ''" > and d.is_active = #{isActive}</if>
<if test= "keyWord != null and keyWord != ''" >
and (
locate(#{keyWord},mt1.type_name) > 0
or locate(#{keyWord},mt2.type_name) > 0
or locate(#{keyWord},mt3.type_name) > 0
or locate(#{keyWord},c.company_name) > 0
or locate(#{keyWord},d.ma_id) > 0
or locate(#{keyWord},d.model_name) > 0
or locate(#{keyWord},d.specification) > 0
or locate(#{keyWord},d.serial_number) > 0
or locate(#{keyWord},d.description) > 0
)
</if>
and d.is_active='1'
</where>
order by
d.is_active
<if test= "monthLeasePriceOrderBy != null and monthLeasePriceOrderBy == 'ASC'" >
,d.month_lease_price
</if>
<if test= "monthLeasePriceOrderBy != null and monthLeasePriceOrderBy == 'DESC'" >
,d.month_lease_price DESC
</if>
<if test= "updateTimeOrderBy != null and updateTimeOrderBy == 'ASC'" >
,d.update_time
</if>
<if test= "updateTimeOrderBy != null and updateTimeOrderBy == 'DESC'" >
,d.update_time DESC
</if>
</select>
<select id= "selectDevInfoHotList" parameterType= "com.bonus.material.device.domain.vo.DevInfoVo" resultType= "com.bonus.material.device.domain.vo.DevInfoVo" >
2024-11-22 17:41:13 +08:00
SELECT
d.ma_id as maId,
d.code as code,
d.device_name as deviceName,
d.device_weight as deviceWeight,
d.type_id as typeId,
d.ma_status as maStatus,
d.brand as brand,
d.model_name as modelName,
d.production_date as productionDate,
d.working_hours as workingHours,
d.serial_number as serialNumber,
d.month_lease_price as monthLeasePrice,
d.day_lease_price as dayLeasePrice,
d.person as person,
d.person_phone as personPhone,
c.company_name as companyName,
2024-11-23 11:42:53 +08:00
h.search_num as searchNum,
d.create_time as createTime
2024-11-22 17:41:13 +08:00
FROM
2024-11-23 11:42:53 +08:00
ma_dev_info d
LEFT JOIN ma_hot_search h ON d.ma_id = h.ma_id
2024-11-22 17:41:13 +08:00
LEFT JOIN bm_company_info c ON d.own_co = c.company_id
where
2024-11-22 10:16:54 +08:00
d.is_active='1'
2024-11-22 17:41:13 +08:00
and d.ma_status = '2'
2024-11-23 11:42:53 +08:00
order by d.create_time desc
2024-11-22 10:16:54 +08:00
</select>
<select id= "selectDevInfoByMaId" parameterType= "Long" resultType= "com.bonus.material.device.domain.vo.DevInfoVo" >
select d.*,c.company_name,c.create_time as company_create_time,c.logo_url as company_logo_url,
c.auth_phone, mt1.type_name as device_name,
mt2.type_name as group_name, mt3.type_name as type_name,
col.id as collect_id, h.search_num
from ma_dev_info d
left join bm_company_info c on d.own_co = c.company_id
left join ma_user_collect col on d.ma_id = col.ma_id
left join ma_hot_search h on d.ma_id = h.ma_id
2024-11-23 11:40:06 +08:00
left join ma_type t on d.type_id = t.type_id
left join ma_type mt1 on d.type_id = mt1.type_id
left join ma_type mt2 on mt1.parent_id = mt2.type_id
left join ma_type mt3 on mt2.parent_id = mt3.type_id
2024-11-22 10:16:54 +08:00
where d.ma_id = #{maId} and d.is_active='1'
2024-11-23 11:42:53 +08:00
SELECT
d.ma_id as maId,
d.code as code,
d.device_name as deviceName,
d.device_weight as deviceWeight,
d.type_id as typeId,
d.ma_status as maStatus,
d.brand as brand,
d.model_name as modelName,
d.production_date as productionDate,
d.working_hours as workingHours,
d.serial_number as serialNumber,
d.month_lease_price as monthLeasePrice,
d.day_lease_price as dayLeasePrice,
d.person as person,
d.person_phone as personPhone,
c.company_name as companyName,
h.search_num as searchNum
FROM
ma_dev_info d
LEFT JOIN ma_hot_search h ON d.ma_id = h.ma_id
LEFT JOIN bm_company_info c ON d.own_co = c.company_id
where
d.is_active='1' and d.ma_id = #{maId}
>>>>>>> origin/master
2024-11-22 10:16:54 +08:00
</select>
<select id= "getFilesByMaId" parameterType= "Long" resultType= "com.bonus.common.biz.domain.SysFile" >
SELECT s.dic_id, s.file_name as name,s.file_url as url
from ma_dev_info d
left join sys_file_info s on d.ma_id = s.model_id
WHERE d.ma_id = #{maId} and d.is_active='1' and s.dic_id in (20,28,29)
</select>
<select id= "getCompanyUpNum" parameterType= "Long" resultType= "Long" >
select count(d.ma_id) from ma_dev_info d
where d.own_co= #{ownCo} and d.ma_status in(16,17) and d.is_active='1'
GROUP BY d.own_co
</select>
<insert id= "insertDevInfo" parameterType= "com.bonus.material.device.domain.DevInfo" useGeneratedKeys= "true" keyProperty= "maId" >
insert into ma_dev_info
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "maId != null and maId != '' " > ma_id,</if>
<if test= "code != null and code != '' " > code,</if>
2024-11-23 11:40:06 +08:00
<if test= "deviceName != null and deviceName != '' " > device_name,</if>
<if test= "deviceWeight != null and deviceWeight != '' " > device_weight,</if>
2024-11-22 10:16:54 +08:00
<if test= "typeId != null and typeId != ''" > type_id,</if>
<if test= "maStatus != null and maStatus != ''" > ma_status,</if>
<if test= "leaseScope != null and leaseScope != ''" > lease_scope,</if>
<if test= "location != null and location != ''" > location,</if>
<if test= "provinceId != null and provinceId != ''" > province_id,</if>
<if test= "cityId != null and cityId != ''" > city_id,</if>
<if test= "areaId != null and areaId != ''" > area_id,</if>
<if test= "brand != null and brand != ''" > brand,</if>
<if test= "modelName != null and modelName != ''" > model_name,</if>
<if test= "productionDate != null and productionDate != ''" > production_date,</if>
<if test= "workingHours != null and workingHours != ''" > working_hours,</if>
<if test= "serialNumber != null and serialNumber != ''" > serial_number,</if>
<if test= "monthLeasePrice != null and monthLeasePrice != ''" > month_lease_price,</if>
<if test= "dayLeasePrice != null and dayLeasePrice != ''" > day_lease_price,</if>
<if test= "picUrl != null and picUrl != ''" > pic_url,</if>
<if test= "jsMonthPrice != null and jsMonthPrice != ''" > js_month_price,</if>
<if test= "jsDayPrice != null and jsDayPrice != ''" > js_day_price,</if>
<if test= "description != null and description != ''" > description,</if>
<if test= "gpsCode != null and gpsCode != ''" > gps_code,</if>
<if test= "ownCo != null and ownCo != ''" > own_co,</if>
<if test= "createTime != null and createTime != ''" > create_time,</if>
<if test= "creator != null and creator != ''" > creator,</if>
<if test= "updateTime != null and updateTime != ''" > update_time,</if>
<if test= "updateBy != null and updateBy != ''" > update_by,</if>
<if test= "specification != null and specification != ''" > specification,</if>
<if test= "deposit != null and deposit != ''" > deposit,</if>
<if test= "isOperator != null and isOperator != ''" > is_operator,</if>
<if test= "isActive != null and isActive != ''" > is_active,</if>
<if test= "updateTime != null and updateTime != ''" > update_time,</if>
<if test= "updateBy != null and updateBy != ''" > update_by,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "maId != null and maId != ''" > #{maId},</if>
<if test= "code != null and code != ''" > #{code},</if>
<if test= "typeId != null and typeId != ''" > #{typeId},</if>
<if test= "maStatus != null and maStatus != ''" > #{maStatus},</if>
<if test= "leaseScope != null and leaseScope != ''" > #{leaseScope},</if>
<if test= "location != null and location != ''" > #{location},</if>
<if test= "provinceId != null and provinceId != ''" > #{provinceId},</if>
<if test= "cityId != null and cityId != ''" > #{cityId},</if>
<if test= "areaId != null and areaId != ''" > #{areaId},</if>
<if test= "brand != null and brand != ''" > #{brand},</if>
<if test= "modelName != null and modelName != ''" > #{modelName},</if>
<if test= "productionDate != null and productionDate != ''" > #{productionDate},</if>
<if test= "workingHours != null and workingHours != ''" > #{workingHours},</if>
<if test= "serialNumber != null and serialNumber != ''" > #{serialNumber},</if>
<if test= "monthLeasePrice != null and monthLeasePrice != ''" > #{monthLeasePrice},</if>
<if test= "dayLeasePrice != null and dayLeasePrice != ''" > #{dayLeasePrice},</if>
<if test= "picUrl != null and picUrl != ''" > #{picUrl},</if>
<if test= "jsMonthPrice != null and jsMonthPrice != ''" > #{jsMonthPrice},</if>
<if test= "jsDayPrice != null and jsDayPrice != ''" > #{jsDayPrice},</if>
<if test= "description != null and description != ''" > #{description},</if>
<if test= "gpsCode != null and gpsCode != ''" > #{gpsCode},</if>
<if test= "ownCo != null and ownCo != ''" > #{ownCo},</if>
<if test= "createTime != null and createTime != ''" > #{createTime},</if>
<if test= "creator != null and creator != ''" > #{creator},</if>
<if test= "updateTime != null and updateTime != ''" > #{update_time},</if>
<if test= "updateBy != null and updateBy != ''" > #{update_by},</if>
<if test= "specification != null and specification != ''" > #{specification},</if>
<if test= "deposit != null and deposit != ''" > #{deposit},</if>
<if test= "isOperator != null and isOperator != ''" > #{isOperator},</if>
<if test= "isActive != null and isActive != ''" > #{isActive},</if>
<if test= "updateTime != null and updateTime != ''" > #{updateTime},</if>
<if test= "updateBy != null and updateBy != ''" > #{updateBy},</if>
</trim>
</insert>
<insert id= "insertLon" >
insert into gps_real_info
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "dto.gpsCode != null and dto.gpsCode != ''" > gps_code,</if>
<if test= "dto.lon != null and dto.lon !=''" > lon,</if>
<if test= "dto.lat != null and dto.lat != ''" > lat,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "dto.gpsCode != null and dto.gpsCode != ''" > #{dto.gpsCode},</if>
<if test= "dto.lon != null and dto.lon !=''" > #{dto.lon},</if>
<if test= "dto.lat != null and dto.lat != ''" > #{dto.lat},</if>
</trim>
</insert>
<update id= "updateDevInfo" parameterType= "com.bonus.material.device.domain.DevInfo" >
update ma_dev_info
<trim prefix= "SET" suffixOverrides= "," >
<if test= "code != null" > code = #{code},</if>
<if test= "typeId != null" > type_id = #{typeId},</if>
<if test= "maStatus != null" > ma_status = #{maStatus},</if>
<if test= "leaseScope != null" > lease_scope = #{leaseScope},</if>
<if test= "location != null" > location = #{location},</if>
<if test= "provinceId != null" > province_id = #{provinceId},</if>
<if test= "cityId != null" > city_id = #{cityId},</if>
<if test= "areaId != null" > area_id = #{areaId},</if>
<if test= "brand != null" > brand = #{brand},</if>
<if test= "modelName != null" > model_name = #{modelName},</if>
<if test= "productionDate != null" > production_date = #{productionDate},</if>
<if test= "workingHours != null" > working_hours = #{workingHours},</if>
<if test= "serialNumber != null" > serial_number = #{serialNumber},</if>
<if test= "monthLeasePrice != null" > month_lease_price = #{monthLeasePrice},</if>
<if test= "dayLeasePrice != null" > day_lease_price = #{dayLeasePrice},</if>
<if test= "picUrl != null" > pic_url = #{picUrl},</if>
<if test= "jsMonthPrice != null" > js_month_price = #{jsMonthPrice},</if>
<if test= "jsDayPrice != null" > js_day_price = #{jsDayPrice},</if>
<if test= "description != null" > description = #{description},</if>
<if test= "gpsCode != null" > gps_code = #{gpsCode},</if>
<if test= "ownCo != null" > own_co = #{ownCo},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "creator != null" > creator = #{creator},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "specification != null" > specification = #{specification},</if>
<if test= "deposit != null" > deposit = #{deposit},</if>
<if test= "isOperator != null" > is_active = #{isOperator},</if>
<if test= "isActive != null" > is_active = #{isActive},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
</trim>
where ma_id = #{maId}
</update>
<update id= "deleteDevInfoByMaId" parameterType= "Long" >
update ma_dev_info set is_active='0' where ma_id = #{maId}
</update>
<update id= "deleteDevInfoByMaIds" parameterType= "String" >
update ma_dev_info set is_active='0' where ma_id in
<foreach item= "maId" collection= "array" open= "(" separator= "," close= ")" >
#{maId}
</foreach>
</update>
2024-11-22 11:12:06 +08:00
<select id= "selectUserCollectByUserId" parameterType= "Long" resultType= "com.bonus.common.biz.domain.UserCollect" >
2024-11-22 10:16:54 +08:00
select id, user_id, ma_id, time from ma_user_collect
where user_id = #{userId}
</select>
<select id= "getHotSearchCountByMaId" resultType= "Integer" >
select count(1) from ma_hot_search
where ma_id = #{maId}
</select>
<insert id= "insertHotSearch" >
INSERT INTO ma_hot_search (ma_id, search_num)
VALUES (#{maId}, 1)
</insert>
<update id= "updateHotSearchByMaId" parameterType= "Long" >
update ma_hot_search
set search_num = search_num + 1
where ma_id = #{maId}
</update>
<select id= "getSysDic" resultType= "com.bonus.common.biz.domain.SysDic" >
select
id,p_id,code,`name`,description,`value`,sort,`level`,status,create_time,creator
from sys_dic
</select>
<select id= "getSysDicById" resultType= "com.bonus.common.biz.domain.SysDic" >
select
id,p_id,code,`name`,description,`value`,sort,`level`,status,create_time,creator
from sys_dic
where id = #{id}
</select>
2024-11-22 11:12:06 +08:00
<select id= "getBaseAddress" resultType= "com.bonus.common.biz.domain.BaseAddress" >
select id,name,code from base_address where status = 1
</select>
2024-11-22 10:16:54 +08:00
<select id= "getBaseAddressById" resultType= "String" >
select name from base_address where status = 1 and id = #{id}
</select>
<select id= "selectDevInfoLists" resultType= "com.bonus.material.device.domain.vo.DevInfoVo" >
select d.*,t.type_name as device_name,t.parent_name as group_name,c.company_name,u.type as type,t.group_name as type_name,t.p_id as group_id,t.group_id as company_id
from ma_dev_info d
left join (select t.*, p.type_name as parent_name, p.type_id as p_id,mt.type_name as group_name, mt.type_id as group_id
2024-11-23 11:40:06 +08:00
from ma_type t
left join ma_type p on t.parent_id=p.type_id
left join ma_type mt on p.parent_id = mt.type_id
2024-11-22 10:16:54 +08:00
) t on d.type_id = t.type_id
left join bm_company_info c on d.own_co = c.company_id
left join ma_up_off u on d.ma_id = u.ma_id ORDER BY d.create_time desc
</select>
</mapper>