Bonus-Cloud-Material-Mall/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml

681 lines
34 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.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="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="person" column="person" />
<result property="personPhone" column="person_phone" />
<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" />
<result property="groupName" column="group_name" />
<result property="companyName" column="company_name" />
</resultMap>
<sql id="selectDevInfoVo">
select ma_id, device_name, device_weight, device_count, code, type_id, ma_status, lease_scope, location, province_id, city_id, area_id, brand, model_name, production_date, working_hours, serial_number,
pic_url, js_month_price, js_day_price, description, gps_code, own_co, create_time,
creator, update_time, person, person_phone, 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.ma_id as maId,
d.code as code,
d.device_name as deviceName,
d.device_weight as deviceWeight,
d.device_count as deviceCount,
d.type_id as typeId,
mt4.type_name as typeName,
mt4.unit_name as unitName,
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,
mt4.lease_price as dayLeasePrice,
d.person as person,
d.person_phone as personPhone,
d.create_time as createTime,
d.update_time as updateTime,
c.company_name as companyName,
c.operate_address as operateAddress,
mt3.type_id as thirdId,
mt3.type_name as thirdName,
mt2.type_id as secondId,
mt2.type_name as secondName,
mt1.type_id as firstId,
mt1.type_name as firstName
FROM
ma_dev_info d
LEFT JOIN bm_company_info c ON d.own_co = c.company_id
LEFT JOIN ma_type mt4 ON mt4.type_id = d.type_id and mt4.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0'
<where>
<if test="maId != null "> and d.ma_id = #{maId}</if>
<if test="code != null and code != ''"> and d.code = #{code}</if>
<if test="deviceName != null and deviceName != ''">
and d.device_name like concat('%',#{deviceName},'%')
</if>
<if test="typeId != null">
<choose>
<when test="level != null and level == 4">
and d.type_id = #{typeId}
</when>
<when test="level != null and level == 3">
and mt3.type_id = #{typeId}
</when>
<when test="level != null and level == 2">
and mt2.type_id = #{typeId}
</when>
<when test="level != null and level == 1">
and mt1.type_id = #{typeId}
</when>
</choose>
</if>
<if test="maStatus != null"> 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 ageMax != null">
and TIMESTAMPDIFF(YEAR, d.production_date, NOW()) &gt;= #{ageMin}
and TIMESTAMPDIFF(YEAR, d.production_date, NOW()) &lt;= #{ageMax}
</if>
<if test="ageMin == null and ageMax != null">
and TIMESTAMPDIFF(YEAR, d.production_date, NOW()) &gt;= #{ageMax}
</if>
<if test="workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != ''">
and d.working_hours &gt;= #{workingHoursMin} and d.working_hours &lt;= #{workingHoursMax}
</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="dayLeasePriceMin != null and dayLeasePriceMax != null">
and mt4.lease_price &gt;= #{dayLeasePriceMin} and mt4.lease_price &lt;= #{dayLeasePriceMax}
</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="companyId != null and companyId != ''"> and d.own_co = #{companyId}</if>
<if test="specification != null "> and d.specification = #{specification}</if>
<if test="deposit != null "> and d.deposit = #{deposit}</if>
<if test="startTime != null and endTime != null">
and d.update_time between #{startTime} and #{endTime}
</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.device_name) > 0
)
</if>
and d.is_active='1'
</where>
order by
d.is_active
<if test="dayLeasePriceOrderBy != null and dayLeasePriceOrderBy == 'ASC'">
,mt4.lease_price
</if>
<if test="dayLeasePriceOrderBy != null and dayLeasePriceOrderBy == 'DESC'">
,mt4.lease_price DESC
</if>
<if test="updateTimeOrderBy != null and updateTimeOrderBy == 'ASC'">
,d.create_time
</if>
<if test="updateTimeOrderBy != null and updateTimeOrderBy == 'DESC'">
,d.create_time DESC
</if>
</select>
<select id="selectDevInfoHotList" parameterType="com.bonus.material.device.domain.vo.DevInfoVo" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
SELECT
d.ma_id as maId,
d.code as code,
d.device_name as deviceName,
d.device_count as deviceCount,
d.device_weight as deviceWeight,
d.type_id as typeId,
mt4.type_name as typeName,
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,
mt4.lease_price as dayLeasePrice,
d.person as person,
d.person_phone as personPhone,
c.company_name as companyName,
c.company_id as companyId,
c.operate_address as operateAddress,
d.create_time as createTime,
mt3.type_id as thirdId,
mt3.type_name as thirdName,
mt2.type_id as secondId,
mt2.type_name as secondName,
mt1.type_id as firstId,
mt1.type_name as firstName
FROM
ma_dev_info d
LEFT JOIN bm_company_info c ON d.own_co = c.company_id
LEFT JOIN ma_type mt4 ON mt4.type_id = d.type_id and mt4.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0'
where
d.is_active='1'
and d.ma_status = '2'
<if test="deviceName != null and deviceName != ''">
and d.device_name like concat('%',#{deviceName},'%')
</if>
order by d.create_time desc
</select>
<select id="selectDevInfoByMaId" parameterType="Long" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
SELECT
d.ma_id as maId,
d.code as code,
d.device_name as deviceName,
d.device_weight as deviceWeight,
d.device_count as deviceCount,
d.type_id as typeId,
mt4.type_name as typeName,
mt4.unit_name as unitName,
mt4.manage_type as manageType,
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,
mt4.lease_price as dayLeasePrice,
d.person as person,
d.person_phone as personPhone,
c.company_id as companyId,
c.company_name as companyName,
mt3.type_id as thirdId,
mt3.type_name as thirdName,
mt2.type_id as secondId,
mt2.type_name as secondName,
mt1.type_id as firstId,
mt1.type_name as firstName,
GROUP_CONCAT(CONCAT(mt1.type_name, '/', mt2.type_name, '/', mt3.type_name)) AS groupName,
IFNULL(h.search_num, 0) as searchNum,
d.create_time as createTime,
d.update_time as updateTime
FROM
ma_dev_info d
LEFT JOIN bm_company_info c ON d.own_co = c.company_id
LEFT JOIN ma_hot_search h ON d.ma_id = h.ma_id
LEFT JOIN ma_type mt4 ON mt4.type_id = d.type_id and mt4.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0'
where
d.is_active='1' and d.ma_id = #{maId}
</select>
<select id="getFilesByMaId" parameterType="Long" resultType="com.bonus.common.biz.domain.SysFileInfo">
SELECT s.dic_id, s.file_name,s.file_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 (0,1,2,3)
</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="deviceName != null and deviceName != '' ">device_name,</if>
<if test="deviceWeight != null and deviceWeight != '' ">device_weight,</if>
<if test="deviceCount != null">device_count,</if>
<if test="code != null and code != '' ">code,</if>
<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="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="companyId != null">own_co,</if>
<if test="person != null and person != ''">person,</if>
<if test="personPhone != null and personPhone != ''">person_phone,</if>
create_time,
<if test="creator != null and creator != ''">creator,</if>
update_time,
<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="updateBy != null and updateBy != ''">update_by,</if>
<if test="ownId != null">own_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="deviceWeight != null and deviceWeight != ''">#{deviceWeight},</if>
<if test="deviceCount != null">#{deviceCount},</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="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="companyId != null">#{companyId},</if>
<if test="person != null and person != ''">#{person},</if>
<if test="personPhone != null and personPhone != ''">#{personPhone},</if>
now(),
<if test="creator != null and creator != ''">#{creator},</if>
now(),
<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="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="ownId != null">#{ownId},</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 and code != '' ">code = #{code},</if>
<if test="deviceName != null and deviceName != '' ">device_name = #{deviceName},</if>
<if test="deviceWeight != null">device_weight = #{deviceWeight},</if>
<if test="deviceCount != null">device_count = #{deviceCount},</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="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="companyId != null">own_co = #{companyId},</if>
<if test="person != null">person = #{person},</if>
<if test="personPhone != null">person_phone = #{personPhone},</if>
<if test="specification != null">specification = #{specification},</if>
<if test="deposit != null">deposit = #{deposit},</if>
<if test="isOperator != null">is_active = #{isOperator},</if>
update_time = now()
</trim>
where ma_id = #{maId}
</update>
<update id="deleteDevInfoByMaId" >
update ma_dev_info set is_active = '0'
where ma_id = #{maId,jdbcType=BIGINT} and is_active = '1' and ma_status != #{statusCode,jdbcType=INTEGER}
</update>
<update id="deleteDevInfoByMaIds" parameterType="String">
update ma_dev_info set is_active='0' where ma_id in
<foreach item="maId" collection="maIds" open="(" separator="," close=")">
#{maId}
</foreach>
</update>
<select id="selectUserCollectByUserId" parameterType="Long" resultType="com.bonus.common.biz.domain.UserCollect">
select id, user_id, ma_id, create_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>
<select id="getDeviceNameCount" resultType="Integer">
select ma_id from ma_dev_info
where device_name = #{deviceName,jdbcType=VARCHAR} and is_active = '1'
</select>
<insert id="insertHotSearch">
INSERT INTO ma_hot_search (ma_id, search_num, create_time)
VALUES (#{maId}, 1, now())
</insert>
<update id="updateHotSearchByMaId" parameterType="Long">
update ma_hot_search
set search_num = search_num + 1,
update_time = now()
where ma_id = #{maId}
</update>
<update id="updateUpDown">
<if test="maIds != null and maIds.size() > 0">
<choose>
<when test="maIds.size() == 1">
<!-- 单个ID更新 -->
update ma_dev_info
set ma_status = #{maStatus}
where ma_id = #{maIds[0]}
</when>
<otherwise>
<!-- 批量更新 -->
update ma_dev_info
set ma_status = #{maStatus}
where ma_id in
<foreach collection="maIds" item="maId" open="(" separator="," close=")">
#{maId}
</foreach>
</otherwise>
</choose>
</if>
</update>
<update id="upMaStatus">
update ma_dev_info set ma_status = #{maStatus} where ma_id = #{maId} and is_active = 1
</update>
<select id="getSysDic" resultType="com.bonus.common.biz.domain.SysDic">
select
dict_code AS id,p_id,code,`name`,description,`value`,sort,`level`,status,create_time,creator
from sys_dict_data
</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_dict_data
where id = #{id}
</select>
<select id="getBaseAddress" resultType="com.bonus.common.biz.domain.BaseAddress">
select id,name,code from base_address
</select>
<select id="getBaseAddressById" resultType="String">
select name from base_address where id = #{id}
</select>
<select id="selectDevInfoLists" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
select
d.*,c.company_name as companyName,c.operate_address as operateAddress,
mt4.type_name as typeName,mt4.unit_name as unitName,
mt3.type_id as thirdId,mt3.type_name as thirdName,
mt2.type_id as secondId,mt2.type_name as secondName,
mt1.type_id as firstId,mt1.type_name as firstName
from
ma_dev_info d
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
left join ma_type mt4 ON mt4.type_id = d.type_id and mt4.del_flag = '0'
left join ma_type mt3 ON mt3.type_id = mt4.parent_id and mt3.del_flag = '0'
left join ma_type mt2 ON mt2.type_id = mt3.parent_id and mt2.del_flag = '0'
left join ma_type mt1 ON mt1.type_id = mt2.parent_id and mt1.del_flag = '0'
<where>
<if test="maId != null "> and d.ma_id = #{maId}</if>
<if test="code != null and code != ''"> and d.code = #{code}</if>
<if test="deviceName != null and deviceName != ''">
and d.device_name like concat('%',#{deviceName},'%')
</if>
<if test="typeId != null">
and d.type_id = #{typeId}
</if>
<if test="maStatus != null"> and d.ma_status = #{maStatus}</if>
<if test="leaseScope != null "> and d.lease_scope = #{leaseScope}</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="companyId != null "> and d.own_co = #{companyId}</if>
<if test="startTime != null and endTime != null">
and d.update_time between #{startTime} and #{endTime}
</if>
<if test="keyWord != null and keyWord != ''">
and (
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.own_id = #{ownId}
and d.is_active = '1'
</where>
ORDER BY d.create_time desc
</select>
<select id="selectCompanyList" resultType="com.bonus.common.biz.domain.BmCompanyInfo">
SELECT
sd.dept_id as companyId,
sd.dept_name as companyName,
b.operate_address as operateAddress
FROM
sys_dept sd
LEFT JOIN bm_company_info b ON sd.dept_id = b.company_id
WHERE sd.parent_id = 0 and sd.order_num != 0
<if test="companyId != null">
and sd.dept_id = #{companyId}
</if>
<if test="companyName != null and companyName != ''">
and sd.dept_name like concat('%',#{companyName},'%')
</if>
</select>
<select id="getBookCar" resultType="com.bonus.material.book.domain.BookCarInfoDto">
SELECT
ma_id as maId,
order_user as orderUser,
order_company as orderCompany
FROM
book_car_detail
WHERE
order_user = #{userId}
AND ma_id = #{maId}
AND order_status = '0'
</select>
<insert id="insertDraft" parameterType="com.bonus.material.device.domain.DevInfo" useGeneratedKeys="true" keyProperty="maId">
insert into ma_dev_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != '' ">device_name,</if>
<if test="deviceWeight != null and deviceWeight != '' ">device_weight,</if>
<if test="deviceCount != null">device_count,</if>
<if test="code != null and code != '' ">code,</if>
<if test="typeId != null and typeId != ''">type_id,</if>
<if test="maStatus != null">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="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="companyId != null">own_co,</if>
<if test="person != null and person != ''">person,</if>
<if test="personPhone != null and personPhone != ''">person_phone,</if>
create_time,
<if test="creator != null and creator != ''">creator,</if>
update_time,
<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>
is_active,
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="ownId != null and ownId != ''">own_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="deviceWeight != null and deviceWeight != ''">#{deviceWeight},</if>
<if test="deviceCount != null">#{deviceCount},</if>
<if test="code != null and code != ''">#{code},</if>
<if test="typeId != null and typeId != ''">#{typeId},</if>
<if test="maStatus != null">#{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="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="companyId != null">#{companyId},</if>
<if test="person != null and person != ''">#{person},</if>
<if test="personPhone != null and personPhone != ''">#{personPhone},</if>
now(),
<if test="creator != null and creator != ''">#{creator},</if>
now(),
<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>
1,
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="ownId != null and ownId != ''">#{ownId},</if>
</trim>
</insert>
<select id="getMaStatusByMaId" resultType="java.lang.Integer">
select ma_status from ma_dev_info where ma_id = #{maId}
</select>
<select id="selectCompany" resultType="java.lang.Integer">
select COUNT(1) from ma_dev_info where ma_status = '2' and own_co = #{companyId}
</select>
<select id="getLeaseList" resultType="com.bonus.material.device.domain.vo.LeaseVo">
SELECT
m.order_id as orderId,
m.ma_id as maId,
m1.`code` as orderCode,
su.nick_name as leaseName,
m.rent_begin_time as leaseStartTime,
m.rent_end_time as leaseEndTime,
m.costs as leasePrice
FROM
ma_order_details m
LEFT JOIN ma_order_info m1 ON m.order_id = m1.order_id
LEFT JOIN sys_user su ON m1.buyer_id = su.user_id
WHERE
m.ma_id = #{maId}
</select>
<select id="getCompanyUpNum" resultType="java.lang.Integer">
SELECT
IFNULL(SUM( h.search_num ), 0) AS companyVisitNum
FROM
ma_hot_search h
LEFT JOIN ma_dev_info m ON h.ma_id = m.ma_id
AND m.is_active = '1'
WHERE
m.ma_status = '2'
AND m.own_co = #{companyId}
</select>
<select id="selectTaskNumByMonth" resultType="java.lang.String">
SELECT SUBSTRING(code, - 4) as code
FROM ma_dev_info
WHERE DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
ORDER BY create_time DESC LIMIT 1
</select>
<select id="selectCompanyById" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
select
company_id as companyId,
company_name as companyName,
create_time as companyCreateTime
from bm_company_info
where company_id = #{companyId}
</select>
</mapper>