selectDB.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. import en from "@/locales/bpmn-js/en"
  2. /* 统计的合格率配置信息, 如公正性, 一年需要完成4次, 当前完成2次的话,则为50%完成率。 */
  3. export const getConfig = (begin,end)=>{
  4. return "select * FROM t_tjpzb"
  5. }
  6. export const getJiaoYanObj = (end)=>{
  7. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  8. return "select a.t_mjsbjdxzjhzbZhName, a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,ifnull(b.t_mjsbjdxzjhzbS,0) as t_mjsbjdxzjhzbS FROM (select t_sbdj.she_bei_shi_bie_h as t_mjsbjdxzjhzbZhName, t_mjsbjdxzjhzb.she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(t_mjsbjdxzjhzb.she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb LEFT JOIN t_sbdj on t_mjsbjdxzjhzb.she_bei_bian_hao_ = t_sbdj.id_ where YEAR(t_mjsbjdxzjhzb.create_time_)="+end+" GROUP BY t_mjsbjdxzjhzb.she_bei_ming_chen HAVING COUNT(t_mjsbjdxzjhzb.she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= "+end+" AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  9. }
  10. export const gethechaObj = (end)=>{
  11. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  12. return "select a.t_sbhcjlbZhname, a.t_sbhcjlbName, a.t_sbhcjlb, ifnull( b.t_sbhcjlbS, 0 ) AS t_sbhcjlbS FROM ( SELECT t_sbdj.she_bei_ming_cheng_ AS t_sbhcjlbZhname, t_sbdj.she_bei_shi_bie_h AS t_sbhcjlbName, COUNT( t_yqsbhcjh.yi_qi_she_bei_min ) AS t_sbhcjlb FROM t_yqsbhcjh LEFT JOIN t_sbdj ON t_yqsbhcjh.yi_qi_she_bei_min = t_sbdj.id_ WHERE YEAR ( t_yqsbhcjh.he_cha_pin_lv_ )= "+end+" GROUP BY t_yqsbhcjh.yi_qi_she_bei_min HAVING COUNT( t_yqsbhcjh.yi_qi_she_bei_min )>= 1 ) AS a LEFT JOIN ( SELECT shi_bie_hao_, COUNT( shi_bie_hao_ ) AS t_sbhcjlbS FROM t_sbhcjlb WHERE YEAR ( he_cha_ri_qi_ )= "+end+" GROUP BY shi_bie_hao_ HAVING COUNT( shi_bie_hao_ )>= 1 ) AS b ON a.t_sbhcjlbName = b.shi_bie_hao_ UNION SELECT t_sbdj.she_bei_ming_cheng_ AS t_sbhcjlbZhname, t_sbhcjlb.shi_bie_hao_ AS t_sbhcjlbName,IF ( t_sbhcjlb.id_, 0, 1 ) AS t_sbhcjlb,IF ( YEAR ( t_sbhcjlb.he_cha_ri_qi_ )= YEAR ( t_sbhcjlb.xia_ci_he_cha_ri_ ), COUNT( t_sbhcjlb.shi_bie_hao_ )+ 1, COUNT( t_sbhcjlb.shi_bie_hao_ )) AS t_sbhcjlbS FROM t_sbhcjlb LEFT JOIN t_sbdj ON t_sbhcjlb.shi_bie_hao_ = t_sbdj.she_bei_shi_bie_h WHERE YEAR ( t_sbhcjlb.he_cha_ri_qi_ )= "+end+" GROUP BY t_sbhcjlb.shi_bie_hao_ HAVING COUNT( t_sbhcjlb.shi_bie_hao_ )>=1"
  13. }
  14. export const getnengliObj = (end)=>{
  15. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  16. return "select a.enname,ifnull(a.num,0) as num, ifnull(b.num,0) as numS from(select jian_ce_biao_zhun as enname, COUNT(jian_ce_biao_zhun) as num from t_ndnlyzsysjbdjhzb where YEAR(yu_ji_shi_jian_)="+end+" GROUP BY jian_ce_biao_zhun HAVING COUNT(jian_ce_biao_zhun)>=1) as a LEFT JOIN (select jian_ce_biao_zhun as enname, COUNT(jian_ce_biao_zhun) as num from t_ndnlyzsysjbdjhzb as c LEFT JOIN t_ndnlyzsysjbdjhb as d on c.parent_id_ = d.id_ where YEAR(c.create_time_)="+end+" and d.shi_fou_guo_shen_='1' GROUP BY jian_ce_biao_zhun HAVING COUNT(jian_ce_biao_zhun)>=1) as b on a.enname = b.enname"
  17. }
  18. export const getbiaozhunObj = (end)=>{
  19. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  20. return "select a.name as name, a.num ,IFNULL(b.numS,0) as numS from(select zhuan_huan_ as name, COUNT(zhuan_huan_) as num from t_bzwzqjhcjhzb where YEAR(create_time_)="+end+" GROUP BY zhuan_huan_ HAVING COUNT(zhuan_huan_)>=1) as a LEFT JOIN (select zhuan_huan_ as name, COUNT(zhuan_huan_) as numS from t_bzwzqjhcjhzb as c LEFT JOIN t_bzwzqjhcjhb as d on c.parent_id_ = d.id_ where YEAR(c.create_time_)="+end+" and d.shi_fou_guo_shen_='1' GROUP BY zhuan_huan_ HAVING COUNT(zhuan_huan_)>=1) as b on a.name = b.name"
  21. }
  22. export const getbiaozhunTObj = (end)=>{
  23. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  24. return "select MONTH(shi_shi_shi_jian_) as time from t_bzwzqjhcjhzb where YEAR(shi_shi_shi_jian_) ="+end+" ORDER BY shi_shi_shi_jian_ ASC LIMIT 1"
  25. }
  26. export const getbzJunZhuObj = (end)=>{
  27. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  28. return "select a.name as name, a.num ,IFNULL(b.numS,0) as numS from(select zhuan_huan_ as name, COUNT(zhuan_huan_) as num from t_bzjzhcjhzb where YEAR(create_time_)="+end+" GROUP BY zhuan_huan_ HAVING COUNT(zhuan_huan_)>=1) as a LEFT JOIN (select zhuan_huan_ as name, COUNT(zhuan_huan_) as numS from t_bzjzhcjhzb as c LEFT JOIN t_bzjzhcjhb as d on c.parent_id_ = d.id_ where YEAR(c.create_time_)="+end+" and d.shi_fou_guo_shen_='1' GROUP BY zhuan_huan_ HAVING COUNT(zhuan_huan_)>=1) as b on a.name = b.name"
  29. }
  30. export const getbzJunZhuTObj = (end)=>{
  31. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  32. return "select MONTH(shi_shi_shi_jian_) as time from t_bzjzhcjhzb where YEAR(shi_shi_shi_jian_) ="+end+" ORDER BY shi_shi_shi_jian_ ASC LIMIT 1"
  33. }
  34. export const getbzXiBaoObj = (end)=>{
  35. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  36. return "select a.name as name, a.num ,IFNULL(b.numS,0) as numS from(select zhuan_huan_ as name, COUNT(zhuan_huan_) as num from t_bzxbqjhcjhzbn where YEAR(create_time_)="+end+" GROUP BY zhuan_huan_ HAVING COUNT(zhuan_huan_)>=1) as a LEFT JOIN (select c.zhuan_huan_ as name, COUNT(c.zhuan_huan_) as numS from t_bzxbqjhcjhzbn as c LEFT JOIN t_bzxbqjhcjh as d on c.parent_id_ = d.id_ where YEAR(c.create_time_)="+end+" and d.shi_fou_guo_shen_='1' GROUP BY c.zhuan_huan_ HAVING COUNT(c.zhuan_huan_)>=1) as b on a.name = b.name"
  37. }
  38. export const getbzXiBaoTObj = (end)=>{
  39. // return "select a.t_mjsbjdxzjhzbName,a.t_mjsbjdxzjhzb,b.t_mjsbjdxzjhzbS FROM (select she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb from t_mjsbjdxzjhzb where YEAR(create_time_)='2022' GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1) as a left join (select she_bei_ming_chen, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS from t_mjsbjdxzjhzb where YEAR(create_time_)= '2022' AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 )as b on a.t_mjsbjdxzjhzbName=b.she_bei_ming_chen"
  40. return "select MONTH(shi_shi_shi_jian_) as time from t_bzxbqjhcjhzbn where YEAR(shi_shi_shi_jian_) ="+end+" ORDER BY shi_shi_shi_jian_ ASC LIMIT 1"
  41. }
  42. export const DBData = (begin,end,scope)=>{
  43. // return "select tt.*,cast(1-(t_gdyrqcwt4"+begin+"/t_gdyrqcwt"+begin+") AS decimal(32,2)) as t_gdyrqcwt6"+begin+
  44. // return "select tt.* "+
  45. // // ",cast(1-(t_gdyrqcwt4"+end+"/t_gdyrqcwt"+end+") AS decimal(32,2)) as t_gdyrqcwt6"+end+
  46. // // ",cast(1-(t_gdyrqcwt50"+begin+"/t_gdyrqcwt"+begin+") AS decimal(32,2)) as t_gdyrqcwt5"+begin+",cast(1-(t_gdyrqcwt50"+end+"/t_gdyrqcwt"+end+") AS decimal(32,2)) as t_gdyrqcwt5"+end+
  47. // // ",cast(ifnull(1-(t_gdyrqcwt2"+begin+"/t_gdyrqcwt"+begin+"),0)+0.01 AS decimal(32,2)) as t_myddc5"+begin+",cast(ifnull(1-(t_gdyrqcwt2"+end+"/t_gdyrqcwt"+end+"),0)+0.01 AS decimal(32,2)) as t_myddc5"+end+
  48. // // ",cast(ifnull(1-(t_gdyrqcwt3"+begin+"/t_gdyrqcwt"+begin+"),0)+0.01 AS decimal(32,2)) as t_myddc6"+begin+",cast(ifnull(1-(t_gdyrqcwt3"+end+"/t_gdyrqcwt"+end+"),0)+0.01 AS decimal(32,2)) as t_myddc6"+end+
  49. // // ",cast(ifnull((t_gdyrqcwt50"+begin+"/t_gdyrqcwt"+begin+"),0)+0.01 AS decimal(32,2)) as t_myddc4"+begin+",cast(ifnull((t_gdyrqcwt50"+end+"/t_gdyrqcwt"+end+"),0)+0.01 AS decimal(32,2)) as t_myddc4"+end+
  50. // " FROM("+s1jianCe(begin,end)+
  51. // " join "+s1renwu(begin,end,scope)+
  52. // " join "+s2jianCe(begin,end)+
  53. // " join "+s2manYiDu(begin,end,scope)+
  54. // " join "+s3tousu(begin,end,scope)+
  55. // " join "+s4renYuanPeiXun(begin,end,scope)+
  56. // " join "+s5renYuanJianDu(begin,end,scope)+
  57. // " join "+s6sheBeiWeiHu(begin,end)+
  58. // " join "+s7sheBeiJiaoZhun(begin,end)+
  59. // " join "+s8sheBeiHeCha(begin,end)+
  60. // ") tt"
  61. return "select tt.* "+
  62. " FROM("+s1jianCe(begin,end)+
  63. " join "+s1renwu(begin,end,scope)+
  64. " join "+s2jianCe(begin,end)+
  65. " join "+s2manYiDu(begin,end,scope)+
  66. " join "+s3tousu(begin,end,scope)+
  67. " join "+s4renYuanPeiXun(begin,end,scope)+
  68. " join "+s5renYuanJianDu(begin,end,scope)+
  69. " join "+s9neiBu(begin,end,scope)+
  70. " join "+s12fengXian(begin,end,scope)+
  71. " join "+s14bufuhexiang(begin,end,scope)+
  72. // " join "+s6sheBeiWeiHu(begin,end)+
  73. " join "+s7sheBeiJiaoZhun(begin,end)+
  74. // " join "+s8sheBeiHeCha(begin,end)+
  75. ") tt"
  76. }
  77. /* 拼接通用条件,选用 */
  78. function PAT(val){
  79. return "shi_fou_guo_shen_ = '1' AND YEAR ( create_time_ ) = '" + val+"'"
  80. }
  81. function PAT_SATISFACTION(val){
  82. return "man_yi_du_ = '满意' AND YEAR ( create_time_ ) = '" + val+"'"
  83. }
  84. function PAT_YEAR(val){
  85. return " YEAR ( create_time_ ) = '" + val+"'"
  86. }
  87. function PAT_TASK(val,choose){
  88. return choose?"shi_fou_guo_shen_ = '1' AND YEAR( create_time_ ) = '"+val+"' AND DATE(update_time_) BETWEEN DATE( create_time_ ) and DATE( qi_wang_wan_cheng ) ":"shi_fou_guo_shen_ = '1' AND YEAR( create_time_ ) = '"+val+"'"
  89. }
  90. function PAT_CHOOSE(val,choose){
  91. return choose + " AND YEAR( create_time_ ) = '"+val+"'"
  92. // return "zhuang_tai_ = '已完成' AND YEAR ( create_time_ ) = '" + val+"'"
  93. }
  94. /* 工具函数参数
  95. 1、时间条件
  96. 2、表名
  97. 3、where条件
  98. 4、连接与连接条件
  99. (0) on 1=1 JOIN 非结束的sql语句
  100. (1) on 1=1 仅被连接, 如当前方法最后一个sql语句
  101. */
  102. function tool(val,tableName,where,join){
  103. let alias = tableName+val //别名
  104. return "( SELECT COUNT( id_ ) AS "
  105. +alias
  106. +" FROM "
  107. +tableName
  108. +" WHERE "
  109. +where
  110. +" ) "
  111. +alias
  112. + (join==0?" on 1=1 JOIN ":" on 1=1 ")
  113. }
  114. function toolTask(val,tableName,where,join){
  115. let alias = tableName+val //别名
  116. return "( SELECT COUNT( id_ ) AS "
  117. +alias
  118. +" FROM "
  119. +tableName
  120. +" WHERE "
  121. +where
  122. +" ) "
  123. +alias
  124. + (join==0?" on 1=1 JOIN ":" on 1=1 ")
  125. }
  126. function toolSame(val,tableName,where,join){
  127. let alias = tableName+'S'+val //别名
  128. return "( SELECT COUNT( id_ ) AS "
  129. +alias
  130. +" FROM "
  131. +tableName
  132. +" WHERE "
  133. +where
  134. +" ) "
  135. +alias
  136. + (join==0?" on 1=1 JOIN ":" on 1=1 ")
  137. }
  138. /* 任务完成 */
  139. function s1renwu(begin,end,scope){
  140. return "( SELECT COUNT( id_ ) AS t_lhjczb"+end+" FROM t_lhjczb "+ "WHERE zhuang_tai_ = '已完成' AND YEAR( create_time_ ) = "+end+") s1renwu1 JOIN"+
  141. "( SELECT COUNT( id_ ) AS t_lhjczbS"+end+" FROM t_lhjczb WHERE YEAR ( create_time_ ) = "+end+" ) s1renwu2 "
  142. }
  143. /* 检测 */
  144. function s1jianCe(begin,end){
  145. // //v3
  146. // return "( SELECT COUNT( id_ ) AS t_mjjcbg"+end+" FROM t_mjjcbg "+ "WHERE shi_fou_guo_shen_ = '已退回' AND YEAR( create_time_ ) = "+end+" ) s1jianCe1 JOIN"+
  147. // "( SELECT COUNT( id_ ) AS t_mjjcbgS"+end+" FROM t_mjjcbg WHERE YEAR ( create_time_ ) = "+end+" ) s1jianCe2 "
  148. // 委托检测数
  149. return "SELECT * FROM (select COUNT( id_ ) AS t_gdyrqcwt"+end+" from t_gdyrgpjc WHERE YEAR( create_time_ ) = "+end+" union all select id_ from t_gdyrqcjc WHERE YEAR( create_time_ ) = "+end+") s1jianCe1 JOIN "+
  150. // "(SELECT COUNT( id_ ) AS t_gdyrqcwt"+end+" FROM (select id_ from t_gdyrgpjc WHERE YEAR( create_time_ ) = '"+end+"' union all select id_ from t_gdyrqcjc WHERE YEAR( create_time_ ) = '"+end+"') a0) s1jianCe2 on 1=1 join "+
  151. // //按期完成检测件数
  152. // "(select count(id_) as t_gdyrqcwt2"+begin+" from(select id_ from t_gdyrgpjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+") union all select id_ from t_gdyrqcjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+")) a) s1jianCe3 on 1=1 JOIN "+
  153. // "(select count(id_) as t_gdyrqcwt2"+end+" from(select id_ from t_gdyrgpjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+") union all select id_ from t_gdyrqcjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+")) a) s1jianCe4 on 1=1 join "+
  154. // //出具报告数
  155. // "(select count(id_) as t_gdyrqcwt3"+begin+" from(select id_ from t_gdyrgpjc where fa_fang_biao_zhi_ is not null and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+") union all select id_ from t_gdyrqcjc where fa_fang_biao_zhi_ is not null and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+")) a) s1jianCe5 on 1=1 JOIN "+
  156. // "(select count(id_) as t_gdyrqcwt3"+end+" from(select id_ from t_gdyrgpjc where fa_fang_biao_zhi_ is not null and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+") union all select id_ from t_gdyrqcjc where fa_fang_biao_zhi_ is not null and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+")) a) s1jianCe6 on 1=1 join "+
  157. // //逾期未完成数
  158. // "(select count(id_) as t_gdyrqcwt4"+begin+" from(select id_ from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+") union all select id_ from t_gdyrqcjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+")) a) s1jianCe7 on 1=1 JOIN "+
  159. // "(select count(id_) as t_gdyrqcwt4"+end+" from(select id_ from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+") union all select id_ from t_gdyrqcjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+")) a) s1jianCe8 on 1=1 JOIN " +
  160. // //检测结果准确率
  161. // "(select count(wei_tuo_id_) as t_gdyrqcwt50"+begin+" from(select wei_tuo_id_ from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+" ) group by wei_tuo_id_ having count(1)=1 union all select wei_tuo_id_ from t_gdyrqcjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+") group by wei_tuo_id_ having count(1)=1 ) a) s1jianCe9 on 1=1 JOIN "+
  162. // "(select count(wei_tuo_id_) as t_gdyrqcwt50"+end+" from(select wei_tuo_id_ from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+" ) group by wei_tuo_id_ having count(1)=1 union all select wei_tuo_id_ from t_gdyrqcjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+" ) group by wei_tuo_id_ having count(1)=1 ) a) s1jianCe10 on 1=1 "
  163. // // 按时完成率
  164. // "( select select count(id_) AS t_gdyrqcwt6"+begin+" from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+"))) s1jianCe11 on 1=1 JOIN "+
  165. "( select count(id_) AS t_gdyrqcwt6"+end+" from t_gdyrgpjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = '"+end+"') ) s1jianCe12 on 1=1"
  166. }
  167. /* 检测 */
  168. function s2jianCe(begin,end){
  169. //v3
  170. return "( SELECT COUNT( id_ ) AS t_mjjcbg"+end+" FROM t_lhjcbgb "+ "WHERE trim(tui_hui_ci_shu_) != '' AND YEAR( create_time_ ) = "+end+" ) s2jianCe1 JOIN"+
  171. "( SELECT COUNT( id_ ) AS t_mjjcbgS"+end+" FROM t_lhjcbgb WHERE YEAR ( create_time_ ) = "+end+" ) s2jianCe2 "
  172. //委托检测数
  173. // return "SELECT * FROM (select COUNT( id_ ) AS t_gdyrqcwt"+begin+" from t_gdyrgpjc WHERE YEAR( create_time_ ) = "+begin+" union all select id_ from t_gdyrqcjc WHERE YEAR( create_time_ ) = "+begin+") s1jianCe1 JOIN "+
  174. // "(SELECT COUNT( id_ ) AS t_gdyrqcwt"+end+" FROM (select id_ from t_gdyrgpjc WHERE YEAR( create_time_ ) = '"+end+"' union all select id_ from t_gdyrqcjc WHERE YEAR( create_time_ ) = '"+end+"') a0) s1jianCe2 on 1=1 join "+
  175. // //按期完成检测件数
  176. // "(select count(id_) as t_gdyrqcwt2"+begin+" from(select id_ from t_gdyrgpjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+") union all select id_ from t_gdyrqcjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+")) a) s1jianCe3 on 1=1 JOIN "+
  177. // "(select count(id_) as t_gdyrqcwt2"+end+" from(select id_ from t_gdyrgpjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+") union all select id_ from t_gdyrqcjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+")) a) s1jianCe4 on 1=1 join "+
  178. // //出具报告数
  179. // "(select count(id_) as t_gdyrqcwt3"+begin+" from(select id_ from t_gdyrgpjc where fa_fang_biao_zhi_ is not null and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+") union all select id_ from t_gdyrqcjc where fa_fang_biao_zhi_ is not null and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+")) a) s1jianCe5 on 1=1 JOIN "+
  180. // "(select count(id_) as t_gdyrqcwt3"+end+" from(select id_ from t_gdyrgpjc where fa_fang_biao_zhi_ is not null and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+") union all select id_ from t_gdyrqcjc where fa_fang_biao_zhi_ is not null and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+")) a) s1jianCe6 on 1=1 join "+
  181. // //逾期未完成数
  182. // "(select count(id_) as t_gdyrqcwt4"+begin+" from(select id_ from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+") union all select id_ from t_gdyrqcjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+")) a) s1jianCe7 on 1=1 JOIN "+
  183. // "(select count(id_) as t_gdyrqcwt4"+end+" from(select id_ from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+") union all select id_ from t_gdyrqcjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+")) a) s1jianCe8 on 1=1 JOIN " +
  184. // //检测结果准确率
  185. // "(select count(wei_tuo_id_) as t_gdyrqcwt50"+begin+" from(select wei_tuo_id_ from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+" ) group by wei_tuo_id_ having count(1)=1 union all select wei_tuo_id_ from t_gdyrqcjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+") group by wei_tuo_id_ having count(1)=1 ) a) s1jianCe9 on 1=1 JOIN "+
  186. // "(select count(wei_tuo_id_) as t_gdyrqcwt50"+end+" from(select wei_tuo_id_ from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+" ) group by wei_tuo_id_ having count(1)=1 union all select wei_tuo_id_ from t_gdyrqcjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+end+" ) group by wei_tuo_id_ having count(1)=1 ) a) s1jianCe10 on 1=1 "
  187. //按时完成率
  188. //"( select select count(id_) AS t_gdyrqcwt6"+begin+" from t_gdyrgpjc where (qi_wang_wan_cheng<fa_fang_biao_zhi_ or fa_fang_biao_zhi_ is null) and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = "+begin+"))) s1jianCe11 on 1=1 JOIN "+
  189. //"( select count(id_) AS t_gdyrqcwt6"+end+" from t_gdyrgpjc where qi_wang_wan_cheng>fa_fang_biao_zhi_ and wei_tuo_id_ in (select id_ from t_gdyrqcwt where YEAR( create_time_ ) = '"+end+"') ) s1jianCe12 on 1=1"
  190. }
  191. /* 满意度 */
  192. function s2manYiDu(begin,end,scope){
  193. // let sql = "( SELECT COUNT( id_ ) AS t_khmydtjb"+begin+" FROM t_khmydtjb "+ "WHERE man_yi_du_ = '满意' AND YEAR( create_time_ ) = "+begin+" ) s2manYiDu1 JOIN"
  194. // for (let i = 1; i < scope.length; i++) {
  195. // if(i === scope.length - 1){
  196. // sql = sql + tool(scope[i],"t_khmydtjb",PAT_SATISFACTION(scope[i]),1)
  197. // }else{
  198. // sql = sql + tool(scope[i],"t_khmydtjb",PAT_SATISFACTION(scope[i]),0)
  199. // }
  200. // }
  201. // let sql1 = " JOIN ( SELECT COUNT( id_ ) AS t_khmydtjbS"+begin+" FROM t_khmydtjb WHERE YEAR ( create_time_ ) = "+begin+" ) s2manYiDu2 JOIN "
  202. // for (let i = 1; i < scope.length; i++) {
  203. // if(i === scope.length - 1){
  204. // sql1 = sql1 + toolSame(scope[i],"t_khmydtjb",PAT_YEAR(scope[i]),1)
  205. // }else{
  206. // sql1 = sql1 + toolSame(scope[i],"t_khmydtjb",PAT_YEAR(scope[i]),0)
  207. // }
  208. // }
  209. // let sqlAll = sql + sql1
  210. // return sqlAll
  211. return "( SELECT COUNT(id_) as t_khmydtjbnum"+end+",sum(ping_fen_1_)+sum(ping_fen_2_)+sum(ping_fen_3_)+sum(ping_fen_4_)+sum(ping_fen_5_) AS t_khmydtjb"+end+" FROM t_khmyddcb WHERE YEAR( create_time_ ) = "+end+" ) s2manYiDu1 JOIN"+
  212. "( SELECT COUNT( id_ ) AS t_khmydtjbS"+end+" FROM t_khmydtjb WHERE YEAR ( create_time_ ) = "+end+" ) s2manYiDu2 "
  213. //调查表总数
  214. // return "( SELECT COUNT( id_ ) AS t_myddc"+begin+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = "+begin+" ) s2manYiDu1 JOIN "+
  215. // "( SELECT COUNT( id_ ) AS t_myddc"+end+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+end+"' ) s2manYiDu2 on 1=1 JOIN "+
  216. // //技术水平
  217. // "( SELECT sum(case when dang_nin_dui_jian='满意' then 1 else 0 end)/sum(1)+0.01 AS t_myddc1"+begin+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+begin+"' ) s2manYiDu3 on 1=1 JOIN "+
  218. // "( SELECT sum(case when dang_nin_dui_jian='满意' then 1 else 0 end)/sum(1)+0.01 AS t_myddc1"+end+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+end+"' ) s2manYiDu4 on 1=1 JOIN "+
  219. // //检测效率满意度
  220. // "( SELECT sum(case when nin_dui_jian_yan_='满意' then 1 else 0 end)/sum(1)+0.01 AS t_myddc2"+begin+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+begin+"' ) s2manYiDu5 on 1=1 JOIN "+
  221. // "( SELECT sum(case when nin_dui_jian_yan_='满意' then 1 else 0 end)/sum(1)+0.01 AS t_myddc2"+end+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+end+"' ) s2manYiDu6 on 1=1 JOIN "+
  222. // //工作态度
  223. // "( SELECT sum(case when nin_dui_jian_ce_r='满意' then 1 else 0 end)/sum(1)+0.01 AS t_myddc3"+begin+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+begin+"' ) s2manYiDu7 on 1=1 JOIN "+
  224. // "( SELECT sum(case when nin_dui_jian_ce_r='满意' then 1 else 0 end)/sum(1)+0.01 AS t_myddc3"+end+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+end+"' ) s2manYiDu8 on 1=1 "
  225. //检测准确性,参照s1的准确率
  226. // "( SELECT sum(case when nin_dui_jian_ce_r='满意' then 1 else 0 end) AS t_myddc4"+begin+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+begin+"' ) s2manYiDu9 on 1=1 JOIN "+
  227. // "( SELECT sum(case when nin_dui_jian_ce_r='满意' then 1 else 0 end) AS t_myddc4"+end+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+end+"' ) s2manYiDu10 on 1=1 "
  228. //报告完成率,外层汇总,此处不计算
  229. // "( SELECT sum(case when nin_dui_jian_ce_r='满意' then 1 else 0 end) AS t_myddc5"+begin+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+begin+"' ) s2manYiDu11 on 1=1 JOIN "+
  230. // "( SELECT sum(case when nin_dui_jian_ce_r='满意' then 1 else 0 end) AS t_myddc5"+end+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+end+"' ) s2manYiDu12 on 1=1 JOIN"
  231. //检测效率,外层汇总,此处不计算
  232. // "( SELECT sum(case when nin_dui_jian_yan_='满意' then 1 else 0 end) AS t_myddc6"+begin+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+begin+"' ) s2manYiDu13 on 1=1 JOIN "+
  233. // "( SELECT sum(case when nin_dui_jian_yan_='满意' then 1 else 0 end) AS t_myddc6"+end+" FROM t_myddc "+ "WHERE YEAR( create_time_ ) = '"+end+"' ) s2manYiDu14 on 1=1 "
  234. }
  235. /* 投诉 */
  236. function s3tousu(begin,end,scope){
  237. return "( SELECT COUNT( id_ ) AS t_complaint"+end+" FROM t_complaint WHERE you_wu_you_xiao_ = '有效投诉' and YEAR ( create_time_ ) = "+end+" ) s3tousu1 JOIN "+
  238. "( SELECT COUNT( id_ ) AS t_complaintS"+end+" FROM t_complaint WHERE you_wu_you_xiao_ = '有效投诉' and chu_li_shi_jian_='<48h' and shi_fou_tong_yi_='同意' and YEAR ( create_time_ ) = "+end+" ) s3tousu2 JOIN "+
  239. "( SELECT COUNT( id_ ) AS t_complainS"+end+" FROM t_complaint WHERE you_wu_you_xiao_ = '有效投诉' and chu_li_jie_guo_sh='已通知' and YEAR ( create_time_ ) = "+end+" ) s3tousu3 JOIN "+
  240. "( SELECT COUNT( id_ ) AS t_mjwtsqb"+end+" FROM t_lhjczb WHERE YEAR ( create_time_ ) = "+end+" ) s3weituo1"
  241. // let sql = "( SELECT COUNT( id_ ) AS t_complaint"+begin+" FROM t_complaint WHERE YEAR ( create_time_ ) = "+begin+" ) s3tousu1 JOIN "
  242. // for (let i = 1; i < scope.length; i++) {
  243. // if(i === scope.length - 1){
  244. // sql = sql + tool(scope[i],"t_complaint",PAT_YEAR(scope[i]),1)
  245. // }else{
  246. // sql = sql + tool(scope[i],"t_complaint",PAT_YEAR(scope[i]),0)
  247. // }
  248. // }
  249. // let sql1 = " JOIN ( SELECT COUNT( id_ ) AS t_mjwtsqb"+begin+" FROM t_mjwtsqb WHERE YEAR ( create_time_ ) = "+begin+" ) s3weituo1 JOIN "
  250. // for (let i = 1; i < scope.length; i++) {
  251. // if(i === scope.length - 1){
  252. // sql1 = sql1 + tool(scope[i],"t_mjwtsqb",PAT_YEAR(scope[i]),1)
  253. // }else{
  254. // sql1 = sql1 + tool(scope[i],"t_mjwtsqb",PAT_YEAR(scope[i]),0)
  255. // }
  256. // }
  257. // let sqlAll = sql + sql1
  258. // return sqlAll
  259. // return "( SELECT COUNT( id_ ) AS t_complaint"+begin+" FROM t_complaint WHERE YEAR ( create_time_ ) = "+begin+" ) s3tousu1 JOIN "+
  260. // tool(end,"t_complaint",PAT_YEAR(end),1)+" JOIN "+
  261. // "( SELECT COUNT( id_ ) AS t_mjwtsqb"+begin+" FROM t_mjwtsqb WHERE YEAR ( create_time_ ) = "+begin+" ) s3weituo1 JOIN "+
  262. // tool(end,"t_mjwtsqb",PAT(end),1)
  263. // return "( SELECT COUNT( id_ ) AS t_complaint"+begin+" FROM t_complaint WHERE YEAR ( create_time_ ) BETWEEN "+begin+" and "+end+") s3tousu1 on 1=1"
  264. }
  265. /* 人员培训 */
  266. function s4renYuanPeiXun(begin,end,scope){
  267. return "( SELECT COUNT( id_ ) AS t_ryywpxjl"+end+" FROM t_lhrypxjlb WHERE shi_fou_guo_shen_ = '1' AND YEAR ( create_time_ ) = "+end+" ) s4renYuanPeiXun1 JOIN "+
  268. "( SELECT COUNT( id_ ) AS t_ryywpxjlS"+end+" FROM t_lhrypxjlb WHERE YEAR ( create_time_ ) = "+end+" ) s4renYuanPeiXun2"
  269. // let sql = "( SELECT COUNT( id_ ) AS t_ryywpxjl"+begin+" FROM t_ryywpxjl WHERE zhuang_tai_ = '已完成' AND YEAR ( create_time_ ) = "+begin+" ) s4renYuanPeiXun1 JOIN "
  270. // for (let i = 1; i < scope.length; i++) {
  271. // if(i === scope.length - 1){
  272. // sql = sql + tool(scope[i],"t_ryywpxjl",PAT_CHOOSE(scope[i],"zhuang_tai_ = '已完成'"),1)
  273. // }else{
  274. // sql = sql + tool(scope[i],"t_ryywpxjl",PAT_CHOOSE(scope[i],"zhuang_tai_ = '已完成'"),0)
  275. // }
  276. // }
  277. // let sql1 = " JOIN ( SELECT COUNT( id_ ) AS t_ryywpxjlS"+begin+" FROM t_ryywpxjl WHERE YEAR ( create_time_ ) = "+begin+" ) s4renYuanPeiXun2 JOIN "
  278. // for (let i = 1; i < scope.length; i++) {
  279. // if(i === scope.length - 1){
  280. // sql1 = sql1 + toolSame(scope[i],"t_ryywpxjl",PAT_YEAR(scope[i]),1)
  281. // }else{
  282. // sql1 = sql1 + toolSame(scope[i],"t_ryywpxjl",PAT_YEAR(scope[i]),0)
  283. // }
  284. // }
  285. // let sqlAll = sql + sql1
  286. // return sqlAll
  287. // return "( SELECT COUNT( id_ ) AS t_ryndpxjh"+begin+" FROM t_ryndpxjh WHERE shi_fou_guo_shen_ = '1' and YEAR( create_time_ ) = "+begin+" ) s4renYuanPeiXun1 JOIN "+
  288. // tool(end,"t_ryndpxjh",PAT(end),1)+" JOIN "+
  289. // "( SELECT COUNT( id_ ) AS t_rypxjlnk"+begin+" FROM t_rypxjlnk WHERE shi_fou_guo_shen_ = '1' and YEAR ( create_time_ ) = "+begin+" ) s4renYuanPeiXun2 JOIN "+
  290. // tool(end,"t_rypxjlnk",PAT(end),1)
  291. }
  292. /* 人员监督 */
  293. function s5renYuanJianDu(begin,end, scope){
  294. return "( SELECT COUNT( id_ ) AS t_zljd"+end+" FROM t_lhryjdjlb WHERE shi_fou_guo_shen_= '1' AND YEAR ( create_time_ ) = "+end+" ) s5renYuanJianDu1 JOIN "+
  295. "( SELECT COUNT( id_ ) AS t_zljdS"+end+" FROM t_lhryjdjlb WHERE YEAR ( create_time_ ) = "+end+" ) s5renYuanJianDu2"
  296. // let sql = "( SELECT COUNT( id_ ) AS t_zljd"+begin+" FROM t_zljd WHERE shi_fou_guo_shen_= '1' AND YEAR ( create_time_ ) = "+begin+" ) s5renYuanJianDu1 JOIN "
  297. // for (let i = 1; i < scope.length; i++) {
  298. // if(i === scope.length - 1){
  299. // sql = sql + tool(scope[i],"t_zljd",PAT_CHOOSE(scope[i],"shi_fou_guo_shen_= '1'"),1)
  300. // }else{
  301. // sql = sql + tool(scope[i],"t_zljd",PAT_CHOOSE(scope[i],"shi_fou_guo_shen_= '1'"),0)
  302. // }
  303. // }
  304. // let sql1 = " JOIN ( SELECT COUNT( id_ ) AS t_zljdS"+begin+" FROM t_zljd WHERE YEAR ( create_time_ ) = "+begin+" ) s5renYuanJianDu2 JOIN "
  305. // for (let i = 1; i < scope.length; i++) {
  306. // if(i === scope.length - 1){
  307. // sql1 = sql1 + toolSame(scope[i],"t_zljd",PAT_YEAR(scope[i]),1)
  308. // }else{
  309. // sql1 = sql1 + toolSame(scope[i],"t_zljd",PAT_YEAR(scope[i]),0)
  310. // }
  311. // }
  312. // let sqlAll = sql + sql1
  313. // return sqlAll
  314. // return "( SELECT COUNT( id_ ) AS t_zljd"+begin+" FROM t_zljd WHERE shi_fou_guo_shen_ = '1' and YEAR( create_time_ ) = "+begin+" ) s5renYuanJianDu1 JOIN "+
  315. // tool(end,"t_zljd",PAT(end),1)+" JOIN "+
  316. // "( SELECT COUNT( id_ ) AS t_zljdss"+begin+" FROM t_zljdss WHERE shi_fou_guo_shen_ = '1' and YEAR ( create_time_ ) = "+begin+" ) s5renYuanJianDu2 JOIN "+
  317. // tool(end,"t_zljdss",PAT(end),1)
  318. }
  319. /* 设备维护 */
  320. function s6sheBeiWeiHu(begin,end){
  321. return "( SELECT COUNT( id_ ) AS t_yqsbwhjhxmt"+begin+" FROM t_yqsbwhjhxmt WHERE YEAR( create_time_ ) = "+begin+" ) s6sheBeiWeiHu1 JOIN "+
  322. tool(end,"t_yqsbwhjhxmt",PAT_YEAR(end),1)+" JOIN "+
  323. "( SELECT COUNT( id_ ) AS t_whbyxx"+begin+" FROM t_whbyxx WHERE YEAR ( create_time_ ) = "+begin+" ) s6sheBeiWeiHu2 JOIN "+
  324. tool(end,"t_whbyxx",PAT_YEAR(end),1)+" JOIN "+
  325. "( SELECT COUNT( id_ ) AS t_yqsbwhjhxmz"+begin+" FROM t_yqsbwhjhxmz WHERE YEAR( create_time_ ) = "+begin+" ) s6sheBeiWeiHu3 JOIN "+
  326. tool(end,"t_yqsbwhjhxmz",PAT_YEAR(end),1)+" JOIN "+
  327. "( SELECT COUNT( id_ ) AS t_whbyxmxxmz"+begin+" FROM t_whbyxmxxmz WHERE YEAR ( create_time_ ) = "+begin+" ) s6sheBeiWeiHu4 JOIN "+
  328. tool(end,"t_whbyxmxxmz",PAT_YEAR(end),1)+" JOIN "+
  329. "( SELECT COUNT( id_ ) AS t_yqsbwhjhxmy"+begin+" FROM t_yqsbwhjhxmy WHERE YEAR( create_time_ ) = "+begin+" ) s6sheBeiWeiHu5 JOIN "+
  330. tool(end,"t_yqsbwhjhxmy",PAT_YEAR(end),1)+" JOIN "+
  331. "( SELECT COUNT( id_ ) AS t_whbyxxmy"+begin+" FROM t_whbyxxmy WHERE YEAR ( create_time_ ) = "+begin+" ) s6sheBeiWeiHu6 JOIN "+
  332. tool(end,"t_whbyxxmy",PAT_YEAR(end),1)+" JOIN "+
  333. "( SELECT COUNT( id_ ) AS t_yqsbwhjhfb"+begin+" FROM t_yqsbwhjhfb WHERE (shi_fou_guo_shen_ like '%同意%' or shi_fou_guo_shen_='1') and YEAR ( create_time_ ) = "+begin+" ) s6sheBeiWeiHu7 JOIN "+
  334. tool(end,"t_yqsbwhjhfb",PAT(end),1)+" JOIN "+
  335. "( SELECT COUNT( id_ ) AS t_yqsbwhjlfb"+begin+" FROM t_yqsbwhjlfb WHERE (shi_fou_guo_shen_ like '%同意%' or shi_fou_guo_shen_='1') and YEAR ( create_time_ ) = "+begin+" ) s6sheBeiWeiHu8 JOIN "+
  336. tool(end,"t_yqsbwhjlfb",PAT(end),1)
  337. }
  338. /* 设备校准 */
  339. function s7sheBeiJiaoZhun(begin,end){
  340. //v3
  341. return "(SELECT she_bei_ming_chen as t_mjsbjdxzjhzbName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzb"+end+" FROM t_mjsbjdxzjhzb WHERE YEAR( create_time_ ) = "+end+" GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 ORDER BY she_bei_ming_chen) s7sheBeiJiaoZhun1 JOIN " +
  342. "(SELECT she_bei_ming_chen as t_mjsbjdxzjhzbSName, COUNT(she_bei_ming_chen) as t_mjsbjdxzjhzbS"+end+" FROM t_mjsbjdxzjhzb WHERE YEAR( create_time_ ) = "+end+" AND DATE(yi_jian_xiao_ri_q) >= DATE(ji_hua_ri_qi_) GROUP BY she_bei_ming_chen HAVING COUNT(she_bei_ming_chen)>=1 ORDER BY she_bei_ming_chen) s7sheBeiJiaoZhun12 "
  343. //v1
  344. // return "( SELECT COUNT( id_ ) AS t_ndsbxzjdjh"+begin+" FROM t_ndsbxzjdjh WHERE shi_fou_guo_shen_ = '1' and YEAR( create_time_ ) = "+begin+" ) s7sheBeiJiaoZhun1 JOIN "+
  345. // tool(end,"t_ndsbxzjdjh",PAT(end),1)+" JOIN "+
  346. // "( SELECT COUNT( id_ ) AS t_yqsbxzjg"+begin+" FROM t_yqsbxzjg WHERE shi_fou_guo_shen_ = '1' and YEAR ( create_time_ ) = "+begin+" ) s7sheBeiJiaoZhun2 JOIN "+
  347. // tool(end,"t_yqsbxzjg",PAT(end),1)
  348. }
  349. /* 设备核查 */
  350. function s8sheBeiHeCha(begin,end){
  351. return "( SELECT COUNT( id_ ) AS t_sbhcjh"+begin+" FROM t_sbhcjh WHERE shi_fou_guo_shen_ = '1' and YEAR( create_time_ ) = "+begin+" ) s8sheBeiHeCha1 JOIN "+
  352. tool(end,"t_sbhcjh",PAT(end),1)+" JOIN "+
  353. "( SELECT COUNT( id_ ) AS t_sbhcjlb"+begin+" FROM t_sbhcjlb WHERE shi_fou_guo_shen_ = '1' and YEAR ( create_time_ ) = "+begin+" ) s8sheBeiHeCha2 JOIN "+
  354. tool(end,"t_sbhcjlb",PAT(end),1)
  355. }
  356. /* 内部质量控制 */
  357. function s9neiBu(begin,end,scope){
  358. return "( SELECT COUNT( id_ ) AS t_mjzlkzxb"+end+" FROM t_mjzlkzxb WHERE YEAR ( create_time_ ) = "+end+" ) s9neibu1 JOIN "+
  359. "( SELECT COUNT( t_mjzlkzxb.id_ ) AS t_mjzlkzxbS"+end+" FROM t_mjzlkzxb left join t_mjzlkzjhb on t_mjzlkzxb.parent_id_ = t_mjzlkzjhb.id_ WHERE t_mjzlkzjhb.shi_fou_guo_shen_='1' AND YEAR ( t_mjzlkzxb.create_time_ ) = "+end+" ) s9neibu2 join"+
  360. "( SELECT COUNT( id_ ) AS t_mjzlkzjlb"+end+" FROM t_mjzlkzjlb WHERE length(shi_fou_guo_shen_) >0 AND YEAR ( create_time_ ) = "+end+" ) s9neibu3 join" +
  361. "( SELECT COUNT( id_ ) AS t_mjzlkzjlbS"+end+" FROM t_mjzlkzjlb WHERE shi_fou_guo_shen_=1 AND YEAR ( create_time_ ) = "+end+" ) s9neibu4"
  362. }
  363. function s12fengXian(begin,end,scope){
  364. return "(select COUNT(t_mjsyshdfxsbykzjhxb.id_) as t_mjsyshdfxsbykzjhxb"+end+" from t_mjsyshdfxsbykzjhxb INNER JOIN t_mjsyshdfxsbykzjhb on t_mjsyshdfxsbykzjhxb.parent_id_ = t_mjsyshdfxsbykzjhb.id_ where YEAR(t_mjsyshdfxsbykzjhxb.shi_shi_ri_qi_)="+end+") s12fengxian1 JOIN " +
  365. "(select COUNT(t_mjsyshdfxsbykzjhxb.id_) as t_mjsyshdfxsbykzjhxbS"+end+" from t_mjsyshdfxsbykzjhxb INNER JOIN t_mjsyshdfxsbykzjhb on t_mjsyshdfxsbykzjhxb.parent_id_ = t_mjsyshdfxsbykzjhb.id_ where YEAR(t_mjsyshdfxsbykzjhxb.shi_shi_ri_qi_)="+end+" and t_mjsyshdfxsbykzjhb.shi_fou_guo_shen_ = '1') s12fengxian2 "
  366. }
  367. function s14bufuhexiang(begin,end,scope){
  368. return "(select COUNT(t_bfhxbgyjzcsjlbx.id_) as t_bfhxbgyjzcsjlbx"+end+" from t_bfhxbgyjzcsjlbx where YEAR(t_bfhxbgyjzcsjlbx.create_time_)="+end+") s14bufuhexiang1 JOIN " +
  369. "(select COUNT(t_bfhxbgyjzcsjlbx.id_) as t_bfhxbgyjzcsjlbxS"+end+" from t_bfhxbgyjzcsjlbx where t_bfhxbgyjzcsjlbx.zhuang_tai_ = '已完成' and YEAR(t_bfhxbgyjzcsjlbx.create_time_)="+end+") s14buhexiang2 "
  370. }