WXDao_getTaskResult.sql 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. select
  2. task.id id,
  3. task.code code,
  4. task.name name,
  5. task.description description,
  6. planstarttime,
  7. planendtime,
  8. exestarttime,
  9. exeendtime,
  10. closemsg,
  11. submittime,
  12. dispatchtime,
  13. source.typename source,
  14. tasktype.typename tasktype,
  15. task.owner,
  16. buser.realname ownername,
  17. task.projectid,
  18. dept.description projectname,
  19. task.executer,
  20. taskstatus
  21. from p_projecttask task
  22. left join t_s_depart dept on task.projectid = dept.id
  23. left join t_s_type source on task.sourcetype = source.typecode and source.typegroupid in (select id from t_s_typegroup where typegroupcode = 'tasksourcetype')
  24. left join t_s_type tasktype on task.tasktype = tasktype.typecode and tasktype.typegroupid in (select id from t_s_typegroup where typegroupcode = 'tasktype')
  25. left join t_s_base_user buser on task.owner = buser.id
  26. where 1 = 1
  27. <#if projectid ?exists && projectid ?length gt 0>
  28. and task.projectid = :projectid
  29. </#if>
  30. <#if openid ?exists && openid ?length gt 0>
  31. and owner in (select id from t_s_user where openid = :openid)
  32. </#if>
  33. <#if qrydate ?exists && qrydate ?length gt 0>
  34. and left(planendtime,10) = :qrydate
  35. </#if>
  36. <#if taskid ?exists && taskid ?length gt 0>
  37. and task.id = :taskid
  38. </#if>
  39. union all
  40. select
  41. task.id id,
  42. task.code code,
  43. task.name name,
  44. task.description description,
  45. planstarttime,
  46. planendtime,
  47. exestarttime,
  48. exeendtime,
  49. closemsg,
  50. submittime,
  51. dispatchtime,
  52. source.typename source,
  53. tasktype.typename tasktype,
  54. task.owner,
  55. buser.realname ownername,
  56. task.projectid,
  57. dept.description projectname,
  58. task.executer,
  59. taskstatus
  60. from p_projecttask task
  61. left join t_s_depart dept on task.projectid = dept.id
  62. left join t_s_type source on task.sourcetype = source.typecode and source.typegroupid in (select id from t_s_typegroup where typegroupcode = 'tasksourcetype')
  63. left join t_s_type tasktype on task.tasktype = tasktype.typecode and tasktype.typegroupid in (select id from t_s_typegroup where typegroupcode = 'tasktype')
  64. left join t_s_base_user buser on task.owner = buser.id
  65. where 1 = 1
  66. <#if projectid ?exists && projectid ?length gt 0>
  67. and task.projectid = :projectid
  68. </#if>
  69. <#if openid ?exists && openid ?length gt 0>
  70. and owner in (select id from t_s_user where openid = :openid)
  71. </#if>
  72. <#if qrydate ?exists && qrydate ?length gt 0>
  73. and left(planendtime,10) < :qrydate
  74. </#if>
  75. <#if taskid ?exists && taskid ?length gt 0>
  76. and task.id = :taskid
  77. </#if>
  78. and taskstatus in ('0','1')