WorkOrderManageMapper.xml 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.huaxu.order.dao.WorkOrderManageMapper" >
  4. <resultMap id="BaseResultMap" type="com.huaxu.order.dto.WorkOrderManageDto" >
  5. <id column="id" property="id" jdbcType="INTEGER" />
  6. <result column="task_no" property="taskNo" jdbcType="VARCHAR" />
  7. <result column="task_desc" property="taskDesc" jdbcType="VARCHAR" />
  8. <result column="order_user_id" property="orderUserId" jdbcType="VARCHAR" />
  9. <result column="send_time" property="sendTime" jdbcType="TIMESTAMP" />
  10. <result column="send_by" property="sendBy" jdbcType="VARCHAR" />
  11. <result column="plan_finish_date" property="planFinishDate" jdbcType="TIMESTAMP" />
  12. <result column="finish_date" property="finishDate" jdbcType="TIMESTAMP" />
  13. <result column="date_limit" property="dateLimit" jdbcType="VARCHAR" />
  14. <result column="urgency" property="urgency" jdbcType="VARCHAR" />
  15. <result column="address" property="address" jdbcType="VARCHAR" />
  16. <result column="contact_user" property="contactUser" jdbcType="VARCHAR" />
  17. <result column="contact_phone" property="contactPhone" jdbcType="VARCHAR" />
  18. <result column="order_time" property="orderTime" jdbcType="VARCHAR" />
  19. <result column="company_org_id" property="companyOrgId" jdbcType="VARCHAR" />
  20. <result column="department_org_id" property="departmentOrgId" jdbcType="VARCHAR" />
  21. <result column="order_status" property="orderStatus" jdbcType="INTEGER" />
  22. <result column="event_type" property="eventType" jdbcType="INTEGER" />
  23. <result column="event_type_name" property="eventTypeName" jdbcType="VARCHAR" />
  24. <result column="order_type_id" property="orderTypeId" jdbcType="INTEGER" />
  25. <result column="order_pid" property="orderPid" jdbcType="VARCHAR" />
  26. <result column="tenant_id" property="tenantId" jdbcType="VARCHAR" />
  27. <result column="process_instance_id" property="processInstanceId" jdbcType="VARCHAR" />
  28. <result column="process_def_id" property="processDefId" jdbcType="VARCHAR" />
  29. <result column="current_task_id" property="currentTaskId" jdbcType="VARCHAR" />
  30. <result column="current_users" property="currentUsers" jdbcType="VARCHAR" />
  31. <result column="current_task_name" property="currentTaskName" jdbcType="VARCHAR" />
  32. <result column="create_by" property="createBy" jdbcType="VARCHAR" />
  33. <result column="date_create" property="dateCreate" jdbcType="TIMESTAMP" />
  34. <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
  35. <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
  36. <result column="geo" property="geo" jdbcType="VARCHAR" />
  37. <result column="videos" property="videos" jdbcType="VARCHAR" />
  38. <result column="pictures" property="pictures" jdbcType="VARCHAR" />
  39. <result column="flow_detail" property="flowDetail" jdbcType="VARCHAR" />
  40. <result column="device_id" property="deviceId" jdbcType="INTEGER" />
  41. <result column="scenes_id" property="scenesId" jdbcType="INTEGER" />
  42. <result column="device_name" property="deviceName" jdbcType="VARCHAR" />
  43. <result column="scenes_name" property="scenesName" jdbcType="VARCHAR" />
  44. <result column="order_status_name" property="orderStatusName" jdbcType="VARCHAR" />
  45. <result column="order_count" property="orderCount" jdbcType="VARCHAR" />
  46. <result column="in_process_status" property="inProcessStatus" jdbcType="INTEGER" />
  47. </resultMap>
  48. <resultMap id="workFlowLogResultMap" type="com.huaxu.order.entity.WorkFlowLog">
  49. <id column="id" property="id" jdbcType="INTEGER" />
  50. <result column="flow_id" property="flowId" jdbcType="INTEGER" />
  51. <result column="log_process_instance_id" property="processInstanceId" jdbcType="VARCHAR" />
  52. <result column="task_id" property="taskId" jdbcType="VARCHAR" />
  53. <result column="handle_user_id" property="handleUserId" jdbcType="VARCHAR" />
  54. <result column="handle_user_name" property="handleUserName" jdbcType="VARCHAR" />
  55. <result column="flow_type" property="flowType" jdbcType="INTEGER" />
  56. <result column="flow_result" property="flowResult" jdbcType="VARCHAR" />
  57. <result column="log_create_by" property="createBy" jdbcType="VARCHAR" />
  58. <result column="log_date_create" property="dateCreate" jdbcType="TIMESTAMP" />
  59. <result column="log_update_by" property="updateBy" jdbcType="VARCHAR" />
  60. <result column="log_date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
  61. </resultMap>
  62. <resultMap id="OrderResultMap" type="com.huaxu.order.dto.WorkOrderManageDto" extends="BaseResultMap">
  63. <association property="workFlowDetail" javaType="com.huaxu.order.entity.WorkFlowDetail">
  64. <id column="id" property="id" jdbcType="INTEGER" />
  65. <result column="flow_id" property="flowId" jdbcType="INTEGER" />
  66. <result column="flow_type" property="flowType" jdbcType="INTEGER" />
  67. <result column="flow_detail" property="flowDetail" jdbcType="VARCHAR" />
  68. <result column="detail_create_by" property="createBy" jdbcType="VARCHAR" />
  69. <result column="detail_date_create" property="dateCreate" jdbcType="TIMESTAMP" />
  70. <result column="detail_update_by" property="updateBy" jdbcType="VARCHAR" />
  71. <result column="detail_date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
  72. </association>
  73. <collection property="workFlowLogList" ofType="com.huaxu.order.entity.WorkFlowLog" javaType="java.util.List" select="getWorkFlowLog" column="{flowId=id}">
  74. <id column="id" property="id" jdbcType="INTEGER" />
  75. <result column="flow_id" property="flowId" jdbcType="INTEGER" />
  76. <result column="log_process_instance_id" property="processInstanceId" jdbcType="VARCHAR" />
  77. <result column="task_id" property="taskId" jdbcType="VARCHAR" />
  78. <result column="handle_user_id" property="handleUserId" jdbcType="VARCHAR" />
  79. <result column="handle_user_name" property="handleUserName" jdbcType="VARCHAR" />
  80. <result column="flow_type" property="flowType" jdbcType="INTEGER" />
  81. <result column="flow_result" property="flowResult" jdbcType="VARCHAR" />
  82. <result column="log_create_by" property="createBy" jdbcType="VARCHAR" />
  83. <result column="log_date_create" property="dateCreate" jdbcType="TIMESTAMP" />
  84. <result column="log_update_by" property="updateBy" jdbcType="VARCHAR" />
  85. <result column="log_date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
  86. </collection>
  87. </resultMap>
  88. <resultMap id="StatisticsMap" type="com.huaxu.order.dto.StatisticsDto" >
  89. <result column="statistics_name" property="statisticsName" jdbcType="VARCHAR" />
  90. <result column="statistics_value" property="statisticsValue" jdbcType="VARCHAR" />
  91. </resultMap>
  92. <sql id="Base_Column_List" >
  93. id, task_no, task_desc, order_user_id, send_time, send_by, plan_finish_date, finish_date,
  94. date_limit, urgency, address, contact_user, contact_phone, order_time, company_org_id,
  95. department_org_id, order_status, event_type, order_type_id, order_pid, tenant_id,
  96. process_instance_id, process_def_id, current_task_id, current_users, current_task_name,
  97. create_by, date_create, update_by, date_update, geo,videos, pictures, device_id, scenes_id,
  98. device_name, scenes_name,in_process_status
  99. </sql>
  100. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  101. select
  102. <include refid="Base_Column_List" />
  103. from sc_work_order_manage
  104. where id = #{id,jdbcType=INTEGER}
  105. </select>
  106. <select id="getWorkFlowLog" resultMap="workFlowLogResultMap" parameterType="map">
  107. select t3.process_instance_id log_process_instance_id,t3.task_id,t3.handle_user_id,t3.handle_user_name,t3.flow_result,t3.create_by log_create_by,
  108. t3.date_create log_date_create,t3.update_by log_update_by,t3.date_update log_date_update
  109. from sc_work_flow_log t3
  110. where t3.flow_id= #{flowId,jdbcType=INTEGER} and t3.flow_type=2
  111. </select>
  112. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  113. delete from sc_work_order_manage
  114. where id = #{id,jdbcType=INTEGER}
  115. </delete>
  116. <insert id="insert" parameterType="com.huaxu.order.entity.WorkOrderManage" >
  117. insert into sc_work_order_manage (id, task_no, task_desc,
  118. order_user_id, send_time, send_by,
  119. plan_finish_date, finish_date, date_limit,
  120. urgency, address, contact_user,
  121. contact_phone, order_time, company_org_id,
  122. department_org_id, order_status, event_type,
  123. order_type_id, order_pid, tenant_id,
  124. process_instance_id, process_def_id, current_task_id,
  125. current_users, current_task_name, create_by,
  126. date_create, update_by, date_update,
  127. geo,videos,pictures)
  128. values (#{id,jdbcType=INTEGER}, #{taskNo,jdbcType=VARCHAR}, #{taskDesc,jdbcType=VARCHAR},
  129. #{orderUserId,jdbcType=VARCHAR}, #{sendTime,jdbcType=TIMESTAMP}, #{sendBy,jdbcType=VARCHAR},
  130. #{planFinishDate,jdbcType=TIMESTAMP}, #{finishDate,jdbcType=TIMESTAMP}, #{dateLimit,jdbcType=VARCHAR},
  131. #{urgency,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{contactUser,jdbcType=VARCHAR},
  132. #{contactPhone,jdbcType=VARCHAR}, #{orderTime,jdbcType=VARCHAR}, #{companyOrgId,jdbcType=VARCHAR},
  133. #{departmentOrgId,jdbcType=VARCHAR}, #{orderStatus,jdbcType=INTEGER}, #{eventType,jdbcType=INTEGER},
  134. #{orderTypeId,jdbcType=INTEGER}, #{orderPid,jdbcType=VARCHAR}, #{tenantId,jdbcType=VARCHAR},
  135. #{processInstanceId,jdbcType=VARCHAR}, #{processDefId,jdbcType=VARCHAR}, #{currentTaskId,jdbcType=VARCHAR},
  136. #{currentUsers,jdbcType=VARCHAR}, #{currentTaskName,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
  137. #{dateCreate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{dateUpdate,jdbcType=TIMESTAMP},
  138. #{geo,jdbcType=VARCHAR},#{videos,jdbcType=VARCHAR},#{pictures,jdbcType=VARCHAR})
  139. </insert>
  140. <insert id="insertSelective" parameterType="com.huaxu.order.entity.WorkOrderManage" keyProperty="id" useGeneratedKeys="true">
  141. insert into sc_work_order_manage
  142. <trim prefix="(" suffix=")" suffixOverrides="," >
  143. <if test="id != null" >
  144. id,
  145. </if>
  146. <if test="taskNo != null" >
  147. task_no,
  148. </if>
  149. <if test="taskDesc != null" >
  150. task_desc,
  151. </if>
  152. <if test="orderUserId != null" >
  153. order_user_id,
  154. </if>
  155. <if test="sendTime != null" >
  156. send_time,
  157. </if>
  158. <if test="sendBy != null" >
  159. send_by,
  160. </if>
  161. <if test="planFinishDate != null" >
  162. plan_finish_date,
  163. </if>
  164. <if test="finishDate != null" >
  165. finish_date,
  166. </if>
  167. <if test="dateLimit != null" >
  168. date_limit,
  169. </if>
  170. <if test="urgency != null" >
  171. urgency,
  172. </if>
  173. <if test="address != null" >
  174. address,
  175. </if>
  176. <if test="contactUser != null" >
  177. contact_user,
  178. </if>
  179. <if test="contactPhone != null" >
  180. contact_phone,
  181. </if>
  182. <if test="orderTime != null" >
  183. order_time,
  184. </if>
  185. <if test="companyOrgId != null" >
  186. company_org_id,
  187. </if>
  188. <if test="departmentOrgId != null" >
  189. department_org_id,
  190. </if>
  191. <if test="orderStatus != null" >
  192. order_status,
  193. </if>
  194. <if test="eventType != null" >
  195. event_type,
  196. </if>
  197. <if test="orderTypeId != null" >
  198. order_type_id,
  199. </if>
  200. <if test="orderPid != null" >
  201. order_pid,
  202. </if>
  203. <if test="tenantId != null" >
  204. tenant_id,
  205. </if>
  206. <if test="processInstanceId != null" >
  207. process_instance_id,
  208. </if>
  209. <if test="processDefId != null" >
  210. process_def_id,
  211. </if>
  212. <if test="currentTaskId != null" >
  213. current_task_id,
  214. </if>
  215. <if test="currentUsers != null" >
  216. current_users,
  217. </if>
  218. <if test="currentTaskName != null" >
  219. current_task_name,
  220. </if>
  221. <if test="createBy != null" >
  222. create_by,
  223. </if>
  224. <if test="dateCreate != null" >
  225. date_create,
  226. </if>
  227. <if test="updateBy != null" >
  228. update_by,
  229. </if>
  230. <if test="dateUpdate != null" >
  231. date_update,
  232. </if>
  233. <if test="geo != null" >
  234. geo,
  235. </if>
  236. <if test="videos != null" >
  237. videos,
  238. </if>
  239. <if test="pictures != null" >
  240. pictures,
  241. </if>
  242. <if test="deviceId != null" >
  243. device_id,
  244. </if>
  245. <if test="scenesId != null" >
  246. scenes_id,
  247. </if>
  248. <if test="deviceName != null" >
  249. device_name,
  250. </if>
  251. <if test="scenesName != null" >
  252. scenes_name,
  253. </if>
  254. </trim>
  255. <trim prefix="values (" suffix=")" suffixOverrides="," >
  256. <if test="id != null" >
  257. #{id,jdbcType=INTEGER},
  258. </if>
  259. <if test="taskNo != null" >
  260. #{taskNo,jdbcType=VARCHAR},
  261. </if>
  262. <if test="taskDesc != null" >
  263. #{taskDesc,jdbcType=VARCHAR},
  264. </if>
  265. <if test="orderUserId != null" >
  266. #{orderUserId,jdbcType=VARCHAR},
  267. </if>
  268. <if test="sendTime != null" >
  269. #{sendTime,jdbcType=TIMESTAMP},
  270. </if>
  271. <if test="sendBy != null" >
  272. #{sendBy,jdbcType=VARCHAR},
  273. </if>
  274. <if test="planFinishDate != null" >
  275. #{planFinishDate,jdbcType=TIMESTAMP},
  276. </if>
  277. <if test="finishDate != null" >
  278. #{finishDate,jdbcType=TIMESTAMP},
  279. </if>
  280. <if test="dateLimit != null" >
  281. #{dateLimit,jdbcType=VARCHAR},
  282. </if>
  283. <if test="urgency != null" >
  284. #{urgency,jdbcType=VARCHAR},
  285. </if>
  286. <if test="address != null" >
  287. #{address,jdbcType=VARCHAR},
  288. </if>
  289. <if test="contactUser != null" >
  290. #{contactUser,jdbcType=VARCHAR},
  291. </if>
  292. <if test="contactPhone != null" >
  293. #{contactPhone,jdbcType=VARCHAR},
  294. </if>
  295. <if test="orderTime != null" >
  296. #{orderTime,jdbcType=VARCHAR},
  297. </if>
  298. <if test="companyOrgId != null" >
  299. #{companyOrgId,jdbcType=VARCHAR},
  300. </if>
  301. <if test="departmentOrgId != null" >
  302. #{departmentOrgId,jdbcType=VARCHAR},
  303. </if>
  304. <if test="orderStatus != null" >
  305. #{orderStatus,jdbcType=INTEGER},
  306. </if>
  307. <if test="eventType != null" >
  308. #{eventType,jdbcType=INTEGER},
  309. </if>
  310. <if test="orderTypeId != null" >
  311. #{orderTypeId,jdbcType=INTEGER},
  312. </if>
  313. <if test="orderPid != null" >
  314. #{orderPid,jdbcType=VARCHAR},
  315. </if>
  316. <if test="tenantId != null" >
  317. #{tenantId,jdbcType=VARCHAR},
  318. </if>
  319. <if test="processInstanceId != null" >
  320. #{processInstanceId,jdbcType=VARCHAR},
  321. </if>
  322. <if test="processDefId != null" >
  323. #{processDefId,jdbcType=VARCHAR},
  324. </if>
  325. <if test="currentTaskId != null" >
  326. #{currentTaskId,jdbcType=VARCHAR},
  327. </if>
  328. <if test="currentUsers != null" >
  329. #{currentUsers,jdbcType=VARCHAR},
  330. </if>
  331. <if test="currentTaskName != null" >
  332. #{currentTaskName,jdbcType=VARCHAR},
  333. </if>
  334. <if test="createBy != null" >
  335. #{createBy,jdbcType=VARCHAR},
  336. </if>
  337. <if test="dateCreate != null" >
  338. #{dateCreate,jdbcType=TIMESTAMP},
  339. </if>
  340. <if test="updateBy != null" >
  341. #{updateBy,jdbcType=VARCHAR},
  342. </if>
  343. <if test="dateUpdate != null" >
  344. #{dateUpdate,jdbcType=TIMESTAMP},
  345. </if>
  346. <if test="geo != null" >
  347. #{geo,jdbcType=VARCHAR},
  348. </if>
  349. <if test="videos != null" >
  350. #{videos,jdbcType=VARCHAR},
  351. </if>
  352. <if test="pictures != null" >
  353. #{pictures,jdbcType=VARCHAR},
  354. </if>
  355. <if test="deviceId != null" >
  356. #{deviceId,jdbcType=INTEGER},
  357. </if>
  358. <if test="scenesId != null" >
  359. #{scenesId,jdbcType=INTEGER},
  360. </if>
  361. <if test="deviceName != null" >
  362. #{deviceName,jdbcType=VARCHAR},
  363. </if>
  364. <if test="scenesName != null" >
  365. #{scenesName,jdbcType=VARCHAR},
  366. </if>
  367. </trim>
  368. </insert>
  369. <update id="updateByPrimaryKeySelective" parameterType="com.huaxu.order.entity.WorkOrderManage" >
  370. update sc_work_order_manage
  371. <set >
  372. <if test="taskNo != null" >
  373. task_no = #{taskNo,jdbcType=VARCHAR},
  374. </if>
  375. <if test="taskDesc != null" >
  376. task_desc = #{taskDesc,jdbcType=VARCHAR},
  377. </if>
  378. <if test="orderUserId != null" >
  379. order_user_id = #{orderUserId,jdbcType=VARCHAR},
  380. </if>
  381. <if test="sendTime != null" >
  382. send_time = #{sendTime,jdbcType=TIMESTAMP},
  383. </if>
  384. <if test="sendBy != null" >
  385. send_by = #{sendBy,jdbcType=VARCHAR},
  386. </if>
  387. <if test="planFinishDate != null" >
  388. plan_finish_date = #{planFinishDate,jdbcType=TIMESTAMP},
  389. </if>
  390. <if test="finishDate != null" >
  391. finish_date = #{finishDate,jdbcType=TIMESTAMP},
  392. </if>
  393. <if test="dateLimit != null" >
  394. date_limit = #{dateLimit,jdbcType=VARCHAR},
  395. </if>
  396. <if test="urgency != null" >
  397. urgency = #{urgency,jdbcType=VARCHAR},
  398. </if>
  399. <if test="address != null" >
  400. address = #{address,jdbcType=VARCHAR},
  401. </if>
  402. <if test="contactUser != null" >
  403. contact_user = #{contactUser,jdbcType=VARCHAR},
  404. </if>
  405. <if test="contactPhone != null" >
  406. contact_phone = #{contactPhone,jdbcType=VARCHAR},
  407. </if>
  408. <if test="orderTime != null" >
  409. order_time = #{orderTime,jdbcType=VARCHAR},
  410. </if>
  411. <if test="companyOrgId != null" >
  412. company_org_id = #{companyOrgId,jdbcType=VARCHAR},
  413. </if>
  414. <if test="departmentOrgId != null" >
  415. department_org_id = #{departmentOrgId,jdbcType=VARCHAR},
  416. </if>
  417. <if test="orderStatus != null" >
  418. order_status = #{orderStatus,jdbcType=INTEGER},
  419. </if>
  420. <if test="eventType != null" >
  421. event_type = #{eventType,jdbcType=INTEGER},
  422. </if>
  423. <if test="orderTypeId != null" >
  424. order_type_id = #{orderTypeId,jdbcType=INTEGER},
  425. </if>
  426. <if test="orderPid != null" >
  427. order_pid = #{orderPid,jdbcType=VARCHAR},
  428. </if>
  429. <if test="tenantId != null" >
  430. tenant_id = #{tenantId,jdbcType=VARCHAR},
  431. </if>
  432. <if test="processInstanceId != null" >
  433. process_instance_id = #{processInstanceId,jdbcType=VARCHAR},
  434. </if>
  435. <if test="processDefId != null" >
  436. process_def_id = #{processDefId,jdbcType=VARCHAR},
  437. </if>
  438. <if test="currentTaskId != null" >
  439. current_task_id = #{currentTaskId,jdbcType=VARCHAR},
  440. </if>
  441. <if test="currentUsers != null" >
  442. current_users = #{currentUsers,jdbcType=VARCHAR},
  443. </if>
  444. <if test="currentTaskName != null" >
  445. current_task_name = #{currentTaskName,jdbcType=VARCHAR},
  446. </if>
  447. <if test="createBy != null" >
  448. create_by = #{createBy,jdbcType=VARCHAR},
  449. </if>
  450. <if test="dateCreate != null" >
  451. date_create = #{dateCreate,jdbcType=TIMESTAMP},
  452. </if>
  453. <if test="updateBy != null" >
  454. update_by = #{updateBy,jdbcType=VARCHAR},
  455. </if>
  456. <if test="dateUpdate != null" >
  457. date_update = #{dateUpdate,jdbcType=TIMESTAMP},
  458. </if>
  459. <if test="geo != null" >
  460. geo = #{geo,jdbcType=VARCHAR},
  461. </if>
  462. <if test="videos != null" >
  463. videos=#{videos,jdbcType=VARCHAR},
  464. </if>
  465. <if test="pictures != null" >
  466. pictures=#{pictures,jdbcType=VARCHAR},
  467. </if>
  468. <if test="inProcessStatus != null" >
  469. in_process_status=#{inProcessStatus,jdbcType=INTEGER},
  470. </if>
  471. </set>
  472. where id = #{id,jdbcType=INTEGER}
  473. </update>
  474. <update id="updateByPrimaryKey" parameterType="com.huaxu.order.entity.WorkOrderManage" >
  475. update sc_work_order_manage
  476. set task_no = #{taskNo,jdbcType=VARCHAR},
  477. task_desc = #{taskDesc,jdbcType=VARCHAR},
  478. order_user_id = #{orderUserId,jdbcType=VARCHAR},
  479. send_time = #{sendTime,jdbcType=TIMESTAMP},
  480. send_by = #{sendBy,jdbcType=VARCHAR},
  481. plan_finish_date = #{planFinishDate,jdbcType=TIMESTAMP},
  482. finish_date = #{finishDate,jdbcType=TIMESTAMP},
  483. date_limit = #{dateLimit,jdbcType=VARCHAR},
  484. urgency = #{urgency,jdbcType=VARCHAR},
  485. address = #{address,jdbcType=VARCHAR},
  486. contact_user = #{contactUser,jdbcType=VARCHAR},
  487. contact_phone = #{contactPhone,jdbcType=VARCHAR},
  488. order_time = #{orderTime,jdbcType=VARCHAR},
  489. company_org_id = #{companyOrgId,jdbcType=VARCHAR},
  490. department_org_id = #{departmentOrgId,jdbcType=VARCHAR},
  491. order_status = #{orderStatus,jdbcType=INTEGER},
  492. event_type = #{eventType,jdbcType=INTEGER},
  493. order_type_id = #{orderTypeId,jdbcType=INTEGER},
  494. order_pid = #{orderPid,jdbcType=VARCHAR},
  495. tenant_id = #{tenantId,jdbcType=VARCHAR},
  496. process_instance_id = #{processInstanceId,jdbcType=VARCHAR},
  497. process_def_id = #{processDefId,jdbcType=VARCHAR},
  498. current_task_id = #{currentTaskId,jdbcType=VARCHAR},
  499. current_users = #{currentUsers,jdbcType=VARCHAR},
  500. current_task_name = #{currentTaskName,jdbcType=VARCHAR},
  501. create_by = #{createBy,jdbcType=VARCHAR},
  502. date_create = #{dateCreate,jdbcType=TIMESTAMP},
  503. update_by = #{updateBy,jdbcType=VARCHAR},
  504. date_update = #{dateUpdate,jdbcType=TIMESTAMP},
  505. geo = #{geo,jdbcType=VARCHAR},
  506. videos = #{videos,jdbcType=VARCHAR},
  507. pictures = #{pictures,jdbcType=VARCHAR},
  508. in_process_status=#{inProcessStatus,jdbcType=INTEGER}
  509. where id = #{id,jdbcType=INTEGER}
  510. </update>
  511. <select id="selectAppTodo" resultMap="BaseResultMap">
  512. select id,task_no,send_time,address,order_type_id,create_by,update_by,task_desc,order_status,current_task_name,in_process_status
  513. from sc_work_order_manage
  514. where find_in_set(#{userId},current_users) and tenant_id = #{tenantId}
  515. union
  516. select id,plan_id,plan_date,task_area_name,task_type,create_by,update_by,task_content,plan_status,current_task_name,in_process_status
  517. from sc_plan_manage
  518. where find_in_set(#{userId},current_users) and tenant_id = #{tenantId}
  519. order by send_time desc
  520. </select>
  521. <select id="selectAppAll" resultMap="BaseResultMap">
  522. select distinct t1.id,task_no,send_time,address,order_type_id,current_task_name,t1.create_by,t1.update_by,task_desc,order_status,in_process_status
  523. from sc_work_order_manage t1
  524. left join sc_work_flow_log t2 ON t1.id=t2.flow_id and flow_type=2 and find_in_set(#{userId},handle_user_id) and left(flow_result,2)='拒单'
  525. where (find_in_set(#{userId},current_users)
  526. or t1.id in(select flow_id from sc_work_flow_log where flow_type=2 and find_in_set(#{userId},handle_user_id)))
  527. and tenant_id = #{tenantId}
  528. and (t2.id is null or t1.order_user_id=t2.handle_user_id)
  529. union
  530. select id,plan_id,plan_date,task_area_name,task_type,current_task_name,create_by,update_by,task_content,plan_status,in_process_status
  531. from sc_plan_manage
  532. where (find_in_set(#{userId},current_users)
  533. or id in(select flow_id from sc_work_flow_log where flow_type=1 and find_in_set(#{userId},handle_user_id)))
  534. and tenant_id = #{tenantId}
  535. order by send_time desc
  536. </select>
  537. <select id="selectOrderDetail" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  538. select t1.*,t2.flow_detail
  539. from sc_work_order_manage t1
  540. left join sc_work_flow_detail t2 on t1.id=t2.flow_id and t2.flow_type=2
  541. where t1.id = #{id,jdbcType=INTEGER} or t1.order_pid = #{orderPid,jdbcType=INTEGER}
  542. order by t1.order_pid
  543. </select>
  544. <insert id="batchInsertByAlarms" >
  545. insert into sc_work_order_manage( task_no, task_desc, address, order_time, company_org_id, department_org_id, order_status, event_type, order_pid, tenant_id, current_task_name, date_create, date_update, geo,scenes_id,scenes_name,device_id,device_name)
  546. values
  547. <foreach collection="workOrderManages" item="item" index="index" separator=",">
  548. (#{item.taskNo} , #{item.taskDesc}, #{item.address}, #{item.orderTime}, #{item.companyOrgId}, #{item.departmentOrgId}, 0, 3, 0, #{item.tenantId}, '设备报警工单', now(), now(), #{item.geo}, #{item.parentSceneId}, #{item.parentSceneName}, #{item.deviceId}, #{item.deviceName})
  549. </foreach>
  550. </insert>
  551. <delete id="batchDeleteByAlarms" >
  552. delete from sc_work_order_manage
  553. where order_status = 0 and device_id in
  554. <foreach collection="deviceIds" item="item" open="(" close=")" index="index" separator=",">
  555. #{item}
  556. </foreach>
  557. </delete>
  558. <select id="findWorkOrderByDeviceIds" resultType="com.huaxu.order.dto.WorkOrderManageByAlarmDto">
  559. select
  560. id
  561. ,device_id as "deviceId"
  562. , task_desc as "taskDesc"
  563. , order_status as "orderStatus"
  564. from sc_work_order_manage
  565. where (order_status = 0 or order_status = 1)
  566. and device_id in
  567. <foreach collection="deviceIds" item="item" open="(" close=")" index="index" separator=",">
  568. #{item}
  569. </foreach>
  570. </select>
  571. <update id="updateByAlarms">
  572. update sc_work_order_manage set task_desc =#{workOrderManage.taskDesc} ,date_update = now() where id=#{workOrderManage.id}
  573. </update>
  574. <select id="findByNo" resultMap="OrderResultMap">
  575. select
  576. t1.id, t1.task_no, t1.task_desc, t1.order_user_id, t1.send_time, t1.send_by, t1.plan_finish_date, t1.finish_date,
  577. t1.date_limit, t1.urgency, t1.address, t1.contact_user, t1.contact_phone, t1.order_time, t1.company_org_id,
  578. t1.department_org_id, t1.order_status, t1.event_type,case when t1.event_type=1 then '运维上报' when t1.event_type=2 then '用户上报' when t1.event_type=3 then '设备告警' end event_type_name,
  579. t1.order_type_id, t1.order_pid, t1.tenant_id,
  580. t1.process_instance_id, t1.process_def_id, t1.current_task_id, t1.current_users, t1.current_task_name,
  581. t1.create_by, t1.date_create, t1.update_by, t1.date_update, t1.geo,t1.videos,t1.pictures,
  582. t1.device_id, t1.scenes_id, t1.device_name, t1.scenes_name,
  583. t2.flow_detail,t2.create_by detail_create_by,t2.date_create detail_date_create,t2.update_by detail_update_by,t2.date_update detail_date_update
  584. from sc_work_order_manage t1 left join sc_work_flow_detail t2
  585. on t1.id = t2.flow_id and t2.flow_type=2
  586. <where>
  587. <if test="order.taskNo != null and order.taskNo != ''">
  588. and t1.task_no = #{order.taskNo}
  589. </if>
  590. </where>
  591. </select>
  592. <!--分页查询-->
  593. <select id="findPage" resultMap="OrderResultMap">
  594. select
  595. t1.id, t1.task_no, t1.task_desc, t1.order_user_id, t1.send_time, t1.send_by, t1.plan_finish_date, t1.finish_date,
  596. t1.date_limit, t1.urgency, t1.address, t1.contact_user, t1.contact_phone, t1.order_time, t1.company_org_id,
  597. t1.department_org_id, t1.order_status, t1.event_type,case when t1.event_type=1 then '运维上报' when t1.event_type=2 then '用户上报' when t1.event_type=3 then '设备告警' end event_type_name,
  598. t1.order_type_id, t1.order_pid, t1.tenant_id,
  599. t1.process_instance_id, t1.process_def_id, t1.current_task_id, t1.current_users, t1.current_task_name,
  600. t1.create_by, t1.date_create, t1.update_by, t1.date_update, t1.geo,t1.videos,t1.pictures,
  601. t1.device_id, t1.scenes_id, t1.device_name, t1.scenes_name,
  602. t2.flow_detail,t2.create_by detail_create_by,t2.date_create detail_date_create,t2.update_by detail_update_by,t2.date_update detail_date_update
  603. from sc_work_order_manage t1 left join sc_work_flow_detail t2
  604. on t1.id = t2.flow_id and t2.flow_type=2
  605. <where>
  606. <if test="order.tenantId != null and order.tenantId != ''">
  607. and t1.tenant_id = #{order.tenantId}
  608. </if>
  609. <if test="order.taskNo != null and order.taskNo != ''">
  610. and t1.task_no like CONCAT('%',#{order.taskNo},'%')
  611. </if>
  612. <if test="order.orderPid != null">
  613. and t1.order_pid = #{order.orderPid,jdbcType=INTEGER}
  614. </if>
  615. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  616. <if test="order.permissonType == 5 or order.permissonType == 2">
  617. and ( t1.department_org_id in
  618. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  619. #{item.orgId}
  620. </foreach>
  621. or
  622. t1.COMPANY_ORG_ID in
  623. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  624. #{item.orgId}
  625. </foreach>
  626. )
  627. </if>
  628. <if test="order.permissonType == 4 or order.permissonType == 3">
  629. and t1.department_org_id in
  630. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  631. #{item.orgId}
  632. </foreach>
  633. </if>
  634. <if test="order.permissonType == 1">
  635. and t1.COMPANY_ORG_ID in
  636. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  637. #{item.orgId}
  638. </foreach>
  639. and (t1.department_org_id is null or t1.department_org_id =0)
  640. </if>
  641. </if>
  642. <if test="order.orderStatus != null">
  643. and t1.order_status = #{order.orderStatus,jdbcType=INTEGER}
  644. </if>
  645. <if test="order.orderStatus == null">
  646. and t1.order_status != 0
  647. </if>
  648. <if test="order.orderTypeId != null">
  649. and t1.order_type_id = #{order.orderTypeId,jdbcType=INTEGER}
  650. </if>
  651. <if test="order.eventType != null">
  652. and t1.event_type = #{order.eventType,jdbcType=INTEGER}
  653. </if>
  654. <if test="order.currentUsers != null">
  655. and FIND_IN_SET(#{order.currentUsers,jdbcType=VARCHAR},t1.current_users)
  656. </if>
  657. <if test="order.startDate != null and order.endDate != null">
  658. <if test="order.orderStatus == 0">
  659. and t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  660. and t1.date_create &lt;= DATE_ADD(date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d'),INTERVAL 1 DAY)
  661. order by t1.date_create desc
  662. </if>
  663. <if test="order.orderStatus != 0">
  664. and t1.send_time &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  665. and t1.send_time &lt;= DATE_ADD(date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d'),INTERVAL 1 DAY)
  666. order by t1.send_time desc
  667. </if>
  668. </if>
  669. <if test="order.startDate == null and order.endDate == null">
  670. order by t1.send_time desc
  671. </if>
  672. </where>
  673. </select>
  674. <!--删除-->
  675. <delete id="batchDelete">
  676. delete from sc_work_order_manage
  677. where order_status = 0
  678. and id in
  679. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  680. #{item}
  681. </foreach>
  682. </delete>
  683. <!--根据orderPid 查询工单-->
  684. <select id="selectByPId" parameterType="map" resultMap="BaseResultMap">
  685. select
  686. <include refid="Base_Column_List"></include>
  687. from sc_work_order_manage
  688. where order_pid = #{orderPid,jdbcType=VARCHAR}
  689. </select>
  690. <!--查询工单派单时的用户状态-->
  691. <select id="selectOrderUserStatus" parameterType="java.lang.String" resultType="map">
  692. SELECT DISTINCT X, Y,
  693. CASE WHEN S IS NULL THEN '空闲' WHEN S='0' THEN '空闲' ELSE '执行中' END S ,
  694. CASE WHEN offlinetime IS NULL THEN '离线' WHEN offlinetime>10 THEN '离线' WHEN offlinetime &lt;= 10 THEN '在线' END L
  695. FROM
  696. (
  697. select order_user_id,longtitude X, latitude Y, TIMESTAMPDIFF(second,upload_date, now()) offlinetime from sc_work_order_manage t1 left join sc_gps_data t2
  698. on t1.order_user_id = t2.user_id
  699. group by order_user_id,longtitude, latitude,upload_date
  700. ) a
  701. left join
  702. (
  703. select count(*) S,order_user_id from sc_work_order_manage
  704. where order_status = 1
  705. group by order_user_id
  706. ) b
  707. on a.order_user_id=b.order_user_id
  708. where a.order_user_id= #{userId,jdbcType=INTEGER}
  709. </select>
  710. <!--查询任务单派单时的用户状态-->
  711. <select id="selectPlanUserStatus" parameterType="java.lang.String" resultType="map">
  712. SELECT
  713. CASE WHEN S IS NULL THEN '空闲' WHEN S='0' THEN '空闲' ELSE '执行中' END S
  714. FROM (
  715. select count(*) S,user_id from sc_plan_manage
  716. where plan_status = 1
  717. group by user_id
  718. ) a
  719. where a.user_id= #{userId,jdbcType=INTEGER}
  720. </select>
  721. <!--查询维修列表的用户状态-->
  722. <select id="selectMaintainUserStatus" parameterType="java.lang.String" resultType="map">
  723. select distinct X, Y,
  724. case when offlinetime is null then '离线' when offlinetime>10 then '离线' when offlinetime &lt;= 10 THEN '在线' END L
  725. from (
  726. select longtitude X, latitude Y, TIMESTAMPDIFF(second,upload_date, now()) offlinetime from sc_gps_data
  727. where user_id= #{userId,jdbcType=INTEGER}
  728. ) a
  729. </select>
  730. <!--待处理权限-->
  731. <select id="selectPendingPower" resultType="java.lang.Integer" parameterType="map">
  732. select count(1) from sc_work_order_manage
  733. where id = #{id,jdbcType=INTEGER} and FIND_IN_SET(#{currentUsers,jdbcType=VARCHAR},current_users)
  734. </select>
  735. <!--综合展示-查询工单执行情况-->
  736. <select id="selectOrderStatus" resultMap="BaseResultMap" >
  737. select order_status_name,sum(order_count) order_count
  738. from(
  739. select order_status,count(1) order_count ,
  740. case when order_status=0 then '未派单' when order_status=1 or order_status=4 then '处理中' else '已完结' end order_status_name
  741. from sc_work_order_manage t1
  742. where
  743. <if test="statsType == null or statsType == 0">
  744. t1.date_create>=date_format(curdate(), '%Y-%m' )
  745. </if>
  746. <if test="statsType == 1">
  747. t1.date_create>=date_format(curdate(), '%Y-1-1' )
  748. </if>
  749. <if test="statsType == 2">
  750. t1.date_create>=date_sub(date_format(curdate(), '%Y-%m-1' ), interval 11 month)
  751. </if>
  752. <if test="tenantId != null and tenantId != ''">
  753. and t1.tenant_id=#{tenantId}
  754. </if>
  755. <if test="companyOrgId != null and companyOrgId !=''">
  756. and t1.company_org_id=#{companyOrgId}
  757. </if>
  758. <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
  759. <if test="permissonType == 5 or permissonType == 2">
  760. and ( t1.department_org_id in
  761. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  762. #{item.orgId}
  763. </foreach>
  764. or
  765. t1.COMPANY_ORG_ID in
  766. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  767. #{item.orgId}
  768. </foreach>
  769. )
  770. </if>
  771. <if test="permissonType == 4 or permissonType == 3">
  772. and t1.department_org_id in
  773. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  774. #{item.orgId}
  775. </foreach>
  776. </if>
  777. <if test="permissonType == 1">
  778. and t1.COMPANY_ORG_ID in
  779. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  780. #{item.orgId}
  781. </foreach>
  782. and (t1.department_org_id is null or t1.department_org_id =0)
  783. </if>
  784. </if>
  785. group by order_status
  786. )tab1
  787. group by order_status_name
  788. </select>
  789. <!--维修列表-工单情况(未派单,处理中)-->
  790. <select id="selectMaintainOrder" resultMap="BaseResultMap" >
  791. select t1.id ,t1.task_no, t1.address, t1.task_desc, t1.plan_finish_date, t1.date_create, t1.order_user_id, t2.flow_detail,
  792. case when t1.order_status=0 then '未派单' when t1.order_status =1 or t1.order_status=4 then '处理中' end order_status_name,
  793. case when t1.event_type=1 then '运维上报' when t1.event_type=2 then '用户上报' when t1.event_type=3 then '设备告警' end event_type_name,
  794. geo
  795. from sc_work_order_manage t1 left join sc_work_flow_detail t2 on t1.id=t2.flow_id and t2.flow_type=2
  796. <where>
  797. t1.order_status !=2 and t1.order_status !=3
  798. <if test="order.tenantId != null and order.tenantId != ''">
  799. and t1.tenant_id = #{order.tenantId}
  800. </if>
  801. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  802. <if test="order.permissonType == 5 or order.permissonType == 2">
  803. and ( t1.department_org_id in
  804. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  805. #{item.orgId}
  806. </foreach>
  807. or
  808. t1.COMPANY_ORG_ID in
  809. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  810. #{item.orgId}
  811. </foreach>
  812. )
  813. </if>
  814. <if test="order.permissonType == 4 or order.permissonType == 3">
  815. and t1.department_org_id in
  816. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  817. #{item.orgId}
  818. </foreach>
  819. </if>
  820. <if test="order.permissonType == 1">
  821. and t1.COMPANY_ORG_ID in
  822. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  823. #{item.orgId}
  824. </foreach>
  825. and (t1.department_org_id is null or t1.department_org_id =0)
  826. </if>
  827. </if>
  828. </where>
  829. order by t1.date_create desc
  830. </select>
  831. <!--App事件列表-->
  832. <select id="findEventListPage" resultMap="OrderResultMap">
  833. select
  834. t1.id, t1.task_no, t1.task_desc, t1.order_user_id, t1.send_time, t1.send_by, t1.plan_finish_date, t1.finish_date,
  835. t1.date_limit, t1.urgency, t1.address, t1.contact_user, t1.contact_phone, t1.order_time, t1.company_org_id,
  836. t1.department_org_id, t1.order_status, t1.event_type,case when t1.event_type=1 then '运维上报' when t1.event_type=2 then '用户上报' when t1.event_type=3 then '设备告警' end event_type_name,
  837. t1.order_type_id, t1.order_pid, t1.tenant_id,
  838. t1.process_instance_id, t1.process_def_id, t1.current_task_id, t1.current_users, t1.current_task_name,
  839. t1.create_by, t1.date_create, t1.update_by, t1.date_update, t1.geo,t1.videos,t1.pictures,
  840. t1.device_id, t1.scenes_id, t1.device_name, t1.scenes_name,
  841. t2.flow_detail,t2.create_by detail_create_by,t2.date_create detail_date_create,t2.update_by detail_update_by,t2.date_update detail_date_update
  842. from sc_work_order_manage t1 left join sc_work_flow_detail t2
  843. on t1.id = t2.flow_id and t2.flow_type=2
  844. <where>
  845. t1.event_type = 1 and t1.create_by = #{order.createBy}
  846. <if test="order.tenantId != null and order.tenantId != ''">
  847. and t1.tenant_id = #{order.tenantId}
  848. </if>
  849. <if test="order.departmentOrgId != null and order.departmentOrgId != ''">
  850. and t1.department_org_id = #{order.departmentOrgId}
  851. </if>
  852. order by t1.date_create desc
  853. </where>
  854. </select>
  855. <!--工单完成情况统计-->
  856. <select id="workOrderStatistics" resultType="map">
  857. select total 工单总数, finished 工单完成数, finished/total 工单完成率 from
  858. (
  859. select count(1) total,sum(case when order_status=2 then 1 when order_status =3 then 1 else 0 end) finished
  860. from sc_work_order_manage t1
  861. <where>
  862. t1.order_status != 0
  863. and t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  864. and t1.date_create &lt; date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d')
  865. <if test="order.tenantId != null and order.tenantId != ''">
  866. and t1.tenant_id = #{order.tenantId}
  867. </if>
  868. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  869. <if test="order.permissonType == 5 or order.permissonType == 2">
  870. and ( t1.department_org_id in
  871. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  872. #{item.orgId}
  873. </foreach>
  874. or
  875. t1.COMPANY_ORG_ID in
  876. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  877. #{item.orgId}
  878. </foreach>
  879. )
  880. </if>
  881. <if test="order.permissonType == 4 or order.permissonType == 3">
  882. and t1.department_org_id in
  883. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  884. #{item.orgId}
  885. </foreach>
  886. </if>
  887. <if test="order.permissonType == 1">
  888. and t1.COMPANY_ORG_ID in
  889. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  890. #{item.orgId}
  891. </foreach>
  892. and (t1.department_org_id is null or t1.department_org_id =0)
  893. </if>
  894. </if>
  895. </where>
  896. ) a
  897. </select>
  898. <!--事件数据月统计-->
  899. <select id="eventMonthStatistics" resultType="map">
  900. select count(1) 数量,date_format(date_create,'%Y-%m-%d') 日期
  901. from sc_work_order_manage t1
  902. <where>
  903. t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  904. and t1.date_create &lt; date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d')
  905. <if test="order.tenantId != null and order.tenantId != ''">
  906. and t1.tenant_id = #{order.tenantId}
  907. </if>
  908. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  909. <if test="order.permissonType == 5 or order.permissonType == 2">
  910. and ( t1.department_org_id in
  911. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  912. #{item.orgId}
  913. </foreach>
  914. or
  915. t1.COMPANY_ORG_ID in
  916. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  917. #{item.orgId}
  918. </foreach>
  919. )
  920. </if>
  921. <if test="order.permissonType == 4 or order.permissonType == 3">
  922. and t1.department_org_id in
  923. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  924. #{item.orgId}
  925. </foreach>
  926. </if>
  927. <if test="order.permissonType == 1">
  928. and t1.COMPANY_ORG_ID in
  929. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  930. #{item.orgId}
  931. </foreach>
  932. and (t1.department_org_id is null or t1.department_org_id =0)
  933. </if>
  934. </if>
  935. </where>
  936. group by date_format(date_create,'%Y-%m-%d')
  937. order by date_format(date_create,'%Y-%m-%d')
  938. </select>
  939. <!--事件数据年统计-->
  940. <select id="eventYearStatistics" resultType="map">
  941. select count(1) 数量,date_format(date_create,'%Y-%m') 日期
  942. from sc_work_order_manage t1
  943. <where>
  944. t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  945. and t1.date_create &lt; date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d')
  946. <if test="order.tenantId != null and order.tenantId != ''">
  947. and t1.tenant_id = #{order.tenantId}
  948. </if>
  949. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  950. <if test="order.permissonType == 5 or order.permissonType == 2">
  951. and ( t1.department_org_id in
  952. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  953. #{item.orgId}
  954. </foreach>
  955. or
  956. t1.COMPANY_ORG_ID in
  957. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  958. #{item.orgId}
  959. </foreach>
  960. )
  961. </if>
  962. <if test="order.permissonType == 4 or order.permissonType == 3">
  963. and t1.department_org_id in
  964. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  965. #{item.orgId}
  966. </foreach>
  967. </if>
  968. <if test="order.permissonType == 1">
  969. and t1.COMPANY_ORG_ID in
  970. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  971. #{item.orgId}
  972. </foreach>
  973. and (t1.department_org_id is null or t1.department_org_id =0)
  974. </if>
  975. </if>
  976. </where>
  977. group by date_format(date_create,'%Y-%m')
  978. order by date_format(date_create,'%Y-%m')
  979. </select>
  980. <!--上报类型统计-->
  981. <select id="reportStatistics" resultMap="StatisticsMap">
  982. select case when t1.event_type=1 then '运维上报' when t1.event_type=2 then '用户上报' when t1.event_type=3 then '设备告警' end statistics_name,
  983. count(*) statistics_value
  984. from sc_work_order_manage t1
  985. <where>
  986. t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  987. and t1.date_create &lt; date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d')
  988. <if test="order.tenantId != null and order.tenantId != ''">
  989. and t1.tenant_id = #{order.tenantId}
  990. </if>
  991. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  992. <if test="order.permissonType == 5 or order.permissonType == 2">
  993. and ( t1.department_org_id in
  994. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  995. #{item.orgId}
  996. </foreach>
  997. or
  998. t1.COMPANY_ORG_ID in
  999. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1000. #{item.orgId}
  1001. </foreach>
  1002. )
  1003. </if>
  1004. <if test="order.permissonType == 4 or order.permissonType == 3">
  1005. and t1.department_org_id in
  1006. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1007. #{item.orgId}
  1008. </foreach>
  1009. </if>
  1010. <if test="order.permissonType == 1">
  1011. and t1.COMPANY_ORG_ID in
  1012. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1013. #{item.orgId}
  1014. </foreach>
  1015. and (t1.department_org_id is null or t1.department_org_id =0)
  1016. </if>
  1017. </if>
  1018. </where>
  1019. group by t1.event_type
  1020. </select>
  1021. <!--工单状态统计-->
  1022. <select id="orderStatusStatistics" resultMap="StatisticsMap">
  1023. select 工单状态 statistics_name,sum(数量) statistics_value from
  1024. (
  1025. select case when t1.order_status=0 then '未派单' when t1.order_status=1 or t1.order_status=4 then '处理中'
  1026. when t1.order_status=2 then '已完成' when t1.order_status=3 then '终止' end 工单状态,count(*) 数量
  1027. from sc_work_order_manage t1
  1028. <where>
  1029. t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  1030. and t1.date_create &lt; date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d')
  1031. <if test="order.tenantId != null and order.tenantId != ''">
  1032. and t1.tenant_id = #{order.tenantId}
  1033. </if>
  1034. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  1035. <if test="order.permissonType == 5 or order.permissonType == 2">
  1036. and ( t1.department_org_id in
  1037. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1038. #{item.orgId}
  1039. </foreach>
  1040. or
  1041. t1.COMPANY_ORG_ID in
  1042. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1043. #{item.orgId}
  1044. </foreach>
  1045. )
  1046. </if>
  1047. <if test="order.permissonType == 4 or order.permissonType == 3">
  1048. and t1.department_org_id in
  1049. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1050. #{item.orgId}
  1051. </foreach>
  1052. </if>
  1053. <if test="order.permissonType == 1">
  1054. and t1.COMPANY_ORG_ID in
  1055. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1056. #{item.orgId}
  1057. </foreach>
  1058. and (t1.department_org_id is null or t1.department_org_id =0)
  1059. </if>
  1060. </if>
  1061. </where>
  1062. group by t1.order_status
  1063. ) a
  1064. group by 工单状态
  1065. </select>
  1066. <!--工单类型统计-->
  1067. <select id="orderTypeStatistics" resultMap="StatisticsMap">
  1068. select case when t1.order_type_id=1 then '表务工单' when t1.order_type_id=2 then '停通水工单'
  1069. when t1.order_type_id=3 then '抢修工单' when t1.order_type_id=4 then '漏点定位工单'
  1070. when t1.order_type_id=5 then '测漏工单' when t1.order_type_id=6 then '违章跑水工单'
  1071. when t1.order_type_id=10 then '压力调度工单' end statistics_name,
  1072. count(*) statistics_value
  1073. from sc_work_order_manage t1
  1074. <where>
  1075. t1.order_type_id>=1
  1076. and t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  1077. and t1.date_create &lt; date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d')
  1078. <if test="order.tenantId != null and order.tenantId != ''">
  1079. and t1.tenant_id = #{order.tenantId}
  1080. </if>
  1081. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  1082. <if test="order.permissonType == 5 or order.permissonType == 2">
  1083. and ( t1.department_org_id in
  1084. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1085. #{item.orgId}
  1086. </foreach>
  1087. or
  1088. t1.COMPANY_ORG_ID in
  1089. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1090. #{item.orgId}
  1091. </foreach>
  1092. )
  1093. </if>
  1094. <if test="order.permissonType == 4 or order.permissonType == 3">
  1095. and t1.department_org_id in
  1096. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1097. #{item.orgId}
  1098. </foreach>
  1099. </if>
  1100. <if test="order.permissonType == 1">
  1101. and t1.COMPANY_ORG_ID in
  1102. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1103. #{item.orgId}
  1104. </foreach>
  1105. and (t1.department_org_id is null or t1.department_org_id =0)
  1106. </if>
  1107. </if>
  1108. </where>
  1109. group by t1.order_type_id
  1110. </select>
  1111. <!--工单时长统计-->
  1112. <select id="orderDurationStatistics" resultMap="StatisticsMap">
  1113. select count(*) statistics_value,duration statistics_name from(
  1114. select case when duration&lt;=1 then 1 when duration>1 and duration&lt;=2 then 2
  1115. when duration>2 and duration&lt;=3 then 3 when duration>3 and duration&lt;=4 then 4
  1116. else 5 end duration
  1117. from
  1118. (
  1119. select TIMESTAMPDIFF(DAY,date_create,finish_date) duration
  1120. from sc_work_order_manage t1
  1121. <where>
  1122. (t1.order_status=2 or t1.order_status=3)
  1123. and t1.date_create &gt;= date_format(#{order.startDate,jdbcType=VARCHAR},'%Y-%m-%d')
  1124. and t1.date_create &lt; date_format(#{order.endDate,jdbcType=VARCHAR},'%Y-%m-%d')
  1125. <if test="order.tenantId != null and order.tenantId != ''">
  1126. and t1.tenant_id = #{order.tenantId}
  1127. </if>
  1128. <if test="order.userType!=null and order.userType!=-999 and order.userType!=-9999 and order.programItems != null and order.programItems.size() > 0">
  1129. <if test="order.permissonType == 5 or order.permissonType == 2">
  1130. and ( t1.department_org_id in
  1131. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1132. #{item.orgId}
  1133. </foreach>
  1134. or
  1135. t1.COMPANY_ORG_ID in
  1136. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1137. #{item.orgId}
  1138. </foreach>
  1139. )
  1140. </if>
  1141. <if test="order.permissonType == 4 or order.permissonType == 3">
  1142. and t1.department_org_id in
  1143. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1144. #{item.orgId}
  1145. </foreach>
  1146. </if>
  1147. <if test="order.permissonType == 1">
  1148. and t1.COMPANY_ORG_ID in
  1149. <foreach collection="order.programItems" item="item" open="(" close=")" separator=",">
  1150. #{item.orgId}
  1151. </foreach>
  1152. and (t1.department_org_id is null or t1.department_org_id =0)
  1153. </if>
  1154. </if>
  1155. </where>
  1156. )a ) b
  1157. group by duration
  1158. </select>
  1159. <select id="selectByTime" resultMap="BaseResultMap">
  1160. select distinct t1.id,task_no,send_time,address,order_type_id,current_task_name,t1.create_by,t1.update_by,task_desc,order_status,in_process_status,t1.plan_finish_date,t1.finish_date,t1.date_create,t1.date_limit
  1161. from sc_work_order_manage t1
  1162. left join sc_work_flow_log t2 ON t1.id=t2.flow_id and flow_type=2 and find_in_set(#{userId},handle_user_id) and left(flow_result,2)='拒单'
  1163. where (find_in_set(#{userId},current_users)
  1164. or t1.id in(select flow_id from sc_work_flow_log where flow_type=2 and find_in_set(#{userId},handle_user_id)))
  1165. and tenant_id = #{tenantId}
  1166. and (t2.id is null or t1.order_user_id=t2.handle_user_id)
  1167. and t1.date_create between #{startTime} and #{endTime}
  1168. union
  1169. select id,plan_id,plan_date,task_area_name,task_type,current_task_name,create_by,update_by,task_content,plan_status,in_process_status,plan_end_date,finish_date,date_create,"0"
  1170. from sc_plan_manage
  1171. where (find_in_set(#{userId},current_users)
  1172. or id in(select flow_id from sc_work_flow_log where flow_type=1 and find_in_set(#{userId},handle_user_id)))
  1173. and tenant_id = #{tenantId}
  1174. and date_create between #{startTime} and #{endTime}
  1175. order by send_time desc
  1176. </select>
  1177. </mapper>