bug修改

This commit is contained in:
GUO 2024-05-28 22:43:56 +08:00
parent f6b3cb7946
commit ad1d9076e1

View File

@ -1,23 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhgd.xmgl.modules.car.mapper.CarInfoMapper"> <mapper namespace="com.zhgd.xmgl.modules.car.mapper.CarInfoMapper">
<sql id="selectTable">
SELECT if(t.car_module_type = 1 or t.car_module_type = 2, wi.id_card,
t.outside_driver_id_card) as outsideDriverIdCard,
if(t.car_module_type = 1 or t.car_module_type = 2, wi.worker_name,
t.driver_worker_name) as driverWorkerName,
t.*,
b.car_type_name,
ei.enterprise_name
FROM car_info t
LEFT JOIN car_type b ON (t.car_type = b.id and t.project_sn = b.project_sn)
left join enterprise_info ei on ei.id = t.enterprise_id
left join worker_info wi
on t.driver_worker_id = wi.id and (t.car_module_type = 1 or t.car_module_type = 2)
left join (SELECT * FROM worker_info GROUP BY id_card) wi1
on wi1.id_card = t.outside_driver_id_card and t.car_module_type = 3
</sql>
<sql id="all"> <sql id="all">
SELECT <include refid="com.zhgd.xmgl.modules.car.mapper.CarInfoMapper.selectTable">
if(t.car_module_type=1 or t.car_module_type=2,wi.id_card,t.outside_driver_id_card) as outsideDriverIdCard, </include>
if(t.car_module_type=1 or t.car_module_type=2,wi.worker_name,t.driver_worker_name) as driverWorkerName, WHERE t.project_sn = #{param.projectSn}
t.*,
b.car_type_name,
ei.enterprise_name
FROM car_info t LEFT JOIN car_type b ON (t.car_type=b.id and t.project_sn=b.project_sn)
left join enterprise_info ei on ei.id=t.enterprise_id
left join worker_info wi on t.driver_worker_id = wi.id and (t.car_module_type=1 or t.car_module_type=2)
left join (SELECT * FROM worker_info GROUP BY id_card) wi1 on wi1.id_card=t.outside_driver_id_card and t.car_module_type=3
WHERE t.project_sn=#{param.projectSn}
<if test="param.carNumber != null and param.carNumber != ''"> <if test="param.carNumber != null and param.carNumber != ''">
and t.car_number like CONCAT(CONCAT('%',#{param.carNumber}),'%') and t.car_number like CONCAT(CONCAT('%', #{param.carNumber}), '%')
</if> </if>
<if test="param.isBlack != null and param.isBlack != ''"> <if test="param.isBlack != null and param.isBlack != ''">
and t.is_black=#{param.isBlack} and t.is_black = #{param.isBlack}
</if> </if>
<if test="param.carModuleType != null and param.carModuleType != '' and param.carModuleType != '4'.toString()"> <if test="param.carModuleType != null and param.carModuleType != '' and param.carModuleType != '4'.toString()">
and t.car_module_type = #{param.carModuleType} and t.car_module_type = #{param.carModuleType}
@ -41,11 +49,13 @@
</include> </include>
</select> </select>
<select id="selectCarTypeCount" resultType="java.util.Map"> <select id="selectCarTypeCount" resultType="java.util.Map">
SELECT b.car_type_name carTypeName,COUNT(1) carTypeNum, SELECT b.car_type_name carTypeName,
IFNULL(SUM((CASE WHEN a.is_black=1 THEN 1 ELSE 0 END)),0) blackNum, COUNT(1) carTypeNum,
IFNULL(SUM((CASE WHEN a.is_black=0 THEN 1 ELSE 0 END)),0) whiteNum IFNULL(SUM((CASE WHEN a.is_black = 1 THEN 1 ELSE 0 END)), 0) blackNum,
FROM car_info a INNER JOIN car_type b ON (a.car_type=b.id and a.project_sn=b.project_sn) IFNULL(SUM((CASE WHEN a.is_black = 0 THEN 1 ELSE 0 END)), 0) whiteNum
WHERE a.project_sn=#{projectSn} FROM car_info a
INNER JOIN car_type b ON (a.car_type = b.id and a.project_sn = b.project_sn)
WHERE a.project_sn = #{projectSn}
group by a.car_type group by a.car_type
</select> </select>
@ -53,30 +63,20 @@
select ct.car_type_name select ct.car_type_name
from car_info ci from car_info ci
inner join car_type ct on ci.car_type = ct.id inner join car_type ct on ci.car_type = ct.id
where ci.id=#{id} where ci.id = #{id}
</select> </select>
<select id="countCarModuleType" resultType="com.zhgd.xmgl.modules.car.entity.vo.CountCarModuleTypeVo"> <select id="countCarModuleType" resultType="com.zhgd.xmgl.modules.car.entity.vo.CountCarModuleTypeVo">
select select ifnull(sum(if(t.car_module_type = 1, 1, 0)), 0) as gdcNum,
ifnull(sum(if(t.car_module_type=1,1,0)),0) as gdcNum, ifnull(sum(if(t.car_module_type = 2, 1, 0)), 0) as cqcNum,
ifnull(sum(if(t.car_module_type=2,1,0)),0) as cqcNum, ifnull(sum(if(t.car_module_type = 3, 1, 0)), 0) as lscNum
ifnull(sum(if(t.car_module_type=3,1,0)),0) as lscNum
from car_info as t from car_info as t
WHERE t.project_sn=#{param.projectSn} WHERE t.project_sn = #{param.projectSn}
</select> </select>
<select id="queryById" resultType="com.zhgd.xmgl.modules.car.entity.CarInfo"> <select id="queryById" resultType="com.zhgd.xmgl.modules.car.entity.CarInfo">
SELECT <include refid="selectTable">
if(t.car_module_type=1 or t.car_module_type=2,wi.id_card,t.outside_driver_id_card) as outsideDriverIdCard, </include>
if(t.car_module_type=1 or t.car_module_type=2,wi.worker_name,t.driver_worker_name) as driverWorkerName,
t.*,
b.car_type_name,
ei.enterprise_name
FROM car_info t LEFT JOIN car_type b ON (t.car_type=b.id and t.project_sn=b.project_sn)
left join enterprise_info ei on ei.id=t.enterprise_id
left join worker_info wi on t.driver_worker_id = wi.id and (t.car_module_type=1 or t.car_module_type=2)
left join (SELECT * FROM worker_info GROUP BY id_card) wi1 on wi1.id_card=t.outside_driver_id_card and
t.car_module_type=3
where t.id = #{id} where t.id = #{id}
</select> </select>
</mapper> </mapper>