| @@ -55,11 +55,11 @@ public class WxUserStructureController extends BaseController { | |||||
| } | } | ||||
| //保密 | //保密 | ||||
| dto.setSex(0); | dto.setSex(0); | ||||
| long secrecy = getCount(dto); | |||||
| long secrecy = wxCUserBasicInfoService.findCountBySex(dto); | |||||
| dto.setSex(1); | dto.setSex(1); | ||||
| long boy = getCount(dto); | |||||
| long boy = wxCUserBasicInfoService.findCountBySex(dto); | |||||
| dto.setSex(2); | dto.setSex(2); | ||||
| long girl = getCount(dto); | |||||
| long girl = wxCUserBasicInfoService.findCountBySex(dto); | |||||
| Long all = secrecy + boy + girl; | Long all = secrecy + boy + girl; | ||||
| List<UserStructureVo> vos = new ArrayList<>(); | List<UserStructureVo> vos = new ArrayList<>(); | ||||
| vos.add(getVo(boy, all, "男", 1)); | vos.add(getVo(boy, all, "男", 1)); | ||||
| @@ -81,7 +81,7 @@ public class WxUserStructureController extends BaseController { | |||||
| endTime = c.getTime(); | endTime = c.getTime(); | ||||
| } | } | ||||
| dto.setEndTime(endTime); | dto.setEndTime(endTime); | ||||
| long all = wxCUserBasicInfoService.findCountByAge(dto); | |||||
| long all = wxCUserBasicInfoService.findCount(dto); | |||||
| List<UserStructureVo> vos = new ArrayList<>(); | List<UserStructureVo> vos = new ArrayList<>(); | ||||
| Calendar c = Calendar.getInstance(); | Calendar c = Calendar.getInstance(); | ||||
| for (EnumAgeInfo a : EnumAgeInfo.values()) { | for (EnumAgeInfo a : EnumAgeInfo.values()) { | ||||
| @@ -135,7 +135,7 @@ public class WxUserStructureController extends BaseController { | |||||
| UserStructureVo vo = new UserStructureVo(); | UserStructureVo vo = new UserStructureVo(); | ||||
| vo.setSortNum(j); | vo.setSortNum(j); | ||||
| j++; | j++; | ||||
| vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime())); | |||||
| vo.setName(new SimpleDateFormat("MM/dd").format(dto.getStartTime())); | |||||
| vo.setCount(count); | vo.setCount(count); | ||||
| wxnewCountVos.add(vo); | wxnewCountVos.add(vo); | ||||
| } | } | ||||
| @@ -209,7 +209,7 @@ public class WxUserStructureController extends BaseController { | |||||
| UserStructureVo vo = new UserStructureVo(); | UserStructureVo vo = new UserStructureVo(); | ||||
| vo.setSortNum(j); | vo.setSortNum(j); | ||||
| j++; | j++; | ||||
| vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime())); | |||||
| vo.setName(new SimpleDateFormat("MM/dd").format(dto.getStartTime())); | |||||
| vo.setCount(count); | vo.setCount(count); | ||||
| newCountVos.add(vo); | newCountVos.add(vo); | ||||
| } | } | ||||
| @@ -278,15 +278,17 @@ public class WxUserStructureController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| PageInfo<WxCUser> page = wxCUserService.listByChannel(sceneList, pageNum, pageSize); | |||||
| PageInfo<WxCUser> page = wxCUserService.listByChannel(getTenantId(), sceneList, pageNum, pageSize); | |||||
| for (WxCUser u : page.getList()) { | for (WxCUser u : page.getList()) { | ||||
| WxUserChannel c = new WxUserChannel(); | WxUserChannel c = new WxUserChannel(); | ||||
| c.setSceneAddress(u.getSceneAddress()); | c.setSceneAddress(u.getSceneAddress()); | ||||
| PageInfo<WxUserChannel> uc = wxUserChannelService.listAsPage(c, 1, 1); | PageInfo<WxUserChannel> uc = wxUserChannelService.listAsPage(c, 1, 1); | ||||
| if (uc.getSize() > 0) { | if (uc.getSize() > 0) { | ||||
| u.setChannelName(uc.getList().get(0).getChannelName()); | u.setChannelName(uc.getList().get(0).getChannelName()); | ||||
| u.setSceneDescription(uc.getList().get(0).getDescription()); | |||||
| } else { | } else { | ||||
| u.setChannelName("其他来源"); | u.setChannelName("其他来源"); | ||||
| u.setSceneDescription("不详"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -306,23 +308,22 @@ public class WxUserStructureController extends BaseController { | |||||
| private long getCountByAge(EnumAgeInfo a, Calendar c, WxCUserBasicInfoDto dto) { | private long getCountByAge(EnumAgeInfo a, Calendar c, WxCUserBasicInfoDto dto) { | ||||
| c.add(Calendar.YEAR, -a.getEnd()); | |||||
| Date startTime = c.getTime(); | |||||
| c.clear(); | |||||
| c.setTime(startTime); | |||||
| c.add(Calendar.YEAR, a.getEnd() - a.getStart()); | |||||
| Date endTime = c.getTime(); | |||||
| dto.setBirthStartTime(startTime); | |||||
| dto.setBirthEndTime(endTime); | |||||
| return wxCUserBasicInfoService.findCountByAge(dto); | |||||
| } | |||||
| if (a.getStart() != 0 || a.getEnd() != 0) { | |||||
| c.add(Calendar.YEAR, -a.getEnd()); | |||||
| Date startTime = c.getTime(); | |||||
| c.clear(); | |||||
| c.setTime(startTime); | |||||
| c.add(Calendar.YEAR, a.getEnd() - a.getStart()); | |||||
| Date endTime = c.getTime(); | |||||
| dto.setBirthStartTime(startTime); | |||||
| dto.setBirthEndTime(endTime); | |||||
| } else { | |||||
| dto.setBirthStartTime(null); | |||||
| dto.setBirthEndTime(null); | |||||
| } | |||||
| //通过性别获取数量 | |||||
| private long getCount(WxCUserBasicInfoDto dto) { | |||||
| // wxCUserBasicInfoService.findCountBySex(dto) basic表与cuser表示对应的,先有cuser 才有basic | |||||
| //所有这里不需要再去查basic | |||||
| return wxCUserService.findCount(dto); | |||||
| return wxCUserBasicInfoService.findCountByAge(dto); | |||||
| } | } | ||||
| private UserStructureVo getVo(long count, long all, String name, Integer num) { | private UserStructureVo getVo(long count, long all, String name, Integer num) { | ||||
| @@ -21,7 +21,10 @@ public class WxCUser implements Serializable { | |||||
| protected List<Long> ids; | protected List<Long> ids; | ||||
| @Transient | @Transient | ||||
| protected String sortColumns; | protected String sortColumns; | ||||
| @Transient | |||||
| protected String sceneDescription; | |||||
| public Long getId() { | public Long getId() { | ||||
| return id; | return id; | ||||
| } | } | ||||
| @@ -308,6 +311,14 @@ public class WxCUser implements Serializable { | |||||
| this.loginCount = loginCount; | this.loginCount = loginCount; | ||||
| } | } | ||||
| public String getSceneDescription() { | |||||
| return sceneDescription; | |||||
| } | |||||
| public void setSceneDescription(String sceneDescription) { | |||||
| this.sceneDescription = sceneDescription; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| @@ -7,7 +7,8 @@ public enum EnumAgeInfo { | |||||
| FOURTH_SLOT(4,35,44,"35岁-44岁"), | FOURTH_SLOT(4,35,44,"35岁-44岁"), | ||||
| FIFTH_SLOT(5,45,54,"45岁-54岁"), | FIFTH_SLOT(5,45,54,"45岁-54岁"), | ||||
| SIXTH_SLOT(6,54,60,"55岁-60岁"), | SIXTH_SLOT(6,54,60,"55岁-60岁"), | ||||
| SEVENTH_SLOT(7,60,200,"60岁以上") | |||||
| SEVENTH_SLOT(7,60,200,"60岁以上"), | |||||
| UNKNOWN(8,0,0,"不详") | |||||
| ; | ; | ||||
| private EnumAgeInfo(Integer sortNum,Integer start,Integer end,String desc) { | private EnumAgeInfo(Integer sortNum,Integer start,Integer end,String desc) { | ||||
| @@ -20,6 +20,6 @@ public interface WxCUserMapper extends CommonMapper<WxCUser, Long> { | |||||
| long findCount(WxCUserBasicInfoDto dto); | long findCount(WxCUserBasicInfoDto dto); | ||||
| List<WxCUser> listByChannel(@Param("sceneList")List<String> sceneList); | |||||
| List<WxCUser> listByChannel(@Param("sceneList")List<String> sceneList, @Param("tenantId")String tenantId); | |||||
| } | } | ||||
| @@ -71,7 +71,7 @@ public interface WxCUserService { | |||||
| * @param pageSize | * @param pageSize | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxCUser> listByChannel(List<String> sceneList, Integer pageIndex, Integer pageSize); | |||||
| PageInfo<WxCUser> listByChannel(String tenantId, List<String> sceneList, Integer pageIndex, Integer pageSize); | |||||
| /** | /** | ||||
| @@ -80,8 +80,8 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public PageInfo<WxCUser> listByChannel(List<String> sceneList, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserMapper.listByChannel(sceneList)); | |||||
| public PageInfo<WxCUser> listByChannel(String tenantId, List<String> sceneList, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserMapper.listByChannel(sceneList, tenantId)); | |||||
| } | } | ||||
| @@ -110,18 +110,22 @@ | |||||
| </update> | </update> | ||||
| <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | ||||
| select count(id) from wx_c_user_basic_info where sex =#{sex} | |||||
| select count(id) from wx_c_user_basic_info | |||||
| where sex =#{sex} | |||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | and create_date >= #{startTime} | ||||
| </if> | </if> | ||||
| <if test=" null != endTime"> | <if test=" null != endTime"> | ||||
| and create_date <= #{endTime} | and create_date <= #{endTime} | ||||
| </if> | </if> | ||||
| <if test="null != tenantId"> | |||||
| and tenant_id =#{tenantId} | |||||
| </if> | |||||
| </select> | </select> | ||||
| <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | ||||
| select count(id) from wx_c_user_basic_info where birthdate is not NULL | |||||
| select count(id) from wx_c_user_basic_info where 1=1 | |||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | and create_date >= #{startTime} | ||||
| </if> | </if> | ||||
| @@ -132,16 +136,23 @@ | |||||
| <if test=" null != birthStartTime "> | <if test=" null != birthStartTime "> | ||||
| and birthdate >= #{birthStartTime} | and birthdate >= #{birthStartTime} | ||||
| </if> | </if> | ||||
| <if test=" null != birthEndTime"> | <if test=" null != birthEndTime"> | ||||
| and birthdate <= #{birthEndTime} | and birthdate <= #{birthEndTime} | ||||
| </if> | </if> | ||||
| <if test=" null == birthStartTime and null == birthEndTime"> | |||||
| and birthdate is null | |||||
| </if> | |||||
| <if test="null != tenantId"> | |||||
| and tenant_id =#{tenantId} | |||||
| </if> | |||||
| </select> | </select> | ||||
| <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | ||||
| select count(id) from wx_c_user_basic_info where 1=1 | select count(id) from wx_c_user_basic_info where 1=1 | ||||
| <if test=" null != sex "> | |||||
| and gender =#{sex} | |||||
| </if> | |||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | and create_date >= #{startTime} | ||||
| </if> | </if> | ||||
| @@ -189,8 +189,11 @@ | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <select id="listByChannel" resultMap="BaseResultMap" parameterType="java.util.List"> | |||||
| <select id="listByChannel" resultMap="BaseResultMap" > | |||||
| select id,nick_name,phone,create_date,scene_address from wx_c_user where 1=1 | select id,nick_name,phone,create_date,scene_address from wx_c_user where 1=1 | ||||
| <if test="null != tenantId"> | |||||
| and tenant_id =#{tenantId} | |||||
| </if> | |||||
| <if test=" sceneList!= null "> | <if test=" sceneList!= null "> | ||||
| and scene_address in | and scene_address in | ||||
| <foreach collection="sceneList" index="index" item="scene" open="(" separator="," close=")"> | <foreach collection="sceneList" index="index" item="scene" open="(" separator="," close=")"> | ||||