Commit c033c626 authored by zuoyh's avatar zuoyh

股東表插入、查詢

parent 8029d7c2
...@@ -155,38 +155,36 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper, ...@@ -155,38 +155,36 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
List<Integer> postionIds = data.stream().map(AppShareholderDetail::getPositionId).collect(Collectors.toList()); List<Integer> postionIds = data.stream().map(AppShareholderDetail::getPositionId).collect(Collectors.toList());
Map<Integer, AppUserPosition> postionMap = appUserPositionBiz.findPostionIdAndPostionMapByIds(postionIds); Map<Integer, AppUserPosition> postionMap = appUserPositionBiz.findPostionIdAndPostionMapByIds(postionIds);
List<AppShareholderDetailVo> AppShareholderDetailVos = new ArrayList<>(); List<AppShareholderDetailVo> appShareholderDetailVos = new ArrayList<>();
List<AppShareholderDetailVo> AppShareholderDetailMerge = new ArrayList<>(); List<AppShareholderDetailVo> appShareholderDetailMerge = new ArrayList<>();
AppShareholderDetailVo appShareholderDetailVo; AppShareholderDetailVo appShareholderDetailVo;
for (AppShareholderDetail appShareholderDetail : data) { for (AppShareholderDetail appShareholderDetail : data) {
appShareholderDetailVo = new AppShareholderDetailVo(); appShareholderDetailVo = new AppShareholderDetailVo();
BeanUtils.copyProperties(appShareholderDetail, appShareholderDetailVo); BeanUtils.copyProperties(appShareholderDetail, appShareholderDetailVo);
String postionName = postionMap == null ? "" : postionMap.get(appShareholderDetail.getPositionId()) == null ? "" : postionMap.get(appShareholderDetail.getPositionId()).getName(); String postionName = postionMap == null ? "" : postionMap.get(appShareholderDetail.getPositionId()) == null ? "" : postionMap.get(appShareholderDetail.getPositionId()).getName();
appShareholderDetailVo.setPositionName(postionName); appShareholderDetailVo.setPositionName(postionName);
AppShareholderDetailVos.add(appShareholderDetailVo); appShareholderDetailVos.add(appShareholderDetailVo);
} }
for (AppShareholderDetailVo appShareholderDetailVoOld : appShareholderDetailVos) {
for (AppShareholderDetailVo appShareholderDetailVoOld : AppShareholderDetailVos) {
boolean flag = true; boolean flag = true;
for (AppShareholderDetailVo appShareholderDetailVoNew : AppShareholderDetailMerge) { for (AppShareholderDetailVo appShareholderDetailVoNew : appShareholderDetailMerge) {
if (appShareholderDetailVoNew.getPhone().equals(appShareholderDetailVoOld.getPhone()) && appShareholderDetailVoNew.getIsQuit().equals(appShareholderDetailVoOld.getIsQuit())) {//判断姓名是否相同 if (appShareholderDetailVoNew.getPhone().equals(appShareholderDetailVoOld.getPhone()) && appShareholderDetailVoNew.getIsQuit().equals(appShareholderDetailVoOld.getIsQuit())) {//判断姓名是否相同
appShareholderDetailVoNew.setCompanyName(appShareholderDetailVoNew.getCompanyName() + "," + appShareholderDetailVoOld.getCompanyName()); appShareholderDetailVoNew.setCompanyName(appShareholderDetailVoNew.getCompanyName() + "," + appShareholderDetailVoOld.getCompanyName());
flag = false; flag = false;
} }
} }
if (flag) { if (flag) {
AppShareholderDetailMerge.add(appShareholderDetailVoOld);//给整合后集合添加子元素 appShareholderDetailMerge.add(appShareholderDetailVoOld);//给整合后集合添加子元素
} }
} }
// dataVO.setPageSize(pageDataVO.getPageSize());
dataVO.setPageSize(AppShareholderDetailMerge.size());
dataVO.setPageSize(pageDataVO.getPageSize());
// dataVO.setPageSize(AppShareholderDetailMerge.size());
dataVO.setPageNum(pageDataVO.getPageNum()); dataVO.setPageNum(pageDataVO.getPageNum());
dataVO.setData(AppShareholderDetailMerge); dataVO.setData(appShareholderDetailMerge);
dataVO.setTotalPage(AppShareholderDetailMerge.size()); dataVO.setTotalPage(pageDataVO.getTotalPage());
// dataVO.setTotalCount(pageDataVO.getTotalCount());
dataVO.setTotalCount(pageDataVO.getTotalCount()); dataVO.setTotalPage(pageDataVO.getTotalPage());
// dataVO.setTotalPage(pageDataVO.getTotalPage());
return dataVO; return dataVO;
} }
......
...@@ -2,30 +2,39 @@ ...@@ -2,30 +2,39 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.github.wxiaoqi.security.admin.mapper.AppShareholderDetailMapper"> <mapper namespace="com.github.wxiaoqi.security.admin.mapper.AppShareholderDetailMapper">
<resultMap id="appShareholderDetailMap" type="com.github.wxiaoqi.security.admin.entity.AppShareholderDetail"> <resultMap id="appShareholderDetailMap" type="com.github.wxiaoqi.security.admin.entity.AppShareholderDetail">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="companyName" column="company_name"/> <result property="companyName" column="company_name"/>
<result property="userId" column="user_id"/> <result property="userId" column="user_id"/>
<result property="phone" column="phone"/> <result property="phone" column="phone"/>
<result property="companyId" column="company_id"/> <result property="companyId" column="company_id"/>
<result property="name" column="name"/> <result property="name" column="name"/>
<result property="crtTime" column="crt_time"/> <result property="crtTime" column="crt_time"/>
<result property="isQuit" column="is_quit"/> <result property="isQuit" column="is_quit"/>
<result property="updTime" column="upd_time"/> <result property="updTime" column="upd_time"/>
<result property="positionId" column="position_id"/> <result property="positionId" column="position_id"/>
</resultMap> </resultMap>
<select id="selectShareHolderByUserIdOrPhone" resultType="java.lang.Integer"> <select id="selectShareHolderByUserIdOrPhone" resultType="java.lang.Integer">
select min(`position_id`) from `app_shareholder_detail` where `is_quit`=0 select min(`position_id`) from `app_shareholder_detail` where `is_quit`=0
<choose> <choose>
<when test="userId != null and (phone == null or phone != '')"> <when test="userId != null and (phone == null or phone != '')">
and `user_id`=#{userId} and `user_id`=#{userId}
</when> </when>
<when test="phone != null and phone != '' and userId == null"> <when test="phone != null and phone != '' and userId == null">
and `phone`=#{phone} and `phone`=#{phone}
</when> </when>
<otherwise> <otherwise>
and `user_id`=#{userId} and `user_id`=#{userId}
</otherwise> </otherwise>
</choose> </choose>
</select>
<select id="xx" resultType="com.github.wxiaoqi.security.admin.entity.AppShareholderDetail">
select max(id) as id,max(name) as `name`,max(is_quit) as `isQuit`,max(position_id) as `positionId`,phone as `phone`,group_concat(company_name) as `companyName` from app_shareholder_detail where is_quit=0 and position_id=1 group by phone
union ALL
select max(id) as id,max(name) as `name`,max(is_quit) as `isQuit`,max(position_id) as `positionId`,phone as `phone`,group_concat(company_name) as `companyName` from app_shareholder_detail where is_quit=0 and position_id=2 group by phone
union ALL
select max(id) as id,max(name) as `name`,max(is_quit) as `isQuit`,max(position_id) as `positionId`,phone as `phone`,group_concat(company_name) as `companyName` from app_shareholder_detail where is_quit=1 and position_id =1 group by phone
union all
select max(id) as id,max(name) as `name`,max(is_quit) as `isQuit`,max(position_id) as `positionId`,phone as `phone`,group_concat(company_name) as `companyName` from app_shareholder_detail where is_quit=1 and position_id =2 group by phone
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment