| | |
| | | <mapper namespace="org.sxkj.gd.workorder.mapper.GdWorkOrderMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="gdWorkOrderResultMap" type="org.sxkj.gd.workorder.entity.GdWorkOrderEntity"> |
| | | <resultMap id="gdWorkOrderResultMap" type="org.sxkj.gd.workorder.vo.GdWorkOrderVO"> |
| | | <result column="id" property="id"/> |
| | | <result column="work_order_name" property="workOrderName"/> |
| | | <result column="work_order_code" property="workOrderCode"/> |
| | | <result column="work_order_type" property="workOrderType"/> |
| | | <result column="work_order_type" property="workOrderType" typeHandler="org.sxkj.common.handler.GenericListTypeHandler"/> |
| | | <result column="type_pinyin_first" property="typePinyinFirst"/> |
| | | <result column="device_load_demand" property="deviceLoadDemand"/> |
| | | <result column="recommend_device_ids" property="recommendDeviceIds"/> |
| | | <result column="work_order_status" property="workOrderStatus"/> |
| | |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | <select id="getWorkOrderDetail" resultMap="gdWorkOrderResultMap"> |
| | | select id, |
| | | work_order_name, |
| | | work_order_code, |
| | | work_order_type, |
| | | type_pinyin_first, |
| | | device_load_demand, |
| | | recommend_device_ids, |
| | | work_order_status, |
| | | execute_start_time, |
| | | execute_end_time, |
| | | service_party, |
| | | public.st_astext(geom) geom, |
| | | remark, |
| | | reject_reason, |
| | | area_code, |
| | | create_user, |
| | | create_dept, |
| | | create_time, |
| | | update_user, |
| | | update_time, |
| | | status, |
| | | is_deleted |
| | | from ja_gd_work_order |
| | | where id = #{id}::BIGINT |
| | | </select> |
| | | |
| | | <select id="getWorkOrderByIdWithoutGeom" resultType="org.sxkj.gd.workorder.entity.GdWorkOrderEntity"> |
| | | select id, |
| | | work_order_name, |
| | | work_order_code, |
| | | work_order_type, |
| | | type_pinyin_first, |
| | | device_load_demand, |
| | | recommend_device_ids, |
| | | work_order_status, |
| | | execute_start_time, |
| | | execute_end_time, |
| | | service_party, |
| | | remark, |
| | | public.st_astext(geom) geom, |
| | | reject_reason, |
| | | area_code, |
| | | create_user, |
| | | create_dept, |
| | | create_time, |
| | | update_user, |
| | | update_time, |
| | | status, |
| | | is_deleted |
| | | from ja_gd_work_order |
| | | where id = #{id} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectGdWorkOrderPage" resultMap="gdWorkOrderResultMap"> |
| | | select * from ja_gd_work_order where is_deleted = 0 |
| | | select |
| | | wo.id, |
| | | wo.work_order_name, |
| | | wo.work_order_code, |
| | | wo.work_order_type, |
| | | wo.type_pinyin_first, |
| | | wo.device_load_demand, |
| | | wo.recommend_device_ids, |
| | | wo.work_order_status, |
| | | wo.execute_start_time, |
| | | wo.execute_end_time, |
| | | wo.service_party, |
| | | public.st_astext(wo.geom) geom, |
| | | wo.remark, |
| | | wo.area_code, |
| | | wo.create_user, |
| | | wo.create_dept, |
| | | wo.create_time, |
| | | wo.update_user, |
| | | wo.update_time, |
| | | wo.status, |
| | | wo.is_deleted, |
| | | bu.name create_user_name |
| | | from ja_gd_work_order wo |
| | | /* 修改点1:关联两端全部转为 VARCHAR */ |
| | | left join blade_user bu on wo.create_user::VARCHAR = bu.id::VARCHAR |
| | | <where> |
| | | /* 修正语法:去掉开头的 and */ |
| | | wo.is_deleted = 0 |
| | | <if test="param2.workOrderStatus != null and param2.workOrderStatus != ''"> |
| | | and wo.work_order_status::VARCHAR like concat(#{param2.workOrderStatus},'%') |
| | | </if> |
| | | <if test="param2.workOrderName != null and param2.workOrderName != ''"> |
| | | and wo.work_order_name like concat('%',#{param2.workOrderName},'%') |
| | | </if> |
| | | <if test="param2.workOrderCode != null and param2.workOrderCode != ''"> |
| | | and wo.work_order_code like concat('%',#{param2.workOrderCode},'%') |
| | | </if> |
| | | <if test="param2.workOrderType != null and param2.workOrderType != ''"> |
| | | /* 将逗号分隔的字符串转换为带引号的格式,如 "road,road1" 转为 "\"road\",\"road1\"" */ |
| | | and wo.work_order_type like concat('%', |
| | | ( |
| | | select string_agg(concat('"', trim(arr_val), '"'), ',') |
| | | from unnest(string_to_array(#{param2.workOrderType}, ',')) as arr_val |
| | | ), |
| | | '%') |
| | | </if> |
| | | <if test="param2.createUser != null "> |
| | | /* 修改点2:过滤条件也进行类型对齐 */ |
| | | and wo.create_user::VARCHAR = #{param2.createUser}::VARCHAR |
| | | </if> |
| | | <if test="param2.createUserName != null and param2.createUserName != ''"> |
| | | and bu.name like concat('%',#{param2.createUserName},'%') |
| | | </if> |
| | | <if test="param2.serviceParty != null and param2.serviceParty != ''"> |
| | | and wo.service_party like concat('%',#{param2.serviceParty},'%') |
| | | </if> |
| | | <if test="param2.startTime != null and param2.startTime != '' and param2.endTime != null and param2.endTime != ''"> |
| | | and wo.execute_start_time <= #{param2.endTime}::timestamp AND wo.execute_end_time >= #{param2.startTime}::timestamp |
| | | </if> |
| | | <if test="param2.deptList != null and param2.deptList.size > 0"> |
| | | /* 修改点3:IN 查询内部元素类型转换 */ |
| | | and wo.create_dept::VARCHAR in |
| | | <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId}::VARCHAR |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | <!-- 按工单类型拼音首字母排序,然后按 createTime 排序 --> |
| | | ORDER BY |
| | | <choose> |
| | | <when test="param2.typePinyinFirst == 'desc'"> |
| | | wo.type_pinyin_first DESC , |
| | | </when> |
| | | <when test="param2.typePinyinFirst == 'asc'"> |
| | | wo.type_pinyin_first ASC , |
| | | </when> |
| | | <otherwise> |
| | | </otherwise> |
| | | </choose> |
| | | <choose> |
| | | <when test="param2.createTimeOrder == 'asc'"> |
| | | wo.create_time ASC |
| | | </when> |
| | | <otherwise> |
| | | wo.create_time DESC |
| | | </otherwise> |
| | | </choose> |
| | | </select> |
| | | |
| | | |
| | | <select id="exportGdWorkOrder" resultType="org.sxkj.gd.workorder.excel.GdWorkOrderExcel"> |
| | | SELECT * FROM ja_gd_work_order ${ew.customSqlSegment} |
| | | SELECT id, |
| | | work_order_name, |
| | | work_order_code, |
| | | work_order_type, |
| | | device_load_demand, |
| | | recommend_device_ids, |
| | | work_order_status, |
| | | execute_start_time, |
| | | execute_end_time, |
| | | service_party, |
| | | geom, |
| | | remark, |
| | | area_code, |
| | | create_user, |
| | | create_dept, |
| | | create_time, |
| | | update_user, |
| | | update_time, |
| | | status, |
| | | is_deleted |
| | | FROM ja_gd_work_order ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | |
| | | <!-- 自定义插入语句,使用ST_GeomFromText处理几何数据 --> |
| | | <insert id="saveWorkOrder" parameterType="org.sxkj.gd.workorder.entity.GdWorkOrderEntity"> |
| | | INSERT INTO ja_gd_work_order ( work_order_name, work_order_code, work_order_type, type_pinyin_first, |
| | | device_load_demand, recommend_device_ids, work_order_status, |
| | | execute_start_time, execute_end_time, service_party, |
| | | geom, remark, area_code, |
| | | create_user, create_dept, create_time, |
| | | update_user, update_time, status, is_deleted) |
| | | VALUES ( #{workOrderParam.workOrderName}, #{workOrderParam.workOrderCode}, #{workOrderParam.workOrderType}, |
| | | #{workOrderParam.typePinyinFirst}, |
| | | #{workOrderParam.deviceLoadDemand}, #{workOrderParam.recommendDeviceIds}, #{workOrderParam.workOrderStatus}, |
| | | #{workOrderParam.executeStartTime}, #{workOrderParam.executeEndTime}, #{workOrderParam.serviceParty}, |
| | | ST_GeomFromText(#{workOrderParam.geom}), #{workOrderParam.remark}, #{workOrderParam.areaCode}, |
| | | #{workOrderParam.createUser}, #{workOrderParam.createDept}, #{workOrderParam.createTime}, |
| | | #{workOrderParam.updateUser}, #{workOrderParam.updateTime}, #{workOrderParam.status}, #{workOrderParam.isDeleted}) |
| | | </insert> |
| | | |
| | | <!-- 自定义更新语句,使用ST_GeomFromText处理几何数据 --> |
| | | <update id="updateWorkOrderById" parameterType="org.sxkj.gd.workorder.entity.GdWorkOrderEntity"> |
| | | UPDATE ja_gd_work_order |
| | | <set> |
| | | <if test="workOrderParam.workOrderName != null and workOrderParam.workOrderName != ''"> |
| | | work_order_name = #{workOrderParam.workOrderName}, |
| | | </if> |
| | | <if test="workOrderParam.workOrderCode != null and workOrderParam.workOrderCode != ''"> |
| | | work_order_code = #{workOrderParam.workOrderCode}, |
| | | </if> |
| | | <if test="workOrderParam.workOrderType != null and workOrderParam.workOrderType != ''"> |
| | | work_order_type = #{workOrderParam.workOrderType}, |
| | | </if> |
| | | <if test="workOrderParam.typePinyinFirst != null and workOrderParam.typePinyinFirst != ''"> |
| | | type_pinyin_first = #{workOrderParam.typePinyinFirst}, |
| | | </if> |
| | | <if test="workOrderParam.deviceLoadDemand != null and workOrderParam.deviceLoadDemand != ''"> |
| | | device_load_demand = #{workOrderParam.deviceLoadDemand}, |
| | | </if> |
| | | <if test="workOrderParam.recommendDeviceIds != null and workOrderParam.recommendDeviceIds != ''"> |
| | | recommend_device_ids = #{workOrderParam.recommendDeviceIds}, |
| | | </if> |
| | | <if test="workOrderParam.workOrderStatus != null"> |
| | | work_order_status = #{workOrderParam.workOrderStatus}, |
| | | </if> |
| | | <if test="workOrderParam.executeStartTime != null"> |
| | | execute_start_time = #{workOrderParam.executeStartTime}, |
| | | </if> |
| | | <if test="workOrderParam.executeEndTime != null"> |
| | | execute_end_time = #{workOrderParam.executeEndTime}, |
| | | </if> |
| | | <if test="workOrderParam.serviceParty != null and workOrderParam.serviceParty != ''"> |
| | | service_party = #{workOrderParam.serviceParty}, |
| | | </if> |
| | | <if test="workOrderParam.geom != null and workOrderParam.geom != ''"> |
| | | geom = ST_GeomFromText(#{workOrderParam.geom}), |
| | | </if> |
| | | <if test="workOrderParam.remark != null and workOrderParam.remark != ''"> |
| | | remark = #{workOrderParam.remark}, |
| | | </if> |
| | | <if test="workOrderParam.areaCode != null and workOrderParam.areaCode != ''"> |
| | | area_code = #{workOrderParam.areaCode}, |
| | | </if> |
| | | <if test="workOrderParam.updateUser != null"> |
| | | update_user = #{workOrderParam.updateUser}, |
| | | </if> |
| | | <if test="workOrderParam.updateTime != null"> |
| | | update_time = #{workOrderParam.updateTime}, |
| | | </if> |
| | | <if test="workOrderParam.status != null"> |
| | | status = #{workOrderParam.status}, |
| | | </if> |
| | | <if test="workOrderParam.isDeleted != null"> |
| | | is_deleted = #{workOrderParam.isDeleted}, |
| | | </if> |
| | | </set> |
| | | WHERE id = #{workOrderParam.id} |
| | | </update> |
| | | |
| | | </mapper> |