| | |
| | | <result property="departmentId" column="department_id" /> |
| | | <result property="serviceOrderClass" column="service_order_class" /> |
| | | <result property="dispatchOrderClass" column="dispatch_order_class" /> |
| | | <result property="departureAddress" column="departure_address" /> |
| | | <result property="departureLongitude" column="departure_longitude" /> |
| | | <result property="departureLatitude" column="departure_latitude" /> |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectDeptVo"> |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.department_id, d.service_order_class, d.dispatch_order_class, d.create_by, d.create_time |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.department_id, d.service_order_class, d.dispatch_order_class, d.departure_address, d.departure_longitude, d.departure_latitude, d.create_by, d.create_time |
| | | from sys_dept d |
| | | </sql> |
| | | |
| | |
| | | <if test="status != null and status != ''"> |
| | | AND status = #{status} |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | | <if test="serviceOrderClass != null and serviceOrderClass != ''"> |
| | | AND service_order_class = #{serviceOrderClass} |
| | | </if> |
| | | <if test="dispatchOrderClass != null and dispatchOrderClass != ''"> |
| | | AND dispatch_order_class = #{dispatchOrderClass} |
| | | </if> |
| | | |
| | | order by d.parent_id, d.order_num |
| | | </select> |
| | | |
| | | <select id="selectDeptListByParentId" parameterType="Long" resultMap="SysDeptResult"> |
| | | <include refid="selectDeptVo"/> |
| | | where d.del_flag = '0' |
| | | |
| | | AND parent_id = #{parentId} |
| | | |
| | | </select> |
| | | |
| | | <select id="selectDeptListByRoleId" resultType="Long"> |
| | |
| | | </select> |
| | | |
| | | <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.department_id, d.service_order_class, d.dispatch_order_class, |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.department_id, d.service_order_class, d.dispatch_order_class, d.departure_address, d.departure_longitude, d.departure_latitude, |
| | | (select dept_name from sys_dept where dept_id = d.parent_id) parent_name |
| | | from sys_dept d |
| | | where d.dept_id = #{deptId} |
| | |
| | | <if test="departmentId != null">department_id,</if> |
| | | <if test="serviceOrderClass != null and serviceOrderClass != ''">service_order_class,</if> |
| | | <if test="dispatchOrderClass != null and dispatchOrderClass != ''">dispatch_order_class,</if> |
| | | <if test="departureAddress != null and departureAddress != ''">departure_address,</if> |
| | | <if test="departureLongitude != null">departure_longitude,</if> |
| | | <if test="departureLatitude != null">departure_latitude,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | create_time |
| | | )values( |
| | |
| | | <if test="departmentId != null">#{departmentId},</if> |
| | | <if test="serviceOrderClass != null and serviceOrderClass != ''">#{serviceOrderClass},</if> |
| | | <if test="dispatchOrderClass != null and dispatchOrderClass != ''">#{dispatchOrderClass},</if> |
| | | <if test="departureAddress != null and departureAddress != ''">#{departureAddress},</if> |
| | | <if test="departureLongitude != null">#{departureLongitude},</if> |
| | | <if test="departureLatitude != null">#{departureLatitude},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | ) |
| | |
| | | <if test="departmentId != null">department_id = #{departmentId},</if> |
| | | <if test="serviceOrderClass != null">service_order_class = #{serviceOrderClass},</if> |
| | | <if test="dispatchOrderClass != null">dispatch_order_class = #{dispatchOrderClass},</if> |
| | | <if test="departureAddress != null">departure_address = #{departureAddress},</if> |
| | | <if test="departureLongitude != null">departure_longitude = #{departureLongitude},</if> |
| | | <if test="departureLatitude != null">departure_latitude = #{departureLatitude},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | |
| | | limit 1 |
| | | </select> |
| | | |
| | | <!-- 获取指定部门ID的分公司ID(parent_id=100的部门) --> |
| | | <select id="selectBranchCompanyIdByDeptId" parameterType="Long" resultType="Long"> |
| | | select case |
| | | -- 如果传入的就是分公司(parent_id=100),直接返回 |
| | | when exists(select 1 from sys_dept where dept_id = #{deptId} and parent_id = 100 and del_flag = '0') |
| | | then #{deptId} |
| | | else ( |
| | | -- 否则从 ancestors 中查找分公司ID |
| | | select d.dept_id |
| | | from sys_dept d |
| | | where d.parent_id = 100 |
| | | and d.del_flag = '0' |
| | | and FIND_IN_SET(d.dept_id, ( |
| | | select ancestors from sys_dept where dept_id = #{deptId} and del_flag = '0' |
| | | )) |
| | | limit 1 |
| | | ) |
| | | end |
| | | </select> |
| | | |
| | | <!-- 根据编码列表查询分公司 --> |
| | | <select id="selectBranchCompaniesByOrderCodes" resultMap="SysDeptResult"> |
| | | select dept_id, dept_name, parent_id, ancestors, service_order_class, dispatch_order_class,departure_address, departure_longitude, departure_latitude |
| | | from sys_dept |
| | | where parent_id = 100 |
| | | and del_flag = '0' |
| | | and ( |
| | | <foreach collection="orderCodes" item="code" separator=" or "> |
| | | service_order_class = #{code} or dispatch_order_class = #{code} |
| | | </foreach> |
| | | ) |
| | | </select> |
| | | |
| | | <!-- 根据service_class查询部门信息 --> |
| | | <select id="selectDeptByServiceClass" parameterType="String" resultMap="SysDeptResult"> |
| | | <include refid="selectDeptVo"/> |
| | | where d.service_order_class = #{serviceClass} and d.del_flag = '0' |
| | | limit 1 |
| | | </select> |
| | | |
| | | </mapper> |