select id, location, location_id, user_id, user_name, phone, dept_id, dept_name, type, create_time from qp_task select t.id, t.location, t.location_id, t.user_id, t.user_name, t.phone, t.dept_id, t.dept_name, t.type, t.create_time, (select f.name from lab_build_floor f where f.type = 1 and f.id = ( select f.parent_id from lab_build_floor f where f.id = (select bfl.build_id from lab_build_floor_layout bfl where bfl.sub_id = t.location_id))) campus,/**校区**/ (select f.`name` from lab_build_floor f where f.type = 2 and f.id = (select bfl.build_id from lab_build_floor_layout bfl where bfl.sub_id = t.location_id)) building,/**楼栋*/ (select bfl.room_num from lab_build_floor_layout bfl where bfl.sub_id = t.location_id) room,/*房间号**/ (select COALESCE(sum(bottle_number), 0) from qp_task_detail d where d.task_id = t.id) applyNum, /**申请总数**/ (select count(1) from qp_bottle_storage st where st.task_id = t.id and st.air_status = 0) storageNum, /** 入库总数 **/ (select count(1) from qp_bottle_storage st where st.task_id = t.id and st.air_status = 1) refuseNum, /** 拒收总数 **/ (select COALESCE(sum(bottle_number), 0) from qp_task_detail td where td.task_id = t.id and qp_status = 0) wpsNum,/** 未派送总数 **/ ((select ifnull((SELECT sum(td.bottle_number) FROM qp_task_detail td WHERE td.task_id = t.id AND qp_status = 1), 0) from dual) - (select count(1) from qp_bottle_storage where task_id = t.id)) drkNum /** 待入库总数 **/ from qp_task as t LEFT JOIN sys_dept d on t.dept_id = d.dept_id LEFT JOIN sys_user u on t.user_id = u.user_id insert into qp_task location, location_id, user_id, user_name, phone, dept_id, dept_name, type, create_time, #{location}, #{locationId}, #{userId}, #{userName}, #{phone}, #{deptId}, #{deptName}, #{type}, #{createTime}, update qp_task location = #{location}, location_id = #{locationId}, user_id = #{userId}, user_name = #{userName}, phone = #{phone}, dept_id = #{deptId}, dept_name = #{deptName}, type = #{type}, create_time = #{createTime}, where id = #{id} delete from qp_task where id = #{id} delete from qp_task where id in #{id}