YsJfysCQuery.xml 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.ghsc.partybuild.mapper.YsJfysCQuery">
  4. <resultMap id="BaseResultMap" type="com.ghsc.partybuild.vo.YsJfysmxVo">
  5. <id column="ysmxid" jdbcType="VARCHAR" property="ysmxid"/>
  6. <result column="jfysid" jdbcType="VARCHAR" property="jfysid"/>
  7. <result column="dzzdm" jdbcType="VARCHAR" property="dzzdm"/>
  8. <result column="v1sl" jdbcType="NUMERIC" property="v1sl"/>
  9. <result column="v2sl" jdbcType="NUMERIC" property="v2sl"/>
  10. <result column="v3sl" jdbcType="NUMERIC" property="v3sl"/>
  11. <result column="v4sl" jdbcType="NUMERIC" property="v4sl"/>
  12. <result column="dzbjfxj" jdbcType="NUMERIC" property="dzbjfxj"/>
  13. <result column="v1hdbz" jdbcType="NUMERIC" property="v1hdbz"/>
  14. <result column="v2hdbz" jdbcType="NUMERIC" property="v2hdbz"/>
  15. <result column="v3hdbz" jdbcType="NUMERIC" property="v3hdbz"/>
  16. <result column="v4hdbz" jdbcType="NUMERIC" property="v4hdbz"/>
  17. <result column="zgdyrs" jdbcType="NUMERIC" property="zgdyrs"/>
  18. <result column="hdbz" jdbcType="NUMERIC" property="hdbz"/>
  19. <result column="xtysze" jdbcType="NUMERIC" property="xtysze"/>
  20. <result column="sjysze" jdbcType="NUMERIC" property="sjysze"/>
  21. <result column="DZZMC" jdbcType="VARCHAR" property="dzzmc"/>
  22. </resultMap>
  23. <!-- 统计党组织人数-->
  24. <select id="selectPartyAndUserTotal" resultType="java.util.Map">
  25. select t1.dzzdm as "dzzdm",t1.dzzmc as "dzzmc",
  26. ifnull(t1.numType1,0) as "v1sl",ifnull(t1.numType2,0) as "v2sl",ifnull(t1.numType3,0) as "v3sl",ifnull(t1.numType4,0) as "v4sl",
  27. ifnull(t2.userCount,0) as "zgdyrs"
  28. from (
  29. select dzzdm,dzzmc,numType1,numType2,numType3,numType4
  30. from (
  31. select t1.dzzdm,t1.dzzmc,t1.numType,ifnull(t2.num,0) as num
  32. from (
  33. select dzzdm,dzzmc,numType from (
  34. select dzzdm,dzzmc,1 as t_st,2 as t_nd,3 as t_rd,4 as t_th from zz_zzqkxx where length(dzzdm)=12
  35. and dzzdm like concat('%',#{gddwdm},'%')
  36. ) t1 unpivot (numType for title in (t_st,t_nd,t_rd,t_th)) t1
  37. ) t1
  38. left join (
  39. select t1.dzzdm,t1.dzzmc,t2.numType,count(t2.numType) as num
  40. from (select dzzdm,dzzmc from zz_zzqkxx where length(dzzdm)=12) t1
  41. inner join (
  42. select p.dzzdm,
  43. p.dzzmc,
  44. count(u.rybm) as userNum,
  45. (case
  46. when count(u.rybm) <![CDATA[ <= ]]>50 then 1 --50人以下
  47. when count(u.rybm) > 50 and count(u.rybm) <![CDATA[ <= ]]> 100 then 2 --51到100人
  48. when count(u.rybm) > 100 and count(u.rybm) <![CDATA[ <= ]]> 300 then 3 --101到300人
  49. when count(u.rybm) > 300 then 4 --300人以上
  50. else 0 end) as numType
  51. from (select * from zz_zzqkxx where dzzdm like concat('%',#{gddwdm},'%')) p
  52. left join ZZ_ZZQKXXFB fb on p.DZZDM = fb.DZZDM
  53. left join vm_ryjbxx u on p.dzzdm = substr(u.szdzbdm, 1, 15)
  54. where fb.ZZLB in ('300', '400') and fb.jczzfl='21' --and p.DZZDM like '001091209017%'
  55. group by p.dzzdm,p.dzzmc
  56. ) t2 on t1.dzzdm=substr(t2.dzzdm, 1, 12)
  57. group by t1.dzzdm,t1.dzzmc,t2.numType
  58. ) t2 on t1.dzzdm=t2.dzzdm and t1.numType=t2.numType
  59. ) pivot (max(num) for numType in ('1' as numType1,'2' AS numType2,'3' AS numType3,'4' as numType4 ))
  60. ) t1
  61. left join (
  62. select SUBSTR(us.szdzbdm,1,12) as dzzdm,count(us.rybm) as userCount from vm_ryjbxx us
  63. inner join gg_zgjbxx info on us.rybm = info.rybm
  64. inner join zd_rylb rylb on info.rylb = rylb.bm
  65. where 1=1
  66. and rylb.bm like '1%' and length(rylb.bm)=3 -- 在岗人员
  67. group by SUBSTR(us.szdzbdm,1,12)
  68. ) t2 on t1.DZZDM=t2.dzzdm -- 在岗人员数量
  69. </select>
  70. <select id="selectYsjybmxList" resultType="java.util.Map" resultMap="BaseResultMap">
  71. select ysmxid, jfysid, mx.dzzdm, v1sl, v2sl, v3sl, v4sl, dzbjfxj, v1hdbz, v2hdbz, v3hdbz, v4hdbz,
  72. zgdyrs, hdbz, xtysze, sjysze,zz.DZZMC from Ys_Jfysmx mx
  73. inner join ZZ_ZZQKXX zz on mx.DZZDM=zz.DZZDM
  74. where Jfysid=#{Jfysid}
  75. </select>
  76. </mapper>