| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143 |
- <?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="cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper">
- <select id="getFillDevices"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select
- distinct
- c.id,
- c.dept_id,
- c.device_code,
- c.device_name,
- b.device_category_id,
- d.person_id user_id
- from
- rq_iot_model_template a,
- rq_iot_model_template_attrs b,
- rq_iot_device c,
- rq_iot_device_person d
- where
- a.device_category_id = b.device_category_id
- and
- a.device_category_id = c.asset_class
- and
- c.id = d.device_id
- and
- c.device_status in ('sg','dm')
- and
- a.deleted = 0
- and
- c.deleted = 0
- and
- d.deleted = 0
- <if test="deviceIds != null and !deviceIds.isEmpty()">
- and c.id in
- <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </select>
- <select id="getFillById" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select * from rq_iot_opeation_fill_order where id = #{id}
- </select>
- <select id="getFillDevices1"
- resultType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO">
- select
- distinct
- c.id,
- c.dept_id,
- c.device_code,
- c.device_name,
- b.device_category_id,
- d.person_id user_id,
- e.name dept_name,
- f.nickname,
- g.name,
- c.device_status
- from
- rq_iot_model_template a,
- rq_iot_model_template_attrs b,
- rq_iot_device c,
- rq_iot_device_person d,
- system_dept e,
- system_users f,
- rq_iot_product_classify g
- where
- a.device_category_id = b.device_category_id
- and
- a.device_category_id = c.asset_class
- and
- c.id = d.device_id
- and
- c.dept_id = e.id
- and
- d.person_id = f.id
- and
- a.device_category_id = g.id
- and
- c.device_status in ('sg','dm')
- and
- a.deleted = 0
- and
- c.deleted = 0
- and
- d.deleted = 0
- <if test="deviceIds != null and !deviceIds.isEmpty()">
- and e.id in
- <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- order by c.dept_id
- </select>
- <select id="getFillDevices2"
- resultType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO">
- select
- distinct
- c.id,
- c.dept_id,
- c.device_code,
- c.device_name,
- b.device_category_id,
- d.person_id user_id,
- e.name dept_name,
- f.nickname,
- g.name,
- c.device_status
- from
- rq_iot_model_template a,
- rq_iot_model_template_attrs b,
- rq_iot_device c,
- rq_iot_device_person d,
- system_dept e,
- system_users f,
- rq_iot_product_classify g
- where
- a.device_category_id = b.device_category_id
- and
- a.device_category_id = c.asset_class
- and
- c.id = d.device_id
- and
- c.dept_id = e.id
- and
- d.person_id = f.id
- and
- a.device_category_id = g.id
- and
- c.device_status = 'sg'
- and
- a.deleted = 0
- and
- c.deleted = 0
- and
- d.deleted = 0
- <if test="deptIds != null and !deptIds.isEmpty()">
- and e.id in
- <foreach collection="deptIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- order by c.dept_id
- </select>
- <insert id="insertFill"
- parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- insert into rq_iot_opeation_fill(device_id,device_code,device_name,device_category_id,create_time,dept_id,order_id,is_report)
- values
- <foreach collection="list" item="item" separator=",">
- (#{item.deviceId},#{item.deviceCode},#{item.deviceName},
- #{item.deviceCategoryId},#{item.createTime},#{item.deptId},#{item.orderId},#{item.isReport})
- </foreach>
- </insert>
- <!-- <insert id="insertFillOrder"
- parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- insert into rq_iot_opeation_fill_order(dept_id,order_name,
- order_status,create_time,order_type,user_name,user_id)
- values
- <foreach collection="list" item="item" separator=",">
- (#{item.deptId},#{item.orderName},#{item.orderStatus},
- #{item.createTime},#{item.orderType},#{item.userName},#{item.userId})
- </foreach>
- </insert>-->
- <insert id="insertLog"
- parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- insert into rq_iot_device_run_log
- (dept_id,device_id,device_code,point_code,fill_content,create_time,point_name,total_run_time,is_sum)
- values
- <foreach collection="list" item="item" separator=",">
- (#{item.deptId},#{item.deviceId},#{item.deviceCode},
- #{item.pointCode},#{item.fillContent},#{item.createTime},#{item.pointName},#{item.totalRunTime},#{item.isSum})
- </foreach>
- </insert>
- <insert id="insertLog1"
- parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- insert into rq_iot_device_run_log
- (dept_id, device_id, device_code, point_code, fill_content, create_time, point_name, total_run_time,is_sum)
- values
- (#{deptId}, #{deviceId}, #{deviceCode},
- #{pointCode}, #{fillContent}, #{createTime}, #{pointName}, #{totalRunTime},#{isSum})
- </insert>
- <update id="updateLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- update rq_iot_device_run_log
- set
- fill_content = #{fillContent}
- where
- device_code = #{deviceCode}
- and
- point_name = #{pointName}
- and
- DATE(create_time) = #{createTime}
- and
- is_sum = 0
- </update>
- <update id="updateSumLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- update rq_iot_device_run_log
- set
- total_run_time = #{totalRunTime}
- where
- device_code = #{deviceCode}
- and
- point_name = #{pointName}
- and
- DATE(create_time) = #{createTime}
- and
- is_sum = 1
- </update>
- <!-- <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT * FROM
- rq_iot_opeation_fill
- WHERE DATE(create_time) = CURDATE()
- <if test="deptId != null and deptId != ''">
- and dept_id in (SELECT d1.id
- FROM system_dept d1
- JOIN system_dept d2 ON d2.id = d1.parent_id
- WHERE d2.parent_id = #{deptId}
- union
- select id from system_dept where id = #{deptId})
- </if>
- </select>-->
- <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT * FROM
- rq_iot_opeation_fill
- WHERE DATE(create_time) = CURDATE()
- <if test="userId != null and userId != ''">
- and device_id in (select device_id from
- rq_iot_device_person where person_id = #{userId})
- </if>
- </select>
- <select id="fills" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT * FROM
- rq_iot_opeation_fill
- WHERE 1=1
- <if test="deviceIds != null and !deviceIds.isEmpty()">
- and device_id in
- <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </select>
- <update id="upFill" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- update rq_iot_opeation_fill set dept_id = #{deptId} where 1=1
- <if test="deviceIds != null and !deviceIds.isEmpty()">
- and device_id in
- <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </update>
- <update id="upFill1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO">
- update rq_iot_opeation_fill_order
- set order_status = '3',
- reason = #{reason}
- where
- id = #{id}
- </update>
- <update id="upFill2" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO">
- update rq_iot_opeation_fill
- set is_fill = '3'
- where
- order_id = #{id}
- </update>
- <select id="deviceList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select device_id from
- rq_iot_device_person where person_id = #{userId}
- </select>
- <select id="fillListByUserId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT DISTINCT
- a.*,
- b.name org_name
- FROM
- rq_iot_opeation_fill a
- JOIN system_dept b ON a.dept_id = b.id
- JOIN rq_iot_model_template_attrs c ON a.device_category_id = c.device_category_id
- JOIN rq_iot_opeation_fill_order d ON a.order_id = d.id
- WHERE
- a.dept_id IN (
- SELECT id FROM (
- SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
- UNION ALL
- SELECT d2.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id WHERE d1.id = #{deptId}
- UNION ALL
- SELECT d3.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id WHERE d1.id = #{deptId}
- UNION ALL
- SELECT d4.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id JOIN system_dept d4 ON d4.parent_id = d3.id WHERE d1.id = #{deptId}
- ) AS dept_hierarchy
- )
- AND (
- <if test="orderId != null and orderId != ''">
- a.order_id = #{orderId}
- </if>
- <!--<if test="orgName != null and orgName != ''">
- (
- a.device_name LIKE CONCAT('%', #{orgName}, '%')
- OR a.device_code LIKE CONCAT('%', #{orgName}, '%')
- OR d.user_name LIKE CONCAT('%', #{orgName}, '%')
- )
- </if>
- <if test="orgName == null or orgName == ''">
- 1=1
- </if>-->
- )
- ORDER BY
- CASE WHEN device_code IS NULL OR device_code = '' THEN 1 ELSE 0 END ASC,
- CAST(SUBSTRING(device_code, 3) AS UNSIGNED) ASC
- </select>
- <select id="getOrderIds" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select
- distinct a.order_id
- from
- rq_iot_opeation_fill a,
- rq_iot_opeation_fill_order b
- where
- a.order_id = b.id
- and
- a.deleted = 0
- and
- b.deleted = 0
- and
- a.order_id is not null
- and(
- <if test="orgName != null and orgName != ''">
- (
- a.device_name LIKE CONCAT('%', #{orgName}, '%')
- OR a.device_code LIKE CONCAT('%', #{orgName}, '%')
- or b.user_name LIKE CONCAT('%', #{orgName}, '%')
- or b.order_name LIKE CONCAT('%', #{orgName}, '%')
- )
- </if>
- <if test="orgName == null or orgName == ''">
- 1=1
- </if>)
- </select>
- <select id="fillListByDeptId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select
- distinct
- a.*,
- b.name org_name
- from
- rq_iot_opeation_fill a,
- system_dept b,
- rq_iot_model_template_attrs c
- where
- a.dept_id = b.id
- and
- a.device_category_id = c.device_category_id
- <if test="orderId != null and orderId != ''">
- and a.order_id = #{orderId}
- </if>
- <if test="deviceId != null and deviceId != ''">
- and a.device_id = #{deviceId}
- </if>
- </select>
- <select id="devListByOrderId" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT
- COUNT(*) AS allDev, -- 总数量
- SUM(CASE WHEN is_fill = 1 THEN 1 ELSE 0 END) AS fillDev, -- is_fill为1的数量
- SUM(CASE WHEN is_fill = 0 THEN 1 ELSE 0 END) AS unFillDev -- is_fill为0的数量
- FROM
- rq_iot_opeation_fill
- WHERE
- order_id = #{orderId}
- and
- dept_id IN (
- SELECT id FROM (
- SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
- UNION ALL
- SELECT d2.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id WHERE d1.id = #{deptId}
- UNION ALL
- SELECT d3.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id WHERE d1.id = #{deptId}
- UNION ALL
- SELECT d4.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id JOIN system_dept d4 ON d4.parent_id = d3.id WHERE d1.id = #{deptId}
- ) AS dept_hierarchy
- )
- and device_name != '日报填报'
- </select>
- <!-- -->
- <select id="selectReportsByYear" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT *
- FROM rq_iot_opeation_fill
- WHERE is_report = 1
- <if test="deptId != null">
- AND dept_id = #{deptId}
- </if>
- AND YEAR(create_time) = #{year}
- </select>
- <select id="fillRecords" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
- SELECT a.*
- FROM rq_iot_opeation_fill_order a
- JOIN rq_iot_opeation_fill b ON a.id = b.order_id
- WHERE b.device_id = #{deviceId}
- <if test="orderName != null and orderName != ''">
- AND (a.order_name LIKE CONCAT('%', #{orderName}, '%')
- OR b.device_code LIKE CONCAT('%', #{orderName}, '%')
- OR b.device_name LIKE CONCAT('%', #{orderName}, '%'))
- </if>
- <if test="orderStatus != null">
- AND a.order_status = #{orderStatus}
- </if>
- ORDER BY a.create_time DESC
- </select>
- <select id="selectListByCreateTime" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
- SELECT a.id, a.create_time
- FROM rq_iot_opeation_fill_order a
- WHERE a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- <if test="deptIds != null and deptIds.size > 0">
- AND a.dept_id IN
- <foreach collection="deptIds" index="index" item="key" open="(" separator="," close=")">
- #{key}
- </foreach>
- </if>
- </select>
- <select id="rhList"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT au.id, au.name, au.parent_id
- FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
- (SELECT @parent_id := '157') pd
- WHERE FIND_IN_SET(parent_id, @parent_id) > 0
- AND @parent_id := concat(@parent_id, ',', id)
- UNION
- SELECT id, name, parent_id
- FROM system_dept
- WHERE id = '157'
- ORDER BY id;
- </select>
- <select id="rdList"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT au.id, au.name, au.parent_id
- FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
- (SELECT @parent_id := '163') pd
- WHERE FIND_IN_SET(parent_id, @parent_id) > 0
- AND @parent_id := concat(@parent_id, ',', id)
- UNION
- SELECT id, name, parent_id
- FROM system_dept
- WHERE id = '163'
- ORDER BY id;
- </select>
- <select id="ryList"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT au.id, au.name, au.parent_id
- FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
- (SELECT @parent_id := '158') pd
- WHERE FIND_IN_SET(parent_id, @parent_id) > 0
- AND @parent_id := concat(@parent_id, ',', id)
- UNION
- SELECT id, name, parent_id
- FROM system_dept
- WHERE id = '158'
- ORDER BY id;
- </select>
- <select id="pdList1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT au.id, au.name, au.parent_id
- FROM (SELECT * FROM system_dept WHERE parent_id IS NOT NULL) au,
- (SELECT @parent_id := #{id}) pd
- WHERE FIND_IN_SET(parent_id, @parent_id) > 0
- AND @parent_id := concat(@parent_id, ',', id)
- UNION
- SELECT id, name, parent_id
- FROM system_dept
- WHERE id = #{id}
- ORDER BY id;
- </select>
- <select id="flList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT au.id, au.name, au.parent_id
- FROM (SELECT * FROM rq_iot_product_classify WHERE parent_id IS NOT NULL) au,
- (SELECT @parent_id := #{id}) pd
- WHERE FIND_IN_SET(parent_id, @parent_id) > 0
- AND @parent_id := concat(@parent_id, ',', id)
- UNION
- SELECT id, name, parent_id
- FROM rq_iot_product_classify
- WHERE id = #{id}
- ORDER BY id;
- </select>
- <select id="pdList" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select
- distinct
- b.id user_id,
- b.nickname user_name,
- c.id dept_id,
- b.mobile,
- c.name orgName
- from
- rq_iot_device_person a
- left join
- system_users b
- on
- a.person_id = b.id
- left join
- system_dept c
- on
- b.dept_id = c.id
- where b.id is not null
- <if test="deviceIds != null and !deviceIds.isEmpty()">
- and a.device_id in
- <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </select>
- <select id="allOrder" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
- select distinct user_name
- from
- rq_iot_opeation_fill_order
- where
- DATE(create_time) = DATE(#{localDateTime})
- <if test="userNames != null and !userNames.isEmpty()">
- and user_name in
- <foreach collection="userNames" item="userName" open="(" separator="," close=")">
- #{userName}
- </foreach>
- </if>
- </select>
- <select id="pdList2" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select
- distinct
- b.id user_id,
- b.nickname user_name,
- c.id dept_id,
- b.mobile,
- c.name orgName
- from
- rq_iot_device_person a
- left join
- system_users b
- on
- a.person_id = b.id
- left join
- system_dept c
- on
- b.dept_id = c.id
- where
- b.id is not null
- and
- c.id is not null
- <if test="deviceIds != null and !deviceIds.isEmpty()">
- and c.id in
- <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- and
- a.person_id
- not in
- (select
- distinct
- d.person_id
- from
- rq_iot_model_template a,
- rq_iot_model_template_attrs b,
- rq_iot_device c,
- rq_iot_device_person d
- where
- a.device_category_id = b.device_category_id
- and
- a.device_category_id = c.asset_class
- and
- c.id = d.device_id
- and
- c.device_status in ('sg','dm')
- and
- a.deleted = 0
- and
- c.deleted = 0
- and
- d.deleted = 0)
- </select>
- <select id="fillList1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT * FROM
- rq_iot_opeation_fill_order
- WHERE 1=1
- <if test="deptId != null and deptId != ''">
- and dept_id = #{deptId}
- </if>
- </select>
- <select id="getAttrsById" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO">
- select
- id,
- name,
- type,
- model_attr,
- is_sum,
- threshold,
- default_value,
- sum_id,
- description
- from
- rq_iot_model_template_attrs
- where
- device_category_id = #{deviceCategoryId} and deleted = 0
- </select>
- <update id="updateFill" parameterType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotOpeationModelPageReqVO">
- update rq_iot_opeation_fill
- set is_fill = '1'
- where device_id = #{deviceId}
- and DATE(create_time) = DATE(#{createTime})
- </update>
- <select id="getFillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
- resultType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO">
- select distinct b.* from
- rq_iot_opeation_fill b,
- rq_iot_opeation_fill_order c
- where
- c.id = #{orderId}
- and
- b.dept_id = c.dept_id
- and
- b.order_id = c.id
- and
- DATE(b.create_time)=DATE(#{createTime})
- order by b.create_time desc
- </select>
- <select id="getDeivceFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- <!--SELECT * FROM rq_iot_device_run_log
- WHERE
- device_id = #{deviceId}
- and
- create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
- device_id = #{deviceId})-->
- SELECT
- point_name,
- fill_content,
- (select max(total_run_time) from rq_iot_device_run_log where device_id = #{deviceId})total_run_time
- FROM rq_iot_device_run_log
- WHERE
- device_id = #{deviceId}
- and
- DATE(create_time) = DATE(#{createTime})
- order by id
- desc
- limit 1
- </select>
- <select id="getLogInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- <!--SELECT * FROM rq_iot_device_run_log
- WHERE
- device_id = #{deviceId}
- and
- create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
- device_id = #{deviceId})-->
- SELECT
- *
- FROM rq_iot_device_run_log
- WHERE
- device_id = #{deviceId}
- and
- point_name = #{pointName}
- and
- DATE(create_time) = DATE(#{createTime})
- order by id
- desc
- limit 1
- </select>
- <select id="getMaxFillInfo" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- <!--SELECT * FROM rq_iot_device_run_log
- WHERE
- device_id = #{deviceId}
- and
- create_time = (SELECT MAX(create_time) FROM rq_iot_device_run_log WHERE
- device_id = #{deviceId})-->
- select max(total_run_time)total_run_time
- from rq_iot_device_run_log
- where
- device_id = #{deviceId}
- and
- point_name=#{pointName}
- </select>
- <select id="devList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select device_id from rq_iot_opeation_fill where order_id = #{orderId}
- </select>
- <select id="orderList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select distinct order_id
- from
- rq_iot_opeation_fill
- where
- device_id = #{deviceId}
- and DATE(create_time) = #{creDate}
- and order_id != #{orderId}
- </select>
- <select id="delList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select * from rq_iot_opeation_fill where order_id = #{orderId}
- </select>
- <delete id="delRepeat" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- delete from rq_iot_opeation_fill where order_id = #{orderId}
- </delete>
- <delete id="delRepeatOrder" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- delete from rq_iot_opeation_fill_order where id = #{orderId}
- </delete>
- <update id="updateFillOrder" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- update rq_iot_opeation_fill_order set order_status = 1,update_time = NOW() where id = #{id}
- </update>
- <update id="updateFillOrder1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- update rq_iot_opeation_fill_order set order_status = 0 where id = #{id}
- </update>
- <update id="updateFillOrder2" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- update rq_iot_opeation_fill_order set order_status = 2,update_time = NOW() where id = #{id}
- </update>
- <select id="carList"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO">
- select distinct device_code ,car_id from rq_iot_car_zhbd
- </select>
- <update id="upLocation"
- parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO">
- update rq_iot_device set location= #{location} where device_code = #{deviceCode}
- </update>
- <select id="deviceCountList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecountdata.IotDeviceCountData"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicecountdata.IotDeviceCountData">
- select
- distinct
- a.device_code,
- a.device_name,
- a.create_time,
- b.name dept_name,
- a.is_fill,
- d.nickname,
- e.order_name
- FROM rq_iot_opeation_fill a
- LEFT JOIN system_dept b
- ON a.dept_id = b.id
- AND b.deleted = 0 -- 将删除检查移至JOIN条件
- LEFT JOIN rq_iot_device_person c
- ON a.device_id = c.device_id
- AND c.deleted = 0 -- 将删除检查移至JOIN条件
- LEFT JOIN system_users d
- ON c.person_id = d.id
- AND d.deleted = 0 -- 将删除检查移至JOIN条件
- LEFT JOIN rq_iot_opeation_fill_order e
- ON a.order_id = e.id
- and e.deleted = 0
- WHERE a.deleted = 0
- and e.order_name is not null
- and a.device_name != '生产日报'
- AND b.id IN (
- SELECT id FROM system_dept WHERE id = #{deptId}
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id = #{deptId}
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}))
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})))
- )
- <if test="isFill != null">
- and a.is_fill = #{isFill}
- </if>
- <if test="createTime != null and createTime.length > 0">
- <choose>
- <when test="createTime.length == 1">
- AND a.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- </when>
- <otherwise>
- AND a.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- </otherwise>
- </choose>
- </if>
- <if test="orderName != null and orderName != ''">
- AND (e.order_name LIKE CONCAT('%', #{orderName}, '%')
- OR a.device_code LIKE CONCAT('%', #{orderName}, '%')
- OR a.device_name LIKE CONCAT('%', #{orderName}, '%')
- OR d.nickname LIKE CONCAT('%', #{orderName}, '%'))
- </if>
- order by a.create_time desc,a.is_fill asc,b.name asc
- </select>
- <select id="countList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
- -- 统计指定部门及其子部门的工单状态
- SELECT
- dept_id,
- name,
- COALESCE(total_count, 0) AS total_count,
- COALESCE(filled_count, 0) AS filled_count,
- COALESCE(unfilled_count, 0) AS unfilled_count,
- COALESCE(filling_count, 0) AS filling_count,
- COALESCE(ignore_count, 0) AS ignore_count
- FROM (
- -- 第一行:汇总数据
- SELECT
- #{deptId} AS dept_id,
- (SELECT name FROM system_dept WHERE id = #{deptId}) AS name,
- COUNT(o.id) AS total_count,
- SUM(CASE WHEN o.order_status = 1 THEN 1 ELSE 0 END) AS filled_count,
- SUM(CASE WHEN o.order_status = 0 THEN 1 ELSE 0 END) AS unfilled_count,
- SUM(CASE WHEN o.order_status = 2 THEN 1 ELSE 0 END) AS filling_count,
- SUM(CASE WHEN o.order_status = 3 THEN 1 ELSE 0 END) AS ignore_count,
- 0 AS sort_order -- 确保汇总数据排在第一行
- FROM rq_iot_opeation_fill_order o
- WHERE o.deleted = 0
- <if test="createTime != null and createTime.length > 0">
- <choose>
- <when test="createTime.length == 1">
- AND o.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- </when>
- <otherwise>
- AND o.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- </otherwise>
- </choose>
- </if>
- AND o.dept_id IN (
- SELECT id FROM system_dept WHERE id = #{deptId} -- 包含根部门自身
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id = #{deptId} -- 一级子部门
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}) -- 二级子部门
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})) -- 三级子部门
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId}))) -- 四级子部门
- )
- UNION ALL
- -- 后续行:直接子部门数据
- SELECT
- d.id AS dept_id,
- d.name,
- COUNT(o.id) AS total_count,
- SUM(CASE WHEN o.order_status = 1 THEN 1 ELSE 0 END) AS filled_count,
- SUM(CASE WHEN o.order_status = 0 THEN 1 ELSE 0 END) AS unfilled_count,
- SUM(CASE WHEN o.order_status = 2 THEN 1 ELSE 0 END) AS filling_count,
- SUM(CASE WHEN o.order_status = 3 THEN 1 ELSE 0 END) AS ignore_count,
- 1 AS sort_order -- 子部门数据排在后面
- FROM system_dept d
- LEFT JOIN rq_iot_opeation_fill_order o
- ON o.deleted = 0
- <if test="createTime != null and createTime.length > 0">
- <choose>
- <when test="createTime.length == 1">
- AND o.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- </when>
- <otherwise>
- AND o.create_time BETWEEN #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- </otherwise>
- </choose>
- </if>
- AND o.dept_id IN (
- SELECT id FROM system_dept WHERE id = d.id -- 子部门自身
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id = d.id -- 子部门的一级子部门
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = d.id) -- 子部门的二级子部门
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = d.id)) -- 子部门的三级子部门
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = d.id))) -- 子部门的四级子部门
- )
- WHERE d.parent_id = #{deptId} -- 只查询直接子部门
- AND d.deleted = 0 -- 排除已删除的部门
- GROUP BY d.id, d.name
- HAVING COUNT(o.id) > 0 -- 只显示有数据的部门
- ) t
- ORDER BY sort_order, dept_id;
- </select>
- <select id="countDeviceList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO">
- -- 统计指定部门及其子部门的工单状态
- -- 第一行:汇总数据
- SELECT
- COUNT(*) AS total_count,
- SUM(CASE WHEN is_fill = 1 THEN 1 ELSE 0 END) AS filled_count,
- SUM(CASE WHEN is_fill = 3 THEN 1 ELSE 0 END) AS ignore_count,
- COUNT(*) - SUM(CASE WHEN is_fill = 1 THEN 1 ELSE 0 END)-SUM(CASE WHEN is_fill = 3 THEN 1 ELSE 0 END) AS unfilled_count
- from(
- select
- distinct
- a.device_code,
- a.device_name,
- a.create_time,
- b.name dept_name,
- a.is_fill,
- d.nickname,
- e.order_name
- FROM rq_iot_opeation_fill a
- LEFT JOIN system_dept b
- ON a.dept_id = b.id
- AND b.deleted = 0 -- 将删除检查移至JOIN条件
- LEFT JOIN rq_iot_device_person c
- ON a.device_id = c.device_id
- AND c.deleted = 0 -- 将删除检查移至JOIN条件
- LEFT JOIN system_users d
- ON c.person_id = d.id
- AND d.deleted = 0 -- 将删除检查移至JOIN条件
- LEFT JOIN rq_iot_opeation_fill_order e
- ON a.order_id = e.id
- and e.deleted = 0
- WHERE a.deleted = 0
- and e.order_name is not null
- and a.device_name != '生产日报'
- AND b.id IN (
- SELECT id FROM system_dept WHERE id = #{deptId}
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id = #{deptId}
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM
- system_dept WHERE parent_id = #{deptId}))
- UNION ALL
- SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id IN (SELECT id FROM
- system_dept WHERE parent_id IN (SELECT id FROM system_dept WHERE parent_id = #{deptId})))
- )
- <if test="createTime != null and createTime.length > 0">
- <choose>
- <when test="createTime.length == 1">
- AND a.create_time = #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- </when>
- <otherwise>
- AND a.create_time BETWEEN
- #{createTime[0],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler} AND
- #{createTime[1],typeHandler=org.apache.ibatis.type.LocalDateTimeTypeHandler}
- </otherwise>
- </choose>
- </if>) a
- </select>
- <select id="childList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
- SELECT id dept_id
- FROM system_dept
- WHERE parent_id = #{deptId}
- AND deleted = 0
- </select>
- <select id="isReport" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select * from
- rq_iot_opeation_fill
- where
- device_id = #{deviceId}
- and
- DATE(create_time) = #{createTime}
- LIMIT 1
- </select>
- <select id="orderDO" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- select
- order_id
- from
- rq_iot_opeation_fill
- where
- device_id = #{deviceId}
- and
- DATE(create_time) = #{createTime}
- </select>
- <select id="reportList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT DISTINCT
- a.device_id,
- a.device_code,
- a.device_name,
- a.create_time,
- b.name AS org_name
- FROM
- rq_iot_opeation_fill a
- INNER JOIN
- rq_iot_model_template_attrs b
- ON
- a.device_category_id = b.device_category_id
- WHERE
- a.order_id = #{orderId}
- AND (
- -- 第一个查询的条件
- (a.is_report = 1 AND b.daily_report = 0
- AND b.name NOT IN (
- SELECT
- DISTINCT
- b2.name
- FROM
- rq_iot_opeation_fill a2
- INNER JOIN
- rq_iot_model_template_attrs b2
- ON
- a2.device_category_id = b2.device_category_id
- WHERE
- a2.order_id = #{orderId}
- AND
- a2.is_report = 0
- AND
- b2.daily_report = 1
- ))
- -- 第二个查询的条件(通过OR代替UNION)
- OR (a.is_report = 0 AND b.daily_report = 1)
- )
- </select>
- <select id="reportList1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
- SELECT DISTINCT
- a.device_id,
- a.device_code,
- a.device_name,
- a.create_time,
- b.name AS org_name
- FROM
- rq_iot_opeation_fill a
- INNER JOIN
- rq_iot_model_template_attrs b
- ON
- a.device_category_id = b.device_category_id
- WHERE
- a.order_id = #{orderId}
- and
- a.is_report = 1
- </select>
- <select id="reportData" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- select * from
- rq_iot_device_run_log
- where
- device_id = #{deviceId}
- and
- point_name = #{pointName}
- and DATE(create_time) = DATE(#{createTime})
- </select>
- <select id="reportData1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- select * from
- rq_iot_device_run_log
- where
- device_id = #{deviceId}
- and
- point_name = #{pointName}
- and DATE(create_time) = DATE(#{createTime})
- </select>
- <select id="getDesc" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
- resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
- select
- description point_name
- from
- rq_iot_model_template_attrs
- where
- name = #{pointName}
- and
- device_category_id =
- (select device_category_id from rq_iot_opeation_fill where device_id = #{deviceId} and DATE(create_time) = #{createTime})
- </select>
- </mapper>
|