Commit 00c334c0 by guojuxing

导购到处调整:提供勾选参数

parent 338a1f20
package com.gic.store.dto;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
*
......@@ -22,6 +25,22 @@ public class ClerkSearchDTO implements Serializable {
private Integer clerkType;
private String storeSearch;
/**
* 门店选择器ID
*/
private Long storeResource;
/**
* 如果勾选了导购,导购ID,英文逗号隔开,用getClerkIdList方法 导出使用
*/
private String clerkIds;
/**
* 为了不与storeInfoIds错乱使用,单独使用一个 导出使用
*/
private String storeInfoIdPram;
private String fileName;
private Integer excelExtension;
private List<String> fieldCodeList;
......@@ -157,6 +176,63 @@ public class ClerkSearchDTO implements Serializable {
this.searchType = searchType;
}
public Long getStoreResource() {
return storeResource;
}
public ClerkSearchDTO setStoreResource(Long storeResource) {
this.storeResource = storeResource;
return this;
}
public String getClerkIds() {
return clerkIds;
}
public ClerkSearchDTO setClerkIds(String clerkIds) {
this.clerkIds = clerkIds;
return this;
}
public List<Integer> getClerkIdList(String suffix) {
if (clerkIds != null && clerkIds != "") {
if (suffix == null || suffix == "") {
//默认空格
suffix = ",";
}
return Arrays.stream(clerkIds.split(suffix))
.filter(e -> e != null && e != "")
.mapToInt(e -> Integer.valueOf(e))
.boxed()
.collect(Collectors.toList());
}
return new ArrayList<>();
}
public List<Integer> getStoreInfoIdParamList(String suffix) {
if (storeInfoIdPram != null && storeInfoIdPram != "") {
if (suffix == null || suffix == "") {
//默认空格
suffix = ",";
}
return Arrays.stream(storeInfoIdPram.split(suffix))
.filter(e -> e != null && e != "")
.mapToInt(e -> Integer.valueOf(e))
.boxed()
.collect(Collectors.toList());
}
return new ArrayList<>();
}
public String getStoreInfoIdPram() {
return storeInfoIdPram;
}
public ClerkSearchDTO setStoreInfoIdPram(String storeInfoIdPram) {
this.storeInfoIdPram = storeInfoIdPram;
return this;
}
@Override
public String toString() {
return "ClerkSearchDTO{" +
......@@ -175,6 +251,9 @@ public class ClerkSearchDTO implements Serializable {
", fieldCodeList=" + fieldCodeList +
", dataType=" + dataType +
", status=" + status +
", storeResource=" + storeResource +
", clerkIds=" + clerkIds +
", storeInfoIdPram=" + storeInfoIdPram +
'}';
}
}
......@@ -104,7 +104,28 @@ public interface TabClerkMapper {
* @Description:
* @author zhiwj
*/
List<TabClerk> listClerkByStoreInfoId(@Param("storeClerkIds") List<Integer> storeClerkIds, @Param("storeInfoIds") String storeInfoIds, @Param("search") String search, @Param("clerkType") Integer clerkType, @Param("status") Integer status);
List<TabClerk> listClerkByStoreInfoId(@Param("storeClerkIds") List<Integer> storeClerkIds,
@Param("storeInfoIds") String storeInfoIds,
@Param("search") String search,
@Param("clerkType") Integer clerkType,
@Param("status") Integer status);
/**
* 查询导购
* @param storeClerkIds
* @param storeInfoIds
* @param search
* @param clerkType
* @param status
* @param clerkIdList
* @return
*/
List<TabClerk> listClerkByStoreInfoIdAndClerkId(@Param("storeClerkIds") List<Integer> storeClerkIds,
@Param("storeInfoIds") String storeInfoIds,
@Param("search") String search,
@Param("clerkType") Integer clerkType,
@Param("status") Integer status,
@Param("clerkIdList") List<Integer> clerkIdList);
/**
* getTotalClerk
......@@ -118,7 +139,10 @@ public interface TabClerkMapper {
* @Description:
* @author zhiwj
*/
Integer getTotalClerk(@Param("storeClerkIds") List<Integer> storeClerkIds, @Param("search") String search, @Param("status") Integer status);
Integer getTotalClerk(@Param("storeClerkIds") List<Integer> storeClerkIds,
@Param("search") String search,
@Param("status") Integer status,
@Param("clerkIdList") List<Integer> clerkIdList);
/**
* getStoreInfoIdsBySearch
......
......@@ -124,7 +124,16 @@ public interface ClerkService {
* @throws
*/
List<TabClerk> listClerkByStoreInfoId(Integer enterpriseId, List<Integer> storeInfoIds, String search, Integer clerkType);
/**
* listClerkByStoreInfoId
* @param enterpriseId
* @param storeInfoIds
* @param search
* @return
*/
List<TabClerk> listClerkByStoreInfoId(Integer enterpriseId, List<Integer> storeInfoIds, ClerkSearchDTO search);
/**
* listClerkByStoreInfoId
* @Title: listClerkByStoreInfoId
......
......@@ -125,13 +125,25 @@ public class ClerkServiceImpl implements ClerkService {
}
@Override
public List<TabClerk> listClerkByStoreInfoId(Integer enterpriseId, List<Integer> storeInfoIdList, ClerkSearchDTO search) {
// list 如果太大, 让 mybatis 解析 会打满内存
String storeInfoIds = null;
if (CollectionUtils.isNotEmpty(storeInfoIdList)) {
storeInfoIds = "(" + storeInfoIdList.stream().map(Object::toString).collect(Collectors.joining(",")) + ")";
}
return tabClerkMapper.listClerkByStoreInfoIdAndClerkId( null,
storeInfoIds, search.getSearch(), search.getClerkType(), null,
search.getClerkIdList(null));
}
@Override
public List<TabClerk> listClerkByStoreInfoId(Integer enterpriseId, List<Integer> storeInfoIds, Integer status, String search) {
return tabClerkMapper.listClerkByStoreInfoId( storeInfoIds, null, search, null, status);
}
@Override
public Integer getTotalClerk(Integer enterpriseId, List<Integer> storeInfoIds, ClerkSearchDTO search) {
return tabClerkMapper.getTotalClerk(storeInfoIds, search.getSearch(), search.getStatus());
return tabClerkMapper.getTotalClerk(storeInfoIds, search.getSearch(), search.getStatus(), search.getClerkIdList(null));
}
@Override
......
......@@ -396,8 +396,15 @@ public class ClerkApiServiceImpl implements ClerkApiService {
storeClerkDTOList.add(clerkStoreListDTO);
storeInfoIds.add(store.getStoreInfoId());
}
//交集
if (CollectionUtils.isNotEmpty(clerkSearchDTO.getStoreInfoIdParamList(null))) {
//前端勾选的门店数据
storeInfoIds.retainAll(clerkSearchDTO.getStoreInfoIdParamList(null));
}
List<TabClerk> clerkList = clerkService.listClerkByStoreInfoId(enterpriseId, storeInfoIds,
clerkSearchDTO.getSearch(), clerkSearchDTO.getClerkType());
clerkSearchDTO);
Map<Integer, List<TabClerk>> storeIdMap = CollectionUtil.group(clerkList, "storeInfoId");
for (ClerkStoreListDTO clerkStoreListDTO : storeClerkDTOList) {
List<TabClerk> tabClerks = storeIdMap.get(clerkStoreListDTO.getStoreInfoId());
......@@ -447,6 +454,11 @@ public class ClerkApiServiceImpl implements ClerkApiService {
List<Integer> storeInfoIds = page.getResult().stream().map(StoreDTO::getStoreInfoId)
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(storeInfoIds)) {
//交集
if (CollectionUtils.isNotEmpty(clerkSearchDTO.getStoreInfoIdParamList(null))) {
//前端勾选的门店数据
storeInfoIds.retainAll(clerkSearchDTO.getStoreInfoIdParamList(null));
}
Integer totalClerk = clerkService.getTotalClerk(enterpriseId, storeInfoIds, clerkSearchDTO);
return ServiceResponse.success(totalClerk);
} else {
......@@ -474,6 +486,7 @@ public class ClerkApiServiceImpl implements ClerkApiService {
storeSearchDTO.setStoreIds(clerkSearchDTO.getStoreIds());
storeSearchDTO.setSearch(clerkSearchDTO.getStoreSearch());
storeSearchDTO.setStoreInfoIds(clerkSearchDTO.getStoreInfoIds());
storeSearchDTO.setStoreResource(clerkSearchDTO.getStoreResource());
return storeApiService.listStore(storeSearchDTO, pageNum, pageSize,
"storeId,storeName,storeCode,storeInfoId,ownType");
......
......@@ -255,6 +255,34 @@
</if>
</where>
</select>
<select id="listClerkByStoreInfoIdAndClerkId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_clerk
<where>
<if test="null != storeClerkIds and storeClerkIds.size() &gt; 0">
and store_info_id in
<foreach close=")" collection="storeClerkIds" index="index" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="storeInfoIds != null ">
and store_info_id in ${storeInfoIds}
</if>
<if test="null != clerkIdList and clerkIdList.size() &gt; 0">
and clerk_id in
<foreach close=")" collection="clerkIdList" index="index" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="search != null and search != '' ">
and (clerk_code like concat('%', #{search} ,'%') or clerk_name like concat('%', #{search} ,'%') or phone_number like concat('%', #{search} ,'%') )
</if>
<if test="status != null ">
and status = #{status}
</if>
</where>
</select>
<select id="getTotalClerk" resultType="int">
select
count(*)
......@@ -269,6 +297,12 @@
#{item}
</foreach>
</if>
<if test="null != clerkIdList and clerkIdList.size() &gt; 0">
and clerk_id in
<foreach close=")" collection="clerkIdList" index="index" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="search != null and search != '' ">
and (clerk_code like concat('%', #{search} ,'%') or clerk_name like concat('%', #{search} ,'%') or phone_number like concat('%', #{search} ,'%') )
</if>
......
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